kmkurn/pytorch-crf

CRF library does not work as expected

vijay120 opened this issue · 1 comments

I am using pytorch-crf to resolve tagging issues in NER, where the I-entity tag gets predicted after O (eg. O, I-person_name) or before B-entity tags (eg. I-person_name, B-person_name). Even after using pytorch-cr, I still am seeing decoded tags with the same errors as before.

I inspected the transitions, start_transitions and end_transition attributes of the CRF library (https://github.com/kmkurn/pytorch-crf/blob/master/torchcrf/__init__.py), and found that the library does not update any of these variables. They seem to be randomly initialized and then called for scoring, but these state transition variables are never updated.

Can you please provide a better understanding on why this is case, and probably provide some input on why these tag errors keep happening in-spite of using the CRF layer.

Thanks and Sincerely,
Vijay Ramakrishnan

Hi, I tested it and the variables' gradients were computed properly, so they should be updated. Can you provide a simple example where the they are not?