addons
addons copied to clipboard
Capability to get probabilities for each tag in crf_decode
Describe the feature and the current behavior/state. I am talking about this specific repository. https://www.tensorflow.org/addons/api_docs/python/tfa/text/crf_decode For now crf_decode function returns the tag indices with highest probability and a score for the whole sequence. But the crf_decode do not returns the probabilities for every tag for each token in sequence like we get in softmax. So I request to please add this capability because probabilities of tags help us know the confidence score and many more things.
Relevant information
- Are you willing to contribute it (yes/no): yes
- Are you willing to maintain it going forward? (yes/no): no
- Is there a relevant academic paper? (if so, where): no
- Is there already an implementation in another framework? (if so, where): I guess in pytorch
- Was it part of tf.contrib? (if so, where): yes, tf.contrib.crf.crf_decode
Which API type would this fall under (layer, metric, optimizer, etc.) It will fall under 'text'
Who will benefit with this feature? I believe many developers around the globe are looking for this feature.
Any other info. Confidence scores for any model are very important for further decisions and modifications.
Hi, we implemented the probability for each tag here: https://github.com/RasaHQ/rasa/blob/master/rasa/utils/tensorflow/crf.py
Regarding to returns the probabilities for every tag for each token in sequence
. Do you means you want the emission probability of each words?
if so, I think you can use tfa.layers.CRF
to get the potentials (as logits).
In following sample code:
layer = tfa.layers.CRF(4, use_boundary=False)
decoded_sequence, potentials, sequence_length, chain_kernel = layer(inputs)
potentials
is the thing you want.
yeah, but potentials are not probabilities. CRF also takes into account transition probabilities
there is an open PR for that: https://github.com/tensorflow/addons/pull/1935
@Ghostvv Thank you for the information you provided. I will do some investigation on the PR. Then, hopefully, do some work based on that.
TensorFlow Addons is transitioning to a minimal maintenance and release mode. New features will not be added to this repository. For more information, please see our public messaging on this decision: TensorFlow Addons Wind Down
Please consider sending feature requests / contributions to other repositories in the TF community with a similar charters to TFA: Keras Keras-CV Keras-NLP