noamaanMulla-03/transformers-issues huggingface dataset:
Adds package and requirement spec output to version check exception
Author: colindean
Pull request: yes

# What does this PR do?

It's difficult to understand what package is affected when `got_ver` here comes back None, so output the requirement and the package. The requirement probably contains the package but let's output both for good measure. This will hopefully be enough for the user to understand that something's wrong with the package if they've already installed it.

Non-exhaustive references for this problem aside from my own encounter:

* https://stackoverflow.com/questions/70151167/valueerror-got-ver-is-none-when-importing-tensorflow
* https://discuss.huggingface.co/t/valueerror-got-ver-is-none/17465
* https://github.com/UKPLab/sentence-transformers/issues/1186
* https://github.com/huggingface/transformers/issues/13356

I speculate that the root of the error comes from a conflict of conda-managed and pip-managed Python packages but I've not yet proven this.

## 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?

Tagging @stas00 because I think that's who `git blame` says touched that area of the code last.


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

This looks like a good improvement to me! Looks good to you, @stas00?

Looks like the test failures are transient package retrieval errors. I don't seem to have permission to rerun them myself.

You can always cheat ;)

```
# to push an empty commit - e.g. to force a CI rebuild - when there is no diff to push
git commit --allow-empty -m "Trigger CI"
git push
```

It looks like the tests are failing still because of pip install slowness… I've pushed a blank commit up once, I'll let a maintainer take it from here.

Could you rebase your branch on main? It may be due to a new release of a dep we have pinned since then (thinking of TensorFlow 2.10)

Rebase completed, but that code quality check still timed out.

All worked this time - thank you for your patience, @colindean!



Thank you! I'm happy to help. I hope somebody else will be helped by this fix!
[BLOOM] Update doc with more details
Author: younesbelkada
Pull request: yes

# What does this PR do?

Addressing https://huggingface.co/bigscience/bloom/discussions/86 
I think that we should add the full list of the trained languages on the documentation so that we can refer to that whenever any user will have any question related to the trained languages

cc @ydshieh @Muennighoff 


Comments:
cc @cakiki 

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

I would remove it, as it doesn't matter for the architecture, which these docs explain afaict? It's just an artefact of the data the models are trained on, hence it's arldy on the pretrained model & dataset READMEs. If someone were to release a BLOOM architecture model trained on different languages, this would be confusing imo.

Also should probably say `Pre-trained BLOOM models were officially released in the following sizes:`, as theoretically it's available in whatever version/size someone wants, just need to train it from scratch



Not sure if the model doc is restricted to the architecture.

- `T5` has `## Example scripts` section
- Some models include `training` and `generation` sections, for example, `t5` or `m2m_100`
- `Marian` has a `## Naming` section

But I agree that we can probably just have something similar to `Marian` doc:

```
Note: The list of languages used in training can be found [here](link to model card page).
```

Okay I agree with both points!
IMO we can just specify that this list of languages is only relevant for bloom models stated on the doc, and for custom bloom models one should refer to the corresponding model card.


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.
Set `use_cache` to `True` in `trocr` model
Author: younesbelkada
Pull request: yes

# What does this PR do?

- set `use_cache` to `True` for consistency with other `transformers` models
- With the PR https://github.com/huggingface/transformers/pull/18843 being merged, `trocr` became the last model in `transformers` that has `use_cache` set to `True`. 
- Except if there is any specific reason to let it to `False`, following #18843 , we think that it would be nice to set it to `True` for consistency with other models in `transformers` 
- All slow tests for `trocr` pass with this change

cc @stas00 @NielsRogge 

Thanks!

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

Great works for me! Thanks @stas00 

Thanks for approving! Merging
[doc] Fix link in `PreTrainedModel.save_pretrained` documentation
Author: tomaarsen
Pull request: yes

# What does this PR do?
Prevent a hyperlink from displaying as the full markdown representation near the bottom of the [PreTrainedModel.save_pretrained](https://huggingface.co/docs/transformers/main/en/main_classes/model#transformers.PreTrainedModel.save_pretrained) documentation. Currently, the additional backticks cause the body to be deemed a code block, preventing it from becoming a link like it should be.

## The current situation
![image](https://user-images.githubusercontent.com/37621491/190603300-fc50647b-0f5f-44ce-b7c6-e65d20a33622.png)

## The new situation
See [here](https://moon-ci-docs.huggingface.co/docs/transformers/pr_19065/en/main_classes/model#transformers.PreTrainedModel.save_pretrained) for the documentation after this PR.
![image](https://user-images.githubusercontent.com/37621491/190614737-564f28b8-eda2-419c-8d26-37c0a9a2216c.png)


## Before submitting
- [x] This PR fixes a typo or improves the docs (you can dismiss the other checks if that's the case).

## Who can review?
@sgugger

- Tom Aarsen

Comments:
_The documentation is not available anymore as the PR was closed or merged._
Organize test jobs
Author: sgugger
Pull request: yes

# What does this PR do?

This PR reorganizes the jobs run on CircleCI to avoid launching setups and running the test fetcher multiple times when there is no tests found to run.

More precisely, it always run the three following jobs:
- `check_code_quality`
- `check_repo_consistency`
- `fetch_tests`
Then the actual tests jobs are run after `fetch_tests` and are immediately cancelled graciously if the `fetch_tests` job didn't find any tests. All of them read the list of tests found by `fetch_tests` and don't re-run the test_fetcher.

This also introduces a `fetch_all_tests` job which creates the file all jobs are looking for and fill it with all the tests, so the nightly run can reuse the same jobs as the standard one. As a result, all jobs `xxx_all` can be safely deleted.

To see the result of a run with one py modified, look at this [report](https://github.com/huggingface/transformers/runs/8381129029) (commit [With a modification in one file only](https://github.com/huggingface/transformers/pull/19058/commits/44c3a39d420a9118dc3586104fe0d3fcaf7c2321) below). Some of the tests are run only on the impacted tests like others (examples, custom tokenizers, layout lm tests) are run on specific tests as long as there was at least a modification warranting some tests. This is the same behavior as before.

To see the result of a run with no code modification, look at this [report](https://github.com/huggingface/transformers/pull/19058/checks?check_run_id=8381322343) (commit [No change, no tests](https://github.com/huggingface/transformers/pull/19058/commits/4497731b550ee7db9f82f0d6d5384e352b51b904) below). All jobs are still run but take a couple of seconds only.

To see the result of a run with all tests run, look at the CI report of this PR (which cleans up a modification I added in the setup and merged by mistake).

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

I think your Build PR Documentation is hanging again :eyes:
Automatically tag CLIP repos as zero-shot-image-classification
Author: osanseviero
Pull request: yes

# What does this PR do?

This PR changes the mapping to map CLIP to zero-shot-image-classification in the Hub automatically. (internal [context](https://huggingface.slack.com/archives/C02EK7C3SHW/p1663315010068709))


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

Merging as it's all green now! Thanks for the review! :hugs:
Typo in configuration
Author: ariG23498
Pull request: no

Hey @NielsRogge 

I found an inconsistency in the documentation and the code for configuration of GroupViT. The default for `num_output_groups` is `[64, 8, 8]` (notice the last element in the list), while that documented is `[64, 8, 0]`. It would be great if we could make the two consistent.

https://github.com/huggingface/transformers/blob/8cb5ecd912e09301be126c6ce6e9a22ca7153da4/src/transformers/models/groupvit/configuration_groupvit.py#L158

https://github.com/huggingface/transformers/blob/8cb5ecd912e09301be126c6ce6e9a22ca7153da4/src/transformers/models/groupvit/configuration_groupvit.py#L204

Comments:
Hi,

thanks for spotting, feel free to fix it in #18020  

Will 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/main/CONTRIBUTING.md) are likely to be ignored.
Thoughts on updating package metadata
Author: ofek
Pull request: no

### Feature request

Switch to modern Python packaging standards.

### Motivation

The Python packaging ecosystem has standardized on the interface for build backends ([PEP 517](https://peps.python.org/pep-0517/)/[PEP 660](https://peps.python.org/pep-0660/)) and the format for metadata declaration ([PEP 621](https://peps.python.org/pep-0621/)/[PEP 631](https://peps.python.org/pep-0631/)). As a result, the execution of `setup.py` files is now [deprecated](https://blog.ganssle.io/articles/2021/10/setup-py-deprecated.html).

So, I'm spending my free time updating important projects so that they are modernized and set an example for others 😄

### Your contribution

I'll open a PR to show what that would look like.

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.
Propose file change
Author: NoelBram
Pull request: yes

I am looking to start contributing to OSS on GitHub and trying it out first with some simple grammar fixes. 

Comments:
The docs for this PR live [here](https://moon-ci-docs.huggingface.co/docs/transformers/pr_18536). 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.
TF: tests for (de)serializable models with resized tokens
Author: gante
Pull request: yes

# What does this PR do?

Since I'm touching the part of our code that handles resizing of token embeddings, I decided to boost our test suite there.

This PR adds two tests regarding resizing token embeddings, on the TF side:
1. Tests that we can resize the embeddings of a model, save it, and then restore it (with the resized embeddings), while keeping the same outputs for a given input in the resized range;
2. Tests that passing inputs outside the vocabulary triggers an exception -- surprisingly, TF doesn't do this check on GPU, which means that a user can resize the embeddings incorrectly and run forward passes (inference or training) with incorrect numerical results, but no exceptions.

⚠️ The tests added above do not pass in all cases, and fixes will be arriving over subsequent PRs. To ensure it doesn't manifest in our push CI, the following touches were added -- alternative suggestions are welcome!
- Test 1. is failing for several models, so a `@slow` decorator was added to keep track of the failures while allowing the push CI to pass. It seemed more sensible to me than to add `skip` in all failing cases 🤔 
- Test 2. Fails for all models with embeddings except BART, on GPU. Our push CI doesn't use GPU, so it is not impacted.

Comments:
_The documentation is not available anymore as the PR was closed or merged._
_no_load_in_8bit module list have custom ignored layers 
Author: ArthurZucker
Pull request: no

### Feature request

Could be awesome to have the property `_no_load_in_8bit = []` for the 8bit quantisation to allow custom layers to not be converted. 
CC @younesbelkada 

### Motivation

Would increase flexibility 

### Your contribution

Would be testing on `Jukebox`



Comments:
Hi @ArthurZucker 
Thanks a lot for the feature request! 
I have addressed a commit in https://github.com/huggingface/transformers/pull/18646 that should support adding an argument `no_load_in_8bit_modules` in `from_pretrained` function. Could you try it in your usecase and let me know if this helped?

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.

Closing as completed in #18646
Add type hints for PyTorch UniSpeech, MPNet and Nystromformer
Author: daspartho
Pull request: yes

Based on the issue https://github.com/huggingface/transformers/issues/16059
@Rocketknight1 could you please take a look at it?
Thanks :)

Comments:
Hi @daspartho, thanks for this! There's one problem, though - one of the functions you added type hints to was marked as `copied from` another function. This caused the `check_repository_consistency` test to fail. If you check the details on that test, the problem is that those functions were copied from `Wav2Vec2Encoder` and `Wav2Vec2EncoderStableLayerNorm`. If you add type hints to those `Wav2Vec2` functions so that they match, and then finally run `make fix-copies` that should resolve this!

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

Hello, @Rocketknight1
I did as you suggested but more copy inconsistencies arised, could you assist me with this?

Hi @daspartho, I think running `make fix-copies` in the root directory of the repo should fix this! If it's not working for you, let me know and I'll run it for you - just make sure the PR is set to allow commits from maintainers.

Hi, @Rocketknight1. I tried running it but I'm not sure why it's not working; could you please run it for me? Thanks :)

@daspartho Done! Double-check the changes and make sure you're happy with them, and I'll merge once you are.

@Rocketknight1 I've checked the changes and I'm happy with them. Thank you very much!
Add tests for legacy load by url and fix bugs
Author: sgugger
Pull request: yes

# What does this PR do?

This PR adds to tests we can load object with the single url to the relevant file, which is a deprecated behavior until v5, but that we unintentionally broke early because it's not tested. The tests added are marked to be removed at v5 (when they test deprecated behavior).

Comments:
_The documentation is not available anymore as the PR was closed or merged._
some data is dropped when encoding by LayoutLMv3Processor
Author: jack-gits
Pull request: no
Labels: name: bug

### System Info

I'm using LayoutLMv3Processor to encoding.
when I input (1, 82, 4) as boxes, the processor will extends the boxes to (1, 512, 4), but some boxes of input is dropped by processor as I can't find them in the encoding;
seems the last n boxes is dropped.

**_tokenizer = LayoutLMv3TokenizerFast.from_pretrained('microsoft/layoutlmv3-base')
processor = LayoutLMv3Processor(LayoutLMv3FeatureExtractor(apply_ocr=False), tokenizer)_**

**boxes of before encoding (512, 4)
boxes of after encoding (82, 4)
boxes of before encoding without duplicated  (58, 4)
boxes of after encoding without duplicated (82, 4)**

### Who can help?

_No response_

### 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

import numpy as np
from PIL import Image
from transformers import LayoutLMv3Processor, LayoutLMv3TokenizerFast, LayoutLMv3FeatureExtractor, \
    LayoutLMv3ForTokenClassification, AutoModelForTokenClassification, AutoConfig
from inference_util import prepare_annotation,load_original_dataset

image_paths,bboxes,ner_tags=load_original_dataset("cro_vl_fr/","test")


tokenizer = LayoutLMv3TokenizerFast.from_pretrained('microsoft/layoutlmv3-base')
processor = LayoutLMv3Processor(LayoutLMv3FeatureExtractor(apply_ocr=False), tokenizer)

item = image_paths[0]
image = Image.open( item).convert("RGB")

# get word-level annotations
image,words,boxes=prepare_annotation(image,bboxes[0])
boxes_2_points= np.hstack((np.array(boxes)[:,0:2],np.array(boxes)[:,4:6])).astype(int)

encoding = processor(image, words, boxes=boxes_2_points,
                                padding="max_length", truncation=True,
                                return_tensors="pt")

for k,v in encoding.items():
    encoding[k] = v.squeeze()

token_boxes = encoding['bbox'].numpy()

print("boxes of before encoding",np.shape(token_boxes))
print("boxes of after encoding",np.shape(boxes_2_points))
token_boxes=[tuple(a) for a in token_boxes]
token_boxes=np.array(list(set(token_boxes)))
boxes_2_points=[tuple(a) for a in boxes_2_points]
boxes_2_points=np.array(list(set(boxes_2_points)))

print("boxes of before encoding without duplicated ",np.shape(token_boxes))
print("boxes of after encoding without duplicated",np.shape(boxes_2_points))

### Expected behavior

original boxes should not be drop.

Comments:
Illegal instruction: 4 error when importing TextClassificationPipeline
Author: ehsong
Pull request: no
Labels: name: bug

### System Info

```
Name: transformers
Version: 4.22.0.dev0

Name: tensorflow
Version: 2.5.0

Name: torch
Version: 1.12.1

Python 3.9.12
```

I keep getting the error 'Illegal instruction: 4 ' when trying to import TextClassificationPipeline from transformers, does this have anything to do with the versions of the dependencies? 

It is quite confusing which versions of the packages are compatible with TextClassificationPipeline, I had the same error when with tensorflow version 2.9

### Who can help?

@Narsil

### Information

- [ ] 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

-

### Expected behavior

-

Comments:
hi @ehsong ,

Are you on Mac M1 ? Do you mind running `transformers-cli env` and printing the output here ?

What code are you using the trigger the issue ?

I googled and found this : https://stackoverflow.com/questions/14268887/what-is-the-illegal-instruction-4-error-and-why-does-mmacosx-version-min-10
I can't tell you exactly what's the issue, but it seems to be the environment you're running in that's causing 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/main/CONTRIBUTING.md) are likely to be ignored.
Unable to Infer on Bloom Model-2b5 using Deepspeed  
Author: Ravisankar13
Pull request: no
Labels: name: bug

### System Info

I was able to load the Bloom-2b5 Model onto my Colab notebook for text generation(Inference). When I use Deepspeed to load the model and try to inference the memory is not sufficient. I don't understand because with the help of deepspeed i should be able to load the larger model or atleast the same model. 

### Who can help?

_No response_

### Information

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

1. Load the 2b5 model- https://huggingface.co/bigscience/bloom-2b5
2. Infer with and without deepspeed - https://huggingface.co/docs/transformers/main_classes/deepspeed

### Expected behavior

Cuda error: Insufficient memory 

Comments:
Hey @Ravisankar13, could you please provide the script you have used, the deepspeed config, as well as the full stacktrace? It will be hard to help you with so little information.

cc @stas00 

@Ravisankar13, please see the work-in-progress here:
https://github.com/bigscience-workshop/Megatron-DeepSpeed/pull/308

You have a variety of different working solutions there. 

we will soon move those here.

Thanks for your response. Let me try them and get back to you

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.