noamaanMulla-03/transformers-issues huggingface dataset:
Raise AttributeError on training deberta models with gradient checkpointing
Author: kumapo
Pull request: no
Labels: name: bug

### System Info

```shell
- `transformers` version: 4.20.1
- Platform: Linux-5.4.188+-x86_64-with-Ubuntu-18.04-bionic
- Python version: 3.7.13
- Huggingface_hub version: 0.8.1
- PyTorch version (GPU?): 1.11.0+cu113 (True)
- Tensorflow version (GPU?): 2.8.2 (True)
- Flax version (CPU?/GPU?/TPU?): not installed (NA)
- Jax version: not installed
- JaxLib version: not installed
- Using GPU in script?: yes
- Using distributed or parallel set-up in script?: no
```


### Who can help?

@LysandreJik

### Information

- [ ] The official example scripts
- [X] My own modified scripts

### Tasks

- [ ] An officially supported task in the `examples` folder (such as GLUE/SQuAD, ...)
- [X] My own task or dataset (give details below)

### Reproduction

- deberta models and `Trainer` with `gradient_checkpointing=True`
- `trainer.train()`
- raise `AttributeError: module 'torch.utils' has no attribute 'checkpoint'`

Refs #9617


### Expected behavior

```shell
nothing raised on training with `gradient_checkpointing=True`.
```


Comments:
Fix: torch.utils.checkpoint import error.
Author: kumapo
Pull request: yes

# What does this PR do?

missing import statements still happens on training deberta models with gradient checkpointing.
Fixes #17848

