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

when run ner, i got error : Key 'bert_model' is not in struct #153

Closed
JxuHenry opened this issue Oct 3, 2022 · 8 comments
Closed

when run ner, i got error : Key 'bert_model' is not in struct #153

JxuHenry opened this issue Oct 3, 2022 · 8 comments
Labels
enhancement New feature or request

Comments

@JxuHenry
Copy link

JxuHenry commented Oct 3, 2022

Traceback (most recent call last):
File "run_bert.py", line 93, in main
tokenizer = BertTokenizer.from_pretrained(cfg.bert_model, do_lower_case=cfg.do_lower_case)
omegaconf.errors.ConfigAttributeError: Key 'bert_model' is not in struct
full_key: bert_model
reference_type=Optional[Dict[Union[str, Enum], Any]]
object_type=dict

@JxuHenry JxuHenry added the enhancement New feature or request label Oct 3, 2022
@JxuHenry JxuHenry changed the title when run ner when run ner, i got error : Key 'bert_model' is not in struct Oct 3, 2022
@pengzju
Copy link
Collaborator

pengzju commented Oct 3, 2022

When you use bert model, please set hydra/model in config.yaml to bert.
You can get more details on https://github.com/zjunlp/DeepKE/blob/main/example/ner/standard/conf/config.yaml

@pengzju pengzju closed this as completed Oct 3, 2022
@JxuHenry
Copy link
Author

JxuHenry commented Oct 4, 2022

https://github.com/zjunlp/DeepKE/blob/main/example/ner/standard/conf/config.yaml

I got the following reslut:
precision recall f1-score support

     DVT     0.0000    0.0000    0.0000       187                                                                                         
      PE     0.0000    0.0000    0.0000       113                                                                                         
    TIME     0.0000    0.0000    0.0000       155                                                                                         

micro avg 0.0000 0.0000 0.0000 455
macro avg 0.0000 0.0000 0.0000 455
weighted avg 0.0000 0.0000 0.0000 455

[2022-10-04 00:44:12,902][main][INFO] - ***** Eval results *****
[2022-10-04 00:44:12,902][main][INFO] -
precision recall f1-score support

     DVT     0.0000    0.0000    0.0000       187                                                                                         
      PE     0.0000    0.0000    0.0000       113                                                                                         
    TIME     0.0000    0.0000    0.0000       155                                                                                         

micro avg 0.0000 0.0000 0.0000 455
macro avg 0.0000 0.0000 0.0000 455
weighted avg 0.0000 0.0000 0.0000 455

Why my model resluts were all zero ?

@pengzju pengzju reopened this Oct 4, 2022
@pengzju
Copy link
Collaborator

pengzju commented Oct 4, 2022

我建议您适当调整超参数,例如学习率learning rate,以及lstm的层数hidden_layer等等。重点关注loss是否为nan

@JxuHenry
Copy link
Author

JxuHenry commented Oct 4, 2022

我建议您适当调整超参数,例如学习率learning rate,以及lstm的层数hidden_layer等等。重点关注loss是否为nan

您好我训练的是bert模型的ner,不是lstm的模型

@pengzju
Copy link
Collaborator

pengzju commented Oct 4, 2022

那就确保您的pretrain模型是正确的,并且调整超参。建议您先在deepke现成的数据集下运行

@JxuHenry
Copy link
Author

JxuHenry commented Oct 4, 2022

那就确保您的pretrain模型是正确的,并且调整超参。建议您先在deepke现成的数据集下运行

那么我实在tran.yml中修改使用的预训练模型是么?

@JxuHenry
Copy link
Author

JxuHenry commented Oct 4, 2022

那就确保您的pretrain模型是正确的,并且调整超参。建议您先在deepke现成的数据集下运行

请问,micro avg、macro avg和weighted avg分别代表什么呢?

image

@JxuHenry JxuHenry closed this as completed Oct 4, 2022
@JxuHenry JxuHenry reopened this Oct 4, 2022
@pengzju
Copy link
Collaborator

pengzju commented Oct 4, 2022

micro avg表示微平均,表示不区分样本类别,计算整体的准确率、召回率和F1值
macro avg表示宏平均,表示所有类别对应指标的平均值。
weighted avg表示带权重平均,表示类别样本占总样本的比重与对应指标的乘积的累加和
具体可参考https://www.jianshu.com/p/757dfef76e13

@zxlzr zxlzr closed this as completed Oct 4, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants