noamaanMulla-03/transformers-issues huggingface dataset:
Tokenize with offsets
Author: eladsegal
Pull request: yes
Labels: name: wontfix

Similar purpose to https://github.com/huggingface/transformers/pull/1274 (which I also used for most of the testing) but different approach.
It keeps track of token offsets by trying to progressively tokenize the text character by character, and consume matching tokens along the way.
It returns just the start of a span. Tests were added for ALBERT, CTRL and T5.
I think this implementation is more generic and simpler to understand, and the results are very good.

Comments:
# [Codecov](https://codecov.io/gh/huggingface/transformers/pull/2178?src=pr&el=h1) Report
> Merging [#2178](https://codecov.io/gh/huggingface/transformers/pull/2178?src=pr&el=desc) into [master](https://codecov.io/gh/huggingface/transformers/commit/26e04e51ef0774e681784d7be900c1119d46c52e?src=pr&el=desc) will **decrease** coverage by `<.01%`.
> The diff coverage is `66.66%`.

[![Impacted file tree graph](https://codecov.io/gh/huggingface/transformers/pull/2178/graphs/tree.svg?width=650&token=9qOlN6Hb1c&height=150&src=pr)](https://codecov.io/gh/huggingface/transformers/pull/2178?src=pr&el=tree)

```diff
@@            Coverage Diff             @@
##           master    #2178      +/-   ##
==========================================
- Coverage   73.73%   73.73%   -0.01%     
==========================================
  Files          87       87              
  Lines       14921    14919       -2     
==========================================
- Hits        11002    11000       -2     
  Misses       3919     3919
```


| [Impacted Files](https://codecov.io/gh/huggingface/transformers/pull/2178?src=pr&el=tree) | Coverage Δ | |
|---|---|---|
| [src/transformers/modeling\_utils.py](https://codecov.io/gh/huggingface/transformers/pull/2178/diff?src=pr&el=tree#diff-c3JjL3RyYW5zZm9ybWVycy9tb2RlbGluZ191dGlscy5weQ==) | `63.91% <0%> (ø)` | :arrow_up: |
| [src/transformers/tokenization\_utils.py](https://codecov.io/gh/huggingface/transformers/pull/2178/diff?src=pr&el=tree#diff-c3JjL3RyYW5zZm9ybWVycy90b2tlbml6YXRpb25fdXRpbHMucHk=) | `92.35% <100%> (-0.03%)` | :arrow_down: |

------

[Continue to review full report at Codecov](https://codecov.io/gh/huggingface/transformers/pull/2178?src=pr&el=continue).
> **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta)
> `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
> Powered by [Codecov](https://codecov.io/gh/huggingface/transformers/pull/2178?src=pr&el=footer). Last update [26e04e5...7870a49](https://codecov.io/gh/huggingface/transformers/pull/2178?src=pr&el=lastupdated). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments).


@thomwolf 
This pull request is ready for review

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.
Wrap Roberta integration test forward passes with torch.no_grad()
Author: mattchurgin
Pull request: yes

# What does this PR do?
This PR wraps forward passes in Roberta integration tests with torch.no_grad(). See issue #14642 

Fixes #14642 
[Issue link](https://github.com/huggingface/transformers/issues/14642)


## 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?

@NielsRogge @LysandreJik @sgugger 


Comments:
Question about the <mask>
Author: yz-qiang
Pull request: no

When fine-tuning the Bert, can I add some kind of constraint on the pre_trained **Bert model** so that Bert knows the different locations of **\<mask\>** to predict the same content? For example,  **xxx \<mask1\> xxx xxx, .... xxx \<mask1\>.**. I know Bert can predict the **MASK** in two positions into the same word when the sentence is not very long, completely. However, if the sentence is long, is there any way to tell the model that the two positions should be predicted into the same word? Please answer me at your convenience, thank you. :)

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.
Remove old asserts.
Author: Narsil
Pull request: yes

# What does this PR do?

<!--
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.

@sgugger

<!-- 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:
Resubmit changes after rebase to master
Author: kct22aws
Pull request: yes

# What does this PR do?
This PR proposes to add a new section to TorchScript documentation "Deploying HuggingFace TorchScript models on AWS using the Neuron SDK". 

Fixes # issue [14425](https://github.com/huggingface/transformers/issues/14425)


## 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?
- [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/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?
@philschmid , @LysandreJik 



Comments:
@philschmid @LysandreJik  I carried over all my work from the previous serialization.rst to serialization.mdx file per rebase to master. Looking forward to the approval and merge to master branch.  

Hi @LysandreJik @philschmid please review this PR and let me know of any suggestions. Thank you.
Question: CANINE with (pre-trained) LM head
Author: aitor-garcia-p
Pull request: no

# 🚀 Feature request

This is more a question than a request.

Would it be possible to have [CANINE](https://huggingface.co/docs/transformers/model_doc/canine) model with a (pre-trained) LM head to perform word/character prediction? (Just like BERTForMaskedLM and other similar models)

## Motivation

The character-based paradigm of the CANINE model is very promising and currently it is possible to perform TokenClassification, SequenceClassification, etc. using it. But I don't see the way of using it to emit LM probabilities over characters of a masked input. In fact, unless I am mistaken, I don't see that any LM pre-trained weights come within the available [pretrained-checkpoints](https://huggingface.co/models?sort=downloads&search=canine). I also see that, in the source code, there are [LM related CANINE heads](https://github.com/huggingface/transformers/blob/v4.15.0/src/transformers/models/canine/modeling_canine.py#L878), but they do not seem to be in use.

So, in summary, CANINE only outputs character embeddings. I have tried to add a fresh LM head on top of it and fine-tune to predict characters, but that lacks all the knowledge that such a LM head would have acquired during a large self-supervised pre-training.

My question is, am I missing or misunderstanding something? Is CANINE suitable to be used for masked words/characters prediction? Will there be, eventually, a pre-trained LM head available for CANINE? (Or maybe this is a question for the original authors of the model?)

## Your contribution

N/A. I am afraid I cannot contribute anything in this regard.

Thank youy so much.


Comments:
Hi,

CANINE can do masked language modeling (that's how it was pre-trained). However, the authors did not release their pre-training code (yet) as seen [here](https://github.com/google-research/language/tree/master/language/canine#pre-training-code-coming-later).

See also #12892.

Ok, that was my understanding of the situation so far.

I just wanted some clarification or confirmation from a more knowledgeable person :-)

Since it has more to do with the authors of the model and not with the Transformers library itself, I close this question for now.

Thank you very much for the quick answer!
is pooler output vector directly comparable to vector representation of word?
Author: jha46
Pull request: no

Hello, all. 

I have a quick question to understand vector representation for a document (I think it is saved in 'pooler_output').
I am sorry to ask a question here. I was not sure where I can ask about this.

If I understand BERT correctly, we can compare similarity across different documents with this vector and
we can also compare similarity across different words with last_hidden_state vectors.

My question is 'are these two types of vectors are in the same embedding space and thus comparable to each other'?
Thanks.



Comments:
Awesome question, I am also wondering the difference between `pooler_output` and `last_hidden_state` @sgugger . It is not clear from the documentation.

I got my answer by checking the source code: https://github.com/huggingface/transformers/blob/92d4ef9ab038dfbbe02556375c4c3c14215b37d2/src/transformers/models/vit/modeling_vit.py#L553

Please use the [forums](https://discuss.huggingface.co/) for questions like this, as we keep issues for bug reports and feature requests only :-)

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.
Examples: Tokenize only max_samples used for train/eval/prediction
Author: ioana-blue
Pull request: no

# 🚀 Feature request

If I understand what's going on, when using flags for max samples to be used for train/eval/prediction, first the tokenizer is called on the whole dataset. This operations seems quite involved and it takes minutes for a decent size dataset. Is it possible to tokenize only max samples as defined by the corresponding parameters to save time?

## Motivation

I use the max sample flags to debug my code. It would be nice to just tokenize the samples that will be used instead of the whole dataset. 


Comments:
I think this can be controlled from user level code. For example, in this line:
https://github.com/huggingface/transformers/blob/master/examples/pytorch/text-classification/run_glue.py#L394

modify the function to receive an argument on how many examples to tokenize. I'm guesstimating that the max samples param was recently introduced and older examples don't use it. I'll change the title of the issue to better reflect this. 

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.

Sorry @ioana-blue, I had missed this issue - let me ping @sgugger for advice, but please note that he is off right now and will answer only when he's back. Thanks!

No worries, I think this can be controlled from the user space and I did so in my most recent code. I think the examples could be fixed as well as - at least - I use them for inspiration and they are great :) 

You can just move the tokenization line after the datasets are truncated. It will take three lines instead of one since by then there will be three separate datasets instead of one, which is the main reason it's not done in the examples as they are, or they will become less readable.

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.
VQA model inferences
Author: PrithivirajDamodaran
Pull request: no

There are a bunch of models fine tuned for VQA and NLVR tasks based on LXMERT, ViLT and Visual BERT, CLIP vision BERT and so on. Is there a resource to see how to run inferences on them ? (and possibly benchmark them )

Comments:
I tried the LXMERT and VisualBERT demos from [here](https://github.com/huggingface/transformers/blob/master/examples/research_projects/lxmert/demo.ipynb) and [here](https://github.com/huggingface/transformers/blob/master/examples/research_projects/visual_bert/demo.ipynb) 

There seems to be dependency issues and a mismatch with tokeniser version in the Req file. Tried fixing it with no luck. 

Question: We need FRCNN models for LXMERT and visual BERT as both uses RoIs as a supervision signal along with text encoder ? 

Does that mean ViLT based VQA won't need FRCNN as they don't use ROI based supervision ? 

Please clarify  

Hi,

I'm working on adding the ViLT model, see #14895. It will be much easier to use compared to LXMERT and VisualBERT. It indeed doesn't require an external model like Faster R-CNN. Instead, it just turns an image into a sequence of patches, which are fed to the model (similar to ViT). 

Awesome thanks ! @patil-suraj  was mentioning you are working on this. Closing this for now. 

Looking forward to it !
How to use an unpretrained model?
Author: jiacheng-ye
Pull request: no

By using the following codes, I can load a **pretrained** model for fine-tuning on QA tasks. I'm wondering how to load a same (same architecture with roberta-base) **unpretrained** model , and train it on my own data from scratch?
```
tokenizer = AutoTokenizer.from_pretrained("roberta-base")
model = AutoModelForQuestionAnswering.from_pretrained("roberta-base")
```

Comments:
You can initialize a model using a configuration object, like so:

```
from transformers import RobertaConfig, RobertaModel

config = RobertaConfig()
model = RobertaModel(config)
```
This for instance will load the default configuration of RoBERTa, as documented [here](https://huggingface.co/docs/transformers/model_doc/roberta#transformers.RobertaConfig) - which means, a `hidden_size` of 768, 12 hidden layers, etc. All weights of the model will be randomly initialized, as we're not instantiating it using the `from_pretrained()` method. To customize the architecture, you can load it as follows:
```
from transformers import RobertaConfig, RobertaModel

config = RobertaConfig(num_hidden_layers=2, hidden_size=20)
model = RobertaModel(config)
```

You can also load a model with randomly initialized weights, but with the architecture of a particular model on the hub, for instance, like so:

```
from transformers import AutoConfig

config = AutoConfig.from_pretrained("klue/roberta-small") # note, this is equivalent to instantiating a RobertaConfig

model = RobertaModel(config)
```


Thanks a lot :)
Config overrides option working on any kind of config
Author: michaelbenayoun
Pull request: no

# 🚀 Feature request

Allow the `--config_overrides` option in language-modeling examples to override a config that was specified by `--config_name` or `--model_name_or_path`, currently this is blocked by:
```python
if self.config_overrides is not None and (self.config_name is not None or self.model_name_or_path is not None):                                                    
            raise ValueError(                                                                                                                                              
                "--config_overrides can't be used in combination with --config_name or --model_name_or_path"                                                               
            )  
```

## Motivation

It is unclear why this is prevented, and it can make things a lot easier when tweaking the settings compared to having to edit a json file everytime. Is there a good reason for not allowing that?

## Your contribution

I can create a PR and make the changes myself.

Comments:
If I remember correctly, it's because the transformers logic prevents us from overriding config if either of those 2 are defined.

I'm sure you will see it immediately if you remove the constraint.

If you find a good way to fix it, by all means please do.

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.
ValueError when converting dialogpt to onnx format
Author: qiuxia-alone
Pull request: no

## Environment info

- `transformers` version: 4.9.2
- Platform: Darwin-20.5.0-x86_64-i386-64bit
- Python version: 3.7.11
- PyTorch version (GPU?): 1.9.0 (False)
- Tensorflow version (GPU?): 2.2.0 (False)
- 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
 @patrickvonplaten, @LysandreJik

## Information

Model I am using ([dialogpt](https://huggingface.co/microsoft/DialoGPT-medium)):
when convert dialogpt to onnx, i meet ValueError:
`ValueError: The type of axis index is expected to be an integer
`

## To reproduce

```
from transformers.convert_graph_to_onnx import convert
from pathlib import Path
convert(framework="pt", model="DialoGPT-medium/", output=Path("onnx/dilogpt.onnx"), opset=11)
```



Comments:
Gently pinging @michaelbenayoun here

Gently pinging @lewtun here

Thanks for the ping! Will take a look :)

Hey @qiuxia-alone, thank you for raising this issue! The ONNX export API was overhauled in `transformers` v4.9.0 ([link](https://github.com/huggingface/transformers/releases/tag/v4.9.0)), and since then the recommended way to export models is via the `transformers.onnx` package. 

For example, one can export the `DialoGPT-medium` checkpoint as follows:

```python
python -m transformers.onnx --model=microsoft/DialoGPT-medium onnx/ --opset 11
```

Does running the above command solve your issue? You can find more information in the docs of your `transformers` version [here](https://huggingface.co/transformers/v4.9.2/serialization.html#exporting-transformers-models).

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 model table cell text alignment
Author: ydshieh
Pull request: yes

# What does this PR do?

The current new model table in [index.mdx](https://github.com/ydshieh/transformers/blob/master/docs/source/index.mdx) left align table cell texts. This PR makes them center-aligned.

On master:

![Capture](https://user-images.githubusercontent.com/2521628/147839482-9ed2520e-3622-4f66-bdfe-3c98f2d8e655.JPG)

On this PR [index.mdx](https://github.com/ydshieh/transformers/blob/center-align-model-table/docs/source/index.mdx):

![Capture2](https://user-images.githubusercontent.com/2521628/147839492-a4a2ee48-e8ab-49c5-86f3-71a4e7b1e05a.JPG)

(Hope centralized instead of decentralized is intended in this context 🤗 )

## Who can review?

@sgugger  @LysandreJik 

Comments: