noamaanMulla-03/transformers-issues huggingface dataset:
Segmentation fault (core dumped) after importing transformers
Author: huangxiaoshuo
Pull request: no

# 🐛 Bug

## Information

Model I am using (Bert, XLNet ...): Bert

Language I am using the model on (English, Chinese ...): English

The problem arises when using:
* [ ] the official example scripts: (give details below)
* [x] my own modified scripts: (give details below)

The tasks I am working on is:
* [ ] an official GLUE/SQUaD task: (give the name)
* [x] my own task or dataset: (give details below)

## To reproduce

Steps to reproduce the behavior:

1.import torch
2.import transformers
3.torch.rand(4,5)

<!-- If you have code snippets, error messages, stack traces please provide them here as well.
     Important! Use code tags to correctly format your code. See https://help.github.com/en/github/writing-on-github/creating-and-highlighting-code-blocks#syntax-highlighting
     Do not use screenshots, as they are hard to read and (more importantly) don't allow others to copy-and-paste your code.-->
```python
import torch
import transformers
torch.rand(4,5)
```
## Expected behavior

<!-- A clear and concise description of what you would expect to happen. -->
I got an error 'segmentation fault (core dumped)' while trying to generate a tensor after importing transformers, but if I removed 'import transformers', the tensor could be generated.
![image](https://user-images.githubusercontent.com/32594371/86000735-83caca00-ba40-11ea-9f25-cf8617f843aa.png)

## Environment info
<!-- You can run the command `transformers-cli env` and copy-and-paste its output below.
     Don't forget to fill out the missing fields in that output! -->
     
- `transformers` version: 2.11.0
- Platform: Ubuntu 18.04.4 LTS
- Python version: 3.7.6
- PyTorch version (GPU?): 1.4.0+cu100
- Tensorflow version (GPU?): 2.2.0
- Using GPU in script?: No
- Using distributed or parallel set-up in script?: No


Comments:
Hi, I believe this error may be due to [the sentencepiece version 0.1.92 which causes a segmentation fault.](https://github.com/huggingface/transformers/issues/4857).

> Hi, I believe this error may be due to [the sentencepiece version 0.1.92 which causes a segmentation fault.](https://github.com/huggingface/transformers/issues/4857).

Thank you very much, this error disappeared when sentencpiece was downgraded to 0.1.91.
BTW, is there some debugging method to find this root cause when we encounter segmentation fault? 

Not that I know of :man_shrugging: 

It works. GREAT!!!!

The error still persists after 6 months. Maybe the version 0.1.91 should be hardcoded in package requirements

It was for the last 3.x versions. For version 4.x onwards, `sentencepiece` is not a requirement anymore.
[Flax] Serialization, Design changes
Author: patrickvonplaten
Pull request: yes

This PR is a proposition for some changes of the flax design. @mfuntowicz - I'm trying to get a better understanding of how to best use the flax library with Transformers' philosophy. Would be super happy about some comments from your side :-) 

1) I think Flax's `from_pretrained()` should default to the flax serialization and not the PyTorch one. Flax's serialization didn't work previously and the model was loaded from PyTorch by default. This PR changes this to Flax and makes `from_pretrained()` and `save_pretrained()` work. I uploaded Bert's and Roberta's flax model weights to the model hub (I noticed that I accidently overwrote an existing Flax `bert-base-cased` - hope that was fine @mfuntowicz - it's doesn't break anything on master since PT was loaded by default)

2) Not sure why we have the `model_class` class attribute in Flax - I don't think we need it no? @mfuntowicz - It would be nice to avoid it for simplicity IMO.

3) I added a `FlaxBertPretrainedModel` class, just as it's done for PyTorch. IMO, ideally we should stay as close as possible to the design of PyTorch. Not sure at all if something like this could work:

```python 
class FlaxBertForMaskedLM(FlaxBertPretrainedModel):

         def __init__(self, config, state, seed, **kwargs):
               self.bert = FlaxBertModel(config, state[self.base_model_prefix], seed, **kwargs)  # pass bert relevant 
        
        @nn.compact
        def __call__(....):
               last_hidden_states = self.bert(hidden_states)[0]
               logits = FlaxBertLMPredictionHead(vocab_size=self.vocab_size, name="mlm", dtype=self.dtype)(last_hidden_states)     
```
=> What do you think @mfuntowicz ?

Would be awesome if we could do some flax library design discussions here @mfuntowicz @LysandreJik @sgugger @thomwolf 

Comments:
I think I'll take a Flax 101 class before reviewing this PR.

Requires more  discussion
About the input of BERT
Author: BeerTai
Pull request: no

Hello, if I want to maintain two different dictionaries, one is BERT's original dictionary and the other is a custom dictionary, and then the input is `[CLS]  BERT dictionary corpus [SEP] custom dictionary corpus [SEP]`, how do I handle the input of the model and what part of the source code do I need to change? Thanks!

Comments:
Hey @BeerTai, 

It would be great if you could ask these kind of questions on the forum: https://discuss.huggingface.co/ . We try to keep github for issues and less for user-specific use cases. Thanks!
LayoutLM wrong shape for bbox in docs
Author: dscarmo
Pull request: no

## Environment info
(Colab, 09 december 2020, CPU runtime)
- `transformers` version: 4.0.1
- Platform: Linux-4.19.112+-x86_64-with-Ubuntu-18.04-bionic
- Python version: 3.6.9
- PyTorch version (GPU?): 1.7.0+cu101 (False)
- Tensorflow version (GPU?): 2.3.0 (False)
- Using GPU in script?: no
- Using distributed or parallel set-up in script?: no

### Who can help
 documentation: @sgugger

## Information

