noamaanMulla-03/transformers-issues huggingface dataset:
Rename variables with unclear naming
Author: qqaatw
Pull request: yes

# What does this PR do? 

This is a followup PR of  #14085.

Edited: I use `remove_prefix_from_model` instead of  `remove_prefix_from_init_model` to match other variables' naming convention.

## 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.

@sgugger @patrickvonplaten 

<!-- 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:
Update TP parallel GEMM image
Author: hyunwoongko
Pull request: yes

I added column parallel and row parallel image

![parallelism-tp-parallel_gemm](https://user-images.githubusercontent.com/38183241/138383838-e9037796-4b73-42dd-918d-e0c42813e2dd.png)

## reviewers
@stas00 

Comments:
this image is wrong.
don't merge now.
I'll update image and explanation.

<img width="812" alt="parallelism-tp-parallel_gemm" src="https://user-images.githubusercontent.com/38183241/138397848-0d73658d-3fda-4a95-b7f2-1f5e232d4e47.png">


I updated image ! Can you merge this? @stas00

Thank you for making the improvements, @hyunwoongko!
Log metrics during training
Author: jmeier-absci
Pull request: no

# 🚀 Feature request

HF Transformers supports custom metrics at evaluation, but not during training. Many metrics are trivial / fast to collect during training time, so it would be nice to collect them too (e.g. BERT accuracy).  

## Motivation

Collecting these metrics during training helps answer a number of research questions including overfitting, model performance, etc. Integration at this level can also pave the way toward collecting sequence-level information that can be logged using tools like W&B Tables.

## Your contribution

I'm happy to submit a PR. Starting this conversation early to see if there is interest in this feature / understand if there's a reason why this isn't already supported in HF.


Comments:
I am not sure what you are saying. Metrics are computed during training at each evaluation step/epoch, depending on the strategy you picked.

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.
Masked word prediction in new language with mBERT/XLM
Author: Remorax
Pull request: no

Hello,

Is there a way to easily predict a masked word in a new language (a language other than the source language) using multilingual models like BERT/XLM/XLM-R?

Ideally, if my masked sentence is:

`My [MASK] is Vivek`

Given a target language, say French, I would want the output for [MASK] to be:

`nom` (`name` in French) 

Is it possible to somehow exploit cross-lingual representations for this purpose?

Comments:
Hello, thanks for opening an issue! We try to keep the github issues for bugs/feature requests.
Could you ask your question on the [forum](https://discuss.huggingface.co) instead?

Thanks!

Hello,

Apologies! I did try to create it on the forum, but unfortunately I don't see any option to "Create Topic", or even reply to posts. I am unsure what the issue is, since I have earned the "Basic" badge and as per my understanding, should be allowed to create topics.

Can you please help me out with this - how should I go about creating topics on the Forum?

Thanks a lot in advance!

If you have earned the "Basic" badge, you should see a "+ New Topic" button on the home page, on the left directly under the blue banner.

I'm sorry, I don't see any blue banner or "add new topic" button. This is the website as it is visible to me:

<img width="1325" alt="Screenshot 2021-08-16 at 3 21 40 PM" src="https://user-images.githubusercontent.com/26062692/129578973-ccf35f37-dfa7-4a14-9ffc-f2e00f109a28.png">

I have earned the Basic badge, though:

<img width="1217" alt="Screenshot 2021-08-16 at 3 23 52 PM" src="https://user-images.githubusercontent.com/26062692/129579180-ae63cc0a-1bb1-487b-8711-6b05d8436ce3.png">

I feel like I am missing something really obvious here, but not sure what. I have used other forums quite a lot previously and am familiar with the typical interface, but I can't find the create topic button though I have looked everywhere. 

What's also interesting is that originally, when I didn't have the "Basic" badge and had just created the account, I _could_ see the create topic button. It didn't allow me to post, of course, and gave me an error message saying I didn't have the permissions to do so. Later, when I acquired the Basic badge by reading some topics **on another tab**, I went back to the same tab from earlier and tried re-clicking on "Create topic". It then gave me a different error message, something like "View not allowed". Really strange, but thought it might be worth mentioning. And when I refreshed the page, sure enough, the Create Topic button had disappeared.

Maybe @Pierrci will have an idea.

Sorry for the late reply, @Remorax you had been wrongly "slienced" by the system, which was preventing you from creating new topics - should be fixed 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.
supporting t5 for question answering
Author: dorooddorood606
Pull request: no

# 🚀 Feature request

Hi, this would be great and appreciated to support t5 model for run_qa.py script, currently this does not support it.

## Motivation

T5 is the state of the art model, for which there are a lot of motivation for people in NLP community to use this model, specially it can handle multiple datasets.


## Your contribution

<!-- Is there any way that you could help, e.g. by submitting a PR?
     Make sure to read the CONTRIBUTING.MD readme:
     https://github.com/huggingface/transformers/blob/master/CONTRIBUTING.md -->


Comments:
Hey @dorooddorood606, 

Since T5 is essentially a text-to-text model, the question-answering task can simply be framed as a seq2seq task. 

I think we could add a `run_qa_seq2seq.py` to https://github.com/huggingface/transformers/tree/master/examples/pytorch/question-answering that is very similar to https://github.com/huggingface/transformers/blob/master/examples/pytorch/summarization/run_summarization.py (we would just need to adapt the dataset to choose from I think). Would you be interested in adding such an example? 

Also pinging @sgugger here to hear his opinion :-)

We could definitely add this kind of example. We just need a proper dataset, as you mentioned.

Dear @sgugger @patrickvonplaten 
Thank you very much for considering my request.

In T5 codebase, for superglue-record, they convert each example to multiple ones for each answer choice [1]. During evaluation though they consider all answer choices. I assume this is the case with most of the QA datasets. In T5 script, since we need seq2seq format, I am not sure how I can handle keeping a set of answers.

thank you very much for your comment in advance.

[1] https://github.com/google-research/text-to-text-transfer-transformer/blob/3c58859b8fe72c2dbca6a43bc775aa510ba7e706/t5/data/preprocessors.py#L918

Cool! @dorooddorood606 would you like to give it a try to make a `run_qa_seq2seq.py` example for SUPERGLUE? Happy to guide you through it :-)

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, currently wip at #13432 

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.
Adding license file to some of the fine-tuned models 
Author: sasaadi
Pull request: no

