noamaanMulla-03/transformers-issues huggingface dataset:
Model isn't saved on "save_steps" 
Author: puraminy
Pull request: no

I am trying to train a T5 model on Colab Using examples, I run the following code:

```
!python run_t5_mlm_flax.py \
	--output_dir="/content/drive/MyDrive/Pouramini/" \
	--model_type="t5" \
	--config_name="/content/drive/MyDrive/Pouramini/" \
	--tokenizer_name="/content/drive/MyDrive/Pouramini/" \
	--dataset_name="oscar" \
	--dataset_config_name="unshuffled_deduplicated_fa" \
	--max_seq_length="512" \
	--per_device_train_batch_size="64" \
	--per_device_eval_batch_size="64" \
	--adafactor \
	--learning_rate="0.005" \
	--weight_decay="0.001" \
	--warmup_steps="2000" \
	--overwrite_output_dir \
	--logging_steps="500" \
	--save_steps="100" \
	--eval_steps="100"
```
Since I want to be able to resume the model train, I set `save_steps` on 100. However, while the progress bar shows step 
```
  7% 510/7794 [1:11:36<24:59:20, 12.35s/ba]
```
There is nothing in my `output_directory` except for config and tokenizer json files, which existed before training.

Comments:
I also set  `--max_steps="150"  ` to see if it saves the model after 150 steps, but nothing happened and it's still running in step 300!!

Thank you for reporting this! I will take a look.

@patil-suraj  Okay, it's now training. In fact, it was in pre-processing stages for dataset and I though it's training. Now it saves the model on "save_steps".
fix issue #13904 -attribute does not exist- 
Author: oraby8
Pull request: yes

# What does this PR do?

The PR addresses the issue #13904
I have changed file "auto_factory.py" and replace self._mapping to self._modle_mapping in line 559


## 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/master/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/master/docs), and
      [here are tips on formatting docstrings](https://github.com/huggingface/transformers/tree/master/docs#writing-source-documentation).
- [ ] Did you write any new necessary tests?


## Who can review?
@sgugger
@LysandreJik
Anyone in the community is free to review the PR once the tests have passed.




Comments:
Predicted Start_index < Predicted End_index in BertForQuestionAnswering
Author: JHH11
Pull request: no

We want to fine-tuned a QA model, which is based on BertForQuestionAnswering. 
After training, we can get a span-start/end scores by input_ids/token_type_ids/attention_mask and choose the indices with maximum span-start/end scores as **predicted start_index** and **predicted end_index**.
But, sometimes **predicted start_index** would less than **predicted end_index**.
If any reasonable method to solve this situation, thanks~

Ex:
`span-start scores = [-0.1, -2.1, 0.7, 1.3, 4.1]`
`span-end scores = [-0.7, 3, 5, -0.7, 3.3]`
`=>`
`predicted start_index = 4`
`predicted end_index = 2`

It is not reasonable.

Comments:
Hello, thanks for opening an issue! We try to keep the github issues for bugs/feature requests.
Could you ask your question on the [forum](https://discuss.huggingface.co) instead?

Thanks!

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.
How to use BertForSequenceClassification for the Apect Based Sentiment Analysis
Author: pawanGithub10
Pull request: no

In Aspect based sentiment analysis the sentence is classified in two way one is aspect and one is sentiment.
e.g. 
"The food is good but service is poor"
The output must be 
aspect food 
sentiment positive
aspect service
sentiment 
negative

So how to configure the BertForSequenceClassification so that two output can be generated for the apsect classification and the sentiment classification.



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/master/CONTRIBUTING.md) are likely to be ignored.
`pipeline` backed with ONNX Runtime and quantization for faster inference
Author: xegulon
Pull request: no

# 🚀 Feature request

<!-- A clear and concise description of the feature proposal.
     Please provide a link to the paper and code in case they exist. -->

It would be cool, when we load a pipeline, to do, during the loading, the conversion to an ONNX `InferenceSession` along with (optionally) the quantization, as these features provide significant speedups. About the live conversion, maybe it could have been done before, i.e. we could load the `.onnx` file from the Hub (among other model assets). Anyway, the main goal is the use of the speedups provided by ONNX Runtime in the pipeline object.

One would instantiate the `pipeline` object that way:
```python
nlp = pipeline('text-classification', onnx_runtime=True, quantization=True)
```
Reference: https://onnxruntime.ai/docs/tutorials/inferencing/huggingface.html

## Motivation

<!-- 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. -->

The speed and memory (with quantization) gains.

## 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 -->

I could try :)

Comments:
@sgugger @LysandreJik find this interesting?

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.
bert obtained different results on mac and linux
Author: HankAlpha
Pull request: no

I ran same code locally on my mac and remotely on linux through JupyterNotebook, and got different result.
Code is as follows:

from transformers import BertTokenizer, BertModel
tokenizer = BertTokenizer.from_pretrained('bert-base-chinese')
inputs = tokenizer('回复新浪网友对博文【国家文物局限制鉴宝节目现场估价转】的评论：;;查看原文：', return_tensors="pt")
model = BertModel.from_pretrained('bert-base-chinese')
model.eval()
outputs_trans = model(**inputs)

I compared model on mac and model on linux, they have same state dict, the inputs are the same, but I got different outputs_trans.

transformers: 4.11.3

Comments:
[Consistency] Make sure all xxxForSequenceClassification models support problem_type
Author: NielsRogge
Pull request: no

A while ago (#11012), an additional attribute called `problem_type` has been added to `xxxForSequenceClassification` models, which you can set to "multi_label_classification", "single_label_classification" or "regression" to fine-tune `xxxForSequenceClassification` models for the respective problem. This makes sure the appropriate loss function is used.

This is great, however, 3 things need to be improved in my opinion:

* this is causing a bit of an inconsistency as it's not implemented in all models which have an `xxxForSequenceClassification` head model.
* it's also not included in any of the CookieCutter templates, which are used to add new models.
* this is not documented anywhere.

cc @abhishekkrthakur 

Comments:
Pretty sure it is documented :) 
https://huggingface.co/transformers/main_classes/configuration.html

Agree that its not in cookie-cutter and its not implemented for all models (it cannot be implemented for all). :)

![image](https://user-images.githubusercontent.com/1183441/131682585-2d0b4a83-0885-4536-81bd-e6b46a78eecd.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.
[TMP] Do not merge.
Author: Narsil
Pull request: yes

<!--
Congratulations! You've made it this far! You're not quite done yet though.

Once merged, your PR is going to appear in the release notes with the title you set, so make sure it's a great title that fully reflects the extent of your awesome contribution.

Then, please replace this with a description of the change and which issue is fixed (if applicable). Please also include relevant motivation and context. List any dependencies (if any) that are required for this change.

Once you're done, someone will review your PR shortly (see the section "Who can review?" below to tag some potential reviewers). They may suggest changes to make the code even better. If no one reviewed your PR after a week has passed, don't hesitate to post a new comment @-mentioning the same persons---sometimes notifications get lost.
-->

<!-- Remove if not applicable -->

Fixes # (issue)


## 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/master/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/master/docs), and
      [here are tips on formatting docstrings](https://github.com/huggingface/transformers/tree/master/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

 -->

Comments:
Was just a temp to fix some tests.
Honor existing attention mask in tokenzier.pad
Author: sgugger
Pull request: yes

# What does this PR do?

In #13914, it was highlighted that the `tokenizer.pad` method erases existing `attention_mask` instead of padding them. While it should definitely create them if they don't exist, it shouldn't erase a mask that is passed.
This PR addresses that and adds a common test.

Fixes #13914 

Comments:
about 'text-generation': how can I generate sentences with multiply words? 
Author: Weifeng-Chen
Pull request: no

For example. Given "apple", "table", I want to generate a sentence like " an apple on the table"


Comments:
Hello, thanks for opening an issue! We try to keep the github issues for bugs/feature requests.
Could you ask your question on the [forum](https://discuss.huggingface.co) instead?

Thanks!

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.
TrainingArguments default parameters throw error (evaluation_strategy, save_strategy)
Author: GuillemGSubies
Pull request: no


So `evaluation_strategy` default value is `"no"` while the default for `evaluation_strategy` is `"steps"`. This will result in an error:

https://github.com/huggingface/transformers/blob/76c4d8bf26de3e4ab23b8afeed68479c2bbd9cbd/src/transformers/training_args.py#L684

### Who can help

- trainer: @sgugger


I could make a PR but changing the default values of something is a breaking change, I don't know if you have any specific procedure to do this.

Comments:
That's only when using `load_best_model_at_end` though, so not the real defaults. We can't change the defaults of other arguments without making a breaking change, so yes, when using `load_best_model_at_end=True` you need to set an `evaluation_strategy` and a `save_strategy` that match.

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.
Make username optional in hub_model_id
Author: sgugger
Pull request: yes

# What does this PR do?

This PR makes the username in the `hub_model_id` optional, by checking whether there is a "/" in it and adding the username if needed. Since no one is allowed to push to base repo IDs (like `"bert-base-cased"`) anymore, this shouldn't lock any usecase while making the API delightfully easier.

Comments:
Feature request : add leave=True to dataset.map to enable tqdm nested bars (and whilst we're at it couldn't we get a way to access directly tqdm underneath?)
Author: BenoitDalFerro
Pull request: no

Furthering tqdm integration #2374 and #11797 solutioned by #12226 provided with tqdm description as `desc='`, it would be so nice to be able to nest HuggingFace `Datasets.map()` progress bars in the grander scheme of things and whilst we're at it why not other functions.

By the way is there not a way to directly interact with underlying tqdm module ? `**kwargs-ish`?

@sgugger @bhavitvyamalik

Comments:
If you are requesting that the `Dataset.map` method accept this kwarg, you should open the feature request on the [Datasets repo](https://github.com/huggingface/datasets).

Woops indeed, done :)
Error: Attribute does not exist
Author: BeaBea1234
Pull request: no

https://github.com/huggingface/transformers/blob/77770ec79883343d32051cfb6a04f64523cd8df1/src/transformers/models/auto/auto_factory.py#L559

shouldn't this be _model_mapping? 

Comments:
Ah, very possibly! cc @sgugger 

Yes, that's a typo. Do you want to suggest a PR to fix it, since you found it?

Closed by #13942 

I'm seeing that this has already been fixed. Thank you, this is helping me a lot! For when is the new release scheduled?
Add support for tf2 encoder_decoder
Author: thevasudevgupta
Pull request: no
Labels: name: New model

# 🌟 New model addition

I would like to add `TensorFlow-2` support for `encoder_decoder` model. I will soon create a PR, if this is approved.

Comments:
Shall I start working on it if no one else is doing it?

Feel free to give it a try and tag me if you encounter any issues along the way! Just to set expectations, such a PR will be a longer project (~1 month) and is a relatively low priority for the library at the moment, so I might not be able to reply daily. 

But nevertheless, I'm more than happy to guide you through a PR :-) 

Thanks! I will start the PR soon :)
Add TrOCR + VisionEncoderDecoderModel
Author: NielsRogge
Pull request: yes

# What does this PR do?

This PR adds the [TrOCR models](https://github.com/microsoft/unilm/tree/6f60612e7cc86a2a1ae85c47231507a587ab4e01/trocr) by Microsoft, together with a new `VisionEncoderDecoderModel` class (which should be used in order to use TrOCR, as it consists of an image encoder and an autoregressive text decoder). This PR is very similar to #13186, it's just the vision counterpart. 

Here's how to use this model:

```
from transformers import TrOCRProcessor, VisionEncoderDecoderModel
import requests
from PIL import Image

processor = TrOCRProcessor.from_pretrained("microsoft/trocr-base-handwritten")
model = VisionEncoderDecoderModel.from_pretrained("microsoft/trocr-base-handwritten")

url = "https://fki.tic.heia-fr.ch/static/img/a01-122-02.jpg"
image = Image.open(requests.get(url, stream=True).raw).convert("RGB")
pixel_values = processor(image, return_tensors="pt").pixel_values

generated_ids = model.generate(input_ids=pixel_values)
print(processor.batch_decode(generated_ids)[0])
```

There's also this Colab notebook for quick inference: https://colab.research.google.com/drive/1qCuqlqc4V9LZhPkxIi_XqCCTQrDhkmHi?usp=sharing

! A big disclaimer: the TrOCR models do not directly work on entire images of PDFs etc. They are trained on single-text-line images. One needs a text detector first, before applying TrOCR. TrOCR is a text recognition model, not a text detection model. One typically needs both in a sequence in order to extract all text from a given image.

## Important note:

The current design of the existing `EncoderDecoderModel`/`FlaxEncoderDecoderModel` is that, if the `hidden_size` of the encoder/decoder don't match, one creates a single projection layer to project the `encoder_hidden_states` to the same number of channels as the decoder. However, for TrOCR, this is not how it's done. Instead, one projects the `encoder_hidden_states` to the same dimension as the decoder when projecting to keys and values, in each decoder layer. Therefore, my proposal is to add an attribute to the config of the decoder called `encoder_hidden_size`, which, if specified, will be used in the `VisionEncoderDecoderModel` class to not project the encoder hidden states. Instead, it will be used when instantiating the key and value projection layers.

For consistency, we could also add this to the existing EncoderDecoderModel/FlaxEncoderDecoderModel. Also relevant for the FlaxVisionEncoderDecoderModel PR, see #13359.

## To do:

- [ ] currently you have to pass `input_ids=pixel_values` to the `generate` method, which is not ideal. I'm in favor of letting the generate method accept an argument called `inputs`, which can work with text, images, speech. Related to #13825.
- [ ] make sure all vision models accept `attention_mask` as input. Related to #13764. 






Comments:
Cannot Replicate xlm-roberta-large-xnli Results
Author: SimoneFaricelli
Pull request: no

## Environment info
- `transformers` version: 4.9.0
- Platform: Linux-5.4.0-1055-aws-x86_64-with-glibc2.10
- Python version: 3.8.8
- PyTorch version (GPU?): 1.8.1+cu102 (True)
- Tensorflow version (GPU?): 2.5.0 (False)
- 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?: No

### Who can help
Models:

- albert, bert, xlm: @LysandreJik
- xlm-roberta-large-xnli @joeddav 

## Information

Model I am using (Bert, XLNet ...): joeddav/xlm-roberta-large-xnli

The problem arises when using:
* [X] the official example scripts: 
```python
from transformers import AutoTokenizer, AutoModelForSequenceClassification
from transformers import pipeline # no difference in manually encoding sentences and passing them through the model
import torch # the use of torch or tensorflow make absolutely no difference at all

device = 0 if torch.cuda.is_available() else -1
tokenizer = AutoTokenizer.from_pretrained("joeddav/xlm-roberta-large-xnli")

model = AutoModelForSequenceClassification.from_pretrained("joeddav/xlm-roberta-large-xnli")

sequence_to_classify = "Seriously, ANY possible sentence in any language."
candidate_labels = ["tecnologia", "cibo", "bevande", "finanza", "cinema", "giochi"]

classifier = pipeline("zero-shot-classification",
                      model=model, tokenizer=tokenizer, device=device)

#hypothesis_template = "This text is about {}." # within its addition, values are even more different
classifier(sequence_to_classify, candidate_labels, hypothesis_template, multi_class=False)
```
* [ ] my own modified scripts: 

The tasks I am working on is:
* [ ] an official GLUE/SQUaD task: (give the name)
* [X] my own task or dataset:
just trying to classify sentences with zero-shot classification on a not-finetuned model

## To reproduce

Steps to reproduce the behavior:

1. Use joeddav/xlm-roberta-large-xnli model for zero-shot classification (with or without pipeline, with any sentence in any language, using either torch or tensorflow)
2. Notice that results are different from **Hosted inference API** of that model, you can try them either using the model page interface or remote API calls

## Expected behavior

Shouldn't the results coming from the use of the model, correspond to the ones coming from the model web page?


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/master/CONTRIBUTING.md) are likely to be ignored.
No log output to console
Author: bingo789
Pull request: no

when i debug a demo, like below:
```
from transformers import AutoTokenizer
import logging

logging.basicConfig(level=logging.INFO)

tokenizer = AutoTokenizer.from_pretrained("bert-base-cased")
tokenizer('i love transformers', padding="max_length", truncation=True)
```

but it's No log output to console. What to do can the logs output  to the console？

Comments:
Could you elaborate what log outputs you expect to get?

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.