Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mask in crf #25

Closed
DanqingZ opened this issue Aug 6, 2020 · 2 comments
Closed

mask in crf #25

DanqingZ opened this issue Aug 6, 2020 · 2 comments

Comments

@DanqingZ
Copy link

DanqingZ commented Aug 6, 2020

您好,

请问用attention_mask做crf的mask的话,一个word假设有多个sub tokens,那这些tokens都就都keep了。在bert for ner里面,是用一个词的第一个token做的classification。

https://github.com/lonePatient/BERT-NER-Pytorch/blob/master/models/bert_for_ner.py#L64
同时在decode的时候

tags = model.crf.decode(logits, inputs['attention_mask'])

此处的mask也是attention mask。那么就会导致从CLS到SEP还有其中的所有token都会被keep,用于做decode。请问此处mask这样设置合理么?还是应该只保留每个word的第一个token呢?谢谢!

@lonePatient
Copy link
Owner

@DanqingZ 大部分中文NER数据都是char分开了,##token英文数据系多点,可以简单修改下就行了,短时间内可能没空去修改了,正在写论文。后续我对英文数据适配下 。

@DanqingZ
Copy link
Author

DanqingZ commented Aug 7, 2020

好的,明白了!那请问CLS和SEP应该keep么,如果是用attention mask这两个也传给CRF了。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants