noamaanMulla-03/transformers-issues huggingface dataset:
Saving model errors
Author: cyfugr
Pull request: no
Labels: name: wontfix

I am trying to fine-tune distillbert for a multilabel task using a V100 gpu and latest transformers from pip. When i try to save the model i get this error: 
```
Traceback (most recent call last):
  File "script/fine_tune_distillbert.py", line 51, in <module>
    model.save_pretrained(ROOT_DIR)
  File "/usr/local/lib/python3.7/dist-packages/transformers/modeling_tf_utils.py", line 534, in save_pretrained
    self.save_weights(output_model_file)
  File "/usr/local/lib/python3.7/dist-packages/tensorflow/python/keras/engine/training.py", line 2085, in save_weights
    hdf5_format.save_weights_to_hdf5_group(f, self.layers)
  File "/usr/local/lib/python3.7/dist-packages/tensorflow/python/keras/saving/hdf5_format.py", line 640, in save_weights_to_hdf5_group
    param_dset = g.create_dataset(name, val.shape, dtype=val.dtype)
  File "/usr/local/lib/python3.7/dist-packages/h5py/_hl/group.py", line 143, in create_dataset
    if '/' in name:
TypeError: a bytes-like object is required, not 'str'
```

The model init:

```
model = TFDistilBertForSequenceClassification.from_pretrained('distilbert-base-uncased', num_labels= max_lab)
optimizer = tf.keras.optimizers.Adam(learning_rate=0.0001)
model.compile(optimizer=optimizer, loss=model.compute_loss, metrics=['accuracy']) # can also use any keras loss fn

model.fit(train_dataset.shuffle(1000).batch(256), epochs=3, batch_size=256,
          validation_data=val_dataset.shuffle(1000).batch(256))
```

The way i am saving after sucessfuly training the model is this : 

```
import os
ROOT_DIR = os.path.abspath(os.curdir)
ROOT_DIR = ROOT_DIR + "/model"

tokenizer.save_pretrained(ROOT_DIR)
model.save_pretrained(ROOT_DIR)
```

Tokenizer is saved perfectly. I have tried to run the same code in a colab notebook ( with much less data) and it saves perfectly but when i use a service like `spell.ml` i get this error.

@LysandreJik 

Comments:
Hi, I'm sorry but I don't know spell.ml or how it works; if it works in a colab notebook and saves correctly, it seems the issue comes from spell.ml rather than transformers.

This issue has been automatically marked as stale and been closed because it has not had recent activity. Thank you for your contributions.

If you think this still needs to be addressed please comment on this thread.
Compatibility scripts
Author: bendboaz
Pull request: no
Labels: name: wontfix

# 🚀 Feature request

Scripts that translate code in older transformers versions into equivalent code that is compatible with newer versions. 

## Motivation

After talking with several other people in my research groups, compatibility issues and getting stuck with old versions have turned out to be pretty common problems. Seeing as many of the things preventing backward compatibility are syntactic (slightly different interfaces for tokenizers, different file paths) I thought it might be possible to add scripts to the package, which translate code to fit, say, one major version higher up (then if a user wanted to step up multiple versions, they could just run several scripts in sequence).

Some rudimentary usage example:
`python transformers-2.11-3.0.py my_project/*`

## Your contribution

I could try to implement such an example scripts, but it would probably take me months and result in a sub-optimal output due to my knowledge about python parsing and the interface changes between major and minor versions of transformers. 
I did find out a [refactoring](https://github.com/python-rope/rope) library for python, or some snippet showing how to [unparse a python AST](https://svn.python.org/projects/python/trunk/Demo/parser/unparse.py).


Comments:
Hello! Thank you for your proposal. This, however, sounds like a colossal amount of work for limited gain - we try to keep the breaking changes across versions to a minimum. I understand that these do happen from time to time, but only for very good reasons that are thoroughly discussed beforehand.

Would you be able to share what breaking changes have impacted you, and have been a bit too hard to overcome/not documented enough, preventing you from upgrading? Understanding this will help us do better in the future.

This issue has been automatically marked as stale and been closed because it has not had recent activity. Thank you for your contributions.

If you think this still needs to be addressed please comment on this thread.
Use Softmax classifiering for run_glue.py example
Author: rhit2020
Pull request: no
Labels: name: wontfix

Hi,
I want to do binary text classification and I'm adapting [run_glue.py](https://github.com/huggingface/transformers/blob/master/examples/text-classification/run_glue.py)  script to my task. The current model uses a linear classifier and the predictions are not in the range of [0,1]. Could you please guide me on how I could use softmax classifier instead of linear classifier?

I added following code after the model is loaded but I get an error related related to loss function that I pasted below. Any suggestion on how to fix this? 
   `model.classifier = torch.nn.Softmax(dim=1)`

```
File "run_glue.py", line 300, in main
    model_path=model_args.model_name_or_path if os.path.isdir(model_args.model_name_or_path) else None
  File "/Users/royaho/PycharmProjects/download_pretrained_model/venv/lib/python3.6/site-packages/transformers/trainer.py", line 775, in train
    tr_loss += self.training_step(model, inputs)
  File "/Users/royaho/PycharmProjects/download_pretrained_model/venv/lib/python3.6/site-packages/transformers/trainer.py", line 1112, in training_step
    loss = self.compute_loss(model, inputs)
  File "/Users/royaho/PycharmProjects/download_pretrained_model/venv/lib/python3.6/site-packages/transformers/trainer.py", line 1136, in compute_loss
    outputs = model(**inputs)
  File "/Users/royaho/PycharmProjects/download_pretrained_model/venv/lib/python3.6/site-packages/torch/nn/modules/module.py", line 727, in _call_impl
    result = self.forward(*input, **kwargs)
  File "/Users/royaho/PycharmProjects/download_pretrained_model/venv/lib/python3.6/site-packages/transformers/modeling_bert.py", line 1377, in forward
    loss = loss_fct(logits.view(-1, self.num_labels), labels.view(-1))
  File "/Users/royaho/PycharmProjects/download_pretrained_model/venv/lib/python3.6/site-packages/torch/nn/modules/module.py", line 727, in _call_impl
    result = self.forward(*input, **kwargs)
  File "/Users/royaho/PycharmProjects/download_pretrained_model/venv/lib/python3.6/site-packages/torch/nn/modules/loss.py", line 962, in forward
    ignore_index=self.ignore_index, reduction=self.reduction)
  File "/Users/royaho/PycharmProjects/download_pretrained_model/venv/lib/python3.6/site-packages/torch/nn/functional.py", line 2468, in cross_entropy
    return nll_loss(log_softmax(input, 1), target, weight, None, ignore_index, None, reduction)
  File "/Users/royaho/PycharmProjects/download_pretrained_model/venv/lib/python3.6/site-packages/torch/nn/functional.py", line 2262, in nll_loss
    .format(input.size(0), target.size(0)))
ValueError: Expected input batch_size (768) to match target batch_size (3).
 
```

Comments:
This issue has been automatically marked as stale and been closed because it has not had recent activity. Thank you for your contributions.

If you think this still needs to be addressed please comment on this thread.
run_clm.py Issue | MODEL_FOR_CAUSAL_LM_MAPPING is None
Author: marscod
Pull request: no
Labels: name: wontfix

When I use latest code of [run_clm.py](https://github.com/huggingface/transformers/blob/master/examples/language-modeling/run_clm.py), it raises the following issue:
```
python run_clm.py \
    --model_name_or_path gpt2 \
    --train_file path_to_train_file \
    --validation_file path_to_validation_file \
    --do_train \
    --do_eval \
    --output_dir /tmp/test-clm
```

```
Traceback (most recent call last):
  File "run_clm.py", line 51, in <module>
    MODEL_CONFIG_CLASSES = list(MODEL_FOR_CAUSAL_LM_MAPPING.keys())
AttributeError: 'NoneType' object has no attribute 'keys'
```
I checked and noticed that MODEL_FOR_CAUSAL_LM_MAPPING is None. Any suggestion?

Comments:
Hi, could you please provide your environment info as asked in the template? `transformers-cli env`

hey, any solution yet?

@LysandreJik I am having the same issue and this is my env:
- `transformers` version: 4.1.0.dev0
- Platform: Linux-5.4.0-1029-gcp-x86_64-with-debian-buster-sid
- Python version: 3.7.6
- PyTorch version (GPU?): not installed (NA)
- Tensorflow version (GPU?): 2.3.1 (False)
- Using GPU in script?: NO (using TPU)
- Using distributed or parallel set-up in script?: 

I got a similar error trying to run `run_clm.py` on a TPU.
`  File "/kaggle/working/transformers/examples/language-modeling/run_clm.py", line 33, in <module>
    from transformers import (
ImportError: cannot import name 'MODEL_FOR_CAUSAL_LM_MAPPING' from 'transformers' (/opt/conda/lib/python3.7/site-packages/transformers/__init__.py)`

@Clickative any solution?


It seems you do not have PyTorch installed? `run_clm.py` is a PyTorch script.

I encountered this same error and followed the advice from @LysandreJik. I installed PyTorch using `pip3 install torch torchvision` and this resolved the issue.

On Kaggle TPU, the current docker seems to have old version of transformers and it reads from the conda environment, so new installs are not taken into account (try `pip show`). Even if docker is set to latest. The GPU docker seem to run a version with 0.9.3 of tokenizers and latest transformers need 0.9.4 which is another issue.

This issue has been automatically marked as stale and been closed because it has not had recent activity. Thank you for your contributions.

If you think this still needs to be addressed please comment on this thread.
Error tokenizer = AutoTokenizer.from_pretrained("vinai/phobert-base")
Author: trungtruc123
Pull request: no
Labels: name: wontfix

I run pretrain PhoBERT error .
ValueError                                Traceback (most recent call last)
<ipython-input-75-d17717702336> in <module>()
      3 
      4 phobert = AutoModel.from_pretrained("vinai/phobert-base")
----> 5 tokenizer = AutoTokenizer.from_pretrained("vinai/phobert-base")
      6 
      7 # INPUT TEXT MUST BE ALREADY WORD-SEGMENTED!

/usr/local/lib/python3.6/dist-packages/transformers/models/auto/tokenization_auto.py in from_pretrained(cls, pretrained_model_name_or_path, *inputs, **kwargs)
    323             if tokenizer_class is None:
    324                 raise ValueError(
--> 325                     "Tokenizer class {} does not exist or is not currently imported.".format(tokenizer_class_candidate)
    326                 )
    327             return tokenizer_class.from_pretrained(pretrained_model_name_or_path, *inputs, **kwargs)

ValueError: **Tokenizer class PhobertTokenizerFast does not exist or is not currently imported.**

Comments:
Hey @trungtruc123, 

can you try upgrading your transformer version?
The following code snippet (as stated on the model card: https://github.com/VinAIResearch/PhoBERT) works perfectly fine for me.

```python
import torch
from transformers import AutoModel, AutoTokenizer

phobert = AutoModel.from_pretrained("vinai/phobert-base")

# For transformers v4.x+: 
tokenizer = AutoTokenizer.from_pretrained("vinai/phobert-base", use_fast=False)
```

Version:
- `transformers` version: 4.1.0.dev0
- Platform: Linux-5.4.0-1030-gcp-x86_64-with-glibc2.10
- Python version: 3.8.5
- PyTorch version (GPU?): 1.8.0.dev20201117 (True)
- Tensorflow version (GPU?): 2.3.1 (False)
- Using GPU in script?: <fill in>
- Using distributed or parallel set-up in script?: <fill in>


It should also work with transformers 4.0.0.

This issue has been automatically marked as stale and been closed because it has not had recent activity. Thank you for your contributions.

If you think this still needs to be addressed please comment on this thread.
getattr introduces bug when setting booleans with config file 
Author: rabeehk
Pull request: no
Labels: name: wontfix

Hi,

In finetune_trainer.py, line 162: https://github.com/huggingface/transformers/blob/5e637e6c690e45d13ebf7296e1ea9dcc188d0f07/examples/seq2seq/finetune_trainer.py#L162

If the user is calling this script with a json config file and setting one of the attributes to false, then on line 162, the result of if `getattr(training_args, p, None)` would be false and if condition would not be called, this results in bug for setting booleans,  could you change this line to following to resolve it: 

`if hasattr(training_args, p): `

thank you. 

Comments:
Hey @rabeehk,

could you attach a code snippet that we can copy-paste to reproduce the error? Thanks!

Hi Patrick, 
I checked and in finetune_trainer.py you consider these parameters only which are all of type float:
` extra_model_params = ("encoder_layerdrop", "decoder_layerdrop", "dropout", "attention_dropout") 
`
In this case the issue would not happen, but if one of these parameters were boolean, lets say "A", if the user pass a config file like below to `finetune_trainer.py`

```
//config.json
{
A: false 
}
```

and if the code tries to updating the value of "A" in the config file as line 162, then this introduces the bug of not setting A.
For now since the variables you consider are float, this wont happen, so please feel free to close the bug. Still safer to change 162 with` if hasattr(training_args, p):`
thanks. 



This issue has been automatically marked as stale and been closed because it has not had recent activity. Thank you for your contributions.

If you think this still needs to be addressed please comment on this thread.
[libprotobuf FATAL /sentencepiece/src/../third_party/protobuf-lite/google/protobuf/repeated_field.h:1505] CHECK failed: (index) >= (0): 
Author: rabeehk
Pull request: no
Labels: name: wontfix

Hi
When I evaluate the finetune_trainer.py on translation datasets like wmt16-en-cs I always get this error after calling evaluate function, I am using version 3.5.1 of transformer on 1 GPU, this issue is really blokcing me, and happens to be there for  all translation datasets I tried, could you give me some ideas on this? thanks 

[libprotobuf FATAL /sentencepiece/src/../third_party/protobuf-lite/google/protobuf/repeated_field.h:1505] CHECK failed: (index) >= (0): 
terminate called after throwing an instance of 'google::protobuf::FatalException'
  what():  CHECK failed: (index) >= (0): 
Aborted




Comments:
Hello! We really cannot help you with this little information. Please respect the issue template with your environment information, the exact command you used to launch the script, and the full stack trace.

Thank you for your understanding.

@rabeehk Did you manage to solve this? Experiencing the same issue fine-tuning mT5 on toy data.

yes I did managed, the issue was I needed to set a longer max_length for the decoder.


if you want to debug your codes, go to the place where huggingface computes the final metrics, like bleu, ... and there you can check that prediction max length and targets max-length need to match

This issue has been automatically marked as stale and been closed because it has not had recent activity. Thank you for your contributions.

If you think this still needs to be addressed please comment on this thread.
BertConfig.id2label use list instead of "int: string" dict
Author: franciszzj
Pull request: no
Labels: name: wontfix

In https://github.com/huggingface/transformers/blob/master/src/transformers/configuration_utils.py#L262, use list instead of "int: string" dict maybe is better.
When we use easydict to replace dict, there will be bugs in updating the `.to_dict()` to other easydict object. Because int object can not be the key in easydict.
Solve method:
use ```["LABEL_{}".format(i) for i in range(num_labels)]``` to replace ```self.id2label = {i: "LABEL_{}".format(i) for i in range(num_labels)}```.

Comments:
This issue has been automatically marked as stale and been closed because it has not had recent activity. Thank you for your contributions.

If you think this still needs to be addressed please comment on this thread.
vocab_file and merges_file still required params for loading serialized tokenizers
Author: minimaxir
Pull request: no
Labels: name: wontfix

e.g.

https://github.com/huggingface/transformers/blob/dd52804f5fce0a568ffbb3dc7fd088d2de0a0e56/src/transformers/models/gpt2/tokenization_gpt2_fast.py#L122-L132

Both of these should probably be optional params now. Setting `vocab_file` and `merges_file` to `None` while specifying a `tokenizer_file` works, but seems messy.

Comments:
Indeed, we could do that, and then add a check below to ensure that we get a correct error message. Do you want to open a PR with the fix?

I wasn't planning on doing a PR because I wasn't sure of the scope of changes needed (e.g. every tokenizer `__init__` would need to be changed) and it also seems like there isn't any documentation for serialized tokenizers at all in `transformers`, so I assumed you were getting to that.

This issue has been automatically marked as stale and been closed because it has not had recent activity. Thank you for your contributions.

If you think this still needs to be addressed please comment on this thread.
Error running source code -- import
Author: RandolphShi
Pull request: no
Labels: name: wontfix

Hi, I have downloaded source code of transformers and tried to run modeling_utils.py.

However, it seems that there are a lot of importing problems.

Am I running it in a wrong way?


Comments:
Hi, what are you trying to do?

The `modeling_utils.py` is an internal file that defines objects to be used by models. I invite you to read the documentation, especially the [quick tour](https://huggingface.co/transformers/quicktour.html).

This issue has been automatically marked as stale and been closed because it has not had recent activity. Thank you for your contributions.

If you think this still needs to be addressed please comment on this thread.
Updating outdated fairseq checkpoint to HF script
Author: machelreid
Pull request: yes
Labels: name: wontfix

The current fairseq checkpoint to HF script is outdated, not being compatible with the newly introduced `hydra` config and fairseq's new PyTorch hub interface.  In addition to this, added one more argument (`--data-dir`) for custom RoBERTa models, and modified the `--classification_head` argument to take in a string rather than `store_true`. This is to reflect (a more likely case) of custom classification heads, rather than the most popular (and already available) `mnli` head. Added an import of `os` (if it counts as a "dependency").

## Before submitting
- [ ] 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?
- [ ] 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.
- [ ] 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?
@LysandreJik @stefan-it @myleott @sgugger 

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.



Comments:
This issue has been automatically marked as stale and been closed because it has not had recent activity. Thank you for your contributions.

If you think this still needs to be addressed please comment on this thread.
Documentation License Query
Author: darigovresearch
Pull request: no
Labels: name: wontfix

We were looking to make some educational material based on the documentation & it wasn't clear what the license is for the documentation.

We see that the repository as a whole is under an Apache license, but the docs page is not explicit on what license the docs with a dedicated license page or in the footer.

Could you please advise?

We have made some other educational material from docs pages for reference (see the flashcards section of https://www.darigovresearch.com/)

Comments:
The documentation is also under the Apache License (version 2.0). Hope that helps!
Would love some flashcards for Transformers :-)

@sgugger thanks for letting us know! An initial set based on your glossary will follow shortly as a start.

Is there any way to update the docs so that the license is in the footer?

I am happy to make a pull request if given context. We think having it there will encourage other people as well to make other educational content based on the docs.

Also could you take a look at this issue as it may be relevant but was auto closed?

https://github.com/huggingface/transformers/issues/6140

I'll work on adding the copyright to individual files and the footer of the docs on Monday. For the issue you mention, I'm not sure what you mean: this points to complete text of the Apache v2 license (as is done for TensorFlow for instance, see [here](https://github.com/tensorflow/tensorflow/blob/master/LICENSE). The snippet is then copied on the code files with the year and authors filled properly (and soon-to-be doc files).

We believe the original post meant that lines 179-188 of your license file suggests that in the License file you need to add or adjust line 190 to have the copyright year & the name of your organisation. The tensorflow license has done this as the first line of their license file.

This issue has been automatically marked as stale and been closed because it has not had recent activity. Thank you for your contributions.

If you think this still needs to be addressed please comment on this thread.