noamaanMulla-03/transformers-issues huggingface dataset:
Add frequency and time masking and noise augmentation to AST
Author: adrianfagerland
Pull request: yes

# What does this PR do?

Adds frequency and time masking, as well as random noise data augmentations to AST feature extractor. This is very useful for training as AST has a tendency to overfit on practical data, at least in my own personal experience. This is also what was used in the original paper and [code](https://github.com/YuanGongND/ast/blob/master/src/dataloader.py#L187).


## 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#create-a-pull-request) Pull Request section?
- [ ] Was this discussed/approved via a Github issue or the [forum](https://discuss.huggingface.co/)?
- [x] Did you make sure to update the documentation with your changes?
- [X] 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.

@ylacombe, @eustlb

This is my first time contributing to `transformers`, so please let me know if I need to make any changes :)

Comments:
Hey @adrianfagerland, thanks for opening the PR, let me know when it's ready for review!

Ready for review now @ylacombe 

The docs for this PR live [here](https://moon-ci-docs.huggingface.co/docs/transformers/pr_33493). All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update.

Hey @adrianfagerland, sorry for the delay, let me know if you still want a review!

Sorry @ylacombe, I'm not able to reopen this PR because I deleted the forked repository so I had to make a new one, PR #34072.
Small Fix to modular converter
Author: MekkCyber
Pull request: yes

# What does this PR do?

This update addresses a small issue in the modular converter. The relative path used in `AUTO_GENERATED_MESSAGE` is generated using a regex that assumes all models reside in the `src/transformers` directory. This approach fails when handling examples located in the `examples/` folder.

The fix is simple : the regex is modified to make sure `examples/` is also taken into account with `src/transformers`

If it's not needed, feel free to disregard.

## 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#create-a-pull-request),
      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?

cc @ArthurZucker 

<!-- 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:

- text models: @ArthurZucker
- vision models: @amyeroberts, @qubvel
- speech models: @ylacombe, @eustlb
- graph models: @clefourrier

Library:

- flax: @sanchit-gandhi
- generate: @zucchini-nlp (visual-language models) or @gante (all others)
- pipelines: @Rocketknight1
- tensorflow: @gante and @Rocketknight1
- tokenizers: @ArthurZucker
- trainer: @muellerzr and @SunMarc
- chat templates: @Rocketknight1

Integrations:

- deepspeed: HF Trainer/Accelerate: @muellerzr
- ray/raytune: @richardliaw, @amogkam
- Big Model Inference: @SunMarc
- quantization (bitsandbytes, autogpt): @SunMarc

Documentation: @stevhliu

HF projects:

- accelerate: [different repo](https://github.com/huggingface/accelerate)
- datasets: [different repo](https://github.com/huggingface/datasets)
- diffusers: [different repo](https://github.com/huggingface/diffusers)
- rust tokenizers: [different repo](https://github.com/huggingface/tokenizers)

Maintained examples (not research project or legacy):

- Flax: @sanchit-gandhi
- PyTorch: See Models above and tag the person corresponding to the modality of the example.
- TensorFlow: @Rocketknight1

 -->


Comments:
LGTM!

@SunMarc
Sentiment Analysis Using Iris Datset
Author: bhavv
Pull request: yes

This project creates a sentiment analysis model using the Iris dataset, mapping iris species to sentiment labels (positive, neutral, and negative). It employs the DistilBERT model for sequence classification, covering data preprocessing, tokenization, training, and evaluation with metrics like precision and F1-score.


Comments:
Hello, could the checkpoint be uploaded to the Hub instead of in the transformers repo?

Hi, I do have checkpoint-75 file. Can you please guide me as to where to upload it? I did not understand the term Hub. Did you mean the branch? I am a student, and this is my first time contributing to a project. I request you to please guide me.

Also, I see that two of my files are not uploaded as they are huge. 
![image](https://github.com/user-attachments/assets/964e6c6d-795b-4497-bab5-727cb52a9c28)


Hi I would like to close the request. Will work on it again. Thank you.
check if eigenvalues of covariance matrix are complex. 
Author: abuelnasr0
Pull request: yes

A follow-up for https://github.com/huggingface/transformers/pull/33950 and https://github.com/huggingface/transformers/pull/33325

This fixes reformer test_resize_tokens_embeddings. We should check if the eigenvalues are complex also to check if the covariance is positive definite.
c.c. @gante Thaks for the other fixes!
and c.c. @ArthurZucker 

Comments:
🌐 [i18n-KO] Translated `backbones.md` to Korean
Author: jun048098
Pull request: yes

<!— PR의 제목은 "🌐 [i18n-KO] Translated `<your_file>.md` to Korean" 으로 부탁드립니다 —>
# What does this PR do?

Translated the `backbones.md` file of the documentation to Korean.
Thank you in advance for your review. 

Part of https://github.com/huggingface/transformers/issues/20179

## Before reviewing
- [x] Check for missing / redundant translations (번역 누락/중복 검사)
- [x] Grammar Check (맞춤법 검사)
- [x] Review or Add new terms to glossary (용어 확인 및 추가)
- [x] Check Inline TOC (e.g. `[[lowercased-header]]`)
- [ ] Check live-preview for gotchas (live-preview로 정상작동 확인)

## Who can review? (Initial)

<!-- 1. 위 체크가 모두 완료된 뒤에만 N조 팀원들에게 리뷰 요청하는 아래 주석을 노출해주세요! 차례대로 1 ~ 5조 -->
<!-- May you please review this PR? --> 
<!-- @harheem, @jeongiin, @1kmmk1, @Seungahson, @win2dvp21 --> 
<!-- @junejae, @Jwaminju, @010kim, @4N3MONE, @boyunJang --> 
<!-- @jungnerd, @cjfghk5697, @yijun-lee, @mreraser --> 
@heuristicwave, @nuatmochoi, @chhaewxn, @jun048098, @ahnjj, @fabxoe

## 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?
- [ ] 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? (Final)

<!-- 2. N조 팀원들과 리뷰가 끝난 후에 아래 주석을 노출해주세요! -->
<!-- @stevhliu May you please review this PR? -->

Comments:
provide trust_remote_code for search feat extractor in model config
Author: eaidova
Pull request: yes

# What does this PR do?

Found issue during usage https://github.com/huggingface/optimum/blob/main/optimum/utils/save_utils.py#L27 with remote_code model, which does not have feature extractor clss,  we see message about providing trust_remote_code argument, however it is already provided.  This message may confuse users and lead to some hanging in code where there is no interactive mode until answer timeout reached.



Comments:
Seems legitimate! cc @Rocketknight1 

Yes, looks good to me too! @eaidova do you have some sample code that used to trigger the issue, but is fixed with this PR?

> Yes, looks good to me too! @eaidova do you have some sample code that used to trigger the issue, but is fixed with this PR?

I found this issue running optimum-cli tool, but I think reproducing may be simplified as:

```
from transformers import AutoFeatureExtractor

try:
    fe = AutoFeatureExtractor.from_pretrained("openbmb/MiniCPM-V-2_6", trust_remote_code=True)
except Exception:
   pass

````

as you can see I explicitly set trust_remote_code=True, but without this fix I'll see dialog with ask to decide to use remote code Y/N.

Besides that for AutoProcessor and AutoTokenizer classes, in this place there is providing trust_remote_code parameter : 
https://github.com/huggingface/transformers/blob/main/src/transformers/models/auto/processing_auto.py#L299
Tests: upcast `logits` to `float()`
Author: gante
Pull request: yes

# What does this PR do?

Some of our `forward` numerical checks compare `logits` against expected values. #33902 removes the upcast scheduled for deprecation in `forward` (`logits = logits.float()`), resulting in significant memory savings.

However, our tests were expecting the cast. This PR is a fix for (some of) those tests. e.g. two slow tests in `llama` are fixed as a result of this PR.

(text search -> `EXPECTED_SLICE`, used in tests that compare `logits` against hardcoded values -> fix whenever applicable )

Comments:
The docs for this PR live [here](https://moon-ci-docs.huggingface.co/docs/transformers/pr_34042). All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update.
[WIP] T5 compile-compatibility
Author: zucchini-nlp
Pull request: yes
Labels: name: run-slow

# What does this PR do?

Fixes https://github.com/huggingface/transformers/issues/33221 and fixes https://github.com/huggingface/transformers/issues/33283

T5 now supports new cache format and is compile compatible. The current state generates same text with dynamic cache as old tuple cache.

TODO:
- [X] Add tests and run existing tests

I ran all tests with static cache and compile for touched T5-based models, but no tests were enabled in UDOP/Pop2Piano etc. Those models are modified to support cache class only (for now) and that is because of `fix-copies`. As those are not super commonly used, I think we can enable compile in later stages. Also enabled slow tests for T5 as part of CI, slow tests locally are passing for me

Comments:
Hey! 🤗 Thanks for your contribution to the `transformers` library!

Before merging this pull request, slow tests CI should be triggered. To enable this:
- Add the `run-slow` label to the PR
- When your PR is ready for merge and all reviewers' comments have been addressed, push an empty commit with the command `[run-slow]` followed by a comma separated list of all the models to be tested, i.e. `[run_slow] model_to_test_1, model_to_test_2`
  - If the pull request affects a lot of models, put at most 10 models in the commit message
- A `transformers` maintainer will then approve the workflow to start the tests

(For maintainers) The documentation for slow tests CI on PRs is [here](https://www.notion.so/huggingface2/CI-for-pull-requests-8335bd9217d24d1e8ed1d3a016f39804).

The docs for this PR live [here](https://moon-ci-docs.huggingface.co/docs/transformers/pr_33754). All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update.

Done, updated the code for readability thus removing some unused things. Compile is working on T5 and other T5-based models, compile tests are green. The CI will also run slow tests for T5

Slow test for T5 added, for encoder-decoder and for encoder-only models
Fix flax failures
Author: LysandreJik
Pull request: yes

Closes https://github.com/huggingface/transformers/issues/33853

Comments:
The docs for this PR live [here](https://moon-ci-docs.huggingface.co/docs/transformers/pr_33912). All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update.
Fix failing conversion
Author: LysandreJik
Pull request: yes

The usage of the conversion Space was not working since it was upgraded to use gradio 4.36.

This is fixed and using the new approach used in Gradio.

Also a test should have been raised but wasn't visible as it was in a subTest; it should now be visible.

Comments:
The docs for this PR live [here](https://moon-ci-docs.huggingface.co/docs/transformers/pr_34010). All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update.

Yes thanks for flagging @osanseviero. Although you'd need to add `gradio_client` as a dependency, it would be much cleaner (and more future-proof) to use the Gradio Client. The Client is pretty lightweight: https://github.com/gradio-app/gradio/blob/main/client/python/requirements.txt, so lmk if you'd like to go down that approach and I can open up a PR

Unfortunately we're extremely strict in the required dependencies for `transformers` so we won't be able to add `gradio_client` at this time

And in terms of future-proof, I mostly need to stay more up to date with the gradio updates to the `safetensors/convert` Space so as to not miss an update! Thanks
Fix PushToHubMixin when pusing to a PR revision
Author: Wauplin
Pull request: yes

This PR fixes `PushToHubMixin` when trying to push a component to a PR revision.

In `.push_to_hub`, if a revision is passed, it currently tries to create a branch with that name. To be honest I don't think this should be the role of `transformers` to try to auto-create a branch if the user asked to push to it. It can lead to misleading behavior where a branch is autocreated even if the user made a typo in the revision name. But we won't change that at least for the sake of not introducing a breaking change.

This PR introduces a fix when the passed revision is in fact a PR ref (`"refs/pr/1"`). In that case, we should not try to create a branch otherwise a HTTP 400 Bad request: `Invalid reference for a branch: refs/pr/1` is raised. I've added a test following the same structure as existing tests.

---
Context: this issue has been reported by a user that wants to push both a model and a tokenizer to the same PR. So what they want to do is:
1. create an empty PR
2. push the model
3. push the tokenizer

Which is currently not possible because of the issue above.

Comments:
If the PR doesn't exist yet, but specified (like `refs/pr/1`), it would still fail right? Is this the behavior we want to keep (and if some doc mentions this?)

> If the PR doesn't exist yet, but specified (like refs/pr/1), it would still fail right? Is this the behavior we want to keep (and if some doc mentions this?)

It would fail yes and I do think this is the correct behavior to have. If the user provides an unknown PR ref, it's preferable to let them know rather than trying to guess what would be the best solution for them (I also do think this should be the case for missing branches as well but it would introduce a breaking change)

Feel free to merge if it's ok. Failing CI doesn't seem to be related (only the docs is failing)
The Sink Cache looks wired
Author: why-in-Shanghaitech
Pull request: no
Labels: name: Good Second Issue

name: bug

name: Cache

### System Info

- `transformers` version: 4.44.2
- Platform: Linux-5.15.0-86-generic-x86_64-with-glibc2.35
- Python version: 3.9.19
- Huggingface_hub version: 0.24.6
- Safetensors version: 0.4.5
- Accelerate version: 0.34.2
- Accelerate config:    not found
- PyTorch version (GPU?): 2.6.0.dev20240914 (False)
- Tensorflow version (GPU?): not installed (NA)
- Flax version (CPU?/GPU?/TPU?): not installed (NA)
- Jax version: not installed
- JaxLib version: not installed
- Using distributed or parallel set-up in script?: No

### Who can help?

@ArthurZucker, @zucchini-nlp

### Information

- [ ] The official example scripts
- [X] My own modified scripts

### Tasks

- [X] An officially supported task in the `examples` folder (such as GLUE/SQuAD, ...)
- [ ] My own task or dataset (give details below)

### Reproduction

https://github.com/huggingface/transformers/blob/75b7485cc72bf7122094b943af9f7d26d69ff827/src/transformers/cache_utils.py#L985-L1006

I find the sink cache does not shift the ROPE positional encoding of the new `key_states`. This would lead to
1. The positional encoding is not consecutive in all the keys;
2. In later generation rounds, the positional encoding is not like what we expected.

Since I'm not quite sure about this, I raise this issue before making a PR. Point it out if I was wrong.

### Expected behavior

It seems that after fixing this the model behavior will be more closed to [the original streamingllm implementation](https://github.com/mit-han-lab/streaming-llm/tree/main), but indeed I couldn't find a good way to test this.

I am very confused about how it could pass the test: https://github.com/huggingface/transformers/blob/317e069ee7f4d6d6595b1b03b5d9adcaede043e3/tests/utils/test_cache_utils.py#L336-L376 (though it fails on my end, the generated text is still reasonable). In this test, the `key_states` will have position encodings inrelevent to the cache size (say we have a sinkcahe with window size 256, the key state may have rope position 300. may be related #32315. If we generate texts manually so that the input positional ids and cache positions are None, the key state position will be starting from at most 257.). 

Comments:
cc @tomaarsen maybe :)

According to @33692, sink cache will be removed. Closing this issue.
Fix NaNs in cost_matrix for mask2former
Author: ducha-aiki
Pull request: yes

I don't have a reproduction code (because that often happens after like day of training), but sometimes training Mask2Former gives me an error:

```python3
rank0]:   File "/opt/conda/lib/python3.10/site-packages/transformers/models/mask2former/modeling_mask2former.py", line 478, in forward
[rank0]:     assigned_indices: Tuple[np.array] = linear_sum_assignment(cost_matrix.cpu())
[rank0]: ValueError: matrix contains invalid numeric entries
```
This PR fixes that.

@amyeroberts, @qubvel



Comments:
Thanks! @qubvel could you please approve test workflows run?
refactor: benchmarks
Author: McPatate
Pull request: yes

Based on a discussion with @LysandreJik & @ArthurZucker, the goal of this PR is to improve transformers' benchmark system.

This is a WIP, for the moment the infrastructure required to make things work is not ready. Will update the PR description when it is the case.



Comments:
The docs for this PR live [here](https://moon-ci-docs.huggingface.co/docs/transformers/pr_33896). All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update.

Compile complains IDK why, will handle, rest mr @McPatate
fix(ci): benchmarks dashboard was failing due to missing quotations
Author: McPatate
Pull request: yes

In the panels' queries, we use a `branch` variable to filter for the appropriate results.

I'm failing to understand why it sometimes works with single quotes, other times doesn't, then changes it's mind again. If the error happens again, I'll investigate deeper. For now the fix works.

Note: I'm only persisting the dashboard's json content and the change has already been made in Grafana.

Comments:
More flexible slow PR CI
Author: ydshieh
Pull request: yes

# What does this PR do?

Taken from  #33170

Comments:
/pytest

This comment contains /pytest, running the specified job...

This comment contains /pytest, running the specified job...

This comment contains /pytest, running the specified job...

This comment contains /pytest, running the specified job...

The docs for this PR live [here](https://moon-ci-docs.huggingface.co/docs/transformers/pr_33921). All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update.

/pytest 

🤣 

i changed it to run-slow so far, pytest is not covered yet Sir!

Go to bed sir 🛌🏻 

and comment on PR page instead of PR diff page won't work unless we merge this PR - (that's why you told me to test on another repo, which is [here](https://github.com/huggingface/transformers_ci_bot)

> Go to bed sir 🛌🏻

I would like to but my brain is full of these github action conditions 😭 

Good night ~

🤗 

This comment contains run-slow, running the specified job...

This comment contains run-slow, running the specified job...

This comment contains run-slow, running the specified job...

This comment contains run-slow, running the specified job...
How to obtain batch index of validation dataset?
Author: SoumiDas
Pull request: no
Labels: name: Usage

Hi,

I wanted to know how would we fetch the batch id/index of the eval dataset in ```preprocess_logits_for_metrics()``` ?

Thanks in advance!

Comments:
You could put a global variable that keeps track of how many samples have been seen in `preprocess_logits_for_metrics`. 

```python

counter = 0
bs = 16

def preprocess_logits_for_metrics(logits, labels):
    global counter

    counter += logits.shape[0]

    batch_idx = counter % bs

```

Then you would have to calculate the batch idx based on the value of counter. You would also need to reset count after completing evaluation. 

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.