noamaanMulla-03/transformers-issues huggingface dataset:
[TAPAS] Tiny fix
Author: NielsRogge
Pull request: yes

# What does this PR do?

This PR includes a finy fix for TAPAS. Namely, when `config.select_one_column` is set to `False`, the model should not recompute the token logits. 

Relevant to #13393

Comments:
Can you include a test to ensure the behavior doesn't happen in the future?

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.
Speeding up the models inference by OpenVINO through accurate quantization via NNCF
Author: kshpv
Pull request: no

# 🚀 Feature request

Add quantization support via [NNCF ](https://github.com/openvinotoolkit/nncf) for fast inference on OpenVINO

## Motivation

Using NNCF can speed up models up to 4x by INT8 quantization. Look at the results [here](https://github.com/openvinotoolkit/nncf#nlp-huggingface-transformers-powered-models)

## Your contribution

NNCF team already created a patch for your repo that enables this feature. Please, take a look at https://github.com/openvinotoolkit/nncf/tree/develop/third_party_integration/huggingface_transformers


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.
Make the "Can't load <file> for <model_name>" error more user-friendly
Author: anton-l
Pull request: yes

# What does this PR do?

This makes the "wrong path" error more explicit and adaptive to avoid issues like https://github.com/huggingface/transformers/issues/14479 where the error message didn't specify that tokenizer files were not in the model repo in the first place.

- [ ] TODO: rewrite the errors for all modules in the same way (feature extractor, model weights,...)


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.
Longformer slower than Roberta
Author: duvi86
Pull request: no

Hi, It seems I have a similar issue than (https://github.com/huggingface/transformers/issues/8725). However, the time difference between Longformer and Roberta is nearly a factor 10. Does it seem normal (sequences are in the 0-100 length for this first test but will go beyond 512 in practice)? After checking it is in the longformer.encoder step that this is quite slow. Here is the config I use (I have similar factor whatever the config):
LongFormer_TOY_MODEL_HPARAMS = {
"vocab_size": len(LongFormer_VOCAB),
"hidden_size": 64,
"num_hidden_layers": 3,
"num_attention_heads": 8,
"intermediate_size": 32,
"hidden_act": "gelu",
"hidden_dropout_prob": 0.1,
"attention_probs_dropout_prob": 0.1,
"max_position_embeddings": 512
+ 2, # tokenizer's model_max_length + 2 ( / tokens of sequence)
"initializer_range": 0.02,
"layer_norm_eps": 1e-12,
"attention_window": 512
}

Thanks!

Comments:
cc @patrickvonplaten 

Hey @duvi86,

Could you please provide a reproducible code snippet that shows the time difference between RoBERTa and Longformer?
Thank you

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.
How to define the self-attention layer with transformers
Author: yingweima2022
Pull request: no

I want to use 'BertLayer'or 'RobertaLayer' to define a self-attention layer,but I can't find the definition of 'RobertaLayer'.Can you provide some relevant documents?Is this API cancelled? Thanks！

“”“
self.basicblocks = nn.ModuleList()
        self.n_layers = 3
        trans_heads = 8
        trans_drop = 0.1
        bert_config = BertConfig(hidden_size=self.config.hidden_size, num_attention_heads=trans_heads, attention_probs_dropout_prob=trans_drop)
        for layer in range(self.n_layers):
            self.basicblocks.append(BertLayer(bert_config))
”“”

Comments:
Hey @193769981, `BertLayer` is defined here:

https://github.com/huggingface/transformers/blob/e68c3756fea7c811d02b8470539ae17ec3ec0e71/src/transformers/models/bert/modeling_bert.py#L445

`RobertaLayer` is a copy of `BertLayer`, so the two should be identical. 

https://github.com/huggingface/transformers/blob/e68c3756fea7c811d02b8470539ae17ec3ec0e71/src/transformers/models/roberta/modeling_roberta.py#L385

Hello, I have solved this problem.
I want to know what form the attention_mask should be when I use Roberta_Layer, and what values the <pad> and non-pad should be set.
![image](https://user-images.githubusercontent.com/44664739/147881376-3fb8a558-6030-4dbd-8f46-e0178ad91222.png)


HF has a [glossary](https://huggingface.co/docs/transformers/glossary/) that provides explanations and examples of terms like `attention_mask`. I hope this helps!

On a secondary note, I recommend that you check out the [HF discussion forum](https://discuss.huggingface.co), which is more suitable for asking questions. The GitHub issue page is dedicated to bug reports, feature requests, etc.
update deprecating `transformers-cli` to `huggingface-cli` in docs
Author: fcakyon
Pull request: yes


Comments:
looks good to me!

Thanks @fcakyon!

This page seriously needs an update, and I believe some methods here don't exist in `huggingface-cli` ...

We should probably just link to the following: https://huggingface.co/docs/hub/adding-a-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.

let's merge this and we'll refine later? (but the doc format changed on the main branch in the meantime :) )

@julien-c revised version of the docs fixed this issue i believe 👍 

cool, closing this then. Thanks! 🙏
Can’t load config for ‘/data/sentence-transformers_all-mpnet-base-v2’
Author: RohanBS
Pull request: no

Hi,

I am trying to use the Accelerated Inference API and am facing this issue while using multiple sentence-transformer models. This happens when I use any input other than the auto-filled one.

![Issue](https://user-images.githubusercontent.com/24825646/144041847-8876f029-8762-41ef-9bcd-9c43fac282d5.png)

@patil-suraj @patrickvonplaten @LysandreJik 


Comments:
cc @nreimers @osanseviero 

This should be fixed now, it was a data corruption issue cc @Narsil 

@osanseviero @Narsil Still facing this issue.

<img width="1685" alt="Screenshot 2021-12-01 at 9 47 09 AM" src="https://user-images.githubusercontent.com/24825646/144170950-f58f8496-e551-4534-9fa1-82c5b8f1107b.png">


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.

@RohanBS sorry for the delay. The data corruption issue was fixed but the results are cached so that would explain why you were still seeing the error. I just tried this query and it seems to be working fine.
Is the attention_mask in BertSelfAttention applied correctly?
Author: avolny
Pull request: no

https://github.com/huggingface/transformers/blob/69511cdcaec8c1c7f0d7f378964eca0ce74ed5a8/src/transformers/models/bert/modeling_bert.py#L325-L327

Relevant Models:
- BERT: @LysandreJik 

I was just working on adjusting Bert to my custom architecture, and when editing the BertSelfAttention module, I have noticed a very strange couple of lines (see the linked code). Shouldn't the masking be applied multiplicatively instead of additively? :thinking: 

I'm happy to be proven wrong and learn a new thing, but it seemed worth bringing up.

Comments:
These issues may be of help: https://github.com/huggingface/transformers/issues/13555 https://github.com/huggingface/transformers/issues/542

Apparently it would still help quite a bit to have comments explaining what's happening - would you like to try your hand at it?

Oooh, yeah, didn't realize it was right before softmax, I had to solve this issue before...

I found the code that converts the binary mask into the log-scale mask as well.

Sure, I will update it and post a pr during the weekend. :)

hmm this piece of code is also present in multiple models I'm sure, all of the models using masked attention could use documenting, correct? @LysandreJik 

Yes, if you could add 1-2 lines of doc to the models concerned, that would be of great help! Thanks, @avolny!

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.
Issue with Jiva/xlm-roberta-large-it-mnli
Author: fbottazzoli
Pull request: no

When running the below piece of code:

`from transformers import pipeline
classifier = pipeline("zero-shot-classification",
                      model="Jiva/xlm-roberta-large-it-mnli", device=0, use_fast=True, multi_label=True)`

the following error occurs:

```
OSError: Can't load config for 'Jiva/xlm-roberta-large-it-mnli'. Make sure that:

- 'Jiva/xlm-roberta-large-it-mnli' is a correct model identifier listed on 'https://huggingface.co/models'

- or 'Jiva/xlm-roberta-large-it-mnli' is the correct path to a directory containing a config.json file
```

Any idea how to fix this issue?
Thank you in advance
Francesca 

Comments:
i was able to fix this issue by installing the correct version
Add Flax RoFormer
Author: stancld
Pull request: yes

# What does this PR do?

This PR adds the flax implementation of `RoFormer` model.

Fixes #14605 


## Before submitting
- [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?

@patrickvonplaten @patil-suraj 


Comments:
Waiting for the CI to be green and then we can merge

Merging - thanks a lot for adding this model @stancld !
[Flax] Add Flax implementation of `RoFormer`
Author: stancld
Pull request: no

# 🚀 Feature request

Add Flax implementation of `RoFormer` models.

## Motivation

Improve the level of Flax/Jax support.

## Your contribution

I'll be glad to work on this :] 

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.

active #15005
AutoTokenizer unable to load pre-trained bert-base-uncased tokenizer
Author: kanishkamisra
Pull request: no

Hello! I am running the following code to load the bert-base-uncased tokenizer:

```py
from transformers import AutoTokenizer

tokenizer = AutoTokenizer.from_pretrained('bert-base-uncased')
```
which results in the following error:

```
---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
<ipython-input-6-ff60bf5b2785> in <module>
----> 1 tokenizer = AutoTokenizer.from_pretrained('bert-base-uncased')

~/opt/miniconda3/lib/python3.8/site-packages/transformers/models/auto/tokenization_auto.py in from_pretrained(cls, pretrained_model_name_or_path, *inputs, **kwargs)
    548             tokenizer_class_py, tokenizer_class_fast = TOKENIZER_MAPPING[type(config)]
    549             if tokenizer_class_fast and (use_fast or tokenizer_class_py is None):
--> 550                 return tokenizer_class_fast.from_pretrained(pretrained_model_name_or_path, *inputs, **kwargs)
    551             else:
    552                 if tokenizer_class_py is not None:

~/opt/miniconda3/lib/python3.8/site-packages/transformers/tokenization_utils_base.py in from_pretrained(cls, pretrained_model_name_or_path, *init_inputs, **kwargs)
   1639         if os.path.isfile(pretrained_model_name_or_path) or is_remote_url(pretrained_model_name_or_path):
   1640             if len(cls.vocab_files_names) > 1:
-> 1641                 raise ValueError(
   1642                     f"Calling {cls.__name__}.from_pretrained() with the path to a single file or url is not "
   1643                     "supported for this tokenizer. Use a model identifier or the path to a directory instead."

ValueError: Calling BertTokenizerFast.from_pretrained() with the path to a single file or url is not supported for this tokenizer. Use a model identifier or the path to a directory instead.
```

The same error does not occur when I use `bert-large-uncased` or any other model, which is very weird!

System/Package Spec:

```
OS: macOS Big Sur
transformers: 4.15.0
torch: 1.10.0 (cpu)
python: 3.8.3
```


Comments:
do you have a folder named `bert-large-uncased` where you're running this code?

OMG! I just realized there's a file I downloaded long ago in this directory that's named `bert-base-uncased` wow is this embarrassing!
TAPAS tokenizer is unable to handle indexed dataframes
Author: xhluca
Pull request: no

Running the following code will result in a `iloc` error:

```python
from transformers import TapasTokenizer
import pandas as pd

model_name = 'google/tapas-base'
tokenizer = TapasTokenizer.from_pretrained(model_name)

data = {'Actors': ["Brad Pitt", "Leonardo Di Caprio", "George Clooney"], 'Number of movies': ["87", "53", "69"]}
queries = ["What is the name of the first actor?", "How many movies has George Clooney played in?", "What is the total number of movies?"]
answer_coordinates = [[(0, 0)], [(2, 1)], [(0, 1), (1, 1), (2, 1)]]
answer_text = [["Brad Pitt"], ["69"], ["209"]]
table = pd.DataFrame.from_dict(data)

# Let's add random years - this will break the tokenzier
table.index = [2000, 2010, 2020]

inputs = tokenizer(table=table, queries=queries, answer_coordinates=answer_coordinates, answer_text=answer_text, padding='max_length', return_tensors='pt')
inputs
```

Comments:
Hi,

This has been reported before in #10265. Would you mind opening a PR to fix this?

@NielsRogge I started a PR here: https://github.com/huggingface/transformers/pull/14549

I'm not sure if it totally solves the problem, but it's a start

@NielsRogge I'm looking about at this comment right now:

> Here's a notebook illustrating the issue, and fixing it:
> 
> https://colab.research.google.com/drive/10MbZiMKyEWUGk2Y1fvIj0Y0_lB42NO38?usp=sharing
> 
> The reason why you're getting the error is because in the part where each cell of the table is replaced by a Cell object:
> 
> https://github.com/huggingface/transformers/blob/97e688bc220514cd5ea072f06b186401c9cfbbd0/src/transformers/models/tapas/tokenization_tapas.py#L2742-L2745
> , the row indices are used.
> 
> This can be fixed by replacing `table` with `table.reset_index(drop=True)` in the first line (or resetting the index of the table before providing it to the tokenizer). Another solution is to replace the final line by `table.iloc[row_index, col_index] = Cell(text=table.iloc[row_index, col_index])`. Will make a small PR to add this.
> 
> Thank you for spotting the error!


I'm wondering if there's any performance improvement in iterating this way through the dataframe over something like:

```python
df.applymap(lambda cell: Cell(text=cell))
```

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.

@NielsRogge has this been resolved?
[doc] Update parallelism.mdx
Author: hyunwoongko
Pull request: yes

- I found some mistakes and fixed them. sorry @stas00
- In addition, `DataParallel` and `DistributedDataParallel` are marked as code because they are class names. (I was trying to switch DataParallel to DataParallelism, but I realized that this means name of class)


## Reviewers
@stas00 

Comments:
updated.

@stas00 This can be merged !
Issue with `stas/tiny-wmt19-en-de` model
Author: tingofurro
Pull request: no

## Environment info

The environment in the Hosted inference API

### Who can help

@stas00

Models:

`stas/tiny-wmt19-en-de` (I assume the issue might be there with other language pairs)

## Information

I am unable to use the model to generate translations, it seems to be generating gibberish (see Screenshot attached).
I tried to use both on the Hosted API & on a local Python setup and get similar results.

## To reproduce

Steps to reproduce the behavior:

1. Open this link: https://huggingface.co/stas/tiny-wmt19-en-de?text=This+is+a+sentence+in+English.
2. Click Generate and the output should be strange.

# Screenshot

<img width="1316" alt="Screen Shot 2022-01-04 at 4 47 53 PM" src="https://user-images.githubusercontent.com/2609265/148128671-eb021720-efcb-4dd5-95a1-71f68717cf38.png">





Comments:
Hi, tingofurro

Have a look at what the model card says:

> This is a tiny model that is used in the transformers test suite. It doesn't do anything useful, other than testing that modeling_fsmt.py is functional.
> 
> Do not try to use it for anything that requires quality.

Thus closing this.


Oops! Thanks for the clarification.
AttributeError: 'Tensor' object has no attribute 'size'
Author: sainimohit23
Pull request: no
Labels: name: TensorFlow

This is the model that I have defined:

```
input_layer = keras.layers.Input(shape = (attention_mask.shape[1],), dtype='int64')
bert = DistilBertModel.from_pretrained("distilbert-base-cased")(input_layer)
bert = bert[0][:,0,:]              
# bert = keras.layers.Dense(units=10, activation='relu')(bert)
classifier = keras.layers.Dense(units=1, activation='sigmoid')(bert)
model = keras.models.Model(inputs=input_layer, outputs=classifier)
model.summary()
```

This is the error I am getting.
```
AttributeError                            Traceback (most recent call last)

<ipython-input-12-6d7e88036056> in <module>()
      1 input_layer = keras.layers.Input(shape = (attention_mask.shape[1],), dtype='int64')
----> 2 bert = DistilBertModel.from_pretrained("distilbert-base-cased")(input_layer)
      3 bert = bert[0][:,0,:]
      4 # bert = keras.layers.Dense(units=10, activation='relu')(bert)
      5 classifier = keras.layers.Dense(units=1, activation='sigmoid')(bert)

1 frames

/usr/local/lib/python3.6/dist-packages/transformers/modeling_distilbert.py in forward(self, input_ids, attention_mask, head_mask, inputs_embeds)
    449             raise ValueError("You cannot specify both input_ids and inputs_embeds at the same time")
    450         elif input_ids is not None:
--> 451             input_shape = input_ids.size()
    452         elif inputs_embeds is not None:
    453             input_shape = inputs_embeds.size()[:-1]

AttributeError: 'Tensor' object has no attribute 'size'
```

The same code works fine when distilbert is replaced with bert. What to do in this case.

Comments:
You are using TF. Did you mean to use `TFDistilBertModel` instead of `DistilBertModel`?

@BramVanroy got it. Thanks.

I wonder if it would be possible to know in advance whether a model supports TF or pyTorch, or both... and throw an exception accordingly?
[megatron convert] PYTHONPATH requirements
Author: stas00
Pull request: yes

This PR documents how to tell the megatron conversion scripts to find the `Megatron-LM` repo, which is needed for recent checkpoints as it was reported at https://github.com/huggingface/transformers/issues/14939

Since one can't install Megatron-LM as a package we can't make the script require it, so documenting it here and will also document in the model cards.

Fixes: https://github.com/huggingface/transformers/issues/14939

@LysandreJik 

----

@jdemouth already updated these:

- https://huggingface.co/nvidia/megatron-gpt2-345m/blob/main/README.md
- https://huggingface.co/nvidia/megatron-bert-uncased-345m/blob/main/README.md
- https://huggingface.co/nvidia/megatron-bert-cased-345m/blob/main/README.md

I need to figure out how to get perms to do so. 

Comments: