PaddlePaddle / PaddleNLP

👑 Easy-to-use and powerful NLP and LLM library with 🤗 Awesome model zoo, supporting wide-range of NLP tasks from research to industrial applications, including 🗂Text Classification, 🔍 Neural Search, ❓ Question Answering, ℹ️ Information Extraction, 📄 Document Intelligence, 💌 Sentiment Analysis etc.
https://paddlenlp.readthedocs.io
Apache License 2.0
12.11k stars 2.94k forks source link

可否在paddlenlp里集成zh_dureader_ce_v2,然后使用PaddleServing pipline去调用 #4952

Closed wangjing11111111 closed 1 year ago

wangjing11111111 commented 1 year ago

请提出你的问题

[Question]: 可否在paddlenlp里集成zh_dureader_ce_v2,然后使用PaddleServing pipline去调用

w5688414 commented 1 year ago

Hi, @wangjing11111111 , zh_dureader_ce_v2的迁移在计划中,需要一定的时间。先提供一下思路: 1.利用脚本把静态图的模型转化成动态图的模型 https://github.com/PaddlePaddle/PaddleNLP/blob/develop/paddlenlp/transformers/ernie/static_to_dygraph_params/match_static_to_dygraph.py 2.然后使用下面的代码加载即可:

def test_cross_encoder():
    model_path = '/dev/rocketqa/v2_macro_cross_model'
    model = ErnieCrossEncoder(model_path,num_classes=1,reinitialize=True)
    model.eval()
    tokenizer = AutoTokenizer.from_pretrained(model_path)
    inputs = tokenizer("trigeminal definition", text_pair="Definition of TRIGEMINAL. : of or relating to the trigeminal nerve.ADVERTISEMENT. of or relating to the trigeminal nerve. ADVERTISEMENT.")
    inputs = {k:paddle.to_tensor([v]) for (k, v) in inputs.items()}
    # Get embedding of text pair.
    with paddle.no_grad():
        embedding = model.matching_v2(**inputs)
        print(embedding)
hit-zcc commented 1 year ago

如果想集成zh_dureader_de_v2 呢。

github-actions[bot] commented 1 year ago

This issue is stale because it has been open for 60 days with no activity. 当前issue 60天内无活动,被标记为stale。

github-actions[bot] commented 1 year ago

This issue was closed because it has been inactive for 14 days since being marked as stale. 当前issue 被标记为stale已有14天,即将关闭。