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

Albert问题 #51

Open
wenling19 opened this issue Sep 10, 2023 · 2 comments
Open

Albert问题 #51

wenling19 opened this issue Sep 10, 2023 · 2 comments

Comments

@wenling19
Copy link

请问模型换成Albert后,会出现下面的错误是什么原因啊?
Traceback (most recent call last):
File "main.py", line 232, in
bertForNer = BertForNer(args, train_loader, dev_loader, test_loader, id2query)
File "main.py", line 31, in init
model = bert_ner_model.BertNerModel(args)
File "/root/autodl-tmp/bert/bert_ner_model.py", line 12, in init
super(BertNerModel, self).init(bert_dir=args.bert_dir, dropout_prob=args.dropout_prob)
File "/root/autodl-tmp/bert/bert_base_model.py", line 18, in init
self.bert_module = BertModel.from_pretrained(bert_dir, output_hidden_states=True,
File "/root/miniconda3/lib/python3.8/site-packages/transformers/modeling_utils.py", line 975, in from_pretrained
config, model_kwargs = cls.config_class.from_pretrained(
File "/root/miniconda3/lib/python3.8/site-packages/transformers/configuration_utils.py", line 403, in from_pretrained
assert (
AssertionError: You tried to initiate a model of type 'bert' with a pretrained model of type 'albert'

@taishan1994
Copy link
Owner

请问模型换成Albert后,会出现下面的错误是什么原因啊? Traceback (most recent call last): File "main.py", line 232, in bertForNer = BertForNer(args, train_loader, dev_loader, test_loader, id2query) File "main.py", line 31, in init model = bert_ner_model.BertNerModel(args)

可能不能使用BertModel来初始化模型,可以看看它是怎么加载的,比如是不是使用AutoModel。

1 similar comment
@taishan1994
Copy link
Owner

请问模型换成Albert后,会出现下面的错误是什么原因啊? Traceback (most recent call last): File "main.py", line 232, in bertForNer = BertForNer(args, train_loader, dev_loader, test_loader, id2query) File "main.py", line 31, in init model = bert_ner_model.BertNerModel(args)

可能不能使用BertModel来初始化模型,可以看看它是怎么加载的,比如是不是使用AutoModel。

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