noamaanMulla-03/transformers-issues huggingface dataset:
Error when loading my trained model
Author: yanchao-yu
Pull request: no

Hello, 

I tried to train the question-answering model using `bert-base-uncased` on SQUADv1.1. The training process seems to be successfully completed. However, when I load the trained model, it said that `File "h5py/h5f.pyx", line 88, in h5py.h5f.open
OSError: Unable to open file (file signature not found)`

Here is my configuration for the training process: 
```
model_name_or_path: bert-base-uncased
do_train: True
do_eval: True
overwrite_output_dir: True
num_train_epochs: 10
per_device_train_batch_size: 12
per_device_eval_batch_size: 12
warmup_steps: 100
weight_decay: 0.01
learning_rate: 3e-5
evaluate_during_training: True
save_steps: 5000
```

And here is what I stored in my model directory: 
```
checkpoint-10000  checkpoint-35000  checkpoint-55000  pytorch_model.bin
checkpoint-15000  checkpoint-40000  checkpoint-60000  special_tokens_map.json
checkpoint-20000  checkpoint-45000  checkpoint-65000  tokenizer_config.json
checkpoint-25000  checkpoint-5000   checkpoint-70000  training_args.bin
checkpoint-30000  checkpoint-50000  config.json vocab.txt
```

I tried to load my model by 
```
self._model = BertForQuestionAnswering.from_pretrained(`./model/trained_squad/`, from_tf=True)
```

It would be appreciated if anyone can give me a clue about what happens here. Is there anything wrong with my training process? 

Best,
Yanchao



Comments:
Does 
```
self._model = BertForQuestionAnswering.from_pretrained(`./model/trained_squad/`)
```
work?

How silly I am! Thanks a lot. It works for me. 

When I take out `from_tf=True` it then says `[Error no file named ['pytorch_model.bin', 'tf_model.h5', 'model.ckpt.index', 'flax_model.msgpack'] found in directory distilbert-somm or `from_tf` and `from_flax` set to False.]()`

amazingly the following worked

tokenizer = AutoTokenizer.from_pretrained("...", use_auth_token="<key>", from_tf=True,)
model = AutoModelForSequenceClassification.from_pretrained("...", from_tf=True, use_auth_token=True)

i.e. the first use_auth_token requires the actual key, while the second has to be "True"
[doc] custom_models: mention security features of the Hub
Author: julien-c
Pull request: yes

 cc @McPatate @n1t0 and  @SBrandeis @osanseviero and everyone reading this, don't hesitate to regularly read the doc and create links between the hub doc and the libraries docs

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

your last change @stevhliu looks good to me, ready to merge for everyone?
HTML dev docs
Author: coyotte508
Pull request: yes

# What does this PR do?

This PR generates the *whole* docs inside the CI. So when the docs fail building, the CI is red instead of green.

You can see the generated html by `build_dev_documentation.yml` here: https://github.com/huggingface/doc-build-dev/tree/main/transformers/pr_15678

You can see the generated html by `build_documentation.yml` here: https://github.com/huggingface/doc-build/tree/main/transformers/doc-build-test

## Before submitting
- [x] This PR fixes a typo or improves the docs (you can dismiss the other checks if that's the case).

## Changes to make

This is a multi-repo PR, for now relying on the `kit` branch of `doc-builder`: https://github.com/huggingface/doc-builder/pull/94. When everything's ready, the `master` branch should be used instead.

Remove `@kit`:

```
pip install git+https://github.com/huggingface/doc-builder@kit -U
```

```
ref: "kit"
```

## 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.

<!-- Your PR will be replied to more quickly if you can figure out the right person to tag with @

Documentation: @sgugger

HF projects:

- datasets: [different repo](https://github.com/huggingface/datasets)
- rust tokenizers: [different repo](https://github.com/huggingface/tokenizers)

Examples:

- maintained examples (not research project or legacy): @sgugger, @patil-suraj
- research_projects/bert-loses-patience: @JetRunner
- research_projects/distillation: @VictorSanh

 -->


Comments:
_The documentation is not available anymore as the PR was closed or merged._
[Test refactor 3/5] Notification service improvement
Author: LysandreJik
Pull request: yes

This improves the notification service in Slack to provide a more comprehensive view over the tests.

Previously:

<img width="493" alt="image" src="https://user-images.githubusercontent.com/30755778/154765757-8ea3f016-b2df-471b-b161-2a31e67effe2.png">

Now:

<img width="614" alt="image" src="https://user-images.githubusercontent.com/30755778/154765783-dc62a4ad-d85b-42b6-af1b-b9e3914a2b4e.png">

To do before merge:
- Update the slack channel reference so that it posts to the right channel
- Ensure compatibility with the `push` job that runs on each commit to `master`

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

Lysandre, you're still summing up one+many on top of the new preview (categories) - this is confusing/misleading since most of the time it's the same error that happens on both setups and shouldn't be counted twice.

and why not do the exact same format for the categories? it'd be much easier to read if it's the same format for all groups and sub-groups, no?

and I'd still format it as:

```
1 | 2 | name1
5 | 6 | name2
```
which is much less noisier, but then I don't know how you format it - you said it was complicated.

if the header isn't too much work to add then:
```
1 | 2 | title
--|---|------- 
1 | 2 | name1
5 | 6 | name2
```



Formatting it as you offer isn't complicated, it was using pandas that I wasn't too keen on. I personally prefer the format above but it's probably because I have seen it too much by now :) Let's hear what others think.

And indeed, will update the categories at the top.

The format isn't too important to me - I'll get used to either way quickly I think :-) 

If I would have to choose, I'd prefer @stas00 solution though as well - would be nice to include the "single-gpu | multi-gpu" header every time 

I have updated the notification service to output the following format:

<img width="635" alt="image" src="https://user-images.githubusercontent.com/30755778/155244600-eb95b042-9f3a-4282-b505-16468f93fa68.png">
[Test refactor 4/5] Improve the scheduled tests
Author: LysandreJik
Pull request: yes

The scheduled tests now leverage a docker container pre-built two hours earlier than this run by the CI.

It generates a job for each folder in the `tests` folder.

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

Very cool!

Looks good to me! Also great that all `generation` tests from `test_generation_utils.py` are run! The errors:

```
ImportError: cannot import name 'json' from 'itsdangerous' (/usr/local/lib/python3.8/dist-packages/itsdangerous/__init__.py)
```

will be fixed once the previous PRs are merged?

> Looks good to me! Also great that all `generation` tests from `test_generation_utils.py` are run! The errors:
> 
> ```
> ImportError: cannot import name 'json' from 'itsdangerous' (/usr/local/lib/python3.8/dist-packages/itsdangerous/__init__.py)
> ```
> 
> will be fixed once the previous PRs are merged?

Actually encountered this problem locally now as well -> think we need to pin the `itsdangerous` library: https://serverfault.com/questions/1094062/error-from-itsdangerous-import-json-as-json-importerror-cannot-import-name-j
[Test refactor 5/5] Build docker images
Author: LysandreJik
Pull request: yes

These docker images will be built on a daily basis to be re-used by the CI.

Additional docker images will be built for Torch versions in [1.4-1.10] and TensorFlow versions in [2.3-2.7].

Comments:
_The documentation is not available anymore as the PR was closed or merged._
Fix build_documentation CI
Author: coyotte508
Pull request: yes

# What does this PR do?

We add more memory to the html build step with `NODE_OPTIONS: --max-old-space-size=6656` in the env.

We also mark the CI as failure if the html generation fails, or the git push fails afterwards.

<!-- Remove if not applicable -->

Fixes # (issue)


## 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/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?



Comments:
_The documentation is not available anymore as the PR was closed or merged._
A question about BertForSequenceClassification
Author: zxk19981227
Pull request: no

In my experiments, I trained a simple sentiment classification model on the SST dataset. But it is interest that it is hardly for the model to converge with BertForSequenceClassification but could converge easily with the simple BertModel's [CLS] +Linear. Did any one else met this problem and could explain the problem to me which part of the pool ,the tanh or the pretrained linear made this problem?

Comments:
Hello, thanks for opening an issue! We try to keep the github issues for bugs/feature requests.
Could you ask your question on the [forum](https://discuss.huggingface.co) instead?

Thanks!

Ok,thank your
[Wav2Vec2FeatureExtractor] Align documentation with code
Author: lsb
Pull request: yes

In the code, `do_normalize` defaults to True: https://github.com/huggingface/transformers/blob/master/src/transformers/models/wav2vec2/feature_extraction_wav2vec2.py#L74

The documentation describe `do_normalize` as a desirable option to set to true, so this PR fixes the documentation to match the code.

## 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/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?



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

https://moon-ci-docs.huggingface.co/docs/transformers/pr_15468/en/model_doc/wav2vec2#transformers.Wav2Vec2FeatureExtractor.do_normalize 🎉 

Sorry for being so incredible late here

Happy to help make things better 🤗 🚀
Fix add-new-model-like when old model checkpoint is not found
Author: sgugger
Pull request: yes

# What does this PR do?

This PR fixes the add-new-model-like command when the old model checkpoint can't be read in its modeling file (because there is no `_CHECKPOINT_FOR_DOC` basically). In this case, the user will be asked to provide it to avoid random failures like when trying to build a new model from rag.

Comments:
_The documentation is not available anymore as the PR was closed or merged._
Save Finetuned XLM-RoBERTa on Tf-Keras
Author: Komalrathod55
Pull request: no

I am finetuning XLM-RoBERTa for text classification. I am finetuning model on Tensorflow-keras. I have trained model on google colab GPU.  I used below save method from keras as shown below to save my model. 

```
model.save("/content/drive/MyDrive/TrainedModel")
loaded_model = tf.keras.models.load_model("/content/drive/MyDrive/TrainedModel")
```

It saves saved model but gives below error when loading the model on CPU. How can I load model to run it?

[/usr/local/lib/python3.7/dist-packages/tensorflow/python/training/py_checkpoint_reader.py](https://localhost:8080/#) in get_tensor(self, tensor_str)
     65   try:
     66     return CheckpointReader.CheckpointReader_GetTensor(
---> 67         self, compat.as_bytes(tensor_str))
     68   # TODO(b/143319754): Remove the RuntimeError casting logic once we resolve the
     69   # issue with throwing python exceptions from C++.
** IndexError: Read less bytes than requested**

I got below warning when saving the model using above function. The saved model size is 7.43 MB. 

WARNING:absl:Found untraced functions such as encoder_layer_call_fn, encoder_layer_call_and_return_conditional_losses, embeddings_layer_call_fn, embeddings_layer_call_and_return_conditional_losses, dense_layer_call_fn while saving (showing 5 of 422). These functions will not be directly callable after loading.
INFO:tensorflow:Assets written to: /content/drive/MyDrive/TrainedModel/assets
INFO:tensorflow:Assets written to: /content/drive/MyDrive/TrainedModel/assets

Comments:
cc @gante @Rocketknight1 

Hi @Komalrathod55 👋 The `.save` method saves a myriad of TensorFlow-related objects, which may be tricky to serialize and/or load due to our complex architectures. We recommend using TF's `model.save_weights("some_folder/your_model_name.h5")` (with the `.h5` file extension) to store the weights, and then our `.from_pretrained("some_folder")` model class method to restore them.

Let me know if this solves your issue :)

Hi @gante , Thank you for your response. I tried the solution provided by you. But I was getting error regarding config file and model name.

1. OSError: Error no file named tf_model.h5 found in directory 
2. file some_folder/config.json not found

 So I renamed model as tf_model.h5 and put config.json in "some_folder".

This works well but this model runs very slow. The time to process a single file is 3.6 seconds. Can you let me know your insights about this issue? Thank you.

My apologies, I should have mentioned that the model must be named `tf_model.h5` -- I'm glad that it runs now. As for speed, I'm afraid we'll need more details -- for instance, if you are trying to run `model.generate()`, speed is a known issue that we are addressing at the moment.

Since the goal of these issues is to report and solve potential bugs, which we've discarded, I'd like to ask you to move the conversation to [our forum](https://discuss.huggingface.co/), where our members and the community can pitch in with solutions.
Fix from_pretrained with default base_model_prefix
Author: sgugger
Pull request: yes

# What does this PR do?

There is a subtle bug in `from_pretrained` that was discovered by @NielsRogge with the Enformer model. Basically, `from_pretrained` will silently not load anything when a subclass does not define `base_model_prefix`. This is because the defaults is left at `""` which then:
- sets `has_prefix_module` to `True`
- changes the `prefix` to `"."` since the model does not have any attribute named `""`
- then ignore all weights

This PR fixes that and removes the `base_model_prefix` attribute from the custom modeling classes used during the test, to make sure we don't have any regression on this.

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

Ah yeah that makes sense! Thanks a lot!
Fix handling of multiple stopping criteria
Author: christiancosgrove
Pull request: yes

If multiple stopping criteria are used, the current logic will break.

Comments:
@christiancosgrove Do you mind sharing the bug you are trying to fix ?

What you are trying to fix should be handled here: https://github.com/huggingface/transformers/blob/master/src/transformers/generation_stopping_criteria.py#L113

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.
Revert changes in logit size for semantic segmentation models
Author: sgugger
Pull request: yes

# What does this PR do?

This PR reverts the changes made in the size of the returned logits of semantic segmentation models made in #15469 because it leads in some situations to two consecutive resizes:
- one to resize the output to the same size of the input
- one to resize the output to the size of the original image
Two different interpolations with nearest neighbors is a bad idea and users will get a best result by just doing one interpolation to get the segmentation mask to the size they want.

This restores backward compatibility, but still introduces a new argument `resize_logits` for situations where the user wants the logits the same size as the `pixel_values` passed to the model.

Comments:
_The documentation is not available anymore as the PR was closed or merged._
Fix semantic segmentation pipeline test
Author: sgugger
Pull request: yes

# What does this PR do?

This fixes the pipeline test for semantic segmentation, which now fails as a consequence of the revert in #15722 

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

I don't think we'll make another breaking change like this soon, so we're safe :-) 

@sgugger I am more thinking along the line of the resampling algorithm changes subtly in torch or different hardware has different floating errors. 

Shouldn't happen in theory, but we all know theory is a far far away galaxy.
addeing tokens to tokenizer for training and inference worsens  prediction immensely
Author: jheinecke
Pull request: no

I use the huggingface Trainer class to finetune a mT5 model. Since my data (AMR graphs) contains mayn tokens like `:ARG0`, `:op2` or `:name`, which are generally split into wordpieces I added those 219 tokens to the tokenizer with

```
from  transformers import MT5ForConditionalGeneration, MT5Tokenizer
tokenizer = MT5Tokenizer.from_pretrained("google/mt5-base")
model     = MT5ForConditionalGeneration.from_pretrained("google/mt5-base")
toks = [ ... my ist of tokens ...]
tokenizer.add_tokens(toks, special_tokens=False)
model.resize_token_embeddings(len(tokenizer))
```

and than starting the training.

Once the model is finetuned I run my test, and once again I add the same tokens in the same order to the tokenizer. But the result is catastrophic, it drops from 80% F1 to 50%, so evidently something is going wrong. I compared the tokenisation with and without added tokens  and this looks OK. But I have not the slightest idea where to check. Can you give me a hint about the error I'm committing ?

## Environment info

- `transformers` version: 4.11.3
- Platform: Linux-5.13.0-30-generic-x86_64-with-glibc2.17
- Python version: 3.8.12
- PyTorch version (GPU): 1.9.1
- Jax version: not installed
- JaxLib version: not installed
- Using GPU in script?: yes
- Using distributed or parallel set-up in script?: no

Comments:
To clarify me question: I thought (possibly erroneously) that the new tokens will have random vectors which will be "learned" during the finetuning. If this is not the case, I have my answer ...

Hey @jheinecke. The best place to ask this question would be the [forum](https://discuss.huggingface.co/). We use issues for bug reports and feature requests. Thanks! 

OK, thanks, I missed that. I'll pose my question there
Add model specific output classes to PoolFormer model docs
Author: tanaymeh
Pull request: yes

# What does this PR do?
This PR adds 2 model-specific outputs (defined in the `modeling_poolformer.py`) to the PoolFormer docs - `PoolFormerModelOutput` and `PoolFormerClassifierOutput`

## Who can review?
@NielsRogge 

Comments:
_The documentation is not available anymore as the PR was closed or merged._
[WiP] support new Marian models
Author: patil-suraj
Pull request: yes

# What does this PR do?

This PR updates the Marian model:
1. To allow not sharing embeddings between encoder and decoder.
2. Allow tying only decoder embeddings with `lm_head`.
3. Separate two `vocabs` in `tokenizer` for `src` and `tgt` language

To support this, the PR introduces the following new methods:
- `get_decoder_input_embeddings` and `set_decoder_input_embeddings`
To get and set the decoder embeddings when the embeddings are not shared. These methods will raise an error if the embeddings are shared.
- `resize_decoder_token_embeddings`
To only resize the decoder embeddings. Will raise an error if the embeddings are shared.

This PR also adds two new config attributes to `MarianConfig`:
- `share_encoder_decoder_embeddings`: to indicate if emb should be shared or not
- `decoder_vocab_size`: to specify the vocab size for decoder when emb are not shared.

And the following methods from `PreTrainedModel` class are overridden to support these changes:
- `tie_weights`
- `_resize_token_embeddings`

Fixes #15109 

Comments:
_The documentation is not available anymore as the PR was closed or merged._
Re-enable doctests for the quicktour
Author: sgugger
Pull request: yes

# What does this PR do?

This PR re-enables the doctests for the quicktour. It shouldn't be merged without its [companion PR](https://github.com/huggingface/doc-builder/pull/112) on the doc-builder side to properly recognize the new framework split comment and to remove the doctest flags on some lines.

I've adapted the example applying the pipeline on the whole superb dataset because:
1. it was way too long
2. writing a custom generator using an object not documented and not even in the main init of Transformers is too advanced for the quicktour.

I've also update the guide for doctests.

Comments:
_The documentation is not available anymore as the PR was closed or merged._
Framework split model report
Author: LysandreJik
Pull request: yes

This updates the CI report for *models* to be split by framework.

From the following:
![image](https://user-images.githubusercontent.com/30755778/155612613-d3303e89-5788-42db-8538-7126241ca977.png)

To the following:
![image](https://user-images.githubusercontent.com/30755778/155613678-be67cd8b-b658-46fa-9c31-6d03653ec077.png)

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