LayoutLM documentation indicates that the shape for the bbox input is [B, seq_len]:
![image](https://user-images.githubusercontent.com/10614968/101692115-76355980-3a4e-11eb-9aa2-a0218c26fead.png)

However, from the code (https://github.com/huggingface/transformers/blob/master/src/transformers/models/layoutlm/modeling_layoutlm.py#L103) bounding boxes are encoded in the form [tl_col, tl_row, br_col, br_row]. Therefore the accepted shape is [B, seq_len, 4].


## To reproduce

Reproduced on this colab: https://colab.research.google.com/drive/1ZRPKlX8-C41nYq3o6QVS68h1JAj1nQMI?usp=sharing

## Expected behavior

Better explanation in docs


Comments:
Sounds right, will fix.
Trainer incorrectly checks pytorch version
Author: Rexhaif
Pull request: no
Labels: name: wontfix

## Environment info
<!-- You can run the command `transformers-cli env` and copy-and-paste its output below.
     Don't forget to fill out the missing fields in that output! -->
     
- `transformers` version: 3.1.0
- Platform: Linux-3.10.0-862.el7.x86_64-x86_64-with-glibc2.27
- Python version: 3.8.5
- PyTorch version (GPU?): 1.6.0 (True)
- Tensorflow version (GPU?): not installed (NA)
- Using GPU in script?: yes(not applicable)
- Using distributed or parallel set-up in script?: not applicable

### Who can help
@sgugger and @prajjwal1 (he added it, according to git blame)

## Information

I'm running token classification example on my own data, and i've faced trouble with fp16 training with torch 1.6.0.
Script says that i need apex installed to use fp16 option. However, apex is not required since torch 1.6.0 came out with native amp support. I've dived into trainer code, and found that there is version checking line: https://github.com/huggingface/transformers/blob/99cb924bfb6c4092bed9232bea3c242e27c6911f/src/transformers/trainer.py#L65

Apparently, it is slightly incorrect. There should be <= instead of <. So it will not try to import apex if torch version is greater OR EQUAL to 1.6

```python
import torch
from packaging import version

print(version.parse(torch.__version__) < version.parse("1.6")) # -> False
print(version.parse(torch.__version__) <= version.parse("1.6")) # -> True
```

## To reproduce
1. Install torch 1.6.0(and do not install apex)
2. clone repository
3. cd into examples/token-classification
4. add '--fp16' to the bottom of run.sh script
5. execute run.sh script

## Expected behavior
 Script works well on torch 1.6.0 without apex installed


Comments:
I am unsure on why you think this test is wrong: if this test is true, we import APEX. So if we check with `<=`, we will then try to import APEX which is exactly what we are trying to avoid.

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.
"run_mlm_wwm.py", line 284 AttributeError: 'DataTrainingArguments' object has no attribute 'valid_ref_file'
Author: NatLun137
Pull request: no

Hi! There is a tiny typo in the code "transformers/examples/language-modeling/run_mlm_wwm.py" at line 284. It should be:
`if data_args.validation_ref_file is not None:` since at line 103 in `DataTrainingArguments` it defined as `validation_ref_file:`

Comments:
Hi! Do you want to submit a PR?

Sure, I'll be happy to do it. I need permission... `remote: Permission to huggingface/transformers.git denied to NatLun137.`

Hmmm I think you just tried to push on `huggingface/transformers`? You should fork the repo, apply your changes there and then open a PR here. I see you created your fork already, how did you open a PR then? Did you use the GitHub UI?
fix the typo 9012
Author: NatLun137
Pull request: yes

# What does this PR do?

Fixes #9012


## Before submitting
- [Y] This PR fixes a typo or improves the docs (you can dismiss the other checks if that's the case).
- [Y] 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 which 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 @
 albert, bert, XLM: @LysandreJik
 examples/distillation: @VictorSanh
 examples/token-classification: @stefan-it
 documentation: @sgugger
 -->


Comments:
Hello! I think you reverted your commit. The PR shows no diff.

> Hello! I think you reverted your commit. The PR shows no diff.

Hi! Yes, unfortunately, I was too quick... The first commit does the fix.

I opened [PR](https://github.com/huggingface/transformers/pull/9038) with correct changes.
Fix typo #9012 (#1)
Author: NatLun137
Pull request: yes

There is a tiny typo in the code "transformers/examples/language-modeling/run_mlm_wwm.py" at line 284. [Details.](https://github.com/huggingface/transformers/issues/9012)

# What does this PR do?

Fixes #9012


## Before submitting
- [Y] This PR fixes a typo or improves the docs (you can dismiss the other checks if that's the case).
- [Y] 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 which may be interested in your PR.

 albert, bert, XLM: @LysandreJik
 examples/distillation: @VictorSanh
 examples/token-classification: @stefan-it
 documentation: @sgugger
 -->


Comments:
GPT2 attention mask
Author: Jiaxin-Wen
Pull request: no

I want to use gpt2 to generate a list of options

> an option is a sentence starting with a special token '<option>'.

As I don't want the following options to rely on the previous options, I think I should mask all the previous options.

I could simply implement that during generation by generating one option per time, but I don't know how to do that during training.

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://discusss.huggingface.co) instead?

Thanks!

Thanks for reminding! 
https://discuss.huggingface.co/t/dynamic-attention-mask-during-gpt-2-training/2789
On 12/11/2020 06:16，Lysandre Debut<notifications@github.com> wrote：

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 instead?

Thanks!

—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub, or unsubscribe.
Seq2SeqTrainer: add a fast test that doesn't learn anything but can run on CPU
Author: sshleifer
Pull request: no
Labels: name: wontfix

@patil-suraj do you want to take this or should I?



Comments:
I'll take it :)

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.
How to get cross attention for bert when config.add_cross_attention is True
Author: qmeeus
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 -->
As far as I can tell, when using BERT with cross attention and output_attention is True, the returned attention only contains self attention (i.e. a tuple of length num_hidden_layers with size (batch_size, num_head, seq_length, seq_length)). How can I get the cross attention weights in that case?

After digging a little bit, I saw that ModelOutput (and child classes) do not include cross attention as potential outputs. The cross attention is returned by [BertLayer](https://github.com/huggingface/transformers/blob/master/src/transformers/modeling_bert.py#L420) (at index 2) but then ignored in [BertEncoder](https://github.com/huggingface/transformers/blob/master/src/transformers/modeling_bert.py#L486). A quick look at the outputs for Encoder-Decoder models shows the same issue. Would it be possible to include cross attention in model outputs? And if yes, how can I help doing so?

<!-- 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 similar question on the forum/Stack Overflow**: https://discuss.huggingface.co/t/how-to-get-cross-attention-values-of-t5/970

Comments:
Hey @qmeeus - thanks for your issue. This corresponds actually to a larger feature requests since we never return the attention masks at the moment. I will open a discussion about this internally and add it to the projects. 

Hi @patrickvonplaten and thank you for your answer ! Let me know if I can help in any way with the developments

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.


This should be resolved now. Bert2Bert can return cross attention masks with `output_attentions=True`
Correct docstring.
Author: Fraser-Greenlee
Pull request: yes

Related issue: https://github.com/huggingface/transformers/issues/8837

# What does this PR do?

Updating the PreTrainedTokenizerBase.pad argument default value docstring to show the correct default value.

**Current**
docstring: 
https://github.com/huggingface/transformers/blob/d5b3e56de5376aa85ef46e7f0325139d9e299a41/src/transformers/tokenization_utils_base.py#L2469-L2470
arg:
https://github.com/huggingface/transformers/blob/d5b3e56de5376aa85ef46e7f0325139d9e299a41/src/transformers/tokenization_utils_base.py#L2431-L2472

<!--
Congratulations! You've made it this far! You're not quite done yet though.

Once merged, your PR is going to appear in the release notes with the title you set, so make sure it's a great title that fully reflects the extent of your awesome contribution.

Then, please replace this with a description of the change and which issue is fixed (if applicable). Please also include relevant motivation and context. List any dependencies (if any) that are required for this change.

Once you're done, someone will review your PR shortly (see the section "Who can review?" below to tag some potential reviewers). They may suggest changes to make the code even better. If no one reviewed your PR after a week has passed, don't hesitate to post a new comment @-mentioning the same persons---sometimes notifications get lost.
-->

Fixes #8837 (issue)

I'm also curious why this method has default `padding=True`? Other methods (prepare_for_model, encode, __call__, encode_plus, batch_encode_plus) have `padding=False`.

Its default means the DataCollatorForLanguageModeling pads input examples which means it can't be simply switched with the default collator in the [example script](https://github.com/huggingface/transformers/blob/master/templates/adding_a_new_example_script/%7B%7Bcookiecutter.directory_name%7D%7D/run_%7B%7Bcookiecutter.example_shortcut%7D%7D.py#L287-L306) without breaking the attention mask.
https://github.com/huggingface/transformers/blob/610cb106a216cfb99d840648b576f9502189e4d1/src/transformers/data/data_collator.py#L253

@mfuntowicz
@LysandreJik 
@sgugger


Comments:
Change nn.dropout to layer.Dropout in TFBart
Author: astariul
Pull request: yes

# What does this PR do?

This PR changes all the `tf.nn.dropout` calls in `modeling_tf_bart.py` and use `tf.keras.layers.Dropout` instead.  
More consistent with `modeling_tf_roberta.py`

Fixes #9045 


## 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?

@patrickvonplaten

Comments:
Hey @astariul-colanim 

Thanks for the fix! Looks good to me if it solves the error on TPU. Also cc @jplu
"resize_token_embeddings" in BertForeMaskedLM won't change last linear layer "output dimension"
Author: HenryPaik1
Pull request: no

## Environment info
- `transformers` version: 4.0.1

### Who can help
 albert, bert, GPT2, XLM: @LysandreJik 
 
## Information

Model I am using (Bert, XLNet ...): BertForMaskedLM

## To reproduce
`resize_token_embeddings` cannot change decoder output feature dimension.
```
model = BertForMaskedLM.from_pretrained('bert-base-uncased')
tokenizer = BertTokenizer.from_pretrained(tokenizer_path) # len(tokenizer) == 30541 (I add some new tokens)
model.bert.resize_token_embeddings(len(tokenizer))

>>>
BertForMaskedLM(
  (bert): BertModel(
    (embeddings): BertEmbeddings(
      (word_embeddings): Embedding(30541, 768)   ######################### This is correct, but the decoder is wrong.
      (position_embeddings): Embedding(512, 768)
      (token_type_embeddings): Embedding(2, 768)
      (LayerNorm): LayerNorm((768,), eps=1e-12, elementwise_affine=True)
      (dropout): Dropout(p=0.1, inplace=False)
...
...
  (cls): BertOnlyMLMHead(
    (predictions): BertLMPredictionHead(
      (transform): BertPredictionHeadTransform(
        (dense): Linear(in_features=768, out_features=768, bias=True)
        (LayerNorm): LayerNorm((768,), eps=1e-12, elementwise_affine=True)
      )
      (decoder): Linear(in_features=768, out_features=30522, bias=True)     ########## out_features not changed
    )
  )
)

```

Comments:
Sorry, My mistakes.
Initial README for `t5-small-indonesian-summarization-cased` model
Author: panggi
Pull request: yes
Labels: name: model card

Initial README for Indonesian T5 Summarization Small Model

Comments:
Awesome! @panggi - did you check out the new `mt5` model as well by any chance? It should work better for your use-case I think :-) 

Thanks @patrickvonplaten, i just knew it from you about `mt5` and definitely will check it out! :)

Thanks for sharing @panggi
Create README.md
Author: smanjil
Pull request: yes
Labels: name: model card

# What does this PR do?

<!--
Congratulations! You've made it this far! You're not quite done yet though.

Once merged, your PR is going to appear in the release notes with the title you set, so make sure it's a great title that fully reflects the extent of your awesome contribution.

Then, please replace this with a description of the change and which issue is fixed (if applicable). Please also include relevant motivation and context. List any dependencies (if any) that are required for this change.

Once you're done, someone will review your PR shortly (see the section "Who can review?" below to tag some potential reviewers). They may suggest changes to make the code even better. If no one reviewed your PR after a week has passed, don't hesitate to post a new comment @-mentioning the same persons---sometimes notifications get lost.
-->

<!-- Remove if not applicable -->

Fixes # (issue)


## Before submitting
- [ ] 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 the it if that's the case.
- [x] Did you make sure to update the documentation with your changes? Here are the
      [documentation guidelines](https://github.com/huggingface/transformers/tree/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?

Anyone in the community is free to review the PR once the tests have passed. Feel free to tag
members/contributors which 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 @

 If you know how to use git blame, that is the easiest way, otherwise, here is a rough guide of **who to tag**.
 Please tag fewer than 3 people.

 albert, bert, XLM: @LysandreJik
 GPT2: @LysandreJik, @patrickvonplaten
 tokenizers: @mfuntowicz
 Trainer: @sgugger
 Benchmarks: @patrickvonplaten
 Model Cards: @julien-c
 Translation: @sshleifer
 Summarization: @sshleifer
 examples/distillation: @VictorSanh
 nlp datasets: [different repo](https://github.com/huggingface/nlp)
 rust tokenizers: [different repo](https://github.com/huggingface/tokenizers)
 Text Generation: @patrickvonplaten, @TevenLeScao
 Blenderbot, Bart, Marian, Pegasus: @sshleifer
 T5: @patrickvonplaten
 Rag: @patrickvonplaten, @lhoestq
 EncoderDecoder: @patrickvonplaten
 Longformer, Reformer: @patrickvonplaten
 TransfoXL, XLNet: @TevenLeScao, @patrickvonplaten
 examples/seq2seq: @sshleifer
 examples/bert-loses-patience: @JetRunner
 tensorflow: @jplu
 examples/token-classification: @stefan-it
 documentation: @sgugger
 -->


Comments: