noamaanMulla-03/transformers-issues huggingface dataset:
Fix: FA2 with packed training
Author: zucchini-nlp
Pull request: yes
Labels: name: run-slow

# What does this PR do?

Fixes the issue from https://github.com/huggingface/transformers/pull/32241#issuecomment-2271314244. The FA2 was taking packed path when we were trying to continue with filled cache and had more than 1 new token. This could happen in assisted decoding for ex.

I think instead if checking the position ids length and last elements, we can check that if they are arranged in increasing order. We can know for sure that packed sequences will not have all elements with increasing positions. Also, we can be sure that in inference we'll always have an increasing order if there's no attn mask provided. If attn mask is there, we'll not reach this check so should not be a problem

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

Slow CI tests are failing for unrelated reasons: gated repo, OOM or failing even w/o this PR. I believe this can be merged, since many tests need to be fixed in general

Yep we need to patch with this let's merge! 🤗 

Yep, and https://github.com/huggingface/transformers/pull/32527 for patch release plz. Can you approve it also?
fix: Fixed conditional check for `encodec` model names
Author: Sai-Suraj-27
Pull request: yes

# What does this PR do?
This `if` condition is always evaluating to True due to the second part being a non-empty string.
https://github.com/huggingface/transformers/blob/48101cf8d127bbf22d751c7df118a6ce357e2e27/src/transformers/models/encodec/convert_encodec_checkpoint_to_pytorch.py#L210

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?
@amyeroberts @sanchit-gandhi 

Comments:
Fix `.push_to_hub(..., create_pr=True, revision="my-branch")` when creating PR on not-owned repo
Author: Wauplin
Pull request: yes

Related to [slack discussion](https://huggingface.slack.com/archives/C02EMARJ65P/p1721320383341439) (cc @molbap) (internal link).

When passing a `revision` in a `push_to_hub` call, the code tries to create the branch before pushing files to it. This is useful to avoid crashing on upload if the branch did not exist. However, when using `create_pr=True` as well to open a PR against an existing branch, the call is also made. This is problematic if the user is opening a PR against a branch on a repo they don't own. Since they don't have permission to create the branch, it will fail with a 403 Forbidden (even if the branch already exists).

This PR fixes this. If `revision` and `create_pr` are passed, then we try to create the branch (as before) and if a HTTP 403 is returned, we ignore it. If the branch doesn't exist, the `create_commit` call just after will also fail with a `HTTP 404 RevisionNotFound`.

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

@Wauplin The hub tests that are currently failing should be fixed upstream. Could you try rebasing to include these and trigger a re-run? 

@amyeroberts I just merged main into my branch which re-triggered the tests. CI is now passing correctly :) 

Thanks 🤗
Cleanup tool calling documentation and rename doc
Author: Rocketknight1
Pull request: yes

This is a nit, but the chat templates doc has the title "Templates for Chat Models". This is annoying - it makes it harder to find if you search for 'chat templates'. Calling the doc "Chat Templates" is much cleaner, and almost certainly better SEO.

This PR makes that change, and also simplifies our tool calling documentation a little. Now that it's a little more mature, we've found that relatively few developers are using `tool_call_id`, so I'm taking that out of the core examples and putting it in a `Tip` block instead.

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

Made a couple of tweaks, cc @amyeroberts / @LysandreJik / ? for core maintainer review!

@amyeroberts done, and PR docs should be updated with the improved tool placement!
[i18n-ar] Add file `docs/source/ar/model_doc/yoso.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 : docs/source/ar/model_doc/yoso.md**](https://github.com/AhmedAlmaghz/transformers/blob/Add_docs_source_ar_model_doc_yoso_md/docs/source/ar/model_doc/yoso.md) 

Comments:
🌐 [i18n-KO] Translated `deepspeed.md` to Korean
Author: 4N3MONE
Pull request: yes

<!-- PR의 제목은 "🌐 [i18n-KO] Translated `<your_file>.md` to Korean" 으로 부탁드립니다 -->
# What does this PR do?

Translated the `<your_file>.md` file of the documentation to Korean.
Thank you in advance for your review. 

Part of https://github.com/huggingface/transformers/issues/20179

## Before reviewing
- [x] Check for missing / redundant translations (번역 누락/중복 검사)
- [x] Grammar Check (맞춤법 검사)
- [x] Review or Add new terms to glossary (용어 확인 및 추가)
- [x] Check Inline TOC (e.g. `[[lowercased-header]]`)
- [ ] Check live-preview for gotchas (live-preview로 정상작동 확인)

## Who can review? (Initial)

<!-- 1. 위 체크가 모두 완료된 뒤에만 N조 팀원들에게 리뷰 요청하는 아래 주석을 노출해주세요! 차례대로 1 ~ 5조 -->
<!-- May you please review this PR? -->
<!-- @jun048098, @yijun-lee, @mreraser, @shinhyunji36, @heuristicwave -->
<!-- @win2dvp21, @enchantee00, @fabxoe, @1kmmk1, @junejae -->
@SeungAhSon, @Jwaminju, @thsamajiki, @4N3MONE, @jungnerd
<!-- @mjk0618, @cjfghk5697, @ahnjj, @JinukHong, @nuatmochoi -->
<!-- @010kim, @chhaewxn, @boyunJang, @jeongiin, @harheem -->

## Before submitting
- [x] This PR fixes a typo or improves the docs (you can dismiss the other checks if that's the case).
- [x] Did you read the [contributor guideline](https://github.com/huggingface/transformers/blob/main/CONTRIBUTING.md#start-contributing-pull-requests),
      Pull Request section?
- [ ] Was this discussed/approved via a Github issue or the [forum](https://discuss.huggingface.co/)? Please add a link
      to it if that's the case.
- [x] Did you make sure to update the documentation with your changes? Here are the
      [documentation guidelines](https://github.com/huggingface/transformers/tree/main/docs), and
      [here are tips on formatting docstrings](https://github.com/huggingface/transformers/tree/main/docs#writing-source-documentation).
- [ ] Did you write any new necessary tests?

## Who can review? (Final)

<!-- 2. N조 팀원들과 리뷰가 끝난 후에 아래 주석을 노출해주세요! -->
@stevhliu May you please review this PR?

Comments:
The docs for this PR live [here](https://moon-ci-docs.huggingface.co/docs/transformers/pr_32431). All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update.
🌐 [i18n-KO] Translated `awq.md`to Korean
Author: ahnjj
Pull request: yes

# What does this PR do?

Translated the `awq.md` file of the documentation to Korean.
Thank you in advance for your review. 

Part of https://github.com/huggingface/transformers/issues/20179

## Before reviewing
- [ ] Check for missing / redundant translations (번역 누락/중복 검사)
- [ ] Grammar Check (맞춤법 검사)
- [ ] Review or Add new terms to glossary (용어 확인 및 추가)
- [ ] Check Inline TOC (e.g. `[[lowercased-header]]`)
- [ ] Check live-preview for gotchas (live-preview로 정상작동 확인)

## Who can review? (Initial)

<!-- 1. 위 체크가 모두 완료된 뒤에만 N조 팀원들에게 리뷰 요청하는 아래 주석을 노출해주세요! 차례대로 1 ~ 5조 -->
<!-- May you please review this PR? -->
<!-- @jun048098, @yijun-lee, @mreraser, @shinhyunji36, @heuristicwave -->
<!-- @win2dvp21, @enchantee00, @fabxoe, @1kmmk1, @junejae -->
<!-- @SeungAhSon, @Jwaminju, @thsamajiki, @4N3MONE, @jungnerd -->
@mjk0618, @cjfghk5697, @ahnjj, @JinukHong, @nuatmochoi
<!-- @010kim, @chhaewxn, @boyunJang, @jeongiin, @harheem -->

## Before submitting
- [x] This PR fixes a typo or improves the docs (you can dismiss the other checks if that's the case).
- [x] Did you read the [contributor guideline](https://github.com/huggingface/transformers/blob/main/CONTRIBUTING.md#start-contributing-pull-requests),
      Pull Request section?
- [ ] Was this discussed/approved via a Github issue or the [forum](https://discuss.huggingface.co/)? Please add a link
      to it if that's the case.
- [x] Did you make sure to update the documentation with your changes? Here are the
      [documentation guidelines](https://github.com/huggingface/transformers/tree/main/docs), and
      [here are tips on formatting docstrings](https://github.com/huggingface/transformers/tree/main/docs#writing-source-documentation).
- [ ] Did you write any new necessary tests?

## Who can review? (Final)

<!-- 2. N조 팀원들과 리뷰가 끝난 후에 아래 주석을 노출해주세요! -->
@stevhliu May you please review this PR?

Comments:
The docs for this PR live [here](https://moon-ci-docs.huggingface.co/docs/transformers/pr_32324). All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update.
cleaned get_test_pipeline() unused variables from tests/pipelines files
Author: jacorobe
Pull request: yes

# What does this PR do?

Fixes #32397 

Removes unused variables from the pipeline test's get_test_pipeline() in accordance with the style guide 


## Who can review?

Anyone in the community is free to review the PR once the tests have passed. 



Comments:
Hi @jacorobe, thanks for opening this PR! 

There's some failing tests which seem related to the changes in this PR which will need to be resolved before anything can be merged
fix: Fixed failing `test_find_base_model_checkpoint`
Author: Sai-Suraj-27
Pull request: yes

# What does this PR do?
Fixed the following test, which is currently failing
https://github.com/huggingface/transformers/blob/7f777ab7d987766446b4337f9e6545aab268bad5/tests/utils/test_add_new_model_like.py#L658-L660


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?
@amyeroberts @ArthurZucker 

Comments:
fix: Updated the `is_torch_mps_available()` function to include `min_version` argument
Author: Sai-Suraj-27
Pull request: yes

# What does this PR do?
Here, we are passing the `min_version` argument:
https://github.com/huggingface/transformers/blob/85817d98fb60977c97e3014196a462b732d2ed1a/src/transformers/trainer.py#L3338
But there is no argument named `min_version` in the function definition.
https://github.com/huggingface/transformers/blob/044281605f5fc037e1048d4360da971fdfbca370/src/transformers/utils/import_utils.py#L423-L429

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?
@muellerzr @amyeroberts 

Comments:
Thanks for flagging this, the real fix would be to adjust `is_torch_mps_available` to include this and add the flag. Would you like to do so? + Logic to check the torch version

This is very much so needed since the checked functionality here requires that version.

> Thanks for flagging this, the real fix would be to adjust `is_torch_mps_available` to include this and add the flag. Would you like to do so? + Logic to check the torch version
> 
> This is very much so needed since the checked functionality here requires that version.

Thanks for the quick review @muellerzr. There is a function available to get the torch version, I used this to check for the minimum version.
https://github.com/huggingface/transformers/blob/0164560353aab22b9c7769d344f833ae8a16f478/src/transformers/utils/import_utils.py#L324-L325
PaliGemmaForConditionalGeneration example script not working (AutoProcessor)
Author: asusevski
Pull request: no
Labels: name: bug

### System Info

- `transformers` version: 4.44.0
- Platform: Linux-5.15.153.1-microsoft-standard-WSL2-x86_64-with-glibc2.35
- Python version: 3.10.12
- Huggingface_hub version: 0.24.5
- Safetensors version: 0.4.4
- Accelerate version: not installed
- Accelerate config: not found
- PyTorch version (GPU?): 2.4.0+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?: no
- Using GPU in script?: no
- GPU type: NVIDIA GeForce RTX 3050 Laptop GP

### Who can help?

@stevhliu 

### Information

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

Working on testing llama cpp paligemma gguf conversion script and need to verify embeddings from official paligemma model. 
However, given the example under [PaliGemmaForConditionalGeneration](https://huggingface.co/docs/transformers/en/model_doc/paligemma#transformers.PaliGemmaForConditionalGeneration), I get the following error:

```ValueError: Unsupported number of image dimensions: 2```

The error stems from the AutoProcessor line.

### Expected behavior

No ValueError

Comments:
Hi, I'm unable to replicate the error from the [PaliGemmaForConditionalGeneration](https://huggingface.co/docs/transformers/en/model_doc/paligemma#transformers.PaliGemmaForConditionalGeneration) code example.

I get an error because I can't find the model `google/PaliGemma-test-224px-hf` and the image in the code example (cc @molbap). Otherwise, the example in [Usage tips](https://huggingface.co/docs/transformers/en/model_doc/paligemma#usage-tips) should work.

apologies, when I ran into the issue I had replaced the url with one that is still available (see: ```https://upload.wikimedia.org/wikipedia/commons/thumb/d/d9/Flag_of_Canada_%28Pantone%29.svg/188px-Flag_of_Canada_%28Pantone%29.svg.png``` for a demo I tried)

