noamaanMulla-03/transformers-issues huggingface dataset:
Getting "AttributeError: 'Tensor' object has no attribute 'numpy'" while fine-tuning BERT for NER
Author: mittalpatel
Pull request: no

As per https://github.com/huggingface/transformers/tree/master/examples/token-classification after doing the required setup and installing required libraries, when I run 

```
python3 run_tf_ner.py --data_dir ./ \
--labels ./labels.txt \
--model_name_or_path $BERT_MODEL \
--output_dir $OUTPUT_DIR \
--max_seq_length  $MAX_LENGTH \
--num_train_epochs $NUM_EPOCHS \
--per_device_train_batch_size $BATCH_SIZE \
--save_steps $SAVE_STEPS \
--seed $SEED \
--do_train \
--do_eval \
--do_predict
```
it stops at one point with error

```
    /usr/local/lib/python3.6/dist-packages/transformers/trainer_tf.py:488 _accumulate_next  *
        return self._accumulate_gradients(per_replica_features, per_replica_labels)
    /usr/local/lib/python3.6/dist-packages/transformers/trainer_tf.py:498 _accumulate_gradients  *
        per_replica_loss = self.args.strategy.experimental_run_v2(
    /usr/local/lib/python3.6/dist-packages/transformers/trainer_tf.py:511 _forward  *
        per_example_loss, _ = self._run_model(features, labels, True)
    /usr/local/lib/python3.6/dist-packages/transformers/trainer_tf.py:534 _run_model  *
        outputs = self.model(features, labels=labels, training=training)[:2]
    /usr/local/lib/python3.6/dist-packages/transformers/modeling_tf_distilbert.py:879 call  *
        loss = self.compute_loss(labels, logits)
    /usr/local/lib/python3.6/dist-packages/transformers/modeling_tf_utils.py:142 compute_loss  *
        if tf.math.reduce_any(labels == -1).numpy() is True:

    AttributeError: 'Tensor' object has no attribute 'numpy'
```

Tensorflow version: 2.2.0
Numpy version: 1.19.0
CUDA version: 10.2

As per some possible solutions I have checked that tf.executing_eagerly() is True. 

Tried on own computer and colab both and it ends up at the same point with same error. 

Comments:
I run into the same error, installing Transformers with pip fix this (not a preferred solution but it works)
`!pip install --upgrade --no-deps --force-reinstall transformers`

fine-tuning BERT for NER also fail using `run_ner.py`. The error is 
```
Traceback (most recent call last):
  File "transformers/examples/token-classification/run_ner.py", line 304, in <module>
    main()
  File "transformers/examples/token-classification/run_ner.py", line 266, in main
    predictions, label_ids, metrics = trainer.predict(test_dataset)
  File "/usr/local/lib/python3.6/dist-packages/transformers/trainer.py", line 781, in predict
    test_dataloader = self.get_test_dataloader(test_dataset)
  File "/usr/local/lib/python3.6/dist-packages/transformers/trainer.py", line 297, in get_test_dataloader
    if isinstance(self.test_dataset, torch.utils.data.IterableDataset):
AttributeError: 'Trainer' object has no attribute 'test_dataset'
```

Thanks for the input @kevin-yauris 

> I run into the same error, installing Transformers with pip fix this (not a preferred solution but it works)
> !pip install --upgrade --no-deps --force-reinstall transformers

This fixed the issue for me too.
pipeline does not do truncation on long texts input, error message found
Author: yuyongze
Pull request: no

# 🐛 Bug

## Information

Model I am using (Bert, XLNet ...): No specified

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.  I have tried using pipeline on my own purpose, but I realized it will cause errors if I input long sentence on some tasks, it should do truncation automatically, but it does not. And the pipeline function does not take extra argument so we cannot add something like `truncation=True`. Here is an example on sentiment-analysis task:
```python
from transformers import pipeline
nlp  = pipeline('sentiment-analysis')
text = "This is an example"*300
nlp(text)
```
2. The error message is below:
```
---------------------------------------------------------------------------
IndexError                                Traceback (most recent call last)
<ipython-input-31-0a8ce849cc29> in <module>()
      2 nlp  = pipeline('sentiment-analysis')
      3 text = "This is an example"*300
----> 4 nlp(text)

11 frames
/usr/local/lib/python3.6/dist-packages/torch/nn/functional.py in embedding(input, weight, padding_idx, max_norm, norm_type, scale_grad_by_freq, sparse)
   1722         # remove once script supports set_grad_enabled
   1723         _no_grad_embedding_renorm_(weight, input, max_norm, norm_type)
-> 1724     return torch.embedding(weight, input, padding_idx, scale_grad_by_freq, sparse)
   1725 
   1726 

IndexError: index out of range in self
```
3. same error on NER task, maybe some other task as well.

