noamaanMulla-03/transformers-issues huggingface dataset:
[fixup/style] requires TF but doesn't say that cleanly
Author: stas00
Pull request: no

It looks like `make fixup` et al, require tf (and pt), but fail in unexpected way when the requirements are missing:

```
python utils/check_repo.py
Checking all models are properly tested.
Checking all objects are properly documented.
Checking all models are in at least one auto class.
Traceback (most recent call last):
  File "/home/michael/projects/transformers/utils/check_repo.py", line 481, in <module>
    check_repo_quality()
  File "/home/michael/projects/transformers/utils/check_repo.py", line 477, in check_repo_quality
    check_all_models_are_auto_configured()
  File "/home/michael/projects/transformers/utils/check_repo.py", line 290, in check_all_models_are_auto_configured
    all_auto_models = get_all_auto_configured_models()
  File "/home/michael/projects/transformers/utils/check_repo.py", line 253, in get_all_auto_configured_models
    for attr_name in dir(transformers.models.auto.modeling_tf_auto):
  File "/home/michael/projects/transformers/src/transformers/file_utils.py", line 1690, in __getattr__
    raise AttributeError(f"module {self.__name__} has no attribute {name}")
AttributeError: module transformers.models.auto has no attribute modeling_tf_auto
make: *** [Makefile:35 : extra_quality_checks] Erreur 1
```

Thank you, @michaelbenayoun for flagging this

Should we add a small script first that checks all the requirements so that the error is not misleading, but something like: "need to install `pip install -e .[dev]` to develop `transformers`"?

@sgugger, @LysandreJik 

Comments:
The same thing happens with flax.

This should take care of all the deps:
```
pip install -e .[dev]
```
Please let us know if it didn't.

I don't think we need a new script for that. Maybe add the check inside the script that fails (`check_all_models_are_auto_configured`) and issue a warning if not all backends are detected (I don't think we need to error out, since it's unlikely the user will bring changes that break a backend when that backend is not even installed)? I can do this later this evening or tomorrow.

Also with a bit of some further massaging of `setup.py`'s  `extras`, we could automate this - basically need to be able to load `extras[dev]` outside of `setup.py`, so the check could be to simply import everything that is in `extras[dev]`.

Note that this specific script only relies on the model backends only, so no need for the whole of dev yet.

If it's easier - then by all means. 

I just thought that if we already maintain `extras[dev]` then any dev tool could just have that as pre-requisite.
Make quality scripts work when one backend is missing.
Author: sgugger
Pull request: yes

# What does this PR do?

