PreTrainedModel.generate do_sample default argument is wrong in the documentation
Author: aligirayhanozbay
Pull request: no
Labels: name: PyTorch

name: Core: Modeling

name: Documentation

# 🐛 Bug

## Information

Model I am using (Bert, XLNet ...): GPT2LMHeadModel

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. Create GPT2LMHeadModel and GPT2Tokenizer objects using the from_pretrained('gpt2') method
2. Use the generate function to generate sequences without any input argument multiple times, and then repeat by setting do_sample = True
3. When do_sample is set to False (or is not supplied at all), the generate method constantly generates the following string:
'!\n\nThe first thing I did was to make a list of all the things I would!'

When generating with do_sample set to True, changing results are outputted. This is consistent with the behaviour described in the code, except for the default value of do_sample

Code sample from a python shell:
'''python
>>> model = transformers.GPT2LMHeadModel.from_pretrained('gpt2')
>>> g2t = transformers.GPT2Tokenizer.from_pretrained('gpt2')
>>> g2t.decode(model.generate()[0])
'!\n\nThe first thing I did was to make a list of all the things I would!'
>>> g2t.decode(model.generate()[0])
'!\n\nThe first thing I did was to make a list of all the things I would!'
>>> g2t.decode(model.generate()[0])
'!\n\nThe first thing I did was to make a list of all the things I would!'
>>> g2t.decode(model.generate(do_sample=True)[0])
"!, I can't help but wonder how she's doing. I really have no idea.!"
>>> g2t.decode(model.generate(do_sample=True)[0])
'!\n\nThe other guy is trying to take something away from the guy before you even start!'
>>> g2t.decode(model.generate(do_sample=True)[0])
'! are you kidding me?\n\n\nBut maybe you should wait for his own "last act!'
'''

Similarly, you can do print((transformers.GPT2LMHeadModel.from_pretrained('gpt2')).config.do_sample) to verify that the 'default' argument is in fact False

## Expected behavior
The documentation should say do_sample is False by default OR the config should be updated to be in line with the documentation

## Environment info
<!-- You can run the command `python 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.4.1
- Platform: Ubuntu GNU/Linux 18.04
- Python version: Python 3.6.9 (default, Nov  7 2019, 10:44:02) [GCC 8.3.0] on linux
- PyTorch version (GPU?): 1.4.0 GPU version with Nvidia RTX 2080Ti
- Tensorflow version (GPU?): N/A
- Using GPU in script?: No
- Using distributed or parallel set-up in script?: No


Comments:
In the documentation for [version 2.4.1/2.4.0](https://huggingface.co/transformers/v2.4.0/main_classes/model.html#transformers.PreTrainedModel.generate), it does indicate it is `False` by default. In the [master documentation](https://huggingface.co/transformers/main_classes/model.html#transformers.PreTrainedModel.generate) though, it is set to `True` by default because we've changed it on the current master.

I see, however the page title for the master documentation clearly indicates 2.4.1 for the version, which was the source of my confusion. Thank you very much for the clarification

Indeed, this is very misleading. I'll update it.