-
Notifications
You must be signed in to change notification settings - Fork 611
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add conditional random fields #314
Conversation
The test cases were failing due to not masking the inputs to the RNN. |
Ping @seanpmorgan @facaiy |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for submitting this! Some initial comments, and then I'll get around to a more thorough review this week.
One thing that would be nice after this merges would be an example colab notebook as shown in the old README (but we could probably show more):
https://github.com/tensorflow/tensorflow/blob/master/tensorflow/contrib/crf/README.md
I don't know it. @qlzh727 Qianli, are you a good person to look at this? cc @WindQAQ @howl-anderson @NLP-ZY who might be interested. |
@seanpmorgan I'm making a colab notebook with usage right now, I'll open a separate PR once this merges. |
Since TF 2.0 encourages users using Keras API, implement CRF functions in the form of Keras layer will be a great feature. keras-contrib already has a CRF layer (https://github.com/keras-team/keras-contrib/blob/master/keras_contrib/layers/crf.py) which is pretty widely used in Keras community. We'd better consistent with it. |
I am working on implementing the CRF Keras layer based on Squadrick's solution. When it's ready I will post a new PR. |
@howl-anderson Will you using any of the functions implemented here? Similar to how If it's the latter, I'll close this PR and we can proceed with our approach. If it's the latter, I'll keep this open. P.S.: Implement your CRF layer under |
IMO, it's best to include both. The raw functions under What do y'all think? Any thoughts on this? @seanpmorgan @WindQAQ @facaiy |
@Squadrick CRF layer will be based on your functions (internally wraps your functions). This is a friendly feature for Keras users. low-level functions (which compatible with tf.contrib) for CRF are still very useful for advanced users and it's very important to users who migrate they code from 1.x to 2.0 and don't want to change their code on a large scale. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Haven't looked deep into the logic yet. Probably need to have some one compare the original implementation again this PR.
@qlzh727 I have some experiences with the original implementation of CRF in the tf.contrib and familiar with how CRF works, I can check/compare this PR with the original one. |
@qlzh727 @howl-anderson @seanpmorgan Modified the CRF code to use
Also, |
@Squadrick Thanks for your update |
@qlzh727 @howl-anderson Any feedback on this? |
@howl-anderson Don't worry, I am still working on it. |
you said the crf is in the tfa.text, but I not find it, are you sure that merge is successful?? |
* Rename crf_ops* -> crf* * The RNN cells inherit `AbstractRNNCell` instead of `Layer` * Remove used `training` variable * Add docstring for RNN Cells
@howl-anderson @guillaumekln @seanpmorgan Made the changes, this should be good to merge. |
@Squadrick Nice job! |
Looks great @Squadrick Thanks! Going to leave this open just for a bit to test #387 |
Assuming this is some edge case because the sanity checks are working on other PRs. Merging. Thanks @Squadrick ! |
Haha, not sure what caused the sanity check to fail. Finally got this long running PR closed. Thanks for the reviews, guys. |
@howl-anderson did you have this implementation in the tf-addons in TF 2.0? like this one: https://github.com/keras-team/keras-contrib/blob/master/keras_contrib/layers/crf.py |
Hi @lingvisa , we do have support for CRF, but as it stands today they are only TF functions: We have an open PR for wrapping these around a layer, please feel free to review and let us know if it meets your expectations. At a first glance I think the keras-contrib version is much simplier and probably benefits from not have CRF functions carried over from tf.contrib. I'll make a note in that PR to consider dropping CRF functions and adopting the keras-contrib version more or less as is |
WIP till I can resolve some of the failing test cases.Closes #22
Ref:
tf.contrib.crf