-
Notifications
You must be signed in to change notification settings - Fork 26.4k
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
Added cleaned configuration properties for tokenizer with serialization - improve tokenization of XLM #1092
Conversation
…anguages except zh, ja and th; Change API to allow specifying language in `tokenize`
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 a lot for all this work, it's great!
I've made a few comments on things to update. Mostly that we are only going to add sacremoses
as required dependencies and raise error messages for the others.
I need to do a few modifications up-stream as mentioned in the comments to make it easier here.
Will do it in another PR so you can have a look.
Codecov Report
@@ Coverage Diff @@
## master #1092 +/- ##
==========================================
+ Coverage 79.61% 79.71% +0.09%
==========================================
Files 42 42
Lines 6898 7010 +112
==========================================
+ Hits 5492 5588 +96
- Misses 1406 1422 +16
Continue to review full report at Codecov.
|
Hi @shijie-wu, |
Ok I think this is good to go. Let's merge it. |
This PR improve the tokenization of XLM. It's mostly the same as the preprocessing in the original XLM. This PR also add
use_lang_emb
to config of XLM model, which makes adding the newly release XLM-17 & XLM-100 easier since both of them don't have language embedding.Details on tokenization:
XLMTokenizer.tokenize(self, text)
toXLMTokenizer.tokenize(text, lang='en')
* XLM used Stanford Segmenter. However, the wrapper (
nltk.tokenize.stanford_segmenter
) are slow due to JVM overhead, and it will be deprecated. Jieba is a lot faster and pip-installable. But there is some mismatch with the Stanford Segmenter. A workaround could be having an argument to allow users to segment the sentence by themselves and bypass the segmenter. As a reference, I also includenltk.tokenize.stanford_segmenter
in this PR.Example of tokenization difference could be found here.