noamaanMulla-03/transformers-issues huggingface dataset:
TF: use the correct config with `(...)EncoderDecoder` models
Author: gante
Pull request: yes

# What does this PR do?

Fixes #18071 

Modifies `unpack_inputs` to ignore the config file for `(...)EncoderDecoder` models, mimicking the behavior in PT. If we don't ignore it, then unset options will get set with the config's default (`False` for most of them), causing the inner models to ignore their own config files.

⚠️ I've added a corresponding test for the `EncoderDecoder` models. I then noticed that other `(...)EncoderFecoder` tests have copy/pasted their own `EncoderDecoderMixin`, so I've left the other classes for a follow-up PR with the following question: should a common `EncoderDecoderMixin` be defined and shared across `(...)EncoderDecoder` tests, or should I add a similar test to all other classes individually?

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

I believe they are -- going to give it a go afterwards if @ydshieh also agrees :)

I have limited connection at this moment in the mountain, so feel free to merge if you prefer. Regarding the common mixin, good for me. I see there are a few little things to address, like the input names (input_ids, pixel values etc).
Would be nice if you do this refactorization after merging my PR about the PT/TF equivalence tests, or incoperate the change in it 🙏 

Thank you for the fix, @gante

@ydshieh can I have a review plz 🙏 

@ydshieh rebased with main and reran tests -- all working 👍
Fix torch version check in Vilt
Author: ydshieh
Pull request: yes

# What does this PR do?

This line fails when torch < 1.10.0
https://github.com/huggingface/transformers/blob/1fc4b2a13223b9069f9969344117a2994261939c/src/transformers/models/vilt/modeling_vilt.py#L44

In  this case, `torch.__version__` is of type `str` instead of `torch.torch_version.TorchVersion` and can't compare to a tuple.

This leads to strange error message when other models being tested, for example (the use of `get_values` below)

```
    def test_training(self):
        for model_class in self.all_model_classes:
            ....
            if model_class in get_values(MODEL_MAPPING):
                continue
```

Comments:
cc @LysandreJik: This is *one* of the reasons why there are more failures in PyTorch past CI.

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

Oops, you approved before I tag 😄
__init__() got an unexpected keyword argument '_name_or_path'
Author: rajnishrajput12
Pull request: no
Labels: name: bug

### System Info

```shell
sentence_transformer versiob 2.2.0
windows
python version- 3.9.12
```


### 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

I am trying the following code :-
1. it gave me error no file "C:\\Users\\ra*****\\Downloads\\bert-base-nli-mean-tokens\\1_Pooling\\config.json"
the i create folder 1_Pooling and kept the downloaded json but then it gave me error
2.__init__() got an unexpected keyword argument '_name_or_path'
NOTE:- I downloaded all the files from https://huggingface.co/sentence-transformers/bert-base-nli-mean-tokens/tree/main"
from sentence_transformers import SentenceTransformer
embedder = SentenceTransformer(r'C:\Users\raj****\Downloads\bert-base-nli-mean-tokens')
corpus = ['A man is eating food.',
          'A man is eating a piece of bread.',
          'The girl is carrying a baby.',
          'A man is riding a horse.',
          'A woman is playing violin.',
          'Two men pushed carts through the woods.',
          'A man is riding a white horse on an enclosed ground.',
          'A monkey is playing drums.',
          'A cheetah is running behind its prey.']
corpus_embeddings = embedder.encode(corpus)
sentence_transformer version 2.2.0

### Expected behavior

```shell
we should be able to load the sentence_transformer from local
```


Comments:
Hi @rajnishrajput12 

It might be better to ask on the [community tab](https://huggingface.co/sentence-transformers/bert-base-nli-mean-tokens/discussions) of the model on the Hub. Otherwise, on [sentence-transformers](https://github.com/UKPLab/sentence-transformers) repository.


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.

Close as this is a question for the library `sentence_transformer`
Change how `take_along_axis` is computed in DeBERTa to stop confusing XLA
Author: Rocketknight1
Pull request: yes

The previous code for `take_along_axis()` in DeBERTa used dynamic TF shapes like `tf.shape()` and `tf.rank()` in conditionals. This is a data-dependent conditional, which is forbidden in XLA.

Replacing these with the static shape equivalents `x.shape` and `x.shape.rank` works fine, and now DeBERTa can be compiled successfully with XLA.

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

@gante The original torch code used `take_along_axis`, so I guess this is a complete TF reimplementation of it! That approach makes way more sense, though - let me make some changes!

> The original torch code used take_along_axis

That would explain it!
Not able to load the Facebook OPT model
Author: xiajinxiong
Pull request: no
Labels: name: bug

### System Info

- `transformers` version: 4.20.1
- Platform: Linux-5.4.0-122-generic-x86_64-with-glibc2.10
- Python version: 3.8.3
- Huggingface_hub version: 0.5.1
- PyTorch version (GPU?): 1.7.1 (True)
- Tensorflow version (GPU?): 2.6.0 (True)
- Flax version (CPU?/GPU?/TPU?): not installed (NA)
- Jax version: not installed
- JaxLib version: not installed

### Who can help?

@LysandreJik


### 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

```python
import torch
from transformers import AutoModelForCausalLM, AutoTokenizer

model = AutoModelForCausalLM.from_pretrained("facebook/opt-13b", torch_dtype=torch.float16)
```

Errors:

KeyError                                  Traceback (most recent call last)

<ipython-input-15-00179d7539d3> in <module>
      2 from transformers import AutoModelForCausalLM, AutoTokenizer
      3 
----> 4 model = AutoModelForCausalLM.from_pretrained("facebook/opt-13b", torch_dtype=torch.float16)

~/workspace/anaconda3/lib/python3.8/site-packages/transformers/models/auto/auto_factory.py in from_pretrained(cls, pretrained_model_name_or_path, *model_args, **kwargs)
    421         kwargs["_from_auto"] = True
    422         if not isinstance(config, PretrainedConfig):
--> 423             config, kwargs = AutoConfig.from_pretrained(
    424                 pretrained_model_name_or_path, return_unused_kwargs=True, trust_remote_code=trust_remote_code, **kwargs
    425             )

~/workspace/anaconda3/lib/python3.8/site-packages/transformers/models/auto/configuration_auto.py in from_pretrained(cls, pretrained_model_name_or_path, **kwargs)
    670 
    671         Examples:
--> 672 
    673         ```python
    674         >>> from transformers import AutoConfig

~/workspace/anaconda3/lib/python3.8/site-packages/transformers/models/auto/configuration_auto.py in __getitem__(self, key)
    385         ("xlsr_wav2vec2", "XLSR-Wav2Vec2"),
    386         ("yolos", "YOLOS"),
--> 387         ("yoso", "YOSO"),
    388     ]
    389 )

KeyError: 'opt'

### Expected behavior

The code is expected to run with any error.

Comments:
Hey @xiajinxiong, this seems to be a version error!

In order to verify, could you run the following snippet and copy-paste the output?

```
import torch
from transformers import AutoModelForCausalLM, AutoTokenizer, __version__

print("Version", __version__)
model = AutoModelForCausalLM.from_pretrained("facebook/opt-13b", torch_dtype=torch.float16)
```

I reaffirmed that the transformers version was 4.20.1.
But it's because my jupyter kernel didn't synchronize with the transformers version.
After I restart the jupyter, it works fine.
Thanks.

I reaffirmed that the transformers version was 4.20.1.
But it's because my jupyter kernel didn't synchronize with the transformers version.
After I restart the jupyter, it works fine.
Thanks.
BLOOM model parameters mentioned in hub-docs
Author: muhammad-ahmed-ghani
Pull request: no

<h3>The model mentioned in Hugging-face hub is actually 176B parameters model by BLOOM. But written as 175B in "docs/source/en/model_doc/bloom.mdx"</h3>
<h4>Visit below link to confirm</h4>

[link](https://huggingface.co/docs/transformers/model_doc/bloom)

![image](https://user-images.githubusercontent.com/63394104/179976308-46ecf0d0-41b8-44e8-bc19-c6c1d60d2969.png)


Comments:
Is the position of the scheduler.step() correct?
Author: AdityaSoni19031997
Pull request: no

## ❓ Questions & Help

In the [lm_finetuning_file](https://github.com/huggingface/transformers/blob/master/examples/run_lm_finetuning.py#L285-L319), the scheduler used is "get_linear_schedule_with_warmup" which in turn uses the underlying "LambdaLR" [ref](https://github.com/huggingface/transformers/blob/594ca6deadb6bb79451c3093641e3c9e5dcfa446/src/transformers/optimization.py#L47);

On a careful study of the file, the "scheduler" is being called for every batch, but that isn't what's as per the official PyTorch [docs](https://pytorch.org/docs/stable/optim.html#torch.optim.lr_scheduler.LambdaLR) to change LR since they are calling it at "epoch-level",

```
>>> lambda1 = lambda epoch: epoch // 30
>>> lambda2 = lambda epoch: 0.95 ** epoch
>>> scheduler = LambdaLR(optimizer, lr_lambda=[lambda1, lambda2])
>>> for epoch in range(100):
>>>     train(...)
>>>     validate(...)
>>>     scheduler.step()
```

I meant it makes sense to me to do it at batch level change the lr etc but not sure why the PyTorch has it differently?

Thanks.

Comments:
Why this issue were left without an answer? I don't know what is the answer, but it seems that this scheduler should be executed at batch-level since there are other examples using batch-level instead of epoch-level: https://github.com/huggingface/transformers/blob/8e8384663d716d4b5a4f510070ff954fc0ba4a52/examples/research_projects/bert-loses-patience/run_glue_with_pabee.py.

Anyway, LambdaLR is a generic LR scheduler which PyTorch provides in order to implement other LR schedulers. It is true that PyTorch docs talks about epoch-level, but there are other LR schedulers, like [CyclicLR scheduler](https://pytorch.org/docs/stable/generated/torch.optim.lr_scheduler.CyclicLR.html), which explicitely indicates that has to be executed at batch-level. Since LambdaLR is a generic LR scheduler, this scheduler will need to be executed at batch-level or epoch-level depending on the specifid LR scheduler implemented. For the linear LR scheduler of the issue, I guess that the correct is to be executed at batch-level, or even could be adapted to epoch level if you want, but taking a look at the scripts of the repository, they use batch-level.
DensePhrase: StopIteration: Caught StopIteration in replica 0 on device 0.
Author: xixiaoyao
Pull request: no
Labels: name: bug

### System Info

```shell
densephrase == 1.0

- `transformers` version: 2.9.0
- Platform: Linux-4.14.0_1-0-0-39-x86_64-with-centos-7.9.2009-Core
- Python version: 3.7.13
- PyTorch version (GPU?): 1.9.0 (True)
- Tensorflow version (GPU?): not installed (NA)
- Using GPU in script?: <fill in>
- Using distributed or parallel set-up in script?: <fill in>
```


### Who can help?

I installed densephrase absolutely followed with readme, [here](https://github.com/princeton-nlp/DensePhrases)

and when I run `make draft MODEL_NAME=test`，it raises error as follows.

![image](https://user-images.githubusercontent.com/24541791/173757450-0f05b89a-ba95-4c6c-a17e-358331e44ce2.png)


### 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

after installed densephrase(https://github.com/princeton-nlp/DensePhrases), just run:

make draft MODEL_NAME=test

### Expected behavior

```shell
no error
```


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.
Difference in the number of data during deep learning
Author: rurujisu
Pull request: no
Labels: name: bug

### System Info

```shell
Python 3
```


### 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

import matplotlib.pyplot as plt
import matplotlib.tri as tri
import numpy as np
import pandas as pd
from keras.models import Sequential
from keras.layers import Dense, Activation

input = pd.read_csv('D:\\puri\\capture\\3_1\\all\\inlet.csv', sep='\t', skiprows=0)
output = pd.read_csv('D:\\puri\\capture\\3_1\\all\\output.csv', sep='\t', skiprows=0)

model = Sequential([
    Dense(32, input_shape=(784,)),
    Activation('relu'),
    Dense(10),
    Activation('softmax'),
])

model = Sequential()
model.add(Dense(32, input_dim=784))
model.add(Activation('relu'))



### Expected behavior

```shell
hi i just started studying machine learning
I followed the machine learning example, but I can't apply it, so I'm asking here


I want to know the correlation between input data and output data, 
but the number of input data is 500(500 x 7) and the number of output data is 1.8 million(1.8M x 4). In this case, what model should I study?
(inlet variables : 7, output variables : 4)

And i have 5 input-output cases, is that enough to find the correlation?

Thanks for reading let me know if I need to find another way
```


Comments:
Hi @rurujisu  👋 As per our [issues guidelines](https://github.com/huggingface/transformers/blob/main/ISSUES.md), we reserve GitHub issues for bugs in the repository and/or feature requests. For any other requests, we'd like to invite you to use our [forum](https://discuss.huggingface.co/) 🤗 

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.
Add Checkpoint Loading from MLflow Model Registry
Author: sam-h-bean
Pull request: no

### Feature request

I would like the ability to pass a model URI that points to a model in an MLflow model registry then load a HuggingFace transformer directly from the registry. 

### Motivation

Model versioning and lifecycle management is a common practice in MLOps so I think it makes sense for this to be a first-class feature in HuggingFace.

### Your contribution

I already have this functional but would like to contribute it back to the project so others can leverage the MLflow model registry to maintain their model lifecycles from development to production!

Comments:
@sgugger this is linked to https://github.com/huggingface/transformers/pull/17686

The code I have working currently looks like 

```python
import os
import mlflow
import glob


def download_from_registry(src_path, dst_path):
    if not os.path.isdir(dst_path):
        os.mkdir(dst_path)

    mlflow.pyfunc.load_model(src_path, dst_path=dst_path)

    return glob.glob(os.path.join(dst_path, "artifacts", "checkpoint-*"))[0]

model_path = download_from_registry("models:/my-model/1", "./my-model/")
model = AutoModelForSequenceClassification.from_pretrained(model_path)
```

and I'm wondering what you think this would look like contributed to the open-source. The code above only works once you have logged the checkpoint as an artifact and registered that model in the MLflow registry. However, it could be factored to also load the model from an MLflow run I think. wdyt?

Hi @sam-h-bean !

We do not plan on supporting other model repositories than our model Hub for the `from_pretrained` method in Transformers. You should build a bridge to upload those checkpoints from MLFlow to the Hub and benefit from all the goodies we have such as the inference widget, model cards, community PRs etc. 😃 

Your solution also works since we support local checkpoints, and only takes three lines of code as you demonstrated 😉 

Hey @sgugger does the Hub have support for private models? These are proprietary models and thus can not be made public. What is the suggest method for cases such as this? It seems like this is a case that will become more prevalent as more companies adopt large language models.

Yes, you can have private models/datasets/spaces on the Hub. See the [doc](https://huggingface.co/docs/hub/repositories-settings#private-repositories)!

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.
Can't Run UL2
Author: cliangyu
Pull request: no
Labels: name: bug

### System Info

- `transformers` version: 4.20.1
- Platform: Linux-5.4.0-81-generic-x86_64-with-glibc2.31
- Python version: 3.10.4
- Huggingface_hub version: 0.8.1
- PyTorch version (GPU?): 1.12.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 distributed or parallel set-up in script?: I guess I tried :)

### Who can help?

@patrickvonplaten , led porting UL2.

### Information

- [ ] The official example scripts
- [X] 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

```python
with init_empty_weights():
    model = OPTModel.from_pretrained("facebook/opt-30b", device_map="auto", offload_folder='./offload_folder').to('cuda')
```
Error message
```python
Exception has occurred: ValueError
weight is on the meta device, we need a `value` to put in on 1.
  File "/media/ntu/volume1/home/s121md302_06/workspace/code/yalb/ul2_test.py", line 25, in <module>
    model = T5ForConditionalGeneration.from_pretrained("google/ul2", low_cpu_mem_usage=True, torch_dtype=torch.bfloat16, device_map='auto').to('cuda')
```
![image](https://user-images.githubusercontent.com/45140242/179469229-5784bc16-9405-489d-b493-838b7f290710.png)


### Expected behavior

I expect the model to be successfully loaded with sharded parameters.

Comments:
Looks like lm_head.weight is causing the problem. But I thought this item was in _keys_to_ignore_on_load_missing of T5ForConditionalGeneration. How could this happen?

google/ul2 · Splitting the model of multiple GPU's
https://huggingface.co/google/ul2/discussions/4
Skip passes report for `--make-reports`
Author: ydshieh
Pull request: yes

# What does this PR do?

We sometimes have timeout on CircleCI. It turns out that the tests are finished (running in the workers, which exit at the end), but the main process is busy doing some reporting work when we specify `--make-reports`. More precisely, it is the `passes` report which takes time (as we include `Pp` in `tr.reportchars = "wPpsxXEf"`). From the 2 screenshots below (running with 64 models), we can see that currently it takes extra ~2-3 minutes at the end.

It seems that  `passes` report doesn't contain any useful information to us, therefore this PR skips generating it to avoid timeout.

- **without this PR**
<img width="448" alt="no-fix" src="https://user-images.githubusercontent.com/2521628/180396971-69f19b12-978b-4e19-8842-17d1af307d51.png">

- **with this PR**
<img width="452" alt="fix" src="https://user-images.githubusercontent.com/2521628/180396917-bb866363-efa3-4959-b5e3-e99ab283cc6c.png">

### One failed CircleCI job run
[Job](https://app.circleci.com/pipelines/github/huggingface/transformers/43738/workflows/325901ce-948e-4737-9a79-8a7fe9d6e27d/jobs/506868/resources)

<img width="452" alt="real" src="https://user-images.githubusercontent.com/2521628/180399481-a7f571bc-75f3-4826-b5d5-8c50c3164678.png">



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

Same as Sylvain :)
Update all no_trainer scripts
Author: muellerzr
Pull request: yes
Labels: name: External

name: Examples

# What does this PR do?

This PR updates the `no_trainer` scripts with the latest capabilities in accelerate:
- Includes gradient_accumulation wrapper
- Adds the `gather_for_metrics` wrapper
- Removes the explicit `step` param since it breaks wandb trackers (it will never be pushed)


## Before submitting
- [ ] This PR fixes a typo or improves the docs (you can dismiss the other checks if that's the case).
- [x] Did you read the [contributor guideline](https://github.com/huggingface/transformers/blob/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?

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