noamaanMulla-03/transformers-issues huggingface dataset:
Is there a helper script to randomly mask spans of text for T5 pretraining?
Author: abhisheknovoic
Pull request: no

Hello team,

 If I have an input text like

```The cute dog walks in the park```

Is there a library within HuggingFace that can output the following for me by masking random spans of text by (optional) taking an input masking probability?

``` 
masked input: The <extra_id_1> walks in <extra_id_2> park
target: <extra_id_1> cute dog <extra_id_2> the <extra_id_3> 


```

This is for preparing data for T5 within my own codebase.

Comments:
Not yet -> on the roadmap :-) 

any updates here?
transformers.onnx mobilenet_v2 not supported but exists in supported list
Author: ashim-mahara
Pull request: no

### System Info

- `transformers` version: 4.25.1
- Platform: Linux-6.0.6-76060006-generic-x86_64-with-glibc2.35
- Python version: 3.10.6
- Huggingface_hub version: 0.10.1
- PyTorch version (GPU?): 1.13.0 (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 notebooks for training)
- Using distributed or parallel set-up in script?: no



`KeyError: "mobilenet-v2 is not supported yet. Only ['albert', 'bart', 'beit', 'bert', 'big-bird', 'bigbird-pegasus', 'blenderbot', 'blenderbot-small', 'bloom', 'camembert', 'clip', 'codegen', 'convbert', 'convnext', 'data2vec-text', 'data2vec-vision', 'deberta', 'deberta-v2', 'deit', 'detr', 'distilbert', 'electra', 'flaubert', 'gpt2', 'gptj', 'gpt-neo', 'groupvit', 'ibert', 'imagegpt', 'layoutlm', 'layoutlmv3', 'levit', 'longt5', 'longformer', 'marian', 'mbart', 'mobilebert', 'mobilenet_v1', 'mobilenet_v2', 'mobilevit', 'mt5', 'm2m-100', 'owlvit', 'perceiver', 'resnet', 'roberta', 'roformer', 'segformer', 'squeezebert', 'swin', 't5', 'vision-encoder-decoder', 'vit', 'whisper', 'xlm', 'xlm-roberta', 'yolos'] are supported. If you want to support mobilenet-v2 please propose a PR or open up an issue."`


### Who can help?

@amyeroberts @NielsRogge 

### Information

- [X] My own modified scripts

### Tasks

- [x] My own task or dataset (give details below)

### Reproduction

```
from transformers import  AutoModelForImageClassification
from transformers.onnx import FeaturesManager

model = AutoModelForImageClassification.from_pretrained("google/mobilenet_v2_1.0_224")
model_kind, model_onnx_config = FeaturesManager.check_supported_model_or_raise(model)
```

### Expected behavior

Should be able to get model_onnx_config for export. 

Comments:
It's just a typo in the list it looks like. cc @younesbelkada or @ArthurZucker if you want to make a quick fix.

on it!

Hi @ashim-mahara 
You should be now be able to export mobilenet in ONNX using the main branch of optimum and transformers

Hi @younesbelkada thank you! that was fast, kudos to you folks!
Converting fairseq roberta to transformer throws ModuleAttributeError: 'RobertaHubInterface' object has no attribute 'args'
Author: fdas3213
Pull request: no

https://github.com/huggingface/transformers/blob/c523b241c2e50c3ed035bb76b938b6a944fed7e5/src/transformers/models/roberta/convert_roberta_original_pytorch_checkpoint_to_pytorch.py#L59

Had this error `ModuleAttributeError: 'RobertaHubInterface' object has no attribute 'args'` when running
```
convert_roberta_original_pytorch_checkpoint_to_pytorch.convert_roberta_checkpoint_to_pytorch(roberta_checkpoint_path='/home/ubuntu/fairseq/checkpoints/',
                                                                                                 pytorch_dump_folder_path='./huggingface/',
                                                                                                 classification_head=False)
```

`roberta.args.encoder_embed_dim` should now be converted to `roberta.model.encoder.args.encoder_embed_dim` to bypass this issue with the current fairseq version

Comments:
line 81&82 `roberta_sent_encoder.emb_layer_norm` should be changed to `roberta_sent_encoder.layernorm_embedding` 

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.

I met the same error just now, thanks for your solution, and I was wondering why attention was not paid to this bug?

I just met too. Thanks for sharing the bugs here!!
Add Onnx Config for PoolFormer
Author: BakingBrains
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 -->

Fixes # (https://github.com/huggingface/transformers/issues/16308)


Add changes to make PoolFormer models available for Onnx conversion.

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.

@ChainYo


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

@ChainYo @michaelbenayoun I have mistakenly closed that previous pull request. Created this with resolved conflicts. 

Yeah I will do that

Thank you
Add japanese translation of template
Author: younesbelkada
Pull request: yes

# What does this PR do?

Adds Japanese template of the README-jp.md following the same convention as what is done in Chinese

cc @sgugger @ArthurZucker 

Comments:
You might be able to modify the README with simple regex/pattern finding 

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

yes, I'll do it now

Thanks for giving me the tip about https://regex101.com/ which made the conversion process much faster! 
Should be good now
[RobertaPreLayernom] Fixes the CI daily test
Author: ArthurZucker
Pull request: yes

# What does this PR do?
The checkpoint was not correct, it is a simply typo as the `flax` and `tf` tests were not affected by this.

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

BTW, this model does not have tf or flax port yet, no?

It does 😉
`model_kwargs` not used in `model.generate()`
Author: charlottecaucheteux
Pull request: no

### System Info