Hi,

Some of the fine-tuned models for zero-shot classification are not listed with license file. More specifically, I am interested in using the "[Sahajtomar/German_Zeroshot](https://huggingface.co/Sahajtomar/German_Zeroshot)" model, which doesn't provide any license.

So, would it be possible to add a license file with details to this model?

Thanks

Comments:
Pinging @Sahajtomar here :)

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 get 8 hidden layer in bertonnx
Author: vigneshmj1997
Pull request: no

Hi i am using Bertonnx for inference how to get 8th hidden layer ouput  from Bertonnx output 
thankyou in advance

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.
Input to a Tensorflow model where a dictionary cannot be used
Author: old-school-kid
Pull request: no

Made a Tensorflow fuctional API model on top of  TFAutoModelForSequenceClassification with 3 sentence as input. 

Training model directly on tokenized input raises
**ValueError: Failed to find data adapter that can handle input: (<class 'list'> containing values of types {'(<class \'list\'> containing values of types {"<class \'tensorflow.python.framework.ops.EagerTensor\'>"})'}), (<class 'list'> containing values of types {"<class 'int'>"})**

If I convert it into numpy array it raises 
**ValueError: Data cardinality is ambiguous:**

`model(X_train[0])`  prduces the desired result in both cases but on training the model it raises errors.


Code can be found in this [notebook](https://colab.research.google.com/drive/1wsVVHiaqBF8joIEsP_XSMF35fnDQS19D?usp=sharing)

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.

Maybe of interest to @Rocketknight1 

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.
is there any <SOS> or <EOS> token in reformer-enwik8?
Author: xichenpan
Pull request: no

## Environment info
None

### Who can help
@patrickvonplaten 

Models:
reformer-enwik8

## Information

Model I am using reformer-enwik8:

The problem arises when using:

```
def encode(list_of_strings, pad_token_id=0):
    max_length = max([len(string) for string in list_of_strings])

    # create emtpy tensors
    attention_masks = torch.zeros((len(list_of_strings), max_length), dtype=torch.long)
    input_ids = torch.full((len(list_of_strings), max_length), pad_token_id, dtype=torch.long)

    for idx, string in enumerate(list_of_strings):
        # make sure string is in byte format
        if not isinstance(string, bytes):
            string = str.encode(string)

        input_ids[idx, :len(string)] = torch.tensor([x + 2 for x in string])
        attention_masks[idx, :len(string)] = 1

    return input_ids, attention_masks
model = ReformerModelWithLMHead.from_pretrained("google/reformer-enwik8")
ids, masks = encode(["I COULD LABEL THIS ON THE INGREDIENTS AS MEAT".capitalize()])
logits = model(input_ids=ids, attention_mask=masks)["logits"]
```

The tasks I am working on is:
try to get LM prob of one certain sequence

## Expected behavior
I expect 0 and 1 represent `<SOS>` and `<EOS>` respectively, but I don't know if it is correct

Comments:
I think `reformer-enwik8` was not trained using a `<SOS> or <EOS>` token - it's just the model to evaluate Reformer's compression capabilities on enwik8, see paper: https://arxiv.org/abs/2001.04451

> I think `reformer-enwik8` was not trained using a or token - it's just the model to evaluate Reformer's compression capabilities on enwik8, see paper: https://arxiv.org/abs/2001.04451

Thanks a lot for the quick reply.
btw, is there any other pretrained character-level language model provide by huggingface now?

To add a related question: Is there any way of knowing which characters are part of the vocabulary of the pre-trained enwik-8 model? To my knowledge there only exists information on the `vocab_size` which is set to 258, but no information on which characters are part of the vocabulary of the pre-trained model.

Reformer simple uses Python's `chr()` and `ord()` methods to tokenize and decode. See: https://huggingface.co/google/reformer-enwik8#reformer-language-model-on-character-level-and-trained-on-enwik8 

This is true. But those methods work with the Unicode character set (i.e. up to 1,114,111) which does not correspond to a `vocab_size` of 258. This can also be seen with the shape of `outputs.scores` which is (1, 258). It seems to me that the vocab_size is just the first 258 characters of the unicode standard, i.e. Basic Latin & Latin-1 Supplement. 

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.
Replace asserts with exceptions
Author: gofixyourself
Pull request: yes

Hi! I replaced asserts in the following files related to #12789 issue:

- src/transformers/trainer_pt_utils.py
- tests/test_feature_extraction_detr.py
- tests/test_feature_extraction_clip.py
- tests/test_feature_extraction_common.py
- tests/test_trainer_seq2seq.py

## 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? 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.

@sgugger Please review

Comments:
How to change type_vocab_size?
Author: leisurehippo
Pull request: no

tensorflow==2.3.1

transformers==4.2.1

My code is as follow:
```
transformer = TFAutoModel.from_pretrained('hfl/chinese-roberta-wwm-ext', from_pt=False, type_vocab_size=3)
```
I got error:
```
ValueError: cannot reshape array of size 1536 into shape (3,768)
```

Comments:
The embedding layer of the exisiting pretrained model you are loading has shape (2, 768). If you specify another shape, like (3, 768), then it cannot reshape the existing embedding layer to the new shape you are asking.

You can however circumvent this using the new `ignore_mismatched_sizes` argument:

```
from transformers import TFAutoModel

transformer = TFAutoModel.from_pretrained('hfl/chinese-roberta-wwm-ext', from_pt=False, type_vocab_size=3,
                                          ignore_mismatched_sizes=True)
```

This will print the following warning:

```
All model checkpoint layers were used when initializing TFBertModel.

Some weights of TFBertModel were not initialized from the model checkpoint at hfl/chinese-roberta-wwm-ext and are newly initialized because the shapes did not match:
- bert/embeddings/token_type_embeddings/embeddings:0: found shape (2, 768) in the checkpoint and (3, 768) in the model instantiated
You should probably TRAIN this model on a down-stream task to be able to use it for predictions and inference.
```

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.
Why we use truncated normal initializer instead of the default glorot_uniform in the tfbert?
Author: hscspring
Pull request: no

I'm confused for the initializer in the bert implementation, each Dense uses a `truncated normal initializer` with std=0.02. 
Why bert do that, is there any explaination?

a piece of code exmaple:

```python
 self.query = tf.keras.layers.Dense(
            units=self.all_head_size, kernel_initializer=get_initializer(config.initializer_range), name="query"
        )
        self.key = tf.keras.layers.Dense(
            units=self.all_head_size, kernel_initializer=get_initializer(config.initializer_range), name="key"
        )
        self.value = tf.keras.layers.Dense(
            units=self.all_head_size, kernel_initializer=get_initializer(config.initializer_range), name="value"
        )

def get_initializer(initializer_range: float = 0.02) -> tf.initializers.TruncatedNormal:
    """
    Creates a :obj:`tf.initializers.TruncatedNormal` with the given range.
    Args:
        initializer_range (`float`, defaults to 0.02): Standard deviation of the initializer range.
    Returns:
        :obj:`tf.initializers.TruncatedNormal`: The truncated normal initializer.
    """
    return tf.keras.initializers.TruncatedNormal(stddev=initializer_range)

```

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.
AttributeError: 'BertTokenizer' object has no attribute 'encode_plus'
Author: vaidyaprasad84
Pull request: no

Hello, 

I installed and unistalled pytorch_pretrained_bert package couple of time via pip install and than by .whl files. But its always giving me this error. 

Thanks

Comments:
Hello! You should install `transformers`, not `pytorch_pretrained_bert`
Keyword errors on tokenizer.encode_plus
Author: tchang1997
Pull request: no

# 🐛 Bug

## Information

Model I am using (Bert, XLNet ...): BertTokenizer

Language I am using the model on (English, Chinese ...): English (`bert-base-uncased`)

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:

Code:
```
tokenizer = BERTTokenizer.from_pretrained('bert-base-uncased')`
result = tokenizer.encode_plus("This is an example sentence", add_special_tokens=True, 
max_length=64, pad_to_max_length=True, return_attention_masks=True, return_tensors='pt'
```

Result:
```
Traceback (most recent call last): 
File "<stdin>", line 1, in <module>
File ".../python3.8/site-packages/transformers/tokenization_utils.py", line 786, in encode_plus
        first_ids = get_input_ids(text)
File ".../python3.8/site-packages/transformers/tokenization_utils.py", line 778, in get_input_ids
        return self.convert_tokens_to_ids(self.tokenize(text, **kwargs))
File ".../python3.8/site-packages/transformers/tokenization_utils.py", line 649, in tokenize                                     
        tokenized_text = split_on_tokens(added_tokens, text)
File ".../python3.8/site-packages/transformers/tokenization_utils.py", line 644, in split_on_tokens             
        return sum((self._tokenize(token, **kwargs) if token not \ 
File ".../python3.8/site-packages/transformers/tokenization_utils.py", line 644, in <genexpr>                  
        return sum((self._tokenize(token, **kwargs) if token not \ 
TypeError: _tokenize() got an unexpected keyword argument 'pad_to_max_length'   
```

A similar issue occurs if I remove the `pad_to_max_length` keyword; then `return_attention_masks` is the unexpected keyword.

## Expected behavior

Expected: the function returns without error a dict with the attention masks, padded sequence, and some other info, as specified by the documentation.

## Environment info

- `transformers` version: 2.1.1
- Platform: WSL 2, Ubuntu 18.04.4 LTS
- Python version: 3.8
- PyTorch version (GPU?): 1.4.0
- Tensorflow version (GPU?): N/A
- Using GPU in script?: no
- Using distributed or parallel set-up in script?: no


Comments:
@tchainzzz  Can you tell how you resolved the particular issue?