noamaanMulla-03/transformers-issues huggingface dataset:
Nicer error message when Bert's input is missing batch size
Author: thomwolf
Pull request: yes

Currently it fails in the computation of the attention_mask.

Let's fail with a shape error message instead.

Comments:
# [Codecov](https://codecov.io/gh/huggingface/transformers/pull/2068?src=pr&el=h1) Report
> Merging [#2068](https://codecov.io/gh/huggingface/transformers/pull/2068?src=pr&el=desc) into [master](https://codecov.io/gh/huggingface/transformers/commit/2d5d86e03779b4b316698438caff0f675ee54abd?src=pr&el=desc) will **increase** coverage by `0.01%`.
> The diff coverage is `100%`.

[![Impacted file tree graph](https://codecov.io/gh/huggingface/transformers/pull/2068/graphs/tree.svg?width=650&token=9qOlN6Hb1c&height=150&src=pr)](https://codecov.io/gh/huggingface/transformers/pull/2068?src=pr&el=tree)

```diff
@@            Coverage Diff             @@
##           master    #2068      +/-   ##
==========================================
+ Coverage   83.15%   83.17%   +0.01%     
==========================================
  Files         109      109              
  Lines       15869    15869              
==========================================
+ Hits        13196    13199       +3     
+ Misses       2673     2670       -3
```


| [Impacted Files](https://codecov.io/gh/huggingface/transformers/pull/2068?src=pr&el=tree) | Coverage Δ | |
|---|---|---|
| [transformers/modeling\_bert.py](https://codecov.io/gh/huggingface/transformers/pull/2068/diff?src=pr&el=tree#diff-dHJhbnNmb3JtZXJzL21vZGVsaW5nX2JlcnQucHk=) | `87.68% <100%> (ø)` | :arrow_up: |
| [transformers/tests/modeling\_common\_test.py](https://codecov.io/gh/huggingface/transformers/pull/2068/diff?src=pr&el=tree#diff-dHJhbnNmb3JtZXJzL3Rlc3RzL21vZGVsaW5nX2NvbW1vbl90ZXN0LnB5) | `74.23% <0%> (+0.57%)` | :arrow_up: |

------

[Continue to review full report at Codecov](https://codecov.io/gh/huggingface/transformers/pull/2068?src=pr&el=continue).
> **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta)
> `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
> Powered by [Codecov](https://codecov.io/gh/huggingface/transformers/pull/2068?src=pr&el=footer). Last update [2d5d86e...18fb935](https://codecov.io/gh/huggingface/transformers/pull/2068?src=pr&el=lastupdated). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments).


lgtm

should this fix be added here as well?  @thomwolf https://github.com/huggingface/transformers/blob/6cc06d17394f5715cdf2d13a1ef7680bedaee9e2/src/transformers/modeling_utils.py#L700
T5 vocab size discrepancy between config and tokenizer
Author: djaym7
Pull request: no

### System Info

![image](https://user-images.githubusercontent.com/12378820/193693962-7720b071-f6d3-4973-8df1-57b5236ea4c8.png)

transformers version == '4.18.0'

### Who can help?

_No response_

### 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

Copy the code in image

### Expected behavior

same vocab size

Comments:
I found the same issue for deberta-v3 #19301. It should be fine as long as the model's vocab is larger than the tokenizer's. 

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 tapas scatter
Author: Bearnardd
Pull request: yes

# What does this PR do?

Changes the usage of scatter from torch_scatter to PyTorch's scatter thus removing the dependency on third party library

* [x] remove torch_scatter dependency
* [x] update  `_segment_reduce` function in order to work with PyTorch's scatter
* [x] update test case `test_reduce_sum_vectorized`



Fixes # (issue)
https://github.com/huggingface/transformers/issues/20101

## Who can review?

@NielsRogge 


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

Hi @sgugger - Sure, I will remove it as a part of removing all "scatter" mentions requested by @NielsRogge.

Hi @NielsRogge - could you tell me what is the difference between `require_scatter` and `require_torch_scatter` in `transformers/src/transformers/testing_utils.py` since they are calling the same thing.

Good question, you can remove both ;)

@NielsRogge - I have removed "scatter" mentions from the code base. It will be good to double check the changes :). I have not changed `.circleci/create_circleci_config.py` since removing it is a part of the #20168 PR.

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

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

Thanks for all the work! Will rebase my PR on yours to finish the job :-)
Where is the Translation template ? 
Author: bfss
Pull request: no

I want to translate the doc in leisure time, and I followed the guide, but not found Translation template...

Comments:
There's some relevant issues on this where people encountered the same issue:
* #17404
* #17028 

For context, @bfss is stating that the [TRANSLATING.md](https://github.com/huggingface/transformers/blob/main/docs/TRANSLATING.md) documentation says:
> To get started, navigate to the [Issues](https://github.com/huggingface/transformers/issues) page of this repo and check if anyone else has opened an issue for your language. If not, open a new issue by selecting the "Translation template" from the "New issue" button.

However, no such issue template exists.

---

That said, there are also some larger issues tracking the progress of the translation of a certain language. Perhaps these can be used as an informal template or guide if no issue for your language exists.
* https://github.com/huggingface/transformers/issues?q=Tranformers+documentation+translation+to+

Thank you for your reply~ @tomaarsen 

Trying to add the template right now. https://github.com/huggingface/transformers/pull/20199
INF encountered when using sampling with temperature.
Author: ElliottYan
Pull request: no
Labels: name: WIP

### System Info

latest transformers version == 4.24.0
When generating samples with mBART, I encounter this problem:
![image](https://user-images.githubusercontent.com/10862038/195253207-8229466b-8342-458d-ac40-0b40edd801af.png)

Looking deeply into the codes, I find the problem roots from the beam score added to next_token_scores here:
https://github.com/huggingface/transformers/blob/bc21aaca789f1a366c05e8b5e111632944886393/src/transformers/generation_utils.py#L2566

The original value of beam_scores is 0, but when using temperature like 0.5, the score is also divided the temperature value in logit_warper and gets larger and larger. And finally it causes the overflow of next_token_scores.  

### Who can help?

@patrickvonplaten @Narsil @gante 

### Information

- [ ] The official example scripts
- [X] 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

**I provide a simple code that can reproduce this issue.** 

import transformers
from transformers import AutoTokenizer, AutoModelForSeq2SeqLM

tokenizer = AutoTokenizer.from_pretrained("facebook/mbart-large-50-many-to-many-mmt")
model = AutoModelForSeq2SeqLM.from_pretrained("facebook/mbart-large-50-many-to-many-mmt")        

model = model.cuda()

src = 'In einem Notruf erzählte Professor Shannon Lamb mit einer etwas zittrigen Stimme der Polizei, dass er seine Freundin erschossen habe und dass die Beamten zu seinem Haus kommen müssten.'

encoded_hi = tokenizer(src, return_tensors="pt", padding=True).to('cuda') # do_sample=True
generated_tokens = model.generate(**encoded_hi, forced_bos_token_id=tokenizer.lang_code_to_id['en_XX'], temperature=0.5, do_sample=True, num_beams=10, num_return_sequences=10)

tgt_txt = tokenizer.batch_decode(generated_tokens, skip_special_tokens=True)

### Expected behavior

I think this should be solved but I'm not sure about the effect of the beam_scores.

Comments:
Hi @ElliottYan 👋  Thank you for pointing it out, it seems like a bug indeed. I will look into it.

Great! Looking forward to your solution. 
For now, I just swap these two lines (L2566 && 2567) and the error disappears. But I'm not sure what I do is correct. 

Are you using half or full precision here? Also `inf` values are not necessarily the reason for a bug, it might also be that `mBart` has some default logit processor settings that 0 out values which the lead to `inf` (cc @gante)
[Don't merge] Check CircleCI against PyTorch 1.13
Author: ydshieh
Pull request: yes

# What does this PR do?

**[Don't merge]** Check CircleCI against PyTorch 1.13

Comments:
The docs for this PR live [here](https://moon-ci-docs.huggingface.co/docs/transformers/pr_20094). All of your documentation changes will be reflected on that endpoint.
Moving examples in docstrings of RobertaTokenizer and LongformerTokenizer to doc source files 
Author: srhrshr
Pull request: no

### Motivation 

When using the `# Copied from` mode of do-repeat-yourself, if there are interactive examples in the source file's docstring, e.g., [`[0, 31414, 232, 328, 2]` in RobertaTokenizer](https://github.com/huggingface/transformers/blob/c28d04e9e252a1a099944e325685f14d242ecdcd/src/transformers/models/roberta/tokenization_roberta.py#L118), then it is currently impossible for the destination file to have accurate interactive examples without having complicated replace patterns in the `copy-check` module. e.g., [`[0, 31414, 232, 2]` is the correct output of this example in `LongformerTokenizer`](https://github.com/huggingface/transformers/blob/main/src/transformers/models/longformer/tokenization_longformer.py#L127). 

For now, to pass the copy check we have copied over the output line from the Roberta model to Longformer.   

> The example should probably go in the doc source file instead, so we can copy without any worry. For now in this PR I'd leave it as the Roberta output as you did. Then we can do a follow-up PR where we change the doc source files for Roberta and Longformer and remove that example from the two docstrings (I can do it or you can, as you prefer!)

_Originally posted by @sgugger in https://github.com/huggingface/transformers/pull/19346#discussion_r988069210_
  

Comments:
#self-assign

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.
List of models/tasks failing ONNX inference
Author: dwyatte
Pull request: no

### System Info

- `transformers` version: 4.23.0.dev0
- Platform: Darwin-21.6.0-x86_64-i386-64bit
- Python version: 3.7.12
- Huggingface_hub version: 0.10.0
- PyTorch version (GPU?): 1.11.0 (False)
- Tensorflow version (GPU?): 2.9.1 (False)
- Flax version (CPU?/GPU?/TPU?): 0.5.2 (cpu)
- Jax version: 0.3.6
- JaxLib version: 0.3.5
- Using GPU in script?: NA
- Using distributed or parallel set-up in script?: NA


### Who can help?

@lewtun

### 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

This issue was surfaced in https://github.com/huggingface/transformers/pull/19255 (see also https://github.com/huggingface/transformers/issues/19320)

Export any of the following model/task/framework parameterizations to ONNX:

- [ ] ("deberta-v2", "question-answering", "pt"),
- [ ] ("deberta-v2", "multiple-choice", "pt"),
- [ ] ("roformer", "multiple-choice", "pt"),
- [ ] ("groupvit", "default", "pt"),
- [ ] ("perceiver", "masked-lm", "pt"),
- [ ] ("perceiver", "sequence-classification", "pt"),
- [ ] ("perceiver", "image-classification", "pt"),
- [ ] ("bert", "multiple-choice", "tf"),
- [ ] ("camembert", "multiple-choice", "tf"),
- [ ] ("roberta", "multiple-choice", "tf"),

Errors are currently not detected at export time (although see https://github.com/huggingface/transformers/pull/19255). However, running inference on these exported models with any shape other than what they were validated with will fail.


### Expected behavior

* Errors are raised during ONNX export
* Inference runs as expected

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.
Type hints
Author: IMvision12
Pull request: yes

# What does this PR do?

Type-hints for `realm`, `Speech2Text2`, `SpeechToText` and `speech-encoder-decoder`

@Rocketknight1

Comments:
Not sure why tests are failing

Hi @IMvision12, I think tests are failing because in some cases you overwrote the default argument values! It's easy to see if you look in the [files changed interface](https://github.com/huggingface/transformers/pull/19818/files). If you set those argument values back to their original defaults then tests should pass.

![image](https://user-images.githubusercontent.com/12866554/197528126-065ac6b4-e277-4c0b-8648-177447dca744.png)



Okay I will change that. 

@Rocketknight1 Tests are still failing

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

@Rocketknight1 Done!!
Pipeline only returns the result of the first sample in a batch
Author: zhaowei-wang-nlp
Pull request: no

### System Info

transformers 4.24.0

### Who can help?

@Nars

### Information

- [X] 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

I just used the code written on https://huggingface.co/docs/transformers/main_classes/pipelines, as follows:
```
from transformers import pipeline
from transformers.pipelines.pt_utils import KeyDataset
import datasets

dataset = datasets.load_dataset("imdb", name="plain_text", split="unsupervised")
pipe = pipeline("text-classification", device=0)
for out in pipe(KeyDataset(dataset, "text"), batch_size=8, truncation="only_first"):
    print(out)
    # [{'label': 'POSITIVE', 'score': 0.9998743534088135}]
    # Exactly the same output as before, but the content are passed
    # as batches to the model
```
The problem is the variable only contains one result of the first sample in a batch, even though the batch size is 8.
If I write:
```
[x for x in pipe(KeyDataset(dataset, "text"), batch_size=8, truncation="only_first")]
```
I will get the results of all samples.


### Expected behavior

The batch size is 8 so the variable "out" should contain 8 results (8 lists of dicts).

Comments:
Generate: TF sample doctest result update
Author: gante
Pull request: yes

# What does this PR do?

Updates sample's output to match the [expected output in CI](https://github.com/huggingface/transformers/actions/runs/3457499228/jobs/5770974732), which has a GPU. 

(The previous output was for a CPU device -- sampling has different outputs for the same seed depending on the hardware, due to implementation differences.)

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

>  But here do you mean some specific implementation differences in the generation method?

No, all differences are just at hardware level :)
[DPR] fix unexpected "pooler" keys
Author: ArthurZucker
Pull request: yes

# What does this PR do?
Fixes #19111, by adding  [r"pooler"] to the list of ignored unexpected keys for both the `DPRPretrainedContextEncoder` and `DPRPretrainedQuestionEncoder`. 

Comments:
The docs for this PR live [here](https://moon-ci-docs.huggingface.co/docs/transformers/pr_20210). All of your documentation changes will be reflected on that endpoint.
[docs] wrote i18n issue template
Author: wonhyeongseo
Pull request: yes

# What does this PR do?
Makes the issue template for translation- `i18n.md` available. Thank you @omarespejel https://github.com/huggingface/transformers/pull/17004

Some questions:
- Would you prefer a `.yml` format for templates? I can convert it if you wish, @sgugger.
- What labels should be added to the issue? `docs`, `i18n`, `help-wanted`, `WIP` perhaps?

Part of  https://github.com/huggingface/transformers/issues/20183, an effort to update the translation guide.

## 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?
- [ ] 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/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 is free to review the PR once the tests have passed. Feel free to tag
members/contributors who may be interested in your PR.
Hello @sgugger, may you please review this PR?

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

> Thanks a lot for drafting this! I think the `WIP` label is fine, it would avoid the issue getting closed by the stale-bot.

Ok, adding it in. So resulting lables will be `WIP` only.

The docs for this PR live [here](https://moon-ci-docs.huggingface.co/docs/transformers/pr_20199). All of your documentation changes will be reflected on that endpoint.
mark `test_save_load_fast_init_from_base` as `is_flaky`
Author: ydshieh
Pull request: yes

# What does this PR do?

Mark `test_save_load_fast_init_from_base` as `is_flaky`.
 - This test is known to be flaky, see #19849
 - The level of flakiness seems to get higher after #20042
 - **ran 5 times, and all passed**.
 - **TODO**: check why #20042 makes this test more flaky.

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

I guess the best first step is to run it 1000 times (in a loop) and see how many times it fails (before and after your PR 20042).

Sometimes it is difficult to get reproducible failure if it is flaky.

As I commented before, this probably comes from models having weights initialized outside of the `_init_weights` function. A way to debug would be to drop somewhere which weight was randomly dropped when the test has failed (if it's printed for instance, we can look for it in the logs)
How to train my own dataset?
Author: Arsmart1
Pull request: no

### Feature request

Could you privide a tutorial for training the whole model using my own dataset? I am a new learner and very confused. Thanks!

### Motivation

Could you privide a tutorial for training the whole model using my own dataset? I am a new learner and very confused. Thanks!

### Your contribution

Could you privide a tutorial for training the whole model using my own dataset? I am a new learner and very confused. Thanks!

Comments:
You could start by checking out the [course](https://huggingface.co/course/chapter1/1). Also please use the [forums](https://discuss.huggingface.co/) for questions like this, since we keep features for bugs and feature requests only.

You could start by checking out the [course](https://huggingface.co/course/chapter1/1). Also please use the [forums](https://discuss.huggingface.co/) for questions like this, since we keep features for bugs and feature requests only.

You could start by checking out the [course](https://huggingface.co/course/chapter1/1). Also please use the [forums](https://discuss.huggingface.co/) for questions like this, since we keep features for bugs and feature requests only.
How to train transformer using my own data?
Author: Arsmart1
Pull request: no

### Feature request

I have not see a tutorial for training my own data.....Can I ? I am a new AI learner. Thank you!!!

### Motivation

I have not see a tutorial for training my own data.....Can I ? I am a new AI learner. Thank you!!!

### Your contribution

I have not see a tutorial for training my own data.....Can I ? I am a new AI learner. Thank you!!!

Comments:
Here is a tutorial in the transformers Doc on how to fine tune a pretrained model using the Transformers library (https://huggingface.co/docs/transformers/training), you can also check the Hugging face course https://huggingface.co/course/chapter1/1, for more help you will need to precise what do you want to do exactly

Besides, I noticed that you opened another issue #20187 for the exact same question. You should always avoid doing that you're just making the maintainers job harder, you should close your new issue. Also, I personally think it will be better to ask these kinds of questions on the Hugging Face's forum (https://discuss.huggingface.co/) or discord server (https://discord.com/invite/JfAtkvEtRb).

Check out the free HuggingFace course: https://hf.co/course.
Downgrade log warning -> info
Author: amyeroberts
Pull request: yes

# What does this PR do?

Downgrades the logged messages about the size parameter being converted from int/tuple -> dict from warning to info. 

## Fixes

Addresses part of the issue raised in #20185 - where many downstream tasks would have multiple warning messages, potentially scaring the users and spamming their logs. 

## 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?
- [ ] 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/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?



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

Thank you!