noamaanMulla-03/transformers-issues huggingface dataset:
[Examples] make default preprocessing_num_workers=1
Author: Yang-YiFan
Pull request: yes

# What does this PR do?

<!--
Congratulations! You've made it this far! You're not quite done yet though.

Once merged, your PR is going to appear in the release notes with the title you set, so make sure it's a great title that fully reflects the extent of your awesome contribution.

Then, please replace this with a description of the change and which issue is fixed (if applicable). Please also include relevant motivation and context. List any dependencies (if any) that are required for this change.

Once you're done, someone will review your PR shortly (see the section "Who can review?" below to tag some potential reviewers). They may suggest changes to make the code even better. If no one reviewed your PR after a week has passed, don't hesitate to post a new comment @-mentioning the same persons---sometimes notifications get lost.
-->

<!-- Remove if not applicable -->

Fixes #19630 

## Who can review?

@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:
Ok I removed it.

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

The failing check was fixed on main, so no need to worry about it. Thanks for your work on this!
[Doctest] Add configuration_realm.py
Author: ak04p
Pull request: yes

<!--
Congratulations! You've made it this far! You're not quite done yet though.

Once merged, your PR is going to appear in the release notes with the title you set, so make sure it's a great title that fully reflects the extent of your awesome contribution.

Then, please replace this with a description of the change and which issue is fixed (if applicable). Please also include relevant motivation and context. List any dependencies (if any) that are required for this change.

Once you're done, someone will review your PR shortly (see the section "Who can review?" below to tag some potential reviewers). They may suggest changes to make the code even better. If no one reviewed your PR after a week has passed, don't hesitate to post a new comment @-mentioning the same persons---sometimes notifications get lost.
-->

<!-- Remove if not applicable -->

Add configuration_realm.py to utils/documentation_tests.txt for doctest.
Based on issue #19487 

@ydshieh could you please check it?
Thank you 



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

Hi @ak04p Thank you for the PR. We should also change this line

```
from transformers import RealmEmbedder, RealmConfig
```

Thank you for the feedback, I'll correct it.
fix some device issues for pt 1.13
Author: ydshieh
Pull request: yes

# What does this PR do?

`PyTorch 1.13` is coming. We have 2 models with a lot of test failures due to some tensor indexing with `indexed tensor` and `indices` on the different devices. (It works with torch <= 1.12.1 though).

This PR fixes this device issue, so we are better prepared for torch 1.13.

Comments:
_The documentation is not available anymore as the PR was closed or merged._
Fix checkpoint used in `VisualBertConfig` doc example
Author: ydshieh
Pull request: yes

# What does this PR do?

The checkpoint was wrong, and not cached during the review in the config doctest PR (as it was wrong all the time).

Comments:
The docs for this PR live [here](https://moon-ci-docs.huggingface.co/docs/transformers/pr_19692). All of your documentation changes will be reflected on that endpoint.
[Doctest] Add configuration_convbert.py
Author: AymenBer99
Pull request: yes

Add configuration_convbert.py to utils/documentation_tests.txt for doctest.

Based on #19487 

@ydshieh  could you please check it?
Thanks :)

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

Thank you again, @AymenBer99 🚀
Fix dtype in radnomly initialized head
Author: sgugger
Pull request: yes

# What does this PR do?

This PR fixes the following [issue](https://github.com/huggingface/accelerate/issues/757) reported in Accelerate: when a model is loaded with `device_map="auto"` and some `torch_dtype`, the randomly initialized head does not respect said dtype.

Comments:
_The documentation is not available anymore as the PR was closed or merged._
[Doctest] Add `configuration_data2vec_vision.py`
Author: daspartho
Pull request: yes

Add `configuration_data2vec_vision.py` to `utils/documentation_tests.txt` for doctest.

Based on issue #19487

@ydshieh could you take a look at it?
Thank you =)

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

@ydshieh made the required changes :)
Added config for configuration_clip.py
Author: soma2000-lang
Pull request: yes

# What does this PR do?
Based on issue: https://github.com/huggingface/transformers/issues/19487
@ydshieh could you please check it?


Comments:
The docs for this PR live [here](https://moon-ci-docs.huggingface.co/docs/transformers/pr_19703). All of your documentation changes will be reflected on that endpoint.
[WHISPER] fix tests after updating the max_length
Author: ArthurZucker
Pull request: yes

# What does this PR do?
Fixes the `max_length` used in the generate function in whisper. 
The default `max_length` argument was changed in the `config.json` as it is more convenient for people who either don't know that the argument exist/don't know the value to set. 

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

Thanks @amyeroberts for running the tests locally, both TF and PT are all green. 

@ArthurZucker It would be nice to explain a bit the reason for the PR, not just what it did 🙏 . It will help others to understand , and it also helps to track (if we need to check this PR for some reason in the future)

@sgugger 

This is the Hub PR @ArthurZucker mentioned (change `max_length` to 448 in order to fix 2 whisper pipeline tests)
https://huggingface.co/openai/whisper-large/commit/baca495426386f789702e7f10edccf761c5f5592

After that change, this PR is required to pass some TF Whisper tests.
Fix code examples of DETR and YOLOS
Author: NielsRogge
Pull request: yes

# What does this PR do?

This is a follow-up PR of #19205.

YOLOS and DETR share the same postprocessing, hence I've added post_process_object_detection to YOLOS, leveraging Copied from statements.

It also improves the code example of DETR, and adds a better one for YOLOS.

Comments:
_The documentation is not available anymore as the PR was closed or merged._
fix test whisper with new max length
Author: ArthurZucker
Pull request: yes

# What does this PR do?
Fixes pipeline test after `max_length` update 
@ydshieh 


Comments:
Could you link the Hub PR that is related?


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

It seems the checkpoint involved is `openai/whisper-tiny.en` which is also used in other test methods. Could you confirm the other tests also pass after that Hub PR?

The `pytorch` tests all pass, 3 `TF` tests fails for now. 
Only the `config.max_length` was changed so should not have a lot of impact.
check decoder_inputs_embeds is None before shifting labels
Author: ArthurZucker
Pull request: yes

# What does this PR do?
This is related to #19157, which pointed out that a few models do not check whether `decoder_inputs_embeds` are None, which is inconsistent with other models. 
Since this is not the first time this is brought, let's solve it all at once, unless there is a particular reason ? 

Comments:
_The documentation is not available anymore as the PR was closed or merged._
[WHISPER] Update documentation of processor and nits in forward example
Author: ArthurZucker
Pull request: yes

# What does this PR do?

Fixes #19672

With respect to #19672, the `__call__` method of the `WhisperProcessor` was updated. 
The doctest were also not passing with the new `max_length`, see #19670 and #19668 
@ydshieh 

Comments:
_The documentation is not available anymore as the PR was closed or merged._
'WhisperProcessor' object has no attribute 'as_target_processor'
Author: GaetanBaert
Pull request: no

### System Info

- `transformers` version: 4.23.1
- Platform: Linux-5.15.0-48-generic-x86_64-with-glibc2.17
- Python version: 3.8.12
- Huggingface_hub version: 0.10.1
- PyTorch version (GPU?): 1.11.0 (True)
- Tensorflow version (GPU?): not installed (NA)
- 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?

@patrickvonplaten

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

I'm trying to train a Whisper model, using the WhisperProcessor. 

As written in the doc of the `__call__` method of the WhisperProcessor, I should have a context processor.as_target_processor() but it seems it doesn't exist. 
"If used in the context ~WhisperProcessor.as_target_processor this method forwards all its arguments to WhisperTokenizer’s [call()]"

Steps to reproduce the bug : 
```
target_text = 'this is a test text'
processor = WhisperProcessor.from_pretrained('openai/whisper-large')
with processor.as_target_processor():
    targets = processor(target_text).input_ids
```

### Expected behavior

The `__call__` method of WhisperProcessor instance in the as_target_processor context should give the result of the WhisperTokenizer `__call__`.

Comments:
Hi,

We'll update that code snippet as we've recently deprecated the use of `as_target_processor`, and new processors like `WhisperProcessor` don't implement it anymore. See #18325 for details.

You can replace

```
text = "hello world"

with processor.as_target_processor():
    encoded_labels = processor(text, padding=True)
```
by 
```
encoded_labels = processor(text=text).input_ids
```

Also cc'ing @ArthurZucker for updating the docs

Hello, 
Thank you for clarification !

Another thing, it seems that the `pad` method does not exist for WhisperProcessor ?

I think we can add it, similar to [this method](https://github.com/huggingface/transformers/blob/3b3024da70a7ada6599390c5b3e1a721c9a4aa4c/src/transformers/models/wav2vec2/processing_wav2vec2.py#L104-L132).

For now you can do `processor.tokenizer.pad(...) `

Nice catch! Will update the doc soon
Improve DETR models
Author: NielsRogge
Pull request: yes

# What does this PR do?

This PR: 

- [x] fixes Deformable DETR's loss function
- [x] adds more copied from statements for consistency
- [x] fixes Conditional DETR's integration tests.

As pointed out in #18948, Deformable DETR uses the same loss function and Hungarian matcher as Conditional DETR (use of sigmoid instead of softmax and not including the no-object class).

This PR also improves the  (original; conditional; deformable) DETR models by improving docs, adding more Copied from statements.


Comments:
_The documentation is not available anymore as the PR was closed or merged._
fixed grammatical omissions and  fixed typos.
Author: YOGENDERSS
Pull request: yes

# What does this PR do?

<!--
Congratulations! You've made it this far! You're not quite done yet though.

Once merged, your PR is going to appear in the release notes with the title you set, so make sure it's a great title that fully reflects the extent of your awesome contribution.

Then, please replace this with a description of the change and which issue is fixed (if applicable). Please also include relevant motivation and context. List any dependencies (if any) that are required for this change.

Once you're done, someone will review your PR shortly (see the section "Who can review?" below to tag some potential reviewers). They may suggest changes to make the code even better. If no one reviewed your PR after a week has passed, don't hesitate to post a new comment @-mentioning the same persons---sometimes notifications get lost.
-->

<!-- Remove if not applicable -->

Fixes # (issue)


## 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?

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:
This PR fixes a typo or improves the docs.

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

@sgugger could you please review this sir.

@codePerfectPlus sir could you please review if possible.
Non-descriptive error when initiating gpt2 tokenizer without internet
Author: tayler6000
Pull request: no

```
  File "C:\[path]\api\utilities\tokenizers.py", line 4, in <module>
    gpt2 = GPT2TokenizerFast.from_pretrained("gpt2")
  File "C:\[path]\venv\lib\site-packages\transformers\tokenization_utils_base.py", line 1750, in from_pretrained
    commit_hash = extract_commit_hash(resolved_vocab_files[file_id], commit_hash)
  File "C:\[path]\venv\lib\site-packages\transformers\utils\hub.py", line 225, in extract_commit_hash
    search = re.search(r"snapshots/([^/]+)/", resolved_file)
  File "C:\Program Files\Python310\lib\re.py", line 200, in search
    return _compile(pattern, flags).search(string)
TypeError: expected string or bytes-like object
```

Just started getting this error today, any idea for a workaround or a good version to rollback to?

Comments:
Update
======

This was caused by a poor internet connection.  It is not obvious that this is being caused by a bad or non-existent internet connection.  Could better error logging be added here?

I took the liberty of moving this issue to `transformers` since the error seemed to have occured here.

Tagging @sgugger 

Looks like a duplicate of #19186 so should be fixed by #19206 .
@tayler6000 You shouldn't have the error if you do a source install, we will also do a patch release today once we confirm the bug is fully fixed.
Redundant normalisation of image and text features in OWL-ViT
Author: ekazakos
Pull request: no

### Who can help?

@alaradirik 

### Issue description

Hi,

Thank you for the codebase! As the title suggests, I think that in `modeling_owlvit.py` the image and text features are normalised twice while in the original codebase from Google Research they are normalised only once. In particular, in `modeling_owlvit.py` image and text features are normalised both in lines 1073-174 and in lines 1145-1146. On the contrary in the original code, in [https://github.com/google-research/scenic/blob/main/scenic/projects/owl_vit/layers.py](https://github.com/google-research/scenic/blob/main/scenic/projects/owl_vit/layers.py), the features are normalised only in lines 86-89 whereas in line 144 the normalisation parameter is set as `normalize=False` and there is a comment explicitly saying `Don't normalize image and text embeddings:`. 

I think this is sensible as there is no reason for double normalisation which normally leads to performance degredation. Please let me know what do you think, and whether I'm wrong as I might be missing something.

Comments:
Hi @ekazakos, you're right but the image embeddings are not normalized twice. `OwlViTModel.forward()` is called within `OwlViTForObjectDetectiob.image_text_embedder()` with `return_base_image_embeds=True`. This assures that we can retrieve both the umodified CLIP (OwlViTModel) embeddings and logits using the normalized features and also the unnormalized image embeddings (lines 1085-1087).

The reason we do this is OwlViT is trained in two stages: (1) training CLIP / OwlViTModel without any modifications and (2) training the object detection head and fine-tuning the base CLIP model.

Hope this helps!

Hi @alaradirik,

I suspected that this was the reason you did that. And thanks for the clarification, it's helpful! Yet, that implies that the text features are indeed normalised twice, no?

> Hi @alaradirik,
> 
> I suspected that this was the reason you did that. And thanks for the clarification, it's helpful! Yet, that implies that the text features are indeed normalised twice, no?

Yes, you're right indeed and thanks for pointing it out! I'll be opening a fix PR shortly.

Glad I could help! Could you please let me know whether this boosts validation performance at all?



Hey @ekazakos, sorry for the delay! The issue will be fixed with this [PR](https://github.com/huggingface/transformers/pull/19712) but it doesn't affect the performance as double normalization yields the same results.
Fix redundant normalization of OWL-ViT text embeddings
Author: alaradirik
Pull request: yes

# What does this PR do?
- Fixes double normalization of OWL-ViT text embeddings, tests are not affected as double normalization yields the same results.
- Replaces deprecated torch.norm() with torch.linalg.norm()

Fixes # 19467


## 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.
- [ ] 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 documentation is not available anymore as the PR was closed or merged._
RuntimeError when using Label smoother
Author: jegork
Pull request: no

### System Info

- `transformers` version: 4.23.1
- Platform: Linux-5.4.0-124-generic-x86_64-with-glibc2.31
- Python version: 3.9.5
- Huggingface_hub version: 0.10.0
- PyTorch version (GPU?): 1.12.1+cu116 (True)
- Tensorflow version (GPU?): not installed (NA)
- Flax version (CPU?/GPU?/TPU?): not installed (NA)
- Jax version: not installed
- JaxLib version: not installed
- Using GPU in script?: No
- Using distributed or parallel set-up in script?: No

### Who can help?

@sgugger

### Information

- [ ] The official example scripts
- [ ] 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

Initially, I encountered 
```
  File "/root/searcher-ranker/.venv/lib/python3.9/site-packages/transformers/trainer_pt_utils.py", line 481, in __call__
    nll_loss = log_probs.gather(dim=-1, index=labels)
RuntimeError: index 1 is out of bounds for dimension 1 with size 1
```
when setting label_smoothing_factor for TrainingArguments, however I managed to simplify reproduction to just calling LabelSmoother instance. 

Minimal example can be seen here (be aware that the data provided there is pre-tokenized using the same tokenizer as the model):
https://colab.research.google.com/drive/1GYI4rV7br7RCXlIO1xjkdk8HSzHxbhma?usp=sharing

### Expected behavior

I guess there should be no problem doing label smoothing as this is just trivial binary classification task.
However, I do have a feeling that I might be doing something wrong, although I seem to have double-checked everything.

Thanks!

Comments:
Label smoothing is not for regression tasks, but when you have several labels.

@sgugger thanks for answering! 
My bad, I spotted my error. I am doing not regression, but binary classification, so I had to provide `num_labels=2` instead of 1.
Removed Bert interdependency from Funnel transformer
Author: mukesh663
Pull request: yes

# What does this PR do?
Hi @sgugger,

Fixes #19303 
- The `BertTokenizer` dependency has been removed from `FunnelTokenizer`
- The `BertTokenizerFast` dependency has been removed from `FunnelTokenizerFast`

## 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.
- [ ] 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?
@sgugger 

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

> You just need to remove those `:obj:` :-)

Made all the necessary changes. Thanks for looking into it.
Adding config files for configuration_clip.py
Author: soma2000-lang
Pull request: yes

# What does this PR do?

Add config files for configuration_clip.py to utils/documentation_tests.txt for doctest.

Based on issue: https://github.com/huggingface/transformers/issues/19487

@ydshieh could you please check it?
Thanks :)

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

Hi @soma2000-lang 

#19647 already works on this model config. Could you find another one if you would like to contribute 🙏 . Thank you btw!