syuoni / eznlp

Easy Natural Language Processing
Apache License 2.0
130 stars 21 forks source link

你好,请问如果想将Boundary Smoothing应用于其他模型,应该提取哪一部分的代码以应用 #42

Closed zulihit closed 8 months ago

zulihit commented 10 months ago

是只需要修改交叉熵损失哪里么,怎么能保证Boundary Smoothing的正常运行,期待您的回复,谢谢

syuoni commented 10 months ago

您好,

是的,只需要将 CE loss 修改成 Boundary smoothing loss 即可,并且修改只是改变了 ground truth 的分布(类似 Label smoothing)。实现参考此处代码:https://github.com/syuoni/eznlp/blob/29eda45aa2e13adfc76d22b2cbc229ee10fcf02a/eznlp/model/decoder/boundaries.py#L167-L185

更具体的解释请看 Boundary Smoothing for Named Entity Recognition 论文的 Methods 部分。谢谢

syuoni commented 10 months ago

另外,boundary smoothing 适用于(基本上)所有的 span-based NER 模型,只需要将 span classification 的 loss 如上所述替换即可。如果想要应用于其他框架下的模型(比如 sequence tagging),实现起来可能就比较不容易了。