Add CRF layer after Transformer model
I've read a paper titled "Named Entity Recognition in Chinese Electronic Medical Records Using Transformer-CRF". 
It takes Transformer's output as CRF's input, as shown in the figure. 
Which function could I use to implement it? model.add() doesn't work.
![Screenshot_20200615_173206_cn wps moffice_eng](https://user-images.githubusercontent.com/64955334/84675939-7d782080-af5f-11ea-8d9d-9dc812b2229a.png)

You can directly feed the output of a transformer's hidden states into a CRF implementation like this https://github.com/s14t284/TorchCRF

Hope it helps!<|||||>This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
<|||||>> I've read a paper titled "Named Entity Recognition in Chinese Electronic Medical Records Using Transformer-CRF".
> It takes Transformer's output as CRF's input, as shown in the figure.
> Which function could I use to implement it? model.add() doesn't work.
> ![Screenshot_20200615_173206_cn wps moffice_eng](https://user-images.githubusercontent.com/64955334/84675939-7d782080-af5f-11ea-8d9d-9dc812b2229a.png)

小哥哥 实现了没<|||||>This repository have showed how to add a CRF layer on transformers to get a better performance on token classification task.
https://github.com/shushanxingzhe/transformers_ner<|||||>I don't think that this implementation is good. 
First, it doesn't take into account the fact that WP get padding index (usually -100) which is not expected in torchcrf and also it go over all the tags, also the one you won't use like the not first WP of a token (token==space separated string)<|||||>Does anyone have a clean implementation of a BERTCRF? Preferably in a Jupyter notebook?