BigBird
Author: thevasudevgupta
Pull request: yes

# What does this PR do?

This PR will add Google's BigBird "Roberta".

<!--
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 #6113.

This PR adds three checkpoints of BigBird:

- [bigbird-roberta-base](https://huggingface.co/google/bigbird-roberta-large)
- [bigbird-roberta-large](https://huggingface.co/google/bigbird-roberta-base)
- [bigbird-base-trivia-itc](https://huggingface.co/google/bigbird-base-trivia-itc)

Here a notebook showing how well BigBird works on long-document question answering: https://colab.research.google.com/drive/1DVOm1VHjW0eKCayFq1N2GpY6GR9M4tJP?usp=sharing

## 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.
@patrickvonplaten
<!-- 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.

Models:

- albert, bert, xlm: @LysandreJik
- blenderbot, bart, marian, pegasus, encoderdecoder,  t5: @patrickvonplaten, @patil-suraj
- longformer, reformer, transfoxl, xlnet: @patrickvonplaten
- fsmt: @stas00
- funnel: @sgugger
- gpt2: @patrickvonplaten, @LysandreJik
- rag: @patrickvonplaten, @lhoestq
- tensorflow: @jplu

Library:

- benchmarks: @patrickvonplaten
- deepspeed: @stas00
- ray/raytune: @richardliaw, @amogkam
- text generation: @patrickvonplaten
- tokenizers: @n1t0, @LysandreJik
- trainer: @sgugger
- pipelines: @LysandreJik

Documentation: @sgugger

HF projects:

- nlp datasets: [different repo](https://github.com/huggingface/nlp)
- rust tokenizers: [different repo](https://github.com/huggingface/tokenizers)

Examples:

- maintained examples (not research project or legacy): @sgugger, @patil-suraj
- research_projects/bert-loses-patience: @JetRunner
- research_projects/distillation: @VictorSanh

 -->


Comments:
Will BigBird-Pegasus be added, and then `BigBirdForConditionalGeneration` so that summarization will be possible?

Yes, we will be adding that soon.

> Will BigBird-Pegasus be added, and then `BigBirdForConditionalGeneration` so that summarization will be possible?



Once pre-trained checkpoints are uploaded to `huggingface_hub`, model & tokenizer can be accessed this way:

```python
from transformers import BigBirdForMaskedLM, BigBirdForPreTraining, BigBirdTokenizer

tokenizer = BigBirdTokenizer.from_pretrained("google/bigbird-roberta-base")

# model with LM head
model_with_lm = BigBirdForMaskedLM.from_pretrained("google/bigbird-roberta-base")

# model with pertaining heads
model_for_pretraining = BigBirdForPreTraining.from_pretrained("google/bigbird-roberta-base")
```

```python
from transformers import BigBirdConfig

# config for bigbird base
config = BigBirdConfig(hidden_size=768, num_hidden_layers=12, num_attention_heads=12, intermediate_size=3072)
# or simply
config = BigBirdConfig()

# config for bigbird trivia ckpts (both ITC & ETC)
config = BigBirdConfig(type_vocab_size=16)

# config for bigbird large
config = BigBirdConfig(hidden_size=1024, num_hidden_layers=24, num_attention_heads=16, intermediate_size=4096)
```

Running this script will enable checkpoints conversion:

```shell
python src/transformers/models/big_bird/convert_bigbird_original_tf_checkpoint_to_pytorch.py --tf_checkpoint_path ./tf_checkpoint/ckpt/model.ckpt-0 --big_bird_config_file ./tf_checkpoint/config.json --pytorch_dump_path ./hf_ckpt
```

I will fix everything up & add tests for auto padding.

Failing tests are unrelated to this PR.

@sgugger, @LysandreJik I updated the code based on your suggestions. Please let me know if I have missed something.

Thank you for taking care of the comments @vasudevgupta7 and for this PR altogether!

@vasudevgupta7 great work, when are you planning to add the BigBirdForConditionalGeneration? And any plans on adding the pubmed pre-trained models?

@sayakmisra I am currently working on it. You can track PR #10991.

@vasudevgupta7 currently loading `vasudevgupta/bigbird-pegasus-large-bigpatent` into `BigBirdForConditionalGeneration` leads to some weights of the checkpoint not being used for initializing the model. Is there a workaround for this?

Can we have separate pretrained checkpoints for BigBird and Pegasus without the finetuning, so that we can use the Pegasus decoder along with the BigBird encoder in our code?

Hey @jigsaw2212, 

we are still working on integrating `BigBirdPegasus` -> for now only the `google/bigbird-...` are fully supported. `BigBirdPegasus` will be merged in 1,2 weeks