noamaanMulla-03/transformers-issues huggingface dataset:
circleci testing issue
Author: ydshieh
Pull request: no

Sorry, this is not a bug report about `transformers` library. But I don't know what's the best place to ask.

While working on a pull request #6998 , after pushing the code, I got

        ==================================== ERRORS ====================================
        ____________________ ERROR collecting tests/test_trainer.py ____________________
	ImportError while importing test module '/home/circleci/transformers/tests/test_trainer.py'.
	Hint: make sure your test modules/packages have valid Python names.
	Traceback:
	/usr/local/lib/python3.7/importlib/__init__.py:127: in import_module
	    return _bootstrap._gcd_import(name[level:], package, level)
	tests/test_trainer.py:3: in <module>
	    import nlp
	E   ModuleNotFoundError: No module named 'nlp'

The PR #6998  has already been tested several times without problem. And it seems that the error `No module named 'nlp'` is not on my side. Could you help me to resolve this?

Comments:
This has been fixed in master already, it's due to the change of name of the nlp library to datasets. You will need to install datasets to have the full test suite working.

Thanks, @sgugger . So in order to make my pull request pass the test online, I have to merge remote master intomy local branch and repush? Is this an acceptable approach of doing PR?

You can either rebase master on your PR branch, or not worry if this is the only test not passing (merging will make the CI green).
T5Tokenizer shouldn't add pad token as prefix to labels
Author: patil-suraj
Pull request: no


## Information
`prepare_seq2seq_batch` method in `T5Tokenizer` now prefixes `pad` token to the `labels`. [here](https://github.com/huggingface/transformers/blob/master/src/transformers/tokenization_t5.py#L362)
But in finetune.py [here](https://github.com/huggingface/transformers/blob/master/examples/seq2seq/finetune.py#L149) we are calling `_shift_right` for T5 , which again adds another `pad` token at the beginning, so now `decoder_input_ids` contain two `pad` tokens. 
## To reproduce

```python
from transformers import T5Tokenizer, T5Model
model = T5Model.from_pretrained("t5-small")
tok = T5Tokenizer.from_pretrained("t5-small")
enc = tok.prepare_seq2seq_batch("src text", "target text", return_tensors="pt")
print(enc["labels"])
# tensor([[   0, 2387, 1499,    1]])
decoder_input_ids = model._shift_right(enc["labels"]) # call _shift_right
print(decoder_input_ids)
#tensor([[   0,    0, 2387, 1499]])
```
<!-- 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.-->

## Expected behavior
There should be no special prefix token for T5 `labels`

@sshleifer 


Comments:
What should i do if I want a model class similar to BertForSequenceClassification?
Author: cloudygoose
Pull request: no
Labels: name: wontfix

# ❓ Questions & Help

Hi!
For my task I want to implement a class similar to BertForSequenceClassification, but a little different, for example, i may want multiple linear head on top of the bert encoding. Call it BertForMySequenceClassification,

But I still want to use the pretrained bert parameters, and hopefully do easy load/save.
For example, i hope i can BertForSequenceClassification.from_pretrianed(some_path)

Any suggestion or help are much appreciated! 
Thanks!

Comments:
Hi @cloudygoose , 
Take a look at the code of  `BertForSequenceClassification` https://huggingface.co/transformers/_modules/transformers/modeling_bert.html#BertForSequenceClassification,

All it does is, pass the inputs through `BertModel`, which returns the pooled output of bert and the applies the classifier on top it.

You can follow the same process, create `YourSequenceClassification` class by sub-classing `BertPreTrainedModel`,
init your `BertModel` and the additional linear heads and final classfication layer and do forward as  
`BertModel -> additional linear heads -> classifier`

You can just take the `BertForSequenceClassification`  as is and additional layers before the `classifier` 

Hope this helps

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.
Error in Loading bert-large-uncased-whole-word-masking-finetuned-squad
Author: hi-weiyuan
Pull request: no
Labels: name: wontfix

# ❓ 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 Stack Overflow (SO) where a whole community of PyTorch and
     Tensorflow enthusiast can help you out. 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 
     
     If your question wasn't answered after a period of time on Stack Overflow, you
     can always open a question on GitHub. You should then link to the SO question 
     that you posted.
     -->

## Details
<!-- Description of your issue -->
In order to use bert-large-uncased-whole-word-masking-finetuned-squad, I firstly download it from https://s3.amazonaws.com/models.huggingface.co/bert/bert-large-uncased-whole-word-masking-finetuned-squad-config.json and https://s3.amazonaws.com/models.huggingface.co/bert/bert-large-uncased-whole-word-masking-finetuned-squad-pytorch_model.bin. Then, as I used other pretrained model before, I change the files name into config.json and pytorch_model.bin. Finally, I run code bert = BertForQuestionAnswering.from_pretrained(root_path + "/bert-large-uncased-whole-word-masked-finetuned-squad/") and meat some errors.
The error info shows as follows:
  File "/home/dl/anaconda3/lib/python3.6/site-packages/transformers/modeling_utils.py", line 662, in from_pretrained
    "Unable to load weights from pytorch checkpoint file. "
OSError: Unable to load weights from pytorch checkpoint file. If you tried to load a PyTorch model from a TF 2.0 checkpoint, please set from_tf=True. 
*** Error in `/home/dl/anaconda3/bin/python3': corrupted double-linked list: 0x000055e3278c88b0 ***


<!-- You should first ask your question on SO, and only if
     you didn't get an answer ask it here on GitHub. -->
**A link to original question on Stack Overflow**:


Comments:
Sounds like your downloads were corrupted.

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.
How i can set the special token 
 to an other id ?
Author: Nkonstan
Pull request: no
Labels: name: wontfix

# ❓ 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 Stack Overflow (SO) where a whole community of PyTorch and
     Tensorflow enthusiast can help you out. 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 
     
     If your question wasn't answered after a period of time on Stack Overflow, you
     can always open a question on GitHub. You should then link to the SO question 
     that you posted.
     -->

## Details
<!-- Description of your issue -->

<!-- You should first ask your question on SO, and only if
     you didn't get an answer ask it here on GitHub. -->
**A link to original question on Stack Overflow**:


Comments:
 Now is set to 0 and let's say i want to change it to 50256 for GPT-2 .

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.
Batching (TF)BertForQuestionAnswering deployment
Author: rdisipio
Pull request: no
Labels: name: wontfix

# 🚀 Feature request

It may be already possible, but I couldn't figure out how, to call TFBertForQuestionAnswering on a batch on context-question pairs rather than just one by one.

## Motivation

I tried out the same code on a machine with 16 cores and a GPU. I could process 22 pairs/sec with the CPUs, but only 11 pairs/sec with the GPU. I assume it's not efficient due to I/O. However, I couldn't find in the example such a way to call the BERT model.

For example, when I do this:
```
input_ids = tokenizer.encode(question, context, add_special_tokens=True, max_length=512)
```

I would like to promote `question` and `context` to an array of pairs so that after calling
```
start_scores, end_scores = model({'input_ids': np.array([input_ids]), # The tokens representing our input text.
                                 'token_type_ids': np.array([segment_ids])}) # The segment IDs to differentiate question from context
```

the returned objects `start_scores` and `end_scores` should be a 2D array (or list). 

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.
added bangla-bert-base model card and also modified other model cards
Author: sagorbrur
Pull request: yes
Labels: name: model card

Hi,
I added model card for bangla-bert-base model and also modified some typo in other model cards also. 
Please check and if possible please merge. 

thanks and regards
Sagor


Comments:
This is great, thanks for sharing! 

In case you have time and want to contribute default sample inputs for Bengali, you can just open a pull request against https://github.com/huggingface/widgets-server/blob/master/DefaultWidget.ts

Your model page's inference widgets will then display relevant sample inputs.

PS/ your models are now correctly linked from https://huggingface.co/datasets/lince

Hi,
Thank you so much. 
I will create a pull request for DefaultWidget.ts

regards
Sagor
[s2s] run_eval supports --prefix clarg.
Author: sshleifer
Pull request: yes

- Useful for multilingual models. 
- `model.config.prefix` will still be used if prefix not passed. This prefix is added to the beginning of each example from the  source document before calling `generate`. 
- `decoder_start_token_id` is a different thing and unaffected.


Usage:

```bash
export dd=wmt_en_de
python run_eval.py Helsinki-NLP/opus-mt-en-gem \
	$dd/val.source \
	$dd/marian_multi_val_gens.txt \
	--reference_path $dd/val.target \
	--task translation --fp16  --bs 128  \
	--score_path $dd/marian_multi_val_bleu.json \
	--prefix ">>deu<<"
```

Comments:
[ERROR] add_special_tokens = True not working in version 3.0.0
Author: 1512262
Pull request: no
Labels: name: wontfix

# 🐛 Bug

## Information

Model I am using (Bert, XLNet ...): BERT

Language I am using the model on (English, Chinese ...): Multi-Lingual

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:
In version 2.11 Everything is OK but I updated to 3.0.0 and I can not create fixed_length with padding for the encoding of the text

<!-- 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.-->

## Expected behavior

<!-- A clear and concise description of what you would expect to happen. -->

## 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:
- Platform:
- Python version:
- PyTorch version (GPU?):
- Tensorflow version (GPU?):
- Using GPU in script?:
- Using distributed or parallel set-up in script?:


Comments:
Hi, can you provide more information (basically fill all the filed in the issue templates) in particular provide a clear example so we can try to reproduce the behavior?

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.
Longformer - Compression
Author: Nouman97
Pull request: no
Labels: name: wontfix

Hello, I have trained a longformer model on my custom question answering dataset, and now I wanted to know if there is a way to compress this trained model?

Thank you!

Comments:
You could check out the example script under distillation: `/home/patrick/hugging_face/transformers/examples/distillation`

Did you upload the model to the model hub? I would be great so that we can take a closer look :-) 

Hello, thanks for the reply. I checked the train.py script under examples/distillation, but it seems that it does not cater to longformer models (the mentioned models within the script are BERT, RoBERTa, and GPT2). Yes, I have uploaded the model: https://s3.amazonaws.com/models.huggingface.co/bert/Nomi97/Chatbot_QA.

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.
Add option to pass parameters to the loss function.
Author: PhilipMay
Pull request: yes

This PR is by far not finished. In the current state it is just a demo how I would implement it. See #7024

- loss_function_params is a dict that gets passed to the CrossEntropyLoss constructor
- that way you can set class_weights for the `CrossEntropyLoss ` for example
- this is a very important thing to do when working with unbalanced data and can improve your metric by a large amount
- it should be no breaking change since `loss_function_params` is always initialized with `None` which is just the current behavior

Example:
```python
model_name = 'bert-base-german-dbmdz-uncased'

config = AutoConfig.from_pretrained(
    model_name,
    num_labels=3,
)

model = AutoModelForSequenceClassification.from_pretrained(
    model_name,
    config=config,
    loss_function_params={"weight": [0.8, 1.2, 0.97]}
)
```

## ToDo
- [ ] discuss with @LysandreJik @sgugger @nvs-abhilash
- [ ] implement for other models
- [ ] add docstrings
- [ ] write tests
- [ ] maybe implement for TF also

Comments:
Closed by this answer: https://github.com/huggingface/transformers/issues/7024#issuecomment-691481436
T5 Training on TPU doesnt use TPU
Author: santhoshkolloju
Pull request: no
Labels: name: wontfix

I am trying to train T5 on TPU .Training started without errors but its very slow . I think its not using TPU backend.
https://colab.research.google.com/drive/10TN0zgPWCIAzbA0PKYIo3fF8wOvfa1P7?usp=sharing

Comments:
Hi @santhoshkolloju  what is the xla and pytorch version ?

Pytorch - 1.7.0a0+542ac74
torch_xla - 1.6+30b65e9
The setup file is taken from 
VERSION = "nightly"  #@param ["1.5" , "20200325", "nightly"]
!curl https://raw.githubusercontent.com/pytorch/xla/master/contrib/scripts/env-setup.py -o pytorch-xla-env-setup.py
!python pytorch-xla-env-setup.py --version $VERSION

@patil-suraj i just realised that i was using the notebook created by you. Thanks for the notebook.
Did anything has changed in the current xla library because of which this is happening? 

Hi @santhoshkolloju , yes there's been some changes to xla, I'm working on the fix, will let you know when I find it.

Also looks like you are trying to do question generation, I am going to release my own experiments by the end of the week. It's pretty exciting.   Here's a relevant thread for QG #4399

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.
Roberta Large doesn't train for sentiment classification
Author: Srj
Pull request: no
Labels: name: wontfix

The following is my classifier class. I trained it with appropriate code and same tokenizer(roberta-base). It trained well on SST2 2 class sentiment problem. But when i replaced base model with roberta-large (also the tokenizer and dim of linear layer)my classifier is stuck at 50% accuracy and not matter how many epoch i run it doesn't improve. Is the weight file faulty or am i doing something wrong? 



```
class Model(nn.Module):
    def __init__(self):
        super(Model,self).__init__()
        self.Bert = transformers.RobertaModel.from_pretrained('roberta-base')
        self.fc0 = nn.Linear(768,512)
        self.d0 = nn.Dropout(0.5)
        self.d1 = nn.Dropout(0.5)
        self.fc1 = nn.Linear(512,1)
        nn.init.normal_(self.fc0.weight,std= 0.1)
        nn.init.normal_(self.fc0.bias ,0.)
        nn.init.normal_(self.fc1.weight,std =0.1)
        nn.init.normal_(self.fc1.bias, 0.)


        
    def forward(self,input_ids,attention_mask):
        hid= self.Bert(input_ids,attention_mask = attention_mask)
        hid= hid[0][:,0,:]
        x = self.d0(hid)
        x = self.fc0(x)
        x = torch.tanh(x)
        x = self.d1(x)
        x = self.fc1(x)
        return x


```
This the optimizer i used and i froze the Roberta Layers and only trained the final layers. I also trained with lr 3e-5. It didn't do any help either.
```
model = Model().to('cuda')
criterion = nn.CrossEntropyLoss(reduction='mean').to('cuda')
for params in model.Bert.parameters():
     params.requires_grad = False
optimizer = torch.optim.Adam(model.parameters(),lr=0.001)
```

Comments:
Your learning rate is pretty high and you might be overfitting. Try it again with 3E-5.

My question is i have freezed the whole roberta layer. Then why still it needs to be such small lr rather than normal 0.001 as i am training only a classifier head.

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.
Datasets & collators for NER
Author: Pradhy729
Pull request: no
Labels: name: wontfix

# 🚀 Feature request

Is there a plan to add a dataset subclass and loader/collator for token classification tasks in the CONLL format? Or has that been deliberately avoided for some reason. 

## Motivation

We have TextDatasets and DataCollatorForLanguageModeling. Can we have something similar for token classification tasks with some CONLL format input text file? That way we can just point to a file & tokenizer and generate a dataset like the language modeling tasks.

## Your contribution

I have a working version of this that I use in my projects. I can package and share it if it would be useful to add directly to transformers library.

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.
Previous commit introduces bug in `convert_pytorch_checkpoint_to_tf2.py`
Author: VictorSanh
Pull request: no
Labels: name: wontfix

This issue concerns the conversion tool `convert_pytorch_checkpoint_to_tf2.py`.

Commit d4c2cb402d6674211726fd5f4803d1090664e438 removed the `*PRETRAINED_MODEL_ARCHIVE_MAP` from the imports so that for each key in `MODEL_CLASSES` is associated to a set of 4 values.
For instance: https://github.com/huggingface/transformers/blob/e8db8b845a971b0cf63a0896b9deb5b316028a8b/src/transformers/convert_pytorch_checkpoint_to_tf2.py#L109

However, in `convert_all_pt_checkpoints_to_tf`, `MODEL_CLASSES` is still expected to unpack 5 values (among which the model maps) which raise an error:
https://github.com/huggingface/transformers/blob/e8db8b845a971b0cf63a0896b9deb5b316028a8b/src/transformers/convert_pytorch_checkpoint_to_tf2.py#L259

Typical command is:
```bash
python src/transformers/convert_pytorch_checkpoint_to_tf2.py \
    --tf_dump_path serialization_dir/weights_release/1st_weight_release/prunebert-base-uncased-6-finepruned-w-distil-squad/ \
    --model_type bert-large-uncased-whole-word-masking-finetuned-squad \
    --pytorch_checkpoint_path /serialization_dir/weights_release/1st_weight_release/prunebert-base-uncased-6-finepruned-w-distil-squad/ \
    --compare_with_pt_model
```

I didn't really follow why the `*PRETRAINED_MODEL_ARCHIVE_MAP` were removed so I'm not sure what is the best course of action here.

Victor

Comments:
I encountered the same problem.
If you were converting a local `pytorch_model.bin` model, you can try this

somewhere around line 258 in `convert_pytorch_checkpoint_to_tf2.py`

```
aws_model_maps = {}
config_class, model_class, pt_model_class, aws_config_map = MODEL_CLASSES[model_type]
# config_class, model_class, pt_model_class, aws_model_maps, aws_config_map = MODEL_CLASSES[model_type]
```

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.