noamaanMulla-03/transformers-issues huggingface dataset:
BioGPT Token Classification
Author: upjabir
Pull request: no
Labels: name: Good First Issue

### Feature request

It would be nice to have this available.

### Motivation

working on biomedical token classification datasets and I would like to try BioGPT with them.

### Your contribution

I could send a PR if you want. I guess it shouldn't be too hard.

Comments:
Yes, feel free to contribute :)

sure, Let me work on it

> sure, Let me work on it

Are you working on it? Else I will take it up.

@kurchi1205 Am working on it . The problem is that biogpt doesnt have fast tokenizer . Currenlty am in a testing phase
added biogpt token classifier
Author: upjabir
Pull request: yes

# What does this PR do?
Added Token Classifier for BioGpt

Fixes #21786


## 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.
- [x] 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).
- [x] 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.
@ArthurZucker @younesbelkada @NielsRogge @sgugger


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

@ArthurZucker am attaching the error from circleci in here. Please do a check on it.
```python
 python setup.py egg_info did not run successfully.
  │ exit code: 1
  ╰─> [7 lines of output]
      fatal: not a git repository (or any of the parent directories): .git
      Traceback (most recent call last):
        File "<string>", line 2, in <module>
        File "<pip-setuptools-caller>", line 34, in <module>
        File "/tmp/pip-install-xnk_5lxf/onnx_fafa120a391e44089efd375a22a6dba2/setup.py", line 72, in <module>
          assert CMAKE, 'Could not find "cmake" executable!'
      AssertionError: Could not find "cmake" executable!
      [end of output]  

``` 

> @ArthurZucker am attaching the error from circleci in here. Please do a check on it.
> 
> ```python
>  python setup.py egg_info did not run successfully.
>   │ exit code: 1
>   ╰─> [7 lines of output]
>       fatal: not a git repository (or any of the parent directories): .git
>       Traceback (most recent call last):
>         File "<string>", line 2, in <module>
>         File "<pip-setuptools-caller>", line 34, in <module>
>         File "/tmp/pip-install-xnk_5lxf/onnx_fafa120a391e44089efd375a22a6dba2/setup.py", line 72, in <module>
>           assert CMAKE, 'Could not find "cmake" executable!'
>       AssertionError: Could not find "cmake" executable!
>       [end of output]  
> ```

You need to pull from main for this!
Fix llama tokenizer
Author: ArthurZucker
Pull request: yes

# What does this PR do?
Draft but:
- Fixes the conversion script 
- update the llama default special tokens 
- fixed compatibility issues
- cleanup llama tokeniztion code
- add tests

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

cc @Narsil for visibility! 

This will need to wait for #22341 

Yes, on it! 

Will finish this tomorrow!

Hi! Does this PR the decoding part of the tokenizer? Seems like it always prefixes the output with space.

For instance, `tokenizer.decode(1)` returns ` 
`, 

Yes, it does: `print(f'\'{tokenizer.decode(tokenizer.encode("Hello world"), skip_special_tokens = True)}\'',)` outputs `'Hello world'  😉
I want the 4.28.0.dev0 version of transformers
Author: gyh123wqe
Pull request: no

### Feature request

I want the 4.28.0.dev0 version of transformers

### Motivation

I want the 4.28.0.dev0 version of transformers

### Your contribution

I want the 4.28.0.dev0 version of transformers

Comments:
you can pip install with source code
Generate: `TextIteratorStreamer` (streamer for gradio)
Author: gante
Pull request: yes

# What does this PR do?

Following the previous streamer PR (#22449), this PR adds a streamer that can be used as an iterator. If we want to use the iterator while generate is running, they must be on separate threads (naturally).

The interface looks quite simple, as can be seen in the documentation 🤗 The only kink is the need to call generation on a separate thread, but there is no great way around it (at most we can design an `if` branch inside generate where, if a streamer is used, generate is called in a separate thread... but that seems overkill for now).

A Gradio demo running on this branch can be seen [here](https://huggingface.co/spaces/joaogante/chatbot_transformers_streaming). There is pretty much no slowdown compared to a non-streamer call.

Inspired by @oobabooga's work (see [this comment](https://github.com/huggingface/transformers/pull/22449#issuecomment-1491311486)).

Comments:
_The documentation is not available anymore as the PR was closed or merged._
piepline not loading the model
Author: deepanshudashora
Pull request: no

### System Info

ubuntu 22.04

### Who can help?

@Narsil 

### Information

- [X] 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

```
    pipe = pipeline("document-question-answering", model=model,tokenizer=tokenizer)
  File "/home/ubuntu/.local/lib/python3.10/site-packages/transformers/pipelines/__init__.py", line 811, in pipeline
    raise Exception(
Exception: Impossible to guess which feature extractor to use. Please provide a PreTrainedFeatureExtractor class or a path/identifier to a pretrained feature extractor.
```

### Expected behavior

SHould be able to load the model

Comments:
How? This pipeline requires a feature extractor to see the document doesn't it? 

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.
Ability to specify certificate for running language training modules (e.g. run_mlm.py)
Author: codesnail
Pull request: no

### Feature request

Add a command line param in training modules, e.g., run_mlm.py to take in a custom certificate file for the requests module.

### Motivation

When running behind a VPN, the training modules e.g., run_mlm.py script gives SSL errors when trying to connect to URLs, e.g., to download a pre-trained model. It gives an error like this:

urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='huggingface.co', port=443): Max retries exceeded with url: /roberta-base/resolve/main/config.json (Caused by SSLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: self signed certificate in certificate chain (_ssl.c:997)')))

This seems to be caused when the code from a device that is behind a VPN, because the VPN connection uses a custom root cert.

### Your contribution

I was able to resolve the issue by specifying a certificate explicitly in requests.get() in _http.py, as follows:

ca = "company_root_ca_exported_from_my_browser"

then modified the following line:
response = requests.request(method=method, url=url, **kwargs)

to this:

response = requests.request(method=method, url=url, verify=ca, **kwargs)


Comments:
Examples are just examples. They can't contain 1,000 arguments to support every user's need without becoming unreadable. In this instance, you should just change the example to suit your need.

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.
fix LayoutLMv3TokenizerFast subword label after 'Ġ' token
Author: thibaultdouzon
Pull request: yes

LayoutLMv3TokenizerFast produces empty 'Ġ' token with `offset_mapping = (0, 0)`. 
Next token is wrongly assumed to also be beginning of word and isn't correctly assigned `pad_token_label`.
This may lead to misalignment of words and token representations.
Other BPE tokenizers might be affected

Add check for previous token if it had an empty `offset_mapping` (not including special tokens)
Remove copy check from LayoutLMv2TokenizerFast for `_batch_encode_plus` because it is not affected (uses WordPiece instead of BPE)
Modify test with text that produce 'Ġ' token.

Fixes issue: #19978

@NielsRogge 
@ArthurZucker 


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

Also cc @amyeroberts 

Hi @ArthurZucker, thanks for your investigations.

This PR fixes the problem for LayoutLMv3 but I expect the problem to exist on other models using Fast BPE tokenization, I will take a look when I can to list all impacted models that need a fix.

Thanks a lot for this fix, would you be able to take into account my comment such that we can merge it? 🙏 

Thanks!

Btw the same fix could then be applied to LayoutLMv2 and LayoutXLM

LayoutLMv2 uses WordPiece and not BPE. From what I saw its vocabulary does not contain empty token and thus cannot produce (0, 0) offset_mapping when encoding.
Multiple eval datasets can only use last dataset for best checkpoint
Author: hawkeoni
Pull request: no

I have a setup where I evaluate the model on several datasets and only the metrics from the last dataset can be used. The [code from Trainer](https://github.com/huggingface/transformers/blob/559a45d1dc1f46d6e9942cdc9ff5eef5a811a59d/src/transformers/trainer.py#L2234) looks like:

```python
 if self.control.should_evaluate:
            if isinstance(self.eval_dataset, dict):
                for eval_dataset_name, eval_dataset in self.eval_dataset.items():
                    metrics = self.evaluate(
                        eval_dataset=eval_dataset,
                        ignore_keys=ignore_keys_for_eval,
                        metric_key_prefix=f"eval_{eval_dataset_name}",
                    )
            else:
                metrics = self.evaluate(ignore_keys=ignore_keys_for_eval)
            self._report_to_hp_search(trial, self.state.global_step, metrics)

        if self.control.should_save:
            self._save_checkpoint(model, trial, metrics=metrics)
````


Only the last metric is used, when datasets are passed as a `Dict[str, Dataset]`
Is this a bug?
A possible fix:
````python

if self.control.should_evaluate:
            if isinstance(self.eval_dataset, dict):
                metrics = {}
                for eval_dataset_name, eval_dataset in self.eval_dataset.items():
                    dataset_metrics = self.evaluate(
                        eval_dataset=eval_dataset,
                        ignore_keys=ignore_keys_for_eval,
                        metric_key_prefix=f"eval_{eval_dataset_name}",
                    )
                    metrics.update(dataset_metrics)
            else:
                metrics = self.evaluate(ignore_keys=ignore_keys_for_eval)
            self._report_to_hp_search(trial, self.state.global_step, metrics)

        if self.control.should_save:
            self._save_checkpoint(model, trial, metrics=metrics)
```

````
Please, close this if this is the intended behavior. If it's not I can submit a pr with fixes.

Comments:
It's possible there is a bug, so please open a PR if you think you have the right fix!
Fix missing metrics with multiple eval datasets
Author: hawkeoni
Pull request: yes

Fixes #22530
[Issue](https://github.com/huggingface/transformers/issues/22530)
**tl;dr** - `Trainer` only keeps the last metric when using multiple eval datasets. This PR fixes that by merging metrics from all eval datasets into one dict.

## 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.
- [x] 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).
- [x] Did you write any new necessary tests?

@sgugger 


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

It seems like the tests failed on an irrelevant "File not found error" in tokenizers, but I can not rerun the tests. 
@sgugger would you kindly trigger them again?

:call_me_hand:
Generate: Enable easier TextStreamer customization
Author: vblagoje
Pull request: yes

# What does this PR do?

Minimally adapts recently integrated (https://github.com/huggingface/transformers/pull/22449) by adding a more obvious API hook for streaming tokens yet retains all the current semantics.

I am excited to use TextStreamer but I found the hook-in API not as intuitive as it could be if one needs to customize token printing. For example, I need to use specific colouring to print arriving tokens, yet achieving this without a complete TextStreamer rewrite is not as easy. We can easily create an obvious hook-in method:

```def on_new_token(self, token: str, stream_end: bool = False):```

This method is called by TextStreamer yet its subclasses can easily customize printing. The default implementation of on_new_token method simply prints tokens to stdout as it currently does. 

I don't foresee any major documentation updates as a consequence of this PR. 

## 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?
@gante @sgugger 

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

> I like the structure, but I dislike the name `on_new_token`. It's actually a callback on "new print-ready text". Perhaps `on_finalized_text`? WDYT?

@gante I am completely indifferent regarding the name. Please adjust the name as you like! 
On a second look, I'm also not 100% sure whether to put this method into TextStreamer only. Your call. 

Let's keep it in `TextStreamer` for now. It's still early to tell how people will want to use it :)
Update test_image_processing_pix2struct.py
Author: younesbelkada
Pull request: yes

# What does this PR do?

This PR should fix the failing test on `main`. 
The fix is to replace the previous image with the one I have uploaded on the Hub: https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/transformers/tasks/australia.jpg

cc @sgugger 

Comments:
_The documentation is not available anymore as the PR was closed or merged._
Fix OPTForQuestionAnswering doc string
Author: curlup
Pull request: yes

Fixes OPTForQuestionAnswering doc string for more adequate model answer decoding

## 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/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.



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

@sgugger Thanks! Done! (took me two attempts 😅 )
Generate: Add text streamer decoding options
Author: gante
Pull request: yes

# What does this PR do?

In advance of communicating the iterator streamer with Gradio demos, adds two important options:
1. option to skip the prompt in the streamer (e.g. for chatbots)
2. option to receive `decode()` kwargs (e.g. to skip special tokens)

It also makes use of the changes in #22516 to make the iterator streamer much more compact -- it is now a child class of the stdout streamer, with a few modifications.

Comments:
_The documentation is not available anymore as the PR was closed or merged._
Add `torch_dtype` attribute
Author: younesbelkada
Pull request: yes

# What does this PR do?

Disclaimer: Maybe there is a more canonical way to retrieve the `torch_dtype` of a loaded model !

I propose to add the attribute `torch_dtype` inside `PreTrainedModel` so that it can be conveniently retrieved. Useful for example for `peft` where I see this solution as one of the possible solution to fix forward pass issues in half-precision for `PrefixTuning` models.

To provide more context, the prefix tuning models feed to the base model [new `past_key_values`](https://github.com/huggingface/peft/blob/main/src/peft/tuners/prefix_tuning.py#L103-L109). Those are computed by default in `float32` (and should always stay in `float32`). However, if the base model is in half-precision, the forward pass would fail (`dtype` mismatch errors). This PR would make the retrieving process of the base model's `dtype` super easy, thus handling this error.

cc @sgugger @pacman100 

Comments:
The `torch_dtype` in the config can't be used for that? 

I don't think so because sometimes (and very often) you load `fp32` models from the Hub, and not all models on the Hub have the `torch_dtype` attribute

Also there is this : 
```python 
    @property
    def dtype(self) -> torch.dtype:
        """
        `torch.dtype`: The dtype of the module (assuming that all the module parameters have the same dtype).
        """
        return get_parameter_dtype(self)
```
but maybe all the parameters do not have the same dtype? 


Ah that works! Thanks for the pointer! I should have digged further :D

_The documentation is not available anymore as the PR was closed or merged._
🚨🚨🚨 `[NLLB Tokenizer]` Fix the prefix tokens 🚨🚨🚨
Author: ArthurZucker
Pull request: yes

# What does this PR do?
The NLLB tokenizer's suffix and prefix token were wrong w.r.t to the paper. 
This breaking change fixes the tokenizer. 
Could be none breaking if we add these to the configuration file maybe? But it is a required change
Have to update the tests but should be good.



The big problem was the `prefix` and `suffix` tokens. 
The previous version adds `[self.eos_token_id, self.cur_lang_code]`  at the end of the token sequence for both target and source tokenization. This is wrong as the `NLLB` paper mentions (page 48, 6.1.1. Model Architecture) : 
> Note that we prefix the source sequence with the source language, as opposed to the target
language as previously done in several works (Arivazhagan et al., 2019; Johnson et al.,
2017). This is primarily because we prioritize optimizing zero-shot performance of our
model on any pair of 200 languages at a minor cost to supervised performance.

Previous behaviour:
```python 
>>> from transformers import NllbTokenizer
>>> tokenizer = NllbTokenizer.from_pretrained("facebook/nllb-200-distilled-600M")
>>> tokenizer("How was your day?").input_ids
[13374, 1398, 4260, 4039, 248130, 2, 256047]
>>> # 2: '
'
>>> # 256047 : 'eng_Latn'
```
New behaviour 
```python 
>>> from transformers import NllbTokenizer
>>> tokenizer = NllbTokenizer.from_pretrained("facebook/nllb-200-distilled-600M")
>>> tokenizer("How was your day?").input_ids
[256047, 13374, 1398, 4260, 4039, 248130, 2]
```

Enabling the old behaviour:

```python 
>>> from transformers import NllbTokenizer
>>> tokenizer = NllbTokenizer.from_pretrained("facebook/nllb-200-distilled-600M", legacy_behaviour = True)
```

This parameter should be part of the `tokenizer_config.json`.

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

Thank you for the implementation, @ArthurZucker!

Could you please put in the PR description the gist of the breaking change with a code sample, and how to revert to the previous behavior if users would like that?

Thank you

Indeed thanks for the tip on how to enable that swiftly! 

One test is failing with NLLB (running  slow ones locally, `test_encode_decode_with_spaces`), fixing this before merging.
Edit: Fast and slow have a different behaviour! `space_between_special_tokens` does not exist in rust (yet, PR coming soon)

Cool, I like the flag :)

Can the doc be shown more prominently? Maybe to replace the disclaimer mentioning to tag me? A disclaimer mentioning that we changed it to what it is now, with the code snippet?



![image](https://user-images.githubusercontent.com/30755778/229569649-9c87f71d-ba2c-4db4-8531-cf441373ff03.png)

Thanks both for proof reading! 👍🏻