noamaanMulla-03/transformers-issues huggingface dataset:
Download offile HuggingFace Models in other format than ".bin" Format
Author: deepaksinghtopwal
Pull request: no

# 🚀 Feature request
### Hi, 
### Just wandering if there is any other way of downloading Huggingface models in a restricted environment?

For example : 
**a.)** we have a network which doesn't allow downloading the model by internet (so the auto download feature in transformer wont work), 
**b.)** we can't download Bin files(So cannot download the files from "Models" option in Huggingface.co)
**c.)** Using the Git clone option gives the Proxy error.

So is there any other way which can be used to download the Huggingface Models ?

<!-- A clear and concise description of the feature proposal.
     Please provide a link to the paper and code in case they exist. -->

## Motivation

<!-- Please outline the motivation for the proposal. Is your feature request
     related to a problem? e.g., I'm always frustrated when [...]. If this is related
     to another GitHub issue, please link here too. -->

## 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:
Not sure how to help here... can you download the files from another machine and sync them to the restricted env?

No, that's the only problem that all the devices within organization are same network and have same policies(as mentioned above).. :)
I see huggingFace has already provided many methods but the challenge is that none of it is working for me ..

But it does support downloading other format(i.e. i recently downloaded models from Easyocr in .pth  and Spacy language models) , So just a query if any solution can be provided around that which can help me using Hugginface models in such restricted environment..



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.
Multilingual MiniLM
Author: rodrigoheck
Pull request: no

Hello everyone! 

I am trying to load this model from Microsoft using the path provided [here](huggingface.co/microsoft/Multilingual-MiniLM-L12-H384). I am applying the same code provided there:

`tokenizer = AutoTokenizer.from_pretrained("microsoft/Multilingual-MiniLM-L12-H384")`

But I am facing this error message:

`stat: path should be string, bytes, os.PathLike or integer, not NoneType`

My intuition says that the model is not correctly stored on the server, but I am not sure. 

Comments:
Alright! I found the solution. For the tokenizer, XLMRobertaTokenizer should be used instead of AutoTokenizer. 

Thanks for reporting. Now that we have model versioning, the author(s) of [`"microsoft/Multilingual-MiniLM-L12-H384"`](https://huggingface.co/microsoft/Multilingual-MiniLM-L12-H384) could update the model's config.json to specify a `tokenizer_class` so that AutoTokenizer works out of the box.

@JetRunner @LysandreJik do you remember who the model author(s) are?

I think I did the uploading. I'll update the config tomorrow!

I believe the config is not yet updated because the error is still there

@sersoage Re-uploading it now. Thanks for the note!

Done

@JetRunner  Thank you!
[WIP - don't merge][TF generate] Make tf generate compatible with tf.function
Author: patrickvonplaten
Pull request: yes
Labels: name: wontfix

The tf generate function shoud be cleaned up so that it can be used with tf.function.

Comments:
is this still being worked on?

I won't be able to take a look in the next ~2 weeks. Feel free to continue the PR :-) 

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.


@patrickvonplaten can I ask whether this change is still working on? Will we be able to get one example for greedy search with tf function compatible? Thanks.

Thank you for all the amazing work! This library is too good to be true and this would be a really good feature to have if possible and when possible!
Byt5
Author: flozi00
Pull request: no
Labels: name: New model

# 🌟 New model addition

## Model description
Tokenizer free Version of mt5
<!-- Important information -->

## Open source status

* [X] the model implementation is available: (give details)
* https://github.com/google-research/byt5
* [X] the model weights are available: (give details)
* https://github.com/google-research/byt5
* [ ] who are the authors: (mention them, if possible by @gh-username)


Comments:
hopefully getting closed by https://github.com/huggingface/transformers/pull/11971
Permission error for cardiffnlp/twitter-roberta-base-emotion
Author: StephenQuirolgico
Pull request: no

@patrickvonplaten,

I'm having issues accessing  the `cardiffnlp/twitter-roberta-base-emotion` model using:
```
task='emotion'
MODEL = f"cardiffnlp/twitter-roberta-base-{task}"
tokenizer = AutoTokenizer.from_pretrained(MODEL)
```
When I substitute another task, such as `task='sentiment'`, it works fine. I have also tried using the `cardiffnlp/twitter-roberta-base-emotion` model within an NLP framework (AdaptNLP) but got a `permission denied` error. However, I did not receive a `permission denied` error when using the `sentiment ` task within this NLP framework. 

Comments:
Hey @StephenQuirolgico,

could you attach a code snippet that I can copy-paste to reproduce the error? :-)

@patrickvonplaten, Not exactly sure what the issue was but it's working now. Thanks!
Permission denied for cardiffnlp/twitter-roberta-base-emotion
Author: StephenQuirolgico
Pull request: no

@patrickvonplaten

When trying to access `cardiffnlp/twitter-roberta-base-emotion` using the example code, it can't seem to find the model. I also tried calling the model from an NLP framework (AdaptNLP) and it gave a Permission denied error. However, I don't get this error  when using `cardiffnlp/twitter-roberta-base-sentiment`. Any suggestions?

Comments:
The model seems accessible: https://huggingface.co/cardiffnlp/twitter-roberta-base-emotion 

And running the example code locally correctly loads the model, and outputs the following:

```py
1) joy 0.9382
2) optimism 0.0362
3) anger 0.0145
4) sadness 0.0112
```

Could you try again to make sure it wasn't a connection issue?

@LysandreJik, thanks - it's working now.
Uncoupling ZeRO-3 weak ref bridge b/w Trainer and modeling_utils
Author: g-karthik
Pull request: no

https://github.com/huggingface/transformers/blob/fd6204b2a70d100800cb259a7fbddfc812631ed3/src/transformers/modeling_utils.py#L1168

So I briefly looked through the ZeRO-3 integration into the `Trainer` and this approach of creating a "bridge" between the `Trainer` and `modeling_utils` via a weak ref is neat.

However, what if I wanted to use ZeRO-3 with HF models outside the scope of the `Trainer` and `TrainingArguments`? Seems like I cannot at the moment.

There seems to be 4 places in `modeling_utils` where `is_deepspeed_zero3_enabled` is called, of which the only one that seems to be heavily tied to the custom `DeepSpeedConfigHF` class is the one referenced above.

Is it not possible to allow `Init()` args to come from the parent `from_pretrained()` method's `kwargs`?

@stas00 @sgugger 

Comments:
Good call, @g-karthik!

Please see the decoupled PR here: https://github.com/huggingface/transformers/pull/11966

Now you can just do:
```
from transformers.integrations import HfDeepSpeedConfig
dsc = HfDeepSpeedConfigHF(ds_config)
model = AutoModel.from_pretrained(name)
```
and it'll just work, w/o needing the Trainer.

Please let me know if it works for you. 

> Is it not possible to allow Init() args to come from the parent from_pretrained() method's kwargs?

I can't see how this would work, since there several other core functions which rely on `is_deepspeed_zero3_enabled` and there is no way to pass this argument to those. That's why the "environmental" approach, rather than passing args.

The only other way I can see this solved is by tapping into the `model.config` object, but then it'll require a ton of code changes - e.g. all examples.

PR merged - I updated the comment above to reflect the final new name.

I will now work on updating the docs so it's all clear.
[Trainer] add train loss and flops metrics reports
Author: stas00
Pull request: yes

The train wasn't reporting loss metrics (and flops it seems), this PR fixes that. Now we get:

```
***** train metrics *****
  epoch                    =        1.0
  total_flos               =      405GF
  train_loss               =     2.9435
  train_runtime            = 0:00:01.75
  train_samples            =         20
  train_samples_per_second =     11.401
  train_steps_per_second   =       1.14
```

Also moves metrics logging to when all metrics have been updated.

@sgugger 

Comments:
Hmm, it broke several trainer tests:
```
FAILED tests/test_trainer.py::TrainerIntegrationTest::test_can_resume_training
FAILED tests/test_trainer.py::TrainerIntegrationTest::test_resume_training_with_frozen_params
FAILED tests/test_trainer.py::TrainerIntegrationTest::test_resume_training_with_gradient_accumulation
FAILED tests/test_trainer_callback.py::TrainerCallbackTest::test_event_flow
```

The metrics log for `train_loss` is now different:
```
    self.assertEqual(log, log1)
E   AssertionError: {'tot[14 chars].0, 'train_loss': 6.380087534586589, 'epoch': 3.0, 'step': 24} != {'tot[14 chars].0, 'train_loss': 3.9063542683919272, 'epoch': 3.0, 'step': 24}
E     {'epoch': 3.0,
E      'step': 24,
E      'total_flos': 4608.0,
E   -  'train_loss': 6.380087534586589}
E   +  'train_loss': 3.9063542683919272}
```

So either there was already `train_loss` in metrics log, but it was saving a different value, So me "fixing" it to report the value `TrainOutput` returns broke the test. or it wasn't there and it wasn't comparing the loss and now it does and it isn't the same. Need to check.

**edit:** proved to be the latter.
unable to parse E:/litao/bert/bert-base-cased\config.json as a URL or as a local path
Author: 754563116
Pull request: no
Labels: name: wontfix

## ❓ Questions & Help

<!-- A clear and concise description of the question. -->
train_file = 'E:/litao/bert/SQuAD 1.1/train-v1.1.json'
    predict_file = 'E:/litao/bert/SQuAD 1.1/dev-v1.1.json'
    model_type = 'bert'
    model_name_or_path  = 'E:/litao/bert/bert-base-cased'
    output_dir = 'E:/litao/bert/transformers-master/examples/output'


![微信图片_20191018180549](https://user-images.githubusercontent.com/32032029/67085767-058c0780-f1d2-11e9-96ca-df431f70b7c8.png)


Comments:
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.


Did you find a solution?

> Did you find a solution?

Rename "bert_config.json" to "config.json".
small bug in RAG model
Author: yuvalkirstain
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.5.1
- Platform: Linux-5.4.0-66-generic-x86_64-with-glibc2.27
- Python version: 3.8.3
- PyTorch version (GPU?): 1.8.1+cu111 (True)

### Who can help
@ola13 

Models:

- rag

## Information

Model I am using (Bert, XLNet ...): RAG

The problem arises when using:
* [ ] the official example scripts: seems to be a bug in https://github.com/huggingface/transformers/blob/master/src/transformers/models/rag/modeling_rag.py#L306
To pass my own question encoder the argument needs to be `question_encoder_model`, but the suffix ("model") gets trimmed because the len is taken according to `question_question_encoder_`.

```python
kwargs_question_encoder = {
            argument[len("question_question_encoder_") :]: value
            for argument, value in kwargs.items()
            if argument.startswith("question_encoder_")
        }
```

## To reproduce

Steps to reproduce the behavior:

```python
question_encoder = AutoModel.from_pretrained("any model")
rag_model = model_class.from_pretrained_question_encoder_generator(
        question_encoder_model=question_encoder, generator_pretrained_model_name_or_path=generator_name_or_path, config=rag_config
    )
```

<!-- 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

be able to pass a question encoder **model** and not just a config to the rag model.


Comments:
This indeed looks like a typo! Thanks for your issue :-)

The kwargs should not be trimmed by `"question_question_encoder"`, but by `"question_encoder"`.

Would you like to open a PR to fix it? Otherwise I can do it as well :-)

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.

Unping
Fix do_eval default value in training_args.py
Author: bonniehyeon
Pull request: yes

# What does this PR do?

According to <do_eval> description, when <evaluation_strategy> is different from 'no' it will be set 'True'.
But the <do_eval>'s defualt setting is None. So, this code can't be executed unless the the user set <do_eval = False>.

`if self.do_eval is False and self.evaluation_strategy != IntervalStrategy.NO : self.do_eval = True  `

I think it will be better to change <do_eval>'s defulat value 'None' into 'False'

- How I FOUND IT.
I was trying to use <training_args.do_eval> in my script.
BUT it didn't worked even the <evaluation_strategy> was set to 'steps'.


Comments:
Saving and loading a model does not work
Author: bipinkc19
Pull request: no

![image](https://user-images.githubusercontent.com/41479925/120278069-8e3ab700-c2d4-11eb-935e-a3a733a24cfd.png)
After pulling a model, tuning it and saving it, it shows this error while loading it back.

I pulled other files except `pytorch_model.bin` from the pretrained model in hugging face
![image](https://user-images.githubusercontent.com/41479925/120278270-cb06ae00-c2d4-11eb-9a40-3e1de6fc123c.png)


Comments:
Your file is called `pytoch_model.bin` instead of `pytorch_model.bin`.

You should use `save_pretrained` :)

Sometime I wonder how more stupid I can be.
Thanks for the help
[docs] fix xref to `PreTrainedModel.generate`
Author: stas00
Pull request: yes
Labels: name: WIP

This PR partially resolves the issue raised in https://github.com/huggingface/transformers/issues/9202

I spent quite some time to try to figure out how to get sphinx to figure out the inheritance so that it could cross-reference inherited methods, but it can't even handle mixins it seems. i.e. it can't resolve: `transformers.PreTrainedModel.generate` 

So one has to explicitly specify the fully qualified original method for xref to work :(

Bottom line - if currently you want a cross-reference link to `transformers.PreTrainedModel.generate` or `T5ForConditionalGeneration.generate` to work, you have to use `~transformers.generation_utils.GenerationMixin.generate`

So I did:
```
find . -type d -name ".git" -prune -o -type f -exec perl -pi -e 's|transformers\.\w+\.generate|transformers.generation_utils.GenerationMixin.generate|g' {} \;
```

then also added the same for `transformers.PreTrainedModel.(greedy_search|sample|beam_search|beam_sample|group_beam_search)`
```
find . -type d -name ".git" -prune -o -type f -exec perl -pi -e 's#transformers.PreTrainedModel.(greedy_search|sample|beam_search|beam_sample|group_beam_search)#transformers.generation_utils.GenerationMixin.$1#g' {} \;
```

Fixes: https://github.com/huggingface/transformers/issues/9202

@sgugger 

Comments:
Would it be a good idea to make an Good second Issue for someone to research whether sphinx could be configured to resolve inherited and mixin methods when it does cross-referencing? It'd be much more intuitive for doc writing if we could have the sub-classed method named and also not needing to hide the sub-class via `~` prefix.

I did spent quite some time trying to find one and also experimenting with different configs but it doesn't mean it doesn't exist.

Sure, we can try that. I didn't try for very long but didn't manage it on my side either, for what it's worth.

https://github.com/huggingface/transformers/issues/11069

https://github.com/huggingface/transformers/issues/11069 had many fishermen but nothing came out of it. So I guess I will merge it and close https://github.com/huggingface/transformers/issues/11069

Fine by me!
[deepspeed] Move code and doc into standalone files
Author: stas00
Pull request: yes
Labels: name: DeepSpeed

Deepspeed integration is no longer bound to HF Trainer and its docs have grown too big to be a subsection of the Trainer docs. This PR:
- creates `transformers.deepspeed` and migrates all the code and references to it
- moves docs to `deepspeed.rst`

Note to @sgugger - I tried to make this easy to review by not making any changes to any content of code or text. Other then the updated imports in the code, the only change is the preamble section of `deepspeed.rst` - there is no need to re-review the rest unless you'd like to. I flagged that new text below.

And I also added a poor-man style redirect links from most of the previous sections in `trainer.rst` so that the old links still work. Well, had to add anchors to sections in the new doc for this to work.

@sgugger 

Comments:
Cannot run the gpt neo 2.7B example
Author: donno2048
Pull request: no

## Environment info
- `transformers` version: 4.4.2
- Platform: Windows and Linux (using wsl)
- Python version: 3.8.5
- PyTorch version (GPU?): 1.8.1+cpu (False)
- Tensorflow version (GPU?): 2.4.1 (False)

Library:

- text generation: @patrickvonplaten
- pipelines: @LysandreJik

## Information

When running the example for gpt-neo i.e.
```py
>>> from transformers import pipeline
>>> generator = pipeline('text-generation', model='EleutherAI/gpt-neo-2.7B')
>>> generator("EleutherAI has", do_sample=True, min_length=50)
```
I get this:
```
Downloading: 100%|█████████████████████████████████████████████████████████████████| 1.46k/1.46k [00:00<00:00, 2.27MB/s]
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/donno2048/.local/lib/python3.8/site-packages/transformers/pipelines/__init__.py", line 344, in pipeline
    framework = framework or get_framework(model)
  File "/home/donno2048/.local/lib/python3.8/site-packages/transformers/pipelines/base.py", line 71, in get_framework
    model = AutoModel.from_pretrained(model, revision=revision)
  File "/home/donno2048/.local/lib/python3.8/site-packages/transformers/models/auto/modeling_auto.py", line 809, in from_pretrained
    config, kwargs = AutoConfig.from_pretrained(
  File "/home/donno2048/.local/lib/python3.8/site-packages/transformers/models/auto/configuration_auto.py", line 389, in from_pretrained
    config_class = CONFIG_MAPPING[config_dict["model_type"]]
KeyError: 'gpt_neo'
```

Comments:
Hi @donno2048. the GPT Neo is available on the master branch, and is not yet in a release. I invite you to install transformers from source, with the following:
```
pip install git+https://github.com/huggingface/transformers
```

Thanks

Does the min_length param work for you? I do the same as above and it doesn't seem to change anything
AutoModel abstraction fails for pre-training initialization
Author: g-karthik
Pull request: no

## Environment info

- `transformers` version: 4.5.1
- Python version: 3.6
- PyTorch version: 1.4+
- Using GPU in script?: No
- Using distributed or parallel set-up in script?: No

### Who can help

@patrickvonplaten, @LysandreJik


## Information

Model I am using: GPT-2

The problem arises when using:
* [Y] my own modified scripts: (give details below)

## To reproduce

Steps to reproduce the behavior:

```
from transformers import AutoConfig, AutoModelForCausalLM, GPT2LMHeadModel
config = AutoConfig.from_pretrained("gpt2", return_dict=True, gradient_checkpointing=False)

model_class = GPT2LMHeadModel
model = model_class(config)  # WORKS FINE

model_class = AutoModelForCausalLM
model = model_class(config)  # FAILS, stack trace below

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: __init__() takes 1 positional argument but 2 were given

```

## Expected behavior

Both cases should work fine. The latter case should pull the former class internally.

Comments:
Hello! We recommend you read the [docs regarding the `AutoModel`](https://huggingface.co/transformers/model_doc/auto.html#transformers.AutoModel.from_config). I have linked you the `from_config` method which should be used in this use case.

However, it is indeed unexpected for you to receive this error message. The message should be more explicit, investigating now.

Opened #11956 for a more explicit error, and opening your use case for discussion.
Authorize args when instantiating an AutoModel
Author: LysandreJik
Pull request: yes

The current `_BaseAutoModelClass` class initialization does not accept any argument, and therefore fails with an arcane error when instantiating it incorrectly, as shown in https://github.com/huggingface/transformers/issues/11953 by @g-karthik:

```py
from transformers import AutoConfig, AutoModelForCausalLM

config = AutoConfig.from_pretrained("gpt2", return_dict=True, gradient_checkpointing=False)
model = AutoModelForCausalLM(config)
```
```out
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: __init__() takes 1 positional argument but 2 were given
```

This PR adds possible arguments and keyword arguments so that the error is always correctly raised:

```out
Traceback (most recent call last):
  File "<input>", line 1, in <module>
  File "/home/xxx/transformers/src/transformers/models/auto/auto_factory.py", line 361, in __init__
    raise EnvironmentError(
OSError: AutoModel is designed to be instantiated using the `AutoModel.from_pretrained(pretrained_model_name_or_path)` or `AutoModel.from_config(config)` methods.
```

Taking this opportunity to re-open the question asked by @g-karthik of whether the `AutoModel`s should have the ability to be instantiated using configuration objects via the `__init__`, similarly to other `PreTrainedModel`s.

@patrickvonplaten @sgugger 

Comments:
@LysandreJik thanks for this!

Yeah IMO it'd be great if the instantiation of `AutoModel`s from a configuration follows a similar signature as that of instantiation of regular model classes from a configuration, just from a consistency standpoint because `AutoModel`s are already effectively treated as models via `modeling_auto.py` just like any other model.