noamaanMulla-03/transformers-issues huggingface dataset:
Fix docs for decoder_input_ids in BART.
Author: ShaneTian
Pull request: yes

Fix docs for `decoder_input_ids` in BART.
Fix #15691

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

Done.
Please review again.

Thanks! However, as you can see, the CI needs all checks passing before we can merge this PR.

For this to pass, you need to run `make fixup` locally and make sure all quality and style checks pass. For more information, please read [this guide](https://huggingface.co/docs/transformers/contributing).

<img width="943" alt="Screenshot 2022-02-18 at 11 28 45" src="https://user-images.githubusercontent.com/48327001/154672136-9cb64b92-d785-4f7e-8b2e-ee9ca8060ebe.png">



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.
Fix prepare_for_model error inconsistency
Author: r-stiller
Pull request: yes

# What does this PR do?
The model default parameters in the `tokenization_utils_base.prepare_for_model` function are fetched after the parameter sanity check. This causes the sanity check to not recognize wrong parameter combinations when using model defaults.
This PR swaps those two.

Fixes #15679

- tokenizers: @n1t0, @LysandreJik

## Code to test:
Prepare:
```
from transformers import AutoTokenizer
tokenizer = AutoTokenizer.from_pretrained('bert-base-uncased')
sentences = ['Sentence number one.',
             'Sentence number two is longer to trigger padding.']

token_ids = tokenizer.batch_encode_plus(
    sentences,
    add_special_tokens=True,
    truncation=False,
    padding=False)
token_ids = token_ids['input_ids']
```

Test:
```
try:
	  tokenizer.prepare_for_model(
	      token_ids,
	      add_special_tokens=False,
	      padding='longest',
	      truncation=False,
	      return_token_type_ids=None) # Uses the model default
except Exception as e:
	e1 = e	

try: 
	  tokenizer.prepare_for_model(
	      token_ids,
	      add_special_tokens=False,
	      padding='longest',
	      truncation=False,
	      return_token_type_ids=True) # Explicitly set to true
except Exception as e:
	e2 = e

assert type(e1) is type(e2) and e1.args == e2.args
```

The error code of Test_01 and Test_02 should be the same.

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

This issue has been automatically marked as stale because it has not had recent activity. If you think this still needs to be addressed please comment on this thread.

Please note that issues that do not follow the [contributing guidelines](https://github.com/huggingface/transformers/blob/master/CONTRIBUTING.md) are likely to be ignored.
DebertaForMaskedLM cannot load the parameters in the MLM head from microsoft/deberta-base
Author: tqfang
Pull request: no

my env:

```
transformers    4.15.0
```

```
from transformers import AutoModelForMaskedLM
model = AutoModelForMaskedLM.from_pretrained("microsoft/deberta-base")
```

The warning goes like:

```
Some weights of the model checkpoint at microsoft/deberta-base were not used when initializing DebertaForMaskedLM: ['deberta.embeddings.position_embeddings.weight', 'lm_predictions.lm_head.dense.bias', 'lm_predictions.lm_head.dense.weight', 'lm_predictions.lm_head.bias', 'lm_predictions.lm_head.LayerNorm.weight', 'lm_predictions.lm_head.LayerNorm.bias']
- This IS expected if you are initializing DebertaForMaskedLM from the checkpoint of a model trained on another task or with another architecture (e.g. initializing a BertForSequenceClassification model from a BertForPreTraining model).
- This IS NOT expected if you are initializing DebertaForMaskedLM from the checkpoint of a model that you expect to be exactly identical (initializing a BertForSequenceClassification model from a BertForSequenceClassification model).
Some weights of DebertaForMaskedLM were not initialized from the model checkpoint at /home/tfangaa/Downloads/ptlm/deberta-base/ and are newly initialized: ['cls.predictions.bias', 'cls.predictions.transform.dense.weight', 'cls.predictions.transform.LayerNorm.weight', 'cls.predictions.transform.dense.bias', 'cls.predictions.decoder.weight', 'cls.predictions.transform.LayerNorm.bias']
You should probably TRAIN this model on a down-stream task to be able to use it for predictions and inference.
```

It seems that the checkpoints provided by `microsoft/deberta-base` doesn't possess the weights needed for the MLM head, so that DebertaForMaskedLM cannot be directly used for masked token prediction.

Is this a bug of the DebertaForMaskedLM class or the checkpoints provided by Microsoft? Thanks!



Comments:
Pinging @BigBird01 on the issue

does someone know the answer?

This issue has been automatically marked as stale because it has not had recent activity. If you think this still needs to be addressed please comment on this thread.

Please note that issues that do not follow the [contributing guidelines](https://github.com/huggingface/transformers/blob/master/CONTRIBUTING.md) are likely to be ignored.

I see the same problem, and this is not only  true for base but also for base-v3 so I would say it is error in code.
Add ONNX export for BeiT
Author: akuma12
Pull request: yes

# What does this PR do?

Based on the fantastic work by @lewtun in https://github.com/huggingface/transformers/pull/15658, I added ONNX export support for the Microsoft BeiT model.

# Usage
```
import requests
import numpy as np
from PIL import Image
from onnxruntime import InferenceSession
from transformers import AutoConfig, AutoFeatureExtractor, AutoModelForImageClassification

# Export ViT checkpoint with image classification head
model_ckpt = "microsoft/beit-base-patch16-224"
!python -m transformers.onnx --model={model_ckpt} --feature=image-classification onnx/

# Download an image of two cute cats - naturally ;-)
url = "http://images.cocodataset.org/val2017/000000039769.jpg"
image = Image.open(requests.get(url, stream=True).raw)

# Instantiate config and feature extractor
config = AutoConfig.from_pretrained(model_ckpt)
feature_extractor = AutoFeatureExtractor.from_pretrained(model_ckpt)
inputs = feature_extractor(image, return_tensors="np")

# Create ONNX Runtime session
session = InferenceSession("onnx/model.onnx", providers=["CPUExecutionProvider"])
outputs = session.run(["logits"], dict(inputs))
predicted_class_idx = np.argmax(outputs[0])
# Returns Predicted class: Egyptian cat
print("Predicted class:", config.id2label[predicted_class_idx])
```


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

Thanks for your PR, super cool!
Tensorboard logger logs to same directory when trial is pruned using hp_search and optuna
Author: fschlatt
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.11.3
- Platform: Linux 
- Python version: 3.8.8

### Who can help
@sgugger 

## Information

I am running a hyperparameter search on various models using optuna on a modified GLUE task. Whenever optuna prunes a trial, the following trial is logged into the same logging directory and therefore doesn't show up in Tensorboard. As far as I can tell, the immediate easy fix would be to call the `on_train_end` callback when the trial is to be pruned. This would reset the tensorboard logger and has worked for me in testing. I'm not sure if it has any unwanted side effects, though. I've opened a Pull Request fixing the issue.



Comments:
Fix Bart type hints
Author: gchhablani
Pull request: yes

# What does this PR do?

This PR adds type-hints to PLBart PyTorch.

A few queries:
1. What about the configuration files? Do they not need type-hinting?
2. I understand someone is working on the BART model: https://github.com/huggingface/transformers/pull/16270/files. There are some copies on there, can I wait for that PR to be merged and see if there are any fixes needed after doing `make fixup` from their PR?

@Rocketknight1

Comments:
Hi @gchhablani that is correct. We have just merged the BART PR, which has overwritten parts of `modeling_plbart.py`. Please check if any further changes are needed to `modeling_plbart.py` - if they are, you can either submit a new PR for them, or rebase this PR onto the updated main/master branch.

But also, thanks for doing this - your PR looks very solid otherwise! 

@Rocketknight1 I have tried to make things a bit more consistent with Bart.
For example:
1. One place was using `torch.FloatTensor` for `encoder_attention_mask`, which should be `torch.LongTensor`.
2. Another discrepancy was that `encoder_hidden_states` were `FloatTensor` in one place, while `Tensor` in another.
3. `input_ids` are actually optional because we can also pass `input_embeds` but it was not present.
4. `past_key_values` was `List[torch.Tensor]` in some places, while `Tuple[torch.Tensor]` in some. Not 100% sure which is correct. I used `List` for now.

PLBart has some additional changes, which may be included. Wdyt?

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

Hi @gchhablani I think this PR is quite difficult to review right now because of all the changes! If possible, could you close this PR, make sure your local repo is updated to the latest changes, then make a new branch and make the plBART PR there? I think if you do that, and only add annotations to the methods that are missing them, then we shouldn't have the problem of multiple affected files.

Thanks, and I'm sorry for the confusion here!

Hi @Rocketknight1!

Sure!
What about the issues with BART?

I think the changes in BART and PLBart are the only ones that need reviewing. Wdyt?

I think it's fine to focus on plBART for this PR. The issues with BART aren't serious, and if we decide to be consistent with `Tuple` or `List` across the whole repo, we can do that with a simple find-replace. So in your plBART PR, don't worry about making changes that will also require changes to BART - just annotate missing types for methods that don't have any yet, and that's perfect!

@Rocketknight1 Can you please review it now?
Thanks!

Looks great to me, thanks for the PR!
Adding missing type hints for mBART model (PyTorch)
Author: reichenbch
Pull request: yes

PyTorch Implementation model added with missing type hints

# What does this PR do?

Added type hints for mBART PyTorch as described in https://github.com/huggingface/transformers/issues/16059


## 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?


## Who can review?

@Rocketknight1 @gante 
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._

Hi, this looks good, and I'm sorry for the delay! I'm guessing the failing tests are due to issues we fixed recently, and would go away if you rebased the PR onto the most recent `huggingface/transformers/main` and force-pushed. If you're not sure how to do that, just ping me here or on Discord and I'll give you instructions!
Remove MBart subclass of XLMRoberta in tokenzier docs
Author: gchhablani
Pull request: yes

# What does this PR do?
This PR removes the line mentioning MBartTokenizer is a subclass of XLMRobertaTokenizer in the fast tokenizer.
@sgugger @patil-suraj 

Comments:
_The documentation is not available anymore as the PR was closed or merged._
add code samples for TF speech models
Author: ydshieh
Pull request: yes

# What does this PR do?

Add:

- TF_SPEECH_BASE_MODEL_SAMPLE
- TF_SPEECH_CTC_SAMPLE

I tested them manually with TFWav2Vec2 (not through doctest).


## Remark:

The following samples are not translated to TF, since I couldn't find models like `TFWav2Vec2ForSequenceClassification`.

- PT_SPEECH_SEQ_CLASS_SAMPLE,
- PT_SPEECH_FRAME_CLASS_SAMPLE,
- PT_SPEECH_XVECTOR_SAMPLE,

Comments:
_The documentation is not available anymore as the PR was closed or merged._
Added spanish translation of autoclass_tutorial.mdx
Author: duedme
Pull request: yes

# Translation of autoclass_tutorial.mdx into spanish

I made the translation of autoclass_tutorial.mdx into Spanish (fixes https://github.com/huggingface/transformers/issues/15947). The document is located in the transformers/docs/source_es folder.

@omarespejel 

## 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/master/CONTRIBUTING.md#start-contributing-pull-requests),
      Pull Request section?



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

Thank you @Duedme! 🤗

@sgugger LGTM 👍 

There are a lot of conflicts in your branch, for just one added file. I think the easiest to fix this is to copy your file, create a new fresh branch from the main branch and open a new PR, as I can't review the diff here :-)
[WIP] Integrate OSLO for tensor parallelism support
Author: jaketae
Pull request: yes

# What does this PR do?

This PR integrates [OSLO](https://github.com/tunib-ai/oslo) in a similar fashion to DeepSpeed. OSLO enables tensor parallelism and kernel fusion, among others.

## To-do
- [ ] Tests
- [ ] Adding OSLO as dependency
- [ ] Review/discuss model save logic

## Who can review?


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

To-do's for self-documentation:

- [ ] Revisit `should_save`
- [ ] Test with DDP and FairScale
- [ ] Think about how to toggle `merge_checkpoint`
- [ ] Debug DeepSpeed (model param size 1)
- [ ] Use `oslo_initialized` attribute to check if OSLO was initialized MPU

Unstale

Closing due to changes in OSLO's API as discussed internally. This PR will be superseded by a future PR once OSLO 3 is released and stable.
How to create vocab.txt for run_mlm.py
Author: ralgond
Pull request: no

hi, I am training a model from scratch. (I set "--train_file ./train_uncased.txt") 

I run script run_mlm.py with argument "--tokenizer_name bert-base-chinese" 

However, I can not find some words (which is in train_uncased.txt) in the file vocab.txt.

could someone tell me how to  create a vocab.txt 

Thanks

Comments:
Pretrained model for sequence to sequence question answering
Author: dharakotecha
Pull request: no

Hi,
Is there a model available which has been trained on sequence to sequence question answering with the SQUAD v1/v2 dataset?
I could not find any in the huggingface model hub.


Comments:
Hi,

Yes there are a few available. I filtered on "question-answering", and the following seq2seq models:
* "bart": https://huggingface.co/models?pipeline_tag=question-answering&sort=downloads&search=bart
* "t5": https://huggingface.co/models?pipeline_tag=question-answering&sort=downloads&search=t5

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.

Hi
Thanks for your response @NielsRogge. 
I meant a generative question answering model trained on SQuAD. This implies that the model is trained with an objective to generate answer sequence unlike the objective to predict start and end index of the answer. 

Hi,

There are a few available, like this one: https://huggingface.co/valhalla/t5-small-qa-qg-hl

Thanks @NielsRogge 
This is exactly what I am looking for.
Fix flax import in `__init__.py`: `modeling_xglm -> modeling_flax_xglm`
Author: stancld
Pull request: yes

# What does this PR do?

This PR fixes import statement in `src/transformers/models/xglm/__init__.py` file: `modeling_xglm -> modeling_flax_xglm`.

## 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?


## 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:

- albert, bert, xlm: @LysandreJik
- blenderbot, bart, marian, pegasus, encoderdecoder,  t5: @patrickvonplaten, @patil-suraj
- longformer, reformer, transfoxl, xlnet: @patrickvonplaten
- fsmt: @stas00
- funnel: @sgugger
- gpt2: @patrickvonplaten, @LysandreJik
- rag: @patrickvonplaten, @lhoestq
- tensorflow: @LysandreJik

Library:

- benchmarks: @patrickvonplaten
- deepspeed: @stas00
- ray/raytune: @richardliaw, @amogkam
- text generation: @patrickvonplaten
- tokenizers: @n1t0, @LysandreJik
- trainer: @sgugger
- pipelines: @LysandreJik

Documentation: @sgugger

HF projects:

- datasets: [different repo](https://github.com/huggingface/datasets)
- rust tokenizers: [different repo](https://github.com/huggingface/tokenizers)

Examples:

- maintained examples (not research project or legacy): @sgugger, @patil-suraj
- research_projects/bert-loses-patience: @JetRunner
- research_projects/distillation: @VictorSanh

 -->

@patil-suraj 

Comments:
_The documentation is not available anymore as the PR was closed or merged._
How to fine-tune the models on huggingface hub with run_mlm.py
Author: ralgond
Pull request: no

Say I have a corpus, I want to use it to fine-tune a model which is on huggingface hub, How should I do?

Thanks.

Comments:
Hi @ralgond 👋 Our documentation probably has the information you need, check [this page](https://huggingface.co/docs/transformers/main/en/training#finetune-a-pretrained-model) (for instance). The documentation is searchable, try looking for the keywords related to your problem. Alternatively, in the `run_mlm.py` script, try running with `--help` to have a description of the arguments. I hope this helps! :D 

We also reserve these 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/) 🤗 I'm closing this issue, but feel free to reopen with queries that fit the criteria I described.
Add use_auth to load_datasets for private datasets to PT and TF examples
Author: KMFODA
Pull request: yes

# What does this PR do?

As per https://github.com/huggingface/transformers/issues/16235 this PR adds the capability to run examples that use trainer on private datasets by adding the use_auth variable to the load_datasets function.

## 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.
- [ ] 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?

@sgugger

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

@sgugger sure thing! I had already added for TF and have just added for Flax. Some examples didn't have `use_auth_token` as a model argument so I added that as well.

Thanks a lot for all your work on this!