noamaanMulla-03/transformers-issues huggingface dataset:
Loading a fairseq trained wav2vec2 model with transformers
Author: tensorfoo
Pull request: no

```
>>> import transformers
>>> from transformers import Wav2Vec2Processor, Wav2Vec2ForCTC
>>> processor = Wav2Vec2Processor.from_pretrained("wav2vec_small.pt")

```

gives the error: 
```
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/tmp/scratch/venv/lib/python3.8/site-packages/transformers/models/wav2vec2/processing_wav2vec2.py", line 110, in from_pretrained
    feature_extractor = Wav2Vec2FeatureExtractor.from_pretrained(pretrained_model_name_or_path, **kwargs)
  File "/tmp/scratch/venv/lib/python3.8/site-packages/transformers/feature_extraction_utils.py", line 304, in from_pretrained
    feature_extractor_dict, kwargs = cls.get_feature_extractor_dict(pretrained_model_name_or_path, **kwargs)
  File "/tmp/scratch/venv/lib/python3.8/site-packages/transformers/feature_extraction_utils.py", line 423, in get_feature_extractor_dict
    text = reader.read()
  File "/usr/lib/python3.8/codecs.py", line 322, in decode
    (result, consumed) = self._buffer_decode(data, self.errors, final)
UnicodeDecodeError: 'utf-8' codec can't decode byte 0x80 in position 0: invalid start byte

```

The file i'm trying to load is the wav2vec2 base model from the paper. 

Comments:
Hey @tensorfoo, there is a [conversion script](https://github.com/huggingface/transformers/blob/master/src/transformers/models/wav2vec2/convert_wav2vec2_original_pytorch_checkpoint_to_pytorch.py) that can be used to convert original fairseq checkpoints to HF transformer format. Does this solve your issue?

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.
Tensorboard missing values
Author: stefan-falk
Pull request: no

## Environment info

- `transformers` version: 4.12.5
- Platform: Ubuntu 18
- Python version: 3.8

### Who can help

Models:
- Wav2Vec2 @patrickvonplaten @anton-l 
## Information

Model I am using is Wav2Vec2ForCTC and it is regarding the eval/loss in Tensorboard.

For some (most) of my experiments I'd notice missing values for the eval/loss:

![image](https://user-images.githubusercontent.com/43335432/149923148-3b82e453-2447-4ba3-b8ff-6143827f1a81.png)

![image](https://user-images.githubusercontent.com/43335432/149923447-7ccb5bd8-2250-43c0-9ee1-2516bd183b6e.png)

I am not doing anything special and I am essentially following the basic fine-tuning examples.

Any idea why I am seeing this? 

Comments:
That's strange @severo do you maybe have any idea?

BTW, @stefan-falk feel free to share a link to your training repo here if the 30% WER seems to high for you. There are some hidden tricks on how to evaluate and train wav2vec2-base, *e.g.* https://github.com/pytorch/fairseq/issues/3227

No idea. @stefan-falk would you be able to share some of these tensorboard trace files (`*.tfevents.*`)?

@severo I've added the files as I found them in my logging-directory: 

[logs.zip](https://github.com/huggingface/transformers/files/7895914/logs.zip)

@patrickvonplaten 

I am using the same method as in your tutorial with the small change of using my own implementation for the error rates:

```python
def compute_metrics(processor, pred):
    pred_logits = pred.predictions
    pred_ids = np.argmax(pred_logits, axis=-1)

    pred.label_ids[pred.label_ids == -100] = processor.tokenizer.pad_token_id

    pred_str = processor.batch_decode(pred_ids)

    # we do not want to group tokens when computing the metrics
    label_str = processor.batch_decode(pred.label_ids, group_tokens=False)

    wer = error_rate(targets=label_str, predictions=pred_str, tokens="words")
    cer = error_rate(targets=label_str, predictions=pred_str, tokens="characters")

    return {"wer": wer, "cer": cer}
```

The reason is because `load_metric("wer")` uses `jiwer`, a library that constantly breaks on macOS somehow, so I replaced it.

Debugging this method tells me that all decoded labels (`label_str`) appear to be fine:

![image](https://user-images.githubusercontent.com/43335432/150109982-9e6b00db-ba5e-4492-995e-6d42213000a9.png)



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.

Unstale

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.
Adding missing type hints for mBART model (TF)
Author: reichenbch
Pull request: yes

Tensorflow Implementation model added with missing type hints

# What does this PR do?

Added type hints for mBART Tensorflow as described in https://github.com/huggingface/transformers/issues/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/master/CONTRIBUTING.md#start-contributing-pull-requests),
      Pull Request section?
- [ ] Was this discussed/approved via a Github issue or the [forum](https://discuss.huggingface.co/)? Please add a link
      to it if that's the case.
- [ ] Did you make sure to update the documentation with your changes? Here are the
      [documentation guidelines](https://github.com/huggingface/transformers/tree/master/docs), and
      [here are tips on formatting docstrings](https://github.com/huggingface/transformers/tree/master/docs#writing-source-documentation).
- [ ] Did you write any new necessary tests?


## Who can review?

@Rocketknight1 @gante 
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 docs for this PR live [here](https://moon-ci-docs.huggingface.co/docs/transformers/pr_16281). All of your documentation changes will be reflected on that endpoint.
Add type annotations of config for vision models
Author: johnnv1
Pull request: yes

I added type annotations for config parameters for Beit, ViT and Deit models at PyTorc. Original issue https://github.com/huggingface/transformers/issues/16059

@Rocketknight1

Just completing the #16151 as describe in #16251 

Comments:
The docs for this PR live [here](https://moon-ci-docs.huggingface.co/docs/transformers/pr_16263). All of your documentation changes will be reflected on that endpoint.
Can't import pipeline
Author: hassanzadeh
Pull request: no

- `transformers` 4.2
- Platform: MacOS
- Python version: 3.7.9
- PyTorch version (GPU?): CPU
- Tensorflow version (GPU?): CPU
- Using GPU in script?: No
- Using distributed or parallel set-up in script?: No
- Pip Version: Latest

I can't import the pipeline function:
```
from transformers import pipeline
```

Gives the following error:
```Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: cannot import name 'pipeline' from 'transformers' (unknown location)
```


Comments:
I can't reproduce on version 4.2.x or `master`.

This may have something to do with your environment. Can you let me know if the following threads help you out:

- https://stackoverflow.com/questions/58585690/python-cannot-import-unknown-location
- https://forum.learncodethehardway.com/t/importerror-unknown-location/2034/8
- https://python-forum.io/Thread-import-error-unknown-location

They're related to `parser` but it may be a similar issue to the one you're encountering here. 

#7333 Check your **tensorflow** version

@dg-data  I'm not using Tensorflow, does that matter? my tf is the latest version.

upgraded tf fixed it, thanks.

> 
> 
> upgraded tf fixed it, thanks.
@hassanzadeh
 Now,which version your tf is?   I just know it's need version 2.0.

According to [documentation](https://huggingface.co/transformers/installation.html), this should also run without TF at all, but with PyTorch alone. The answer seems to suggest that TF is required under all circumstances. I just tried a PyTorch-only installation and ran into the same error. Now shifting to TF, but I guess the documentation should be updated or the PyTorch-only install should be checked.

@chiarcos would you happen to have a reproducer to run into the issue with PyTorch-only installs? It shouldn't (and isn't) required to have TF installed for pipelines, so this is a bug that I, unfortunately, can't manage to reproduce.

Got same bug, on pytorch-only enviroment as well.

> 
> 
> @chiarcos would you happen to have a reproducer to run into the issue with PyTorch-only installs? It shouldn't (and isn't) required to have TF installed for pipelines, so this is a bug that I, unfortunately, can't manage to reproduce.

Apologies, I had shifted to TF installation already. This worked like a charm and the system is in production. I see to reproduce it when I have a minute.

Using conda pytorch environment and got the same bug

Same here

Same here, also installing TF in addition to PyTorch didn't help...
Swap `eval_delay signs`
Author: OllieBroadhurst
Pull request: no

### Who can help
@sgugger

## Information

The signs for the `eval_delay` comparisons need to be switched. This is pretty NB @sgugger as there are a lot of breakages involved here.

Greater than sign must be changed to less than sign [here](https://github.com/huggingface/transformers/blob/main/src/transformers/trainer_callback.py#L422) and [here](https://github.com/huggingface/transformers/blob/main/src/transformers/trainer_callback.py#L446).

I'll put in a PR if need be.



Comments:
Swap inequalities
Author: OllieBroadhurst
Pull request: yes

# What does this PR do?

The eval delay is a feature that allows a user to specify the number of steps/epochs to wait before the first evaluation can take place. This fixes a bug where the opposite behavior occurs - evaluation stops after eval_delay!

Fixes #16365


## 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?
@sgugger (sorry for the repeated tagging)


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

Thanks for fixing!
Make Transformers use cache files when hf.co is down
Author: sgugger
Pull request: yes

# What does this PR do?

This PR makes sure that we actually go look in the cached files when hf.co is down (or the internet connection of the user). The main issue was that we were raising the `HTTPError` too fast and didn't execute the code path that goes look in the cached files.

Since that error is now delayed, in case of a connection error and file not in the cache, we end up in the `ValueError` raised by `get_from_cache` [here](https://github.com/huggingface/transformers/blob/12428f0ef15bb3631e7a5f04672ddb05f363de97/src/transformers/utils/hub.py#L538), so I had to adapt a bit the cascade of errors in the `from_pretrained` methods.

This is then tested for all objects with a `from_pretrained` method (except Flax models since I didn't find a tiny flax model).

Comments:
_The documentation is not available anymore as the PR was closed or merged._
Update docs/README.md
Author: ydshieh
Pull request: yes

# What does this PR do?

Add information about how to perform doc testing **for a specific python module**. Potentially making the process less scaring (a lot of file changes) for the users. 

Also make it more clear/transparent that `file_utils.py` should be (almost) always included.


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

Do you mean: there are some python module files or doc files, for which if we want to run doctest, it will require changes (preparation) in files other than 

- the target files themselves
-  `file_utils.py`


> Ah sorry, I misread the command! This works indeed but could we maybe wait for the refactor of `file_utils` to merge this (and fix the paths)? I'll probably forget to adapt this otherwise.

Oh, yes for sure!

Will merge this PR once Sylvain's PR about file_utils is merged.
Adding type hints & decorator for TFT5
Author: Dahlbomii
Pull request: yes

@Rocketknight1 

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

Hi @Dahlbomii, thanks for this PR! It looks good, and thanks for doing both the type hinting and decorator change in the same PR. There's one failing TF test that's worrying us, but I've reviewed the whole PR and I can't see what would cause that, so I suspect it might be a problem with the test. We're investigating!

@Rocketknight1 the failing test is in a function associated to the decorator -- I can take a look 🔍 

HF was down when the tests were executed (HTTP errors all around) - rerunning tests :)

@Dahlbomii we have renamed our key branch from `master` to `main`. Fetching new commits in your fork, running these instructions (https://github.com/huggingface/transformers/issues/16289), then rebasing this branch should fix the tests.

Apologies for the extra work 🙏 

It's probably easier if I just make a new PR in a new fork, one sec!
add GPT-J ONNX config to Transformers
Author: chainyo
Pull request: yes

# What does this PR do?

I'm looking for contributing to `Transformers` repository by adding more OnnxConfig to available models on the hub.
I have created a little organization [ONNXConfig for all](https://huggingface.co/OWG) to track the models that needs support for ONNX.

This is the first contribution since CamemBERT OnnxConfig some months ago.

I took example on `GPT2` and `GPT-Neo` OnnxConfig but I'm not sure if everything is good or if `GPT-J` needs special things to be added.

So this PR is a work in progress. If anyone can send me ressources to read to understand if it lacks anything, it would be awesome! :hugs: 

## Who can review?

Models GPT2 / GPT-Neo
@LysandreJik @michaelbenayoun 


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

So what is the next step to make it merged ?

Hey @ChainYo the last thing to check is that the slow tests pass with:

```
RUN_SLOW=1 python -m pytest tests/onnx/test_onnx_v2.py -k "gpt-j"
```

We only run these on the `main` branch, so it would be good to know that they pass before we merge.

Apart from that, the PR looks really good - gently pinging @sgugger or @LysandreJik for final approval
Cache the files in get_fast_tokenizer_file()
Author: AnthonyBarbier
Pull request: no

# 🚀 Feature request

`transformers.BertTokenizer.from_pretrained()` calls `get_fast_tokenizer_file()` which downloads a file from the HuggingFace server but never adds it to the cache.

Would be useful to cache that file (in the same folder as the models) to make CI runs more robust.

## Motivation

Try to avoid having issues such as the one below in our CI runs:
```
E           requests.exceptions.HTTPError: 500 Server Error: Internal Server Error for url: https://huggingface.co/api/models/mrm8488/bert-small-finetuned-squadv2
```

This is a duplicate of https://github.com/huggingface/transformers/issues/14862 which was closed without getting fixed and I don't seem able to re-open it.

Comments:
Hello, thanks for opening an issue! This should be fixed by https://github.com/huggingface/transformers/pull/16362 which should drop in the next release.

Closing for now, feel free to reopen if it doesn't solve your issue.
Update readme with how to train offline and fix BPE command
Author: ncoop57
Pull request: yes

# What does this PR do?

Just some minor updates to the README with how to do offline training and fixed the BPE command to allow for easy copy and paste.

@lvwerra 


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

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

@lvwerra thanks for the edits, it reads a lot better!

Awesome, thanks for integrating the changes. There seems to be one comment still open? Do you disagree there or should we integrate it as well?

@lvwerra whoops, completely missed that comment 😅 just added it 😃

@ncoop57 Is it possible that you just closed the comment without applying it? 😃 

> @ncoop57 Is it possible that you just closed the comment without applying it? 😃

🤦 this is why I should not manage PRs from the GitHub app 😅. Okay @lvwerra , I think I commited all the changes 🤞

Looks good - feel free to merge it when you are ready and all the checks have passed. 🚀
Fix BigBirdModelTester
Author: ydshieh
Pull request: yes

# What does this PR do?

Current `BigBirdModelTester` with `block_size=16` will cause the model to change `attention_type` from `block_sparse` to `original_full`.

https://github.com/huggingface/transformers/blob/9fef668338b15e508bac99598dd139546fece00b/src/transformers/models/big_bird/modeling_big_bird.py#L2059-L2070

In the PT/Flax equivalence test (from `ModelTesterMixin`), the `FlaxBigBird` model will still use `block_sparse`. This causes the test failed with `1e-5`.

I couldn't find any word `not possible` or `impossible` in `modeling_flax_big_bird.py`.

Currently, I change  `block_size=16` to  `block_size=8` in order to make both models run with `block_sparse` and pass the test.
However, it would be good at some point to check if we should have the same `self.set_attention_type("original_full")` for `FlaxBigBirdModel`.

Question: is `block_size=16` chosen intentionally to test `self.set_attention_type` in PT's BigBird?

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

The expected value in `test_fast_integration` needs to be updated - if the change in this PR is OK.

Totally fine to switch to `block_size=8` if both test run the `"block_sparse"` mode this way :-) Thanks a lot for looking into this!

Update the expected value in `test_fast_integration` - to take into account of the change `block_size=8` and therefore `block_sparse`.
Type hints and decorator for TF T5
Author: Dahlbomii
Pull request: yes

@Rocketknight1 @gante 

Comments:
Thanks for this, the PR looks perfect to me! I see XLA generation tests failing, though - @gante could this be another situation like GPT-2 with some weird input names that are exposed by the decorator?

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

@gante I think some of those were changes to main that came in during the PR, including the missing XLA function that caused those test failures! Let me fix it up real quick.

@Dahlbomii Tests are green so we're going to merge now. Thanks for your help with this, and thanks for your patience as we both edited the file you were working on and renamed `master` to `main` midway through your PR!
Copy of the custom modeling file when saving a model
Author: benderama3
Pull request: no

Hi,

When using the dynamic code loading feature #13467 , the custom modeling file (eg: modeling.py) isn't copied into the folder when you save the model. 
In this case, you have to manually copy the file to the folder to be able to reload the model from the checkpoint.

Code example:
```
from transformers import AutoModel, AutoTokenizer

# Load a model from the hub with a custom modeling file
model = AutoModel.from_pretrained("ccdv/lsg-base-4096", trust_remote_code=True)
model.save_pretrained("saved_model")

# Fail to reload since the file isn't in the folder
model = AutoModel.from_pretrained("saved_model", trust_remote_code=True) 
```

Any plan to fix this ?

Thank you





Comments:
Yes, there are plans to couple this we the `AutoXxx.register` API so that when you register a new architecture, the custom code is copied to the right places when doing `save_pretrained`. I'm hoping to get to this by the end of the week.

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.

This should have been addressed by #15379, see the description of this PR or the new [doc page](https://huggingface.co/docs/transformers/master/en/custom_models) for more information!

This issue has been automatically marked as stale because it has not had recent activity. If you think this still needs to be addressed please comment on this thread.

Please note that issues that do not follow the [contributing guidelines](https://github.com/huggingface/transformers/blob/master/CONTRIBUTING.md) are likely to be ignored.
Fix readme links and add CI check
Author: sgugger
Pull request: yes

# What does this PR do?

This PR fixes links that are broken in the main README or don't add the necessary "docs". It also make `check_utils` automatically treat those problems when a user runs `make fix-copies`, or error when the CI runs the repo consistency checks and there is a wrong doc links.

The mistakes fixed/checked are:
- link to https://huggingface.co/transformers (missing the "docs")
- main not in the right place: https://huggingface.co/main/transformers


Comments:
CI failure has been fixed on master, so merging :-)
Rename semantic segmentation outputs
Author: NielsRogge
Pull request: yes

# What does this PR do?

This PR renames `SemanticSegmentationModelOutput` to `SemanticSegmentationOutput`, because of simplicity.

We also have `SequenceClassifierOutput` and `TokenClassifierOutput` for instance, so the "model" in the name is not really useful.

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

`Classifier` is a model name, whereas `Segmentation` is not. We could go for `SemanticSegmenter` if you dislike `SemanticSegmentationModelOutput`, but `SemanticSegmentationOutput` does not match the other model output names.

Agree with @sgugger , similarly to `SemanticSegmentationModelOutput`, I've added a `ImageClassificationModelOutput` (in resnet pr for now) following the same naming convention

Should we resurrect this? We went for `ImageClassifierOutput`, maybe we can go for `SemanticSegmenterOutput` as @sgugger proposed

@FrancescoSaverioZuppichini updated the PR accordingly