noamaanMulla-03/transformers-issues huggingface dataset:
Fix typo in mega.mdx
Author: dleve123
Pull request: yes

# What does this PR do?

Fixes a typo in the Mega documentation.

## Before submitting
- [x] 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?

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.

Documentation: @sgugger, @stevhliu and @MKhalusova

Comments:
_The documentation is not available anymore as the PR was closed or merged._
the line 32 in convert_llama_weights_to_hf is  LlamaTokenizer not LlamaForTokenizer 
Author: zhl5842
Pull request: no

https://github.com/huggingface/transformers/blob/c07a02a4b7892edfee22cbe57d3cdd9e10ae7a4d/src/transformers/models/llama/convert_llama_weights_to_hf.py#L37

from transformers import LlamaForCausalLM, LlamaForTokenizer 

to

from transformers import LlamaForCausalLM, LlamaTokenizer  


Comments:
Hi @zhl5842, thanks for raising this! Would you like to open a PR to fix this doc example? 

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.
🌐 [i18n-KO] Translated `serialization.mdx` to Korean
Author: wonhyeongseo
Pull request: yes

<!-- PR의 제목은 "🌐 [i18n-KO] Translated `<your_file>.mdx` to Korean" 으로 부탁드립니당 -->
# What does this PR do?

Translated the `serialization.mdx` file of the documentation to Korean.
Thank you in advance for your review. 

Part of https://github.com/huggingface/transformers/issues/20179
<!-- 메인 이슈에 기록이 남아요! 가짜연구소 리포를 사용해 연습하실때는 제거해주시면 감사하겠습니다! :smile: -->

## 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?

<!-- 제출 전 체크리스트로, 가짜연구소만의 체크리스트도 <details>로 감싸서 만들어두면 더 좋을 것 같아요. -->

## Who can review?
<!-- 1. 모든 번역이 완료된 뒤에만 가짜연구소 팀원들에게 리뷰 요청하는 아래 주석을 노출해주세요! -->
Team PseudoLab, may you please review this PR? @0525hhgus, @KIHOON71, @sim-so, @gabrielwithappy, @HanNayeoniee, @wonhyeongseo, @jungnerd

<!-- 2. 가짜연구소 팀원들과 리뷰가 끝난 후에만 허깅페이스 직원들에게 리뷰 요청하는 아래 주석을 노출해주세요! -->
@sgugger, @ArthurZucker, @eunseojo May you please review this PR?

Comments:
_The documentation is not available anymore as the PR was closed or merged._

Team PseudoLab, may you please review this PR? @0525hhgus, @KIHOON71, @sim-so, @gabrielwithappy, @HanNayeoniee, @wonhyeongseo, @jungnerd

@sgugger, @ArthurZucker, @eunseojo May you please review this PR?
🌐 [i18n-KO] Translated `token_classification.mdx` to Korean
Author: 0525hhgus
Pull request: yes

# What does this PR do?

Translated the `tasks/token_classification.mdx` file of the documentation to Korean.

Thank you in advance for your review! 😄 

Part of https://github.com/huggingface/transformers/issues/20179

## 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?

<!-- 제출 전 체크리스트로, 가짜연구소만의 체크리스트도 <details>로 감싸서 만들어두면 더 좋을 것 같아요. -->

## Who can review?
<!-- 가짜연구소 팀원들과 리뷰가 끝난 후에만 허깅페이스 직원들에게 리뷰 요청하는 아래 주석을 노출해주세요! -->
Team PseudoLab, may you please review this PR?

@0525hhgus, @KIHOON71, @sim-so, @gabrielwithappy, @HanNayeoniee, @wonhyeongseo, @jungnerd

May you please review this PR?
@sgugger, @ArthurZucker, @eunseojo

Comments:
_The documentation is not available anymore as the PR was closed or merged._

> 정말 많은 내용이 들어 있는 문서였지만 덕분에 금방 읽을 수 있었습니다! 😄 `Named Entity Recognition` -> `개체명 인식`, `dataset`->`데이터셋` 두 가지를 포함하여 몇 가지 수정 사항을 제안 드립니다. 잘 부탁 드리겠습니다!