This PR makes the quality scripts issue a warning instead of erroring when one backend is missing (which shouldn't be the case since the contributing guide says to run `pip install -e .[dev]` but we never know). It's also fine since a user is unlikely to make changes to a specific backend of the library if it's not even installed.

Fixes #11570

Comments:
The CI will have all backends installed.

This takes care of contributors that cannot install one backend for one reason or another (for instance if jax/flax was not available on Windows which wouldn't surprise me).

> The CI will have all backends installed.

All is good then.

I totally agree, that not needing to force someone to install libs they don't need is a goodness.

Very awesome!

Oh very good idea, that way we get the best of both worlds! Thanks for the suggestion, will apply that this morning and merge.
Add Pooler to DistilBERT
Author: peterskipper
Pull request: no

# 🚀 Feature request
Hi, I'd like to add a Pooler class to the DistilBERT model, whose interface is similar to BertPooler [here](https://github.com/huggingface/transformers/blob/7da995c00c025c4180c7fb0357256b7f83d342ef/src/transformers/models/bert/modeling_bert.py#L610)

## Motivation
I was using your DistilBERT model and discovered that I needed a pooler, so I wrote my own class. Thought I would add it to the repo in case others would like it.

## Your contribution
If this is something you're interested in, I can submit a PR
<!-- Is there any way that you could help, e.g. by submitting a PR?
     Make sure to read the CONTRIBUTING.MD readme:
     https://github.com/huggingface/transformers/blob/master/CONTRIBUTING.md -->


Comments:
This issue has been automatically marked as stale because it has not had recent activity. If you think this still needs to be addressed please comment on this thread.

Please note that issues that do not follow the [contributing guidelines](https://github.com/huggingface/transformers/blob/master/CONTRIBUTING.md) are likely to be ignored.
Typo in examples/text-classification README
Author: lukemelas
Pull request: no

In the examples/text-classification README, the example scripts for "PyTorch version, no Trainer" are slightly incorrect. They should be adjusted as: 
```diff
export TASK_NAME=mrpc

python run_glue_no_trainer.py \
  --model_name_or_path bert-base-cased \
  --task_name $TASK_NAME \
-   --max_seq_length 128 \
+   --max_length 128 \
  --per_device_train_batch_size 32 \
  --learning_rate 2e-5 \
  --num_train_epochs 3 \
  --output_dir /tmp/$TASK_NAME/
```
Thanks for your great repo!
Luke

Comments:
Indeed, do you want to open a PR with the fix since you found it?

PS: I didn't know that \`\`\`diff feature, it's soooo pretty 🤩 !

This issue has been automatically marked as stale because it has not had recent activity. If you think this still needs to be addressed please comment on this thread.

Please note that issues that do not follow the [contributing guidelines](https://github.com/huggingface/transformers/blob/master/CONTRIBUTING.md) are likely to be ignored.
GPT2 on TPU, training is so slow.
Author: enkhjile
Pull request: no

When training GPT2 on TPU from scratch, training loss is constant & evaluation loss is decreasing very small amount.



> [INFO|trainer.py:1776] 2021-03-26 04:06:22,551 >>   Num examples = 100000
> [INFO|trainer.py:1777] 2021-03-26 04:06:22,551 >>   Batch size = 2
> {'eval_loss': 4.687133312225342, 'eval_runtime': 736.3302, 'eval_samples_per_second': 135.809, 'epoch': 0.05}
>   1%|#                                                                                                     | 22000/2080235 [22:38:08<2499:54:52,  4.37s/it]                                                [INFO|trainer.py:1528] 2021-03-26 04:18:38,885 >> Saving model checkpoint to outputs/line_by_line/checkpoint-22000
> [INFO|configuration_utils.py:314] 2021-03-26 04:18:38,912 >> Configuration saved in outputs/line_by_line/checkpoint-22000/config.json
> [INFO|modeling_utils.py:837] 2021-03-26 04:18:56,125 >> Model weights saved in outputs/line_by_line/checkpoint-22000/pytorch_model.bin
> [INFO|tokenization_utils_base.py:1896] 2021-03-26 04:18:56,130 >> tokenizer config file saved in outputs/line_by_line/checkpoint-22000/tokenizer_config.json
> [INFO|tokenization_utils_base.py:1902] 2021-03-26 04:18:56,131 >> Special tokens file saved in outputs/line_by_line/checkpoint-22000/special_tokens_map.json
> {'loss': 2.56, 'learning_rate': 0.0004963706023598295, 'epoch': 0.05}
> {'loss': 2.56, 'learning_rate': 0.0004963465666138682, 'epoch': 0.05}
> {'loss': 2.56, 'learning_rate': 0.0004963225308679067, 'epoch': 0.05}
> {'loss': 2.56, 'learning_rate': 0.0004962984951219453, 'epoch': 0.05}
> {'loss': 2.56, 'learning_rate': 0.000496274459375984, 'epoch': 0.05}
> {'loss': 2.56, 'learning_rate': 0.0004962504236300226, 'epoch': 0.05}
> {'loss': 2.56, 'learning_rate': 0.0004962263878840611, 'epoch': 0.05}
> {'loss': 2.56, 'learning_rate': 0.0004962023521380998, 'epoch': 0.05}
> {'loss': 2.56, 'learning_rate': 0.0004961783163921384, 'epoch': 0.06}
> {'loss': 2.56, 'learning_rate': 0.000496154280646177, 'epoch': 0.06}
>   1%|#1                                                                                                    | 23000/2080235 [23:52:03<2524:57:42,  4.42s/it][INFO|trainer.py:1775] 2021-03-26 05:32:34,207 >> ***** Running Evaluation *****
> [INFO|trainer.py:1776] 2021-03-26 05:32:34,317 >>   Num examples = 100000
> [INFO|trainer.py:1777] 2021-03-26 05:32:34,317 >>   Batch size = 2
> {'eval_loss': 4.667241096496582, 'eval_runtime': 739.6907, 'eval_samples_per_second': 135.192, 'epoch': 0.06}`



Comments:
This issue has been automatically marked as stale because it has not had recent activity. If you think this still needs to be addressed please comment on this thread.

Please note that issues that do not follow the [contributing guidelines](https://github.com/huggingface/transformers/blob/master/CONTRIBUTING.md) are likely to be ignored.
AttributeError: 'Trainer' object has no attribute 'log_metrics'
Author: yanan1116
Pull request: no

I try to fine tune the distilbert-base-uncased on my own dataset, which are csv made up of each news line by line.
here is my command:

```
nohup python run_mlm.py \
    --model_name_or_path distilbert-base-uncased \
    --train_file df_finetune_train.csv \
    --validation_file df_finetune_test.csv  \
    --do_train \
    --do_eval \
    --preprocessing_num_workers 72 \
    --output_dir ./finetuned_bert \
    --overwrite_cache True \
    --max_seq_length 256 \
    --line_by_line True > log_fintune_mlm &
```
Here is the error.

> {'loss': 1.7847, 'learning_rate': 3.264263411864888e-07, 'epoch': 2.98}
> {'loss': 1.7906, 'learning_rate': 1.7858832434478192e-07, 'epoch': 2.99}
> {'loss': 1.7839, 'learning_rate': 3.075030750307503e-08, 'epoch': 3.0}
> {'train_runtime': 65966.5445, 'train_samples_per_second': 2.563, 'epoch': 3.0}
> Traceback (most recent call last):
>   File "run_mlm.py", line 487, in <module>
>     main()
>   File "run_mlm.py", line 462, in main
>     trainer.log_metrics("train", metrics)
> AttributeError: 'Trainer' object has no attribute 'log_metrics'


transformers version: 4.3.3
torch version: 1.5.0+cu101

Comments:
You should install Transformers from source. See #10446.

This issue has been automatically marked as stale because it has not had recent activity. If you think this still needs to be addressed please comment on this thread.

Please note that issues that do not follow the [contributing guidelines](https://github.com/huggingface/transformers/blob/master/CONTRIBUTING.md) are likely to be ignored.
Exception: cannot import name 'Regex' from 'tokenizers' 
Author: xiliuhk
Pull request: no

From: site-packages/transformers/convert_slow_tokenizer.py
When first-time call: 
from transformers import XLMRobertaTokenizer
tokenizers-0.10.1 transformers-4.4.2

Comments:
same problem.

Edit: I updated the package "tokenizers" to the latest version and it works fine.

Hi! Do you have a colab so we can reproduce the issue? Or some commands we can run to obtain the same environment you have and test it out?

This issue has been automatically marked as stale because it has not had recent activity. If you think this still needs to be addressed please comment on this thread.

Please note that issues that do not follow the [contributing guidelines](https://github.com/huggingface/transformers/blob/master/CONTRIBUTING.md) are likely to be ignored.
Removes SageMakerTrainer code but keeps class as wrapper
Author: philschmid
Pull request: yes

# What does this PR do?

This PRs removes the `SageMakerTrainer` specific code since it has been merged into Trainer #10975. We had issues and bugs in `SageMakerTrainer` but not in `Trainer` since this class is already deprecated and will be removed in v5 of Transformers I removed the code for the next release. 
`SageMakerTrainer` will still work since all functionality has been migrated to `Trainer`. I tested it with `run_glue.py` 

Comments:
[Flax] Add Electra models
Author: CoderPat
Pull request: yes

# What does this PR do?

- Implement Flax version of Electra model and classes for different downstream tasks: 
  - `FlaxElectraModel`
  - `FlaxElectraForMaskedLM`
  - `FlaxElectraForPreTraining`
  - `FlaxElectraForMultipleChoice`
  - `FlaxElectraForQuestionAnswering`
  - `FlaxElectraForSequenceClassification`
  - `FlaxElectraForTokenClassification`
 
Most of the code taken from FlaxBert code and the Pytorch Electra code, and also adapted code from the original PR from @chris-tng  (credit where it's due since he started this in #9172 ).

Running the tests (including the slow ones) works, and I already tested in my downstream task and seems to be working


## 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.
- [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 who may be interested in your PR.

Tagging @patrickvonplaten @sgugger @chris-tng , feel free to tag other people



Comments:
I think I address most comments (the only thing missing is removing the `from_pt` when the flax checkpoint gets upload)! Thanks for the swift feedback

Hey @CoderPat,

We've merged a last design extension for the Flax design today, [here](https://github.com/huggingface/transformers/commit/f748bd424213ca8e76e6ad9ffe2beece2ff2655e) -> could you merge master into your PR one last time and adapt the code to add those extensions (example docstring + model outputs + all_attentions + all_hidden_states) - super sorry for the merge conflict again, but this will be the last one!
Issue in checkpointing
Author: yes1234man
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: 4.6.0
- Platform: - 
- Python version: 3.8
- PyTorch version (GPU?): 3.7
- Tensorflow version (GPU?): - 
- Using GPU in script?: - 
- Using distributed or parallel set-up in script?: - 

### Who can help
<!-- Your issue 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: @Rocketknight1

Library:

- benchmarks: @patrickvonplaten
- deepspeed: @stas00
- ray/raytune: @richardliaw, @amogkam
- text generation: @patrickvonplaten
- tokenizers: @LysandreJik
- trainer: @sgugger
- pipelines: @LysandreJik

Documentation: @sgugger

Model hub:

- for issues with a model report at https://discuss.huggingface.co/ and tag the model's creator.

HF projects:

- datasets: [different repo](https://github.com/huggingface/datasets)
- 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

 -->
@sgugger


## Information
Hi 
I am observing reloading after checkpoint does not get the same results. I searched and as mentioned here https://github.com/huggingface/transformers/issues/11323#issuecomment-822729525 , trainer currently does not save the random states to reload them as well, which is important. Could you add these info in self.state and set random states also in the trainer in the resume? that would be great 

thanks

## Expected behavior

After resume, one should get exact same results as training the models without break. 

Comments:
cannot access to pretrained vocab file on S3
Author: zeze-zzz
Pull request: no

Hi, thanks for develop well-made pytorch version of BERT.
Unfortunately, pretrained vocab files are not reachable.

error traceback is below.
> File "/usr/local/lib/python3.6/dist-packages/pytorch_pretrained_bert/tokenization.py", line 124, in from_pretrained
    resolved_vocab_file = cached_path(vocab_file)
  File "/usr/local/lib/python3.6/dist-packages/pytorch_pretrained_bert/file_utils.py", line 88, in cached_path
    return get_from_cache(url_or_filename, cache_dir)
  File "/usr/local/lib/python3.6/dist-packages/pytorch_pretrained_bert/file_utils.py", line 178, in get_from_cache
    .format(url, response.status_code))
OSError: HEAD request failed for url https://s3.amazonaws.com/models.huggingface.co/bert/bert-base-uncased-vocab.txt with status code 404

Comments:
I have the same issue. 

> OSError: HEAD request failed for url https://s3.amazonaws.com/models.huggingface.co/bert/bert-base-chinese-vocab.txt with status code 404


It would be nice to be able to cache the vocab files as well as the model weights out of the box.

I found temporary solution for this issue.
`BertTokenizer.from_pretrained` method accepts local file instead of model_name
ex) `BertTokenizer.from_pretrained('/dir/to/vocab/bert-base-uncased-vocab.txt')`

vocab txt file can be downloaded from [google bert repo](https://github.com/google-research/bert#pre-trained-models).

The files are back. Sorry, wrong manipulation while adding the new models.

> I found temporary solution for this issue.
> `BertTokenizer.from_pretrained` method accepts local file instead of model_name
> ex) `BertTokenizer.from_pretrained('/dir/to/vocab/bert-base-uncased-vocab.txt')`
> 


Well, this solution doesn't seem to be working now, I get 

`OSError: Model name 'path/to/model/vocab.txt' was not found in tokenizers model name list (bart-/model/large, bart-large-mnli, bart-large-cnn, bart-large-xsum). We assumed 'path/to/model/vocab.txt' was a path, a model identifier, or url to a directory containing vocabulary files named ['vocab.json', 'merges.txt'] but couldn't find such vocabulary files at this path or url. `

> I found temporary solution for this issue.
> `BertTokenizer.from_pretrained` method accepts local file instead of model_name
> ex) `BertTokenizer.from_pretrained('/dir/to/vocab/bert-base-uncased-vocab.txt')`
> 
> vocab txt file can be downloaded from [google bert repo](https://github.com/google-research/bert#pre-trained-models).

Hi, I add this file, however I got another error:

*** json.decoder.JSONDecodeError: Expecting value: line 1 column 2 (char 1)

Any help please?
[template runner CI] copies need to be fixed too
Author: stas00
Pull request: yes

This PR https://github.com/huggingface/transformers/pull/11475 gets model-templates job fail because it doesn't fix the copy and then `make fixup` fails, see: https://github.com/huggingface/transformers/pull/11475/checks?check_run_id=2502230586

Also it's unclear what purpose serves: `git fetch origin master:master` here:

https://github.com/huggingface/transformers/blob/2ce0fb84cc500a26b0c45bec1f8a42e33d13e05d/.github/workflows/model-templates.yml#L59

@LysandreJik, @sgugger 

Comments:
unable to import transformers in Python <3.8
Author: cdeepali
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: 4.4.2 
- Python version: 3.7


### Who can help
<!-- Your issue 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: @Rocketknight1

Library:

- benchmarks: @patrickvonplaten
- deepspeed: @stas00
- ray/raytune: @richardliaw, @amogkam
- text generation: @patrickvonplaten
- tokenizers: @LysandreJik
- trainer: @sgugger
- pipelines: @LysandreJik

Documentation: @sgugger

Model hub:

- for issues with a model report at https://discuss.huggingface.co/ and tag the model's creator.

HF projects:

- datasets: [different repo](https://github.com/huggingface/datasets)
- 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

 -->

## To reproduce

Steps to reproduce the behavior:

1. Install transformers
```
conda create -y -n py37-trans python=3.7 transformers -c HuggingFace
conda activate py37-trans
```
2. import transformers throws the following error:
`ModuleNotFoundError: No module named 'importlib_metadata'`

<!-- 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
Import should be successful. 
<!-- A clear and concise description of what you would expect to happen. -->


Comments:
I can add a PR to fix this.
Distil BART for text simplification
Author: jyotsna2893
Pull request: no
Labels: name: New model

# 🌟 New model addition

## Model description
Not completed yet. I will notify very soon when it is done.
If anyone has any leads regarding the same issue, please share. It would be great help.

Comments:
Can you provide a link to a paper, implementation and optional weights, if possible?

Hello NeilsRogge, I am building the model on basis of DistilBERT. I am still in the initial phase, but if you want to read/know more about it please go through this link
https://huggingface.co/transformers/_modules/transformers/models/distilbert/modeling_tf_distilbert.html#TFDistilBertModel