noamaanMulla-03/transformers-issues huggingface dataset:
Fix : wrong link in the documentation (ConvBERT vs DistilBERT)
Author: Tikquuss
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 #14667 

## 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).
- [ ] Did you write any new necessary tests?


## Who can review?

@LysandreJik @mishig25 

<!-- 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:

- albert, bert, xlm: @LysandreJik
- blenderbot, bart, marian, pegasus, encoderdecoder,  t5: @patrickvonplaten, @patil-suraj
- longformer, reformer, transfoxl, xlnet: @patrickvonplaten
- fsmt: @stas00
- funnel: @sgugger
- gpt2: @patrickvonplaten, @LysandreJik
- rag: @patrickvonplaten, @lhoestq
- tensorflow: @LysandreJik

Library:

- benchmarks: @patrickvonplaten
- deepspeed: @stas00
- ray/raytune: @richardliaw, @amogkam
- text generation: @patrickvonplaten
- tokenizers: @n1t0, @LysandreJik
- trainer: @sgugger
- pipelines: @LysandreJik

Documentation: @sgugger

HF projects:

- datasets: [different repo](https://github.com/huggingface/datasets)
- rust tokenizers: [different repo](https://github.com/huggingface/tokenizers)

Examples:

- maintained examples (not research project or legacy): @sgugger, @patil-suraj
- research_projects/bert-loses-patience: @JetRunner
- research_projects/distillation: @VictorSanh

 -->


Comments:
Add a job to test doc building (for realsies this time)
Author: sgugger
Pull request: yes

# What does this PR do?

This PR takes over from #14645 to do it properly this time, meaning:
- we don't rely on secrets anymore which doesn't work for pull-request
- we don't need the secrets as we are not pushing anywhere
- we actually checkout the content after the PR merge, and not just master 🤦 


Comments:
Just rebased on `master` and force-pushed.

Checking that it fails as it's missing the `kenlm` dependency, which I will add right after I confirm it fails.

Yes the object and its docstings exist whether or not `kenlm` is installed.
Put back open in colab markers
Author: sgugger
Pull request: yes

# What does this PR do?

This PR should be merged once everything is ready on moon-landing (cc @mishig25 I will wait for your green light).

Comments:
Making a note that this PR should be merged after https://github.com/huggingface/moon-landing/pull/1621 gets merged

@sgugger done on the moon-landing side. Please feel free to merge this PR

Thanks!
Feature request: Add built-in support for autorregressive text generation with ONNX models
Author: piEsposito
Pull request: no

# 🚀  Add built-in support for autorregressive text generation with ONNX models.

After converting a autorregressive model to ONNX, it would be nice to be able to generate text with it via something like:
```python
from transformers import OnnxTextGenerationModel, AutoTokenizer

model_path = "gpt-something.onnx"
tokenizer_name = "gpt2"

model = OnnxTextGenerationModel(model_path)

# and then

text = "Replace me by any text you'd like."
encoded_input = tokenizer(text, return_tensors='tf')
output = model.generate(encoded_input)
```

With support to using `past_key_values` internally in the most efficient way. 

## Motivation

When trying to accelerate inference with transformers, being unable to load our ONNX model with the lib and running a `model.generate` method to seamlessly generate sequences and perform Beam Search is somehow frustrating. That leads us to have to rely on custom implementations - which takes time and are a lot more prone to have bugs. 

We can try to hack a subclass of `GenerationMixin`, but having to convert things to and from PyTorch makes everything too slow. 

## Your contribution

I can try submitting a PR, but this will take long, as I work full-time and might not have enough time to make it fast.


Comments:
I believe such work is currently happening cc @michaelbenayoun @patrickvonplaten @mfuntowicz 

Nice. Can I contribute to that by any means?


@michaelbenayoun - is this supposed to be implemented in `optimum`?

Yes, this is planned.
Nice to know that there is interest for such features!

Pinging @lewisbails and @philschmid as they were the ones suggesting to add those kind of features to `optimum`.

Hey @piEsposito would you mind moving this feature request over to the `optimum` [repo](https://github.com/huggingface/optimum/issues)? 

Moving forward, we're planning the keep the ONNX export functionality in `transformers` and handle optimisation / generation features in `optimum` (to separate concerns).

Thank you!

Sure, I can do that. 

We are following this discussion on https://github.com/huggingface/optimum/issues/55 .

Thank you!
Make MLuke tokenizer tests slow
Author: sgugger
Pull request: yes

# What does this PR do?

To avoid the timeouts in the test suites, this PR makes all mLuke tokenizer tests slow until we figure out a way to speed them up.

Comments:
cc @NielsRogge 

Hi, I suspect that the slowness is from reading the large `entity_vocab.json` in `MLukeTokenizer.__init__()`, which has 418 MB ([studio-ousia/mluke-base](https://huggingface.co/studio-ousia/mluke-base/tree/main)).
When I tried on my local PC, only reading the entity vocab file in `__init__()` took around 20s.

If this is the problem, we can reduce the file size.
The entity vocabulary has 120M entries, but now we naively represent the same entities from different languages separate entries, like

```
{
	“en:Japan”: 13,
	“de:Japan”: 13,
	'ko:일본’: 13,
	“ja:日本”: 13,
	...
}
```

We could instead represent the entities with Wikidata QID (e.g., `Q17` for `Japan`), which would significantly reduce the file size. Using QID may look cryptic at first, but now we think this may be the right way to handle entities in multilingual settings.
Do you have any suggestions on this?

For tests we don't need a real file (apart from the integration test). All other tokenizers are tested on a vocab of 10-15 tokens, so ideally building something that just have the strict minimum to test would be great.

Sure, I will work on it.
CausalLMHead Models do not register head parameters.
Author: AndreiSiliUiPath
Pull request: no

## Environment info
- `transformers` version: 4.12.2
- Platform: Linux-5.4.0-87-generic-x86_64-with-glibc2.10
- Python version: 3.8.8
- PyTorch version (GPU?): 1.9.1+cu111 (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?: Yes
- Using distributed or parallel set-up in script?: No

### Who can help
@LysandreJik

## Information

Model I am using (Bert, XLNet ...): BertLMHeadModel

The problem arises when using:
* [ ] the official example scripts: (give details below)
* [x] my own modified scripts: (give details below)

The tasks I am working on is:
* [ ] an official GLUE/SQUaD task: (give the name)
* [x] my own task or dataset: (give details below)

## To reproduce

Steps to reproduce the behavior:

1. Instantiate a BertLMHeadModel. The model contains, among others, a linear layer under the path `cls.predictions.decoder `. Specifically, it contains 2 parameters: `cls.predictions.decoder.weight` and `cls.predictions.decoder.bias`.
```python
from transformers import AutoModelForCausalLM
model = AutoModelForCausalLM.from_pretrained("bert-base-uncased", is_decoder=True)
print(model.cls.predictions.decoder)
```
2. Get a list of model parameters.
```python
parameter_keys = list(dict(model.named_parameters()).keys())
```
3. The decoder parameters are missing.
```python
print("cls.predictions.decoder.weight" in parameter_keys)
print("cls.predictions.decoder.bias" in parameter_keys)
```
4. Note that the parameters appear under the cls module:
```python
print(list(dict(model.cls.named_parameters()).keys()))
```
5. Note that the `cls.decoder` module appears to be registerred.
```python
print(list(dict(model.named_modules()).keys()))
``` 

## Expected behavior
Decoder parameters should be incldued in the model parameters.


Comments:
This is because input- and output embeddings are tied (i.e. shared).

But this causes a lot of confusion, I know. Would be better indeed if these get included in the named parameters of a model. cc @LysandreJik 

Thanks for the explanation. Makes sense. I am nut sure including it in the named parameters would help since the optimizer will complain of duplicate parameters in that case. 

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.
Automatically build doc notebooks
Author: sgugger
Pull request: yes

# What does this PR do?

This PR automatically build the notebooks associated to the doc pages and updates them when building the documentation. For now it relies on [this unmerged PR](https://github.com/huggingface/doc-builder/pull/50/files) on the doc-builder side, hence the specific branch (so I can test).

Once the PR there is merged we can remove the specific branch from the job.

As seen with @LysandreJik, I am going to merge this PR to test everything goes well and will revert if not :-)

Comments:
What does adjust_logits_during_generation (formerly prepare_logits_for_generation) do?
Author: cz3344
Pull request: no
Labels: name: Discussion

https://github.com/huggingface/transformers/blob/49c5202522bdaf66e45df505b3a3c566e56134c3/src/transformers/modeling_utils.py#L794

Hi. Anyone can share why there is this method here?

Comments:
Pro Sam @sshleifer, Can you help here. Many thx.

I think it helps to force the model generate a token such as `bos_token` or `eos_token` by setting the probability of generation of all other tokens to 0 

It is only used by `MarianMTModel` and `BartForConditionalGeneration`.
For Bart, what @mariamabarham said is exactly correct
> it helps to force the model generate a token such as bos_token or eos_token by setting the probability of generation of all other tokens to 0.

For Marian, it does that and one extra job, it prevents the model from ever predicting `pad_token_id`. In Marian, it's important that that logic happens before the softmax so that the probabilities of other "legal" tokens are not super low.

Great Q!




> It is only used by `MarianMTModel` and `BartForConditionalGeneration`.
> For Bart, what @mariamabarham said is exactly correct
> 
> > it helps to force the model generate a token such as bos_token or eos_token by setting the probability of generation of all other tokens to 0.
> 
> For Marian, it does that and one extra job, it prevents the model from ever predicting `pad_token_id`. In Marian, it's important that that logic happens before the softmax so that the probabilities of other "legal" tokens are not super low.
> 
> Great Q!

@mariamabarham @sshleifer  Many thanx for your response!
Actually, I am learning the code https://github.com/huggingface/transformers/blob/49c5202522bdaf66e45df505b3a3c566e56134c3/src/transformers/modeling_utils.py#L816 
I am still don't understand how https://github.com/huggingface/transformers/blob/49c5202522bdaf66e45df505b3a3c566e56134c3/src/transformers/modeling_utils.py#L794 can do this. It just returns the same logits back right? What kind of operation in this method？ 

That method is now called `adjust_logits_during_generation`.
It's overwritten for bart:
https://github.com/huggingface/transformers/blob/482a5993c20ef32512a42661bfa404516763b72e/src/transformers/modeling_bart.py#L1028

and marian 
https://github.com/huggingface/transformers/blob/482a5993c20ef32512a42661bfa404516763b72e/src/transformers/modeling_marian.py#L49


Hi @sshleifer  - Just a quick doubt. Why ```adjust_logits_during_generation``` is required for Bart. Is it because of any specific constraints the model is having?

What I have observed, the moment we disable it, generation is going haywire. 
I understood, its doing nothing more than forcing everything except 0 ( bos_token_id ) th index to be small or 0.0. But what is the logical reasoning behind it for Bart Model only. Its not applicable for all models ( say T5 ).
[Flax examples] remove dependancy on pytorch training args
Author: patil-suraj
Pull request: yes

# What does this PR do?

Remove dependency on PyTorch `TrainingArguments` class in flax examples.

Fixes #13721

Comments:
@patrickvonplaten I've run the flax examples tests and made sure that they pass with this PR. Merging this now.
Feel free to leave comments if you see something strange :) 

Awesome - thanks @patil-suraj
Bort always predict wrong words
Author: Oxi84
Pull request: no

Even on api interface Bort predict wrong words in MaskedLM for example here - https://huggingface.co/amazon/bort?text=Paris+is+the+%3Cmask%3E+of+France.

So there has to be some configuration bug that should be fixed.

The same happens when calling Bort using auto classes.

Could you take a look?



Comments:
Pinging @stefan-it here as he contributed this model

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.

Hi @Oxi84 , we were not able to get mask prediction working, even with the original Gluonnlp implementation. So I think it's a good idea to disable the inference for now.

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.
Loading t5 from config file
Author: hadifar
Pull request: no

Why cannot load T5 from a config file? 

Python: 3.9.5
Transformer: 4.12.5
OS: ubuntu 18.04
CPU


```
from transformers import (
    AutoConfig, T5Model, T5ForConditionalGeneration, T5Config,
)


config = AutoConfig.from_pretrained('t5-small')
model = T5ForConditionalGeneration.from_pretrained(config)

```


Here is the link to reproduce the issue in colab:

https://colab.research.google.com/drive/17tKE50_CGH12I-McVrob7JfFkveOH6Mc?usp=sharing



Comments:
This is due to the fact that the "architectures" attribute of the [config](https://huggingface.co/t5-small/blob/main/config.json#L3) of the "t5-small" checkpoint is set to `T5WithLMHeadModel`, however it was renamed to `T5ForConditionalGeneration`.

I believe that should be updated (as well as the other T5 checkpoints). Correct me if I'm wrong @patrickvonplaten.

@hadifar if you want to load the model from scratch with a specific config you can do:

```python
config = AutoConfig.from_pretrained('t5-small')
model = T5ForConditionalGeneration(config)
```

if you want to load the pretrained weights with a specific config (that matches the weights) you should do:

```python
config = AutoConfig.from_pretrained('t5-small')
model = T5ForConditionalGeneration.from_pretrained('t5-small', config)
```
Fix special character in MDX
Author: sgugger
Pull request: yes

# What does this PR do?

In the `quicktour.mdx`, there are a few &amp;lt; that should be < in some of the model outputs.
This will need to be cherry-picked when re-building the stable doc.

Comments:
Merging to test the new automatic jobs to update notebooks and check the doc building is not broken :-)

:+1:
PT CausalLM models config issue
Author: ydshieh
Pull request: no

## Environment info

- `transformers` version: 4.13.0.dev0
- Platform: Windows-10-10.0.19042-SP0
- Python version: 3.9.5
- PyTorch version (GPU?): 1.9.0+cpu (False)
- Tensorflow version (GPU?): 2.7.0 (False)
- Flax version (CPU?/GPU?/TPU?): not installed (NA)
- Jax version: not installed
- JaxLib version: not installed
- Using GPU in script?: No
- Using distributed or parallel set-up in script?: No

### Who can help

@patrickvonplaten @sgugger 

## Information

Several PT causal LM models set `config.is_decoder = True` for a deeply copied `config` after `super().__init__(config)`.
Yet for doc examples in those model files, there are
```
model = XXXForCausalLM.from_pretrained('...', add_cross_attention=False)
assert model.config.is_decoder, f"{model.__class__} has to be configured as a decoder."
```
which fail, since `XXXForCausalLM.config.is_decoder` is `False`.

For example, `BartForCausalLM`:

```
class BartForCausalLM(BartPretrainedModel):
    def __init__(self, config):
        super().__init__(config)
        config = copy.deepcopy(config)
        config.is_decoder = True
        config.is_encoder_decoder = False
        self.model = BartDecoderWrapper(config)
```

And this example will fail
```
Example::

    >>> from transformers import BartTokenizer, BartForCausalLM

    >>> tokenizer = BartTokenizer.from_pretrained('facebook/bart-large')
    >>> model = BartForCausalLM.from_pretrained('facebook/bart-large', add_cross_attention=False)
    >>> assert model.config.is_decoder, f"{model.__class__} has to be configured as a decoder."
    >>> inputs = tokenizer("Hello, my dog is cute", return_tensors="pt")
    >>> outputs = model(**inputs)

    >>> last_hidden_states = outputs.last_hidden_state
```

## To reproduce

Just run the above example:

```
from transformers import BartTokenizer, BartForCausalLM

tokenizer = BartTokenizer.from_pretrained('facebook/bart-large')
model = BartForCausalLM.from_pretrained('facebook/bart-large', add_cross_attention=False)
assert model.config.is_decoder, f"{model.__class__} has to be configured as a decoder."
inputs = tokenizer("Hello, my dog is cute", return_tensors="pt")
outputs = model(**inputs)

last_hidden_states = outputs.last_hidden_state
```

Error:
```
Traceback (most recent call last):
  File "C:\Users\33611\Desktop\Projects\transformers-dev-2\transformers\check_cross.py", line 5, in <module>
    assert model.config.is_decoder, f"{model.__class__} has to be configured as a decoder."
AssertionError: <class 'transformers.models.bart.modeling_bart.BartForCausalLM'> has to be configured as a decoder.
```

## Expected behavior

The example should work. 

- Either `config.is_decoder` and `config.is_encoder_decoder` should be set before `super().__init__(config)` 
- or we should remove `assert model.config.is_decoder, f"{model.__class__} has to be configured as a decoder."`

I think the first is what is intended to be.

## Other

I can open a PR for this once having feedback.

Comments:
Improve documentation of some models
Author: NielsRogge
Pull request: yes

# What does this PR do?

This PR:
- migrates the docs of ImageGPT, TAPAS and TrOCR from rst to Markdown. 
- adds links to my demo notebooks for ViT, BEiT, LUKE, Perceiver.
- improves the docstrings of the Perceiver model.

Comments:
Please ping me when you're ready to merge it @NielsRogge so that I may update the stable docs with this
Code parrot minor fixes/niceties
Author: ncoop57
Pull request: yes

# What does this PR do?

Hi there, really excited by HF expanding into Deep Learning for Software Engineering! This PR just adds a few fixes/niceties I found while testing out the scripts. Specifically:
1. Move the training code to a main function to allow using TPUs (TPU testing still needs to be done, but GPU training still works) with accelerate since it expects some entry function
2. Add some additional flags to human eval script for specifying which device to run the `text-generation` pipeline on and to specify how many tasks to evaluate against as it was previously hard-coded to 4
3. Update documentation to have the correct batch size flag for the validation set (was `eval_batch_size`, but should be `valid_batch_size`), add command for human eval script to use flag `--HF_ALLOW_CODE_EVAL="1"` since the program will throw an exception after generating all the samples, and add a note to make sure to install git-lfs for initializing/training the model.
4. Fix one of the requirements (`huggingface-hub`) to be `0.1.0` so that it does not conflict with the other libraries.

Since I couldn't get TPU training to work even with moving everything into the main function, I can separate out that commit if y'all would prefer into a separate WIP PR while I work on it. Just lemme know :nerd_face:!

You can verify my changes with this colab! https://colab.research.google.com/drive/1Tn0wsqqNbAEpxDn2AFs13Ssqwb0r3o-x?usp=sharing

## 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?
- [ ] 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).
- [ ] Did you write any new necessary tests?


## Who can review?

- research_projects/codeparrot: @lvwerra

Comments:
Alrighty @lvwerra, I think this PR should be (:crossed_fingers:) good to go :rocket:! Lemme know if anything else needs to be done!