MPNet: Masked and Permuted Pre-training for Language Understanding
Author: StillKeepTry
Pull request: yes

# Model addition
[MPNet](https://arxiv.org/abs/2004.09297)

## Model description
MPNet introduces a novel self-supervised objective named masked and permuted language modeling for language understanding. It inherits the advantages of both the masked language modeling  (MLM) and the permuted language modeling (PLM) to addresses the limitations of MLM/PLM, and further reduce the inconsistency between the pre-training and fine-tuning paradigms.

# What does this PR do?

<!--
Congratulations! You've made it this far! You're not quite done yet though.

Once merged, your PR is going to appear in the release notes with the title you set, so make sure it's a great title that fully reflects the extent of your awesome contribution.

Then, please replace this with a description of the change and which issue is fixed (if applicable). Please also include relevant motivation and context. List any dependencies (if any) that are required for this change.

Once you're done, someone will review your PR shortly (see the section "Who can review?" below to tag some potential reviewers). They may suggest changes to make the code even better. If no one reviewed your PR after a week has passed, don't hesitate to post a new comment @-mentioning the same persons---sometimes notifications get lost.
-->

<!-- Remove if not applicable -->

Fixes # (issue)


## Before submitting
- [x] This PR fixes a typo or improves the docs (you can dismiss the other checks if that's the case).
- [x] Did you read the [contributor guideline](https://github.com/huggingface/transformers/blob/master/CONTRIBUTING.md#start-contributing-pull-requests),
      Pull Request section?
- [x] Was this discussed/approved via a Github issue or the [forum](https://discuss.huggingface.co/)? Please add a link
      to it if that's the case.
- [x] Did you make sure to update the documentation with your changes? Here are the
      [documentation guidelines](https://github.com/huggingface/transformers/tree/master/docs), and
      [here are tips on formatting docstrings](https://github.com/huggingface/transformers/tree/master/docs#writing-source-documentation).
- [x] Did you write any new necessary tests?


## Who can review?

Anyone in the community is free to review the PR once the tests have passed. Feel free to tag
members/contributors which may be interested in your PR.

<!-- Your PR will be replied to more quickly if you can figure out the right person to tag with @

 If you know how to use git blame, that is the easiest way, otherwise, here is a rough guide of **who to tag**.
 Please tag fewer than 3 people.

 albert, bert, XLM: @LysandreJik
 GPT2: @LysandreJik, @patrickvonplaten
 tokenizers: @mfuntowicz
 Trainer: @sgugger
 Benchmarks: @patrickvonplaten
 Model Cards: @julien-c
 examples/distillation: @VictorSanh
 nlp datasets: [different repo](https://github.com/huggingface/nlp)
 rust tokenizers: [different repo](https://github.com/huggingface/tokenizers)
 Text Generation: @patrickvonplaten, @TevenLeScao
 Blenderbot, Bart, Marian, Pegasus: @patrickvonplaten
 T5: @patrickvonplaten
 Rag: @patrickvonplaten, @lhoestq
 EncoderDecoder: @patrickvonplaten
 Longformer, Reformer: @patrickvonplaten
 TransfoXL, XLNet: @TevenLeScao, @patrickvonplaten
 examples/seq2seq: @patil-suraj
 examples/bert-loses-patience: @JetRunner
 tensorflow: @jplu
 examples/token-classification: @stefan-it
 documentation: @sgugger
 FSTM: @stas00
 -->


Comments:
Hey @StillKeepTry - could you maybe link the paper corresponding to your model add a small PR description? :-) That would be very helpful

Thanks for the new PR @StillKeepTry - could you add a `test_modeling_mpnet.py` file - it would be important to test the model :-) 

Also it would be amazing if you could give some context of MPNet - is there a paper, blog post, analysis, results that go along with the model? And are there pretrained weights? 

Thanks a lot! 

> Thanks for the new PR @StillKeepTry - could you add a `test_modeling_mpnet.py` file - it would be important to test the model :-) 
> 
> 
> 
> Also it would be amazing if you could give some context of MPNet - is there a paper, blog post, analysis, results that go along with the model? And are there pretrained weights? 
> 
> 
> 
> Thanks a lot! 

https://arxiv.org/abs/2004.09297

> > Thanks for the new PR @StillKeepTry - could you add a `test_modeling_mpnet.py` file - it would be important to test the model :-)
> > Also it would be amazing if you could give some context of MPNet - is there a paper, blog post, analysis, results that go along with the model? And are there pretrained weights?
> > Thanks a lot!
> 
> https://arxiv.org/abs/2004.09297

ok

Oh and another thing to do after the merge will be to add your new model to the main README and the documentation so that people can use it! The template should give you a file for the `.rst` (or you can use `docs/model_doc/bert.rst` as an example).

I have updated `test_modeling_mpnet.py` now.

Hi, every reviewer. Thank you for your valuable reviews. I have fixed previous comments (like doc, format, and so on) and updated the `tokenization_mpnet.py` and `tokenization_mpnet_fast.py` by removing the inheritance. Besides, I also upload test files (`test_modeling_mpnet.py`, `test_modeling_tf_mpnet.py`) for testing, and model weights into the model hub. 

Fantastic, thanks for working on it! Will review today.

@patrickvonplaten Hi, are there any new comments?

Hello!

Still some comments:

1. Update the inputs handling in the TF file, we have merged an update for the booleans last Friday. You can see an example in the TF BERT file if you need one.
2. rebase and fix the conflicting files.
3. Fix the check_code_quality test.

I think something went wrong with the merge here :-/ Could you try to open a new PR that does not include all previous commits or fix this one? 

> I think something went wrong with the merge here :-/ Could you try to open a new PR that does not include all previous commits or fix this one?

OK, it seems something wrong when I update to the latest version. :(

@patrickvonplaten @JetRunner @sgugger @LysandreJik @jplu The new PR is moved to [https://github.com/huggingface/transformers/pull/8971](https://github.com/huggingface/transformers/pull/8971)