noamaanMulla-03/transformers-issues huggingface dataset:
Unable to load BART model, AttributeError: module 'jax.ops' has no attribute 'index_update'
Author: ayaka14732
Pull request: no

## Environment info

- `transformers` version: 4.17.0
- Platform: Linux-5.11.0-1018-gcp-x86_64-with-glibc2.31
- Python version: 3.10.4
- PyTorch version (GPU?): not installed (NA)
- Tensorflow version (GPU?): not installed (NA)
- Flax version (CPU?/GPU?/TPU?): 0.4.1 (tpu)
- Jax version: 0.3.4
- JaxLib version: 0.3.2
- Using GPU in script?: no
- Using distributed or parallel set-up in script?: no

### Who can help

@patil-suraj @patrickvonplaten

## Information

Model I am using: BART

The problem arises when using:
* [x] the official example scripts

## To reproduce

Steps to reproduce the behavior:

```python
>>> from transformers import FlaxBartForSequenceClassification
>>> model = FlaxBartForSequenceClassification.from_pretrained('facebook/bart-base')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/ayaka/venv310/lib/python3.10/site-packages/transformers/modeling_flax_utils.py", line 550, in from_pretrained
    model = cls(config, *model_args, **model_kwargs)
  File "/home/ayaka/venv310/lib/python3.10/site-packages/transformers/models/bart/modeling_flax_bart.py", line 933, in __init__
    super().__init__(config, module, input_shape=input_shape, seed=seed, dtype=dtype)
  File "/home/ayaka/venv310/lib/python3.10/site-packages/transformers/modeling_flax_utils.py", line 116, in __init__
    random_params = self.init_weights(self.key, input_shape)
  File "/home/ayaka/venv310/lib/python3.10/site-packages/transformers/models/bart/modeling_flax_bart.py", line 939, in init_weights
    input_ids = jax.ops.index_update(input_ids, (..., -1), self.config.eos_token_id)
AttributeError: module 'jax.ops' has no attribute 'index_update'
```


Comments:
https://jax.readthedocs.io/en/latest/jax.ops.html#module-jax.ops

> The functions jax.ops.index_update, jax.ops.index_add, etc., which were deprecated in JAX 0.2.22, have been removed. Please use the [jax.numpy.ndarray.at](https://jax.readthedocs.io/en/latest/_autosummary/jax.numpy.ndarray.at.html#jax.numpy.ndarray.at) property on JAX arrays instead.


Fixed in #16078
Add doctests for albert, bert, bigbird, mobilebert
Author: vumichien
Pull request: yes

# What does this PR do?

Add doctests for albert, bert, bigbird, mobilebert

## 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?
@patrickvonplaten @ydshieh 

Comments:
Wav2Vec2 Speech Pre-Training After a few epochs the contrastive loss was decreased to zero and the model stopped changing
Author: umairahmad-ua
Pull request: no

I tried to re-run the demo script with the same parameters on Colab. After a few epochs, the contrastive loss was decreased to zero and the model stopped changing. Original Script can be found here: https://github.com/huggingface/transformers/tree/master/examples/pytorch/speech-pretraining

Here is sample code [Colab](https://colab.research.google.com/drive/1IDwie_Te_2GntHay_zZ-oPvriNsacQ8d?usp=sharing):

sample output:

  ```
| loss: 9.969e-02| constrast_loss: 0.000e+00| div_loss: 9.969e-01| %_mask_idx: 5.137e-01| ppl: 
  2.000e+00| lr: 1.572e-03| temp: 1.902e+00| grad_norm: 8.068e-19
  
  | loss: 9.969e-02| constrast_loss: 0.000e+00| div_loss: 9.969e-01| %_mask_idx: 4.952e-01| ppl: 
  2.000e+00| lr: 1.572e-03| temp: 1.902e+00| grad_norm: 4.017e-19
  
  
  | loss: 9.969e-02| constrast_loss: 0.000e+00| div_loss: 9.969e-01| %_mask_idx: 4.831e-01| ppl: 
  2.000e+00| lr: 1.572e-03| temp: 1.902e+00| grad_norm: 5.166e-19
```

I used the parameters given in the README file so this behavior is unexpected and may indicate a different problem.

Is this a bug in the official feature or am i doing some mistake if so please help how can I fix this problem?

@patrickvonplaten @anton-l 

Comments:
Hey @umairahmad-ua,

I was using 8 GPUs - in a simple colab you get just a single GPU, so I think the effective batch_size is very much different which then quickly loads to a collapse of the `contrastive_loss`. TBH, I dont' think you can reproduce the training in a single colab (you would have to let it run for 4 weeks to see significant changes)

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.

It's interesting, I have the same problem when pre-train wav2vec2 on my own datasets, and the div_loss cannot go down at same value (9.969e-01).
I set batch_size=16, single GPU.
`FeaturesManager.get_model_from_feature` should be a staticmethod
Author: andylolu2
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.17.0
- Platform: Linux (Pop!_OS)
- Python version: 3.9.6
- PyTorch version (GPU?): 1.9.0+cu111
- Tensorflow version (GPU?): /
- Using GPU in script?: No
- Using distributed or parallel set-up in script?: No

### Who can help

@michaelbenayoun who committed #14358 

## Information

Type error for Pylance in VsCode: 
![Screenshot from 2022-03-22 23-42-33](https://user-images.githubusercontent.com/66584117/159596983-44a93943-7568-41af-8026-e99a1c2c06d1.png)

## Fix

https://github.com/huggingface/transformers/blob/77321481247787c97568c3b9f64b19e22351bab8/src/transformers/onnx/features.py#L336-L345

I believe the above function should have the `@staticmethod` decorator.


Comments:
R3M: A Universal Visual Representation for Robot Manipulation
Author: edbeeching
Pull request: no
Labels: name: New model

# 🌟 New model addition

## Model description
We pre-train a visual representation using the Ego4D human video dataset using a combination of time-contrastive learning, video-language alignment,and an L1 penalty to encourage sparse and compact representations. The resulting representation, R3M, can be used as a frozen perception module for downstream policy learning. Across a suite of 12 simulated robot manipulation tasks, we find that R3M improves task success by over 20% compared to training from scratch and by over 10% compared to state-of-the-art visual representations like CLIP and MoCo. Furthermore, R3M enables a Franka Emika Panda arm to learn a range of manipulation tasks in a real, cluttered apartment given just 20 demonstrations.
<!-- Important information -->

## Open source status

* [x] the model implementation is available:(https://github.com/facebookresearch/r3m)
* [x] the model weights are available: https://github.com/facebookresearch/r3m/blob/main/r3m/example.py
* [x] who are the authors: @suraj-nair-1 


Comments:
generate text function support part of the  target inputs
Author: lonelydancer
Pull request: no
Labels: name: wontfix

# 🚀 Feature request

<!-- A clear and concise description of the feature proposal.
     Please provide a link to the paper and code in case they exist. -->
https://pytorch.org/docs/stable/generated/torch.nn.Transformer.html?highlight=transformer#torch.nn.Transformer

in pytorch transformer class, we can see the forward function can pass target sentence; so when i wanna to generate the target_sentence from the middle , i can pass part of the target_sentence to the model, then i can generate the rest of the sentence.
## Motivation
the generate function is really powerful.
Here is my situation, i have the full source sentence and certain part of the target sentence, then i begin to generate the rest of the target sentence, using beam search etc..
But i found the interface do not support part of target sentence as input.

<!-- 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:
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.


hi, did you solve this problem?
Rename master to main for notebooks links and leftovers
Author: sgugger
Pull request: yes

# What does this PR do?

This PR prepares the switch in the notebooks repo default branch from master to main and also catches a few leftovers master that were in the links to transformers GitHub. There are also a few links that were badly converted when moving to the new doc frontend that are fixed (transformers-doc2mdx -> transformers)

Comments:
fixed typo from enable to disable in disable_progress_bar function
Author: Gladiator07
Pull request: yes

# What does this PR do?

This PR fixes the typo from `Enable progress bar` to `Disable progress bar` in `disable_progress_bar()` function's documentation.

- [x] This PR fixes a typo or improves the docs (you can dismiss the other checks if that's the case).

Comments:
@sgugger can you please review this PR?

_The documentation is not available anymore as the PR was closed or merged._
Inference API with GPT2 {"error": "Unknown error"}
Author: nbravulapalli
Pull request: no

### Who can help


@Narsil 
@LysandreJik 

## Information

When I try to use the Inference API with gpt2, I am receiving a response saying there is an `Unknown error`. I have used the same codebase for a few months now, initially it was working, then the API started returning errors about cuda (only when using gpu), then the API was working again, now the API is returning  `{'error': 'Unknown error'}` for both CPU and GPU inference.

## To reproduce

headers = {"Authorization": f"Bearer {BEARER}"}
API_URL = "https://api-inference.huggingface.co/models/gpt2"
data = json.dumps({"inputs": 'Here is a sentence that I like', "parameters":{"num_return_sequences":1,  "max_length":1},"options": {"wait_for_model": False, "use_cache": False, "use_gpu":False}})
response = requests.request("POST", API_URL, headers=headers, data=data)
test_output = json.loads(response.content.decode("utf-8"))


## Expected behavior

Returns the generated completion by gpt2


Comments:
```python
import json
import os

API_TOKEN = os.getenv("API_TOKEN")

import requests

headers = {"Authorization": f"Bearer {API_TOKEN}"}
API_URL = "https://api-inference.huggingface.co/models/gpt2"


def query(payload):
    data = json.dumps(payload)
    response = requests.request("POST", API_URL, headers=headers, data=data)
    return json.loads(response.content.decode("utf-8"))


data = query(
    {
        "inputs": "The answer to the universe is",
        "parameters": {"num_return_sequences": 1, "max_length": 1},
        "options": {"wait_for_model": False, "use_cache": False, "use_gpu": False},
    }
)

print(data)
```

This seems to work currently. Are you sure about your Bearer ? (It shouldn't produce `unknown error` anyway, but I fail to see what's wrong in your code).
Can you share a little your environmnet too ? (Python version, requests version)

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.
TrOCR not working anymore after 4.16.2 update
Author: thetruejacob
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.16.2
- Platform:  Colab
- Python version: 3.8?
- PyTorch version (GPU?): latest in colab
- Tensorflow version (GPU?):
- Using GPU in script?: Yes
- Using distributed or parallel set-up in script?:

### Who can help
Models:
TrOCR @NielsRogge  

I believe something has happened to the Trainer class that now makes evaluation of NielsRogge's TrOCR  model run into a bug. 

I have reproduced his notebook here, and encountered the bug when using the latest transformers version. 
  https://colab.research.google.com/drive/1ZcwbH_JzBMT7M84eDkUw9eJRqBxyofkB?usp=sharing



Comments:
Thanks for reporting, this has been fixed in #15603.

For now, you have to install from source to have it: 

`pip install git+https://github.com/huggingface/transformers`

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.
Cannot set deterministic=False for FlaxRobertaPreTrainedModel, therefore dropout doesn't work?
Author: gmaratos
Pull request: no

Looking at FlaxRobertaPreTrainedModel's [call function](https://github.com/huggingface/transformers/blob/db7d6a80e82d66127b2a44b6e3382969fdc8b207/src/transformers/models/roberta/modeling_flax_roberta.py#L610), there doesn't seem to be a way to set deterministic=False. Therefore, when it calls self.module.apply it leaves deterministic on its default (True). This isn't necessarily a problem if you just want to do inference with the model, but if we want to fine tune then we cannot use dropout. Is there some other place to set this argument that I am missing?

Comments:
Actually as far as I can tell, the argument train: bool is acting as the deterministic switch. So if I set train=True, then dropout is used. The documentation could use some explanation in my opinion, and also it needs to be explained how if this is true then we need to provide a dropout seed.

Hi, you are right. `train` is used to control the `deterministic` arg, which is only used in internal modules. All public-facing models expose `train` arg to prevent this. And yes, this should be documented. 

>  also it needs to be explained how if this is true then we need to provide a dropout seed.

The seed is provided when initialising/loading the model, and the default is `True`. And the dropout seed is created by splitting this main seed.

Would you like to open a PR to add the docstring for `train` arg  ? We'll need to update this for all models in the `..._INPUTS_DOCSTRING` variable.

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.
tf.concatenate does not exist
Author: pedro-r-marques
Pull request: no

## Environment info
Any

### Who can help
@Rocketknight1

## Information

BERT TFBertSelfAttention layer calls a function `tf.concatenate` when given a `past_key_value` parameter. This function does not exist in the TF 2.0 API. The correct function name is `tf.concat`.

## To reproduce

Call a TFBertLayer layer with a non nil `past_key_value` argument.

## Expected behavior

The code should be modified to use `tf.concat` instead.

Comments:
Good spot! Would you be willing to submit a PR? If not, don't worry, let us know and we'll do it instead.

I will try to submit a PR. It will probably take me a few days to craft a test case that exercises this functionality.

Hi, this is my fault in my PR: #13222. There are a few files involved, in particular, the TF template file

```
transformers\templates\adding_a_new_model\cookiecutter-template-{{cookiecutter.modelname}}\test_modeling_tf_{{cookiecutter.lowercase_modelname}}.py
```

I am sorry about this mistake. @pedro-r-marques If you still want to open the PR, could you also fix the other models that have `tf.concatenate`, please? Thank you!

Hi @pedro-r-marques 

Would it be OK for me to submit a PR for this issue? Or you want to contribute once you have the time?

@ydshieh Please do go ahead. I didn't have the opportunity to reproduce the use case for `past_key_value`.

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.
TF PushToHubCallback fixes and updates
Author: Rocketknight1
Pull request: yes

We had a couple of reports of slowdown and hanging with the `PushToHubCallback`. In particular, when training finished, there was a very long wait for the last training checkpoint to be pushed before the end-of-training commit could start, which sometimes seemed like it had hung completely. As a workaround, the end-of-training push now cancels any previous pushes with `terminate()` (thanks @LysandreJik!) before it starts, to save time and avoid this problem. This works well in testing.

However, there is a secondary problem - when we do an end-of-training push, we probably don't want to save a whole checkpoint with things like optimizer state, as they can be very large. Right now the `PushToHubCallback` does not delete checkpoint data in the output dir when it pushes at the end of training, and also does not squash commits (so if it cancels a checkpoint push and then starts the end-of-training push, it has to push the commit that includes the checkpoint data even if it's been deleted in the end-of-training commit).

I think we should definitely delete the checkpoint data in the final push, and possibly also squash commits to make the upload a lot faster (and reduce the size of the target repo). I can make these changes in this PR - WDYT?

CC: @merveenoyan 

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

Will do!
[FlaxSpeechEncoderDecoder] Fix feature extractor gradient test
Author: sanchit-gandhi
Pull request: yes

Applies new logic to the `assert_difference` statement in the FlaxSpeechEncoderDecoderModel test. For two arrays `a` and `b`, we compute the absolute difference between the arrays: `diff = np.abs(a - b)`.  Only one element of the absolute difference array `diff` has to be greater than the specified tolerance `tol` for the statement to pass. This is in contrary to the previous implementation, in which the _minimum_ of `diff` had to exceed `tol`. This provides more robustness to the `test_freeze_feature_encoder` test and enables the tolerances to be set to more reasonable values. The modified test passes locally over 20 repeat runs.

Comments:
_The documentation is not available anymore as the PR was closed or merged._
Fix Typo in Argument of FlaxWav2Vec2ForPreTrainingModule
Author: sanchit-gandhi
Pull request: yes

This PR amends a typo in the `freeze_feature_encoder` argument to the `call` function in FlaxWav2Vec2ForPreTrainingModule and it's subsequent use in the Wav2Vec2 module.

Comments:
_The documentation is not available anymore as the PR was closed or merged._
Add TF implementation of GPT-J model
Author: stancld
Pull request: no

# 🚀 Feature request

Add TF implementation of GPT-J model

## Motivation

Narrow the gap between PT and TF implementations.

## Your contribution

I'd like to work on this.

Comments:
Good luck.

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.

active #15623
Create concept guide section
Author: stevhliu
Pull request: yes
Labels: name: Documentation

This PR wraps up the IA migration:

- Created a Conceptual Guide section and migrated docs that are explanatory.
- Created a separate page in Conceptual Guides for this [section](https://huggingface.co/docs/transformers/main/en/preprocessing#everything-you-always-wanted-to-know-about-padding-and-truncation) about padding and truncation from the Preprocess doc.
- Reorganized table of contents to group similar topics together like contributing (how to add model/pipeline/testing etc.). Feel free to suggest any changes :)
- Renamed [Create a custom ~~model~~](https://huggingface.co/docs/transformers/main/en/create_a_model) to `architecture` based on @NielsRogge feedback that this guide only describes how to customize the architecture from the config. Also feel free to suggest another title here, I'm not too excited with what I have right now. The title should be distinct from [Sharing custom models](https://huggingface.co/docs/transformers/main/en/custom_models), which actually shows you how to write your own custom config and model.
- Updated the `index` to reflect how the docs are organized.
- Removed older versions of docs that have been updated ([fine-tune ](https://huggingface.co/docs/transformers/main/en/custom_datasets )and [multilingual](https://huggingface.co/docs/transformers/main/en/multilingual)).

Comments:
_The documentation is not available anymore as the PR was closed or merged._
Is it possible to train all the models available in hub using deepspeed?
Author: srulik-ben-david-hs
Pull request: no

If not, how to know which ones?
Specifically, I interested in sentence-transformers models. 
(is it possible at all to train them using transformers api?)

@nreimers @stas00 

thanks!





Comments:
more or less yes, please see https://github.com/huggingface/transformers/pull/12695 - I don't have 100% coverage of all models but the majority of popular models work just fine as seen by the tests.

I'm not rushing to merge that PR since it's just many tests.

If you find any that don't work please report and we will make it work.

amazing. thanks for your help.