BERT-BiLSTM-CRF-NER-pytorch
BERT-BiLSTM-CRF-NER-pytorch copied to clipboard
Pytorch BERT-BiLSTM-CRF For NER
### _****_楼主可以分享一下预测代码嘛
您好,感谢对我再“出现wordPiece应该怎么办?”这一问题下的提问了。 是我描述不到位,我遇到的问题是: 数据集使用的Conll2003,Bert模型使用的是bert-base-cased。运行时出现如下错误: > File "D:\python-workspace\BERT-BiLSTM-CRF-NER-pytorch-master\utils.py", line 162, in convert_examples_to_features assert len(ori_tokens) == len(ntokens), f"{len(ori_tokens)}, {len(ntokens)}, {ori_tokens}, {ntokens}" AssertionError: 3, 8, ['[CLS]', '-DOCSTART-', '[SEP]'], ['[CLS]', '-', 'do', '##cs', '##tar', '##t',...
用给的官方数据集和自己的数据集测试均得到precision、recall和FB1均为0.不知道什么原因
训练好模型后,再次调用仅把do_test 设置为true,train和eval设置为false。 test的数据集里有数据,却读取不到,显示: 02/28/2022 12:44:43 - INFO - __main__ - Num examples = 0 求问这个问题该如何解决呢? 谢谢!!
extended_attention_mask = extended_attention_mask.to(dtype=next(self.parameters()).dtype) # fp16 compatibility 卡在这语句上,感觉应该是维度不匹配的问题,应该怎么修改啊?
At the predict method, if I do not specify input_mask the crf will not be able to execute decode due to `None.byte()`
这样导致原本的word和token之间对应不上。
首先感谢您的代码! 在按照您提供的数据集格式替换了自己的输入及训练数据后,最终得到的预测文件中存在测试标签偏移的情况(如图,“深”应为B-ORG,此处为test集原标签),查找源代码后发现,output文件中原预测标签(all_ori_labels)来自utils.get_Dataset的第一个返回examples(来自get_examples),是对BIO格式文件做的一个简单读取(取左列为token,取右列为label)。 我猜测可能是因为该读取未为all_ori_labels中的每个句子添加标记,导致ori_labels的开头与结尾较ori_tokens及prel缺少两个标签,因此在最后输出文件跳过标签时,吞掉了all_ori_labels第一个字的标签。不过,在训练过程中,并未引用到get_examples,而是使用了添加过这些标签的TensorDataset(),所以应该不会结果产生其他影响=) 也许您能告诉我是否是我错误注释掉了某部分代码,或有其他忽略的细节导致的错误 
Hello. I want to run your code using another pretrained BERT from https://huggingface.co/indobenchmark/indobert-large-p2. In ner.py, I have write the specific pretrained model path like this ``` model = BERT_BiLSTM_CRF.from_pretrained("/indobenchmark/indobert-large-p2", config=config,...