- `transformers` version: 4.25.1
- Platform: Linux-5.4.0-124-generic-x86_64-with-debian-bullseye-sid
- Python version: 3.7.13
- Huggingface_hub version: 0.10.1
- PyTorch version (GPU?): 1.12.1+cu102 (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?: <fill in>
- Using distributed or parallel set-up in script?: <fill in>

### Who can help?

@ArthurZucker and @younesbelkada


### Information

- [X] The official example scripts
- [X] My own modified scripts

### Tasks

- [ ] An officially supported task in the `examples` folder (such as GLUE/SQuAD, ...)
- [ ] My own task or dataset (give details below)

### Reproduction

**Issue**: the extra `model_kwargs` are not used when using `model.generate(**model_kwargs)` (tried with transformer version '4.25.1' and '4.23.1'. 

**Code to replicate**: 

``` python
from transformers import GPT2LMHeadModel

class ToyGPT(GPT2LMHeadModel):
    def forward(self, *args, added_param=None, **kwargs):
        print("added_param", added_param)
        return super().forward(*args, **kwargs)
    
toy_model = ToyGPT.from_pretrained("gpt2")
toy_model.generate(added_param=1, max_length=5)
```

**Current output**:
`"added_param, None"`

**Current behaviour**: 
The extra `added_param` is not passed as input to the `forward()` of the model when generating new inputs, thus, `None` is printed during the forward pass. 

### Expected behavior

**Expected output**
"added_param, 1"

**Expected behaviour**
The generate function should print the updated version of the model_kwargs. 

Comments:
This snippet should work (tested on the `main` branch):
```
from transformers import GPT2LMHeadModel

class ToyGPT(GPT2LMHeadModel):
    def forward(self, *args, added_param=None, **kwargs):
        print("added_param", added_param)
        return super().forward(*args, **kwargs)
    def prepare_inputs_for_generation(self, *args, added_param=None, **kwargs):
        output = super().prepare_inputs_for_generation(*args, **kwargs)
        output.update({"added_param": added_param})
        return output
    
toy_model = ToyGPT.from_pretrained("gpt2")
toy_model.generate(added_param=1, max_length=5)
```
you'll need to update the method `prepare_inputs_for_generation` to consider also your new args

Amazing. It works. Thank you very much !
Unable to use BERTmodel 
Author: ashlytom
Pull request: no

### System Info

Transformer version = 4.24.0
Python = 3.8
Error: SSLError: HTTPSConnectionPool(host='huggingface.co', port=443): Max retries exceeded with url: /bert-large-uncased/resolve/main/config.json (Caused by SSLError(SSLError(136, '[X509: NO_CERTIFICATE_OR_CRL_FOUND] no certificate or crl found (_ssl.c:4264)')))

@LysandreJik


### Who can help?

@LysandreJik


### Information

- [X] The official example scripts
- [ ] My own modified scripts

### Tasks

- [ ] An officially supported task in the `examples` folder (such as GLUE/SQuAD, ...)
- [X] My own task or dataset (give details below)

### Reproduction

from summarizer import Summarizer

body = 'Text body that you want to summarize with BERT'
body2 = 'Something else you want to summarize with BERT'
model = Summarizer()
model(body)
model(body2)

### Expected behavior

Load the summaries

Comments:
Are you behind some firewall? It seems like you can't connect hugging face. If you are able to freely access internet with proxy you could yous this snippet:

```python3
import os
os.environ['HTTP_PROXY'] = 'http://proxy_url:proxy_port'
os.environ['HTTPS_PROXY'] = 'http://proxy_url:proxy_port'
```

otherwise you can manually download model and load it from disk

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/main/CONTRIBUTING.md) are likely to be ignored.
Infer pretrained base model and tokenizer used from a fine-tuned model_dir
Author: yunjiangster
Pull request: no

### Feature request

I would like to infer the pretrained base model and the tokenizer from the model_dir of a fine-tuned model. Is that possible with the default trainer setup? What I did previously was to programmatically copy all the tokenizer data into each checkpoint folder. But this seems cumbersome. 

### Motivation

This reduces overhead during inference/prediction. All I have to specify is just the model_dir. 

### Your contribution

Given enough guidance, I am happy to submit a PR.

Comments:
Please use the [forums](https://discuss.huggingface.co/) for such questions as we keep issues for bugs and feature requests only.

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/main/CONTRIBUTING.md) are likely to be ignored.
Fix fx symbolic tracing for deberta
Author: michaelbenayoun
Pull request: yes

# What does this PR do?

Deberta cannot be traced when using relative attention. This fixes the issue.

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/main/CONTRIBUTING.md) are likely to be ignored.

@michaelbenayoun With no response from @BigBird01 I think we can merge this. Can you just fix the conflict?

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/main/CONTRIBUTING.md) are likely to be ignored.
[ `T5`] fix fp16 loading issue
Author: younesbelkada
Pull request: yes
Labels: name: Core: Modeling

# What does this PR do?

This PR mainly fixes https://github.com/huggingface/transformers/actions/runs/3754402958/jobs/6378652143 

Since the PR https://github.com/huggingface/accelerate/pull/920 has been merged, the fix proposed in https://github.com/huggingface/transformers/pull/20760 seems to not work anymore using the main branch of `accelerate` for some specific cases. 

To reproduce (use the main branch of `accelerate`): 
```
import torch
from transformers import T5ForConditionalGeneration

model = T5ForConditionalGeneration.from_pretrained("t5-small", torch_dtype=torch.float16)
print(model.decoder.block[0].layer[2].DenseReluDense.wo.weight.dtype)
>>> torch.float16
```

Why?

I believe this is because the aforementioned PR introduced a new argument `dtype` on the function `set_module_tensor_to_device`, if this argument is set to `None` (by default), the target value [is automatically set to the `dtype` of the old tensor](https://github.com/huggingface/accelerate/blob/53b8ed1e8ed5fb8e9d2978744515c31c09e1423e/src/accelerate/utils/modeling.py#L129) - which slightly breaks some assumptions made in https://github.com/huggingface/transformers/pull/20760
I believe upstreaming this change on `modeling_utils` by adding the support of this new argument should be the fix. As some users might not use the latest version of accelerate, I added a small hack to make this change backward compatible, but I am not sure if this is the best solution

Tested this fix on the main branch of `accelerate`,  `accelerate==0.15.0` and all relevant tests pass

cc @sgugger 

Comments:
_The documentation is not available anymore as the PR was closed or merged._
Enable BAAI/AltCLIP model to better handle Chinese prompts 
Author: BAAI-OpenPlatform
Pull request: no

### Feature request

We already have our bilingual CLIP model here: https://huggingface.co/BAAI/AltCLIP    (currently private)
Would you like to collaborate with us to merge it into transformers?
Thanks a lot!

### Motivation

Want to enable our bilingual ALtCLIP model to handle Chinese prompts as well as English; 

### Your contribution

We can collaborate with you to work on it. We are familiar with our model, but is not clear how to merge in into 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/main/CONTRIBUTING.md) are likely to be ignored.
🔥[Community Event] Doc Tests Sprint - Configuration files🔥 #19487
Author: aashigupta25
Pull request: yes

I want to work on this project.
Thank you

Comments:
Please follow the [contributing guide](https://github.com/huggingface/transformers/blob/main/CONTRIBUTING.md) and make sure you open a pull request that does some modifications on one of the configurations.

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

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/main/CONTRIBUTING.md) are likely to be ignored.
AttributeError: 'DummyVecEnv' object has no attribute 'render_mode'
Author: felipeoliverai
Pull request: no

### System Info

I'm doing the Deep RL course, I don't know what is happening, something is wrong in the notebook on unit 1: https://colab.research.google.com/github/huggingface/deep-rl-class/blob/master/notebooks/unit1/unit1.ipynb#scrollTo=xMkkkukIBQJM 

when I try to push my Agent to HF Hub I received this error message: AttributeError: 'DummyVecEnv' object has no attribute 'render_mode' 

my code is very similar to the notebook example.

### Who can help?

_No response_

### Information

- [ ] The official example scripts
- [ ] My own modified scripts

### Tasks

- [ ] An officially supported task in the `examples` folder (such as GLUE/SQuAD, ...)
- [ ] My own task or dataset (give details below)

### Reproduction

Code example: 

import gym

from stable_baselines3 import PPO
from stable_baselines3.common.vec_env import DummyVecEnv
from stable_baselines3.common.env_util import make_vec_env

from huggingface_sb3 import package_to_hub


env_id = "LunarLander-v2"
model_architecture = "PPO"
repo_id = "Felipe474/ppo-LunarLander-v2"  # Change with your repo id, you can't push with mine 😄
commit_message = "Upload PPO LunarLander-v2 trained agent"


eval_env = DummyVecEnv([lambda: gym.make(env_id)])


package_to_hub(model=model, # Our trained model
               model_name=model_name, # The name of our trained model 
               model_architecture=model_architecture, # The model architecture we used: in our case PPO
               env_id=env_id, # Name of the environment
               eval_env=eval_env, # Evaluation Environment
               repo_id=repo_id, # id of the model repository from the Hugging Face Hub (repo_id = {organization}/{repo_name} for instance ThomasSimonini/ppo-LunarLander-v2
               commit_message=commit_message)


### Expected behavior

Successively push agent to HF hub.

Comments:
Learning rate is set to zero for the entirety of the first epoch
Author: mmcdermott
Pull request: no

https://github.com/huggingface/transformers/blob/31d452c68b34c2567b62924ee0df40a83cbc52d5/src/transformers/optimization.py#L210

Both in practice and based on my understanding of the code, this will produce a `LambdaLR` that will return a multiplicative factor of 0 for the entirety of the first epoch (as `current_step` will be 0), which will mean that the entire first epoch the model will not train.

The names given to variables in the code imply this might be intended to be set with training steps, not epochs; is that the desire? If not, should this be modified to account for the first epoch having `current_step` equal to 0? Or is something wrong in my specific use-case?

My use-case is in using the `get_polynomial_decay_schedule_with_warmup` as a scheduler in a pytorch lightning module. Note I also mentioned this on the forum, here: https://discuss.huggingface.co/t/huggingface-lr-decay-schedulers-spend-the-first-epoch-w-an-lr-of-0/28195

Comments:
Diving deeper into this, I think this is due to a mismatch between pytorch lightning's design and huggingface's. Huggingface trainer. [Huggingface's trainer calls the lr scheduler every step](https://github.com/huggingface/transformers/blob/31d452c68b34c2567b62924ee0df40a83cbc52d5/src/transformers/trainer.py#L1845), and [pytorch lightning can be configured to either call it once per step or once per epoch](https://github.com/Lightning-AI/lightning/blob/612d43e5bf38ba73b4f372d64594c2f9a32e6d6a/src/pytorch_lightning/loops/epoch/training_epoch_loop.py#L407), so I likely have something configured wrong.
[i18n-<ao>] Translating docs to <am>
Author: arabaman
Pull request: no
Labels: name: WIP

<!--
Note: Please search to see if an issue already exists for the language you are trying to translate.
-->

Hi!

Let's bring the documentation to all the <languageName>-speaking community 🌐 (currently 0 out of 267 complete)

Who would want to translate? Please follow the 🤗 [TRANSLATING guide](https://github.com/huggingface/transformers/blob/main/docs/TRANSLATING.md). Here is a list of the files ready for translation. Let us know in this issue if you'd like to translate any, and we'll add your name to the list.

Some notes:

* Please translate using an informal tone (imagine you are talking with a friend about transformers 🤗).
* Please translate in a gender-neutral way.
* Add your translations to the folder called `<languageCode>` inside the [source folder](https://github.com/huggingface/transformers/tree/main/docs/source).
* Register your translation in `<languageCode>/_toctree.yml`; please follow the order of the [English version](https://github.com/huggingface/transformers/blob/main/docs/source/en/_toctree.yml).
* Once you're finished, open a pull request and tag this issue by including #issue-number in the description, where issue-number is the number of this issue. Please ping @ArthurZucker, @sgugger for review.
* 🙋 If you'd like others to help you with the translation, you can also post in the 🤗 [forums](https://discuss.huggingface.co/).

## Get Started section

- [ ] [index.mdx](https://github.com/huggingface/transformers/blob/main/docs/source/en/index.mdx) https://github.com/huggingface/transformers/pull/20180
- [ ] [quicktour.mdx](https://github.com/huggingface/transformers/blob/main/docs/source/en/quicktour.mdx) (waiting for initial PR to go through)
- [ ] [installation.mdx](https://github.com/huggingface/transformers/blob/main/docs/source/en/installation.mdx).

## Tutorial section
- [ ] [pipeline_tutorial.mdx](https://github.com/huggingface/transformers/blob/main/docs/source/en/pipeline_tutorial.mdx)
- [ ]  [autoclass_tutorial.mdx](https://github.com/huggingface/transformers/blob/master/docs/source/autoclass_tutorial.mdx)
- [ ]  [preprocessing.mdx](https://github.com/huggingface/transformers/blob/main/docs/source/en/preprocessing.mdx)
- [ ]  [training.mdx](https://github.com/huggingface/transformers/blob/main/docs/source/en/training.mdx)
- [ ]  [accelerate.mdx](https://github.com/huggingface/transformers/blob/main/docs/source/en/accelerate.mdx)
- [ ]  [model_sharing.mdx](https://github.com/huggingface/transformers/blob/main/docs/source/en/model_sharing.mdx)
- [ ]  [multilingual.mdx](https://github.com/huggingface/transformers/blob/main/docs/source/en/multilingual.mdx)

<!--
Keep on adding more as you go 🔥
-->


Comments:
Hi @arabaman. Could you please fill the template with your language?