## 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/main/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/)? 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/main/docs), and
      [here are tips on formatting docstrings](https://github.com/huggingface/transformers/tree/main/docs#writing-source-documentation).
- [ ] Did you write any new necessary tests?


## Who can review?

@LysandreJik


Comments:
_The documentation is not available anymore as the PR was closed or merged._
Use higher value for hidden_size in Flax BigBird test
Author: ydshieh
Pull request: yes

# What does this PR do?

#17658 changed `hidden_size` from `32` to `4` in `FlaxBigBirdModelTester`, which cause the PT/Flax difference increased by ~ 50 times. This PR changes it back (but keep other changes untouched). We can therefore use `1e-5` instead of `5e-5`.

(`hidden_size=4` with `num_attention_heads=2` is likely to introduce some edge cases in random init.)

The testing time (on GCP CPU VM)  is 66 vs. 64 seconds (with `-n 1`) and 46 vs. 44 seconds (with `-n 2`), so this change doesn't make the test slower.

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

@patil-suraj  If you have one minute to review this one, I can merge it today 😄 🙏 but not urgent
Fix Maskformer test
Author: ydshieh
Pull request: yes

# What does this PR do?

Fix Maskformer test `test_multi_gpu_data_parallel_forward`.

Ignore the test, as the original workaround will break current checkpoints.

------
Original Attempt

I know we probably want to avoid using `nn.DataParallel(model)`. But before doing so, I just tried my best to fix tests.
After spending some time debugging, I find using `add_module` instead of `nn.Sequential` causing problems.

I am not sure if the change in this PR is what we prefer though.

@NielsRogge Is there any reason to use `add_module`? I don't know if the comment regarding `Provide backwards compatibility ...` is really necessary.

https://github.com/huggingface/transformers/blob/d88719581b34f301edcc7772d927d8a3e3a77af6/src/transformers/models/maskformer/modeling_maskformer.py#L1986

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

You are right, 

prev (and checkpoint on Hub): `model.pixel_level_module.decoder.fpn.stem.0.weight`

this PR: `model.pixel_level_module.decoder.fpn.stem.layers.1.weight` --> Get extra `layers` attribute


I will ignore the test

But maybe let's use `self.layers = nn.Sequential(...)` for future models in the 1st place?

Yes, the problem here is that the model inherited from `nn.Sequential`, which was a mistake. And to fix it, we had to go through this hacky way. But it's definitely not the recommended approach!

Test skipped now.
Fix test_inference_instance_segmentation_head
Author: ydshieh
Pull request: yes

# What does this PR do?

Current `test_inference_instance_segmentation_head` (in `MaskFormerModelIntegrationTest`) failed in CI.
The expected slice 
```python
[[-1.3738, -1.7725, -1.9365], [-1.5978, -1.9869, -2.1524], [-1.5796, -1.9271, -2.0940]]
```
has precision `4` and `atol` argument (`TOLERANCE`) is also `1e-4`, which makes the difference at the boundary. This is **likely** the cause of test failures. Give more precision for the expected values should fix the issue.

```bash
(Pdb) diff1 # (with original expected values)
0.0001039505
(Pdb) diff2 # (with more precision)
1.4066696e-05
```

(However, I am not able to get the test failure with the original setting, launched manually in a GCP VM.)

Comments:
_The documentation is not available anymore as the PR was closed or merged._
Add type hints for gptneox models
Author: willtai
Pull request: yes

# What does this PR do?
Adding missing type hints for `GPTNeoxForCausalLM` and `GPTNeoXModel` as referenced in this issue.(https://github.com/huggingface/transformers/issues/16059#issuecomment-1164898772).

## Before submitting
- [x] Did you read the [contributor guideline](https://github.com/huggingface/transformers/blob/main/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/)? 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/main/docs), and
[here are tips on formatting docstrings](https://github.com/huggingface/transformers/tree/main/docs#writing-source-documentation).
- [ ] Did you write any new necessary tests?

## Who can review?
Anyone in the community please feel free to review😄

@Rocketknight1


Comments:
_The documentation is not available anymore as the PR was closed or merged._
Allow passing encoder_ouputs as tuple to EncoderDecoder Models
Author: jsnfly
Pull request: yes

# What does this PR do?

Fixes #15536

For now I have added a test of the functionality to an existing test, since I'm not sure if there should be a separate test (or a test at all) for such a minor issue. Let me know if there is a better way.

## 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/main/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/)? Please add a link
      to it if that's the case.
https://github.com/huggingface/transformers/issues/15536
- [ ] Did you make sure to update the documentation with your changes? Here are the
      [documentation guidelines](https://github.com/huggingface/transformers/tree/main/docs), and
      [here are tips on formatting docstrings](https://github.com/huggingface/transformers/tree/main/docs#writing-source-documentation).
- [x] Did you write any new necessary tests?


## Who can review?

@patrickvonplaten 

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


@jsnfly , thanks you for this PR... Is it possible to do this fix for a T5 model as well.. It is also a sequence to sequence models and sometime we may want to pass a tuple to the decoder.
404 Errors on Loading Artifacts due to mispellings could suggest a model/tokenizer/dataset to the API user in the error message.
Author: domenicrosati
Pull request: no

### Feature request

When loading a model/tokenizer/config/Datasets with Auto* (or even other loader classes). It would be fun to autosuggest a model from HF hub if you make a typo in the 404 error message from the API. 

Feel free to close this if you think its silly and freviolous.

An implementation could use edit distance of input string to  models or tokenizer... or perform a search with that string using the model hub search API.



### Motivation

Sometimes folks misspell or forget the name of a model/tokenizer/config, it might be nice to suggest the correction in the error message!

### Your contribution

Sure thing, yes I could make a PR, if this is something other people would want.

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/main/CONTRIBUTING.md) are likely to be ignored.
Illegal instruction (core dumped) error: PowerPC8
Author: leonardottl
Pull request: no
Labels: name: bug

### System Info

```shell
transformers              2.5.1
python3.8
pytorch                   1.10.2 

All packages installed with conda by way of the conda-forge or powerai repositories, all of them are ppc64-le compatible
```


### Who can help?

I am trying to load a BERT pre-trained model. All imports work fine, and loading the tokenizer works fine, but loading the model does not.

I am running on an nvidia-docker2 container for pytorch, namely ibmcom/pytorch-ppc64le  with updated libraries using only powerai repositories. The error occurs here:

import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
import torch
import torch.nn as nn
from sklearn.model_selection import train_test_split
from sklearn.metrics import classification_report
import transformers
from transformers import BertTokenizer, BertForSequenceClassification

model = BertForMaskedLM.from_pretrained("dccuchile/bert-base-spanish-wwm-uncased")

@LysandreJik 

### Information

- [ ] The official example scripts
- [ ] My own modified scripts

### Tasks

- [ ] An officially supported task in the `examples` folder (such as GLUE/SQuAD, ...)
- [ ] My own task or dataset (give details below)

### Reproduction

import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
import torch
import torch.nn as nn
from sklearn.model_selection import train_test_split
from sklearn.metrics import classification_report
import transformers
from transformers import BertTokenizer, BertForSequenceClassification

model = BertForMaskedLM.from_pretrained("dccuchile/bert-base-spanish-wwm-uncased")

### Expected behavior

```shell
What is expected is that the model loads and I can use it to further train it.
```


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/main/CONTRIBUTING.md) are likely to be ignored.
add doctests for data2VecText
Author: artemisep
Pull request: no

### Feature request

Enable doctests for data2VecText model, as part of https://github.com/huggingface/transformers/issues/16292

### Motivation

please see https://github.com/huggingface/transformers/issues/16292

### Your contribution

implement this feature

Comments:
Hey @Ruihua-Fang,

Would you like to give it a try? :-)

Hey @patrickvonplaten , yep, Thanks :)


Following the instruction in https://github.com/huggingface/transformers/issues/16292 as listed below:
Make sure to run the doc example doc test locally as described in https://github.com/huggingface/transformers/tree/master/docs#for-python-files
5 failed, 2 passed
see attached file for detailed 
[doctest_data2vec_text_errormsg.txt](https://github.com/huggingface/transformers/files/8730807/doctest_data2vec_text_errormsg.txt)
error messages 

p.s, for sanity check, I also run the doctest sample for the following:

bigbird_pegasus: all 5 tests passed
data2vec_audio in the same folder: 1 failed, 4 passed

error message for data2vec_audio:
[doctest] transformers.models.data2vec.modeling_data2vec_audio.Data2VecAudioForAudioFrameClassification.forward _______________________________________
1420 heads.
1421
1422 Example:
1423
1424 ```python
1425 >>> from transformers import Wav2Vec2FeatureExtractor, Data2VecAudioForAudioFrameClassification
1426 >>> from datasets import load_dataset
1427 >>> import torch
1428
1429 >>> dataset = load_dataset("hf-internal-testing/librispeech_asr_demo", "clean", split="validation")
Expected nothing
Got:
Downloading and preparing dataset librispeech_asr/clean to /home/ruihua/.cache/huggingface/datasets/hf-internal-testing___librispeech_asr/clean/2.1.0/d3bc4c2bc2078fcde3ad0f0f635862e4c0fef78ba94c4a34c4c250a097af240b...
Dataset librispeech_asr downloaded and prepared to /home/ruihua/.cache/huggingface/datasets/hf-internal-testing___librispeech_asr/clean/2.1.0/d3bc4c2bc2078fcde3ad0f0f635862e4c0fef78ba94c4a34c4c250a097af240b. Subsequent calls will reuse this data.

/home/ruihua/project/huggingface/tf/transformers/src/transformers/models/data2vec/modeling_data2vec_audio.py:1429: DocTestFailure

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/main/CONTRIBUTING.md) are likely to be ignored.
Fix TF GPT2 `test_onnx_runtime_optimize`
Author: ydshieh
Pull request: yes

# What does this PR do?

Fix TF GPT2 `test_onnx_runtime_optimize` by skipping 2 test classes.

Current error:

```
tests/models/gpt2/test_modeling_tf_gpt2.py::TFGPT2ModelTest::test_onnx_runtime_optimize
(line 372)  onnxruntime.capi.onnxruntime_pybind11_state.InvalidGraph: [ONNXRuntimeError] : 10 : INVALID_GRAPH : This is an invalid model. In Node, ("tfgpt2_for_sequence_classification_27/GatherV2", GatherV2, "", -1) : ("tfgpt2_for_sequence_classification_27/score/Tensordot:0": tensor(float),"tfgpt2_for_sequence_classification_27/sub:0": tensor(int32),"tfgpt2_for_sequence_classification_27/GatherV2/axis:0": tensor(int32),) -> ("logits": tensor(float),) , Error No Op registered for GatherV2 with domain_version of 10
```

Comments:
_The documentation is not available anymore as the PR was closed or merged._
Cannot run run_qa.py due to "ImportError: cannot import name 'send_example_telemetry'"
Author: maria364
Pull request: no
Labels: name: bug

### System Info

```shell
- `transformers` version: 4.18.0.dev0
- Platform: Linux-4.15.0-180-generic-x86_64-with-Ubuntu-18.04-bionic
- Python version: 3.6.9
- Huggingface_hub version: 0.4.0
- PyTorch version (GPU?): 1.10.0+cu102 (True)
- Tensorflow version (GPU?): 2.6.2 (False)
- Flax version (CPU?/GPU?/TPU?): not installed (NA)
- Jax version: not installed
- JaxLib version: not installed
- Using GPU in script?: <fill in>
- Using distributed or parallel set-up in script?: <fill in>
```


### Who can help?

_No response_

### Information

- [X] The official example scripts
- [ ] My own modified scripts

### Tasks

- [X] An officially supported task in the `examples` folder (such as GLUE/SQuAD, ...)
- [X] My own task or dataset (give details below)

### Reproduction

I am trying to run the [run_qa.py](https://github.com/huggingface/transformers/blob/main/examples/pytorch/question-answering/run_qa.py) using the corresponding command provided in the instructions. However, I face the following issue:
 
Traceback (most recent call last):
  File "run_qa.py", line 45, in <module>
    from transformers.utils import check_min_version, send_example_telemetry
ImportError: cannot import name 'send_example_telemetry'



### Expected behavior

```shell
I would expect to see the following values, as mentioned in the instructions.

f1 = 88.52
exact_match = 81.22
```


Comments:
Hi, did you solve this problem, I have the same problem now

@maria364 
Hi, did you solve this problem, I have the same problem now TAT

Hi, I am experiencing the same problem when trying to run "run_mlm.py".

Hi, @maria364 @xueqianyi @DidiDerDenker  Could you try the latest version of `transformers`? This should fix the issue I believe.



> 

Thanks so much！And that makes sense：
`pip install git+https://github.com/huggingface/transformers`
Add a TF in-graph tokenizer for BERT
Author: Rocketknight1
Pull request: yes

Hey all! I've done some testing and the in-graph BERT tokenizer is now yielding the same outputs as our tokenizers, even for multi-part texts where we need to concatenate and get `token_type_ids` right. There's still several things left to do before this is ready, but I figured now is the time to lay it out and get some feedback!

Left to do:

- [x] Add input normalization
- [x] Is texts_a / texts_b the right way to handle inputs? Should it just be a multidimensional tensor?
- [x] Should this be a complete class rather than reading attributes from an existing tokenizer?
- [x] Add imports and maybe some kind of AutoModel to make this findable by users
- [x] Add dependency for tensorflow_text and import checks
- [x] Do we need to change the name? Most TF users will still want the normal tokenizers
- [x] Add tests, particularly one with a full model and one with saving to savedmodel, as these are main use cases
- [x] Currently always pads to max length - this should be an option
- [x] Add documentation
- [ ] Consider adding docs on how to add other TF tokenizers, so we can see if users want to add them once we have a framework in place?

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

@sgugger @gante I'm happy with this PR now, so I'm ready for a final review! Also, the tests are slightly slow (~1min for the whole test suite on a single core). Should I mark some of them as `@slow`, or will they only be run nightly and when a PR affects the BERT directory anyway?
BLOOM - Fix mask creation by default
Author: younesbelkada
Pull request: yes

- fix niche case where the mask is not fed to the forward function

cc @justheuristic 

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

This happens if user decides to run `model(input_ids=some_tensor)`, which originally happened during prototyping (in a notebook).

It is indeed a niche case;
However, the fact that mask _is_ optional can hint other users to the idea that they can keep it None - and it would be more intuitive if having mask=None would be equivalent to passing all ones, like in GPT2Model for example.
Better Fine-Tuning by Reducing Representational Collapse
Author: mingruimingrui
Pull request: no
Labels: name: Feature request

# 🚀 Feature request

Add r3f/r4f to some popular objective functions as suggested by [Armen et. al](https://arxiv.org/abs/2008.03156).

## Motivation

Finetuning is a primary use case of many users of the transformers library.
We can use r3f/r4f to reduce representation collapse by vocabulary inefficiencies.
This is also a relatively cheap feature to implement.

## Your contribution

Understand that this is a relatively new paper with not too much benchmarking done. Will do PR if requested.

Comments:
Would be lovely to see it, seems promising!

Any progress? @LysandreJik
[Generation] `length_penalty` means `beam_alpha`
Author: ShaneTian
Pull request: no

https://github.com/huggingface/transformers/blob/508baf194313c397345af868202404e285494a28/src/transformers/generation_utils.py#L949-L952
https://github.com/huggingface/transformers/blob/508baf194313c397345af868202404e285494a28/src/transformers/generation_beam_search.py#L829

There are two issues about `length_penalty`:
1. Actually, `length_penalty=1` does **NOT** mean no penalty. It is no penalty when `length_penalty=0`, right?
2. This is different from the [`beam_alpha` paper](https://arxiv.org/pdf/1609.08144.pdf), why?
    <img width="632" alt="image" src="https://user-images.githubusercontent.com/42370681/165103163-b5946237-b03e-4a24-bb3e-2122a9dacec2.png">


Comments:
See https://github.com/huggingface/transformers/issues/4915  https://github.com/huggingface/transformers/issues/4918#issuecomment-681985118  https://github.com/huggingface/transformers/issues/14768

cc @patrickvonplaten 
https://github.com/huggingface/transformers/blame/508baf194313c397345af868202404e285494a28/src/transformers/generation_beam_search.py#L829

Hey @ShaneTian,

Good catch! I think that's exactly right - we should change the docs here to:

```py
             length_penalty (`float`, *optional*, defaults to 1.0): 
                 Exponential penalty to the length. 1.0 means that the beam score is penalized by the sequence length. 0.0 means no penalty. Set to values < 0.0 in order to encourage the 
                 model to generate longer sequences, to a value > 0.0 in order to encourage the model to produce shorter 
                 sequences. 
```

Would you like to open a pull request for this?

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/main/CONTRIBUTING.md) are likely to be ignored.

@ShaneTian note that the length penalty is different from the "alpha" penalty simply because we discovered it first ;-) Would be too difficult to change now though

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/main/CONTRIBUTING.md) are likely to be ignored.