<!-- 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.-->

## Expected behavior

<!-- A clear and concise description of what you would expect to happen. -->

## 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.0.2
- Platform: Google Colab
- Python version:  Python 3.6.9
- PyTorch version (GPU?):1.5.1+cu101, no GPU
- Tensorflow version (GPU?): no
- Using GPU in script?: no 
- Using distributed or parallel set-up in script?: no


Comments:
Duplicate of #4224
[DOCS] BertModel documentation doesn't mention the usage of tokenizers for creating input_ids
Author: Sriharsha-hatwar
Pull request: no
Labels: name: wontfix

Documentation of https://huggingface.co/transformers/model_doc/bert.html#transformers.BertModel.forward currently doesn't mention the usage of `tokenizers.BertWordPieceTokenizer` for instance when I am using BertModel. 


Comments:
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.
why isn't AlbertForMultipulChioce in modeling_albert?
Author: oashua
Pull request: no
Labels: name: wontfix

name: Core: Modeling

# ❓ 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 Stack Overflow (SO) where a whole community of PyTorch and
     Tensorflow enthusiast can help you out. 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 
     
     If your question wasn't answered after a period of time on Stack Overflow, you
     can always open a question on GitHub. You should then link to the SO question 
     that you posted.
     -->

## Details
<!-- Description of your issue -->
I just copy code from RobertaForMultipleChoice to modeling_albert and change all 'roberta' to 'albert', but the loss didn't goes dowm evidently. And the result is even worse than articles.
<!-- You should first ask your question on SO, and only if
     you didn't get an answer ask it here on GitHub. -->
**A link to original question on Stack Overflow**: 

Comments:
I have come accross the same problem when I was testing RACE for Albert.
Your implementation might be right because there are few differences betweent "roberta" and "albert" finetune heads.
If you are testing RACE like me, the real problem may lie in the lack of max_qa_length implementation in run_multiple_choice.py.

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.
the special token of XLNet
Author: lytum
Pull request: no
Labels: name: wontfix

hello,

may i ask you the special tokens of XLNet are same as BERT, in which they are '[CLS]' and '[SEP]'? Because i found the special tokens of XLNet are '<cls>' and '<sep>' in the original code, however, many public introduction about Xlnet still use the same tokens '[CLS]' and '[SEP]' as BERT. is it ok? are they same and don't matter?

Comments:
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.
Unable to load Longformer pretrained weights
Author: qianyingw
Pull request: no

Hi, 

I am following the official example to load longformer model by:

```
from transformers import LongformerModel, LongformerTokenizer
tokenizer = LongformerTokenizer.from_pretrained('allenai/longformer-base-4096')
model = LongformerModel.from_pretrained('allenai/longformer-base-4096')

```
I can load tokenizer and config, but when I try to load model, it gave me the error "OSError: Unable to load weights from pytorch checkpoint file. If you tried to load a PyTorch model from a TF 2.0 checkpoint, please set from_tf=True." It happened on my other transformer models like BERT/XLNet, and I solved it by their corresponding functions "convert_tf_checkpoint_to_pytorch". I don't understand why this happen on Longformer as it is not from any tensorflow module?

I'm using
- `transformers` version: 3.0.0
- Python version: 3.7.4
- PyTorch version: 1.2.0

Comments:
Hi! Do you have internet access? Does the folder `allenai/longformer-base-4096` exist on your machine?

Ahh...sorry I thought it was included in the library...Thank you for your reply!

It is included in the library :) I'm asking because it may be possible that you have a folder that has the same name, so the library is looking to load that folder instead of [the weights we have on S3.](https://huggingface.co/allenai/longformer-base-4096)

@LysandreJik I don't have any existing folder called 'allenai/longformer-base-4096' (or 'bert-base-uncased' for BERT) and I can't load pretrained weights until I download them to my local machines
ALBERT tokenizer is not callable
Author: guoxuxu
Pull request: no