세심한 리뷰 감사합니다 🤗
감사 코멘트를 전부 달고 싶은데, 알림이 너무 많이 갈 것 같아서 하나만 달겠습니다 😢

- `entity`를 `개체`로 glossary를 포함하여 수정했습니다. 훨씬 이해가 쉽고 익숙해서 좋습니다!
- `데이터 세트`, `콜레이터`, `평가 지표` 단어도 반영했습니다! 꼼꼼하게 봐주셔서 감사합니다 :)
- 오타, 맞춤법, 자연스러운 문장도 모두 반영했습니다. 능동태로 바꾸니까 잘 읽힙니다 🙂

May you please review this PR? 😄 
@sgugger, @ArthurZucker, @eunseojo
ImportError: cannot import name 'AlignModel' from 'transformers
Author: swjtu-jason
Pull request: no

### System Info

ImportError: cannot import name 'AlignModel' from 'transformers

transformers.__version__= 4.22.1


### Who can help?

_No response_

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

ImportError: cannot import name 'AlignModel' from 'transformers

### Expected behavior

I want to import AlignModel from transformers4.22.1

Comments:
ALIGN was only added in v4.27 of Transformers, so you'll need to do `pip install --upgrade transformers` to upgrade to the latest version.

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.
bos_token and eos_token for Llama tokenizer
Author: yujianll
Pull request: no

### System Info

- `transformers` version: 4.28.0.dev0
- Platform: Linux-5.15.0-58-generic-x86_64-with-glibc2.17
- Python version: 3.8.15
- Huggingface_hub version: 0.11.0
- PyTorch version (GPU?): 1.13.0+cu117 (True)
- Tensorflow version (GPU?): not installed (NA)
- Flax version (CPU?/GPU?/TPU?): not installed (NA)
- Jax version: not installed
- JaxLib version: not installed

### Who can help?

@ArthurZucker @zphan

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

```
model = AutoModelForCausalLM.from_pretrained("./llama-7b-hf")
tokenizer = AutoTokenizer.from_pretrained("./llama-7b-hf", use_fast=False)
```

`model.config.eos_token_id` shows 1, but `tokenizer.eos_token_id` shows 2.

### Expected behavior

I wonder if they should be the same, or am I missing something?

Comments:
Hey! There must be a typo in your `generation_config` as the `convert_llama_weights_to_hf.py` as well as `configuration_llama` both set it to `2`. Are you sure that you are using the latest scripts? 
The fix is just `model.config.eos_token_id = 2` in this case. 

