noamaanMulla-03/transformers-issues huggingface dataset:
Improve torch.fx support to trace non torch objects
Author: thomasw21
Pull request: yes

# What does this PR do?

Improve `torch.fx` support to be able to track non tensor/parameter/module attributes. For example the new tracing mechanism allows to trace `config`, `num_heads` etc ... attributes that are important if one wants to build transformations on top.

Caveat: tracing such objects prevents `torch.jit.script` to work correctly due to limitations on their end. Consequently we gate the feature behind `trace_non_torch_object` flag upon tracing which defaults to False. (We could default to True, but that's a breaking change)

```
E   AssertionError: Could not TorchScript the traced model: 
E   Module 'GraphModule' has no attribute 'config' (This attribute exists on the Python module, but we failed to convert Python type: 'transformers.models.gpt2.configuration_gpt2.GPT2Config' to a TorchScript type. Only tensors and (possibly nested) tuples of tensors, lists, or dictsare supported as inputs or outputs of traced functions, but instead got value of type GPT2Config.. Its type was inferred; try adding a type annotation for the attribute.):
E     File "<eval_with_key>.0", line 5
E   def forward(self, input_ids : torch.Tensor, token_type_ids : torch.Tensor):
E       config = self.config
E                ~~~~~~~~~~~ <--- HERE
E       config_1 = self.config
E       config_2 = self.config
```

Comments:
The docs for this PR live [here](https://moon-ci-docs.huggingface.co/docs/transformers/pr_18765). 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/main/CONTRIBUTING.md) are likely to be ignored.
Added tests for yaml and json parser
Author: IMvision12
Pull request: yes

# What does this PR do?

Fixes #19116


## Before submitting
- [x]  adding as parse_yaml_file method to HfArgumentParser with the code above
- [x] refactor the dupe code between parse_json_file and parse_dict similar to the code above
- [x] add a small test of parse_yaml_file
- [x]  add a small test of parse_json_file


## Who can review?

@sgugger 





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

Where can one find examples of yaml or json configs ?
In "Question Answering" separate context from question
Author: yoeldk
Pull request: no

# 🚀 Feature request

## Motivation
Often one may have many questions on the same content. In the current implementation, the function will be called multiple times with the same context but with different questions causing a lot of computational time. 

## Idea
I was wondering if there's a way to speed up runtime by splitting the context and question instead of the single question_answering() which gets both arguments. 
This way the algorithmic parts that are only dependent on the context can be calculated once, and re-used many times when asking several questions on the same content.



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.

Any update on this? 

Currently there is no way to handle this in the pipelines. You should be able to achieve this pretty simply by using a model/tokenizer without the pipeline. See here for an example of how to do that: https://huggingface.co/transformers/task_summary.html#extractive-question-answering

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.

@LysandreJik In the link you had provided it looks like all the computation is being done in the loop that iterates over the questions, so no work is being done only once for the context outside the loop. Why do we have to tokenize the same context for every question?

@yoeldk did you figure this out?

> @yoeldk did you figure this out?

Not really, but I'm now dealing with other things so I decided to leave it
Breakup export guide
Author: stevhliu
Pull request: yes
Labels: name: Documentation

This PR breaks up `serialization.mdx` into separate ONNX and TorchScript docs. Currently, this doc is quite long which makes it difficult for users to quickly find what they're looking for and it also discusses two different topics. I think separating these topics into their own docs makes it easier for users to focus on just one thing at a time, and it's also easier to skim (I also included some light edits for clarity).

Let me know what you think! :)

Comments:
_The documentation is not available anymore as the PR was closed or merged._
Update Protobuf dependency version to fix known vulnerability
Author: qthequartermasterman
Pull request: yes

# What does this PR do?
Protobuf v3.20.1 has a known security vulnerability, [described here on snyk](https://security.snyk.io/package/pip/protobuf/3.20.1). Bumping the protobuf dependency version fixes this vulnerability.


## 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.

Library:
- pipelines: @LysandreJik

Comments:
_The documentation is not available anymore as the PR was closed or merged._
Added type hints for TF: rag model
Author: debjit-bw
Pull request: yes

Based on Issue https://github.com/huggingface/transformers/issues/16059

Type hints for the [TFRagModel](https://huggingface.co/docs/transformers/model_doc/rag) have been added.

@Rocketknight1 Could you please check the changes and merge if it's fine?

Thanks a lot.

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

@Rocketknight1 can you take a look at this? I just added type hints and fixed a syntax error in one previous type. Still it shows it failed these 2 tests. I have no idea what these tests do, can you shed some light on this issue?

Thanks a lot @Rocketknight1, I have made the suggested changes!

Looks perfect now, thank you!
ci(stale.yml): upgrade actions/setup-python to v4
Author: oscard0m
Pull request: yes


# What does this PR do?
Update actions/setup-python to v4 in stale.yml
<!--
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 -->


## 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.
**No but I can create one and reference it here if it's necessary.**
- [ ] 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). 
**I understand no documentation changes are necessary for this change.**
- [x] Did you write any new necessary tests? 
**I understand no tests are necessary for this change.**


## Who can review?
🤷🏽, no human committer checking Git Blame

Comments:
ci(stale.yml): update actions/checkout to v3
Author: oscard0m
Pull request: yes



# What does this PR do?
Update actions/checkout to v3 in stale.yml
<!--
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 -->


## 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.
**No but I can create one and reference it here if it's necessary.**
- [ ] 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). 
**I understand no documentation changes are necessary for this change.**
- [x] Did you write any new necessary tests? 
**I understand no tests are necessary for this change.**


## Who can review?
🤷🏽, no human committer checking Git Blame

Comments:
_The documentation is not available anymore as the PR was closed or merged._
Wrap Deit integration test forward passes with torch.no_grad()
Author: daspartho
Pull request: yes

# What does this PR do?
As proposed in issue #14642, this PR wraps forward passes in Deit integration tests with torch.no_grad(). This way, no unnecessary gradients are computed during inference.


## Before submitting
- [ ] This PR fixes a typo or improves the docs.
- [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/)?
- [ ] Did you make sure to update the documentation with your changes?
- [ ] Did you write any new necessary tests?


## Who can review?
@LysandreJik could you please take a look at it?
Thanks :)

Comments:
_The documentation is not available anymore as the PR was closed or merged._
Wrap DebertaV2 integration test forward passes with torch.no_grad()
Author: daspartho
Pull request: yes

# What does this PR do?
As proposed in issue #14642, this PR wraps forward passes in DeberatV2 integration tests with torch.no_grad(). This way, no unnecessary gradients are computed during inference.


## Before submitting
- [ ] This PR fixes a typo or improves the docs.
- [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/)?
- [ ] Did you make sure to update the documentation with your changes?
- [ ] Did you write any new necessary tests?


## Who can review?
@LysandreJik could you please take a look at it?
Thanks :-)

Comments:
_The documentation is not available anymore as the PR was closed or merged._
Wrap ConvBert integration test forward passes with torch.no_grad()
Author: daspartho
Pull request: yes

# What does this PR do?
This PR wraps forward passes in ConvBert integration tests with `torch.no_grad()`, as proposed in issue #14642. This avoids the computation of unnecessary gradients during inference.

## Before submitting
- [ ] This PR fixes a typo or improves the docs.
- [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/)?
- [ ] Did you make sure to update the documentation with your changes?
- [ ] Did you write any new necessary tests?


## Who can review?
@LysandreJik could you please check it?
Thanks :)

Comments:
_The documentation is not available anymore as the PR was closed or merged._
Wrap BigBird integration test forward passes with torch.no_grad()
Author: daspartho
Pull request: yes

# What does this PR do?
As proposed in issue #14642, this PR wraps forward passes in BigBird integration tests with torch.no_grad(). This way, no unnecessary gradients are computed during inference.


## Before submitting
- [ ] This PR fixes a typo or improves the docs.
- [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/)?
- [ ] Did you make sure to update the documentation with your changes?
- [ ] Did you write any new necessary tests?


## Who can review?
@LysandreJik could you please take a look at it?
Thanks :)

Comments:
_The documentation is not available anymore as the PR was closed or merged._
A developer environment, for faster and efficient contributions.
Author: AnirudhDaya
Pull request: no

### Feature request

Hello maintainers.
I would like to add gitpod to your repo to help beginners contribute.
 - Gitpod is an online IDE which can be launched from any GitHub page. Within seconds, Gitpod provides a fully working development environment, including a VS Code-powered IDE and a cloud-based Linux container explicitly configured for the project
- Gitpod is highly contextual, such that it opens the IDE in the correct mode depending on the context:
   -  If you are looking at a particular file of a certain commit on GitHub, starting a Gitpod workspace will check out the right version and open the file you’ve been looking at in the IDE.

   - Starting a Gitpod workspace from an issue will automatically create a branch and preconfigure the commit message.
- Once you are in the IDE, you can interact with GitHub in various ways. Besides the obvious Git integration, you can do things like commenting inline in editors, approving and even merging PRs.

### Motivation

I have seen many repos adopting gitpod to help new contributors in their open-source journey. It's hassle-free. You don't need to worry about dependencies not being present, since gitpod does all the heavy lifting.

### Your contribution

I can add a badge to your repo in the [CONTRIBUTING.md](https://github.com/huggingface/transformers/blob/main/CONTRIBUTING.md) file similar to this one:
<a href="https://gitpod.io/#<your-repository-url>">
  <img
    src="https://img.shields.io/badge/Contribute%20with-Gitpod-908a85?logo=gitpod"
    alt="Contribute with Gitpod"
  />
</a>

Comments:
Hey @AnirudhDaya, what difference is there with https://github.dev/huggingface/transformers ?

Thank you!

Sorry my bad. It didn't catch my eye.

No worries :)
ONNX support for gpt-neox
Author: hannan72
Pull request: no

### Feature request

Is there any possibility that we can convert gpt-neox to onnx using transformer library?

### Motivation

onnx model will be faster.

### Your contribution

-

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/main/CONTRIBUTING.md) are likely to be ignored.

Hi @hannan72 we have a guide on adding support to export new architectures to ONNX: https://huggingface.co/docs/transformers/serialization#contributing-a-new-configuration-to-transformers

Would you like to have a go at implementing the ONNX config for this model? It should be similar to what has already been done for other GPT models like `gpt-neo`

Hi @lewtun 
It is totally welcome if I can convert GPT like models to onnx. I did the conversion for gpt-j-6b. The problem was that the inference time improvement was only 5% in comparison to PyTorch on my GPU. Did you have any benchmark for the conversion of GPT models to onnx?

Hi @hannan72 

> It is totally welcome if I can convert GPT like models to onnx. I did the conversion for gpt-j-6b.

Cool, this would be a nice addition! 

> The problem was that the inference time improvement was only 5% in comparison to PyTorch on my GPU. Did you have any benchmark for the conversion of GPT models to onnx?

Were you running on ONNXRuntime? We've found that to really speed up generations with GPT-like models, one needs to include ONNXRuntime's [IO bindings](https://onnxruntime.ai/docs/api/python/api_summary.html#iobinding) and [ORTValue](https://onnxruntime.ai/docs/api/python/api_summary.html#ortvalue). I don't have a benchmark for this currently, but it's something we're looking into in `optimum`


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 `BloomForQuestionAnswering`
Author: younesbelkada
Pull request: yes

# What does this PR do?

This PR adds the class `BloomForQuestionAnswering`, insipred from [`GPTJForQuestionAnswering`](https://github.com/huggingface/transformers/blob/4c962d5e790d06c142af35aad165c74c0bcf861a/src/transformers/models/gptj/modeling_gptj.py#L1024), as the community asked for the release of this class (See the discussion here: https://huggingface.co/bigscience/bloom/discussions/46#633b35f21fd49ee0b64e29d2) 

cc @sgugger @ydshieh @LysandreJik  @ArthurZucker 

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

I have just fixed your suggestions @sgugger  💪 Gently pinging you here, and let me know if you need me to open a PR for GPTJ too ;) !

Thanks a lot!!
Some question about training BERT after change the Vocab.txt size
Author: WenTingTseng
Pull request: no
Labels: name: wontfix

The original bert-base-chinese-vocab.txt size is 21128.
I use my own vocab.txt size is 44900
When I try to train Fine-tune BERT Model using BertForMaskedLM it have some promble about size mismatch.
I have try to change the BertEmbeddings its self.word_embeddings config.vocab_size to 44900 like this
`self.word_embeddings = nn.Embedding(44900, config.hidden_size, padding_idx=0) `
But it still have problem like this

```
RuntimeError: Error(s) in loading state_dict for BertForMaskedLM:
        size mismatch for bert.embeddings.word_embeddings.weight: copying a param with shape torch.Size([21128, 768]) from checkpoint, the shape in current model is torch.Size([44900, 768]).
        size mismatch for cls.predictions.bias: copying a param with shape torch.Size([21128]) from checkpoint, the shape in current model is torch.Size([44900]).
        size mismatch for cls.predictions.decoder.weight: copying a param with shape torch.Size([21128, 768]) from checkpoint, the shape in current model is torch.Size([44900, 768]).
```
I do not sure how to fix it.
I have think about if I need to change the pre trained BERT config.json file? Its vocab_size from 21128 to 44900


Comments:
You can't really change the vocabulary without re-training the whole model. Is there some overlap between the BERT vocabulary and your custom vocabulary? If so, you can add the 20k+ tokens using `add_tokens` (which will probably slow down things, as that's a lot of added tokens).

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.


you can now do this. Keras (tf-nightly version) has added a new util `keras.utils.warmstart_embedding_matrix`. Using this you can continuously train your model with changing vocabulary. https://www.tensorflow.org/api_docs/python/tf/keras/utils/warmstart_embedding_matrix
Add LayoutLMv2 to models exportable with ONNX
Author: fadi212
Pull request: yes

This PR adds the code for converting LayoutLMv2 model to onnx format. 

Comments:
@michaelbenayoun  Can you please review this PR and highlight why these circleci tests are failing ?

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 working on this @fadi212 🙏 I am interested in this work, but I see it has been quite some time since you've had an opportunity to work on it. Are you still working on this? If you no longer have the time or resources to do so, would you be able to provide any next steps or advice on what is necessary for completion? Thank you for your time and effort 🤗
docker-build: Update actions/checkout to v3
Author: Sushrut1101
Pull request: yes

For hacktoberfest 2022 :)

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

Thanks for your PR @Sushrut1101! I'll ping Yih-Dar @ydshieh for review but he's off for the week; he'll review when he's back! Thanks :)

> Thanks for your PR @Sushrut1101! I'll ping Yih-Dar @ydshieh for review but he's off for the week; he'll review when he's back! Thanks :)



> Actually checked and it's fine for me; thanks for your PR @Sushrut1101!

You're welcome! 👍😃