noamaanMulla-03/transformers-issues huggingface dataset:
input_ids is None when evaluating
Author: qshi95
Pull request: no

Information
=====
When evaluating model checkpoints, I find that input_ids passed to the model is None, but encoder_outputs are available instead. I'd like to obtain the value of input_ids, what should I do? Thanks.

To reproduce
=====
run the following command:

python run_summarization.py \
    --model_name_or_path facebook/bart-large \
    --do_eval \
    --dataset_name cnn_dailymail \
    --dataset_config "3.0.0" \
    --source_prefix "summarize: " \
    --output_dir /tmp/tst-summarization \
    --per_device_train_batch_size=4 \
    --per_device_eval_batch_size=4 \
    --overwrite_output_dir \
    --predict_with_generate

and print(input_ids) in the forward functions of the model.

Comments:
I find that evaluating will run a bart encoder in advance, I add a self.input_ids = input_ids in the encoder, and then can obtain it easily.
🌐 [i18n-KO] Translated `add_tensorflow_model.md` to Korean
Author: keonju2
Pull request: yes

<!-- PR의 제목은 "🌐 [i18n-KO] Translated `add_tensorflow_model.md` to Korean" 으로 부탁드립니다 -->
# What does this PR do?

Translated the `add_tensorflow_model.md` file of the documentation to Korean 😄 
Thank you in advance for your review!

Part of https://github.com/huggingface/transformers/issues/20179
<!-- 메인 이슈에 기록이 남아요! 가짜연구소 리포를 사용해 연습하실때는 제거해주시면 감사하겠습니다! :smile: -->

## 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]]`)
- [x] Check live-preview for gotchas (live-preview로 정상작동 확인)

## Who can review? (Initial)
<!-- 1. 위 체크가 모두 완료된 뒤에만 OSSCA 팀원들에게 리뷰 요청하는 아래 주석을 노출해주세요! -->
<!-- Team OSSCA, may you please review this PR?  -->
@wonhyeongseo, @keonju2, @harheem, @HongB1, @junejae

## 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. 가짜연구소 팀원들과 리뷰가 끝난 후에만 허깅페이스 직원들에게 리뷰 요청하는 아래 주석을 노출해주세요! -->
May you please review this PR?
 @sgugger, @ArthurZucker, @eunseojo

Comments:
Please do not open and close four different PRs for the same file. You can update the original PR.

공들여 번역 및 수정을 통해 훌륭한 결과물이 나오신 것 같네요! 전체적으로 잘 읽히는 것 같습니다~ 

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

Could you review this PR? 😃
@sgugger, @ArthurZucker, @eunseojo
Fix `torch_job` worker(s) crashing
Author: ydshieh
Pull request: yes

# What does this PR do?

CircleCI nightly run's `torch_job` has crashed worker(s). This is due to the change of num. of processes from `3` to `8` in #25274 for that job. This PR changes it to `6` to avoid this crash.

It seems `Oneformer` is the (only) test that uses a lot of memory and causes the crash.

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

Not too bad: we still went from `3` (before) to `6` (this PR) - for `torch_job`!

(And once we can make oneformer test small, we can go `8`.)
Fix missing usage of `token`
Author: ydshieh
Pull request: yes

# What does this PR do?

As pointed in [here](https://github.com/huggingface/transformers/pull/25248#issuecomment-1662999713) and [there](https://github.com/huggingface/transformers/pull/25248#issuecomment-1664783396), there are a few missing `token`.

Thanks @Jackmin801 pointing out this to us.

Comments:
_The documentation is not available anymore as the PR was closed or merged._
Trainer.predict should use padding token from tokenizer when possible
Author: jacob-rosenthal
Pull request: no

### System Info

- `transformers` version: 4.30.2
- Platform: macOS-13.0-arm64-arm-64bit
- Python version: 3.11.4
- Huggingface_hub version: 0.15.1
- Safetensors version: 0.3.1
- PyTorch version (GPU?): 2.0.0 (False)
- 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?

@sgugger 

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

Trainer.predict()

### Expected behavior

As documented, `Trainer.predict()` uses a padding value of -100. However, if the Trainer is initialized with a tokenizer, it would be more consistent to use whatever the padding token is from the tokenizer. That way, the predictions can be decoded by the tokenizer more seamlessly.

I think this could be done by adding a check to `Trainer.evaluation_loop()` to set the padding index:

```python
pad_index = -100 if not self.tokenizer or not self.tokenizer.pad_token_id else self.tokenizer.pad_token_id
```
and then replacing the hardcoded -100 values in the code here with the `pad_index` from above: 

https://github.com/huggingface/transformers/blob/e42587f596181396e1c4b63660abf0c736b10dae/src/transformers/trainer.py#L3113-L3198

I would be happy to open a PR if you think this is a good idea. Thanks!

Comments:
No, that would be inconsistent with the index used by the losses functions for index that should be ignored.

Ok, thanks for the response. I'll close the issue and leave here my code for handling the -100 tokens during decoding for anyone seeing this in the future.

```python
predictions = trainer.predict(test_dataset=dataset)
predictions.label_ids[predictions.label_ids == -100] = trainer.tokenizer.pad_token_id
predictions_decoded = trainer.tokenizer.batch_decode(predictions.label_ids, skip_special_tokens=True)
```

I appreciate all your work! 🚀🤗
Fine-tune T5 on SQuAD
Author: h1326889
Pull request: no

### System Info

I was trying to use the official command to evaluate T5 on SQuAD data, but where can I find the prediction file that contains the actual answer T5 generated?
  python run_seq2seq_qa.py \
  --model_name_or_path t5-small \
  --dataset_name squad \
  --context_column context \
  --question_column question \
  --answer_column answers \
  --do_eval \
  --max_seq_length 384 \
  --doc_stride 128 \
  --predict_with_generate \
  --output_dir /tmp/debug_seq2seq_squad/

### Who can help?

@sgugger

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

NA

### Expected behavior

find the prediction file

Comments:
I didn't verify manually, but I think you have to modify 

https://github.com/huggingface/transformers/blob/fc7ce2ebc52eccd8158a7feeeee11eb44f964937/examples/pytorch/question-answering/run_seq2seq_qa.py#L695-L706

in order to save the prediction (generation).

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.
translate the English documentation into Chinese
Author: liteli1987gmail
Pull request: yes

#  Aim
Aims to translate the English documentation into Chinese, making it easier for Chinese developers to read and reducing the difficulty of accessing the documentation for them.

zh_translate:
@chenglu




Comments:
Hi @liteli1987gmail, thanks for opening this PR and starting the Chinese translation effort! 

Is there a corresponding github issue for this translation? We recommend opening an issue (following [this template](https://github.com/huggingface/transformers/blob/f4e4b4d0e2dc248433e808594f7595292037d891/.github/ISSUE_TEMPLATE/i18n.md#L4)) so that others can easily track progress and contribute. 

As we see here, translating all of the pages at once creates a very large diff that isn't realistic for people to review. Could you instead have each of the pages listed in a checklist on the github issue, and then open a separate PR for each of those pages? 

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.
Contradictory information in documentation about the ability to push qunatized models to hub
Author: amdnsr
Pull request: no

### System Info

Using Google Colab and the main branch of the transformers library on GitHub.

### Who can help?

@sgugger @stevhliu @MKhalusova 

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

The note at the end of the section [Load a large model in 4bit](https://huggingface.co/docs/transformers/main/main_classes/quantization#load-a-large-model-in-4bit) and [Load a large model in 8bit
](https://huggingface.co/docs/transformers/main/main_classes/quantization#load-a-large-model-in-8bit) suggests that it's not possibel to push the quantized weights on the hub:

> Note that once a model has been loaded in 4-bit it is currently not possible to push the quantized weights on the Hub.

> Note that once a model has been loaded in 8-bit it is currently not possible to push the quantized weights on the Hub except if you use the latest transformers and bitsandbytes.

But the example in [Push quantized models on the 🤗 Hub
](https://huggingface.co/docs/transformers/main/main_classes/quantization#push-quantized-models-on-the-hub) suggests that it's possible to push quantized models to the hub.
Same is suggested in [Load a quantized model from the 🤗 Hub
](https://huggingface.co/docs/transformers/main/main_classes/quantization#load-a-quantized-model-from-the-hub)

Does it mean that push to hub is only supported for 8-bit quantized models when using the latest transformers and bitsandbytes but NOT for 4-bit models?

Or is it actually possible to push to hub for both 8-bit and 4-bit quantized models?

### Expected behavior

Can 4-bit and 8-bit quantized models be pushed to hub and be loaded from hub?

Comments:
cc @younesbelkada 

Hi @amdnsr 
Thanks for the issue
as explained in the mentioned paragraphs, it is possible to push 8bit quantized weights only if you use the latest transformers + bitsandbytes. However, pushing 4bit weights is currently not supported

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.
Use small config for `OneFormerModelTest.test_model_with_labels`
Author: ydshieh
Pull request: yes

# What does this PR do?

And now we can safely use `pytest_num_workers=8` for `torch_job`.

The [job run page](https://app.circleci.com/pipelines/github/huggingface/transformers/70121/workflows/759a5a5b-53d0-4641-ace8-136d972079ef/jobs/879218/resources): it shows a peak of 78%. Without this PR (and run with `n8`, we get crashed or ~97 peak RAM usage)



<img width="1112" alt="Screenshot 2023-08-08 170353" src="https://github.com/huggingface/transformers/assets/2521628/d4fbdeba-819a-4618-8b2a-c3eb3c5cd1bc">
 

Comments:
The docs for this PR live [here](https://moon-ci-docs.huggingface.co/docs/transformers/pr_25383). All of your documentation changes will be reflected on that endpoint.
Fix link to swin transformers v2 microsoft model
Author: JuanFKurucz
Pull request: yes

# What does this PR do?

The link `https://huggingface.co/microsoft/swinv2_tiny_patch4_windows8_256/` redirects to a 404. The actual link is https://huggingface.co/microsoft/swinv2-tiny-patch4-window8-256.

At the same time, loading the configuration using 
```python3
from transformers import AutoConfig
config = AutoConfig.from_pretrained("microsoft/swinv2_tiny_patch4_windows8_256")
```
Returns 
```
HTTPError: 401 Client Error: Unauthorized for url: 
https://huggingface.co/microsoft/swinv2_tiny_patch4_windows8_256/resolve/main/config.json
```

As the link is not valid, this change fixes it.

Comments:
_The documentation is not available anymore as the PR was closed or merged._
Fix link to speech encoder decoder model in speech recognition readme
Author: JuanFKurucz
Pull request: yes

# What does this PR do?

Current README documentation aims to `https://huggingface.co/docs/transformers/main/en/model_doc/speechencoderdecoder#speech-encoder-decoder-models`, which redirects to a 404 Not found. The actual link seems to be `https://huggingface.co/docs/transformers/main/en/model_doc/speech-encoder-decoder#speech-encoder-decoder-models`

Comments:
The docs for this PR live [here](https://moon-ci-docs.huggingface.co/docs/transformers/pr_20633). All of your documentation changes will be reflected on that endpoint.
Add copied from for image processor methods
Author: amyeroberts
Pull request: yes

# What does this PR do?

Adds `# Copied from` headers to shared image processor methods to ensure any updates to e.g. docstrings are propogated across. This mainly applies to the methods resize, center_crop and rescale. 

This is in part to prepare for any future adaptations to make handling of images with different number of channels / ambiguous data formats e.g. adding `input_data_format` arguments or handling an ImageArray object. 

## 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?


Comments:
_The documentation is not available anymore as the PR was closed or merged._
MassFormer
Author: yunyicheng
Pull request: no
Labels: name: New model

### Model description

We propose adding a new model, MassFormer, to predict tandem mass spectra accurately. MassFormer uses a graph transformer architecture to model long-distance relationships between atoms in the molecule. The transformer module is initialized with parameters obtained through a chemical pre-training task, then fine-tuned on spectral data. MassFormer outperforms competing approaches for spectrum prediction on multiple datasets and is able to recover prior knowledge about the effect of collision energy on the spectrum. We demonstrate that the model can identify relationships between fragment peaks by employing gradient-based attribution methods. To further highlight MassFormer’s utility, we show that it can match or exceed existing prediction-based methods on two spectrum identification tasks. Our code is the first open-source implementation of a deep-learning MS/MS spectrum predictor and may encourage future research in this area.

### Open source status

- [X] The model implementation is available
- [X] The model weights are available

### Provide useful links for the implementation

This model will be implemented according to the paper by @adamoyoung as listed below.

Reference:
Young, A., Wang, B. and Röst, H., 2021. MassFormer: Tandem mass spectrum prediction with graph transformers. arXiv preprint arXiv:2111.04824.

Comments:
Hey @amyeroberts, could I implement this?
I think the implemented link is [here](https://github.com/Roestlab/massformer)

Hi Adithya, thank you for your interest in this project! However, this is my undergraduate research project in Röst Lab, and I am working with Adamo Young now, planning to optimize the original implementation and make it more suitable for hugging face.

Oh that's alright @yunyicheng, good luck on the implementation!!

Hi @yunyicheng, thanks for opening this new model feature request! 

The recommended and easiest way to add a model is adding the model code to the hub directly using [this tutorial](https://huggingface.co/docs/transformers/custom_models). This avoids the lengthy review process and your model is still available through the typical transformers API e.g. `AutoModel.from_pretrained(...)`. 

cc @clefourrier for graph models :) 

Hi! I agree that adding the code to the hub directly would be the best way to go :)
🌐 [i18n-KO] Translated `perf_train_cpu_many.md` to Korean
Author: nuatmochoi
Pull request: yes

# What does this PR do?

Translated the `perf_train_cpu_many.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]]`)
- [x] Check live-preview for gotchas (live-preview로 정상작동 확인)

## Who can review? (Initial)

May you please review this PR? @nuatmochoi, @bolizabeth, @hyunhp, @heuristicwave, @mjk0618, @jungnerd

## 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)

May you please review this PR? @sgugger, @ArthurZucker, @eunseojo

Comments:
_The documentation is not available anymore as the PR was closed or merged._
16059 - Add missing type hints for ASTModel
Author: nablabits
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 -->

Fixes https://github.com/huggingface/transformers/issues/16059



## Who can review?

@Rocketknight1



Comments:
_The documentation is not available anymore as the PR was closed or merged._
RecursionError or "File name too long" error when HF_HOME is set to a relative path
Author: tamastarjanyi
Pull request: no

### System Info

- `transformers` version: 4.31.0
- Platform: Linux-6.2.0-26-generic-x86_64-with-glibc2.35
- Python version: 3.9.5
- Huggingface_hub version: 0.16.4
- Safetensors version: 0.3.2
- Accelerate version: 0.21.0
- Accelerate config:    not found
- PyTorch version (GPU?): 1.12.1+cu113 (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?

@sgugger @LysandreJi

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

export HF_HOME=hfh 
or
export HF_HOME=.
Then execute below code

```
from pathlib import Path

from transformers import pipeline

print(Path("/home/test/hub") / "/home/test")  # = /home/test # OK
print(Path("home/test/hub") / "home/test")  # = home/test/hub/home/test # BAD
print(Path("hfh/mydir") / "hfh/")  # = hfh/mydir/hfh # BAD
# See dynamic_module_utils.py -> create_dynamic_module() -> Line 62

pipe = pipeline("text-generation", model="databricks/dolly-v2-3b", trust_remote_code=True)
pipe("Why the sky is blue?")
```

Result with HF_HOME=hfh
```
OSError: [Errno 36] File name too long: 'hfh/modules/hfh/modules/hfh/modules/hfh/modules/hfh/modules/hfh/modules/...
```
Result with HF_HOME=.
```
RecursionError: maximum recursion depth exceeded while calling a Python object
```


### Expected behavior

pipeline should be executed

Comments:
Thanks for reporting! The PR linked above should fix this!
YOLOS - Revert default return_pixel_mask value
Author: amyeroberts
Pull request: yes

# What does this PR do?

Fixes a change in default value for `return_pixel_mask` which was changed with #25121

## 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?


Comments:
_The documentation is not available anymore as the PR was closed or merged._
Generate: length validation
Author: gante
Pull request: yes

# What does this PR do?

This PR moves the length validation code to a dedicated function, to make `generate` more readable, and adds code to handle two cases discussed recently in other issues:
1. `min_new_tokens` was not being checked against the maximum possible generation length;
2. users were unaware that a default `max_length` exists, which impacts `min_length` and `min_new_tokens` 

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