# 🐛 Bug

## Information
when running the follwoing given example:
from transformers import AlbertTokenizer, AlbertModel
import torch
tokenizer = AlbertTokenizer.from_pretrained('albert-base-v2')
model = AlbertModel.from_pretrained('albert-base-v2')
inputs = tokenizer("Hello, my dog is cute", return_tensors="pt")

it alerts "*** TypeError: 'AlbertTokenizer' object is not callable"

examples link: https://huggingface.co/transformers/model_doc/albert.html#alberttokenizer

Model I am using (Bert, XLNet ...):
ALBERT

Language I am using the model on (English, Chinese ...):
English

The problem arises when using:
* [X ] the official example scripts: (give details below)
from transformers import AlbertTokenizer, AlbertModel
import torch
tokenizer = AlbertTokenizer.from_pretrained('albert-base-v2')
model = AlbertModel.from_pretrained('albert-base-v2')
inputs = tokenizer("Hello, my dog is cute", return_tensors="pt")
 link: https://huggingface.co/transformers/model_doc/albert.html#alberttokenizer'


<!-- 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.-->

*** TypeError: 'AlbertTokenizer' object is not callable

## Expected behavior

Should given a workable example of using ALBERT ?

## 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.3.0
- Platform:  Linux
- Python version:   3.7.4
- PyTorch version (GPU?):   1.4.0
- Tensorflow version (GPU?):  
- Using GPU in script?:  Yes
- Using distributed or parallel set-up in script?:   No


Comments:
Hi there, you should upgrade your transformers library to v3. The version you have does not have callable tokenizers.

Alternatively, the docs for v2.3.0 are [here](https://huggingface.co/transformers/v2.3.0/). You can use the dropdown menu on the left (just under the hugging face) to change the version of the documentation you are using.

Thanks very much

Alternatively,  I found using tokenizer.ecode is ok. 
But, How to view the old doc details for this version?
https://huggingface.co/transformers/v2.3.0/model_doc/albert.html#
This link seems to be archived documentation. No examples provided here.

This is the documentation of the version 2.3.0. For better documentation, you should really consider upgrading your library :-)

Understand. Thanks very much.
Create README.md
Author: gianfrancobarone
Pull request: yes
Labels: name: model card

Hello, we are making this pull request to add model card for our Italian sentiment political model. Thanks!


Comments:
# [Codecov](https://codecov.io/gh/huggingface/transformers/pull/5989?src=pr&el=h1) Report
> Merging [#5989](https://codecov.io/gh/huggingface/transformers/pull/5989?src=pr&el=desc) into [master](https://codecov.io/gh/huggingface/transformers/commit/33d7506ea10ca92886fd1bb3b5306a1a720c58fe&el=desc) will **increase** coverage by `0.17%`.
> The diff coverage is `n/a`.

[![Impacted file tree graph](https://codecov.io/gh/huggingface/transformers/pull/5989/graphs/tree.svg?width=650&height=150&src=pr&token=9qOlN6Hb1c)](https://codecov.io/gh/huggingface/transformers/pull/5989?src=pr&el=tree)

```diff
@@            Coverage Diff             @@
##           master    #5989      +/-   ##
==========================================
+ Coverage   78.48%   78.66%   +0.17%     
==========================================
  Files         146      146              
  Lines       26230    26230              
==========================================
+ Hits        20587    20634      +47     
+ Misses       5643     5596      -47     
```


| [Impacted Files](https://codecov.io/gh/huggingface/transformers/pull/5989?src=pr&el=tree) | Coverage Δ | |
|---|---|---|
| [src/transformers/modeling\_tf\_distilbert.py](https://codecov.io/gh/huggingface/transformers/pull/5989/diff?src=pr&el=tree#diff-c3JjL3RyYW5zZm9ybWVycy9tb2RlbGluZ190Zl9kaXN0aWxiZXJ0LnB5) | `64.90% <0.00%> (-33.90%)` | :arrow_down: |
| [src/transformers/file\_utils.py](https://codecov.io/gh/huggingface/transformers/pull/5989/diff?src=pr&el=tree#diff-c3JjL3RyYW5zZm9ybWVycy9maWxlX3V0aWxzLnB5) | `81.49% <0.00%> (+0.29%)` | :arrow_up: |
| [src/transformers/modeling\_tf\_electra.py](https://codecov.io/gh/huggingface/transformers/pull/5989/diff?src=pr&el=tree#diff-c3JjL3RyYW5zZm9ybWVycy9tb2RlbGluZ190Zl9lbGVjdHJhLnB5) | `95.53% <0.00%> (+69.51%)` | :arrow_up: |

------

[Continue to review full report at Codecov](https://codecov.io/gh/huggingface/transformers/pull/5989?src=pr&el=continue).
> **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta)
> `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
> Powered by [Codecov](https://codecov.io/gh/huggingface/transformers/pull/5989?src=pr&el=footer). Last update [33d7506...ec916e3](https://codecov.io/gh/huggingface/transformers/pull/5989?src=pr&el=lastupdated). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments).
Cleanup Trainer and expose customization points
Author: sgugger
Pull request: yes

Clean up some parts of the code of `Trainer` and expose some function as customization points (doc will follow if you agree on this).

Comments:
# [Codecov](https://codecov.io/gh/huggingface/transformers/pull/5982?src=pr&el=h1) Report
> Merging [#5982](https://codecov.io/gh/huggingface/transformers/pull/5982?src=pr&el=desc) into [master](https://codecov.io/gh/huggingface/transformers/commit/2c0da7803a75f0fc6e6d484e23ca283faa32d785&el=desc) will **decrease** coverage by `0.15%`.
> The diff coverage is `60.00%`.

[![Impacted file tree graph](https://codecov.io/gh/huggingface/transformers/pull/5982/graphs/tree.svg?width=650&height=150&src=pr&token=9qOlN6Hb1c)](https://codecov.io/gh/huggingface/transformers/pull/5982?src=pr&el=tree)

```diff
@@            Coverage Diff             @@
##           master    #5982      +/-   ##
==========================================
- Coverage   78.66%   78.51%   -0.16%     
==========================================
  Files         146      146              
  Lines       26227    26240      +13     
==========================================
- Hits        20632    20602      -30     
- Misses       5595     5638      +43     
```


| [Impacted Files](https://codecov.io/gh/huggingface/transformers/pull/5982?src=pr&el=tree) | Coverage Δ | |
|---|---|---|
| [src/transformers/trainer.py](https://codecov.io/gh/huggingface/transformers/pull/5982/diff?src=pr&el=tree#diff-c3JjL3RyYW5zZm9ybWVycy90cmFpbmVyLnB5) | `40.87% <60.00%> (+2.41%)` | :arrow_up: |
| [src/transformers/modeling\_tf\_electra.py](https://codecov.io/gh/huggingface/transformers/pull/5982/diff?src=pr&el=tree#diff-c3JjL3RyYW5zZm9ybWVycy9tb2RlbGluZ190Zl9lbGVjdHJhLnB5) | `26.02% <0.00%> (-69.52%)` | :arrow_down: |
| [src/transformers/generation\_tf\_utils.py](https://codecov.io/gh/huggingface/transformers/pull/5982/diff?src=pr&el=tree#diff-c3JjL3RyYW5zZm9ybWVycy9nZW5lcmF0aW9uX3RmX3V0aWxzLnB5) | `86.46% <0.00%> (-0.26%)` | :arrow_down: |
| [src/transformers/file\_utils.py](https://codecov.io/gh/huggingface/transformers/pull/5982/diff?src=pr&el=tree#diff-c3JjL3RyYW5zZm9ybWVycy9maWxlX3V0aWxzLnB5) | `81.49% <0.00%> (+0.29%)` | :arrow_up: |
| [src/transformers/modeling\_tf\_distilbert.py](https://codecov.io/gh/huggingface/transformers/pull/5982/diff?src=pr&el=tree#diff-c3JjL3RyYW5zZm9ybWVycy9tb2RlbGluZ190Zl9kaXN0aWxiZXJ0LnB5) | `98.79% <0.00%> (+33.89%)` | :arrow_up: |

------

[Continue to review full report at Codecov](https://codecov.io/gh/huggingface/transformers/pull/5982?src=pr&el=continue).
> **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta)
> `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
> Powered by [Codecov](https://codecov.io/gh/huggingface/transformers/pull/5982?src=pr&el=footer). Last update [2c0da78...e583bf0](https://codecov.io/gh/huggingface/transformers/pull/5982?src=pr&el=lastupdated). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments).
bug in trainer.py line297
Author: Jiaxin-Wen
Pull request: no

# 🐛 Bug

## Information

I found this bug while running example/token_classification/run_ner.py. 
I fixed that by delete the 'self.' prefix.

## Reproduce
 just execute `run_ner.py`


Comments:
Will be fixed by #5982

Fixed by #5982
Error Instantiating T5-11B from conributed models
Author: lordtt13
Pull request: no

# 🐛 Bug

## Information

Model I am using : T5-11B

Language I am using the model on: English

The problem arises when using:
when I try downloading the T5-11B model

The tasks I am working on is:
Evaluating ROGUE score on CNN dataset

## To reproduce

Steps to reproduce the behavior:
Just try instantiating the T5-11B model using the AutoModel Class

Error Message:
OSError: Can't load weights for 't5-11b'. Make sure that:

- 't5-11b' is a correct model identifier listed on 'https://huggingface.co/models'

- or 't5-11b' is the correct path to a directory containing a file named one of pytorch_model.bin, tf_model.h5, model.ckpt.

## Expected behavior
Would instatntiate the 

## Environment info
- `transformers` version: 2.11.0
- Platform: Linux-5.3.0-61-generic-x86_64-with-glibc2.10
- Python version: 3.8.3
- PyTorch version (GPU?): 1.5.0 (True)
- Tensorflow version (GPU?): 2.2.0 (False)
- Using GPU in script?: Yes
- Using distributed or parallel set-up in script?: No

Comments:
same result. I can't download

Please see https://github.com/huggingface/transformers/issues/5986#issuecomment-663090043

Works when I use:

```python
import transformers

t5 = transformers.AutoModel.from_pretrained('t5-11b', use_cdn = False)
```

Thank You!
Fix #5974
Author: sgugger
Pull request: yes

Small bug introduced by the model outputs PR.

Comments:
# [Codecov](https://codecov.io/gh/huggingface/transformers/pull/5999?src=pr&el=h1) Report
> Merging [#5999](https://codecov.io/gh/huggingface/transformers/pull/5999?src=pr&el=desc) into [master](https://codecov.io/gh/huggingface/transformers/commit/76f52324b1e2d2bb631c80895a5f16ddc303a099&el=desc) will **increase** coverage by `0.00%`.
> The diff coverage is `0.00%`.

[![Impacted file tree graph](https://codecov.io/gh/huggingface/transformers/pull/5999/graphs/tree.svg?width=650&height=150&src=pr&token=9qOlN6Hb1c)](https://codecov.io/gh/huggingface/transformers/pull/5999?src=pr&el=tree)

```diff
@@           Coverage Diff           @@
##           master    #5999   +/-   ##
=======================================
  Coverage   78.66%   78.66%           
=======================================
  Files         146      146           
  Lines       26230    26229    -1     
=======================================
  Hits        20633    20633           
+ Misses       5597     5596    -1     
```


| [Impacted Files](https://codecov.io/gh/huggingface/transformers/pull/5999?src=pr&el=tree) | Coverage Δ | |
|---|---|---|
| [src/transformers/modeling\_transfo\_xl.py](https://codecov.io/gh/huggingface/transformers/pull/5999/diff?src=pr&el=tree#diff-c3JjL3RyYW5zZm9ybWVycy9tb2RlbGluZ190cmFuc2ZvX3hsLnB5) | `79.12% <0.00%> (-0.04%)` | :arrow_down: |
| [src/transformers/generation\_utils.py](https://codecov.io/gh/huggingface/transformers/pull/5999/diff?src=pr&el=tree#diff-c3JjL3RyYW5zZm9ybWVycy9nZW5lcmF0aW9uX3V0aWxzLnB5) | `97.11% <0.00%> (+0.28%)` | :arrow_up: |

------

[Continue to review full report at Codecov](https://codecov.io/gh/huggingface/transformers/pull/5999?src=pr&el=continue).
> **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta)
> `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
> Powered by [Codecov](https://codecov.io/gh/huggingface/transformers/pull/5999?src=pr&el=footer). Last update [76f5232...c6a5a2a](https://codecov.io/gh/huggingface/transformers/pull/5999?src=pr&el=lastupdated). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments).