noamaanMulla-03/transformers-issues huggingface dataset:
RAG : Can we fine-tune RAG with update frequency method similar to Fairseq framework?
Author: shamanez
Pull request: no

RAG fine-tune script needs 8 GPUs to train. Is there any chance that the training can be done with less number of GPUs using the update frequency? 

Comments:
Hey @shamanez - what do you mean by "update frequency"? You don't need to use 8 GPUS => you can just reduce the number of gpus as you wish and keep the "same" batch size by increasing the `gradient_accumulation_steps` - does this make sense? 

Let's say if the effective batch size is 32 with 8 GPUs and I want to keep the same batch size with 4 GPUs, I just need to change the _gradient_accumulation_steps_ to 2 right?

[Update_Freq](https://fairseq.readthedocs.io/en/latest/command_line_tools.html#fairseq-train) is what fairseq used to keep the effective batch size same with less number of GPUs.

Yeah exactly, in `examples/rag/finetune.sh` the default is `gpus=8` and `gradient_accumalation_steps=1`. So if you want to use less gpus while keeping the same "effective" batch size you should increase `gradient_accumalation_steps` accordingly

Thanks a lot. :)
Fix wrong reference name/filename in docstring of `SquadProcessor`
Author: phiyodr
Pull request: yes


# 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 #7613 

Replace wrong filenames in docstring:  `train-v1.1.json`/`train-v2.0.json` -> `dev-v1.1.json`/`dev-v2.0.json` 


## Before submitting
- [x] This PR fixes a typo or improves the docs (you can dimiss 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 the 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).
- [ ] 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, GPT2, XLM: @LysandreJik 
 tokenizers: @mfuntowicz
 Trainer: @sgugger
 Speed and Memory Benchmarks: @patrickvonplaten
 Model Cards: @julien-c
 Translation: @sshleifer
 Summarization: @sshleifer
 TextGeneration: @TevenLeScao 
 examples/distillation: @VictorSanh
 nlp datasets: [different repo](https://github.com/huggingface/nlp)
 rust tokenizers: [different repo](https://github.com/huggingface/tokenizers)
 Text Generation: @TevenLeScao
 Blenderbot, Bart, Marian, Pegasus: @sshleifer
 T5: @patrickvonplaten
 Longformer/Reformer: @patrickvonplaten
 TransfoXL/XLNet: @TevenLeScao 
 examples/seq2seq: @sshleifer
 examples/bert-loses-patience: @JetRunner
 tensorflow: @jplu
 examples/token-classification: @stefan-it
 documentation: @sgugger
 -->

Comments:
SquadProcessor: Wrong reference name/filename in docstring
Author: phiyodr
Pull request: no

As the docstring of the function `get_train_examples()` refers to  `train-v1.1.json`/`train-v2.0.json`, I guess `get_dev_examples()` should refer to `dev-v1.1.json`/`dev-v2.0.json` (but refers to `train-v1.1.json`/`train-v2.0.json`):

https://github.com/huggingface/transformers/blob/aa6c3c14b4ff8fbd5d40b100f4aae71fb359d6ae/src/transformers/data/processors/squad.py#L610-L617

Comments:
Indeed! Do you want to open a PR fixing the doc?

Yes, I can do that. :)
Fix tokenizer UnboundLocalError when padding is set to PaddingStrategy.MAX_LENGTH
Author: GabrielePicco
Pull request: yes

# 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 #7609 

## Who can review?

 tokenizers: @mfuntowicz

Comments:
Thanks!
Tokenizer: UnboundLocalError with PaddingStrategy MAX_LENGTH
Author: GabrielePicco
Pull request: no

## Environment info
<!-- You can run the command `transformers-cli env` and copy-and-paste its output below.
     Don't forget to fill out the missing fields in that output! -->
     
- `transformers` version: 3.1.0
- Platform: macOS-10.15.7-x86_64-i386-64bit
- Python version: 3.8.5
- PyTorch version (GPU?): 1.6.0 (False)
- Tensorflow version (GPU?): not installed (NA)
- Using GPU in script?: no
- Using distributed or parallel set-up in script?: no


### Who can help
 
 tokenizers: @mfuntowicz

## Information

Model I am using: <transformers.tokenization_bert.BertTokenizer>

The problem arises when using:
* the official example scripts: 
using the `encode_plus`

The tasks I am working on is:
* Tokenizing

## To reproduce

Steps to reproduce the behavior:

1. tokenizer = AutoTokenizer.from_pretrained("bert-base-cased")
2. tokenizer.encode_plus("hello word", max_length=128, padding=PaddingStrategy.MAX_LENGTH)

<!-- If you have code snippets, error messages, stack traces please provide them here as well.
     Important! Use code tags to correctly format your code. See https://help.github.com/en/github/writing-on-github/creating-and-highlighting-code-blocks#syntax-highlighting
     Do not use screenshots, as they are hard to read and (more importantly) don't allow others to copy-and-paste your code.-->

`UnboundLocalError: local variable 'padding_strategy' referenced before assignment`

## Expected behavior

Return Tokenizer output

Comments:
Converting Tensorflow checkpoint to Pytorch not work for TF models downloaded using TFAutoModel.from_pretrained()
Author: gh-yewang
Pull request: no

# ❓ Questions & Help

<!-- The GitHub issue tracker is primarly intended for bugs, feature requests,
     new models and benchmarks, and migration questions. For all other questions,
     we direct you to the Hugging Face forum: https://discuss.huggingface.co/ .
     You can also try Stack Overflow (SO) where a whole community of PyTorch and
     Tensorflow enthusiast can help you out. In this case, make sure to tag your
     question with the right deep learning framework as well as the
     huggingface-transformers tag: 
     https://stackoverflow.com/questions/tagged/huggingface-transformers 
     -->

## Details
<!-- Description of your issue -->
I took a try of converting tf checkpoint to pytorch and it works well on the model that in the links on your [page](https://huggingface.co/transformers/converting_tensorflow_models.html)
However, the conversion seems not working with models(bert, albert..) that downloaded using TFAutoModel.from_pretrained()
I am wondering if I miss anything or those models are not currently supported?

Thanks
<!-- You should first ask your question on the forum or SO, and only if
     you didn't get an answer ask it here on GitHub. -->
**A link to original question on the forum/Stack Overflow**:

Comments:
Could you provide an example code that didn't work?

Providing the example for repo as below(e.g. let's try bert):
`from transformers import AutoConfig, TFAutoModel, BertForPreTraining, load_tf_weights_in_bert`
`model_name = "bert-base-uncased"`
`config = AutoConfig.from_pretrained(model_name)`
`tf_model = TFAutoModel.from_pretrained(model_name, config)#get the tf model using TFAutoModel`
`tf_model.save_weights("./bert")#save tf model to ckpt`
`pt_model = BertForPreTraining(config)#init pt model`
`load_tf_weights_in_bert(pt_model, config, "./")#convert tf ckpt to pt model`

You should use `save_pretrained` and `from_pretrained` to do the conversion:

```py
tf_model.save_pretrained("./bert")
pt_model = BertForPreTraining.from_pretrained("./bert", from_tf=True)
```

Yes, the conversion above works for me. But it seems to me that load_tf_weights_in_bert() works only with limited Bert model if I want to convert tensorflow checkpoint to a pytorch model.

The `load_tf_weights_in_bert` method is meant to be used to convert BERT models from the original implementation (google-research/bert), not to do the conversion between our architectures in PyTorch <>  our architectures in TensorFlow.

Closing as the conversion shown worked!

Thanks! @LysandreJik
position_ids parameter cannot work with past parameter for GPT2Model during batch inference
Author: gmftbyGMFTBY
Pull request: no

# ❓ Questions & Help

<!-- The GitHub issue tracker is primarly intended for bugs, feature requests,
     new models and benchmarks, and migration questions. For all other questions,
     we direct you to the Hugging Face forum: https://discuss.huggingface.co/ .
     You can also try Stack Overflow (SO) where a whole community of PyTorch and
     Tensorflow enthusiast can help you out. In this case, make sure to tag your
     question with the right deep learning framework as well as the
     huggingface-transformers tag: 
     https://stackoverflow.com/questions/tagged/huggingface-transformers 
     -->

## Details
<!-- Description of your issue -->
Hi, @patrickvonplaten.  I just finished training a GPT-2 model by using the `GPT2Model` class, and I try to speed up the inference by using the batch inference (very similar to #3021 ). However, I found that the `position_ids` parameter cannot work with the `past` parameter, and it raises the Error: `RuntimeError: The size of tensor a (32) must match the size of tensor b (2592) at non-singleton dimension 0`.
![微信图片_20201007002211](https://user-images.githubusercontent.com/27548710/95229447-2b6f4980-0833-11eb-8cf4-07465f8935ec.png)
I found the exception happens in the `modeling_gpt2.py` line 471, so I check the original codes of the `GPT2Model` class. In `modeling_gpt2.py` line 426 to line 427 (line 558 to line 559 in the lastest original code):
```python
if position_ids is not None:
    position_ids = position_ids.view(-1, input_shape[-1])
```

Actually, during using the `past` parameter for speeding up the inference, the input_shape is `[batch_size, 1]`, but the `position_ids` is `[batch_size, seq_length]`. So, when we use the `past` and `position_ids` at the same time, the position_ids will be converted into a wrong shape `[batch_size*seq_length, 1]` (the shape we want should be `[batch_size, seq_length]`). For example, as shown in the figure, the `batch_size` is 32 and the `seq_length` is 81, and the generated position_ids shape is `[2592, 1]` (32*81=2592), but the correct position_ids shape should be `[32, 81]`.
So I think it may be a bug, but I am not so sure about it. Can you guys help me to figure it out?

Here are the environment variables in my system:
* transformers==2.11.0
* pytorch==1.5.1
* python==3.6.11

<!-- You should first ask your question on the forum or SO, and only if
     you didn't get an answer ask it here on GitHub. -->
**A link to original question on the forum/Stack Overflow**:

Comments:
Hey @gmftbyGMFTBY - I think the better approach to tackle your problem would actually be this one here: https://github.com/huggingface/transformers/issues/3021#issuecomment-681792104 .

This way you should not run into any errors regarding the position_ids

Hey, @patrickvonplaten, it works for me. Thank you so mcuh.
code copy button on the website doesn't copy `...` lines
Author: stas00
Pull request: no
Labels: name: wontfix

# 🐛 Bug

## Information

When the copy button is clicked on a code like [this](https://huggingface.co/transformers/quicktour.html#using-the-tokenizer):

```
>>> pt_batch = tokenizer(
...     ["We are very happy to show you the 🤗 Transformers library.", "We hope you don't hate it."],
...     padding=True,
...     truncation=True,
...     return_tensors="pt"
... )
```

only the first line is copied. 

All lines starting with `>>>` get copied, but `...` lines are ignored. So for example, [this](https://huggingface.co/transformers/quicktour.html#customizing-the-model) gets fully copied:

```
>>> from transformers import DistilBertConfig, DistilBertTokenizer, DistilBertForSequenceClassification
>>> config = DistilBertConfig(n_heads=8, dim=512, hidden_dim=4*512)
>>> tokenizer = DistilBertTokenizer.from_pretrained('distilbert-base-uncased')
>>> model = DistilBertForSequenceClassification(config)
```

I was told that this is the issue with `sphinx_copybutton` and I found an already opened issue there:
https://github.com/executablebooks/sphinx-copybutton/issues/65

So hopefully it gets fixed over there, and then the website can be updated to include the fix.




Comments:
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.


this seems to have been fixed in sphinx - I re-checked and it works now.
add xlm-roberta-large-xnli model card
Author: joeddav
Pull request: yes
Labels: name: model card


Comments:
# [Codecov](https://codecov.io/gh/huggingface/transformers/pull/6723?src=pr&el=h1) Report
> Merging [#6723](https://codecov.io/gh/huggingface/transformers/pull/6723?src=pr&el=desc) into [master](https://codecov.io/gh/huggingface/transformers/commit/a25c9fc8e14f3e8914116e6142af2a9589dc8e63?el=desc) will **decrease** coverage by `0.04%`.
> The diff coverage is `n/a`.

[![Impacted file tree graph](https://codecov.io/gh/huggingface/transformers/pull/6723/graphs/tree.svg?width=650&height=150&src=pr&token=9qOlN6Hb1c)](https://codecov.io/gh/huggingface/transformers/pull/6723?src=pr&el=tree)

```diff
@@            Coverage Diff             @@
##           master    #6723      +/-   ##
==========================================
- Coverage   79.00%   78.96%   -0.05%     
==========================================
  Files         156      156              
  Lines       28405    28405              
==========================================
- Hits        22442    22429      -13     
- Misses       5963     5976      +13     
```


| [Impacted Files](https://codecov.io/gh/huggingface/transformers/pull/6723?src=pr&el=tree) | Coverage Δ | |
|---|---|---|
| [src/transformers/generation\_tf\_utils.py](https://codecov.io/gh/huggingface/transformers/pull/6723/diff?src=pr&el=tree#diff-c3JjL3RyYW5zZm9ybWVycy9nZW5lcmF0aW9uX3RmX3V0aWxzLnB5) | `80.70% <0.00%> (-3.01%)` | :arrow_down: |
| [src/transformers/file\_utils.py](https://codecov.io/gh/huggingface/transformers/pull/6723/diff?src=pr&el=tree#diff-c3JjL3RyYW5zZm9ybWVycy9maWxlX3V0aWxzLnB5) | `82.41% <0.00%> (-0.26%)` | :arrow_down: |

------

[Continue to review full report at Codecov](https://codecov.io/gh/huggingface/transformers/pull/6723?src=pr&el=continue).
> **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta)
> `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
> Powered by [Codecov](https://codecov.io/gh/huggingface/transformers/pull/6723?src=pr&el=footer). Last update [a25c9fc...715d491](https://codecov.io/gh/huggingface/transformers/pull/6723?src=pr&el=lastupdated). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments).


Merging so I can tweet, but lmk if anything is off and I'll update it.

looks good! Fixed tiny typos in 3242e4d9

Hi @joeddav! Could you share your hyperparameters for training the model (I assume you used the `run_glue`)? Would you say that the last phase of training helped significantly?
RAG: NameError: name 'load_dataset' is not defined
Author: shamanez
Pull request: no

I tried to load RAG according to the documentation. 

` retriever = RagRetriever.from_pretrained("facebook/rag-token-base", index_name="exact", use_dummy_dataset=True)
`

The above line gave the following error.

**/python3.6/site-packages/transformers/retrieval_rag.py", line 220, in __init__
    self.dataset = load_dataset(
NameError: name 'load_dataset' is not defined**

Comments:
I think this is a duplicate of #7536. RAG requires datasets and faiss to be installed in your environment to work properly.
The fix with proper error messages is on in #7537.
ImportError: cannot import name 'RobertaLMHeadModel'
Author: earendil91
Pull request: no

Hi all, I was just trying to run a text generation script for low-resource languages, and therefore experimented with XLM-R and initially with Roberta, using the documentation for RobertaForCausalLM:
here: https://huggingface.co/transformers/model_doc/roberta.html#robertaforcausallm

I am running into the import error shown in the title. See code snippet and error message below. I also experimented with different Tensorflow and transformers versions to no avail. I suspect that the model classes have changed (or the documentation may not be up to date with the current version). I also tried importing RobertaForCausalLM but it returned the same error.

## Environment info     
- `transformers` version: 3.1.0
- Platform: Linux-4.15.0-112-generic-x86_64-with-Ubuntu-18.04-bionic
- Python version: 3.6.9
- Tensorflow version: 2.3.1


### Who can help
@LysandreJik , @TevenLeScao
 
Model I am using (**Roberta**, **XLM-Roberta**):

The problem arises when using:
* [X] the official example scripts: (give details below)
* [ ] my own modified scripts: (give details below)

The tasks I am working on is:
* [ ] an official GLUE/SQUaD task: (give the name)
* [X] my own task or dataset: (give details below)

## To reproduce
Steps to reproduce the behavior:

1. Run:
```
from transformers import RobertaTokenizer, RobertaLMHeadModel, RobertaConfig
import torch
tokenizer = RobertaTokenizer.from_pretrained('roberta-base')
config = RobertaConfig.from_pretrained("roberta-base")
config.is_decoder = True
model = RobertaLMHeadModel.from_pretrained('roberta-base', config=config, return_dict=True)
inputs = tokenizer("Hello, my dog is cute", return_tensors="pt")
outputs = model(**inputs)
prediction_logits = outputs.logits
```

Error: `ImportError: cannot import name 'RobertaLMHeadModel'`

If this script runs succesfully, I 'd like to re-run it for XMLRoberta (changing the imports and model names of course).
Many thanks!

Comments:
The newly added config decoder_start_token_id for bart-base model is wrong?
Author: fomalhautb
Pull request: no

The new config file for `bart-base` has been updated on October 5.th.  The new config file looks like the following:
```
{
  ...
  "bos_token_id": 0,
  ...
  "decoder_start_token_id": 2,
  ...
  "eos_token_id": 2,
  ...
}
```

the `decoder_start_token_id` was added newly, it wasn't there before. But as far I understand, the `decoder_start_token_id` should be `bos_token_id` as default . The newly added config-line changed the behavior for the `generate` function.

Comments:
A similar problem is here [#5212](https://github.com/huggingface/transformers/issues/5212)

Moved there.
Unrecognized configuration class <class 'transformers.configuration_electra.ElectraConfig'>
Author: cktsangal
Pull request: no

# 🐛 Bug

## Information

Model I am using : ahotrod/electra_large_discriminator_squad2_512

This problem happened again, when I use ELECTRA on question-answering pipeline. My Transformers version is 2.11.0.

Code:
> from transformers import pipeline, AutoTokenizer, AutoModelForQuestionAnswering
> 
> tokenizer = AutoTokenizer.from_pretrained("ahotrod/electra_large_discriminator_squad2_512")
> model = AutoModelForQuestionAnswering.from_pretrained("ahotrod/electra_large_discriminator_squad2_512")

Error:

> Traceback (most recent call last):
>   File "albert_qa.py", line 5, in <module>
>     model = AutoModelForQuestionAnswering.from_pretrained("ahotrod/electra_large_discriminator_squad2_512")
>   File "/home/aim/ANDY-project/sentence-transformers-env/lib/python3.6/site-packages/transformers/modeling_auto.py", line 1004, in from_pretrained
>     ", ".join(c.__name__ for c in MODEL_FOR_QUESTION_ANSWERING_MAPPING.keys()),
> ValueError: Unrecognized configuration class <class 'transformers.configuration_electra.ElectraConfig'> for this kind of AutoModel: AutoModelForQuestionAnswering.


- `transformers` version: 2.11.0
- Platform: Ubuntu
- Python version: 3.6.9
- PyTorch version (GPU?): 1.5.1


Comments:
Hi! Even though the ELECTRA model was added in version v2.8.0, the `ElectraForQuestionAnswering` head was only added in v3.0.0. You would need to upgrade your `transformers` version to at at least v3.0.0 for your code to work!

I am trying to use pretrained Distilbert in EncoderDecoderModel but i am getting this error. How can i leverage pretrained distilbert in EncoderDecoderModel.

`ValueError: Unrecognized configuration class <class 'transformers.configuration_distilbert.DistilBertConfig'> for this kind of AutoModel: AutoModelForCausalLM.
Model type should be one of CamembertConfig, XLMRobertaConfig, RobertaConfig, BertConfig, OpenAIGPTConfig, GPT2Config, TransfoXLConfig, XLNetConfig, XLMConfig, CTRLConfig, ReformerConfig, BertGenerationConfig.`