brightmart / albert_zh

A LITE BERT FOR SELF-SUPERVISED LEARNING OF LANGUAGE REPRESENTATIONS, 海量中文预训练ALBERT模型
https://arxiv.org/pdf/1909.11942.pdf
3.94k stars 753 forks source link

有相关onnx模型转换与调用的支持嘛? #172

Open Gmgge opened 2 years ago

Gmgge commented 2 years ago

你好,非常感谢你们开源如此棒的工作

我在尝试将模型转换为onnx,以使用推理框架onnxruntime。 我进行了以下的工作 1.参考huggingface/transformers,调用模型转换将预训练模型转换为onnx,参考教程在此 运行脚本为: python -m transformers.onnx --model "/project/gm/project/transformers/albert-chinese-tiny-train/" albert-chinese-tiny-train 结果为: Some weights of the model checkpoint at /project/gm/project/transformers/albert-chinese-tiny-train/ were not used when initializing AlbertModel: ['predictions.dense.bias', 'predics.decoder.bias', 'predictions.LayerNorm.weight', 'predictions.LayerNorm.bias', 'predictions.decoder.weight', 'predictions.dense.weight']

2.参考transformers中对onnx的模型调用,结果提示参数错误 session = InferenceSession("onnx/model.onnx") inputs = tokenizer("Using DistilBERT with ONNX Runtime!", return_tensors="np") outputs = session.run(output_names=["last_hidden_state"], input_feed=dict(inputs))

有相关提示或者文档嘛?我阅读了本项目的文档,但是没有找到相关信息,不知道是否因为有些遗漏。

如果有相关的提示或者样例代码以参考,非常感谢