keras-nlp icon indicating copy to clipboard operation
keras-nlp copied to clipboard

Add Pure Keras 3 CRF Layer with Native Loss and Viterbi Decoding for Sequence Labeling

Open gcuder opened this issue 8 months ago • 0 comments

Is your feature request related to a problem? Please describe.
Currently, Keras-hub lacks a pure Keras 3 implementation of a CRF layer. This forces users to rely on external libraries like TensorFlow Addons, which can introduce dependency and compatibility issues as TFA is already deprecated.

Describe the solution you'd like
I'd like to implement a native CRF layer in Keras-hub that:

  • Computes CRF log-likelihood loss during training.
  • Applies Viterbi decoding during inference.
  • Integrates seamlessly with Keras 3’s API.
    Include clear documentation and usage examples.

Describe alternatives you've considered
Using TensorFlow Addons for CRF functionality was considered, but it adds deprecated dependencies that might cause conflicts.

Additional context

https://www.tensorflow.org/addons/api_docs/python/tfa/layers/CRF

gcuder avatar Mar 02 '25 10:03 gcuder