noamaanMulla-03/transformers-issues huggingface dataset:
[i18n-ar] Translated file : `docs/source/ar/gguf.md` into Arabic
Author: AhmedAlmaghz
Pull request: yes


## What does this PR do?
Translated the `docs/source/ar/gguf.md` file of the documentation to `Arabic العربية`. I use transformers for my side-project and wanted to contribute. As a beginner, this seemed appropriate.

### Some questions:

- I can't access the pr documentation endpoint for `Arabic العربية`. Is there a missing step?
- I left all the other files alone after copying the English docs. Is this acceptable for future updates or should I add contents to the `_toctree.yml` only when translation is complete? Should I delete all other files for a cleaner review?
- In `Arabic`, people use both `Transformer` and `المحولات` to describe the model. However, as this is more of a product of HuggingFace I opted not to translate it. May you please let me know which you would prefer?

Thank you in advance for your review.

Part of #32435

### Before submitting

- [ ] This PR fixes a typo or improves the docs (you can dismiss the other checks if that's the case).
- [ ] 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?
 @stevhliu , @MKhalusova , @abodacs, may you please review this PR?
 

Comments:
cc @stevhliu for visibility
[i18n-ar] Translated file : `docs/source/ar/tflite.md` into Arabic
Author: AhmedAlmaghz
Pull request: yes


## What does this PR do?
Translated the `docs/source/ar/tflite.md` file of the documentation to `Arabic العربية`. I use transformers for my side-project and wanted to contribute. As a beginner, this seemed appropriate.

### Some questions:

- I can't access the pr documentation endpoint for `Arabic العربية`. Is there a missing step?
- I left all the other files alone after copying the English docs. Is this acceptable for future updates or should I add contents to the `_toctree.yml` only when translation is complete? Should I delete all other files for a cleaner review?
- In `Arabic`, people use both `Transformer` and `المحولات` to describe the model. However, as this is more of a product of HuggingFace I opted not to translate it. May you please let me know which you would prefer?

Thank you in advance for your review.

Part of #32435

### Before submitting

- [ ] This PR fixes a typo or improves the docs (you can dismiss the other checks if that's the case).
- [ ] 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?
 @stevhliu , @MKhalusova , @abodacs, may you please review this PR?
 

Comments:
Thank you @abodacs
[i18n-ar] Translated file : `docs/source/ar/chat_templating.md` into Arabic
Author: AhmedAlmaghz
Pull request: yes


## What does this PR do?
Translated the `docs/source/ar/chat_templating.md` file of the documentation to `Arabic العربية`. I use transformers for my side-project and wanted to contribute. As a beginner, this seemed appropriate.

### Some questions:

- I can't access the pr documentation endpoint for `Arabic العربية`. Is there a missing step?
- I left all the other files alone after copying the English docs. Is this acceptable for future updates or should I add contents to the `_toctree.yml` only when translation is complete? Should I delete all other files for a cleaner review?
- In `Arabic`, people use both `Transformer` and `المحولات` to describe the model. However, as this is more of a product of HuggingFace I opted not to translate it. May you please let me know which you would prefer?

Thank you in advance for your review.

Part of #32435

### Before submitting

- [ ] This PR fixes a typo or improves the docs (you can dismiss the other checks if that's the case).
- [ ] 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?
 @stevhliu , @MKhalusova , @abodacs, may you please review this PR?
 

Comments:
cc @stevhliu for visibility

شكراً جزيلاَ اخي عبدالله @abodacs  على جهودك الرائعة والعظيمة
اتمنى لك التوفيق
[i18n-ar] Translated file : `docs/source/ar/custom_models.md` into Arabic
Author: AhmedAlmaghz
Pull request: yes


## What does this PR do?
Translated the `docs/source/ar/custom_models.md` file of the documentation to `Arabic العربية`. I use transformers for my side-project and wanted to contribute. As a beginner, this seemed appropriate.

### Some questions:

- I can't access the pr documentation endpoint for `Arabic العربية`. Is there a missing step?
- I left all the other files alone after copying the English docs. Is this acceptable for future updates or should I add contents to the `_toctree.yml` only when translation is complete? Should I delete all other files for a cleaner review?
- In `Arabic`, people use both `Transformer` and `المحولات` to describe the model. However, as this is more of a product of HuggingFace I opted not to translate it. May you please let me know which you would prefer?

Thank you in advance for your review.

Part of #32435

### Before submitting

- [ ] This PR fixes a typo or improves the docs (you can dismiss the other checks if that's the case).
- [ ] 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?
 @stevhliu , @MKhalusova , @abodacs, may you please review this PR?
 

Comments:
Thank you @abodacs
[i18n-ar] Translated file : `docs/source/ar/create_a_model.md` into Arabic
Author: AhmedAlmaghz
Pull request: yes


## What does this PR do?
Translated the `docs/source/ar/create_a_model.md` file of the documentation to `Arabic العربية`. I use transformers for my side-project and wanted to contribute. As a beginner, this seemed appropriate.

### Some questions:

- I can't access the pr documentation endpoint for `Arabic العربية`. Is there a missing step?
- I left all the other files alone after copying the English docs. Is this acceptable for future updates or should I add contents to the `_toctree.yml` only when translation is complete? Should I delete all other files for a cleaner review?
- In `Arabic`, people use both `Transformer` and `المحولات` to describe the model. However, as this is more of a product of HuggingFace I opted not to translate it. May you please let me know which you would prefer?

Thank you in advance for your review.

Part of #32435

### Before submitting

- [ ] This PR fixes a typo or improves the docs (you can dismiss the other checks if that's the case).
- [ ] 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?
 @stevhliu , @MKhalusova , @abodacs, may you please review this PR?
 

Comments:
cc @stevhliu 

Thank you @abodacs
StableDropout class
Author: fkrasnov2
Pull request: no
Labels: name: Usage

name: bug

### System Info

Hi,

Everything's going great with DeBERTa, thanks a lot! I've got one little thing though: 
The dropout value is a bit hard to read: it's StableDropout().  Could be much better:  StableDropout(p=0.1)

![image](https://github.com/user-attachments/assets/81384c9c-56ca-44a0-9614-d072d63fa328)

It's no big deal, but if you think there's something I can do about it, let me know.

Best,
Fedor (Ted)

### Who can help?

@ArthurZucker

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

https://github.com/huggingface/transformers/blob/78b2929c0554b79e0489b451ce4ece14d265ead2/src/transformers/models/deberta/modeling_deberta.py#L207

### Expected behavior

class StableDropout(nn.Module):
    """
    Optimized dropout module for stabilizing the training

    Args:
        drop_prob (float): the dropout probabilities
    """

    def __init__(self, drop_prob):
        super().__init__()
        self.drop_prob = drop_prob
        self.count = 0
        self.context_stack = None
    
    def __repr__(self):
        return f"StableDropout(p={self.drop_prob:.4f})"
        
    def __str__(self):
        return f"StableDropout(p={self.drop_prob:.4f})"

Comments:
Would you like to open a PR to fix this?

Yes, I do.

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.
`gpt2` with `output_attentions=True` has different attentions shape between flash and eager
Author: lapp0
Pull request: no
Labels: name: Usage

name: bug

### System Info

- `transformers` version: 4.44.2
- Platform: Linux-6.5.0-35-generic-x86_64-with-glibc2.35
- Python version: 3.10.14
- Huggingface_hub version: 0.24.6
- Safetensors version: 0.4.5
- Accelerate version: 0.34.2
- Accelerate config:    not found
- PyTorch version (GPU?): 2.3.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 distributed or parallel set-up in script?: <fill in>
- Using GPU in script?: <fill in>
- GPU type: NVIDIA GeForce RTX 4090


### Who can help?

@ArthurZucker @gante

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

```
>>> model_flash = transformers.AutoModelForCausalLM.from_pretrained("gpt2", device_map="cuda", attn_implementation="flash_attention_2", torch_dtype=torch.bfloat16)
>>> model_eager = transformers.AutoModelForCausalLM.from_pretrained("gpt2", device_map="cuda", attn_implementation="eager")

>>> input_ids = torch.tensor([[1, 2, 3, 4], [5, 6, 7, 8], [9, 10, 11, 12]]).to("cuda")

>>> eager_attns = model_eager(input_ids, output_attentions=True).attentions
>>> flash_attns = model_flash(input_ids, output_attentions=True).attentions

>>> len(eager_attns)
12
>>> len(flash_attns)
12

>>> eager_attns[0].shape
torch.Size([3, 12, 4, 4])
>>> flash_attns[0].shape
torch.Size([3, 4, 768])
```

### Expected behavior

`output_attentions=True` should be result in an error for `GPT2FlashAttention2`

Additionally I'd like to understand what's being returned here.



Comments:
When you use the `flash_attention_2`, the model cannot output the partial attention weights. I think there were warnings! 

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.
KeyError: 'qwen2_vl' loading from Transformers
Author: kev-iotairx
Pull request: no
Labels: name: bug

### System Info

- `transformers` version: 4.44.2
- Platform: Linux-6.1.85+-x86_64-with-glibc2.35
- Python version: 3.10.12
- Huggingface_hub version: 0.24.7
- Safetensors version: 0.4.5
- Accelerate version: 0.34.2
- Accelerate config: 	not found
- PyTorch version (GPU?): 2.4.1+cu121 (True)
- Tensorflow version (GPU?): 2.17.0 (True)
- Flax version (CPU?/GPU?/TPU?): 0.8.5 (gpu)
- Jax version: 0.4.33
- JaxLib version: 0.4.33
- Using distributed or parallel set-up in script?: <fill in>
- Using GPU in script?: <fill in>
- GPU type: Tesla T4


### Who can help?

@amyeroberts @qubvel 

### 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 am attempting to load the model from transformers library and getting an error. Here are instructions from official documentation: https://huggingface.co/Qwen/Qwen2-VL-7B-Instruct?library=transformers 

I am on:  `transformers 4.44.2`

```
# Load model directly
from transformers import AutoProcessor, AutoModelForSeq2SeqLM

processor = AutoProcessor.from_pretrained("Qwen/Qwen2-VL-7B-Instruct")
model = AutoModelForSeq2SeqLM.from_pretrained("Qwen/Qwen2-VL-7B-Instruct")
```

```
---------------------------------------------------------------------------
KeyError                                  Traceback (most recent call last)
/usr/local/lib/python3.10/dist-packages/transformers/models/auto/configuration_auto.py in from_pretrained(cls, pretrained_model_name_or_path, **kwargs)
    992             try:
--> 993                 config_class = CONFIG_MAPPING[config_dict["model_type"]]
    994             except KeyError:

3 frames
KeyError: 'qwen2_vl'

During handling of the above exception, another exception occurred:

ValueError                                Traceback (most recent call last)
/usr/local/lib/python3.10/dist-packages/transformers/models/auto/configuration_auto.py in from_pretrained(cls, pretrained_model_name_or_path, **kwargs)
    993                 config_class = CONFIG_MAPPING[config_dict["model_type"]]
    994             except KeyError:
--> 995                 raise ValueError(
    996                     f"The checkpoint you are trying to load has model type `{config_dict['model_type']}` "
    997                     "but Transformers does not recognize this architecture. This could be because of an "

ValueError: The checkpoint you are trying to load has model type `qwen2_vl` but Transformers does not recognize this architecture. This could be because of an issue with the checkpoint, or because your version of Transformers is out of date.
```

### Expected behavior

Load the Qwen / llama vision models successfully from transformers. 

Comments:
You need at least version v4.45 for Qwen2-VL. Please upgrade transformers with `pip install -U transformers` 🤗
Number of Image tokens in input_ids mismatched with num_images when finetuning LLaVA-NeXT
Author: lihytotoro
Pull request: no
Labels: name: bug

name: Vision

### System Info

Copy-and-paste the text below in your GitHub issue and FILL OUT the two last points.

- `transformers` version: 4.45.1
- Platform: Linux-5.4.0-135-generic-x86_64-with-glibc2.31
- Python version: 3.10.8
- Huggingface_hub version: 0.25.1
- Safetensors version: 0.4.5
- Accelerate version: 1.0.0
- Accelerate config:    not found
- PyTorch version (GPU?): 2.4.1+cu121 (True)
- 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?: <fill in>
- Using GPU in script?: <fill in>
- GPU type: NVIDIA A100-SXM4-80GB

### Who can help?

@zucchini-nlp 

### 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 encountered this bug when trying to finetune llava-v1.6-vicuna-7b-hf with the repository [https://github.com/zjysteven/lmms-finetune](url).
1. Clone and Installation
git clone https://github.com/zjysteven/lmms-finetune.git
conda create -n lmms-finetune python=3.10 -y
conda activate lmms-finetune
python -m pip install -r requirements.txt
python -m pip install --no-cache-dir --no-build-isolation flash-attn
2. Running example_image.sh
`bash example_scripts/example_image.sh`

The warning I got seems to indicate that I need to merge the image tokens into input_ids earlier, but I cannot figure out where to do this(in the dataset or collator?)
![warning](https://github.com/user-attachments/assets/6ab1263d-e2ff-42ba-a2a9-3c37cf1d7209)
Then in the trainer I got this error:
![error](https://github.com/user-attachments/assets/4301e053-3669-4020-9c24-e1160a70c8a6)
Which probably means the image tokens in input_ids are not recognized properly?

### Expected behavior

Expect behaviour: the image tokens are merged into input_ids successfully in the Trainer, and thus the finetuning proceeds normally.

Comments:
Hey @lihytotoro !

The reproduction is quite lengthy and involves a lot of code in the "lmms-finetune" repo. Can you provide a small reproducer that causes the same error.

From traceback I guess the reason is that padding sides do not match. Make sure that `model.padding_side == processor.tokenizer.padding_side`. For that I'd recommend to use a prev version of transformers as we had a small update on tokenizers and I don't see the fix on latest patch release. So, can you try to downgrade transformers first and then follow the above steps?

cc @ArthurZucker , can we get https://github.com/huggingface/transformers/pull/33942 in the next patch release, if there are any. If next minor release is soon, don't worry, we can wait for a while :)

Next patch release is soon yep! 

closing as the fix was merged
Mllama: update docs
Author: zucchini-nlp
Pull request: yes

# What does this PR do?

Fixes https://github.com/huggingface/transformers/issues/34304 and adds info about lm-head resizing. Maybe also fixes https://github.com/huggingface/transformers/issues/33819?

Comments:
The docs for this PR live [here](https://moon-ci-docs.huggingface.co/docs/transformers/pr_34334). All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update.
More precise `inputs_embeds` input logic and tests
Author: gante
Pull request: no
Labels: name: WIP

name: Generation

Tracker to update how we handle the `inputs_embeds` input, especially in `generate`, and how we test it.

More precisely:
- [ ] Remove support of `inputs_embeds` in `generate` in models that don't actually support it. (Check skipped tests)
- [ ] Remove as many skips as possible in tests like `test_inputs_embeds_matches_input_ids_with_generate` or `test_inputs_embeds` (Check the tests folder and search for `inputs_embeds`)

Comments:
Tests: move `generate` tests to the right mixin and delete redundant tests
Author: gante
Pull request: yes

Moves `generate` tests incorrectly placed in the general mixin to `GenerationTesterMixin`. In the process, removes redundant tests and streamlines repeated logic 👀 

⚠️ reviewer: start by reviewing `test_modeling_utils.py`, the last file in the diff. In it, I explain what happened to each test and why -- most were actually deleted, as they were redundant.

After this PR:
✅ fewer redundant tests and less code duplication
✅ fewer flaky tests
✅ faster tests
✅ more test coverage

In a follow-up PR:
👉 Fix failing upgraded generate+FA2 test
👉 Fix failing added generate+torch.compile test

Closes #32913

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

For tests where `is_flaky` is removed, you ran it with `--flake-finder --flake-runs 500` right? (at least for some models ?)

> For tests where is_flaky is removed, you ran it with --flake-finder --flake-runs 500 right? (at least for some models ?)

@ydshieh yes :D The pattern was actually added in a recent PR: https://github.com/huggingface/transformers/pull/34386
Fix PixtralProcessor to return input IDs for all prompts and images in batch
Author: Ryukijano
Pull request: yes

Related to #34204

Update `PixtralProcessor` to handle batches of images and text prompts correctly.

* **`src/transformers/models/pixtral/processing_pixtral.py`**
  - Modify the handling of images to correctly iterate over the zip of images, image sizes, and text.
  - Remove the aggregation of all images into a length 1 list of lists.
  - Ensure the `PixtralProcessor` processes each example in a batch individually.

* **`tests/models/pixtral/test_processor_pixtral.py`**
  - Add a test case to verify the `PixtralProcessor` returns the outputs corresponding to all prompts and images in a batch.
  - Ensure the test case includes multiple images and text prompts in a batch.
  - Verify the outputs of the `PixtralProcessor` match the expected outputs for all examples in the batch.

---

For more details, open the [Copilot Workspace session](https://copilot-workspace.githubnext.com/huggingface/transformers/issues/34204?shareId=fd463015-5d04-46dd-87f2-fa810d0d0456).

Comments:
cc @zucchini-nlp 

cc @molbap as you already reviewed the prev PR and I see you have opened another PR recently

yes, duplicated and already solved here https://github.com/huggingface/transformers/pull/34486