noamaanMulla-03/transformers-issues huggingface dataset:
Missing support for token sampling in XLMRobertaTokenizer (sentencepiece) 
Author: talbaumel
Pull request: no

### Feature request

Hi all, token sampling is supported by the sentencepiece library, but the kwargs required to enable it are blocked by the wrapper (`_tokenize` as no `**kwargs` param)

This simple fix will enable support for token sampling 🎉

### Motivation

Token sampling is awesome, it will enable learning a more robust model 👍

### Your contribution

In `XLMRobertaTokenizer.py`
```
def _tokenize(self, text, **kwargs):
        enable_sampling = kwargs.get("enable_sampling", False)
        if enable_sampling:
            return self.sp_model.EncodeAsPieces(text)
        else:
            return self.sp_model.sample_encode_as_pieces(text, nbest_size=kwargs['nbest_size'], alpha=kwargs['alpha'])
```

And in `tokenization_utils_base.py`:
Line 318 --> `def split_on_tokens(tok_list, text, **kwargs):`
Line 338 --> `self._tokenize(token) if token not in self.unique_no_split_tokens else [token]`



Comments:
+1

+1

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.
Whether to use 'logits' or 'loss' in LabelSmoother
Author: zalmanchen
Pull request: no

### System Info

- 'transformers' version: 4.24.0

### Who can help?

_No response_

### Information

- [X] The official example scripts
- [ ] My own modified scripts

### Tasks

- [ ] An officially supported task in the `examples` folder (such as GLUE/SQuAD, ...)
- [ ] My own task or dataset (give details below)

### Reproduction



it is in "transformers/trainer.py"
![ec8d50fbf9388598e5bb7a631f406f364921130857e902ff2d73b9dff332d30cQzpcVXNlcnNcemFsbWFcQXBwRGF0YVxSb2FtaW5nXERpbmdUYWxrXDQ3NDQyMTE1Ml92MlxJbWFnZUZpbGVzXDE2NzAwODU4NjkwOThfREVGN0M0QzMtRjI1Mi00Y2UyLUE2RDYtNjFCQzI4MENEOTZDLnBuZw==](https://user-images.githubusercontent.com/70104951/205451920-7b0c4a21-7b83-4873-b04a-e9ba6ba97e03.png)

it is in "transformers/trainer_pt_utils.py"

![75a7ca0c9a5623cd394ed71be3651c998b0d15e9238e67fe612854c05af75025QzpcVXNlcnNcemFsbWFcQXBwRGF0YVxSb2FtaW5nXERpbmdUYWxrXDQ3NDQyMTE1Ml92MlxJbWFnZUZpbGVzXDE2NzAwNTY0NTI2MTdfODUyRkFENTUtRDVDRi00YTE4LUIyNTItRUJENjg0MTU3MUNFLnBuZw==](https://user-images.githubusercontent.com/70104951/205450770-bca21a08-0115-4895-94ae-f7cfd76d6e61.png)



### Expected behavior


In fact, it is not a bug problem! I just have doubts about the variable used in a function

In "transformers/trainer_pt_utils.py", the class "LabelSmoother \__call\__" function, I noticed that it uses the **'logits'** value, but **'output [0]'** is selected under 'else' condition, if I am not mistaken, **'output[0]'** should represent loss(I use the **_BartForConditionalGeneration_**) . So is there any problem here? 

Comments:
Please use the [forums](https://discuss.huggingface.co/) to ask such questions, as we keep issues for bugs and feature requests only. The labels are popped when we use label smoothing, so the loss is not included in the ouputs/

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.
Models for low resource languages
Author: RaiAmanRai
Pull request: no
Labels: name: New model

### Model description

Hi, I was wondering if there is any way to take leverage of STOA models like [this](https://huggingface.co/facebook/bart-large-mnli) one by facebook and come up with a model for a low resource language, say Filipino using something like student-teacher methods.

My main aim is to come up with some **Zero-Shot models** for such languages with similar accuracy when used with languages like english.



### Open source status

- [X] The model implementation is available
- [X] The model weights are available

### Provide useful links for the implementation

_No response_

Comments:
Sensible default for Trainer's dataloader_num_workers argument
Author: kmewhort
Pull request: no

### Feature request

As a relative beginner with Transformers and ML, it took me quite a bit of performance analysis and fiddling to figure out why my GPU was being vastly underutilized in training on image classification.  I finally figured out that the bottleneck was dataloaders (as typical for image tasks, it has a few image transformations) and I got a 10X performance increase by setting `dataloader_num_workers` to 16.

Could this have a more a higher default to avoid this gotcha?  Maybe it could default to something like half the number of available CPUs?

### Motivation

It's frustrating for a beginner to have training times super slow because of an unset parameter.  It'd be great for the defaults to work well out-of-the-box.

### Your contribution

Happy to submit a PR if the idea is greenlit.

Comments:
It's hard to have a nice default that would work everywhere: for NLP tasks you wouldn't need this since the preprocessing is fast. How about doing something in the vision examples?

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.
[bnb optim] fixing test
Author: stas00
Pull request: yes

**Note to reviewers: we are dealing with a slow test, so a green CI doesn't tell anything.**

This work is a continuation of https://github.com/huggingface/transformers/pull/21019 where this test failure was first reported by @ydshieh 

This PR:

- extends/improves the `run_trainer` wrapper which simplifies the bnb test
- drops the percentage-based asserts as those are quite meaningless - since they don't measure the memory used by the optimizer but the whole memory - it replaces them with the actual calculated saved memory expectation since we know exactly what the saved memory should be for a particular model. it's `6*params` bytes but not for `nn.Embedding` which gets fp32 - so let's measure that carefully. 

https://github.com/huggingface/transformers/blob/35a7052b61579cfe8df1a059d4cd3359310ec2d1/src/transformers/trainer.py#L1042-L1050

- drops the peak gpu memory comparison since on its own it's totally meaningless, in my testing I get both optims produce the same peak memory - what we care about is the total gpu memory.
- forces 1 gpu - so that the gpu memory usage is the same in all environments, to support 2+ gpus we need to have a different threshold for each - except this is totally unncessary
- switches to MBs everywhere, so it's much easier to debug 

Now, the test should be very deterministic on any gpu/platform. I still gave a small margin for differences.

You can read my notes in the test for the exact math.

@ydshieh. please verify it works on the CI and we will then merge it. Thank you!

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

The new test now passes on CI runners! I will review the change and thank you @stas00 ❤️ !
Fix `torchscript` tests for `AltCLIP`
Author: ydshieh
Pull request: yes

# What does this PR do?

Fix `torchscript` tests for `AltCLIP`.

This model uses `roberta` as text model, which has 
```python
        self.register_buffer(
            "token_type_ids", torch.zeros(self.position_ids.size(), dtype=torch.long), persistent=False
        )
```
and this requires the change in this PR to pass the test.

See [current failing job run page](https://github.com/huggingface/transformers/actions/runs/3889079663/jobs/6637067165)

Comments:
_The documentation is not available anymore as the PR was closed or merged._
Improved logo display in dark mode
Author: shaonianche
Pull request: no

### Feature request

![image](https://user-images.githubusercontent.com/16186646/205929373-4c1e4c99-5c46-44d0-909c-313e029fef65.png)

Use [github's](https://github.blog/changelog/2021-11-24-specify-theme-context-for-images-in-markdown/) features to improve how the logo is displayed

### Motivation

...

### Your contribution

![logo](https://user-images.githubusercontent.com/16186646/205928567-485a016d-ff1e-4e2f-adf2-d7f2315ffa14.png#gh-light-mode-only)
![logo](https://user-images.githubusercontent.com/16186646/205928895-e69bb7e3-4158-44d6-b910-52d2156f969a.png#gh-dark-mode-only)

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.
Incremental Training on model of my domain which I have fine tuned using run_mlm
Author: SakshamSoni-code
Pull request: no

### Model description

I have used run_mlm to fine tune the model of my own domain. Now I want to do is, I want to pass a incremental flag in run_mlm, if that flag will be true then instead of fine tuning I want to start training on the already trained model of my own domain which we got before. What are the changes we need to do in run_mlm?

### Open source status

- [ ] The model implementation is available
- [ ] The model weights are available

### Provide useful links for the implementation

_No response_

Comments:
Please use the [forums](https://discuss.huggingface.co/) to ask such questions as we keep issues for bugs 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/main/CONTRIBUTING.md) are likely to be ignored.
Data to text representation considers only first 2 triplets
Author: jyotibhat1
Pull request: no

Hello,
I trained t5-base with wenNLG2020 data set which takes the data in the form of multiple triplets. When a query is made to the model in the same format, it explains the first 2 triplets and ignores the rest. Is it any config issue?

Comments:
Please use the [forums](https://discuss.huggingface.co/) to ask such questions as we keep the issues for bugs 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/main/CONTRIBUTING.md) are likely to be ignored.
Pre-trained tokenizer `repr` is inconsistent with attribute name
Author: inwaves
Pull request: no

### System Info

- `transformers` version: 4.26.0.dev0
- Platform: macOS-12.5.1-x86_64-i386-64bit
- Python version: 3.10.8
- Huggingface_hub version: 0.11.1
- PyTorch version (GPU?): 1.13.1 (False)
- Tensorflow version (GPU?): 2.11.0 (False)
- Flax version (CPU?/GPU?/TPU?): 0.6.3 (cpu)
- Jax version: 0.4.1
- JaxLib version: 0.4.1
- Using GPU in script?: No
- Using distributed or parallel set-up in script?: No

### Who can help?

Hi @ArthurZucker, since this is tokeniser-related, do you mind having a look?

### Information

- [ ] The official example scripts
- [ ] My own modified scripts

### Tasks

- [ ] An officially supported task in the `examples` folder (such as GLUE/SQuAD, ...)
- [X] My own task or dataset (give details below)

### Reproduction

This one's pretty straightforward: 

1. Using a pre-trained tokeniser (`PreTrainedTokenizerFast` or `PreTrainedTokenizerBase`), print out the object.
2. The `repr`, which is defined in [`tokenization_utils_base`](https://github.com/huggingface/transformers/blob/a3c37825cc1e305dde63455b5f321586e6d29e07/src/transformers/tokenization_utils_base.py#L1573), returns something like this:

`PreTrainedTokenizerFast(name_or_path='gpt2', vocab_size=50257, model_max_len=1024, is_fast=True, padding_side='right', truncation_side='right', special_tokens={'bos_token': '
', 'eos_token': '
', 'unk_token': '
', 'pad_token': '[PAD]'})`

3. Note the `model_max_len` attribute.

### Expected behavior

The repr should display `model_max_length=1024` instead, since that is the actual name of the attribute. Other attribute labels in the repr seem consistent with the name, which leads me to believe this is a typo.

I came across this because I printed out the object, and then tried to access that tokeniser's `model_max_len`, which of course errors out since there's no attribute with that name.

Comments:
The `PreTrainedTokenizerFast` and `PreTrainedTokenizerBase` are abstract classes and should not really be used. The `model_max_len` is a vestige of a previous argument, opening a PR to fix this typo as indeed the attribute does not exist.
[Tokenizers] Fix a small typo
Author: ArthurZucker
Pull request: yes

# What does this PR do?
Fixes #21073, there was a typo in the `__repr__` method of the `PretrainedTokenizer` which uses the previous `model_max_len` instead of `model_max_length`

Comments:
_The documentation is not available anymore as the PR was closed or merged._
Update task summary part 1
Author: stevhliu
Pull request: yes

This PR reworks the task summary to be more conceptual and provides more explanation about a topic to help users better understand it. It'll be focused more on understanding instead of practical steps. The update will be split into two parts:

1. Describe the tasks 🤗 Transformers is capable of solving (the focus of this PR). Provide some context about how these tasks used to be solved, how they're handled now, and practical applications of each task.
2. Explain how 🤗 Transformers solve these tasks. This'll be a more conceptually advanced and separate page.

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

> It is called "what Transformers can do", so I think the introductions of each modality should just explain what each modality is and abstain from comparing models

Thanks for the feedback, this helped me refine the scope of this page! It was a little difficult trying to discuss the tasks and not be tempted to also talk about the models since the two are so closely related. 😅 I updated the intro of each modality with an explanation of the input data and how to get it into a useable format by the model to solve a task.
Add Spanish translation to community.mdx
Author: shogohida
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 -->
Adds Spanish translation to community.mdx

Fixes #15947 

## Before submitting
- [x] This PR fixes a typo or improves the docs (you can dismiss the other checks if that's the case).
- [ ] Did you read the [contributor guideline](https://github.com/huggingface/transformers/blob/main/CONTRIBUTING.md#start-contributing-pull-requests),
      Pull Request section?
- [ ] Was this discussed/approved via a Github issue or the [forum](https://discuss.huggingface.co/)? Please add a link
      to it if that's the case.
- [ ] Did you make sure to update the documentation with your changes? Here are the
      [documentation guidelines](https://github.com/huggingface/transformers/tree/main/docs), and
      [here are tips on formatting docstrings](https://github.com/huggingface/transformers/tree/main/docs#writing-source-documentation).
- [ ] Did you write any new necessary tests?


## Who can review?

@osanseviero @omarespejel @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:

- text models: @ArthurZucker and @younesbelkada
- vision models: @amyeroberts and @NielsRogge
- speech models: @sanchit-gandhi

Library:

- flax: @sanchit-gandhi
- generate: @gante
- pipelines: @Narsil
- tensorflow: @gante and @Rocketknight1
- tokenizers: @ArthurZucker
- trainer: @sgugger

Integrations:

- deepspeed: @stas00
- ray/raytune: @richardliaw, @amogkam

Documentation: @sgugger, @stevhliu and @MKhalusova

HF projects:

- accelerate: [different repo](https://github.com/huggingface/accelerate)
- datasets: [different repo](https://github.com/huggingface/datasets)
- diffusers: [different repo](https://github.com/huggingface/diffusers)
- rust tokenizers: [different repo](https://github.com/huggingface/tokenizers)

Maintained examples (not research project or legacy):

- Flax: @sanchit-gandhi
- PyTorch: @sgugger
- TensorFlow: @Rocketknight1

 -->


Comments:
_The documentation is not available anymore as the PR was closed or merged._
Rework automatic code samples in docstrings
Author: sgugger
Pull request: yes

# What does this PR do?

This PR reworks the automatic code sample docstrings in two ways:

First, use the auto-classes for the preprocessing. As was decided internally, we want to document the model class used, but use the auto classes for preprocessing so users are not confused when a given model uses the tokenizer/feature extractor/image processor/processor of another.

Second, we don't want to showcase `hf-internal-testing` models in the docstrings. Those are tiny random models and it confuses users more than it helps. However when using the standard checkpoint we get doctest problems, so this PR removes the output/loss from the code example when it shouldn't be tested.

Two examples are shown with BERT and DeBERTaV2, I can add more models to the PR if it suits everyone.

Comments:
_The documentation is not available anymore as the PR was closed or merged._
Added type hints to modeling_tf_encoder_decoder.py
Author: Batese2001
Pull request: yes

# What does this PR do?

This pull request adds type hints for modeling_tf_encoder_decoder.py as outlined in Issue #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?
- [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?

@Rocketknight1 


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.
CLIP not releasing GPU memory after each inference batch
Author: corbt
Pull request: no

### System Info

- `transformers` version: 4.25.1
- Platform: Linux-5.15.0-46-generic-x86_64-with-glibc2.31
- Python version: 3.10.8
- Huggingface_hub version: 0.11.1
- PyTorch version (GPU?): 1.12.1 (True)
- Tensorflow version (GPU?): not installed (NA)
- Flax version (CPU?/GPU?/TPU?): not installed (NA)
- Jax version: not installed
- JaxLib version: not installed
- Using GPU in script?: Yes
- Using distributed or parallel set-up in script?: No

### Who can help?

@patil-suraj

### Information

- [ ] The official example scripts
- [X] My own modified scripts

### Tasks

- [ ] An officially supported task in the `examples` folder (such as GLUE/SQuAD, ...)
- [X] My own task or dataset (give details below)

### Reproduction

```python
from transformers import CLIPTokenizerFast, CLIPProcessor, CLIPModel
import torch

model_id = 'openai/clip-vit-base-patch32'
device = 'cuda'

tokenizer = CLIPTokenizerFast.from_pretrained(model_id)
processor = CLIPProcessor.from_pretrained(model_id)
model = CLIPModel.from_pretrained(model_id).to(device)

images = glob.glob('/data/index/abo/images/small/*/*.jpg')
dataset = Dataset.from_dict({'image': images}).cast_column('image', Image())

for i in range(0, len(dataset), 500):
  print(i)
  batch = processor(
    text=None,
    images=dataset[i:i+500]['image'],
    return_tensors='pt'
  )['pixel_values'].to(device)

  model.get_image_features(batch)
```

### Expected behavior

Each time I call `model.get_image_features(batch)` about 20GB of GPU memory is consumed. However, the GPU memory is never cleared, so I quickly run into a `CUDA out of memory` error. This memory also isn't cleared if I manually call `torch.cuda.empty_cache()`.

It's possible I'm missing a step, but to me it looks like there may be a bug in the model code causing it not to free GPU memory after it finishes inference on a batch?

Comments:
Maybe it's missing a `torch.no_grad`? Not sure though, cc @amyeroberts and @ArthurZucker if you have time to dive into this a bit more :-)

@sgugger thanks for the tip; I think that's the source of the issue! When I wrap my code in a `with torch.no_grad():` context it starts releasing GPU memory correctly. Not going to close the issue just yet since I'm not sure whether this *should* be the caller's responsibility or not when calling `get_image_features`, but at any rate the problem is solved for me. 🙂

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.
[CI-doc-daily] Remove RobertaPreLayernorm random tests
Author: ArthurZucker
Pull request: yes

# What does this PR do?
Let's wait until #20757 is merged to merge this. 
The checkpoints for `RobertaPreLayerNormForMaskedLM`, `RobertaPreLayerNormForQuestionAnswering`, `RobertaPreLayerNormForTokenClassification`, where not provided thus the expected values are random and should not be tested. 

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