I see. The [config.json](https://huggingface.co/decapoda-research/llama-7b-hf/blob/main/config.json) and [generation_config.json](https://huggingface.co/decapoda-research/llama-7b-hf/blob/main/generation_config.json) both set it to 1. So I will change it to 2 for now.

Thank you 


Sent from Yahoo Mail for iPhone


On Monday, March 20, 2023, 11:16 AM, Yujian Liu ***@***.***> wrote:




I see. The config.json and generation_config.json both set it to 1. So I will change it to 2 for now.

—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.Message ID: ***@***.***>





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.
Update test_beam_constraints.py
Author: mzamini92
Pull request: yes

# What does this PR do?

The advantage of using `assertEqual` over `==` is that it provides more informative error messages in case of a failure. For example, if you use `assertEqual(a, b)` and the assertion fails, the error message will include the values of a and b as well as the test name and line number. This makes it easier to identify and fix the problem. Similarly, the advantage of using `assert_` over `==` is that it provides a more informative error `message. assert_` is a method provided by the `unittest.TestCase` class that takes a single argument and asserts that it evaluates to True. If the argument is not True, the test fails and an error message is printed that includes the test name and line number.

<!-- Remove if not applicable -->

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#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?

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 and @younesbelkada
- vision models: @amyeroberts
- speech models: @sanchit-gandhi
- graph models: @clefourrier

Library:

- flax: @sanchit-gandhi
- generate: @gante
- pipelines: @Narsil
- tensorflow: @gante and @Rocketknight1
- tokenizers: @ArthurZucker
- trainer: @sgugger

Integrations:

- deepspeed: HF Trainer: @stas00, Accelerate: @pacman100
- ray/raytune: @richardliaw, @amogkam

Documentation: @sgugger, @stevhliu and @MKhalusova

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: @sgugger
- TensorFlow: @Rocketknight1

 -->


Comments:
_The documentation is not available anymore as the PR was closed or merged._
[`PEFT`] Add HFTracer support for PEFT
Author: younesbelkada
Pull request: yes

# What does this PR do?

For more context, PiPPy is a library for an out-of-the-box Pipeline Parallelism for torch models. PiPPY heavily relies on HF tracer under the hood. 
Some interest has grown to support PiPPy for PEFT models: https://github.com/huggingface/peft/issues/194#issuecomment-1496767740 but it appeared that before this PR PEFT models were not supported by the HF tracer for many reasons. Therefore this PR addresses this, by doing precisely:

1- Relaxing the constraints for the model check in the tracing mechanism
2- Define a proper `__iter__` method for `HFProxy` class to properly handle `**kwargs` calls in the forward passes

A proper testing suite will be added in PEFT, as a set of slow tests, as the GH runner uses an environment that is complied with the main branch of transformers.

Thanks a lot @michaelbenayoun for digging the issue with me

cc @michaelbenayoun @sgugger @pacman100 


Comments:
_The documentation is not available anymore as the PR was closed or merged._

I'm not against the auto-formatting changes, but could we have them in a separate PR please? This is polluting the diff here.
Fix None value when adding info to auto_map
Author: sgugger
Pull request: yes

# What does this PR do?

This should fix the issue encountered in #22983: before testing if `--` in in a value of the auto map, we need to make sure it's not `None`.

Fixes #22983

Comments:
_The documentation is not available anymore as the PR was closed or merged._

There are some, it's juss the case when there is only a fast tokenizer that is custom that is not tested.
None check for encoder
Author: sfilios
Pull request: yes

In the case that BartForConditionalGeneration decoder is being used without an encoder, this change maintains the ability to resize embeddings. 


## 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#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.
- [Not Necessary] 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).
- [Not Necessary] Did you write any new necessary tests?


@ArthurZucker and @younesbelkada


Comments:
_The documentation is not available anymore as the PR was closed or merged._

Hey! As you can see from the red tests, this cannot be merged as it is breaking a lot of the API 😅
🚨🚨🚨 Use default ignore index in Luke
Author: sgugger
Pull request: yes

# What does this PR do?

As discussed in #22981, the `ignore_index` for Luke should be the same as all models in Transformers, even if it does not match the original authors implementation.

This is breaking but needed to align all models to have the same API.

Fixes #22981

Comments:
_The documentation is not available anymore as the PR was closed or merged._
Add interpolation of position encodings to BLIP-2
Author: akkikiki
Pull request: no
Labels: name: Feature request

### Feature request

ViT implemented in Huggingface Transformers has the feature to enable finetuning with different resolution of images
https://huggingface.co/docs/transformers/model_doc/vit#transformers.ViTModel.forward.interpolate_pos_encoding while the newly implemented BLIP-2 model does not. Would like to add those following the ViT implementation.

### Motivation

I was playing around with the model whether different (mainly higher) resolution of input images helps downstream tasks. 

(Curious to get feedback on whether this feature would be needed or not for the sake of keeping the code simple.)

### Your contribution

It's mostly copying & pasting from the ViT implementation `interpolate_pos_encoding` but have a working code ready and ready for PR to get reviewed (and address bugs).

Comments:
it is good if the clip-pretrained model has the interpolate_pos_encoding like vit, 

@amyeroberts Shall I open a pull request? Have one handy.

Hi @akkikiki, thanks for opening this issue! 

`interpolate_pos_encoding` was added to the ViT model the enable cross-loading of DINO weights into the architecture. In general, we try and keep the forward passes of the models as simple as possible (few if/else branches). As such, it's not something that we'll be adding to the model at the moment. Let's keep this issue open, if there's many requests for it from the community (I'll measure with 👍 on your issue description) then we can revisit. 

If you have your own fork with these changes, feel free to share here so others can see and benefit from your work. 

Sounds good! +1 to follow the "keep it simple (and stupid)" principle.
Bring back PartialState DeepSpeed
Author: muellerzr
Pull request: yes

# What does this PR do?

This PR brings back the DeepSpeed implementation. After thorough help and investigation with @pacman100 we've determined the cause of the test failures is an issue on the DeepSpeed side, and an issue will be opened to track this. As a result, to maintain tests passing this PR should not be merged until after it is completed

Said issue: https://github.com/microsoft/DeepSpeed/issues/3341

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#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?

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.

@sgugger @pacman100 

Comments:
_The documentation is not available anymore as the PR was closed or merged._

Hello Zach, after further deep dive, I found that we need to use DeepSpeed utils for initializing distributed setup in Accelerate's Partial State as done in the above-linked PR. This should solve the issues with the DeepSpeed tests.

Thank you for the fix! Confirmed it works

https://github.com/huggingface/transformers/actions/runs/4815347341/jobs/8573997198
Add gradient checkpointing to Whisper Flax
Author: versae
Pull request: yes

It uses `flax.linen.remat` and follows on PRs #13657 and #17994.

# What does this PR do?

Adds gradient_checkpointing to Flax Whisper models.


## 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#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?

@sanchit-gandhi @peregilk 


Comments:
_The documentation is not available anymore as the PR was closed or merged._

Thanks for the review, @sanchit-gandhi! Should be all good now 😃.

Amazing @versae! Requesting final review before we can get this merged 🤗

Thank you! I learnt a lot 🤓
[`Pix2Struct`] Fix pix2struct doctest
Author: younesbelkada
Pull request: yes

# What does this PR do?

Fixes Pix2Struct doctest
Link to failing job: https://github.com/huggingface/transformers/actions/runs/4815336726/jobs/8573921590

With https://github.com/huggingface/transformers/pull/23004 being merged, the label smoothing of the loss function has been removed. Therefore the expected value of the loss function changed, leading to the failing doctest.

cc @ydshieh 


Comments:
_The documentation is not available anymore as the PR was closed or merged._
MegaModel not usable with chunking if input_embeds are used instead of input_ids
Author: jganitzer
Pull request: no

### System Info

When input_embeds are used instead of input_ids then input_ids = None.
Therefore this error happens in modeling_mega.py:

-> 1544 if self.config.use_chunking and (input_ids.size(1) > self.config.chunk_size):
   1545     print(input_ids.size(1))
   1546     if input_ids.size(1) % self.config.chunk_size != 0:

AttributeError: 'NoneType' object has no attribute 'size'

### Who can help?

 @ArthurZucker and @younesbelkada

### 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

from transformers import MegaModel, MegaConfig
class MegaRegressor(nn.Module):
    def __init__(self, input_dim=4, hidden_dim=4, num_layers=2, num_heads=4):
        super().__init__()
        config = MegaConfig(
            vocab_size=4, 
            hidden_size=hidden_dim,
            num_attention_heads=num_heads,
            intermediate_size=4*hidden_dim,
            max_positions=50000,
            num_hidden_layers=num_layers,
            output_attentions=False,
            return_dict=True,
            use_chunking=True,
            chunk_size = 100
        )
        self.encoder = MegaModel(config)
        self.fc = nn.Linear(config.hidden_size, 1)
        self.dropout = nn.Dropout(config.hidden_dropout_prob)

    def forward(self, inputs_embeds):
        out = self.encoder(inputs_embeds=inputs_embeds)  # (batch_size, seq_length, hidden_size)

        output = out['last_hidden_state']
        
        output = torch.mean(output, dim=1)
        
        output = self.dropout(output)
        logits = self.fc(output).squeeze()  # (batch_size, 1)

        return logits

model = MegaRegressor().to(device)
#print(data.shape)  -->  torch.Size([8, 49800, 4])
output = model(data)

### Expected behavior

Model should not raise AttributeError: 'NoneType' object has no attribute 'size'

Comments:
Good catch, the error is pretty straightforward, we should check with either size.