noamaanMulla-03/transformers-issues huggingface dataset:
docs: add HuggingArtists to community notebooks
Author: AlekseyKorshuk
Pull request: yes

# What does this PR do?

* Add [HuggingArtists](https://github.com/AlekseyKorshuk/huggingartists) project to [Community Notebooks](https://huggingface.co/transformers/master/community.html#community-notebooks) in documentation


## Before submitting

- [x] This PR fixes a typo or improves the docs (you can dismiss the other checks if that's the case).
- [ ] 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/)? https://discuss.huggingface.co/t/huggingartists-train-a-model-to-generate-lyrics/9045 
- [ ] 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 who may be interested in your PR.

@sgugger
<!-- 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: @LysandreJik

Library:

- benchmarks: @patrickvonplaten
- deepspeed: @stas00
- ray/raytune: @richardliaw, @amogkam
- text generation: @patrickvonplaten
- tokenizers: @n1t0, @LysandreJik
- trainer: @sgugger
- pipelines: @LysandreJik

Documentation: @sgugger

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

 -->


Comments:
Roll out the test fetcher on push tests
Author: sgugger
Pull request: yes

# What does this PR do?

This PR rolls out the test_fetcher script on the merged PR in master, making it so that:
- circleCI only runs the tests that are affected by the diff between the master branch and the last commit
- non slow single and multi GPU tests only runs the tests that are affected by the diff between the master branch and the last commit

The last thing to add is a scheduled job to run all those tests daily to make sure we don't miss anything.

Comments:
Spanish NER bad extraction
Author: diego6662
Pull request: no

## Environment info

- `transformers` version: 4.9.1
- Platform: linux-ubuntu 20.04.2 LTS x86_64
- Python version: 3.7.6
- PyTorch version (GPU?): No
- Tensorflow version (GPU?): No
- Using GPU in script?: No
- Using distributed or parallel set-up in script?: No

### Details
I used this hugginface model for NER extraction https://huggingface.co/mrm8488/bert-spanish-cased-finetuned-ner 
Input: "Efrain Avella"
Expected output :  {
    "entity_group": "PER",
    "score": 0.9992852807044983,
    "word": "Efrain Avella",
    "start": 0,
    "end": 12
  }
Transformers output: {
    "entity_group": "PER",
    "score": 0.9990411400794983,
    "word": "E",
    "start": 0,
    "end": 1
  },
  {
    "entity_group": "PER",
    "score": 0.8103020787239075,
    "word": "##frain Avella",
    "start": 1,
    "end": 13
  }



Comments:
Hello! Did you try with the `aggregation_strategy` parameter as mentioned in the [docs](https://huggingface.co/transformers/main_classes/pipelines.html#tokenclassificationpipeline)?

No, I used grouped_entities but I saw that it is deprecated, thanks, I will try it with the aggregation_strategy
MLM example not able to run_mlm_flax.py
Author: R4ZZ3
Pull request: no

I am going through this mlm exaxmple on Google TPU VM instance v3-8 https://github.com/huggingface/transformers/tree/master/examples/flax/language-modeling

I have defined MODEL_DIR with:
export MODEL_DIR="./norwegian-roberta-base"

I have defined symbolic link with:
ln -s home/Admin/Research/transformers/examples/flax/language-modeling/run_mlm_flax.py norwegian-roberta-base/run_mlm_flax.py

I am running with remove VS code and am able to run first 2 steps. now at run_mlm_flax_py if I run referring to symbolic link I am getting:
![image](https://user-images.githubusercontent.com/25264037/128644570-b7b04397-2077-4420-9f25-8e9277473939.png)

If I run directly the original script I am getting: 
![image](https://user-images.githubusercontent.com/25264037/128644580-68089b5c-d50a-4a90-8501-5b4945ada394.png)


![image](https://user-images.githubusercontent.com/25264037/128644591-fd843934-a67f-4714-b47e-5847404ac4a9.png)

Do you have some idea what I have done wrong?





Comments:
Hey @R4ZZ3,

Can you run:

```transformers-cli env```

And post the output here?

Sure, I will run it late this evening and post output here (UTC +3)

Ok, found time in between the day @patrickvonplaten 

- `transformers` version: 4.3.3
- Platform: Linux-5.4.0-1043-gcp-x86_64-with-debian-bullseye-sid
- Python version: 3.7.11
- PyTorch version (GPU?): not installed (NA)
- Tensorflow version (GPU?): not installed (NA)
- Using GPU in script?: To my knowledge this script should only use TPUs
- Using distributed or parallel set-up in script?: To my knowledge processing is spread out to 8 tpu cores

I did pull changes. Tokenizer saving gives error (Doing this from norwegian-roberta-base folder)

![image](https://user-images.githubusercontent.com/25264037/128717682-4484f027-2598-4ff5-848d-ecfe4c43ea51.png)


tokenizer.save(./tokenizer.json) works

I was able to fix symbolic link issue with by giving full paths but still have the same error with. Also FYI installed Pytorch 1.9 as I remember from Flax event that for some things it was necessary to have for some processing but no change to error
![image](https://user-images.githubusercontent.com/25264037/128721317-330a80c4-d9c1-46f9-9ca2-794ab76f4726.png)


Hey @R4ZZ3,

Could you please update your transformer version to a newer one? Ideally master for Flax examples as they have been added very recently?

Sure thing, ill try

Ok, now seems to move further @patrickvonplaten Thanks!
Still had to save tokenizer with tokenizer.save(./tokenizer.json) though

![image](https://user-images.githubusercontent.com/25264037/128925529-ced5f775-e9a4-43dc-bc0e-58085de28386.png)
Cannot import name 'BEiTForImageClassification' from 'transformers' 
Author: dnnxl
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! -->

Hi trying to run the BEiTForImageClassification in Google Colab and got the following error Cannot import name 'BEiTForImageClassification' from 'transformers'. Any suggestion on how to fix it?

- `transformers` version: 4.9.2
- Platform: Google Colab

Models:
- nielsr/beit-base-patch16-224


## To reproduce

Steps to reproduce the behavior:

Based on https://huggingface.co/nielsr/beit-base-patch16-224.
1. Run and using the following code
` ` ` 
from transformers import AutoTokenizer, BEiTForImageClassification  
tokenizer = AutoTokenizer.from_pretrained("nielsr/beit-base-patch16-224")
model = BEiTForImageClassification.from_pretrained("nielsr/beit-base-patch16-224")
` ` ` 

<!-- 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. -->
An error "Cannot import name 'BEiTForImageClassification' from 'transformers' "

Comments:
I have encountered the same problem, and solved it by re-installing `transformers` from the source via the following command:
`pip install git+https://github.com/huggingface/transformers` (for further details please see https://huggingface.co/transformers/installation.html). Installing from the source resulted in a `transformers ` version of 4.10.0, and then I could import the Beit models.

Another thing that caught my attention in your code sample is that there is a little typo that might also be causing the problem, the module to be imported is written as `BEiTForImageClassification`, however it is supposed to be `BeitForImageClassification`.

Thanks it solves the problem. Also for the clarification.
Rotate checkpoint `shutil.rmtree(checkpoint)` fails
Author: sbmaruf
Pull request: no

I was training `google/mt5-xl` model with `deepspeed` by huggingface trainer. The training was done in an aws `p3dn.24xlarge` node with 8V100 GPUs.
 
Trainer fails when [_rotate_checkpoints](https://github.com/huggingface/transformers/blob/7fcee113c163a95d1b125ef35dc49a0a1aa13a50/src/transformers/trainer.py#L1982) is called. Specifically in this [line](https://github.com/huggingface/transformers/blob/7fcee113c163a95d1b125ef35dc49a0a1aa13a50/src/transformers/trainer.py#L2005).
Apparently `shutil.rmtree` has this known [issue](https://github.com/ansible/ansible/issues/34335). 

Error Traceback:

```
Traceback (most recent call last):
  File "src/train.py", line 93, in <module>
    main()
  File "src/train.py", line 74, in main
    resume_from_checkpoint=checkpoint,
  File "transformers/src/transformers/trainer.py", line 1328, in train
    self._maybe_log_save_evaluate(tr_loss, model, trial, epoch)
  File "transformers/src/transformers/trainer.py", line 1409, in _maybe_log_save_evaluate
    self._save_checkpoint(model, trial, metrics=metrics)
  File "transformers/src/transformers/trainer.py", line 1528, in _save_checkpoint
    self._rotate_checkpoints(use_mtime=True, output_dir=run_dir)
  File "transformers/src/transformers/trainer.py", line 1954, in _rotate_checkpoints
    shutil.rmtree(checkpoint)
  File "/usr/lib/python3.6/shutil.py", line 490, in rmtree
    onerror(os.rmdir, path, sys.exc_info())
  File "/usr/lib/python3.6/shutil.py", line 488, in rmtree
    os.rmdir(path)
OSError: [Errno 39] Directory not empty: '/en-google_mt5-xl-1e-5-1234/checkpoint-320'
```


May be a `distributed barrier` is required for this to work properly.


@stas00 @sgugger

Comments:
This code is only called from the main process (controlled by [this test](https://github.com/huggingface/transformers/blob/24cbf6bc5a0b6a9bb5afdda6bb1a329ac980fa4b/src/transformers/trainer.py#L1593)) so it's a not a distributed barrier issue.

Unless you are using AWS SageMaker with the model parallel extension, that `should_save` is only True for the local main process (or main process). Could you please give us more information to reproduce the bug?

I didn't use `AWS SageMaker`. Since you requested for more information, I started to think about a minimal example. The codebase I was working with is too large and contains redundant codes.
I took the script `run_summarization.py` and tried running with my environment. What happened that my transformers version was `4.6.0` from this [branch](https://github.com/huggingface/transformers/tree/t5-fp16-no-nans). I change my `tranformers` to `4.10.0.dev0` and the problem goes away. I could not reproduce the error.
Closing the issue for the time being. If I face the same error, I will open the issue again. 

Ah, if you were on an older version, the barrier may not have been there, yes.
How do i pre-train Bert_mlm model [Discussion]
Author: mosh98
Pull request: no

Hi, 
i've been able to pre train a Bert model using the run_mlm.py file. Thanks to huggingface team ofc. :D

I do have one question tho, if i want to further pre train a bert_mlm model, do i use the same pre training script such as run_mlm.py for the mlm model. Is that the "correct" way or is there another type of training script i should use.


Any help is much appreciated

Comments:
@NielsRogge 
@sgugger 

Any thoughts?

Kind regards,
Mosleh

Hi there! Please use the [forums](https://discuss.huggingface.co/) for questions like this, as we keep the issues for bugs and feature requests only.

As for your question, you can fine-tune any existing model with that `run_mlm` script.

Hi,

Alright thanks, i'll post in forums next time.

/Mosleh
[Doctest] Setup, quicktour and task_summary
Author: sgugger
Pull request: yes

# What does this PR do?

This PR starts the work of re-enabling the doc tests and makes sure our documentation uses the latest version of the APIs. For the doctest setup, it registers the options we will need for `doctest` in the setup.cfg.

For the quicktour and task_summary, it tweaks all results to match the output of the code so the doctests pass for those two files, and removes the use of deprecated APIs (AutoModelWithLMHead) as well as favoring the call method of the tokenizers over the encode method.

Comments:
Is there any convenient way to train a transformer from scratch ?
Author: Hannibal046
Pull request: no

Hello guys!
`Huggingface/transformers` is such a convenient library to use when it comes to all sorts of pertained model. But I am wondering is there a convenient way to train a model from scratch ?
If I want to rebuild the model in `Attention is all you need` , the first thought came into my mind is change modeling_bart.py to adapt to`Attention is all you need` setting like `three way weight tying`,,and do not using `.from_pretrained`, 
Is there any better way to do it ?
I know this is a **pertained_model** library , but isn't is be cool to do something more with it?
I am looking forward to your reply

Comments:
Hello, thanks for opening an issue! We try to keep the github issues for bugs/feature requests.
Could you ask your question on the [forum](https://discuss.huggingface.co) instead?

There are a few scripts related to pretraining: [language-modeling examples](https://github.com/huggingface/transformers/tree/master/examples/pytorch/language-modeling)

Thanks!
Tensorboard error while running mlm_flax TPU example script on TPU
Author: BirgerMoell
Pull request: no

## Environment info
Following the https://github.com/huggingface/transformers/tree/master/examples/research_projects/jax-projects#how-to-setup-tpu-vm

## Script

./run_mlm_flax.py \
    --output_dir="./" \
    --model_type="roberta" \
    --config_name="./" \
    --tokenizer_name="./" \
    --dataset_name="oscar" \
    --dataset_config_name="unshuffled_deduplicated_als" \
    --max_seq_length="128" \
    --per_device_train_batch_size="4" \
    --per_device_eval_batch_size="4" \
    --learning_rate="3e-4" \
    --warmup_steps="1000" \
    --overwrite_output_dir \
    --num_train_epochs="8" \
    --push_to_hub

## Error
v  File "./run_mlm_flax.py", line 66
    print(f"Unable to display metrics through TensorBoard because some package are not installed: {ie}")
                                                                                                      ^
## Information
Tensorboard is already installed using pip install tensorboard


Comments:
Can you send me your tpu_name & name of virtual environment in a personal Slack message? I'll have a look

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.
Reactive test fecthers on scheduled test with proper git install
Author: sgugger
Pull request: yes

# What does this PR do?

This PR reactivates the test fecther on the scheduled jobs, now that we have debug the root of the issue: PyTorch docker image does not contain a recent `git` version, which in turns does not work properly with GitHub actions, so we need to:
- install it manually
- **then** check out the repo after.

Comments:
Can not instantiate `PreTrainedTokenizerFast` from instantiated tokenizer object
Author: brand17
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.3.2
- Platform: Windows
- Python version: 3.6.6
- PyTorch version (GPU?): N/A
- Tensorflow version (GPU?): 2.3.0
- Using GPU in script?: No
- Using distributed or parallel set-up in script?: No

### Who can help
@LysandreJik

## Information

Model I am using (Bert, XLNet ...):

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)
* [ ] my own task or dataset: (give details below)

## To reproduce

Steps to reproduce the behavior:

1. Run the following script:

```
from tokenizers import Tokenizer
tok = Tokenizer(BPE(unk_token="[UNK]"))
trainer = BpeTrainer(special_tokens=["[UNK]", "[CLS]", "[SEP]", "[PAD]", "[MASK]"])
tok.pre_tokenizer = Whitespace()
def it():
  for t in ['one', 'two', 'three']:
    yield t

tok.train_from_iterator(it(), trainer)
from transformers import PreTrainedTokenizerFast
tok = PreTrainedTokenizerFast(tokenizer_object=tok)

```

I am getting error:

> Exception has occurred: ValueError       (note: full exception trace is shown but execution is paused at: _run_module_as_main)
> Couldn't instantiate the backend tokenizer from one of: (1) a `tokenizers` library serialization file, (2) a slow tokenizer instance to convert or (3) an equivalent slow tokenizer class to instantiate and convert. You need to have sentencepiece installed to convert a slow tokenizer to a fast one.
> 

I have sentencepiece installed (0.1.91).

## Expected behavior

No error

Comments:
The ability to load a tokenizer object directly was introduced in version v4.5.x! Could you upgrade your `transformers` version to a more recent one?
Add VisualBERT demo notebook
Author: gchhablani
Pull request: yes
Labels: name: WIP

In continuation with #10534, this PR adds demo for VisualBERT model.
I am planning to base it on the `LXMERT` examples, hence the copy-paste of files for now.

Comments:
I have updated the demo. Turns out I didn't need to change a lot from the LXMERT demo. I have used the same files, just replaced the tokenizer, the model and the labels that are being used. Only `demo.ipynb` is different.

Requesting @LysandreJik @patil-suraj to review.

Thanks for approving and merging @patil-suraj @LysandreJik ^_^
Fix VisualBert Embeddings
Author: gchhablani
Pull request: yes

# What does this PR do?
This PR addresses the issue mentioned in #13001. The `self.input_embeds` has been replaced with `self.position_ids` as suggested by @NielsRogge.

Comments:
Did you verify that it fixes the error mentioned in the issue?

i.e. does the following work:

```
from transformers import BertTokenizer, VisualBertModel
tokenizer = BertTokenizer.from_pretrained('bert-base-uncased')
model = VisualBertModel.from_pretrained('uclanlp/visualbert-vqa-coco-pre')
inputs = tokenizer("The capital of France is Paris.", return_tensors="pt")
visual_embeds =  torch.zeros((1,36,2048)) #example of ROI features
visual_token_type_ids = torch.ones(visual_embeds.shape[:-1], dtype=torch.long) #example
visual_attention_mask = torch.ones(visual_embeds.shape[:-1], dtype=torch.float)
inputs.update({{
    "visual_embeds": visual_embeds,
    "visual_token_type_ids": visual_token_type_ids,
    "visual_attention_mask": visual_attention_mask
}})
outputs = model(**inputs)
```

@NielsRogge

Yes. I tried it for the example and it works fine.

@NielsRogge Does this look okay?

Idont understand
can predict_with_generate (do_eval) work with sharded_ddp fairscale in 4.6.1+?
Author: gyin94
Pull request: no

In 4.5.0, sharded_ddp won't work with  predict_with_generate in seq2seq or clm model training during the eval step. Wonder whether it can work in the latest version. 

Comments:
Can I ask whether we have any progress on the model prediction (text generation) during the training with fairscale? Thanks/ cc @stas00 

most likely you'd want to ask @sgugger as I he did the fairscale integration. 

you can ask me about the deepspeed integration if you try that instead.

`sharded_ddp` does not work for evaluation, as is mentioned in the documentation. I have mentioned that on the fairscale repository but did not get any update for the authors (same for the blocking aprt of Zero offload via fairscale) so I suggest you use DeepSpeed instead, where we have a much better support from the team at Microsoft.

and if fairscale solves the problem on their side and the work resumes in this direction, the key to making generate work might have to include the enabling `synced_gpus` here for fairscale (for zero3-like fairscale features that is):

https://github.com/huggingface/transformers/blob/fb65f65ea6175036f0cc8318145853e9c833f914/src/transformers/trainer_seq2seq.py#L164

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.
Fix omitted lazy import for xlm-prophetnet
Author: minwhoo
Pull request: yes

# What does this PR do?

Fixes import code for the xlm-prophetnet model to support lazy import. Continued from #13015.

## 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?


Comments:
The failures are unrelated to this PR (and the underlying problem is fixed on master) so can be safely ignored.

One last thing: can you run `make style` on your branch to fix the quality issue? We should be good to go after.