noamaanMulla-03/transformers-issues huggingface dataset:
Fix trainer seq2seq qa.py evaluate log
Author: iamtatsuki05
Pull request: yes

# What does this PR do?

<!--

This PR fix the If eval tries to log eval logs with prediction_loss_only and logging_dir, it will not be logged, so I changed it so that logs will be saved.

-->

## 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?
@sgugger  @patil-suraj

Comments:
_The documentation is not available anymore as the PR was closed or merged._
Automodel "from_config" fails when config is loaded from PretrainedConfig.from_dict(config)
Author: elangovana
Pull request: no
Labels: name: bug

### System Info

If the config is saved to dict, it cannot be converted back to autoconfig ??



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


```python
 bart_config = transformers.BartConfig(vocab_size=vocab_size, d_model=64,   encoder_ffn_dim=64, encoder_layers=2, decoder_ffn_dim=64, decoder_layers=2 )

config = bart_config.to_dict()

AutoModelForSeq2SeqLM.from_config(transformers.PretrainedConfig.from_dict(config))
```

This ends up in the following error. What is the alternative to loading autoconfig from a dict?
```text
ValueError: Unrecognized configuration class <class 'transformers.configuration_utils.PretrainedConfig'> for this kind of AutoModel: AutoModelForSeq2SeqLM.
Model type should be one of BartConfig, BigBirdPegasusConfig, BlenderbotConfig, BlenderbotSmallConfig, EncoderDecoderConfig, FSMTConfig, LEDConfig, LongT5Config, M2M100Config, MarianConfig, MBartConfig, MT5Config, PegasusConfig, PLBartConfig, ProphetNetConfig, T5Config, XLMProphetNetConfig.

```

### Expected behavior

`transformers.PretrainedConfig.from_dict(config)` should return the correct config type

Comments:
Hi @elangovana 👋 `PretrainedConfig` is a base class, which is not supposed to work on its own.

Since you know what class you are storing in the example, you can simply do
```python
from transformers import AutoModelForSeq2SeqLM, BartConfig

vocab_size = 128

bart_config = BartConfig(
    vocab_size=vocab_size, d_model=64, encoder_ffn_dim=64, encoder_layers=2, decoder_ffn_dim=64, decoder_layers=2
)
config = bart_config.to_dict()
model = AutoModelForSeq2SeqLM.from_config(BartConfig.from_dict(config))
```

Alternatively, if you don't want to rely on a specific config class at load time, you can also do
```python
from transformers import AutoConfig, AutoModelForSeq2SeqLM, BartConfig

vocab_size = 128

bart_config = BartConfig(
    vocab_size=vocab_size, d_model=64, encoder_ffn_dim=64, encoder_layers=2, decoder_ffn_dim=64, decoder_layers=2
)
bart_config.save_pretrained("/tmp/")
model = AutoModelForSeq2SeqLM.from_config(AutoConfig.from_pretrained("/tmp"))
```

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.
[Speech Model] Add Emformer
Author: anton-l
Pull request: yes

# What does this PR do?

This PR adds the Emformer model: an auto-regressive ASR model with an option for RNN-Transducer decoding.
This model shows promising result for real-time speech recognition and there are 3 pretrained checkpoints available via the torchaudio library:
https://pytorch.org/audio/main/tutorials/online_asr_tutorial.html

Original `torchaudio` implementation: https://github.com/pytorch/audio/blob/main/torchaudio/models/emformer.py

Paper: https://arxiv.org/abs/2010.10759

RNN-Transducer details for reference: https://lorenlugosch.github.io/posts/2020/11/transducer/



Comments:
@anton-l could you leave some comments in the code so that I know where I should take a look for the model design here?

The docs for this PR live [here](https://moon-ci-docs.huggingface.co/docs/transformers/pr_17302). All of your documentation changes will be reflected on that endpoint.

@anton-l do you want to fix the failling tests or should I review already?

@patrickvonplaten I've left a comment about the last major failing test above, but the rest is ready for review :) 
Also I'm not sure what happened to the sentencepiece tests here https://app.circleci.com/pipelines/github/huggingface/transformers/41150/workflows/91d3a0c9-f633-4895-9169-3179f759ced6/jobs/468492, could you take a look please?

> @patrickvonplaten I've left a comment about the last major failing test above, but the rest is ready for review :) Also I'm not sure what happened to the sentencepiece tests here https://app.circleci.com/pipelines/github/huggingface/transformers/41150/workflows/91d3a0c9-f633-4895-9169-3179f759ced6/jobs/468492, could you take a look please?

See: https://huggingface.slack.com/archives/C01NE71C4F7/p1653573450540219?thread_ts=1653570610.579129&cid=C01NE71C4F7 

Rebase to main should solve the issue

@patrickvonplaten looks like the remaining failed tests are unrelated 

Taking this PR over! 

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.

Actually closing this for now as I'm not sure anymore whether this should go into `main`. We should maybe eventually think about a new speech library on top of Transformers

If anyone from the community is interested in taking over this PR, please feel free to do so!
T5model result get <UNK>
Author: moseshu
Pull request: no
Labels: name: New model

### Model description

config = T5Config(num_layers=12,
                      num_decoder_layers=12,
                      pad_token_id=0,
                      es_token_id=VOCAB_SIZE + 2,
                      model_parallel=True,
                      vocab_size=VOCAB_SIZE,
                      num_heads=12,
                      d_model=1024,
                      d_kv=64,
                      d_ff=3072,
                      decoder_start_token_id= VOCAB_SIZE_ZH + 1,
                      )
model = T5ForConditionalGeneration(config)
this is my T5 model config.
 epoch is 200 .I use it to train a translation model, but the result is <UNK>.
How can I use T5ForConditionalGeneration to train my custom model?
my config is right?

### Open source status

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

### Provide useful links for the implementation

_No response_

Comments:
dalle mega
Author: patil-suraj
Pull request: yes
Labels: name: WIP

# What does this PR do?

This PR adds the DalleMega model from [dalle-mini](https://github.com/borisdayma/dalle-mini) for text-2-image generation.
The VQGAN model required for converting the tokens to image is in this PR #18150

- [ ] override the `sample` method for classifier-free guidance. 
- [ ] port and upload weights on the hub
- [ ] add tests
- [ ] add docs
- [ ] boom!

Comments:
@patil-suraj - I can take over the PR if you want :-)

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.
Updated hf_argparser.py
Author: IMvision12
Pull request: yes

# What does this PR do?



Works on #19116


## Summary
- [x] adding as parse_yaml_file method to HfArgumentParser with the code above
- [x] refactor the dupe code between parse_json_file and parse_dict similar to the code above
- [ ] add a small test of parse_yaml_file
- [ ] add a small test of parse_json_file




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

Thanks for your PR! Can you just run `make style` on your branch to fix the code quality issue?

Yeah Sure!


Done @sgugger!!

Thanks again!
Translation italian: add new pipeline
Author: nickprock
Pull request: yes

## What does this PR do?

Italian translation of doc related to the add_new_pipeline of :hugs: Transformers.
* updated _toctree.yml
* added add_new_pipeline.mdx

## 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?
- [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).

See issue: [#17459](https://github.com/huggingface/transformers/issues/17459)

@omarespejel 
@sgugger 
@mfumanelli 

Comments:
_The documentation is not available anymore as the PR was closed or merged._
Run the scheduled tests
Author: LysandreJik
Pull request: yes
Labels: name: WIP

:warning: Do not merge this PR!

PR 2/2: in order to finish running suite, rebase this PR on [`test-tokenizers-main`](https://github.com/huggingface/transformers/tree/test-tokenizers-main), branch of PR https://github.com/huggingface/transformers/pull/16708. 

---

This PR builds on top of https://github.com/huggingface/transformers/pull/16708.

It leverages the docker images created in the PR above, and updates the channel in which to report the tests to be a dummy one.

Comments:
The docs for this PR live [here](https://moon-ci-docs.huggingface.co/docs/transformers/pr_16712). All of your documentation changes will be reflected on that endpoint.
Use `math.pi` instead of `torch.pi` in `MaskFormer`
Author: ydshieh
Pull request: yes

# What does this PR do?

`MaskFormer` uses `torch.pi` which is only available in `torch >= 1.10`. The Past CI with PyTorch 1.9 gives
```bash
AttributeError: module 'torch' has no attribute 'pi'
``` 
This PR adds a warning if PT <= 1.9 for this model, similar in `ViltModel` https://github.com/huggingface/transformers/blob/71fc33174664738d8c8d93025ebc810180e69c20/src/transformers/models/vilt/modeling_vilt.py#L44


**Question: Should we also skip the whole test suite for  `MaskFormer` depending on the torch version? The objective is to make Past CI cleaner if we ever run it again with previous torch version.**

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

> If it's just for `torch.pi` can we change this to `math.pi` and have the model work with PyTorch 1.9?

I can change it to `math.pi`.
[FIX] Document Question Answer warning with Donut model
Author: WaterKnight1998
Pull request: yes

# What does this PR do?

Currently if you try to use the Document Question Answering pipeline with Donut model a warning is thrown telling that the model is not supported. However, the model appears as supported in the documentation.

Reviewers:

Models:

- donut: @NielsRogge 

Library:

- pipelines: @ankrgyl 



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

Hi there @WaterKnight1998, we have an open PR (https://github.com/huggingface/transformers/pull/19027) that aims to solve this problem. I believe @NielsRogge and team prefer not to include `donut-swin` in the list of `AutoModelForDocumentQuestionAnswering`. @NielsRogge would you mind clarifying?

Closing this as it's fixed by #19027
HfArgumentParser support yaml parser
Author: jiangwangyi
Pull request: no
Labels: name: Good First Issue

### Feature request

HfArgumentParser now supports for parsing dict and json files, will it be possible to support for parsing the widely used yaml files?

### Motivation

I think using yaml is a good way to record arguments.

### Your contribution

Not yet.

Comments:
cc @sgugger 

If you want to open a PR, please go ahead!

You can just use
`parser.parse_dict(yaml.safe_load(f))`

Which could all go in a `parse_yaml_file` method :-) Doing this and also refactoring the `parse_json_file` to use `parse_dict`, as well as adding small tests would be nice additions that shouldn't be too hard, so putting the "Good first issue" label here.

To summarize:
- [ ] adding as `parse_yaml_file` method to `HfArgumentParser` with the code above
- [ ] refactor the dupe code between `parse_json_file` and `parse_dict` similar to the code above
- [ ] add a small test of `parse_yaml_file`
- [ ] add a small test of `parse_json_file`

This could be done in a single PR or separate ones :-)


Hi, I would like to work on it



How can i write test for  `parse_yaml_file` and `parse_json_file` it will require an external json and yaml file to testing

No, you can create it during the test by saving some dictionary (look at the `parse_dict` tests) into a temporary file.

Hey, @sgugger I have written the test for `parse_yaml_file` and `parse_json_file` using tempfile is it acceptable?? Also it passes the tests.
![Capture](https://user-images.githubusercontent.com/88665786/192546217-56e3f77f-85ca-4b7f-b1fd-cd54d6f6a3bb.PNG)


You can also use the context manager for a temp dir.
```
with tempfile.TemporaryDirectory() as tmp_dir:
    # Save file in tmp_dir as usual
    # do the tests
```
The plus for this is that it's automatically cleaned up when you exit the with block (whereas the temp file will stay until the next restart).

Okay I will change that!
Small Typo in Docs GenerationMixin for use_cache parameter
Author: ankrgyl
Pull request: no
Labels: name: bug

### System Info

In the text_generation docs (https://huggingface.co/docs/transformers/main_classes/text_generation), `use_cache` does not show up as its own line in the list of parameters.

<img width="973" alt="Screen Shot 2022-09-16 at 6 09 30 PM" src="https://user-images.githubusercontent.com/565363/190812185-35c6eb4d-fbbf-4d17-ad86-6c1d2083c0e0.png">

I think this is a small typo due to an extra `:` in the code. Happy to fix.

### Who can help?

@LysandreJik 

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

The website link

### Expected behavior

`use_cache` should be on its own line

Comments:
@ankrgyl that's a good finding 👍 A PR contribution would be deeply appreciated (for TF and FLAX as well, if the typo also exists there), but I will pick it up otherwise :)
Fix small use_cache typo in the docs
Author: ankrgyl
Pull request: yes

# What does this PR do?

Fixes #19079


## 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?
- [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).
- [ ] Did you write any new necessary tests?


## Who can review?

@gante

Comments:
@gante from what I can tell, generation_flax_utils.py does not have a `use_cache` parameter.

_The documentation is not available anymore as the PR was closed or merged._
Fix doctest for `TFDeiTForImageClassification`
Author: ydshieh
Pull request: yes

# What does this PR do?

Since TF 2.10, `tf.random.set_seed` with a fixed seed won't give the same model weights anymore. See the [release note](https://github.com/tensorflow/tensorflow/releases/tag/v2.10.0). We need `tf.keras.utils.set_random_seed()` for this purpose.

This PR fixes the doctest for `TFDeiTForImageClassification` by using the above solution.

- I have to update the expected value however.
- I get the new expected value on a CPU VM. It should work on the GPU VM too, but let's keep an eye on the CI result.



Comments:
> LGTM! 👍
> 
> is the line that sets the non-Keras seed still needed? (`>>> tf.random.set_seed(3)`)

No we don't need it :-) Removed it.

_The documentation is not available anymore as the PR was closed or merged._
Document and validate typical_p in generation
Author: mapmeld
Pull request: yes

# What does this PR do?

Throws a `ValueError` when `typical_p` argument is provided to text-generation, but its value or `do_sample=False` prevent typical decoding from happening as intended. Adds a line documenting typical decoding.

Most arguments to generate were previously covered in #18261 , but not `typical_p`.


Comments:
_The documentation is not available anymore as the PR was closed or merged._
Fix trainer seq2seq qa.py evaluate log and ft script
Author: iamtatsuki05
Pull request: yes

# What does this PR do?

<!--

This PR fix the If eval tries to log eval logs with prediction_loss_only and logging_dir, it will not be logged, so I changed it so that logs will be saved.

-->

## 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.
- [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?
@sgugger  @patil-suraj

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

Synchronized data from the main branch.
[BUG] Getting different sentence embeddings when using model on CPU and GPU
Author: kbkartik
Pull request: no
Labels: name: bug

### System Info


- `transformers` version: 4.21.2
- Platform: Linux-5.4.188+-x86_64-with-Ubuntu-18.04-bionic
- Python version: 3.7.13
- Huggingface_hub version: 0.9.1
- PyTorch version (GPU?): 1.12.1+cu113 (False)
- Tensorflow version (GPU?): 2.8.2 (False)
- Flax version (CPU?/GPU?/TPU?): not installed (NA)
- Jax version: not installed
- JaxLib version: not installed
- Using GPU in script?: Yes
- Using distributed or parallel set-up in script?: No

### Who can help?

@LysandreJik @sg

### 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 RobertaConfig, RobertaModel, RobertaTokenizer
import torch
import numpy as np
device = ("cuda" if torch.cuda.is_available() else "cpu")
# Initializing tokenizer
tokenizer = RobertaTokenizer.from_pretrained("roberta-base")

# Initializing a RoBERTa configuration
configuration = RobertaConfig()
configuration.vocab_size = tokenizer.vocab_size

# Initializing a model from the configuration
model = RobertaModel(configuration)
model = model.to(device)
model = model.eval()

with torch.no_grad():
    tokenized_task = tokenizer('random_sentence_check_v000', return_tensors="pt")
    outputs = model(**tokenized_task.to(device))
    embedding = outputs.pooler_output.squeeze(0).cpu().numpy().tolist()

### Expected behavior

I should get same sentence embedding either on CPU and GPU from a pretrained model

Comments:
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.

To fix this issue, we need to set the seed values which I forgot.
Fix cache names in CircleCI jobs
Author: ydshieh
Pull request: yes

# What does this PR do?

Fix cache names in CircleCI jobs.

According to [this doc](https://circleci.com/docs/caching#restoring-cache), the cache names in `CircleCI` jobs should follow the patterns:
```yaml
- restore_cache:
      keys:
          - v0.5-torch-{{ checksum "setup.py" }}
          - v0.5-torch-
- save_cache:
      key: v0.5-torch-{{ checksum "setup.py" }}
      paths:
          - '~/.cache/pip'  
```

- The 2nd key in `restore_cache` should be the 1st key without `{{ checksum "setup.py" }}`
- The key in `save_cache` should be the 1st key in `restore_cache`

We need the trailing `-` in the 2nd key in `restore_cache` to avoid the collapse between `v0.5-torch-` and `v0.5-torch_and_tf-` ect.

(Thanks @stas00 for finding this issue, and @gante for the comment on Slack)

Comments:
_The documentation is not available anymore as the PR was closed or merged._
Pipeline return_all_scores deprecation warning might be incorrect
Author: ogabrielluiz
Pull request: no
Labels: name: Good First Issue

name: bug

### System Info

Transformers version: 4.21.3
Python version: 3.8.10



### Who can help?

@Narsil

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

Steps to reproduce:

1. Load a pipeline
2. Call it using `return_all_scores=True`

### Expected behavior

Expected behaviour would be the warning to advise to use `top_k=None` to get a similar result from what I've seen in the code.
The warning states to use `top_k=1`, which does not return all scores.

Comments:
@ogabrielluiz ,

You are correct, we could adapt the error message based on the value of `return_all_scores` (`True -> top_k=None` , `False -> top_k=1`) .

Would you be willing to open a PR on this ?

On it. 

Thanks!