Closed wangjing11111111 closed 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)
如果想集成zh_dureader_de_v2 呢。
This issue is stale because it has been open for 60 days with no activity. 当前issue 60天内无活动,被标记为stale。
This issue was closed because it has been inactive for 14 days since being marked as stale. 当前issue 被标记为stale已有14天,即将关闭。
请提出你的问题
[Question]: 可否在paddlenlp里集成zh_dureader_ce_v2,然后使用PaddleServing pipline去调用