noamaanMulla-03/transformers-issues huggingface dataset:
Pegasus from Pytorch to tensorflow
Author: karimfayed
Pull request: no
Labels: name: Migration

I have fine-tuned PEGASUS model for abstractive  summarization using [this script](https://gist.github.com/jiahao87/50cec29725824da7ff6dd9314b53c4b3) which uses huggingface.
 The output model is in pytorch.

On huggingface [docs](https://huggingface.co/transformers/serialization.html) the following is supposed to do the required conversion:
`python convert_graph_to_onnx.py --framework <pt, tf> --model bert-base-cased bert-base-cased.onnx`
I use colab and I ran the following command to transform my pegasus model:
`!python convert_graph_to_onnx.py --framework <pt, tf> --model ./results/checkpoint-4000 ./results/checkpoint-4000.onnx`
I keep getting the following message which is confusing as  it is written in the documentation that the script convert_graph_to_onnx.py is at the root of the transformers sources:
![Screenshot (84)](https://user-images.githubusercontent.com/46823709/124824521-c2a82f80-df72-11eb-8406-128555604460.png)



**Thank you in advance.**

Comments:
You should update `<pt, tf>` to reflect the library you want to use to export the graph. Either `pt` or `tf`.

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 in terms of accuracy of onnx converted models of SQUAD based ROBERTA  on legal domain.
Author: kingafy
Pull request: no

Hi Team,

I was using the  hugging face utility from latest transformer version to convert a SQUAD based Roberta model  to ONNX. After conversion, I observed the accuracy has dipped significantly even though I never quantized the model. Any suggestions or advice what could have been the reason. Does the ONNX conversion results in loss in terms of predictions? If so, is there any parameter which can be experimented with to reduce and yet improve the run time performance.


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?

If you'd like us to investigate this as a bug, please provide additional information so that we may help; for example, the ID of a pretrained model on the hub that loses accuracy when being converted, the commands run, the environment, library version.

Thanks!

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.
Cached data not checked for integrity
Author: xloem
Pull request: no

### Who can help

@julien-c @sgugger 

## To reproduce

Steps to reproduce the behavior:

1. Mutate a cache file or cut the internet while downloading
2. Load the data e.g. via a pipeline
3. Either the incorrect data loads fine, or an unhelpful error is thrown

## Expected behavior

The files are hashed in git and delivered via https with the hash included.  It would be good for the cache system to verify this hash and report corruption to help the user, especially if a model fails to load.  It would be great if the hash system were a little integrated with git so that git signatures of the hashes could be checked some day.  Alternatively/additionally certificate pinning could be used in the library to help protect the user.

Users should be informed when using the library, that it does not authenticate the models when they are loaded, and that it is easy for a malicious party to alter them undetected.


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.
Slow gpt2 training on TPU with run_clm_flax.py
Author: miwojc
Pull request: no

## Environment info

- `transformers` version: 4.9.0.dev0
- Platform: Linux-5.4.0-1043-gcp-x86_64-with-glibc2.29
- Python version: 3.8.10
- PyTorch version (GPU?): 1.9.0+cpu (False)
- Tensorflow version (GPU?): 2.5.0 (False)
- Flax version (CPU?/GPU?/TPU?): 0.3.4 (cpu)
- Jax version: 0.2.16
- JaxLib version: 0.1.68
- Using GPU in script?: No
- Using distributed or parallel set-up in script?: No

### Who can help
- gpt2: @patrickvonplaten, @LysandreJik 

 -->

## Information

Model I am using (Bert, XLNet ...): gpt2

The problem arises when using:
* [X] the official example scripts: (give details below)
https://huggingface.co/flax-community/papuGaPT2/blob/main/run_clm_flax.py
with only small modification added print(jax.device_count()) in main() to see if TPU is being used.

The tasks I am working on is:
* [ ] an official GLUE/SQUaD task: (give the name)
* [X] my own task or dataset: (give details below)
Oscar, polish dataset 47GB:
--dataset_name="oscar" \
--dataset_config_name="unshuffled_deduplicated_pl" \

## To reproduce

Steps to reproduce the behavior:

1. login to remote VM:
```./google-cloud-sdk/bin/gcloud alpha compute tpus tpu-vm ssh dishcloth --zone us-central1-a --project hf-flax```
2. activate venv:
 source ~/papugapt2/bin/activate
3. run pretraining:
```
cd papuGaPT2
bash pretrain_model.sh
```

## Expected behavior

Expected to get training speed around 1s/it on this dataset (as this was speed achieved before updating to latest scripts from master)

But instead the speed is around 10-20s/it


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.
dtype
Author: tshi04
Pull request: no

## Environment info
<!-- You can run the command `transformers-cli env` and copy-and-paste its output below.
     Don't forget to fill out the missing fields in that output! -->

- `transformers` version:
- Platform:
- Python version:
- PyTorch version (GPU?):
- Tensorflow version (GPU?):
- Using GPU in script?:
- Using distributed or parallel set-up in script?:

### Who can help
<!-- Your issue 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: @Rocketknight1

Library:

- benchmarks: @patrickvonplaten
- deepspeed: @stas00
- ray/raytune: @richardliaw, @amogkam
- text generation: @patrickvonplaten
- tokenizers: @LysandreJik
- trainer: @sgugger
- pipelines: @LysandreJik

Documentation: @sgugger

Model hub:

- for issues with a model report at https://discuss.huggingface.co/ and tag the model's creator.

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

 -->

## Information

Model I am using (Bert, XLNet ...):

The problem arises when using:
* [ ] the official example scripts: (give details below)
* [ ] my own modified scripts: (give details below)

The tasks I am working on is:
* [ ] an official GLUE/SQUaD task: (give the name)
* [ ] my own task or dataset: (give details below)

## To reproduce

Steps to reproduce the behavior:

1.
2.
3.

<!-- If you have code snippets, error messages, stack traces please provide them here as well.
     Important! Use code tags to correctly format your code. See https://help.github.com/en/github/writing-on-github/creating-and-highlighting-code-blocks#syntax-highlighting
     Do not use screenshots, as they are hard to read and (more importantly) don't allow others to copy-and-paste your code.-->

## Expected behavior

<!-- A clear and concise description of what you would expect to happen. -->


Comments:
[Feature Processing Sequence] Remove duplicated code
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 removes redundant code which was overlooked in https://github.com/huggingface/transformers/pull/12804

Comments:
Flax Save/Load from base model with different name
Author: patrickvonplaten
Pull request: no

The following doesn't work correctly at the moment - loading a base model into a head from PyTorch model when the names are different. *E.g.*: 

```python
from transformers import RobertaModel, FlaxRobertaForMaskedLM, RobertaConfig

model = RobertaModel(RobertaConfig())
model.save_pretrained("./")

FlaxRobertaForMaskedLM.from_pretrained("./", from_pt=True)
```

=> Many weights are incorrectly loaded here. I know what the problem is, but it'll require ~1h to solve. Will take a look later today.

Comments:
cc @patil-suraj 

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 a Bert version of the OpenAIGPTLMHeadModel?
Author: logan-siyao-peng
Pull request: no

# 🚀 Feature request

I am trying to use the bert-base-chinese model to evaluate the fluency of Chinese texts. I noticed a sample code that uses openai-gpt for English that employes the class OpenAIGPTLMHeadModel. However, since only the bert-base-chinese model is available for Chinese, I am wondering whether there is an equivalence in BERT.

The sample code is attached below:
model = OpenAIGPTLMHeadModel.from_pretrained('openai-gpt',cache_dir='gpt')
tokenizer = OpenAIGPTTokenizer.from_pretrained('openai-gpt',cache_dir='gpt')
tokenize_input = tokenizer.tokenize(sentence)
tensor_input = torch.tensor([tokenizer.convert_tokens_to_ids(tokenize_input)])
loss=model(tensor_input, lm_labels=tensor_input)
print(math.exp(loss))




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.
CLIP tokenizer inconsistent with OpenAI release
Author: normster
Pull request: no

## Environment info

- `transformers` version: 4.6.1
- Platform: Linux-5.4.0-52-generic-x86_64-with-glibc2.10
- Python version: 3.8.5
- PyTorch version (GPU?): 1.8.1 (True)
- Tensorflow version (GPU?): 2.4.1 (False)
- Using GPU in script?: No
- Using distributed or parallel set-up in script?: No

@patil-suraj

## Information

Model I am using (Bert, XLNet ...):

The problem arises when using:
* [x] my own modified scripts: (give details below)
* [ ] the official example 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:

```
>>> import clip
>>> import transformers
>>> clip.tokenize('hello world')
tensor([[49406,  3306,  1002, 49407,     0,     0,     0,     0,     0,     0,
             0,     0,     0,     0,     0,     0,     0,     0,     0,     0,
             0,     0,     0,     0,     0,     0,     0,     0,     0,     0,
             0,     0,     0,     0,     0,     0,     0,     0,     0,     0,
             0,     0,     0,     0,     0,     0,     0,     0,     0,     0,
             0,     0,     0,     0,     0,     0,     0,     0,     0,     0,
             0,     0,     0,     0,     0,     0,     0,     0,     0,     0,
             0,     0,     0,     0,     0,     0,     0]])
>>> tokenizer = transformers.CLIPTokenizerFast.from_pretrained('openai/clip-vit-base-patch32')
>>> tokenizer('hello world')
{'input_ids': [3306, 220, 1002], 'attention_mask': [1, 1, 1]}
```

The HF CLIPTokenizer seems to add an extra token while dropping the <bos> and <eos> tokens. Am I missing something here?

Thanks!

Comments:
The non-fast tokenizer seems to be fine:

```
>>> tokenizer = transformers.CLIPTokenizer.from_pretrained('openai/clip-vit-base-patch32')
>>> tokenizer('hello world')
{'input_ids': [49406, 3306, 1002, 49407], 'attention_mask': [1, 1, 1, 1]}
```

To add more into this, HF's fast tokenizer seems to add an extra token for every white space between words:
```
>>> tokenizer("a photo of a cat")['input_ids']
[320, 220, 1125, 220, 539, 220, 320, 220, 2368]
```

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, is there any update/eta on this?

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.
Fix missing `seq_len` in `electra` model when `inputs_embeds` is used. 
Author: sararb
Pull request: yes

## Before submitting

- [x] This PR Fixes a small bug discussed in #[13122](https://github.com/huggingface/transformers/issues/13122)
- [ ] 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.

blenderbot, bart, marian, pegasus, encoderdecoder, t5: @patrickvonplaten, @patil-suraj, @NielsRogge 


Comments:
LGTM! Did you verify that it works now?

Thanks a lot for the PR @sararb !
AutoModel KeyError: 'layoutlmv2'
Author: nurgel
Pull request: no

## Environment info
- `transformers` version: 4.9.2
- Platform: Linux-5.4.104+-x86_64-with-Ubuntu-18.04-bionic
- Python version: 3.7.11
- PyTorch version (GPU?): 1.9.0+cu102 (False)
- Tensorflow version (GPU?): 2.5.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

## Information

I am trying to run layoutlmv2. When I run the code from documentation:


```
from transformers import AutoTokenizer, AutoModel
  
tokenizer = AutoTokenizer.from_pretrained("microsoft/layoutlmv2-base-uncased")
```


I get the below error:

> KeyError                                  Traceback (most recent call last)
> <ipython-input-7-457d9de7bf01> in <module>()
>       1 from transformers import AutoTokenizer, AutoModel
>       2 
> ----> 3 tokenizer = AutoTokenizer.from_pretrained("microsoft/layoutlmv2-base-uncased")
>       4 
>       5 model = AutoModel.from_pretrained("microsoft/layoutlmv2-base-uncased")
> 
> /usr/local/lib/python3.7/dist-packages/transformers/models/auto/tokenization_auto.py in from_pretrained(cls, pretrained_model_name_or_path, *inputs, **kwargs)
>     532         if config_tokenizer_class is None:
>     533             if not isinstance(config, PretrainedConfig):
> --> 534                 config = AutoConfig.from_pretrained(pretrained_model_name_or_path, **kwargs)
>     535             config_tokenizer_class = config.tokenizer_class
>     536 
> 
> /usr/local/lib/python3.7/dist-packages/transformers/models/auto/configuration_auto.py in from_pretrained(cls, pretrained_model_name_or_path, **kwargs)
>     450         config_dict, _ = PretrainedConfig.get_config_dict(pretrained_model_name_or_path, **kwargs)
>     451         if "model_type" in config_dict:
> --> 452             config_class = CONFIG_MAPPING[config_dict["model_type"]]
>     453             return config_class.from_dict(config_dict, **kwargs)
>     454         else:
> 
> KeyError: 'layoutlmv2'

Comments:
@NielsRogge 

Hello @nurgel! LayoutLM v2 is not merged yet so it isn't available in the latest version. You can follow the development here https://github.com/huggingface/transformers/pull/12604
can't import TFBertModel from transformers
Author: xiongma
Pull request: no

this is the log when I imported the TFBertModel from transformers
```
from transformers import TFBertModel
ImportError: cannot import name 'TFBertModel' from 'transformers' (/home/cally/.local/lib/python3.7/site-packages/transformers/__init__.py)

```
my enviroment is transformers 2.4 linux python 3.7

Comments:
I try it in Mac, it had same error
my enviroment is transformers 2.4 mac python 3.7

That's because you don't have TensorFlow 2 installed.

Conda users:

For whom the problem is not solved with re/installing TensorFlow, update the modules in conda.
`conda install tensorflow`

You might want to try this:

`conda install -c huggingface transformers`

(ref: https://pypi.org/project/transformers/)

Thank you @mzackaria for the answer. The problem is solved (a long time ago).  as mentioned above :)

I'm on Tensorflow 1.x and can't upgrade to 2.x
Installing an older version of transformers worked for me.
`pip install transformers==4.2.2`
Fix generation docstrings regarding input_ids=None
Author: jvamvas
Pull request: yes

# What does this PR do?

The docstrings incorrectly describe what happens if no input_ids are passed. This PR changes the docstrings so that the actual behavior is described.

## 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?

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.

Documentation: @sgugger


Comments:
Thanks for reviewing!
The merge conflict has been resolved.
How much of an improvement is DistilGPT-2 over an equivalent model trained without distilation?
Author: offendo
Pull request: no

Hi! 

I'm working on a distillation project right now, and I was wondering if this information is available anywhere.

I saw [this page](https://github.com/huggingface/transformers/tree/9ee66adadb2a8d6e04e8b18a1c9ea0b57c80642e/examples/research_projects/distillation) provides a comparison for `DistilGPT-2` vs `GPT-2`, but I don't see anything about the improvement of `DistilGPT-2` over an equivalent model (same parameters, etc.) trained in a traditional fashion. 

Any help would be greatly appreciated. Thanks!

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.