# Add whole word mask support for lm fine-tune#7925
Conversation
|
And I wonder which version of black you use in check_code_quality. I reformat my code with black(19.10b0), and all files are left unchanged |
sgugger
left a comment
There was a problem hiding this comment.
Thanks a lot for your PR!
Before digging more in a detailed review, I have a general comment: I think this should be decoupled a bit more: you created a new class LineByLineWithRefDataset, and in the same vein, I think you should create a new DataCollator for the whole-world masking. This will make it clearer to read and easier to customize.
It would also be super nice if you could document in the README how to use your example with a chinese reference file (do you pass the script you added? or use the script you added to generate a file?)
Finish ~ @sgugger |
sgugger
left a comment
There was a problem hiding this comment.
Thanks for addressing my initial comments!
Added a few suggestions of rewording, and the last thing left is to rename the argument wwm: this is not very informative and we usually have more descriptive argument names (mlm is not ideal either, I'll fix this one in another PR). Could you replace all wwm by whole_word_masking? Thanks!
| export TEST_FILE=/path/to/dataset/wiki.test.raw | ||
| export REF_FILE=/path/to/ref.txt | ||
|
|
||
| python run_language_modeling.py \ |
There was a problem hiding this comment.
Can we leave one version with just mlm and no wwm first?
There was a problem hiding this comment.
Sure, I update my readme, it's same with English version if only mlm.
| def _dataset(file_path): | ||
| if args.line_by_line: | ||
| if args.chinese_ref_file: | ||
| if not args.wwm or args.mlm: |
There was a problem hiding this comment.
The test is not consistent with the error message that wants both of those to be True.
Co-authored-by: Sylvain Gugger <[email protected]>
Co-authored-by: Sylvain Gugger <[email protected]>
Co-authored-by: Sylvain Gugger <[email protected]>
Co-authored-by: Sylvain Gugger <[email protected]>
Co-authored-by: Sylvain Gugger <[email protected]>
Co-authored-by: Sylvain Gugger <[email protected]>
|
thx! |
|
Looking good to me except for the code quality. If you don't manage to fix it, I can force-push on your branch. |
OK, I tried to fix it but failed :( |
|
Just made the necessary change. Note that this wasn't styling that caused the isse but the code quality in general. |
LysandreJik
left a comment
There was a problem hiding this comment.
This mostly looks good to me except I don't fully understand why we need the reference file. What's LTP? Why do we need reference files? Can this be explained in the README?
Thanks for your question. Q : Why LTP ? @LysandreJik hope this would help. |
LysandreJik
left a comment
There was a problem hiding this comment.
Okay, I think I understand it better now. Thanks for adding your explanation to the README.
|
@wlhgtc ltp is not added to the requirements.txt under examples folder |
Thanks for your notice. I forgot add it to requirements.txt. |
Thanks, I also just tried, ltp requires transformer==3.2. I have no idea why. so have to install ltp with on dependency. Very annoying. By the way, thanks for the excellent work. one more bug looks like when doing eval, it is referring to the ref file for the training data. if I set train_data = test_data. It goes through fine. Did I do something wrong? I am trying to follow your process as close as I can |
|
This PR add support for wwm (whole word mask) proxy when fine-tune BERT like model.
And it can be divided into two part : English Model Support and Chinese Model Support
For English, it's simple. The original tokenizer res contains symbols like '##ing'.
I just use the same mask proxy in data_collator.py by Google.
For Chinese, it's hard. We need to rely on (word level) tokenizer, cause BERT is char level in Chinese.
So I do things as follow to get word level tokens:
Then, it's all same to English.
And I add two parameters (
wwmandchinese_ref_path) to run lm.