MNN icon indicating copy to clipboard operation
MNN copied to clipboard

chinese-bert-wwm-ext模型怎么转换成onnx

Open sunnyzhaohui opened this issue 1 year ago • 1 comments

平台(如果交叉编译请再附上交叉编译目标平台):

Linux

Github版本:

https://github.com/alibaba/MNN/releases 2.9.0

编译方式:

下载:chinese-bert-wwm-ext 模型下载链接: https://huggingface.co/hfl/chinese-bert-wwm-ext/tree/main 方式一:使用 MNN 目录下面的 transformers/llm/export/llm_export.py 无法转换。 方式二:使用命令转换 import torch from transformers import BertModel

 model_name = "./hfl/chinese-bert-wwm-ext"
 model = BertModel.from_pretrained(model_name)

 dummy_input = (torch.zeros(1, 128, dtype=torch.long),)  # 假设输入长度为128
 torch.onnx.export(model, dummy_input, "bert_base_chinese.onnx", opset_version=11)

结果: 方式一,没有对应的--type 类型 方式二: 只有单独的bert_base_chinese.onnx 文件,没有相应的llm.onnx 和 tokenizer.txt 文件

请指点一下。

sunnyzhaohui avatar Jun 25 '24 08:06 sunnyzhaohui

这个不是用 mnn-llm 的。和 torch 类似的方式推理就好了。把 bert_base_chinese.onnx 转成 mnn 使用

jxt1234 avatar Jun 26 '24 03:06 jxt1234

Marking as stale. No activity in 60 days.

github-actions[bot] avatar Aug 25 '24 09:08 github-actions[bot]