noamaanMulla-03/transformers-issues huggingface dataset:
Support turning off the model uploading in ClearML
Author: david1542
Pull request: yes

# What does this PR do?
Support turning off the model uploading in ClearML using an environment variable called `CLEARML_LOG_MODEL`


Fixes #20889 


## Before submitting
- [ ] This PR fixes a typo or improves the docs (you can dismiss the other checks if that's the case).
- [ ] Did you read the [contributor guideline](https://github.com/huggingface/transformers/blob/main/CONTRIBUTING.md#start-contributing-pull-requests),
      Pull Request section?
- [ ] 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/main/docs), and
      [here are tips on formatting docstrings](https://github.com/huggingface/transformers/tree/main/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.

<!-- 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:

- text models: @ArthurZucker and @younesbelkada
- vision models: @amyeroberts and @NielsRogge
- speech models: @sanchit-gandhi

Library:

- flax: @sanchit-gandhi
- generate: @gante
- pipelines: @Narsil
- tensorflow: @gante and @Rocketknight1
- tokenizers: @ArthurZucker
- trainer: @sgugger

Integrations:

- deepspeed: @stas00
- ray/raytune: @richardliaw, @amogkam

Documentation: @sgugger and @stevhliu

HF projects:

- accelerate: [different repo](https://github.com/huggingface/accelerate)
- datasets: [different repo](https://github.com/huggingface/datasets)
- diffusers: [different repo](https://github.com/huggingface/diffusers)
- rust tokenizers: [different repo](https://github.com/huggingface/tokenizers)

Maintained examples (not research project or legacy):

- Flax: @sanchit-gandhi
- PyTorch: @sgugger
- TensorFlow: @Rocketknight1

 -->


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

Hi @sgugger :) I modified the docstring, as you suggested. Can you please have a look? 🙏

Code looks good but it seems there is an issue with your CircleCI permissions, the tests won't run.
Could you try refreshing your permissions as shown [here](https://support.circleci.com/hc/en-us/articles/360048210711-How-to-Refresh-User-Permissions-)?

@sgugger I re-authenticated to CircleCI, and it seems that the CI passed :)
Can you have a look and approve? :)

@sgugger Thanks for the feedback. I accepted your change :)

Thanks for your contribution!
fix parameter name in docstring
Author: cceyda
Pull request: yes

# What does this PR do?
fixes parameter name `return_tensor -> return_tensors` in docstring.

Fixes potential confusion.

I believe this is my biggest contribution yet 🤣 

## Before submitting
- [x] 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/main/CONTRIBUTING.md#start-contributing-pull-requests), Pull Request section?

## 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


Comments:
_The documentation is not available anymore as the PR was closed or merged._
fix levit timm conversion file
Author: Bearnardd
Pull request: yes

# What does this PR do?
Fixes conversion file `convert_levit_timm_to_pytorch.py` for levit


Fixes # (issue)
https://github.com/huggingface/transformers/issues/20937




## Who can review?
@NielsRogge




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

Thanks again for your contribution!
CLIP - Mismatch tokenizer_config.json of CLIPTokenizer.from_pretrained() and huggingface_hub
Author: Decentblast
Pull request: no

### System Info

Model ID : `"openai/clip-vit-base-patch32"`
Transformer Version : 4.23.0
In the huggingface hub, the file https://huggingface.co/openai/clip-vit-base-patch32/blob/main/tokenizer_config.json doesn't have the parameter `model_max_length:77`.
On the contrary, if I use the following:
`tokenizer = CLIPTokenizer.from_pretrained("openai/clip-vit-base-patch32")`
`tokenizer.save_pretrained('./test_tokenizer/')`
The tokenizer_config.json saved under **test_tokenizer** has the the parameter `model_max_length:77`.

So, when I load tokenizer from the downloaded files from https://huggingface.co/openai/clip-vit-base-patch32/tree/main , the `tokenizer.model_max_length` is different from the `CLIPTokenizer.from_pretrained("openai/clip-vit-base-patch32")`.
The former one has a `model_max_length=1000000000000000019884624838656`
The later one has a `model_max_length=77`



### Who can help?

@patil-suraj , @SaulLu 

### Information

- [X] 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

1. Download the files directly from CLIP huggingface hub: https://huggingface.co/openai/clip-vit-base-patch32/tree/main and store them under a folder such as './hub_model_clip/'
2.  Run the following code in a notebook
```
from transformers import CLIPTokenizer
tokenizer_1 = CLIPTokenizer.from_pretrained("openai/clip-vit-base-patch32")
tokenizer_2 = CLIPTokenizer.from_pretrained("./hub_model_clip/")
```
3. Check the following two:
```
print(tokenizer_1.model_max_length) # 77
print(tokenizer_2.model_max_length) # 1000000000000000019884624838656
```

### Expected behavior

Sync up the model_max_len from different source of the CLIP tokenizer

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.
Levit conversion file argparser bug
Author: Bearnardd
Pull request: no

### Who can help?

@NielsRogge

### Reproduction

In the conversion file for the `levit` model (`convert_levit_timm_to_pytorch.py`) there is a wrong usage of `argparse.ArgumentParser()` for the `--push_to_hub` argument. Currently it is handled with the type `bool` but in the argparser `bool` type does not work as expected and the current code always generates `push_to_hub=True` not matter if in the CLI we use `--push_to_hub=False` or `--push_to_hub=True`. More canonical convention of handling boolean values with the argparser is to use two arguments. As an example: `--no-push_to_hub` to store `False` values and `--push_to_hub` to store `True` values.


### Expected behavior

Correct usage of the `argparser`.

Comments:
Closing since fix was merged.
Add Object Detection task tutorial to the transformers documentation
Author: MKhalusova
Pull request: no

Currently, the transformers documentation has two how-to guides for CV tasks - image classification and semantic segmentation. Transformers support other CV tasks, such as object detection. This issue describes a proposal to add a how-to guide for object detection similar in structure to the existing guides to help the community members get started with object detection on their own data using the transformers library. 

Here’s an approximate outline for the page: 

1. Intro: what object detection is, including the video from https://huggingface.co/tasks/object-detection
2. Fine-tuning either DETR or YOLOS on a new dataset (TODO: decide which one to pick).
 2.1. Loading a dataset 
 2.2. Preprocessing the dataset 
 2.3. Setting up an evaluation metric
 2.4. Training and pushing a model to the hub
3. Using the fine-tuned model for inference.

Some existing notebooks for reference: 
    - [Fine-tuning YOLOS on a custom dataset for object detection](https://github.com/NielsRogge/Transformers-Tutorials/blob/master/YOLOS/Fine_tuning_YOLOS_for_object_detection_on_custom_dataset_(balloon).ipynb)
    - [Fine-tuning DETR on a custom dataset for object detection](https://github.com/NielsRogge/Transformers-Tutorials/blob/master/DETR/Fine_tuning_DetrForObjectDetection_on_custom_dataset_(balloon).ipynb)


Related [WIP] PR: https://github.com/huggingface/transformers/pull/20874

Comments:
This looks great to me, looking forward to seeing the guide and let me know if there is anything I can help with! 🙂 

I would recommend using DETR since it is a lot more popular than YOLOS (263k downloads versus 28.4k).

@stevhliu That's a good reason to go with DETR, thanks for the tip! 

The issue is fixed with https://github.com/huggingface/transformers/pull/20925
fix typo
Author: sabaul
Pull request: yes

# What does this PR do?

Typo fix: Corrected the word metada --> metadata


## Before submitting
- [x] 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/main/CONTRIBUTING.md#start-contributing-pull-requests),
      Pull Request section?
- [ ] 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/main/docs), and
      [here are tips on formatting docstrings](https://github.com/huggingface/transformers/tree/main/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.

Comments:
_The documentation is not available anymore as the PR was closed or merged._
Replace `past` with `past_key_values`
Author: ArthurZucker
Pull request: yes

# What does this PR do?
The argument `past` was completely replaced with `past_key_values` thus this PR should fix any problem with `kwargs` being swallowed for old models in generation. 
Related to #20347

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

Ok the failing tests were because I did not pull from main, were the `tf_utils` now uses the `generate_config`. LGTM the failing test seems to be unrelated

Yes, good to merge for me!
[make repo-consistency] weird warning
Author: stas00
Pull request: no

This doesn't make sense:
```
You are using torch==1.13.0, but torch>=1.9.0 is required to use MCTCTModel. Please upgrade torch.
```

since: `1.13 > 1.9`  - a wrong comparison function?

full output:

```
$ make repo-consistency
python utils/check_copies.py
python utils/check_table.py
python utils/check_dummies.py
python utils/check_repo.py
Checking all models are included.
Checking all models are public.
You are using torch==1.13.0, but torch>=1.9.0 is required to use MCTCTModel. Please upgrade torch.
Checking all models are properly tested.
Checking all objects are properly documented.
[...]
```

@sgugger 

Comments:
super, thank you for fixing, Sylvain!
PyTorch training scripts freeze when preprocessing_num_workers > 1
Author: Lokiiiiii
Pull request: no

### System Info

transformers 4.24.0
datasets 2.7.1

Dockerfile: https://github.com/aws/deep-learning-containers/blob/master/pytorch/training/docker/1.12/py3/cu113/Dockerfile.gpu

### Who can help?

@sgugger, @patil-sura

### Information

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

### Tasks

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

### Reproduction

### Local Repro

`python3.8 run_mlm.py --dataloader_drop_last True --dataset_config_name wikitext-103-v1 --dataset_name wikitext --do_train True --fp16 True --max_seq_length 512 --model_name_or_path bert-base-uncased --num_train_epochs 16 --per_device_train_batch_size 32 --preprocessing_num_workers 12
`
### AWS Repro

`
!pip install sagemaker
from sagemaker.pytorch import PyTorch
PyTorch(
framework_version='1.12',
py_version="py38",
instance_type="ml.p4d.24xlarge",
distribution={"pytorchddp": {"enabled": True}},
source_dir="examples/pytorch/language-modeling",
entry_point="run_mlm.py",
hyperparameters={
    'dataset_name': 'wikitext',
    'dataset_config_name': 'wikitext-103-v1',
    'do_train': True,
    'fp16': True,
    'model_name_or_path': 'bert-base-uncased',
    'num_train_epochs': 10,
    'per_device_train_batch_size': 32,
    'preprocessing_num_workers': 12,
},
).fit()
`

### Expected behavior

Training to completion without stalls/freezes at data preprocessing.

Currently the training stalls with the last log line being:
```
Grouping texts in chunks of 512
```

Comments:
Any update 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/main/CONTRIBUTING.md) are likely to be ignored.
CLIPProcessor.from_pretrained is None
Author: troilus-canva
Pull request: no

### System Info

transformers version: 4.20.1

### Who can help?

@patil-suraj

### Information

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

### Tasks

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

### Reproduction

from transformers import CLIPProcessor, CLIPModel

processor = CLIPProcessor.from_pretrained("openai/clip-vit-base-patch32")

### Expected behavior

returned processor without `TypeError: 'NoneType' object is not callable`.

Comments:
Could you try:
- updating Transforemrs to the latest version
- make sure you have all optional dependencies necessary for CLIP (PILlow mainly)

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.
Make the attention_head_size in distilbert an object attribute
Author: KarlFelixJoehnk
Pull request: yes

# What does this PR do?

It simply moves the attention_head_size in the distilbert model to be an object attribute. This is necessary if you want to use the Distilbert model in the nn_pruning library. It will also benefit anyone who ever needs to access the attention_head_size attribute from an instance of a Distilbert model. This change is consistent with other transformer models in this library (see BERT https://github.com/huggingface/transformers/blob/main/src/transformers/models/bert/modeling_bert.py#L253 or BART https://github.com/huggingface/transformers/blob/main/src/transformers/models/bart/modeling_bart.py#L157)

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

> Thanks for your PR. Could you just run `make style` on your branch to fix the quality issue?

Hi @sgugger, thanks for the quick approval. Just fixed the code style

Thanks again for your contribution!
Model bart cannot correctly process the length of attention_mask when the item of past_key_values is added.
Author: xyjigsaw
Pull request: no

### System Info

- `transformers` version: 4.18.0
- Platform: Linux-5.4.0-109-generic-x86_64-with-glibc2.31
- Python version: 3.9.12
- Huggingface_hub version: 0.2.1
- PyTorch version (GPU?): 1.11.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?: <fill in>
- Using distributed or parallel set-up in script?: <fill in>

### Who can help?

@patil-sura

### 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

execute the code:
`
outputs = self.bart(input_ids=input_ids,
                                attention_mask=attention_mask,
                                past_key_values=past_key_values,
                                labels=labels)
`
Model bart cannot correctly process the length of attention_mask when the item of past_key_values is added.

Additionally,

If someone uses past_key_values, it seems to raise the following exception:

`
RuntimeError: view size is not compatible with input tensor‘s size and stride ...
`
since bart executes torch.cat in BartAttention class:

`
key_states = torch.cat([past_key_value[0], key_states], dim=2)
`
`
value_states = torch.cat([past_key_value[1], value_states], dim=2)
`
Thus, we should make key_states and value_states contiguous.


@patrickvonplaten

---




### Expected behavior

It will run correctly.

Comments:
cc @ArthurZucker 

@xyjigsaw could you please add a complete reproducible code snippet here though? 

We cannot run:

```python
outputs = self.bart(input_ids=input_ids, attention_mask=attention_mask, past_key_values=past_key_values, labels=labels)
```

because we don't know what `input_ids`, etc... is.

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 warning for MCTC model
Author: sgugger
Pull request: yes

# What does this PR do?

In #20861, the warning introduced did not use the right direction for the test. This PR fixes that.
Fixes #21031

Comments:
Merging to fix the warning @ydshieh but can address any comment in a later PR :-) 

The docs for this PR live [here](https://moon-ci-docs.huggingface.co/docs/transformers/pr_21049). All of your documentation changes will be reflected on that endpoint.
Force_download=True not working, `No such file or directory: './.cache/models--togethercomputer--GPT-JT-6B-v1/refs/main'`
Author: bhavnicksm
Pull request: no

### System Info

- `transformers` version: 4.25.1
- Platform: Linux-5.15.0-57-generic-x86_64-with-glibc2.29
- Python version: 3.8.10
- Huggingface_hub version: 0.11.1
- PyTorch version (GPU?): 1.13.1+cu117 (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?: no
- Using distributed or parallel set-up in script?: no

### Who can help?

@younesbelkada @ArthurZucker 

### Information

- [ ] The official example scripts
- [ ] My own modified scripts

### Tasks

- [X] An officially supported task in the `examples` folder (such as GLUE/SQuAD, ...)
- [ ] My own task or dataset (give details below)

### Reproduction

Got the error while running the following command:

```python
from transformers import AutoTokenizer, AutoModelForCausalLM

tokenizer = AutoTokenizer.from_pretrained("togethercomputer/GPT-JT-6B-v1", cache_dir='./.cache/')
```


### Expected behavior

Should download the model anew rather than looking in the cache

Comments:
Hi, @bhavnicksm can you provide more information about your system (by using `transformers-cli env` in terminal) so that it will be easier to reproduce the code?  

Can you also tell us if there is folder `./.cache/` where you execute this code? Reading the error, it might simply be because the cache folder was not properly created.

@sgugger The cache folder gets created properly and there's the folder of that name, but the folder is not populated with any files. It's just empty.

Hi @susnato updated the original issue with the relevant information. Thanks for the suggestion to use `transformers-cli`. 

I ran your code snippet and cannot reproduce your issue. I also don't understand why that snippet of code should download anything anew and not look at the cache.

@sgugger the issue has been resolved, thanks for looking into it! 🫂

I believe it was a connection issue with the servers because even SentenceTransformers was giving a error but something about how it couldn't connect to HF.

They both started to work at the same time a few hours later. 

About the logic in the reproduction code, the default cache path wasn't working so providing another cache path with `force_download=True` might make it download again. Nevermind since it's been resolved 😄
Pushing T5ForConditionalGeneration to hub
Author: GravermanDev
Pull request: no

### System Info

- `transformers` version: 4.25.1
- Platform: Linux-5.10.147+-x86_64-with-glibc2.27
- Python version: 3.8.16
- Huggingface_hub version: 0.11.1
- PyTorch version (GPU?): 1.13.0+cu116 (True)
- Tensorflow version (GPU?): 2.9.2 (True)
- 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

### Who can help?

@Narsil

### Information

- [ ] 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

`trained_model.model.push_to_hub("model")`

```AttributeError                            Traceback (most recent call last)
[<ipython-input-21-b193d55bd628>](https://localhost:8080/#) in <module>
----> 1 trained_model.model.push_to_hub("model")

[/usr/local/lib/python3.8/dist-packages/torch/nn/modules/module.py](https://localhost:8080/#) in __getattr__(self, name)
   1263             if name in modules:
   1264                 return modules[name]
-> 1265         raise AttributeError("'{}' object has no attribute '{}'".format(
   1266             type(self).__name__, name))
   1267 

AttributeError: 'T5ForConditionalGeneration' object has no attribute 'push_to_hub'
```

### Expected behavior

I want to push T5ForConditionalGeneration to te hub, it doesn't work, I don't know if you need more info

Comments:
It will be very hard to help you without a reproducible example. `T5ForConditionalGeneration` is a `PreTrainedModel` and so does have a `push_to_hub` method.

Oh, I’m sorry, @sgugger, here is my code
https://colab.research.google.com/drive/1a59B4e8AooTFkUeMOs5Zsa0DIBWGM3k6?usp=sharing

the relevant part is at the bottom

during making a minimal example, the code started working, sorry for wasting your time, have a great day!