noamaanMulla-03/transformers-issues huggingface dataset:
[INFO|modelcard.py:460] 2022-03-11 19:03:24,502 >> Dropping the following result as it does not have all the necessary fields: {'task': {'name': 'Causal Language Modeling', 'type': 'text-generation'}}
Author: Penguin-jpg
Pull request: no

## Environment info
- `transformers` version: 4.18.0.dev0
- Platform: Windows-10-10.0.17763-SP0
- Python version: 3.6.8
- Huggingface_hub version: 0.4.0
- PyTorch version (GPU?): 1.10.2+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?: yes
- Using distributed or parallel set-up in script?: no

Models:
- GPT-Neo

Examples:
- lanuage modelling/run_clm.py and run_clm_no_trainer.py
- maintained examples (not research project or legacy): @sgugger, @patil-suraj

## Information

Model I am using (Bert, XLNet ...):GPT-NEO

The problem arises when using:
* [x] the official example scripts: (give details below)
   I used run_clm.py and run_clm_no_trainer.py to train GPT-NEO, but it doesn't work today. It worked everytime before today.
* [ ] 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)
  I repeated the process in https://github.com/gagan3012/project-code-py/blob/master/notebooks/gptneomodel.ipynb to create this dataset. I didn't make it a txt file, I use csv. But I also tried a txt file(the data is from https://s3.amazonaws.com/code-search-net/CodeSearchNet/v2/python.zip), and it didn't work.(Both file worked before.)

## To reproduce

Steps to reproduce the behavior:

1. change directory to transformers\examples\pytorch\language-modeling
2. run the command below
```
python run_clm.py^
      --output_dir C:\GPT_Coder\model_gpt_neo_test^
      --model_name_or_path EleutherAI/gpt-neo-125M^
	  --train_file C:\GPT_Coder\data\leetcode\train.csv^
      --validation_file C:\GPT_Coder\data\leetcode\valid.csv^
	  --validation_split_percentage 0^
      --per_device_train_batch_size 8^
      --per_device_eval_batch_size 8^
      --learning_rate 5e-5^
	  --block_size 128^
	  --num_train_epochs 10
```
3. after tokenized the dataset and group text, this message shows
![image](https://user-images.githubusercontent.com/69071861/157858881-197e5677-52c2-4ed8-a9cb-00b3deb513e7.png)

## Expected behavior
I expected it to start training just like how it worked before.


Comments:
Hi @Penguin-jpg , to run the training and evaluation you should pass the `--do_train` and `--do_eval` arguments to the script. 

> Hi @Penguin-jpg , to run the training and evaluation you should pass the `--do_train` and `--do_eval` arguments to the script.

Thanks!! It works! But it is weird. I am pretty sure that when I passed do_train and do_eval then it said no such argument or something like that before today. I had to remove them to make it work.
Deberta v2 code simplification
Author: guillaume-be
Pull request: yes

# What does this PR do?

This PR simplifies and fixes the code for the DeBERTa V2 disentangled attention bias calculation:
1. Removes a spurious substraction of the type `x - x` always resulting in 0
2. Fixes condition checking for the attention type and attention score calculation. In the current version, the additional check to see if `p2p` is in the attention type is performed at the wrong position (https://github.com/huggingface/transformers/blob/2c2a31ffbcfe03339b1721348781aac4fc05bc5e/src/transformers/models/deberta_v2/modeling_deberta_v2.py#L781).  The `p2c` attention is not used for `p2p`, but `c2p` is. Currently the execution would fail if the attention types include `p2p` but not `c2p`: the c2p_pos variable used https://github.com/huggingface/transformers/blob/2c2a31ffbcfe03339b1721348781aac4fc05bc5e/src/transformers/models/deberta_v2/modeling_deberta_v2.py#L813 would not be defined at https://github.com/huggingface/transformers/blob/2c2a31ffbcfe03339b1721348781aac4fc05bc5e/src/transformers/models/deberta_v2/modeling_deberta_v2.py#L772. This PR moves the check for the `p2p` attention flag to the right position and simplifies the `p2c` attention calculation.

## Who can review?

@LysandreJik
@BigBird01 

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

Hello @LysandreJik , @BigBird01 ,
As discussed a couple of weeks back I wanted to reach out to see if any further work would be required on this PR.

Thank you!

LGTM, also pinging @anton-l  as it affects SEW/SEW-D

Hello @LysandreJik , @anton-l 
I was wondering if there is further work required on this PR?
Thank you!

Hi @guillaume-be, no further changes required from my side (SEW-D models), feel free to merge if everything else is ok 🙂 

Thanks for your PR, merging!
Add Slack notification support for doc tests
Author: patrickvonplaten
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 -->

This PR enables Slack reports for the daily doc tests.

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

I will look this later today. Still learn this kind of things. If it is urgent, don't hesitate to go ahead though.

LGTM (without looking the notification script in detail).

Just 2 questions (due to my lack of expertise):

- why `working-directory: transformers` are removed (they appear in `self_scheduled.yml`)?
- I saw the following block is removed (it doesn't show up in `self_scheduled.yml` though)
```python
with:
      repository: 'huggingface/transformers'
      path: transformers
```
(just wondering why we don't need this)


> 

Very good question! And I don't really know the answer :D I just noticed that it didn't work with 

```py
with:
      repository: 'huggingface/transformers'
      path: transformers
```

very well and I also think it's not necessary here so I removed it. Maybe @LysandreJik can give you a better answer.
Issue in Tutorial - "Fine-tune a pretrained model"
Author: aflah02
Pull request: no

One of the code snippets in the tutorial are -

```
from datasets import load_dataset

dataset = load_dataset("yelp_review_full")
dataset[100]
```

However this raises an error - 

```
KeyError                                  Traceback (most recent call last)
[<ipython-input-1-0e4a64458134>](https://localhost:8080/#) in <module>()
      2 
      3 dataset = load_dataset("yelp_review_full")
----> 4 dataset[100]

[/usr/local/lib/python3.7/dist-packages/datasets/dataset_dict.py](https://localhost:8080/#) in __getitem__(self, k)
     46             suggested_split = available_suggested_splits[0] if available_suggested_splits else list(self)[0]
     47             raise KeyError(
---> 48                 f"Invalid key: {k}. Please first select a split. For example: "
     49                 f"`my_dataset_dictionary['{suggested_split}'][{k}]`. "
     50                 f"Available splits: {sorted(self)}"

KeyError: "Invalid key: 100. Please first select a split. For example: `my_dataset_dictionary['train'][100]`. Available splits: ['test', 'train']"
```

I believe this is just a missing extra key while trying to access the value in the dictionary. 

So the last line should be something like - 

`dataset['train'][100]`

Which does indeed give a correct output - 

```
{'label': 0,
 'text': 'My expectations for McDonalds are t rarely high. But for one to still fail so spectacularly...that takes something special!\\nThe cashier took my friends\'s order, then promptly ignored me. I had to force myself in front of a cashier who opened his register to wait on the person BEHIND me. I waited over five minutes for a gigantic order that included precisely one kid\'s meal. After watching two people who ordered after me be handed their food, I asked where mine was. The manager started yelling at the cashiers for \\"serving off their orders\\" when they didn\'t have their food. But neither cashier was anywhere near those controls, and the manager was the one serving food to customers and clearing the boards.\\nThe manager was rude when giving me my order. She didn\'t make sure that I had everything ON MY RECEIPT, and never even had the decency to apologize that I felt I was getting poor service.\\nI\'ve eaten at various McDonalds restaurants for over 30 years. I\'ve worked at more than one location. I expect bad days, bad moods, and the occasional mistake. But I have yet to have a decent experience at this store. It will remain a place I avoid unless someone in my party needs to avoid illness from low blood sugar. Perhaps I should go back to the racially biased service of Steak n Shake instead!'}
```



Comments:
I can fix this if this fix looks fine

I think your code is right.

@lishengfever yeah i feel so too and it works but the pull request got clouded after running make style so I'm waiting for a response for that
`self.encoder_attn` not defined for PyTorch XGLM
Author: OllieBroadhurst
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: 4.17.0
- Platform: Ubuntu
- Python version: 3.7
- PyTorch version (GPU?): 1.10.0+cu111
- Tensorflow version (GPU?): NA
- Using GPU in script?: Y
- Using distributed or parallel set-up in script?: N

### Who can help
@patil-suraj 

## Information

Model I am using (Bert, XLNet ...): XGLM

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:

```python
tokenizer = XGLMTokenizer.from_pretrained("facebook/xglm-564M")
model = EncoderDecoderModel.from_encoder_decoder_pretrained("facebook/xglm-564M", "facebook/xglm-564M")

model.config.decoder_start_token_id = tokenizer.cls_token_id
model.config.pad_token_id = tokenizer.pad_token_id

inputs = tokenizer("Test input", return_tensors="pt").input_ids
labels = tokenizer("Test label", return_tensors="pt").input_ids

with torch.no_grad():
    outputs = model(input_ids=inputs, labels=labels)

print(outputs.loss)
```

You should get:

```python

AttributeError: 'XGLMDecoderLayer' object has no attribute 'encoder_attn'
```

This is because `self.encoder_attn` [here](https://github.com/huggingface/transformers/blob/master/src/transformers/models/xglm/modeling_xglm.py#L472) hasn't been defined. It looks like it should be an instance of `XGLMAttention` looking at the Flax version [here](https://github.com/huggingface/transformers/blob/master/src/transformers/models/xglm/modeling_flax_xglm.py#L330).

## Expected behavior

The example above should print out a loss number.

Thanks!


Comments:
Good catch! Should be fixed in https://github.com/huggingface/transformers/pull/16290
Typo: Missing a coma in document
Author: PolarisRisingWar
Pull request: no

In `https://huggingface.co/docs/transformers/master/en/task_summary#extractive-question-answering`, this sentence:
![image](https://user-images.githubusercontent.com/48322321/159153847-6a1bcd93-855b-4425-9716-fd1a576068ea.png)
Should it be `model-specific separators, token type ids and attention masks`?

Comments:
Thank you for flagging this typo 👍  Would you like to open a PR with the fix, @PolarisRisingWar? (source file [here](https://github.com/huggingface/transformers/blob/master/docs/source/task_summary.mdx)) 

If not, I can take care of it :)
Remove disclaimer from Longformer docs
Author: gchhablani
Pull request: yes

# What does this PR do?
This PR removes disclaimer from the Longformer docs. Checked with @patil-suraj.

## Before submitting
- [x] This PR fixes a typo or improves the docs (you can dismiss the other checks if that's the case).

## Who can review?
Documentation: @sgugger
CC: @patil-suraj 

Comments:
_The documentation is not available anymore as the PR was closed or merged._
Add argument "cache_dir" for transformers.onnx
Author: happyXia
Pull request: yes

# What does this PR do?


Add argument "cache_dir" for transformer.onnx ,to enables the user to select the cache path when exporting large ONNX model. Because the default cache directory may run out of space.


<!-- 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:
_The documentation is not available anymore as the PR was closed or merged._

Looking at the CI, it seems you need to format your files @happyXia - can you please run:

```
make style && make quality
```

and commit / push the formatted files?

> Looking at the CI, it seems you need to format your files @happyXia - can you please run:
> 
> ```
> make style && make quality
> ```
> 
> and commit / push the formatted files?

Sure, I have reformated and pushed the flawed files.


I checked that the slow tests pass with

```
RUN_SLOW=1 python -m pytest -x tests/onnx/test_onnx_v2.py
```

so this all looks good to me - merging now. Thank you @happyXia 🚀 !
Why is my train_samples_per_second graph growing?
Author: wickedsprout
Pull request: no

I'm training T5 so I'll tag @patrickvonplaten in the off chance it's something specific and not an obvious thing I'm missing.

Why is my train_samples_per_second graph linearly growing? I didn't set an increasing batch size, so it should be constant, right?

<img width="365" alt="image" src="https://user-images.githubusercontent.com/31738272/153556974-46775320-cadb-4327-8ac0-31a3ab231026.png">



Comments:
Hey @drunkinlove, 

Could you specify which training you used exactly? Do you use the official HF Trainer : https://huggingface.co/docs/transformers/v4.16.2/en/main_classes/trainer#transformers.Trainer? 

@patrickvonplaten Hi! I did indeed, here are the arguments I specified:

- output_dir="checkpoints",
- logging_dir="logs",
- logging_strategy="steps",
- logging_steps=100,
- per_device_train_batch_size=4,
- num_train_epochs=100,
- max_steps=10000,
- warmup_steps=5000,
- weight_decay=0.01,
- evaluation_strategy="steps",
- save_strategy="steps",
- eval_steps=5000,
- save_steps=5000,
- save_total_limit=100,
- fp16=False,
- gradient_accumulation_steps=1

Am I even reading this graph correctly? It's supposed to be 'amount of training samples seen per second' vs 'total seconds passed', right? It looks really suspicious, I'm considering logging the time after each step myself to make my own graph.

Hey @drunkinlove,

I looked a bit into it. This graph should actually not show a line really but just a single scalar value for a single training run. If you look into this code line: https://github.com/huggingface/transformers/blob/b87c044c79a408c0a1e7f7b046b5b4ce999c2d0e/src/transformers/trainer.py#L1546,

you can see that the `train_samples_per_second` metric is computed only once during training (after the training is finished) and the tensorboard should only show a single scalar as it is done here: https://huggingface.co/patrickvonplaten/xls-r-300m-sv-cv8/tensorboard 

So, I don't really understand how it is possible that you see a linear graph there. Do you have a link to your repo on the Hub? 

The metric `train_samples_per_second` literally just says "How many training samples were treated per second" so it's a very easy formula: `number of all training samples` / `total time of training`

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.
GPT2 TensorFlow Type Hints
Author: cakiki
Pull request: yes

# What does this PR do?
Add type hints to the TF GPT2 model

Also remove two unused imports that were breaking `make fixup`

<!-- Remove if not applicable -->
Addresses  https://github.com/huggingface/transformers/issues/16059


## 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?
- [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.
- [ ] Did you make sure to update the documentation with your changes? 
- [ ] Did you write any new necessary tests?


## Who can review?

@Rocketknight1 @gante 


Comments:
Potential issues (not very sure about those): 
- Pytorch GPT2 has a `GPT2ForTokenClassification` class with no equivalent in the TF version.
-  TF GPT2 uses `past` for the parameter that other models (e.g. pytorch gpt2 and tf roberta) call `past_key_values`

_The documentation is not available anymore as the PR was closed or merged._
Fix Marian conversion script
Author: patil-suraj
Pull request: yes

# What does this PR do?

Fixes the `Marian` conversion script to use the correct value for `activation_function` and also 
set `tied-embeddings=True` when  `tied-embeddings-all=True`

cc @tiedemann

Comments:
Trust you on this :-) 

_The documentation is not available anymore as the PR was closed or merged._
[SegFormer] Remove unused attributes
Author: NielsRogge
Pull request: yes

# What does this PR do?

This PR removes the unused attributes `image_size` and `downsampling_rates` from the configuration. As they simply aren't used by the model, this is not a breaking change.

It also adds a link to the blog post in SegFormer's docs, and clarifies that the model works on any input size as it pads the input.

It also improves the overall readability of `modeling_segformer.py`.

Comments:
_The documentation is not available anymore as the PR was closed or merged._
apply_rotary_pos_emb gives different results between PT & Flax
Author: ydshieh
Pull request: no

## Environment info
- `transformers` version: 4.18.0.dev0
- Platform: Linux-5.13.0-1019-gcp-x86_64-with-glibc2.31
- Python version: 3.9.7
- Huggingface_hub version: 0.4.0
- PyTorch version (GPU?): 1.10.2+cu102 (False)
- Tensorflow version (GPU?): 2.7.0 (False)
- Flax version (CPU?/GPU?/TPU?): 0.4.0 (cpu)
- Jax version: 0.3.1
- JaxLib version: 0.3.0
- Using GPU in script?: <fill in>
- Using distributed or parallel set-up in script?: <fill in>

### Who can help
- Flax + GPT-J,: @patil-suraj
(I could try to help after finalizing some other PRs if you are busy)

## Description

The method `apply_rotary_pos_emb` in `modeling_gptj.py` and `modeling_flax_gptj.py` give different results while having the same inputs. See the next section.

While working on the #16280, this difference cause the more aggressive PT/Flax equivalence test failing with `1e-5`.
(This was not detected in #15841 because `FlaxGPTJModelTest` overwrite the equivalence test, which wasn't updated at that time.)

## To reproduce

```python
from transformers.models.gptj.modeling_gptj import apply_rotary_pos_emb as apply_rotary_pos_emb_pt
from transformers.models.gptj.modeling_flax_gptj import apply_rotary_pos_emb as apply_rotary_pos_emb_flax

import numpy as np
import torch

batch_size = 1
seq_len = 3
num_heads = 2
rotary_dim = 4

k_rot = np.ones(shape=(batch_size, seq_len, num_heads, rotary_dim), dtype=np.float32)

sin = np.array([[ 0.        ,  0.        ],
       [ 0.84147096,  0.00999983],
       [ 0.9092974 ,  0.01999867],
       [ 0.14112   ,  0.0299955 ],
       [-0.7568025 ,  0.03998933],
       [-0.9589243 ,  0.04997917],
       [-0.2794155 ,  0.059964  ]], dtype=np.float32)

cos = np.array([[ 1.        ,  1.        ],
       [ 0.54030234,  0.99995   ],
       [-0.41614684,  0.9998    ],
       [-0.9899925 ,  0.99955004],
       [-0.6536436 ,  0.9992001 ],
       [ 0.2836622 ,  0.99875027],
       [ 0.96017027,  0.99820054]], dtype=np.float32)

sin = sin[:seq_len]
cos = cos[:seq_len]

pt_output = apply_rotary_pos_emb_pt(torch.FloatTensor(k_rot), sincos=(torch.FloatTensor(sin), torch.FloatTensor(cos)))
flax_output = apply_rotary_pos_emb_flax(k_rot, sincos=(sin.reshape((batch_size, seq_len, 2)), cos.reshape((batch_size, seq_len, 2))))

pt_output = pt_output.numpy()
flax_output = np.array(flax_output)

max_diff = np.amax(np.abs(pt_output - flax_output))
print(max_diff)
```

gives

```
1.8185948
```

The expected outputs (`max_diff`) should be small, like < `1e-5`.






Comments:
Thanks for reporting this, looking into it.
[FlaxGPTJ] Fix bug in rotary embeddings
Author: patil-suraj
Pull request: yes

# What does this PR do?

The rotary embeddings in `FlaxGPTJ` are computed in-correctly and they don't match with the PT version. This PR fixes  `rotate_every_two` function to match with PT version.

Thanks a lot @ydshieh for finding this issue!

Fixes #16288

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

> Shouldn't the slow test have failed here?

The difference(s) - for hidden states - I got are in the range like of `1e-2`. Not sure if this will affect the outputs of slow test.
I can run the slow tests to see what happen internally.

> > Shouldn't the slow test have failed here?
> 
> The difference(s) - for hidden states - I got are in the range like of `1e-2`. Not sure if this will affect the outputs of slow test. I can run the slow tests to see what happen internally.

Yes, the diff for the output was surprisingly small and didn't affect generation when I last tested.