noamaanMulla-03/transformers-issues huggingface dataset:
NLLB Code Examples out of date?
Author: Sharrnah
Pull request: no
Labels: name: bug

### System Info

4.44.0, Windows 11, Python 3.11

### Who can help?

Probably @ArthurZucker but not 100% sure.

### Information

- [X] 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

1. Load the NLLB-200 model
2. Try to use the code exactly as in the example code here https://github.com/huggingface/transformers/blob/main/docs/source/en/model_doc/nllb.md#generating-with-nllb
3. Getting the error that tokenizer does not expect any argument.
   ```
    Error: AutoTokenizer.__init__() takes 1 positional argument but 2 were given
    Traceback (most recent call last):
      File "E:\AI\whisper-audio-translate-transcribe\Whispering-VRC\Models\TextTranslation\texttranslate.py", line 88, in TranslateLanguage
        translation_text, from_code, to_code = texttranslateNLLB200.translate_language(text, from_code, to_code, as_iso1)
                                               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      File "E:\AI\whisper-audio-translate-transcribe\Whispering-VRC\Models\TextTranslation\texttranslateNLLB200.py", line 530, in translate_language
        inputs = tokenizer(text).to(torch_device)
                 ^^^^^^^^^^^^^^^
    TypeError: AutoTokenizer.__init__() takes 1 positional argument but 2 were given
   ```


### Expected behavior

That the example code works.

I found this issue https://github.com/huggingface/transformers/issues/31348
Which mentions that there where deprecation changes to the tokenizer? But its completely unclear now how to use it. It worked in an old version of transformers, but i updated it just to learn that its now broken and the example code shows code that clearly doesn't work anymore. (Unless i am doing something completely wrong.)

Comments:
Hi @Sharrnah, I just used this code snippet
```python
from transformers import AutoModelForSeq2SeqLM, AutoTokenizer

tokenizer = AutoTokenizer.from_pretrained("facebook/nllb-200-distilled-600M")
model = AutoModelForSeq2SeqLM.from_pretrained("facebook/nllb-200-distilled-600M")

article = "UN Chief says there is no military solution in Syria"
inputs = tokenizer(article, return_tensors="pt")

translated_tokens = model.generate(
    **inputs, 
    forced_bos_token_id=tokenizer.convert_tokens_to_ids("fra_Latn"), 
    max_length=30
)

translation = tokenizer.batch_decode(translated_tokens, skip_special_tokens=True)[0]
print(translation)
```
And had no issues running it - from your example it doesn't look like you are using exactly the code from the official examples, could you give a full reproducer?

oops. I am so sorry. i had an error in my code at another place which resulted it not loading the tokenizer correctly.
I guess that came from too much testing around to get it updated to some smaller changes.

Its working now.

Thank you and sorry again.

No worries - thanks for updating!
fix: Fixed unknown pytest config option `doctest_glob`
Author: Sai-Suraj-27
Pull request: yes

# What does this PR do?
Everytime we use `pytest`, we are getting this warning
```
PytestConfigWarning: Unknown config option: doctest_glob
self._warn_or_fail_if_strict(f"Unknown config option: {key}\n")
```
This is because there is no [configuration option](https://docs.pytest.org/en/latest/reference/reference.html#configuration-options) called `doctest_glob` in pytest. Rather, It should be added as an option to the `addopts` configuration option as shown [here](https://docs.pytest.org/en/latest/reference/reference.html#confval-addopts).


Fixes # (issue)


## 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?
@ydshieh @amyeroberts 

Comments:
Unpin deepspeed in Docker image/tests
Author: muellerzr
Pull request: yes

# What does this PR do?

DS released 0.14.4 awhile ago which fixed all the broken tests. Now that I have some time to look at it it seems safe to install now (accelerate tests pass)

Fixes # (issue)


## 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#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.

@ydshieh 

Comments:
The docs for this PR live [here](https://moon-ci-docs.huggingface.co/docs/transformers/pr_32572). All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update.
Updated workflows to the latest versions
Author: Sai-Suraj-27
Pull request: yes

# What does this PR do
Updated [actions/checkout](https://github.com/actions/checkout), [setup-python](https://github.com/actions/setup-python), and [actions/checkout](https://github.com/actions/cache) to the latest versions.


Fixes # (issue)

## 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?
@ydshieh @amyeroberts 

Comments:
The docs for this PR live [here](https://moon-ci-docs.huggingface.co/docs/transformers/pr_32405). All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update.
[i18n-ar] Add File : `./output_files_md/trans_repo/docs/source/ar/_toctree.yml` 
Author: AhmedAlmaghz
Pull request: yes

 # What does this PR do? 
 Translate docs into Arabic issue-number #32435 
 @stevhliu , @MKhalusova , @abodacs 
 This pull request contains changes [**for file : ./output_files_md/trans_repo/docs/source/ar/_toctree.yml**](https://github.com/AhmedAlmaghz/transformers/blob/Add_docs_source_ar__toctree.yml/./output_files_md/trans_repo/docs/source/ar/_toctree.yml) 

Comments:
[i18n-ar] Add File : `./output_files_md/trans_repo/i18n/‏‏README_ar.md` 
Author: AhmedAlmaghz
Pull request: yes

 # What does this PR do? 
 Translate docs into Arabic issue-number #32435 
 @stevhliu , @MKhalusova , @abodacs 
 This pull request contains changes [**for file : ./output_files_md/trans_repo/i18n/‏‏README_ar.md**](https://github.com/AhmedAlmaghz/transformers/blob/Add_i18n_‏‏README_ar.md/./output_files_md/trans_repo/i18n/‏‏README_ar.md) 

Comments:
[i18n-ar] Add File : `i18n/‏‏README_ar.md` 
Author: AhmedAlmaghz
Pull request: yes

 # What does this PR do? 
 Translate docs into Arabic issue-number #32435 
 @stevhliu , @MKhalusova , @abodacs 
 This pull request contains changes [**for file : i18n/‏‏README_ar.md**](https://github.com/AhmedAlmaghz/transformers/blob/Add_i18n_‏‏README_ar.md/i18n/‏‏README_ar.md) 

Comments:
[i18n-ar] Add `README_ar.md` to `i18n/README_zh-hant.md` 
Author: AhmedAlmaghz
Pull request: yes

 # What does this PR do? 
 Translate docs into Arabic issue-number #32435 
 @stevhliu , @MKhalusova , @abodacs 
 This pull request contains changes [**for file : i18n/README_zh-hant.md**](https://github.com/AhmedAlmaghz/transformers/blob/Update_i18n_README_zh-hant_md/i18n/README_zh-hant.md) 

Comments:
[i18n-ar] Add `README_ar.md` to `i18n/README_zh-hans.md`
Author: AhmedAlmaghz
Pull request: yes

 # What does this PR do? 
 Translate docs into Arabic issue-number #32435 
 @stevhliu , @MKhalusova , @abodacs 
 This pull request contains changes [**for file : i18n/README_zh-hans.md**](https://github.com/AhmedAlmaghz/transformers/blob/Update_i18n_README_zh-hans_md/i18n/README_zh-hans.md) 

Comments:
[i18n-ar] Add `README_ar.md` to `i18n/README_vi.md`
Author: AhmedAlmaghz
Pull request: yes

 # What does this PR do? 
 Translate docs into Arabic issue-number #32435 
 @stevhliu , @MKhalusova , @abodacs 
 This pull request contains changes [**for file : i18n/README_vi.md**](https://github.com/AhmedAlmaghz/transformers/blob/Update_i18n_README_vi_md/i18n/README_vi.md) 

Comments:
[i18n-ar] Add `README_ar.md` to `i18n/README_te.md`
Author: AhmedAlmaghz
Pull request: yes

 # What does this PR do? 
 Translate docs into Arabic issue-number #32435 
 @stevhliu , @MKhalusova , @abodacs 
 This pull request contains changes [**for file : i18n/README_te.md**](https://github.com/AhmedAlmaghz/transformers/blob/Update_i18n_README_te_md/i18n/README_te.md) 

Comments:
[i18n-ar] Add `README_ar.md` to `i18n/README_ru.md`
Author: AhmedAlmaghz
Pull request: yes

 # What does this PR do? 
 Translate docs into Arabic issue-number #32435 
 @stevhliu , @MKhalusova , @abodacs 
 This pull request contains changes [**for file : i18n/README_ru.md**](https://github.com/AhmedAlmaghz/transformers/blob/Update_i18n_README_ru_md/i18n/README_ru.md) 

Comments:
[i18n-ar] Add `README_ar.md` to `i18n/README_pt-br.md`
Author: AhmedAlmaghz
Pull request: yes

 # What does this PR do? 
 Translate docs into Arabic issue-number #32435 
 @stevhliu , @MKhalusova , @abodacs 
 This pull request contains changes [**for file : i18n/README_pt-br.md**](https://github.com/AhmedAlmaghz/transformers/blob/Update_i18n_README_pt-br_md/i18n/README_pt-br.md) 

Comments:
[i18n-ar] Add `README_ar.md` to `i18n/README_ko.md`
Author: AhmedAlmaghz
Pull request: yes

 # What does this PR do? 
 Translate docs into Arabic issue-number #32435 
 @stevhliu , @MKhalusova , @abodacs 
 This pull request contains changes [**for file : i18n/README_ko.md**](https://github.com/AhmedAlmaghz/transformers/blob/Update_i18n_README_ko_md/i18n/README_ko.md) 

Comments:
[i18n-ar] Add `README_ar.md` to `i18n/README_ja.md`
Author: AhmedAlmaghz
Pull request: yes

 # What does this PR do? 
 Translate docs into Arabic issue-number #32435 
 @stevhliu , @MKhalusova , @abodacs 
 This pull request contains changes [**for file : i18n/README_ja.md**](https://github.com/AhmedAlmaghz/transformers/blob/Update_i18n_README_ja_md/i18n/README_ja.md) 

Comments:
[i18n-ar] Add `README_ar.md` to  `i18n/README_hd.md` 
Author: AhmedAlmaghz
Pull request: yes

 # What does this PR do? 
 Translate docs into Arabic issue-number #32435 
 @stevhliu , @MKhalusova , @abodacs 
 This pull request contains changes [**for file : i18n/README_hd.md**](https://github.com/AhmedAlmaghz/transformers/blob/Update_i18n_README_hd_md/i18n/README_hd.md) 

Comments:
[i18n-ar] Add `README_ar.md` to  `i18n/README_fr.md`
Author: AhmedAlmaghz
Pull request: yes

 # What does this PR do? 
 Translate docs into Arabic issue-number #32435 
 @stevhliu , @MKhalusova , @abodacs 
 This pull request contains changes [**for file : i18n/README_fr.md**](https://github.com/AhmedAlmaghz/transformers/blob/Update_i18n_README_fr_md/i18n/README_fr.md) 

Comments:
[i18n-ar] Add `README_ar.md` to `i18n/README_es.md`
Author: AhmedAlmaghz
Pull request: yes

 # What does this PR do? 
 Translate docs into Arabic issue-number #32435 
 @stevhliu , @MKhalusova , @abodacs 
 This pull request contains changes [**for file : i18n/README_es.md**](https://github.com/AhmedAlmaghz/transformers/blob/Update_i18n_README_es_md/i18n/README_es.md) 

Comments:
[i18n-ar] add `README_ar.md` to `i18n/README_de.md`
Author: AhmedAlmaghz
Pull request: yes

 # What does this PR do? 
 Translate docs into Arabic issue-number #32435 
 @stevhliu , @MKhalusova , @abodacs 
 This pull request contains changes [**for file : i18n/README_de.md**](https://github.com/AhmedAlmaghz/transformers/blob/Update_i18n_README_de_md/i18n/README_de.md) 

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

# What does this PR do?

Currently the `test_inputs_embeds_matches_input_ids` is failing for some models that support inputs embeds in forward, but not in generate. This PR skips those tests

We could technically add support to generate from embeds for those models, but since there's no request from users I decided not to spend time on that and better skip tests

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

Oh, sorry it is not this test but another one which calls `generate()`. My bad, just saw it was fixed recently and my branch was behind main
Adds uniform processing kwargs to paligemma.
Author: MnCSSJ4x
Pull request: yes

# What does this PR do?
Adds Uniform Processing kwargs for paligemma model. 

Partially Fixes Issue 31911 


## Before submitting
- [x] Did you read the [contributor guideline](https://github.com/huggingface/transformers/blob/main/CONTRIBUTING.md#create-a-pull-request),
      Pull Request section?
- [ ] 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.

Can Review - @zucchini-nlp 


Comments:
Oh, can you remove the "Fixes #" from body. If not merging this PR will close the linked issue :)

@zucchini-nlp I changed the code to incorporate the new parameters. Let me know if I am going in the right direction. I haven't started writing the tests as I was occupied these few days. Will add that soon. Let me know if there is any reference which can help me understand the test or to take ideas from. 

Hey @yonigozlan I wrote some tests however got failure in tokenization and others where I checked the circle CI log and noticed gated repo issue. Is there a way to fix it or mock it up?
[Docs] Update resources
Author: NielsRogge
Pull request: yes

# What does this PR do?

This PR updates the resources section of various models.

Comments:
The docs for this PR live [here](https://moon-ci-docs.huggingface.co/docs/transformers/pr_32831). All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update.
Pass `HFQuantizer` to `from_pretrained` kwargs
Author: liamd101
Pull request: no
Labels: name: Feature request

name: Quantization

### Feature request

Currently, when loading a model in quantized form, the `HFQuantizer` is created based on other kwargs passed into the `from_pretrained` function. See current implementation below:
```python
# modeling_utils::from_pretrained()
    if pre_quantized or quantization_config is not None:
        if pre_quantized:
            config.quantization_config = AutoHfQuantizer.merge_quantization_configs(
                config.quantization_config, quantization_config
            )
        else:
            config.quantization_config = quantization_config
        hf_quantizer = AutoHfQuantizer.from_config(config.quantization_config, pre_quantized=pre_quantized)
    else:
        hf_quantizer = None
```
This should be a straightforward addition, by adding the following lines:
```python
# modeling_utils::from_pretrained()
    hf_quantizer = kwargs.pop("hf_quantizer", None)
    if hf_quantizer is not None:
        pass
    elif pre_quantized or quantization_config is not None:
        ...
```

### Motivation

This would give users more flexibility, and allow one to easily create and integrate custom implementations of the `HFQuantizer` class. I am personally working on a project where this change is necessary to work with quantization methods that have not yet been added to the library

### Your contribution

I can make a PR and contribution

Comments:
cc @SunMarc 

It would benefit since the current HFQuantizer behaves badly. The current logic is based on directly replacing all linear/conv operators within layers, while not all the linear/conv operators are intended to be replaced (e.g., gate for MoE). The configs of components to be quantized have been well supported in AutoGPTQ.  I suggest either supporting unsetting HF_Quantizer or supporting a complete version of it. @SunMarc
fix: Corrected ` falcon-mamba-7b` model checkpoint name
Author: Sai-Suraj-27
Pull request: yes

# What does this PR do?
Few `docstrings` are [failing](https://github.com/huggingface/transformers/actions/runs/10397798754/job/28796639865) due to this small nit in check-point name.
https://huggingface.co/tiiuae/falcon-mamba-7b

Fixes # (issue)


## 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?
@ArthurZucker @amyeroberts 

Comments:
fix: update doc link for runhouse in README.md
Author: muddlebee
Pull request: yes

# What does this PR do?

Updated the link for runhouse to https://www.run.house/docs/tutorials/quick-start-cloud


## 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?
- [ ] 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
- speech models: @sanchit-gandhi
- graph models: @clefourrier

Library:

- flax: @sanchit-gandhi
- generate: @zucchini-nlp (visual-language models) or @gante (all others)
- pipelines: @Narsil
- tensorflow: @gante and @Rocketknight1
- tokenizers: @ArthurZucker
- trainer: @muellerzr and @SunMarc

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:
Causal lanuage modeling should consider loss masks for pad tokens.
Author: sherlcok314159
Pull request: no
Labels: name: Feature request

### Feature request

A common snippet for training causal language models is like the below:

```python
        loss = None
        if labels is not None:
            # Shift so that tokens < n predict n
            shift_logits = logits[..., :-1, :].contiguous()
            shift_labels = labels[..., 1:].contiguous()
            # Flatten the tokens
            loss_fct = CrossEntropyLoss()
            shift_logits = shift_logits.view(-1, self.config.vocab_size)
            shift_labels = shift_labels.view(-1)
            # Enable model parallelism
            shift_labels = shift_labels.to(shift_logits.device)
            loss = loss_fct(shift_logits, shift_labels)

        if not return_dict:
            output = (logits,) + outputs[1:]
            return (loss,) + output if loss is not None else output
```

However, in real-world scenarios, we train LLMs by batched inputs which results in pad tokens in batches. Those pad tokens should be neglected for loss computation. For instance, switch pad token labels to `-100`.

### Motivation

See the above

### Your contribution

If you are busy for this, I can submit a PR.

Comments:
Hi @sherlcok314159, please check out our NLP course and how to use data collators to handle setting padding to -100: https://huggingface.co/learn/nlp-course/chapter7/4?fw=pt#data-collation

Thanks for your kind advice. I found Trainer already has the collator function to ignore pad tokens.