noamaanMulla-03/transformers-issues huggingface dataset:
Fix usage of additional kwargs in `from_encoder_decoder_pretrained` in encoder-decoder models
Author: jsnfly
Pull request: yes

# What does this PR do?

Somewhat continuing https://github.com/huggingface/transformers/pull/15043 but concerning all of the encoder-decoder models:
If, like in this [example](https://github.com/huggingface/transformers/blob/f71fb5c36e739d8224419bb091b4c16531df829f/examples/pytorch/speech-recognition/README.md?plain=1#L218), extra keyword arguments are used with `from_encoder_decoder_pretrained` it raises an error:
```pthon
TypeError: __init__() got an unexpected keyword argument 'add_adapter'
```
This is because the arguments [should be part of the config](https://github.com/huggingface/transformers/blob/f71fb5c36e739d8224419bb091b4c16531df829f/src/transformers/models/auto/auto_factory.py#L136).

This PR tries to fix this issue.


## Before submitting
- [ ] 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?
- [ ] 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?

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.
@patrickvonplaten


Comments:
Hey @jsnfly,

sorry for answering so late. Great job on identifying the problem! I left some improvements as comments in the PR. The problem is that if we remove `**kwargs_encoder` from `AutoModel.from_pretrained(...)` we loose functionality - *e.g.* if someone would pass `local_files_only=True`. 

Could you maybe adapt all examples as shown for `EncoderDecoderModel` above? :-) Think then we can merge this one!

Hey @patrickvonplaten,

thank you for the suggestions, they do indeed make the code a lot cleaner and more functional! Let me know if there are additional improvements.

> indeed

Great job @jsnfly! Checked it locally and everything works perfectly fine :-) 



Great job merging this PR! the documentation will now be removed from the staging environment.
Add FastTokenizer to REALM
Author: qqaatw
Pull request: yes

# What does this PR do?

This is a follow-up PR of https://github.com/huggingface/transformers/pull/13292#discussion_r786162541 and https://github.com/huggingface/transformers/pull/13292#discussion_r780749863.

This PR removes the `BertTokenizer` abstraction and adds a `FastTokenizer` to REALM.

<!-- Remove if not applicable -->

Fixes # (issue)


## Before submitting
- [ ] 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?
- [ ] 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?

@patrickvonplaten @patil-suraj @sgugger 

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.

<!-- 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:
Is there any script for running RACE dataset?
Author: whaor
Pull request: no

# 🚀 Feature request

examples/multiple-choice/run_swag.py
is the script for running SWAG dataset, although readme says that a tweak of preprocess_function() should get things work for RACE dataset, but i still can not figure it out with this little information. is there any information about how to run RACE?


Comments:
Add truncation_side option to tokenizers
Author: NielsRogge
Pull request: yes
Labels: name: WIP

# What does this PR do?

As requested by #12909, it would be handy if one could also decide on whether to truncate sequences from the left instead of from the right. 

As we already have a `padding_side` (which can be either left/right), it makes sense to also add a `truncation_side` (which by default is set to `"right"`, but users can initialize a tokenizer with `truncation_side` set to `"left"`).

The test could possibly be improved (for which I'd like to get some help).

Also requesting review from @patrickvonplaten since I've also added the option in `feature_extraction_sequence_utils.py`. 

Regarding the fast tokenizers, I see `padding_side` is used [here](https://github.com/huggingface/transformers/blob/12e02e339f6d19218b36a30883188ea0254bc7e7/src/transformers/tokenization_utils_fast.py#L362). Should I define something similar for `truncation_side`?

Fixes #12909 

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.

~Gentle ping @NielsRogge for when you have a chance to wrap this up~ Issue opened in tokenizers :)

It is waited for more than a year now (https://github.com/huggingface/transformers/issues/4476#issuecomment-677823688). Please implement this (even if it works out just for ordinary tokenizers), for people to use now this solution, while users of Rust tokenizers wait for the fast tokenizers solution (https://github.com/huggingface/tokenizers/issues/779).

Fixed per #14947.
Update README.md
Author: anton-l
Pull request: yes

# What does this PR do?

Adds an OVHcloud tutorial URL for the Robust Speech Challenge

Comments:
Thank you for your PR! The docs for this PR live [here](https://moon-ci-docs.huggingface.co/docs/transformers/pr_15239). All of your documentation changes will be reflected on that endpoint.

Great job merging this PR! the documentation will now be removed from the staging environment.
run_glue.py with XLNet model on CoLA dataset reaches 0 accuracy
Author: yonatanbitton
Pull request: no
Labels: name: wontfix

## Environment info
- `transformers` version: 4.1.1
- Platform: Linux
- Python version: 3.6.10
- PyTorch version (GPU?): 1.7.0 (True)
- Tensorflow version (GPU?): not installed (NA)
- Using GPU in script?: Yes
- Using distributed or parallel set-up in script?: No
     
### Who can help
@TevenLeScao 

## Information
Model I am using: XLNet

The problem arises when using:
*  The official example scripts of `run_glue.py`

The tasks I am working on is:
* an official GLUE: CoLA

## To reproduce

Steps to reproduce the behavior:
I am using the "run_glue" cmd as described here: https://github.com/huggingface/transformers/tree/master/examples/text-classification
`python run_glue.py --task_name cola  --model_name_or_path xlnet-base-cased --do_train --do_eval --max_seq_length 128 --per_device_train_batch_size 32 --learning_rate 2e-5 --num_train_epochs 3.0 --do_predict --overwrite_output_dir`

That's the results I get: 
```
[p]$ cat res_cola_xlnet.txt 
eval_loss = 0.612945020198822
eval_matthews_correlation = 0.0
epoch = 3.0
```

## Expected behavior

Results > 0

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.

Hi, did you fix this issue? I also got this problem when using BART-large.
Fixes tf_default_data_collator sometimes guessing the wrong dtype for labels
Author: Rocketknight1
Pull request: yes

Fixes issues reported by @philschmid in [this notebook](https://colab.research.google.com/drive/13nMZPJpgJpqzdl2e5t4cnV26m_l2xwlw?usp=sharing) with `labels` occasionally ending up as `tf.float32` instead of `tf.int64`. 

The underlying cause was that the `dtype` checking code failed in cases when the label for a single example was a Numpy scalar - this caused `isinstance(np.ndarray)` to return `False`. Adding `or isinstance(np.generic)` correctly catches Numpy scalars as well as arrays.

Comments:
Thank you for your PR! The docs for this PR live [here](https://moon-ci-docs.huggingface.co/docs/transformers/pr_15234). All of your documentation changes will be reflected on that endpoint.

Great job merging this PR! the documentation will now be removed from the staging environment.
add support to DistilBertLMHeadModel
Author: kwang2049
Pull request: yes

# What does this PR do?

Fixes #14737 
Goal: Add support to DistilBertLMHeadModel
Changes: 

1. Modified [modeling_distilbert.py](https://github.com/huggingface/transformers/blob/master/src/transformers/models/distilbert/modeling_distilbert.py): Changed `MultiHeadSelfAttention`, `Transformer`, `TransformerBlock` to model cross-attention and accept arguments `encoder_hidden_states` & `encoder_attention_mask `; and added the new class `DistilBertLMHeadModel`;
2. Expose the new class and register it everywhere needed.

## Before submitting
- [x] 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).
- [ ] Did you write any new necessary tests?

## Who can review?
@VictorSanh @thomwolf @patil-suraj 

Comments:
Thanks for the PR! There's a similar PR here #11085, which is almost complete, so let's wait for the author to see if he's still interested to finish it :) 

> Thanks for the PR! There's a similar PR here #11085, which is almost complete, so let's wait for the author to see if he's still interested to finish it :)

Thanks for your attention! OK, let me also have a look at what is going on there and anything I can help:).

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.
Make sure to raise NotImplementedError with correct method name
Author: kumapo
Pull request: yes

# What does this PR do?

I've found a message raised with `NotImplementedError` by `PreTrainedModel._init_weights()` is not correct.
This PR resolves that.

## 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?

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.


Comments:
Thank you for your PR! The docs for this PR live [here](https://moon-ci-docs.huggingface.co/docs/transformers/pr_15253). All of your documentation changes will be reflected on that endpoint.

Great job merging this PR! the documentation will now be removed from the staging environment.
Fix crash when logs are empty because Keras has wiped them out of spite
Author: Rocketknight1
Pull request: yes

In situations where the training history is empty, TF model card creation via `model.create_model_card()` or `model.push_to_hub()` no longer crashes.

Comments:
Thank you for your PR! The docs for this PR live [here](https://moon-ci-docs.huggingface.co/docs/transformers/pr_15258). All of your documentation changes will be reflected on that endpoint.

Great job merging this PR! the documentation will now be removed from the staging environment.
Tentative workflow improvement
Author: LysandreJik
Pull request: yes

This improves the workflow of the doc-builder bot by adding a single comment when the PR is opened.

When the PR is closed or merged, it edits that comment. If the PR is reopened, it re-edits that comment.

Comments:
_The documentation is not available anymore as the PR was closed or merged._

See the edits of the comment above.

I'm ok with both solutions 1 and 3 - I agree that it might be odd for the comment to be deleted, and hiding the comment removes that peculiarity.

If it's ok with you, I'll merge this PR as it is, as it is already an improvement of the workflow. I'm very open to any PR you offer regarding 1 or 3.

**Seems it works again**

off topic - but today when I checked the link, I always get 
```
404

Sorry, we can’t find the page you are looking for.
```

Yesterday, I saw it worked. (Maybe @LysandreJik you are already aware of this fact?)

Hey @ydshieh, I believe these are due to errors on our backend; we're currently setting up a system that would make for a better way to share that info with the contributors. In the meantime, please do not hesitate to ping us on the PRs themselves with the commit that failed to be deployed. Thank you!
Addition of Swin Transformer for Computer Vision
Author: bhadreshpsavani
Pull request: no
Labels: name: New model

# 🌟 Addition Swin Transformer

## Model description
Swin Transformer (the name Swin stands for Shifted window) is initially described in arxiv, which capably serves as a general-purpose backbone for computer vision. It is basically a hierarchical Transformer whose representation is computed with shifted windows. The shifted windowing scheme brings greater efficiency by limiting self-attention computation to non-overlapping local windows while also allowing for cross-window connection.

Swin Transformer achieves strong performance on COCO object detection (58.7 box AP and 51.1 masks AP on test-dev) and ADE20K semantic segmentation (53.5 mIoU on Val), surpassing previous models by a large margin.

## Open source status

* [x] the model implementation is available: https://github.com/microsoft/Swin-Transformer
* [x] the model weights are available: https://github.com/microsoft/Swin-Transformer
* [x] who are the authors: [Swin Transformer](https://arxiv.org/pdf/2103.14030.pdf)

## Possible Task Support:
Opensource Version Supports below tasks
* Image Classification
* Object Detection
* Instance Segmentation
* Semantic Segmentation
* Video Recognition


Comments:
Maybe of interest to @NielsRogge 

Hello, I would like to work on adding Swin. I will put out a PR sometime soon.


Hey @novice03, thanks for your effort! I believe that @FrancescoSaverioZuppichini is in the process of adding the `Mask2Former` model which depends on Swin, so he's probably working on that too. 

I'll let him share more about his work.
[ViTMAE] Add image pretraining script
Author: NielsRogge
Pull request: yes

# What does this PR do?

This PR adds an example script to a new folder, "image-pretraining". It allows the user to pre-train a Vision Transformer (ViT) using the [MAE](https://arxiv.org/abs/2111.06377) method. More specifically, one can pre-train a `ViTMAEForPreTraining` with the script. After pre-training, one can easily load the weights into a `ViTForImageClassification`, obtaining SOTA accuracy. 🥇 

Some things that require some feedback:

- regarding providing a custom dataset: this should be updated in the README. The original script uses torchvision's handy ImageFolder as seen [here](https://github.com/facebookresearch/mae/blob/6a2ba402291005b003a70e99f7c87d1a2c376b0d/main_pretrain.py#L128). Can we have something similar with `datasets`? ([#2830](https://github.com/huggingface/datasets/pull/2830))
- hyperparameters: here are the ones used in the original paper:
<img width="521" alt="Schermafbeelding 2022-01-20 om 10 22 07" src="https://user-images.githubusercontent.com/48327001/150310271-5d3afc1b-43a9-46be-bc9b-d7a53c9c65de.png">

=> I'd like to mimic these as closely as possible.

Comments:
_The documentation is not available anymore as the PR was closed or merged._

We do have a speech-pretraining folder in the examples directory, which also only works for a single model (`Wav2Vec2ForPreTraining`).

Do what you want then :-)
Prepare ONNX export for torch v1.11
Author: lewtun
Pull request: yes

# What does this PR do?

This PR prepares the ONNX export for `torch` v1.11, where the following arguments from the [`torch.onnx.export()` ](https://pytorch.org/docs/stable/onnx.html#torch.onnx.export)function will be removed:

* `use_external_data_format`
* `enable_onnx_checker`

A simple check on the `torch` version is used to ensure backwards compatibility with versions < 1.11

I've also tested that the slow tests pass on the nightly version of `torch` by running:

```
RUN_SLOW=1 pytest tests/test_onnx_v2.py
```



Comments:
_The documentation is not available anymore as the PR was closed or merged._
Move BART + ONNX example to research_projects
Author: lewtun
Pull request: yes

# What does this PR do?

This PR moves the BART + ONNX example contributed in #14310 under the `examples/research_projects` folder to indicate that it is not actively maintained by the `transformers` team.

cc @fatcat-z 


Comments:
_The documentation is not available anymore as the PR was closed or merged._
Fix
Author: novice03
Pull request: yes

# What does this PR do?

Fixes some suggestions not addressed in [this](https://github.com/huggingface/transformers/pull/15085/) pull request.

I've fixed the typo and unnecessary imports, but running `make style` may not allow some parts of the code to stay in the same line.

## Who can review?

@sgugger 

Comments:
_The documentation is not available anymore as the PR was closed or merged._

Hello, the `check_code_quality` fails now. Running `make style` will revert all the changes I made to the modeling file, so some parts of the code will not stay in the same line. 

In the previous commit, I removed trailing commas and put the code in the same line, but the check still fails. In the next commit, I'll run `make style`.

Thanks again!
Benchmark link in transformers/notebooks/README.md is broken
Author: evandrosks
Pull request: no

Hi @sgugger,

I noticed the link in the transformers/notebooks/README.md (https://github.com/huggingface/transformers/tree/master/notebooks) for the Benchmarks notebook is broken.

I believe the correct link should be: https://github.com/huggingface/notebooks/blob/master/examples/benchmark.ipynb



Comments:
Thanks for flagging this! Do you want to a make a PR to fix it?

Sure, I'll send one shortly
corrected typo in robust speech event README.md regarding OVH Cloud link
Author: mattchurgin
Pull request: yes

# What does this PR do?
Corrects a typo in robust speech event README that incorrectly directed US users to the Canadian OVH Cloud site.

## Before submitting
- [X] This PR fixes a typo or improves the docs (you can dismiss the other checks if that's the case).

## Who can review?
@patrickvonplaten @anton-l 


Comments:
_The documentation is not available anymore as the PR was closed or merged._

US OVHcloud service is sadly not supported by this event
Refine errors for pretrained objects
Author: sgugger
Pull request: yes

# What does this PR do?

This PR breaks refines the error returned for pretrained objects using the error codes now returned by hf.co to clearly indicate to the user if:
- there is a problem in the repo name
- there is a problem in the revision
- there is a problem with a specific file
- there is a general connection error

Whenever we are in a situation where the model has a version in another framework, a helpful error message is shown.

Also note that this PR removes the hard failure on `get_list_of_files` whenever there is a connection problem, which should make the CI way less flaky.

Comments:
_The documentation is not available anymore as the PR was closed or merged._
TypeError: stat: path should be string, bytes, os.PathLike or integer, not NoneType
Author: pratikchhapolika
Pull request: no

I am downloading the model <<https://huggingface.co/microsoft/Multilingual-MiniLM-L12-H384/tree/main>> **microsoft/Multilingual-MiniLM-L12-H384** and then using it.

**Transformer Version: '4.11.3'**

Following are the files in the links:
<img width="277" alt="Screenshot 2021-12-14 at 3 29 09 PM" src="https://user-images.githubusercontent.com/11159549/145976626-afde48a9-224f-4298-817c-e56a912ec036.png">



When I use this line:

`tokenizer = tr.BertTokenizer.from_pretrained("/home/pchhapolika/minilm_model/")`


**Error: TypeError: stat: path should be string, bytes, os.PathLike or integer, not NoneType**

Comments:
How are you downloading the files, and what are the size of the files @pratikchhapolika ?

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.