noamaanMulla-03/transformers-issues huggingface dataset:
Change default value of `attn_temperature_tuning`
Author: gmlwns2000
Pull request: yes

# What does this PR do?

Fixes #37479

## 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?
- [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?

@Cyrilvallez @Rocketknight1 


Comments:
Hi 👋, thank you for opening this pull request! The pull request is converted to draft by default. The CI will be paused while the PR is in draft mode. When it is ready for review, please click the `Ready for review` button (at the bottom of the PR page). This will assign reviewers and trigger CI.
Mismatching default value of `Llama4TextConfig` `attn_temperature_tuning` between official llama code
Author: gmlwns2000
Pull request: no
Labels: name: bug

### System Info

In `transfomers` library, the default value of `attn_temperature_tuning` in `Llama4TextConfig`, is `4`. 

https://github.com/huggingface/transformers/blob/953196a43dae6a3c474165fba7d215fcbc7b7730/src/transformers/models/llama4/configuration_llama4.py#L231

However, I think this value should be boolean because it is used as a condition flag in the forward pass.

https://github.com/huggingface/transformers/blob/953196a43dae6a3c474165fba7d215fcbc7b7730/src/transformers/models/llama4/modeling_llama4.py#L334

Moreover, in the official implementation, that value is boolean, which is defaulted to `False`. [(Offical Config File)](https://github.com/meta-llama/llama-models/blob/823cd8622e44d90b8e989e9f41ca364c06f5701d/models/llama4/args.py#L80)

### Who can help?

@ArthurZucker

### Information

- [x] The official example scripts
- [ ] 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

Any `Llama4TextConfig` instances.

### Expected behavior

The default value of `config.attn_temperature_tuning` should be `True` or `False` depending on input sequence length.

Comments:
Searched the codebase and the value is indeed only used as a boolean rather than an `int` - cc @arthurzucker should we just make it `True`/`False`?

Hi, I will make a PR of it if we need to change it to a boolean.

Arthur is out actually! @Cyrilvallez are you okay with the change? I'm pretty sure it's correct

Indeed, this is definitely a mismatch! Will be much clearer as a bool! All green if you want to open a PR to correct it @gmlwns2000! 🤗

I just made the PR that fixes this issue!
Add MLCD Model
Author: tanhuajie
Pull request: no
Labels: name: New model

name: Vision

### Model description

The MLCD models were released by the DeepGlint-AI team in [unicom](https://github.com/deepglint/unicom), which focuses on building foundational visual models for large multimodal language models using large-scale datasets such as LAION400M and COYO700M, and employs sample-to-cluster contrastive learning to optimize performance. MLCD models are primarily used for multimodal visual large language models, such as LLaVA.

🔥**MLCD-ViT-bigG**🔥 series is the state-of-the-art vision transformer model enhanced with 2D Rotary Position Embedding (RoPE2D), achieving superior performance on document understanding and visual question answering tasks. Developed by DeepGlint AI, this model demonstrates exceptional capabilities in processing complex visual-language interactions.

**Tips:**

- We adopted the official [LLaVA-NeXT](https://github.com/LLaVA-VL/LLaVA-NeXT) and the official training dataset [LLaVA-NeXT-Data](https://huggingface.co/datasets/lmms-lab/LLaVA-NeXT-Data) for evaluating the foundational visual models.

- The language model is [Qwen2.5-7B](https://huggingface.co/Qwen/Qwen2.5-7B-Instruct). 

**Result:** 

| Vision Tower                                                                                  | RoPE2D | ChartQA   | DocVQA    | InfoVQA   | OCRBench   | MMMU      |
| :-------------------------------------------------------------------------------------------- | :----: | :-------- | :-------- | :-------- | :--------- | :-------- |
| CLIP (ViT-L-14-336px)                                                                         |   ×    | 66.52     | 75.21     | 38.88     | 525.00     | 44.20     |
| SigLIP (ViT-SO400M-384px)                                                                     |   ×    | 69.28     | 76.71     | 41.38     | 554.00     | 46.78     |
| DFN5B (ViT-H-14-378px)                                                                        |   ×    | 64.36     | 70.87     | 38.59     | 473.00     | **48.00** |
| **[MLCD (ViT-L-14-336px)](https://huggingface.co/DeepGlint-AI/mlcd-vit-large-patch14-336)**   |   ×    | 67.84     | 76.46     | 43.48     | 531.00     | 44.30     |
| **[MLCD (ViT-bigG-14-336px)](https://huggingface.co/DeepGlint-AI/mlcd-vit-bigG-patch14-336)** |   √    | 71.07     | 79.63     | 44.38     | 572.00     | 46.78     |
| **[MLCD (ViT-bigG-14-448px)](https://huggingface.co/DeepGlint-AI/mlcd-vit-bigG-patch14-448)** |   √    | **73.80** | **83.34** | **46.59** | **582.00** | 46.00     |


### Open source status

- [x] The model implementation is available
- [x] The model weights are available

### Provide useful links for the implementation

_No response_

Comments:
:rotating_light: :rotating_light: Allow saving and loading multiple "raw" chat template files
Author: Rocketknight1
Pull request: yes

Extremely draft PR for now, but the idea here is that even when a model has multiple templates, we can save them in a `templates/` directory, and finally no longer have any cases where templates have to be saved as single JSON-encoded lines.

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

Failing tests are unrelated, so cc @arthurzucker @cyrilvallez for core maintainer review. I realize this is probably a lower priority than some other stuff right now, though, so don't stress!

cc @zucchini-nlp this should be just about ready for review now - can you take a look at the processor sections before I ping the core maintainers?

Also cc @Wauplin to check the Hub downloading code!

CI is finally green enough to merge this after #37282, and the non-core reviews are done at this point. cc @arthurzucker @cyrilvallez for core maintainer review!

cc @zucchini-nlp I had to make one change to llava_onevision to get tests to pass. The cause was that one of the new chat template tests asserts that `save_pretrained()` raises an error in a certain case. However, the overridden `save_pretrained()` for `llava_onevision` removes an attribute **from the base class**, then saves, and then adds the attribute back. This means that if we throw an error while saving, the attributes list remains broken for that class in all future tests!

I moved the attribute change into a `try/finally` block to avoid this: https://github.com/huggingface/transformers/pull/36588/files#diff-9db8ebe793630046c299cff97cef77e2a0656aac4961fbb1e880698831d33548

Tests are green so merging, including making this the default new save format! I'll keep an eye out for bugs/issues, we have time before the next release to smooth things over.

Congrats for getting it to the finish line @Rocketknight1 !
Llama4: remove redundant transpose of router_logits
Author: pbelevich
Pull request: yes

# What does this PR do?

This PR removes redundant transpose of router_logits

## Who can review?
cc @ArthurZucker


Comments:
Hi 👋, thank you for opening this pull request! The pull request is converted to draft by default. The CI will be paused while the PR is in draft mode. When it is ready for review, please click the `Ready for review` button (at the bottom of the PR page). This will assign reviewers and trigger CI.
Add Fast Yolos Processor
Author: keetrap
Pull request: yes

Related #36978
cc @yonigozlan

Comments:
Hi 👋, thank you for opening this pull request! The pull request is converted to draft by default. The CI will be paused while the PR is in draft mode. When it is ready for review, please click the `Ready for review` button (at the bottom of the PR page). This will assign reviewers and trigger CI.

The docs for this PR live [here](https://moon-ci-docs.huggingface.co/docs/transformers/pr_37292). All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update.
Set `open` encoding to `utf-8` for Windows compatability
Author: hlky
Pull request: yes

# What does this PR do?

Set `open` encoding to `utf-8` for Windows compatability

## Who can review?

Anyone in the community is free to review the PR once the tests have passed. Feel free to tag
members/contributors who may be interested in your PR.

Comments:
cc @ArthurZucker 

This is a really important change - though maybe we could just set an envvar instead? https://dev.to/methane/python-use-utf-8-mode-on-windows-212i
Add index selection for `output_hidden_states`
Author: hlky
Pull request: yes

# What does this PR do?

This PR adds index selection for `output_hidden_states` by allowing a list of indices to be passed. In this initial version only `clip` is modified, note that models that copy from `clip` currently have some docstrings changed due to `check_copies`, after an initial review I'll apply the changes to those models, eventually these changes can be applied to all models.

Internally `output_hidden_states` normalises negative indices.

The order of indices supplied to `output_hidden_states` is maintained in `hidden_states` output and duplicate indices are supported, this is required for `vipllama` and the tests for `vipllama` respectively.

The usage of `output_hidden_states` in `llava` and other versions is updated with the exception of `llava_onevision` as this model uses `siglip`, so it will be updated when the changes from `clip` are applied to `siglip`. I looked at the checkpoints listed in the examples for other `llava` versions and they all appear to use `clip`.

~~Note the changes in `vipllava` also required `reversed` due to the order of selected indices `-2, -5, -8, -11 and 6`.~~ ~~`vipllava` needs some special handling, specifically because the test case uses `0, 0, 1, 1, 0` as the selected indices.~~

The result of these changes is increased memory efficiency.

Fixes #33698

## 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.
cc @amyeroberts 

Comments:
cc @qubvel or @molbap for a first review :)

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

Thanks for the review @qubvel, I've made the requested changes.

Thanks, let's get an approval from the core-maintainer as well - cc @ArthurZucker
Add `private` to `trainer.push_to_hub`. Add `_update_repo_visibility` to trainer.
Author: hlky
Pull request: yes

# What does this PR do?

Currently setting `hub_private_repo` training argument only allows control over repo visibility at creation.

This PR adds `private` parameter to `trainer.push_to_hub`, this allows control over repo visiblity at creation in case `hub_private_repo` was not set in training arguments, and allows updating visibility of existing repos.

Fixes #33492
Fixes #32909


## 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#create-a-pull-request),
      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).
- [x] Did you write any new necessary tests?


## Who can review?

cc @muellerzr

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

friendly tagging @SunMarc for review
Fix AutoProcessor loading error
Author: JJJYmmm
Pull request: yes

Fixes #36194

this PR may help :) @Rocketknight1 


## 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?

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:

- 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 @MekkCyber

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:
Gonna close this in favour of #36184!
quick fix fast_image_processor register error
Author: JJJYmmm
Pull request: yes

# What does this PR do?

Fixes #36715 


## 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?
- [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).
- [x] Did you write any new necessary tests?

Comments:
Hi 👋, thank you for opening this pull request! The pull request is converted to draft by default. When it is ready for review, please click the `Ready for review` button (at the bottom of the PR page).

We just merged #36184 2 minutes ago - can you rebase this PR to make sure it still works after the processor registration changes?

@Rocketknight1 OK!  I've just rebased the PR. It should now be good to merge! Please verify and proceed with the merge if everything looks good. 🤗

@JJJYmmm yes, this is a nice fix, thank you! Missing that the `Fast` base inherited from the original `Base` was a nasty bug.
DeformableDetrHungarianMatcher: fancy indexing fails
Author: codingS3b
Pull request: no
Labels: name: bug

### System Info

- `transformers` version: 4.49.0
- Platform: Linux-3.10.0-1160.25.1.el7.x86_64-x86_64-with-glibc2.17
- Python version: 3.12.9
- Huggingface_hub version: 0.29.2
- Safetensors version: 0.5.3
- Accelerate version: not installed
- Accelerate config: not found
- DeepSpeed version: not installed
- PyTorch version (GPU?): 2.6.0+cu118 (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?

I assume this to be a bug when carrying out the matching with `DeformableDetrHungarianMatcher`, where indexing fails due to shape mismatches but am not totally sure whether I have the data prepared in the expected format. @qubvel @amyeroberts, could you possibly have a look? 



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


```python
import torch
import numpy as np

from transformers.loss.loss_deformable_detr import DeformableDetrHungarianMatcher

np.random.seed(42)
matcher = DeformableDetrHungarianMatcher()

batch_size = 2
num_queries = 10
num_classes = 2

# prepare the data according to the docstring of the matcher
outputs = {
    "logits": torch.randn(batch_size, num_queries, num_classes),  # batch_size, num_queries, num_classes
    "pred_boxes": torch.randn(batch_size, num_queries, 4),        # batch_size, num_queries, 4
}

# for each sample in the batch, a different number of objects can be present
targets = []
for sidx in range(batch_size):
    n_objects = np.random.randint(1, 4)
    d = {
        "class_labels": torch.ones(n_objects).to(torch.uint8),  # we have only one class, but the number of objects is random 
        "boxes": torch.randn(n_objects, 4), 
    }
    print(f"Sample {sidx}: {n_objects} ground-truth objects!")
    targets.append(d)

# this fails with IndexError: The shape of the mask [4] at index 0 does not match the shape of the indexed tensor [20, 2] at index 1
# the relevant line is `class_cost = pos_cost_class[:, target_ids] - neg_cost_class[:, target_ids]`
matcher(outputs, targets)
```

### Expected behavior

I would expect the matcher to not crash and provide a reasonable output instead.

Comments:
I figured it out and it is not a bug but rather an error on my side, sorry! If values of `class_labels` are of dtype `torch.int64` instead of `torch.uint8`, the indexing works.
VDR task guide
Author: merveenoyan
Pull request: yes

Added VDR task guide as I noticed the model docs are too minimal for a solid use case 

Comments:
Hi 👋, thank you for opening this pull request! The pull request is converted to draft by default. The CI will be paused while the PR is in draft mode. When it is ready for review, please click the `Ready for review` button (at the bottom of the PR page). This will assign reviewers and trigger CI.

~couldn't upload images to documentation-images yet~ uploaded, thanks a lot for the review in advance 💗

The docs for this PR live [here](https://moon-ci-docs.huggingface.co/docs/transformers/pr_37485). All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update.
Add Fast Chinese-CLIP Processor
Author: keetrap
Pull request: yes

Related  #36978 
cc @qubvel @yonigozlan 




Comments:
Hi 👋, thank you for opening this pull request! The pull request is converted to draft by default. The CI will be paused while the PR is in draft mode. When it is ready for review, please click the `Ready for review` button (at the bottom of the PR page). This will assign reviewers and trigger CI.

@yonigozlan Thanks for the review. Tests Updated.

@keetrap Great LGTM! could you update your branch?
@ArthurZucker Could you have a look?
Add Fast Conditional-DETR Processor
Author: keetrap
Pull request: yes
Labels: name: Vision

name: Processing

Related #36978
cc @yonigozlan

Comments:
Hi 👋, thank you for opening this pull request! The pull request is converted to draft by default. The CI will be paused while the PR is in draft mode. When it is ready for review, please click the `Ready for review` button (at the bottom of the PR page). This will assign reviewers and trigger CI.

Hi @keetrap, before I dive deep into the code, could you check if it would be useful to use modular here, as this image processor seems to have some similarities with other DETR image processors? You can look at the modular files of Deformable DETR and RT DETR to see how it's done. Thanks for working on this!

@yonigozlan Thanks for the review. I’ve added the modular file. The tests are failing here, but they’re passing locally.

Hi @keetrap ! Could you merge with main and run `make fix-copies` pls?