noamaanMulla-03/transformers-issues huggingface dataset:
Tensorflow example squad's run_qa.py miss token_type_ids inputs
Author: zhuango
Pull request: no
Labels: name: bug

### System Info

transformers==4.20.1, torch==1.9.0, tensorflow2==2.9.

### Who can help?

_No response_

### 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

Steps to reproduce the behavior

1. Download SQuADv.11 fine-tuned bert large weights from: https://huggingface.co/bert-large-uncased-whole-word-masking-finetuned-squad
2. Successfully reproduce the inference F1-score by runing this [pytorch example](https://github.com/huggingface/transformers/blob/main/examples/pytorch/question-answering/run_qa.py).
3. But fail to reproduce the inference f1-score by runing this [tensorflow2 example](https://github.com/huggingface/transformers/blob/main/examples/tensorflow/question-answering/run_qa.py).
4. The reason is the tensorflow example miss the token_type_ids inputs. I add this input at following position to solved this problem:

https://github.com/huggingface/transformers/blob/main/examples/tensorflow/question-answering/run_qa.py#L640
`        tensor_keys = ["attention_mask", "token_type_ids", "input_ids"]`

https://github.com/huggingface/transformers/blob/main/examples/tensorflow/question-answering/run_qa.py#L661
```
            eval_inputs = {
                "input_ids": tf.ragged.constant(processed_datasets["validation"]["input_ids"]).to_tensor(),
                "token_type_ids": tf.ragged.constant(processed_datasets["validation"]["token_type_ids"]).to_tensor(),
                "attention_mask": tf.ragged.constant(processed_datasets["validation"]["attention_mask"]).to_tensor(),
            }

```
https://github.com/huggingface/transformers/blob/main/examples/tensorflow/question-answering/run_qa.py#L681
```
            predict_inputs = {
                "input_ids": tf.ragged.constant(processed_datasets["test"]["input_ids"]).to_tensor(),
                "token_type_ids": tf.ragged.constant(processed_datasets["test"]["token_type_ids"]).to_tensor(),
                "attention_mask": tf.ragged.constant(processed_datasets["test"]["attention_mask"]).to_tensor(),
            }
```

### Expected behavior

Both pytorch and tensorflow example produce same F1-score based on [this weights](https://huggingface.co/bert-large-uncased-whole-word-masking-finetuned-squad).

Comments:
cc @Rocketknight1 

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.

This issue has been resolved by #18451
Adding TF Implementation of BEiT
Author: MadElf1337
Pull request: no
Labels: name: WIP

### Feature request

Addition of TF implementation of BEiT 

### Motivation

I have always seen that there is a discrepancy in the availability of models for PyTorch and the models available in TensorFlow, and want to have models for usage in both backends.

### Your contribution

I will add the implementation of BEiT in TF :)

cc - @gante

Comments:
cc @NielsRogge @amyeroberts 

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.

Hi @MadElf1337 do you have any updates? Are you still planning on contributing this model?   

Yep I’m still working on the model, had to keep it aside for a bit due to my uni exam schedule, but will start again the day my exams are over


Regarding the updates, I am done with the architecture, have to write the functions for specific purposes(like segmentation) and the tests

Great - glad to hear you're still interested :) 

As @NielsRogge pointed out, data2vec vision is an extension of BEiT. This means the porting should be a lot simpler! In our [pytorch BEiT implementation](https://github.com/huggingface/transformers/blob/main/src/transformers/models/data2vec/modeling_data2vec_vision.py#L310), you can see this from the `#Copied from` statements. Ideally the TF implementation would reflect this and be the same as our pytorch implementation, however TF data2vec vision is already implemented. So, we need to move the data2vec code to beit, and then add the necessary `#Copied from` statement in data2vec. Does this make sense? 

Could you open a draft PR for the model please so that the code is visible? 

Good luck with the last of your exams!

Yes I’ll open a draft PR to show the code that’s been done till date

And thanks!
Examples do not seem to work on any spaces right now (possible downtime?)
Author: ankrgyl
Pull request: no
Labels: name: bug

### System Info

This is observed online on spaces:

E.g. https://huggingface.co/spaces/nielsr/donut-docvqa, if you click any of the examples, you see
![Screen Shot 2022-08-30 at 4 06 41 PM](https://user-images.githubusercontent.com/565363/187558797-d0858c72-a580-4650-8f2d-b451f294da3d.png)

Similarly, https://huggingface.co/spaces/impira/docquery produces console errors like:

```
POST https://hf.space/embed/impira/docquery/api/predict/ 500
post_data @ index.09173af6.js:7790
(anonymous) @ index.09173af6.js:7872
(anonymous) @ index.09173af6.js:6566
(anonymous) @ index.09173af6.js:506
(anonymous) @ index.09173af6.js:505
click_handler_1 @ index.d284cf1a.js:1881
click_handler_1 @ index.d284cf1a.js:1346
```

I also tried https://huggingface.co/spaces/Epoching/DocumentQA.

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

Visit any space with examples, and try clicking on them.

### Expected behavior

The examples should populate.

Comments:
Hey @ankrgyl! I tried using them a few seconds ago and it seems to work; is the issue still happening from your side? It may have been a transient error.

It wasn't working until around 11:15 PM PST, at which point the website seem to have reset (see screenshot below) and ~10 minutes later, it started working.

![image](https://user-images.githubusercontent.com/565363/187689585-8ba4f00a-6606-4d04-9b7a-66f300bee25b.png)

During this period, I also noticed that deploying a gradio space with `enable_queue=False` would not work -- it seemed like something was broken with the `/predict` handler (which gets called in that case). I did some extensive testing while working with the Gradio team on https://github.com/gradio-app/gradio/issues/2132.

Understood, thank you! Should this be closed as it seems the error has been resolved?

Yes it can definitely be closed! I mostly opened it in case it was helpful as an alert while things were behaving weirdly.

Sounds good! Let me close it and feel free to reopen if you ever run into something similar.
Add type hints to XLM-Roberta-XL models
Author: asofiaoliveira
Pull request: yes

This PR adds type hints for the PyTorch XLM-Roberta-XL as mentioned in #16059 
@Rocketknight1

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

Hello @Rocketknight1 , just reminding you of this 

Hi @asofiaoliveira, I'm extremely sorry for the delay here! The PR is perfect, and I'm merging now!
T5 Tokenizer misses a space
Author: ari9dam
Pull request: no
Labels: name: bug

### System Info


```
tokenizer = AutoTokenizer.from_pretrained("t5-3b", use_fast=False)#metrics_util.tokenizer
tokenizer.decode(tokenizer("Intel unveils Project Alloy 'merged reality' headset")["input_ids"], skip_special_tokens=True)

Output: Intel unveils Project Alloy'merged reality' headset 
```
Note that the space between Alloy and 'merged reality' is missing.

System
---------------------
transformers == 4.21.0
python == 3.7.11
Ubuntu 18.04.6 LTS


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

from transformers import AutoTokenizer
tokenizer = AutoTokenizer.from_pretrained("t5-3b", use_fast=False)#metrics_util.tokenizer
print(tokenizer.decode(tokenizer("Intel unveils Project Alloy 'merged reality' headset")["input_ids"], skip_special_tokens=True))

### Expected behavior

Intel unveils Project Alloy 'merged reality' headset

Comments:
One workaround is adding `clean_up_tokenization_spaces=False` in tokenizer.decode

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 t5 for text generation
Author: sam-h-bean
Pull request: yes

# What does this PR do?

Add support for `T5ForConditionalGeneration` to the text generation pipeline


## Who can review?

@LysandreJik  @patrickvonplaten 


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

Thanks for opening the PR @sam-h-bean, can you explain a bit more why you require this change? Can't you use the text-to-text pipeline in your application to leverage T5 instead?

I'm **not** in favor of this PR as is because `T5ForConditionalGeneration` is clearly a different architecture (and input/output format) then `...CausalLM` which is GPT-like style

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.
TF to ONNX export fails with CLI using example from docs
Author: cchan-lm
Pull request: no
Labels: name: bug

### System Info

- `transformers` version: 4.21.1
- Platform: Linux-4.15.0-187-generic-x86_64-with-debian-buster-sid
- Python version: 3.7.5
- Huggingface_hub version: 0.8.1
- PyTorch version (GPU?): not installed (NA)
- Tensorflow version (GPU?): 2.7.0 (False)
- 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?

_No response_

### 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. Save a TF transformers model (from example at https://huggingface.co/docs/transformers/serialization)
```
from transformers import AutoTokenizer, TFAutoModelForSequenceClassification

# Load tokenizer and TensorFlow weights from the Hub
tokenizer = AutoTokenizer.from_pretrained("distilbert-base-uncased")
tf_model = TFAutoModelForSequenceClassification.from_pretrained("distilbert-base-uncased")
# Save to disk
tokenizer.save_pretrained("local-tf-checkpoint")
tf_model.save_pretrained("local-tf-checkpoint")
```

2. Use CLI to export to ONNX to see failure: `python -m transformers.onnx --model=local-tf-checkpoint onnx/`
3. Use `--framework` to use successfully: `python -m transformers.onnx --model=local-tf-checkpoint --framework=tf onnx/`

### Expected behavior

Once the model directory has been provided, the export should know that a TF model is being used. There should be no dependency on PyTorch (there is also no PyTorch in this environment). Instead, I get this error: `RuntimeError: Cannot export model to ONNX using PyTorch because no PyTorch package was found.`

Either `transformers` should be updated or the docs at https://huggingface.co/docs/transformers/serialization should be updated to say that `--framework=tf` for TensorFlow models is required.

Comments:
Hmmm that's interesting, indeed!

The docs should be updated, but it would be nice to also support this out of the box. Would you like to try your hand at a PR? 

cc @lewtun @michaelbenayoun @JingyaHuang for knowledge

Sure, I can try making a PR for it! Will be doing so from my personal account, @rachthree.

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.

Because PR https://github.com/huggingface/transformers/pull/18615 has been merged, I'm considering this closed.
BUG for beam_indices from model.generate()
Author: Hannibal046
Pull request: no
Labels: name: bug

### System Info

- `transformers` version: 4.22.0.dev0
- Platform: Linux-5.8.0-51-generic-x86_64-with-glibc2.10
- Python version: 3.8.13
- Huggingface_hub version: 0.8.1
- PyTorch version (GPU?): 1.12.1+cu113 (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-suraj, @patrickvonplaten, @LysandreJik

### 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
from transformers import BartTokenizer,BartForConditionalGeneration
model_path = "/data/pretrained_model/bart_base"
toker = BartTokenizer.from_pretrained(model_path)
model = BartForConditionalGeneration.from_pretrained(model_path)

input_tokens = ["what do you think it ? huggingface is a great library. And I enjoy it very much",
                "transformers is so good"]
batch_size = 2
num_beams = 10
max_length = 10
num_return_sequences = 5
input_ids = toker(input_tokens,return_tensors='pt',padding=True).input_ids
output=model.generate(input_ids,max_length=max_length,\
						num_beams=num_beams,num_return_sequences=num_return_sequences,\
						return_dict_in_generate=True,output_scores=True)
print(output.beam_indices)
```
![image](https://user-images.githubusercontent.com/38466901/187733097-195fda80-3b1f-4b59-898f-e2eacf10729d.png)
![image](https://user-images.githubusercontent.com/38466901/187734309-9fde1b06-3172-4730-97d6-42e953cbffc9.png)



### Expected behavior

This is super weird that `beam_indices` of second batch has indices in the first 10 beams. If calculate the average logits across the sentence according to this `beam_indices`, we won't get the `output.sequences_scores` So I think the number in the red box of the first picture should be added 10 (num_beams), if we add 10, we can get the correct token to be generated in `output.sequences[5]` as shown in the second picture

Comments:
Also, could you please check this ? https://discuss.huggingface.co/t/larger-sum-logits-larger-sum-probability/22358

Also cc @gante for `generate` :)

Hey @Hannibal046 👋 Thank you so much for raising this issue, there was indeed a problem with the last beam index for all batches except the first one!

Check #18851 for the fix and for snippets that confirm the correctness after the fix 🤗 

Regarding the forum issue -- it seems like a relevant problem. Could you please open an issue here on GitHub? ❤️
Fix decode_input_ids to bare T5Model and improve doc
Author: ekagra-ranjan
Pull request: yes

# What does this PR do?

* Fix 1: use the tokenizer to obtain the labels as tensors. `docs/source/en/model_doc/t5.mdx`
*  Fix 2: `src/transformers/models/t5/`
    * Present case: T5 prepends the decoder_input_ids with pad token. This preprocessing is handled internally by `T5ForConditionalGeneration` by shifting the labels to the right. 
    * Issue: This preprocessing needs to be done manually while using bare T5Model. This is missing from the example which uses bare T5Model.
    * Proposed Fix: Added a preprocessing step in the example so that the input matches with what T5 expects at its decoder. The PR reuses the `_shift_right()` method which is an internal function to T5. Please let me know if we can rename `_shift_right()` to `shift_right()` or if there is a better way to handle this.


## Before submitting
- [X] 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?


@sgugger @patrickvonplaten @patil-suraj


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

Thanks for the fixes! 

@patrickvonplaten Thanks for the review! Applied your suggestions.
Fix `test_tf_encode_plus_sent_to_model` for `LayoutLMv3`
Author: ydshieh
Pull request: yes

# What does this PR do?

The recently added `TFLayoutLMv3Model` triggered the test `test_tf_encode_plus_sent_to_model`, which needs to prepare an extra argument `boxes` when calling tokenizer methods, otherwise we get an error

```bash
>               for word, box in zip(text, boxes):
E               TypeError: 'NoneType' object is not iterable
```

[Currently failed test](https://github.com/huggingface/transformers/runs/8173669915?check_suite_focus=true)

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

A question -- PT has an equivalent tokenizer test, yet I don't see this test being overwritten in PT's `layoutlmv3`. Do you know why that happens? 🤔 

> A question -- PT has an equivalent tokenizer test, yet I don't see this test being overwritten in PT's layoutlmv3. Do you know why that happens?

Hi @gante I guess you are talking about 
https://github.com/huggingface/transformers/blob/dae0bfc525dd9867a2c9f5917cbf551fb9cc1732/tests/models/layoutlmv3/test_tokenization_layoutlmv3.py#L1154
(I didn't realized there is a PT version for this test until now)

That test method uses `boxes` (and overwrites the common one), see
https://github.com/huggingface/transformers/blob/dae0bfc525dd9867a2c9f5917cbf551fb9cc1732/tests/models/layoutlmv3/test_tokenization_layoutlmv3.py#L1185

I can change this PR to be more like that PT test.

Oh, right! I was looking for the test in the wrong file :)
Update no trainer scripts to include gather for metrics
Author: arun99481
Pull request: yes

# What does this PR do?

Update run_wav2vec_pretraining_no_trainer example to include accelarator.gather_metrics

Related to #18437 

I ran the tests for tests for 'wav2vec_pretraining_no_trainer'  in 'test_pytorch_examples.py' files locally.

## 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?
- [x] 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.
- [x] 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?
@muellerzr  , @sgugger , @pacman100 
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._
Further reduce the number of alls to head for cached objects
Author: sgugger
Pull request: yes

# What does this PR do?

This PR completes #18534 and leverages the cache system of files that do not exist at a given commit in a repo introduced in the last release of `huggingface_hub` (by this [PR](https://github.com/huggingface/huggingface_hub/pull/986)) to further reduce the numbers of calls to the API when trying to load configurations/models/tokenizers/pipelines to just 1 call **every time** the object is cached and the current commit is the same one as the distant repo for the given revision.

cc @Narsil 




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

and also cc @Wauplin :)

Yes, my plan was to port this to `hugginface_hub` next, along with the commi_hash argument (which does not exist there yet), to then be able to use the function of `huggingface_hub` after the next release!

Thanks for the reviews, will address comments later this morning.
unpin slack_sdk version
Author: ydshieh
Pull request: yes

# What does this PR do?

The issue in Slack SDK 3.18.2 was fixed in 3.18.3, so no longer need to pin 3.18.1.

For more details, see
https://github.com/slackapi/python-slack-sdk/pull/1259#issuecomment-1237731450
https://github.com/slackapi/python-slack-sdk/issues/1261

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