pytorch-crf icon indicating copy to clipboard operation
pytorch-crf copied to clipboard

issues about the parameter "num_tags" of the CRF()?

Open XFR1998 opened this issue 2 years ago • 1 comments

I would like to know the the parameter "num_tags" of the CRF()? should the tagset={'O':0, 'B':1, 'I':2, '': 3, '': 4} include these two labels:'', ''?

because I need to ensure the hidden_size in the fully connected layer follow the lstm self.fc = nn.Linear(configs.hidden_size*self.num_directions, num_tags)
crf.decode(emissions=lstm_feats, mask=mask_tensor)

Thanks~

XFR1998 avatar Mar 20 '22 14:03 XFR1998

Hi, I'm not sure I understand the question. Basically, num_tags should be set to the size of possible tags for a token. So, if your task is NER with 3 entities: PER, LOC, and ORG, then you'll have 7 tags: O, B-PER, I-PER, B-LOC, I-LOC, B-ORG, and I-ORG. So, you set num_tags=7. Let me know if you still have questions.

kmkurn avatar Apr 16 '22 02:04 kmkurn