liuyukid / transformers-ner

Pytorch-Named-Entity-Recognition-with-transformers
209 stars 44 forks source link

Keyerror while evaluting model #14

Closed laleye closed 3 years ago

laleye commented 3 years ago

I got this error while evaluting model after the first epoch. I'm using the roberta+crf with the script run_crf_ner.py.

File "token_classification/roberta_train.py", line 336, in evaluate preds_list[i].append(label_map[preds[i][j]]) KeyError: -1

If someone has already encountered this error, please help to understand why since my label ids don't contain -1 value.

liuyukid commented 3 years ago

I'm sorry that there may be a bug in my code, but I can't help you locate the error。 You can try run_span_ner.py, which should work better than run_crf_ner.py

laleye commented 3 years ago

Thanks for your response. By using run_span_ner, I was able to run an exp after fixing a small bug on line 232: adv.adversarial_training(args, inputs, optimizer) insted of adv.training(args, inputs, optimizer). I can do a pull request if you don't have time to correct it and if I have the rights.

Hansyvea commented 3 years ago

has this issue been solved by now?