noamaanMulla-03/transformers-issues huggingface dataset:
Update `FillMaskPipeline.__call__` signature and docstring
Author: alvarobartt
Pull request: yes

# What does this PR do?

This PR updates the `FillMaskPipeline.__call__` signature to remove the unused `*args` and updates the docstrings accordingly, to use `inputs` over `args`.

## 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.
- [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?

As it's related to a `pipeline` I'm assuming @Rocketknight1 (?), let me know otherwise!

Comments:
The docs for this PR live [here](https://moon-ci-docs.huggingface.co/docs/transformers/pr_35006). All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update.
requests.exceptions.ReadTimeout on already cached/downloaded model using SentenceTransformers
Author: HeAndres
Pull request: no
Labels: name: Usage

name: bug

### System Info

transformers version: 44.2
python version: 3.11.6
system OS: Linux

### Who can help?

_No response_

### Information

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

When HuggingFace servers are down or you have no internet connection, try to initialize an already downloaded/cached model. I was using SentenceTransformers (running SentenceTransformer(model_name_or_path=model_id, device=my_device), but the problem comes from the transformers library, so I'm not sure which library should make the changes.

### Expected behavior

The model loads properly without requiring any connection to the hub.

Comments:
Hey @HeAndres, you can force transformers to run offline a few different ways; check this documentation for more info: https://huggingface.co/docs/transformers/v4.45.2/en/installation#offline-mode

Hi, @LysandreJik. Even if it can be forced to be totally offline, shouldn't it try to get the model from local if the connection fails? I mean, I see no downside to trying to get the model from local. Or is there anything I can't see?
Thanks

I could try to work on a PR to change this, let me know if it would be of help!

The assumption you should have is for `from_pretrained` to always try and fetch the latest revision of the model; if it fails to get it, I believe it's much safer to let the user know it couldn't retrieve it rather than use a previous version from the cache. 

This seems to me like a potential pitfall/debugging hell users would not understand. I personally think having the ability to load from cache but requiring the user to specify that it should take from the cache is the least dangerous path

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.
about code
Author: lanlan990802
Pull request: no
Labels: name: bug

### System Info

Could you please advise me on how to resolve this issue after importing the Transformer library from Hugging Face?
ValueError: TimeSeriesTransformerForPrediction does not support Flash Attention 2.0 yet. Please request to add support where the model is hosted, on its model hub page: https://huggingface.co/Maple728/TimeMoE-50M/discussions/new or in the Transformers GitHub repo: https://github.com/huggingface/transformers/issues/new

### Who can help?

_No response_

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

I got the code from https://huggingface.co/Maple728/TimeMoE-50M/tree/main

### Expected behavior

maybe I got a mistake from the wrong way， I immediately download from the browser.

Comments:
What transformers version are you using?

@lanlan990802 this seems like an error with the code hosted on the repo you linked. Have you considered opening an issue there directly?

https://huggingface.co/Maple728/TimeMoE-50M/discussions

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.
Not only main process will save checkpoints during training
Author: chchch0109
Pull request: no
Labels: name: bug

### System Info

- `transformers` version: 4.45.2
- Platform: Linux-5.15.0-72-generic-x86_64-with-glibc2.35
- Python version: 3.9.0
- Huggingface_hub version: 0.25.1
- Safetensors version: 0.4.5
- Accelerate version: 0.34.2
- Accelerate config:    not found
- PyTorch version (GPU?): 2.1.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 RTX A6000

### Who can help?

@muellerz @SunMarc 

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

1. parser training argument with `training_args.output_dir = my_dir`.
2. `if PartialState().is_main_process: training_args.output_dir = 'modified_dir'`
3. When I call `trainer.save_model`, the model will be saved in `modfied_dir`, but the intermediate checkpoints saved by trainer will be saved in both

### Expected behavior

Only the main process save the checkpoints during training.

Comments:
Hey @chchch0109, thanks for the report. Could you share a rminimal reproducer ? Also feel free to open a PR if you know how to this the issue ! 

```python
"""
script:
accelerate launch
this_file.py
--output_dir my_output_dir
"""
import transformers
from accelerate.state import PartialState

parser = transformers.HfArgumentParser((TrainingArguments))
training_args = parser.parse_args_into_dataclasses()
if PartialState().is_main_process:
    training_args.output_dir = 'modified_output_dir'

# setup trainer
....
trainer.train()

# trainer save checkpoints in both 'my_output_dir' and 'modified_output_dir'
```

I only tried on my side but I think this issue will happen in all systems.

I'm glad to contribute but now I can't locate the issue. I will try to do it.

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.
trie split bug
Author: zpp13
Pull request: no
Labels: name: bug

### System Info


- `transformers` version: 4.41.0
- Platform: Linux-5.4.0-162-generic-x86_64-with-glibc2.35
- Python version: 3.10.12
- Huggingface_hub version: 0.23.4
- Safetensors version: 0.4.3
- Accelerate version: 0.30.1
- Accelerate config:    not found
- PyTorch version (GPU?): 2.2.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 GPU in script?: <fill in>
- Using distributed or parallel set-up in script?: <fill in>

### Who can help?

 @ArthurZucker and @itazap

### Information

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

from transformers.tokenization_utils import Trie
trie = Trie()
trie.add("abc")
trie.add("b")
trie.split("ab cd")
# ['ab c', 'd']

### Expected behavior

in my opinion, this should get ['a', 'b',  'cd'],but get ['ab c', 'd']
First submission, sorry if I understand something wrong.

Comments:
Hey! The trie is mostly for internal usage, I think this is expected ! (we don't take spaces into account AFAIK)

This error occurs not only with spaces,for example:
<img width="859" alt="截屏2024-10-31 上午9 32 29" src="https://github.com/user-attachments/assets/cabfe2e7-8458-46bb-bd94-048d8d6e0cb4">


@ArthurZucker and @itazap

Hey, sorry but the tre is not for general purpose usage, if it is breaking a tokenizer than sure let's fix it, but it does not seem to be the case!
Bug: `orig_height` and `orig_width` variable undeifined in llava processing
Author: chenweize1998
Pull request: no
Labels: name: bug

name: Vision

name: Multimodal

### System Info

- `transformers` version: 4.47.0.dev0                                     
- Platform: Linux-5.10.112-005.ali5000.alios7.x86_64-x86_64-with-glibc2.32
- Python version: 3.10.13                                                 
- Huggingface_hub version: 0.26.2                                         
- Safetensors version: 0.4.5                                              
- Accelerate version: 1.1.1                                               
- Accelerate config:    not found                                         
- PyTorch version (GPU?): 2.4.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?: True
- Using GPU in script?: True                                         
- GPU type: NVIDIA H800

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

Here's a minimum script to reproduce the bug. When `return_tensors` is not specified, it raises `UnboundLocalError: local variable 'orig_height' referenced before assignment`. 

```python
from transformers import AutoProcessor
from datasets import load_dataset

processor = AutoProcessor.from_pretrained("models/llava-hf/llama3-llava-next-8b-hf/")
dataset = load_dataset("HuggingFaceM4/LLaVA_Wild_Modif")

text = processor.apply_chat_template(
    [
        {
            "role": "user",
            "content": [{"type": "text", "text": dataset["test"][0]["question"]}, {"type": "image", "text": None}],
        }
    ],
    add_generation_prompt=True,
)

# Raise the error "UnboundLocalError: local variable 'orig_height' referenced before assignment"
inputs = processor(images=[dataset["test"][0]["image"]], text=text)

# No error when specifying return_tensors:
# inputs = processor(images=[dataset["test"][0]["image"]], text=text, return_tensors='pt')
```

### Expected behavior

The code should not raise error without specifying `return_tensors`. The bug is possibly introduced from https://github.com/huggingface/transformers/pull/34779

Comments:
Just opened a PR. @zucchini-nlp Could you review the code and confirm whether the changes in code can fix the bug? Thanks
Optimize memory usage of mllama encoder
Author: milesial
Pull request: yes

Changes the order of ops from "stack -> tensor index" into "list index -> stack". This small change means the stack operation has now a lot fewer inputs. This can save a lot (multiple x) of runtime memory especially once the graph is exported to ONNX or TRT.

@zucchini-nlp



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

For the mllama vision encoder (which should be the same size for 11B and 90B), in TRT BF16 BS8:

Before this change: 7GB of activations
After this change: 3GB of activations
Object detection evaluator
Author: qubvel
Pull request: yes
Labels: name: Examples

name: Vision

# What does this PR do?

Refactor the Object Detection example evaluation strategy. Instead of accumulating boxes during evaluation, we switch to the `--batch_eval_metric true` option and compute metrics at each batch.

Fixes #34675 

## 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:
@yonigozlan please review when you have bandwidth

The docs for this PR live [here](https://moon-ci-docs.huggingface.co/docs/transformers/pr_35040). All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update.
Typo in warning switching to optimum-quanto
Author: Bojun-Feng
Pull request: yes

# What does this PR do?

Fixes a typo in warning switching to `optimum-quanto`.

## 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, @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:
Thanks for the fix!
add docstring example for compute_loss_func
Author: secrettoad
Pull request: yes

# Add docstring example for compute_loss_function in trainer.py

<!--

Addresses issue raised in https://github.com/huggingface/transformers/issues/34955 around a missing/incomplete doctoring. Replaced with suggestion from @stevhliu.

-->

Fixes #34955


## 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?

@stevhliu @Rocketknight1 


Comments:
The docs for this PR live [here](https://moon-ci-docs.huggingface.co/docs/transformers/pr_35020). All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update.
Missing example in docstring for compute_loss_func (`Callable`, *optional*) in trainer.py
Author: shindennach
Pull request: no
Labels: name: bug

### System Info

Docstring of Trainer.py (https://github.com/huggingface/transformers/blob/v4.46.3/src/transformers/trainer.py#L294) 
Independent of environment

### Who can help?

@stevh

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

Thank you for the generally great documentation in huggingface transformers. It is really helpful for newbies like me. 
I noticed there seems to be an example missing in the docstring for the trainer.py script (https://github.com/huggingface/transformers/blob/v4.46.3/src/transformers/trainer.py#L294). 
In the description of the 'compute_loss_func (`Callable`, *optional*):' in line 342 the end of the last sentence seems to be missing. ("For example, here is one using the loss function from `transformers`"

### Expected behavior

It would be great to have an example for how the loss function has to look. 
Thank you. 

Comments:
cc @stevhliu 

Thanks for catching this! Would you like to open a PR and complete the sentence with something like the following?

```md
For example, see the default [loss function](https://github.com/huggingface/transformers/blob/052e652d6d53c2b26ffde87e039b723949a53493/src/transformers/trainer.py#L3618) used by [`Trainer`].
```

Here is a PR implementing @stevhliu's suggestion.

https://github.com/huggingface/transformers/pull/35020. My first on the repo so please let me know if I need to make any changes, even as simple as it is.
Add type hints for forward functions in Gemma2
Author: jla524
Pull request: yes

# What does this PR do?

<!--
Congratulations! You've made it this far! You're not quite done yet though.

Once merged, your PR is going to appear in the release notes with the title you set, so make sure it's a great title that fully reflects the extent of your awesome contribution.

Then, please replace this with a description of the change and which issue is fixed (if applicable). Please also include relevant motivation and context. List any dependencies (if any) that are required for this change.

Once you're done, someone will review your PR shortly (see the section "Who can review?" below to tag some potential reviewers). They may suggest changes to make the code even better. If no one reviewed your PR after a week has passed, don't hesitate to post a new comment @-mentioning the same persons---sometimes notifications get lost.
-->

<!-- Remove if not applicable -->

Add type hints to functions added in https://github.com/huggingface/transformers/pull/34282

## Who can review?

@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 @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:
The docs for this PR live [here](https://moon-ci-docs.huggingface.co/docs/transformers/pr_35034). All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update.