guillaumegenthial / tf_ner

Simple and Efficient Tensorflow implementations of NER models with tf.estimator and tf.data
Apache License 2.0
923 stars 275 forks source link

how to get top-k best candidate sequences when using CRF for decoding? #47

Closed zfyu closed 5 years ago

zfyu commented 5 years ago

how to get top-k best candidate sequences when using CRF for decoding in tensorflow?

guillaumegenthial commented 5 years ago

Hi @zfyu, sorry to tell you that, but you can't! Theoretically you could, but you would need to modify the tensorflow crf implementation so that the dynamic decoding keeps track of the top k at every recurrence step.

zfyu commented 5 years ago

Thank you for your suggestion. @guillaumegenthial

createmomo commented 5 years ago

how to get top-k best candidate sequences when using CRF for decoding in tensorflow?

Hi, maybe you can consider re-implement the n-best output algorithm mentioned in this tool by yourself, https://taku910.github.io/crfpp/

zfyu commented 5 years ago

@createmomo Thank you very much. I'll try it. BTW, I found that I read your blog "CRF Layer on the Top of BiLSTM - 1" a few days ago. What a coincidence! It is very helpful!