Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

求回复:用bert-tiny做多标签分类,训练没有问题,保存了tc.config和tc.model,推理的时候在加载模型的地方报错 #12

Open
sll0107 opened this issue Mar 5, 2024 · 4 comments

Comments

@sll0107
Copy link

sll0107 commented Mar 5, 2024

self.pretrain_model = pretrained_model(self.pretrained_config) # 推理时候只需要加载超参数, 不需要预训练模型的权重

预训练模型是bert-tiny,加载用的AutotModel,不是BertModel
在tcGraph.py的这行报错,报错如下

OSError: AutoModel is designed to be instantiated using the AutoModel.from_pretrained(pretrained_model_name_or_path) or AutoModel.from_config(config) methods.

@yongzhuo
Copy link
Owner

yongzhuo commented Mar 6, 2024

huggingface/transformers#11953,transformers的__init__()初始化传参不一样导致,还是不要改成Auto的

@sll0107
Copy link
Author

sll0107 commented Mar 6, 2024 via email

@yongzhuo
Copy link
Owner

yongzhuo commented Mar 6, 2024

可以的,这是同架构的

@sll0107
Copy link
Author

sll0107 commented Mar 6, 2024 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants