noamaanMulla-03/transformers-issues huggingface dataset:
'MarianTokenizer' object has no attribute 'target_encoder'
Author: bariluz93
Pull request: no
Labels: name: bug

### System Info

- `transformers` version: 4.19.0.dev0
- Platform: Linux-4.19.129-aufs-1-x86_64-with-debian-10.1
- Python version: 3.7.3
- Huggingface_hub version: 0.5.1
- PyTorch version (GPU?): 1.11.0+cu102 (False)
- Tensorflow version (GPU?): 2.8.0 (False)
- Flax version (CPU?/GPU?/TPU?): not installed (NA)
- Jax version: not installed
- JaxLib version: not installed
- Using GPU in script?: no
- Using distributed or parallel set-up in script?: no


### Who can help?

@patil-suraj @SaulLu

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

model_name='Helsinki-NLP/opus-mt-en-he'
tokenizer = MarianTokenizer.from_pretrained(model_name)
tokenizer.get_tgt_vocab()


### Expected behavior

I expected to get the target vocab but instead, i got the error 
AttributeError: 'MarianTokenizer' object has no attribute 'target_encoder'
I need to find a way to separate vocab into the source and target vocabs instead of the current vocab which contains a mix of both languages.

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.
Conversion from TF BERT Checkpoint to HF Model Breaks
Author: vladd-i
Pull request: no
Labels: name: bug

### System Info

I'm trying to convert the BERT TF1 checkpoint provided in [MLPerf GDrive](https://drive.google.com/drive/folders/1oQF4diVHNPCclykwdvQJw8n_VIWwV0PT?usp=sharing) to a HF BERT model using the following transformer-cli command provided in [HF documentation](https://huggingface.co/docs/transformers/converting_tensorflow_models):
```
transformers-cli convert --model_type bert --tf_checkpoint model.ckpt-28252 --config bert_config.json --pytorch_dump_output pytorch_model.bin
```
but it breaks with the following error:
```
Traceback (most recent call last):
  File "/workdisk/vlad/composer_venv/bin/transformers-cli", line 8, in <module>
    sys.exit(main())
  File "/workdisk/vlad/composer_venv/lib/python3.9/site-packages/transformers/commands/transformers_cli.py", line 55, in main
    service.run()
  File "/workdisk/vlad/composer_venv/lib/python3.9/site-packages/transformers/commands/convert.py", line 103, in run
    convert_tf_checkpoint_to_pytorch(self._tf_checkpoint, self._config, self._pytorch_dump_output)
  File "/workdisk/vlad/composer_venv/lib/python3.9/site-packages/transformers/models/bert/convert_bert_original_tf_checkpoint_to_pytorch.py", line 36, in convert_tf_checkpoint_to_pytorch
    load_tf_weights_in_bert(model, config, tf_checkpoint_path)
  File "/workdisk/vlad/composer_venv/lib/python3.9/site-packages/transformers/models/bert/modeling_bert.py", line 172, in load_tf_weights_in_bert
    if pointer.shape != array.shape:
  File "/workdisk/vlad/composer_venv/lib/python3.9/site-packages/torch/nn/modules/module.py", line 1177, in __getattr__
    raise AttributeError("'{}' object has no attribute '{}'".format(
AttributeError: 'Embedding' object has no attribute 'shape'
```

### Who can help?

@LysandreJik
@Rocketknight1

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

Steps to reproduce:
1. Download the following 4 files from [MLPerf GDrive](https://drive.google.com/drive/folders/1oQF4diVHNPCclykwdvQJw8n_VIWwV0PT?usp=sharing) and put them in the same directory: 
- tf1_ckpt/model.ckpt-28252.data-00000-of-00001
- tf1_ckpt/model.ckpt-28252.index
- tf1_ckpt/model.ckpt-28252.meta
- bert_config.json
2. Run the command to convert TF checkpoint to HF BERT model:
```
transformers-cli convert --model_type bert --tf_checkpoint model.ckpt-28252 --config bert_config.json --pytorch_dump_output pytorch_model.bin
```

### Expected behavior

The command should convert TF checkpoint to HF BERT model.

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.
Increase notebooks page visibility
Author: alaradirik
Pull request: no

Hi, I was looking at the [notebooks page](https://huggingface.co/docs/transformers/notebooks) and I noticed that the community notebooks link is broken and some of the official notebooks are outdated and throw errors when run. 

It would be great to reorganize the notebooks page such that:
1) The [community page ](https://huggingface.co/docs/transformers/v4.21.0/en/community) is renamed as Community Notebooks or merged with the Notebooks page
2) We add tags or organize the community notebooks page by task and topic (fine-tuning, image classification, etc.)
3) Existing official notebooks are updated
4) Notebooks page/s are promoted on the homepage

@NielsRogge @sgugger @amyeroberts @LysandreJik could you comment on this?

Comments:
I wouldn't merge the community notebooks page with the notebooks page, just make the link work again. I think it's important to separate what we officially support from what we don't. Organizing things a bit better would certainly be welcome, as always, happy to look at a PR!

Same for fixing some of the notebooks if they don't run anymore. They are not tested like the examples scripts so it's possible that some API changes broke them.

Makes sense, I will reorganize the Community page and double check the official notebooks then!

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.
This code block will not be executed 
Author: AlfredQin
Pull request: no
Labels: name: bug

### System Info

python 3.9

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

[](urlhttps://github.com/huggingface/transformers/blob/main/src/transformers/models/detr/modeling_detr.py)

`        combined_attention_mask = None

        if attention_mask is not None and combined_attention_mask is not None:
            # [bsz, seq_len] -> [bsz, 1, tgt_seq_len, src_seq_len]
            combined_attention_mask = combined_attention_mask + _expand_mask(
                attention_mask, inputs_embeds.dtype, tgt_len=input_shape[-1]
            )`

### Expected behavior

The combined_attention_mask is set to None, so the if code block below it will never be executed because it  will check combined_attention_mask is not None.

Comments:
Where is that code block from?

The code block is from https://github.com/huggingface/transformers/blob/8e8384663d716d4b5a4f510070ff954fc0ba4a52/src/transformers/models/detr/modeling_detr.py#L1076

cc @NielsRogge 

Hi @AlfredQin, thanks for spotting that. The `combined_attention_mask` was probably taken from another model, which is not relevant for DETR.

Feel free to open a PR to remove that code block!

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.
checkpoints_to_be_deleted = checkpoints_sorted[:number_of_checkpoints_to_delete] TypeError: slice indices must be integers or None or have an __index__ method
Author: plageon
Pull request: no
Labels: name: bug

### System Info

transformers.__version__==4.9.2



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

1. use **trainer** to train your model

2. specify argument `resume_from_checkpoint`

### Expected behavior

if you use **trainer** to train your model and specify argument `resume_from_checkpoint`
`trainer.train(resume_from_checkpoint=checkpoint)`

you may encounter an error like this:
checkpoints_to_be_deleted = checkpoints_sorted[:number_of_checkpoints_to_delete]
TypeError: slice indices must be integers or None or have an __index__ method

this results from this line in **trainer.py**
```
number_of_checkpoints_to_delete = max(0, len(checkpoints_sorted) - save_total_limit)
checkpoints_to_be_deleted = checkpoints_sorted[:number_of_checkpoints_to_delete]
```
resolution:
add a conversion to int type for variable `number_of_checkpoints_to_delete`
```
number_of_checkpoints_to_delete = int(max(0, len(checkpoints_sorted) - save_total_limit))
checkpoints_to_be_deleted = checkpoints_sorted[:number_of_checkpoints_to_delete]
```



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.

cc @sgugger 

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.
`activation_dropout` in OPT is never used
Author: shijie-wu
Pull request: no
Labels: name: bug

### System Info

main

### Who can help?

@patil-suraj, @patrickvonplaten, @LysandreJik

### Information

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

### Tasks

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

### Reproduction

https://github.com/huggingface/transformers/blob/ee67e7ad4fd7a766891b68f708cf03e30f609976/src/transformers/models/opt/modeling_opt.py#L279

`activation_dropout` in `modeling_opt.py` is never used. It would not behave as expected if one initial a model randomly while setting it to non-zero.

### Expected behavior

`activation_dropout` is used or removed.

Comments:
cc @ArthurZucker 

Will have a look asap 😀

Okay I think we should just remove it, we don't use it in either the flax or the tf version and it is probably a typo. 😄  I will open a PR soon to fix that !

I'm happy to contribute if removing is what we want 😊

Feel free to open a PR and tag me when it is ready! 😄 

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.

Sorry about the delay! I opened a PR https://github.com/huggingface/transformers/pull/18842 @ArthurZucker 

Gonna merge it to main 🥳
how we can replace/swap the Wikipedia data with our custom data for knowledge retrieval in the RAG  model and  the format of the retrieval data.  
Author: Madhuri05thorat
Pull request: no
Labels: name: wontfix

# ❓ Questions & Help

<!-- The GitHub issue tracker is primarly intended for bugs, feature requests,
     new models and benchmarks, and migration questions. For all other questions,
     we direct you to the Hugging Face forum: https://discuss.huggingface.co/ .
     You can also try Stack Overflow (SO) where a whole community of PyTorch and
     Tensorflow enthusiast can help you out. In this case, make sure to tag your
     question with the right deep learning framework as well as the
     huggingface-transformers tag: 
     https://stackoverflow.com/questions/tagged/huggingface-transformers 
     -->

## Details
<!-- Description of your issue -->

<!-- You should first ask your question on the forum or SO, and only if
     you didn't get an answer ask it here on GitHub. -->
**A link to original question on the forum/Stack Overflow**:

Comments:
I am also playing with RAG model and I am trying to understand how to replace the Wikipedia data with my custom data. From transformes/model-cards/facebook/rag-sequence-nq I see that the train dataset is wiki_dpr.  So I loaded it with the following
`
from datasets import load_dataset
dataset = load_dataset("wiki_dpr")
`
The dataset is loaded with arrow into RAM(it's prety big, 75 GB). I was wandering, the custom dataset must have the same format as `wiki_dpr` ? If you can help  with a tutorial on how to replace wiki dataset with a custom one, it will be very helpful. Thank you :D

I think @lhoestq is working on this right now? 

Yes indeed. I'll create the PR later today to allow users to use their own data. I'll also add code examples

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.


Hi, Sorry to bump a closed issue but it's the first one in a google search for Rag (or DPR) and huggingface. 

Could we please have links here for the code exemples or informations about custom datas ? 

Thanks a lot :smiley: 

Hi !
Sure. You can find more information in [the RAG examples readme](https://github.com/huggingface/transformers/tree/master/examples/research_projects/rag#use-your-own-knowledge-source). Also feel free to take a look at [the code that shows how to do it step by step](https://github.com/huggingface/transformers/blob/master/examples/research_projects/rag/use_own_knowledge_dataset.py).

from this link using snippet of code to download the Wikipedia data.(https://huggingface.co/datasets/wiki_dpr/blob/main/wiki_dpr.py)

this is the command to download all 50 batches of data : !wget https://dl.fbaipublicfiles.com/dpr/data/wiki_encoded/single/nq/wiki_passages_{1..50}.

Then based on your system config merge the batches and go further.
Fix `check_decoder_model_past_large_inputs` for `class TFBartModelTest`
Author: ydshieh
Pull request: yes

# What does this PR do?

The usage of `decoder_position_ids` in `check_decoder_model_past_large_inputs` will produce different results **when the initial attention mask (i.e. the called `past`) contains `0`**, and makes the test flaky.

This PR remove `check_decoder_model_past_large_inputs` from this test. This also makes the test identical to its PT equivalent test, as well as the test implemented in other TF models.



Comments:
_The documentation is not available anymore as the PR was closed or merged._
create Past CI results as tables for GitHub issue
Author: ydshieh
Pull request: yes

# What does this PR do?

Update Past CI error statistic report script to produce 2 GitHub issue tables :-)

Comments:
One table

| no. | error |
|-:|:-|
| 63 | AttributeError: module 'torch.jit._state' has no attribute '_clear_class_state' |
| 38 | RuntimeError: iter.device(arg).is_cuda() INTERNAL ASSERT FAILED at "/pytorch/aten/src/ATen/native/cu |
| 3 | OSError: gs555750 is not a valid git identifier (branch name, tag name or commit id) that exists for |
| 3 | AssertionError: Couldn't trace module. |
| 3 | RuntimeError: "normal_kernel_cpu" not implemented for 'BFloat16' |
| 1 | RuntimeError: Caught RuntimeError in replica 0 on device 0. |

Another one

| model | no. of errors | major error | count |
|-:|-:|-:|-:|
| bloom | 48 | RuntimeError: iter.device(arg).is_cuda() INTERNAL ASSERT FAI | 38 |
| data2vec | 9 | AttributeError: module 'torch.jit._state' has no attribute ' | 9 |
| clip | 6 | AttributeError: module 'torch.jit._state' has no attribute ' | 6 |
| blenderbot | 6 | AttributeError: module 'torch.jit._state' has no attribute ' | 6 |
| bart | 6 | AttributeError: module 'torch.jit._state' has no attribute ' | 6 |
| blenderbot_small | 6 | AttributeError: module 'torch.jit._state' has no attribute ' | 6 |
| canine | 3 | AttributeError: module 'torch.jit._state' has no attribute ' | 3 |
| bigbird_pegasus | 3 | AttributeError: module 'torch.jit._state' has no attribute ' | 3 |
| convnext | 3 | AttributeError: module 'torch.jit._state' has no attribute ' | 3 |
| beit | 3 | AttributeError: module 'torch.jit._state' has no attribute ' | 3 |
| albert | 3 | AttributeError: module 'torch.jit._state' has no attribute ' | 3 |
| codegen | 3 | AttributeError: module 'torch.jit._state' has no attribute ' | 3 |
| ctrl | 3 | AttributeError: module 'torch.jit._state' has no attribute ' | 3 |
| convbert | 3 | AttributeError: module 'torch.jit._state' has no attribute ' | 3 |
| bert_generation | 3 | AttributeError: module 'torch.jit._state' has no attribute ' | 3 |
| cpm | 3 | AttributeError: module 'torch.jit._state' has no attribute ' | 3 |

_The documentation is not available anymore as the PR was closed or merged._
Dropout in OPT embedding layer
Author: shijie-wu
Pull request: no
Labels: name: bug

### System Info

main

### Who can help?

@ArthurZucker, @patrickvonplaten, @LysandreJik

### Information

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

### Tasks

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

### Reproduction

The [OPT paper](https://arxiv.org/pdf/2205.01068.pdf) (sec 2.2) mentioned 
> We use a dropout of 0.1 throughout, but we do not apply any dropout to embeddings.

This is also supported by loading [the official checkpoints](https://github.com/facebookresearch/metaseq/tree/main/projects/OPT) and running the following check

```python
import torch
data = torch.load("reshard-model_part-0.pt")
assert data['cfg']['model'].no_emb_dropout
```

However, in `modeling_opt.py`, dropout is applied to the embedding layer.

https://github.com/huggingface/transformers/blob/80367cd1fb6d36ca6bdd99b70586aab4ffae1ae1/src/transformers/models/opt/modeling_opt.py#L641-L642

### Expected behavior

No dropout in the embedding layer

Comments:
Remove dropout in embedding layer of OPT
Author: shijie-wu
Pull request: yes

# What does this PR do?

Fixes https://github.com/huggingface/transformers/issues/18844


## Before submitting
- [ ] This PR fixes a typo or improves the docs (you can dismiss the other checks if that's the case).
- [x] Did you read the [contributor guideline](https://github.com/huggingface/transformers/blob/main/CONTRIBUTING.md#start-contributing-pull-requests),
      Pull Request section?
- [x] Was this discussed/approved via a Github issue or the [forum](https://discuss.huggingface.co/)? Please add a link
      to it if that's the case.
- [ ] Did you make sure to update the documentation with your changes? Here are the
      [documentation guidelines](https://github.com/huggingface/transformers/tree/main/docs), and
      [here are tips on formatting docstrings](https://github.com/huggingface/transformers/tree/main/docs#writing-source-documentation).
- [ ] Did you write any new necessary tests?


## Who can review?

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._

Thanks for your PR @shijie-wu! Pinging @ArthurZucker and @younesbelkada to take a look at this as soon as they're back from leave (in about a week's time).
Fix TF start docstrings
Author: Rocketknight1
Pull request: yes

(This is not an urgent fix and can wait until after the release)

Our TF models include a cookie-cutter docstring explaining how inputs can be passed, which is very prominent in the online docs. Parts of this are old and confusing, and it had a few errors, both grammar and variable names. I rewrote it, which should hopefully reduce user confusion in future!

Comments:
_The documentation is not available anymore as the PR was closed or merged._
Align try_to_load_from_cache with huggingface_hub
Author: sgugger
Pull request: yes

# What does this PR do?

This PR completely align `try_to_load_from_cache` with its `huggingface_hub` counterpart (it's a copy-paste while just removing the `repo_type` argument) and adapts its use in `cached_file`. This is done before the next release of Transformers so that there is no breaking change if users start to adopt it (since the arguments are in a different order), and to make the transition (which will happen after the next release of `huggingface_hub`) easier.

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

There is one on the HF hub side ;-) I just removed it here since it does not concern Transformers and we only the default value.

Perfect :)
Fix tflongformer int dtype
Author: Rocketknight1
Pull request: yes

TFLongformer had a lot of `int32` dtypes in its code, caused by `tf.convert_to_tensor()` defaulting to int32 when passed a list of ints, as well as some explicit `int32` lines. We prefer `int64` across our models, so I've converted everything to use that.

Fixes #13632 

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

But it doesn't look to good to CI 😅 

Working on that bit!

Quick update: I did a lot of dtype casting which should resolve the remaining issues. Because TFLED has some sections copied from TFLongFormer, TFLED got updated as well. However, the TFLongformerEmbeddings were copied from TFRobertaEmbeddings, but I broke this connection because we have to do some extra casting in TFLongformer due to things like the `global_attention_mask`, and I don't really want to mess with TFRoberta when it doesn't have issues, because it's a heavily-used model.

Looks good! 👍 

Thanks for taking care of this one
TF: correct TFBart embeddings weights name when load_weight_prefix is passed
Author: gante
Pull request: yes

# What does this PR do?

Follow up to #18939 -- the embeddings weights were not being named correctly when `load_weight_prefix` was being passed. A few comments were also added so that our future selves remember how TF sets the names to their variables.

This was the cause of the TFRag test failures, as the loaded TFBart (`self.rag.generator`) was not getting its embedding weights.

Comments:
cc @ydshieh -- this PR fixes the TFRag test we've seen in the scheduled CI run

_The documentation is not available anymore as the PR was closed or merged._
TF: TF 2.10 unpin + related onnx test skips
Author: gante
Pull request: yes

# What does this PR do?

Unpins TF, but adds the appropriate test skips.

Should remove the tensorflow probability CI problem.

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

@ydshieh -- no command was added there, but rather a newline at the end of the file (automatic vscode settings). They already exist in some of the docker files. Happy to revert!

Oh, it's fine. No need to revert. (The consequence of getting up at 5AM ...)