Full snippet:
```
from PIL import Image
import requests
from transformers import AutoProcessor, PaliGemmaForConditionalGeneration

model_id="google/paligemma-3b-mix-224"
processor = AutoProcessor.from_pretrained(model_id)
url = "https://upload.wikimedia.org/wikipedia/commons/thumb/d/d9/Flag_of_Canada_%28Pantone%29.svg/188px-Flag_of_Canada_%28Pantone%29.svg.png"
image = Image.open(requests.get(url, stream=True).raw)

inputs = processor(images=image, return_tensors="pt")
```

Hi,

When you get ValueError: Unsupported number of image dimensions: 2, it means you're passing a grey-scaled image. You can make it RGB by doing `image = Image.open(requests.get(url, stream=True).raw).convert("RGB")`

I definitely did try this with an image I had on my computer but I guess I had some other unrelated issue. Closing issue
Documentation: BOS token_id deprecation change for NLLB
Author: christoukmaji
Pull request: yes

# What does this PR do?

Changes documentation to account for deprecation changes as outlined in https://github.com/huggingface/transformers/issues/31348


Fixes # (31348)


## 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.

@stevhliu 

Comments:
The docs for this PR live [here](https://moon-ci-docs.huggingface.co/docs/transformers/pr_32443). 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 `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/Add_i18n_README_es_md/i18n/README_es.md) 

Comments:
[i18n-ar] Add file `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/Add_i18n_README_hd_md/i18n/README_hd.md) 

Comments:
Automatically add `transformers` tag to the modelcard
Author: LysandreJik
Pull request: yes

Transformers models on the Hub are not automatically tagged as `transformers` anymore, and this tag should automatically be added to the `metadata`. 

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

It would be better to explicitly tag with `library_name` rather than through normal tags I think

Better now @osanseviero
How to implement bind_tools to custom LLM from huggingface pipeline(Llama-3) for a custom agent
Author: talhaty
Pull request: no



Example Code
```

name = "meta-llama/Meta-Llama-3-8B-Instruct"

auth_token = ""

tokenizer = AutoTokenizer.from_pretrained(name,use_auth_token=auth_token)

bnb_config = BitsAndBytesConfig(
    load_in_8bit=True,
)

model_config = AutoConfig.from_pretrained(
    name,
    use_auth_token=auth_token,
    tempreature=0.1,
)

model = AutoModelForCausalLM.from_pretrained(
    name,
    trust_remote_code=True,
    config=model_config,
    quantization_config=bnb_config,
    device_map='auto',
    use_auth_token=auth_token,
)

streamer = TextStreamer(tokenizer, skip_prompt=True, skip_special_tokens=True)

pipe = pipeline("text-generation", model=model, tokenizer=tokenizer, max_new_tokens=4096, device_map="auto", streamer = streamer)
llm = HuggingFacePipeline(pipeline=pipe)

@tool
def some_custom_tool(input_string: str) -> str:
    """Executes some work and returns a success message if successfull else it return the error message"""
    return "SUCCESS"


tools = [some_custom_tool]
prompt = ChatPromptTemplate.from_messages(
    [
        (
            "system",
            f"""
                You are an Assistant......
            """,
        ),
        ("user", "{input}"),
        MessagesPlaceholder(variable_name="agent_scratchpad"),
    ]
)
            
llm_with_tools = llm.bind_tools(tools)

            

agent = (
    {
        "input": lambda x: x["input"],
        "agent_scratchpad": lambda x: format_to_openai_tool_messages(
            x["intermediate_steps"]
        ),
    }
    | prompt
    | llm
    | JsonOutputParser()
)
            

agent_executor = AgentExecutor(agent=agent, tools=tools, verbose=True, return_intermediate_steps= True)
```

Description

I am trying to bind a custom tool with the LLM just like ChatOpenAI but i am getting the following error. It looks like the bind_tools does exist in HuggingFacePipeline. Is there a way to bind a custom tool to an LLM from HuggingFacePipeline?

AttributeError: 'HuggingFacePipeline' object has no attribute 'bind_tools'

System Info:
```

langchain==0.2.6
langchain-community==0.2.6
langchain-core==0.2.11
langchain-openai==0.1.14
langchain-text-splitters==0.2.2
Python 3.10.13

```
I am doing this on Kaggle GPU t4x2


Comments:
Hello! Did you mean to open this issue in langchain? :)

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.