【发布时间】:2023-03-12 15:50:01
【问题描述】:
我已从找到 here 的转换器存储库中下载了 HuggingFace BERT 模型,并希望使用 run_ner.py 脚本在自定义 NER 标签上训练模型,因为它在“命名实体识别”部分中引用了 here ”。
我在代码中将模型(“bert-base-german-cased”)、data_dir(“Data/sentence_data.txt”)和标签(“Data/labels.txt)”定义为默认值。
现在我将这个输入用于命令行:
python run_ner.py --output_dir="Models" --num_train_epochs=3 --logging_steps=100 --do_train --do_eval --do_predict
但它所做的只是告诉我:
Some weights of the model checkpoint at bert-base-german-cased were not used when initializing BertForTokenClassification: ['cls.predictions.bias', 'cls.predictions.transform.dense.weight', 'cls.predictions.transform.dense.bias', 'cls.predictions.transform.LayerNorm.w
eight', 'cls.predictions.transform.LayerNorm.bias', 'cls.predictions.decoder.weight', 'cls.seq_relationship.weight', 'cls.seq_relationship.bias']
- This IS expected if you are initializing BertForTokenClassification from the checkpoint of a model trained on another task or with another architecture (e.g. initializing a BertForSequenceClassification model from a BertForPretraining model).
- This IS NOT expected if you are initializing BertForTokenClassification from the checkpoint of a model that you expect to be exactly identical (initializing a BertForSequenceClassification model from a BertForSequenceClassification model).
Some weights of BertForTokenClassification were not initialized from the model checkpoint at bert-base-german-cased and are newly initialized: ['classifier.weight', 'classifier.bias']
You should probably TRAIN this model on a down-stream task to be able to use it for predictions and inference.
之后它就停止了,不是结束脚本,而是等待。
有谁知道这可能是什么问题?我是否缺少参数?
我的 CoNLL 格式的 sentence_data.txt 看起来像这样(小 sn-p):
Strafverfahren O
gegen O
; O
wegen O
Diebstahls O
hat O
das O
Amtsgericht Ort
Leipzig Ort
- O
Strafrichter O
这就是我在 labels.txt 中定义标签的方式:
"Date", "Delikt", "Strafe_Tatbestand", "Schadensbetrag", "Geständnis_ja", "Vorstrafe_ja", "Vorstrafe_nein", "Ort",
"Strafe_Gesamtfreiheitsstrafe_Dauer", "Strafe_Gesamtsatz_Dauer", "Strafe_Gesamtsatz_Betrag"
【问题讨论】:
标签: python machine-learning nlp bert-language-model huggingface-transformers