noamaanMulla-03/transformers-issues huggingface dataset:
Fix a Bug, trainer_seq2seq.py, in the else branch at Line 172, generation_inputs should be a dict
Author: TranSirius
Pull request: yes

# Fixing Bug

<!--
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 # (issue)

In `trainer_seq2seq.py / Seq2SeqTrainer / prediction_step`, Line 174 reads:

```python
generated_tokens = self.model.generate(
    **generation_inputs,
    **gen_kwargs,
)
```

which require the generated_tokens to be a `dict`. However, in the `else` branch in Line 171, the `generation_inputs` is created as a `Tensor` object, which will cause a problem.

Fix this by creating `generation_inputs` as a dict, and add a key called `input_ids`.

Comments:
Hey @TranSirius,

Thanks a lot for your PR here! It looks good to me - @sgugger can you maybe take a look as well?

Should we maybe write some tests for this use case as well?

Oops didn't see your comment @patrickvonplaten. Adding a test would be nice to have indeed @TranSirius if you want to work on it on a separate PR.
[trainer] conditional ctx managers into one wrapper
Author: stas00
Pull request: yes

This PR simplifies the code by taking 3 conditionals that are repeated in 3 places in trainer.py and makes use of a wrapper method.

Let me know if you prefer I make this helper method private and add a leading `_`.

If this looks good, we could repeat this in the other places where we have similar situations. While this makes the code simpler it doesn't necessarily make it more easy to understand, since it makes some parts of the logic somewhat hidden.

@sgugger 



Comments:
tf.matrix_band_part have been deprecated
Author: zoheth
Pull request: no

https://github.com/huggingface/transformers/blob/fae0b9faefc371977d139b60202a63dcedbd8ea8/src/transformers/models/xlnet/modeling_tf_xlnet.py#L500

This should be replaced by `tf.linalg.band_part` here?


Comments:
Fix syntax for class references
Author: sgugger
Pull request: yes

# What does this PR do?

This PR fixes the documentation links made of the form :obj:`~transformers.ObjectName`. Those are not detected by `doc-builder` (and can't really be added since we use `:obj:` very often) so I searched and fixed the docstrings instead.

See the [TextClassificationPipeline](https://huggingface.co/docs/transformers/master/en/main_classes/pipelines#transformers.TextClassificationPipeline) in the current doc for an example of the problem:

![image](https://user-images.githubusercontent.com/35901082/144895213-013c0bce-5f40-499a-8631-bd97adb3720e.png)

cc @mishig25 @LysandreJik (merging to fix but will address any comment you have on your return Lysandre).

Comments:
LGTM, thanks for the ping
[Feature request] Doc example copy button - option to remove input prompts and outputs
Author: ydshieh
Pull request: no

# 🚀 Feature request

<!-- A clear and concise description of the feature proposal.
     Please provide a link to the paper and code in case they exist. -->

Documentation page: Make example copy buttons remove input prompts (`>>>` and `...`) before copying, as well as skip lines that don’t start with prompts (in case they are output lines). Or provide the option to toggle this functionality.

## Motivation

When I copy doc examples, the input prompts & outputs lines are also copied. It would be very convenient to remove these automatically. I have seen some websites that can do this, or even toggle the modes for copying or not copying these prompts.

You can find an example here:

[Sphinx-copybutton](https://sphinx-copybutton.readthedocs.io/en/latest/#)

## Your contribution

It's not clear to me how to contribute to this, but I will be happy to do it if it's possible and welcomed.


Comments:
This is a bug that will be fixed soon, see https://github.com/huggingface/doc-builder/issues/41. cc @mishig25. Thanks for reporting.

Thanks, @NielsRogge . I didn't follow that repository. I am closing this issue.
"Size mismatch" when using the same type of model as pretraining during finetuning while "num_labels" is diffierent
Author: CaoYiqingT
Pull request: no

Model - Roberta
The details of this issue are as follows:
Code used:
```
         pretrain model and param: RobertaForSequenceClassification with num_labels=3
         pretrain model saving method: model.save_pretrained(save_path)

         finetune model and param: RobertaForSequenceClassification with num_labels=2
         finetune load model param method: RobertaForSequenceClassification.from_pretrained(save_path, num_labels=2)
```

What I wished is to load pretrain param with the classifier layer param randomly initialized, for the finetune process has diffierent num_labels as pretrain. But I got the following error:
`RuntimeError: Error(s) in loading state_dict for RobertaForSequenceClassification:
	size mismatch for classifier.out_proj.weight: copying a param with shape torch.Size([3, 768]) from checkpoint, the shape in current model is torch.Size([2, 768]).
	size mismatch for classifier.out_proj.bias: copying a param with shape torch.Size([3]) from checkpoint, the shape in current model is torch.Size([2]).`

For sure, I can fix this manually by first loading the model params in RobertaModel, then saving RobertaModel and finally using RobertaModel params to init my new RobertaForSequenceClassification, but it's somehow complicated for the same kind of problems might occure at any moment. Maybe fix this in the next version of huggingface transformers in a good choice.

Best wish
@LysandreJik 



Comments:
We've recently added a new `ignore_mismatched_sizes` argument to the `from_pretrained` method, which can be set to `True` to ignore such runtime errors, and to be able to replace the head of an already fine-tuned model.

You can run it as follows:

```
from transformers import RobertaForSequenceClassification

model = RobertaForSequenceClassification.from_pretrained("path_to_already_finetuned_model", num_labels= 3, ignore_mismatched_sizes=True)
```

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/master/CONTRIBUTING.md) are likely to be ignored.
the results of run_glue_no_trainer.py are different from those reported in the paper
Author: junleiz
Pull request: no

## Environment info
<!-- You can run the command `transformers-cli env` and copy-and-paste its output below.
     Don't forget to fill out the missing fields in that output! -->

- `transformers` version:
- Platform: ubuntu 18
- Python version: 3.6
- PyTorch version (GPU?): 1.6
- Tensorflow version (GPU?): 
- Using GPU in script?: YES
- Using distributed or parallel set-up in script?: no

### Who can help
@LysandreJik @sgugger 
Models:

I fine-tuned the Bert-base model on the GLUE dataset using run_glue_no_trainer.py provided by hugging face (https://github.com/huggingface/transformers/tree/master/examples/pytorch/text-classification). The results are similar those in the website:
![image](https://user-images.githubusercontent.com/26025961/139570070-124094ad-8692-4046-824e-04bd05e9b794.png)
But the results reported in the paper are:
![image](https://user-images.githubusercontent.com/26025961/139570130-2a2f8b2a-a964-45b0-9902-d20c56c78c20.png)
Why they are significantly different?


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/master/CONTRIBUTING.md) are likely to be ignored.
Add BigBird/BigBird Pegasus to models exportable with ONNX
Author: genolve
Pull request: yes

This PR adds BigBird and BigBird Pegasus to models exportable with ONNX and also adds them in test_onnx_v2.py




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/master/CONTRIBUTING.md) are likely to be ignored.
Small fix for GPT2OnnxConfig
Author: nguyenhuuthuat09
Pull request: yes

# What does this PR do?

This PR fix a small bug of `GPT2OnnxConfig()`.

Since `GPT2OnnxConfig.input` currently lacks a `dynamic_axes` for `input sequence length`, we cannot feed an input of any length into exported `GPT2 Onnx model` when doing inference.  (I used [this guide](https://huggingface.co/docs/transformers/serialization) to export Onnx model.)

I checked other supported models' `OnnxConfig`, they seem doesn't have this issues.




## 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/master/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/master/docs), and
      [here are tips on formatting docstrings](https://github.com/huggingface/transformers/tree/master/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.

@patrickvonplaten, @LysandreJik



Comments:
cc @mfuntowicz @lewtun @michaelbenayoun 

Oh, great to know about it! Never mind, I am going to close this PR. 

Hope to see the new update soon and thank you all very much for your great contribution to the community!
Convert tutorials
Author: sgugger
Pull request: yes

# What does this PR do?

This PR converts the rst files in the documentation that currently have a corresponding notebook to Markdown so I can then work on updating the script that auto-generates the notebooks form the documentation.

Comments:
You need to follow this format for the ColabDropdown to appear:
https://github.com/huggingface/doc-builder/blame/92bc1f3833fc825bd772455df17505d1f322ee88/build/transformers/master/en/quicktour.mdx#L43-L51
1. Put `ColabDropdown` svelte component after the title
2. And change `options` attribute

Also, for this change ti take effect, we need to merge various PR in a specific order:
1. https://github.com/huggingface/moon-landing/pull/1621
2. https://github.com/huggingface/doc-builder/pull/42
3. https://github.com/huggingface/transformers/pull/14655

Thanks for the syntax! Will amend this PR but I think we can make it a bit easier on the documentation writer since all the links are automatically generated. I'll add a syntax `[[colab]]` (like we use `[[autodoc]]`) to the `doc-builder` and it will replace it with the component you created.

@sgugger sounds great to me! could you add the parsing side for `[[colab]]` on doc-builder?

Yes, I will work on that this morning. Feel free to merge the two PRs in order once they are ready, I want @LysandreJik to review this one anyway.

Arg, rebase messed up the diff :-( Closing an re-opening.
Do we use JSON lines or JSON only for run_translation.py in PyTorch?
Author: GaurangTandon
Pull request: no

### Who can help

Models:

- maintained examples (not research project or legacy): @sgugger, @patil-suraj

## Information

The run_translation.py file requires that we pass `train_file` and `validation_file` as **json** file only, see:

https://github.com/huggingface/transformers/blob/master/examples/pytorch/translation/run_translation.py#L219

However, the [README](https://github.com/huggingface/transformers/tree/master/examples/pytorch/translation) states that

> The task of translation supports only custom JSONLINES files, with each line being a dictionary with a key "translation" and its value another dictionary whose keys is the language pair

Also in the example just above this line, it references jsonlines:

```bash
python examples/pytorch/translation/run_translation.py \
    --model_name_or_path t5-small \
    ...
    --train_file path_to_jsonlines_file \
    --validation_file path_to_jsonlines_file \
    ...
```

Similarly, from the argument description:

https://github.com/huggingface/transformers/blob/master/examples/pytorch/translation/run_translation.py#L115

I have made a merge request to address, what I believe, is an issue. Please correct me if I'm wrong. Thanks.

Comments:
fix: verify jsonlines file in run_translation (#14660)
Author: GaurangTandon
Pull request: yes

# What does this PR do?

Fixes #14660 

The documentation and the code everywhere mention jsonlines file except in the actual code where the verification was for json file instead.

## 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/master/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/master/docs), and
      [here are tips on formatting docstrings](https://github.com/huggingface/transformers/tree/master/docs#writing-source-documentation).
- [x] Did you write any new necessary tests?


## Who can review?

Examples:

- maintained examples (not research project or legacy): @sgugger, @patil-suraj




Comments:
Thanks for your PR! You should accept both extensions as there are many jsonline files that actually have the .json extension.

Thanks @sgugger , it is fixed now
Missing weight parameter when loading from deepspeed stage-2
Author: Atharva-Phatak
Pull request: no

Converting deepspeed_zero_stage_2 to fp32 misses some parameters. I was finetuning bart-large using deepspeed_stage_2. I converted to fp32 checkpoints(using zero_to_fp32.py) and got a .bin file.

When I try to load this model using model.load_state_dict(path_to_bin_file) I get the following keys missing error.
"model.embed.tokens.weight" ?

I am using using pytorch-lightning for training.

Comments:
Maybe @stas00 has encountered this error in the past

Since you were using PL, you probably want to ask that question on their Issues, since I don't know how they did the Deepspeed integration.

i.e. this question is unrelated to `transformers`
[trainer] support UserDict inputs (torch-nightly)
Author: stas00
Pull request: yes

torch-nightly has changed the behavior of DataLoader. Until now its iterator was returning a `dict` structure, but with pt-11 it now returns our custom `BatchEncoding` dict structure, which broke `_prepare_inputs` in Trainer as it misses the `dict` check.

This PR fixes the problem switching to checking if it's any kind of dict structure via Mappings and removes `**` as dict can be init'ed with any type of dict. (`**dict` breaks with `UserDict`)

Thanks to @sgugger for helping me to fix this one.

@sgugger 

Comments:
Move pyctcdecode
Author: sgugger
Pull request: yes

# What does this PR do?

This PR moves the `pyctcdedcode` to the methods of `Wav2Vec2ProcessorWithLM` so that one can always import it. The dependencies seem a bit tricky to all install (and in particular kenlm is a hard requirement but it doesn't seem to always work properly, especially in notebooks) so this makes the object easier to import for everyone.

Comments:
LongformerTokenizer Error
Author: Gracccce
Pull request: no

## Environment info
<!-- You can run the command `transformers-cli env` and copy-and-paste its output below.
     Don't forget to fill out the missing fields in that output! -->

- `transformers` version: 2.11.0
- Platform: Linux-5.10.68+-x86_64-with-debian-buster-sid
- Python version: 3.7.6
- PyTorch version (GPU?): 1.5.1 (True)
- Tensorflow version (GPU?): 2.2.0 (True)
- Using GPU in script?: fill in
- Using distributed or parallel set-up in script?: fill in

### Who can help
@patrickvonplaten

## Information

Model I am using (Bert, XLNet ...):
Longformer
The problem arises when using:
* [ ] the official example scripts: (give details below)
>>> from transformers import LongformerTokenizer, LongformerForSequenceClassification
>>> import torch

>>> tokenizer = LongformerTokenizer.from_pretrained('allenai/longformer-base-4096')
>>> model = LongformerForSequenceClassification.from_pretrained('allenai/longformer-base-4096')

>>> inputs = tokenizer("Hello, my dog is cute", return_tensors="pt")

---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-9-509e5550f58e> in <module>
----> 1 inputs = tokenizer("Hello, my dog is cute", return_tensors="pt")

TypeError: 'LongformerTokenizer' object is not callable


Comments:
Revert open-in-colab and add perceiver
Author: sgugger
Pull request: yes

# What does this PR do?

I merged a bit too fast #14665 so this PR reverts the [[open-in-colab]] markers since the corresponding Svelte component has not been merged yet.
This PR also adds Perceiver to the table of content. (cc @NielsRogge )

Comments:
LGTM!
The loss function should ignore tokens whose index is set to - 100
Author: Silypie
Pull request: no

Loss function in `EncoderDecoderModel` as well as `BartForConditionalGeneration` didn't ignore special tokens:
https://github.com/huggingface/transformers/blob/e9800122a6f6a68aee7dff347c8f4a6d28e345a2/src/transformers/models/encoder_decoder/modeling_encoder_decoder.py#L529

Does it need to be like the loss function in `T5ForConditionalGeneration`:
https://github.com/huggingface/transformers/blob/e9800122a6f6a68aee7dff347c8f4a6d28e345a2/src/transformers/models/t5/modeling_t5.py#L1644

Comments:
No, the ignore_index is set to -100 by default as can be seen in PyTorch' [docs](https://pytorch.org/docs/stable/generated/torch.nn.CrossEntropyLoss.html).

> No, the ignore_index is set to -100 by default as can be seen in PyTorch' [docs](https://pytorch.org/docs/stable/generated/torch.nn.CrossEntropyLoss.html).

I got it, thank you very much!
add str hub token to repository when provided else fallback to default
Author: philschmid
Pull request: yes

# What does this PR do?

This PR fixes the Repository creation when using `PushToHubCallback`. Currently, the Repository is created assuming the `HF_TOKEN` is available on the machine, but that's not the case for every scenario. 
These changes check if the `hub_token` parameter is provided if yes then it is passed into the `Repository` if not the default value `True` is used. 


Comments:
should we/can we add in the upcoming release to have it "fixed" for now and then improve on it? @Rocketknight1 @LysandreJik ? 

Yes, agreed that it should be in the PR; pinging @Rocketknight1 for a quick review and will merge afterwards.

Also I'll be doing significant updates to the PushToHubCallback in the model card PR that's due Soon™, so I'll play around with it a bit more when I'm testing that.
[WIP] Add Flax FNet
Author: gchhablani
Pull request: yes

# What does this PR do?

This PR adds FNet model in Flax.

Comments:
Thanks for that 🤗 I could test it on TPU whenever the PR is ready, I think only the Auto Configuration stuff is missing 😅

@stefan-it It will take me some time to finish this. I will let you know when it is working!

I will be continuing this PR after #13752 is merged, just in case any changes are needed afterwards.

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/master/CONTRIBUTING.md) are likely to be ignored.

Unstale

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/master/CONTRIBUTING.md) are likely to be ignored.
Wrong link in the documentation (ConvBERT, BART, Fnet)
Author: Tikquuss
Pull request: no

In the documentation on transform-based models [0], the link that is supposed to point to the **ConvBERT** paper [1, 2] points instead to the **DistilBERT** paper [3].

[0] https://huggingface.co/docs/transformers
[1] https://huggingface.co/docs/transformers/model_summary#convbert
[2] https://arxiv.org/pdf/2008.02496.pdf
[3] https://arxiv.org/pdf/1910.01108.pdf

Comments:
Nice catch! Would you like to submit a PR to amend this?

Sure ! As soon as I finish reading the documentation, to avoid making two PRs in case I find another error.

Going through the documentation I found an error and a warning. I'll make a PR about it. I just want to note that I didn't do a documentation review, I stumbled upon these errors by coincidence: my remarks should therefore not be considered an absolute documentation review.

# Fnet [1]
At the level of model documentation, the label corresponding to FNet is rather FlauBERT (see screenshot below)

![fnet](https://user-images.githubusercontent.com/49171640/145333383-08cd58e6-4739-403b-943c-b4fd48fb39ab.jpg)


# BART [2]
At the level of the model documentation, the link that points to the BART authors' code points to a github branch that has been modified [3, 4].

[1] https://huggingface.co/docs/transformers/model_doc/fnet
[2] https://huggingface.co/docs/transformers/model_doc/bart#overview
[3] https://github.com/pytorch/fairseq/tree/master/examples/bart
[4] https://github.com/pytorch/fairseq/tree/main/examples/bart

@mishig25 do you know where this could come from?

@LysandreJik https://github.com/huggingface/transformers/pull/14704