CTRL model can not work
Author: yanan1116
Pull request: no

torch ver: 1.8.1+cu102
transformers ver: 4.4.2

I adopt the example codes from https://github.com/huggingface/transformers/blob/master/examples/text-generation/run_generation.py
to generate text by using ctrl.
here is the head part of my codes:

```
import torch
from transformers import CTRLTokenizer, CTRLLMHeadModel
tokenizer = CTRLTokenizer.from_pretrained('ctrl')
model = CTRLLMHeadModel.from_pretrained('ctrl')

encoded_prompt = tokenizer.encode("Links Hello, my dog is cute", add_special_tokens=False)
```
Error:

> ---------------------------------------------------------------------------
> ValueError                                Traceback (most recent call last)
> <ipython-input-13-b2e746c8b306> in <module>
> ----> 1 encoded_prompt = tokenizer.encode("Links Hello, my dog is cute", add_special_tokens=False)
> 
> ~/yanan/env/lib/python3.6/site-packages/transformers/tokenization_utils_base.py in encode(self, text, text_pair, add_special_tokens, padding, truncation, max_length, stride, return_tensors, **kwargs)
>    2030             stride=stride,
>    2031             return_tensors=return_tensors,
> -> 2032             **kwargs,
>    2033         )
>    2034
> 
> ~/yanan/env/lib/python3.6/site-packages/transformers/tokenization_utils_base.py in encode_plus(self, text, text_pair, add_special_tokens, padding, truncation, max_length, stride, is_split_into_words, pad_to_multiple_of, return_tensors, return_token_type_ids, return_attention_mask, return_overflowing_tokens, return_special_tokens_mask, return_offsets_mapping, return_length, verbose, **kwargs)
>    2355             return_length=return_length,
>    2356             verbose=verbose,
> -> 2357             **kwargs,
>    2358         )
>    2359
> 
> ~/yanan/env/lib/python3.6/site-packages/transformers/tokenization_utils.py in _encode_plus(self, text, text_pair, add_special_tokens, padding_strategy, truncation_strategy, max_length, stride, is_split_into_words, pad_to_multiple_of, return_tensors, return_token_type_ids, return_attention_mask, return_overflowing_tokens, return_special_tokens_mask, return_offsets_mapping, return_length, verbose, **kwargs)
>     458             return_special_tokens_mask=return_special_tokens_mask,
>     459             return_length=return_length,
> --> 460             verbose=verbose,
>     461         )
>     462
> 
> ~/yanan/env/lib/python3.6/site-packages/transformers/tokenization_utils_base.py in prepare_for_model(self, ids, pair_ids, add_special_tokens, padding, truncation, max_length, stride, pad_to_multiple_of, return_tensors, return_token_type_ids, return_attention_mask, return_overflowing_tokens, return_special_tokens_mask, return_offsets_mapping, return_length, verbose, prepend_batch_axis, **kwargs)
>    2792                 padding=padding_strategy.value,
>    2793                 pad_to_multiple_of=pad_to_multiple_of,
> -> 2794                 return_attention_mask=return_attention_mask,
>    2795             )
>    2796
> 
> ~/yanan/env/lib/python3.6/site-packages/transformers/tokenization_utils_base.py in pad(self, encoded_inputs, padding, max_length, pad_to_multiple_of, return_attention_mask, return_tensors, verbose)
>    2591             else:
>    2592                 raise ValueError(
> -> 2593                     f"type of {first_element} unknown: {type(first_element)}. "
>    2594                     f"Should be one of a python, numpy, pytorch or tensorflow object."
>    2595                 )
> 
> ValueError: type of None unknown: <class 'NoneType'>. Should be one of a python, numpy, pytorch or tensorflow object.

Comments:
I also try to git pull the updated codes and run the official command:
`python run_generation.py --model_type ctrl --model_name ctrl --temperature 0 --repetition 1.2`

ERROR:

> 04/07/2021 10:22:08 - WARNING - main - device: cpu, n_gpu: 0, 16-bits training: False
> 04/07/2021 10:23:25 - INFO - main - Namespace(device=device(type='cpu'), fp16=False, k=0, length=20, model_name_or_path='ctrl', model_type='ctrl', n_gpu=0, no_cuda=False, num_return_sequences=1, p=0.9, padding_text='', prefix='', prompt='', repetition_penalty=1.2, seed=42, stop_token=None, temperature=0.0, xlm_language='')
> Model prompt >>> Links Hello, my dog is cute
> 2021-04-07 10:24:00.280690: W tensorflow/stream_executor/platform/default/dso_loader.cc:60] Could not load dynamic library 'libcudart.so.11.0'; dlerror: libcudart.so.11.0: cannot open shared object file: No such file or directory
> 2021-04-07 10:24:00.280732: I tensorflow/stream_executor/cuda/cudart_stub.cc:29] Ignore above cudart dlerror if you do not have a GPU set up on your machine.
> Traceback (most recent call last):
> File "run_generation.py", line 290, in
> main()
> File "run_generation.py", line 231, in main
> preprocessed_prompt_text = prepare_input(args, model, tokenizer, prompt_text)
> File "run_generation.py", line 92, in prepare_ctrl_input
> encoded_prompt = tokenizer.encode(prompt_text, add_special_tokens=False)
> File "/usr/local/lib/python3.6/dist-packages/transformers/tokenization_utils_base.py", line 2032, in encode
> **kwargs,
> File "/usr/local/lib/python3.6/dist-packages/transformers/tokenization_utils_base.py", line 2357, in encode_plus
> **kwargs,
> File "/usr/local/lib/python3.6/dist-packages/transformers/tokenization_utils.py", line 460, in _encode_plus
> verbose=verbose,
> File "/usr/local/lib/python3.6/dist-packages/transformers/tokenization_utils_base.py", line 2794, in prepare_for_model
> return_attention_mask=return_attention_mask,
> File "/usr/local/lib/python3.6/dist-packages/transformers/tokenization_utils_base.py", line 2593, in pad
> f"type of {first_element} unknown: {type(first_element)}. "
> ValueError: type of None unknown: <class 'NoneType'>. Should be one of a python, numpy, pytorch or tensorflow object.

Hello, I'm having a hard time reproducing. When running your last example, I get an error because you've specified a temperature of 0 whereas it should be strictly positive, but that's it.

From your error I believe it might be due to a setup issue. Can you fill in the environment information requested as asked in the template? `transformers-cli env`

Or do you have a colab handy with a reproducer? Thank you!

Oh, I've tweaked a few things and I now have a reproducer! Looking into it.

Hey @yananchen1989, there was an issue with the vocabulary, I've patched it in [`huggingface@c03b9b`](https://huggingface.co/ctrl/commit/c03b9b1e9f9269e4ec848bc341bb71acab8d18c7). Can you let me know if you manage to use the CTRL model now?

@LysandreJik 
Hi ,
here is the env info:

> 
> - `transformers` version: 4.6.0.dev0
> - Platform: Linux-4.9.2-3.0.0.std7b.el7.5.x86_64-x86_64-with-Ubuntu-18.04-bionic
> - Python version: 3.6.9
> - PyTorch version (GPU?): 1.7.1+cu101 (True)
> - Tensorflow version (GPU?): 2.3.1 (True)
> - Using GPU in script?: <fill in>
> - Using distributed or parallel set-up in script?: <fill in>

And another machine's env. (actually I run the codes in both the two machines to check if there is something wrong in the env rather than the code itself)

> - `transformers` version: 4.4.2
> - Platform: Linux-4.9.2-3.0.0.std7b.el7.5.x86_64-x86_64-with-debian-buster-sid
> - Python version: 3.7.10
> - PyTorch version (GPU?): 1.8.1+cu102 (True)
> - Tensorflow version (GPU?): 2.3.1 (True)
> - Using GPU in script?: <fill in>
> - Using distributed or parallel set-up in script?: <fill in>

After reinstallation by the command: 
`pip install git+https://github.com/huggingface/transformers`

The env info:

> - `transformers` version: 4.6.0.dev0
> - Platform: Linux-4.9.2-3.0.0.std7b.el7.5.x86_64-x86_64-with-Ubuntu-18.04-bionic
> - Python version: 3.6.9
> - PyTorch version (GPU?): 1.5.0 (False)
> - Tensorflow version (GPU?): 2.4.1 (False)
> - Using GPU in script?: <fill in>
> - Using distributed or parallel set-up in script?: <fill in>
> 

> In [5]: model_name='ctrl'
> 
> In [6]: from transformers import pipeline
>    ...: model  = pipeline("text-generation", model=model_name, device=0) #
>    ...:
> 
> In [7]: results = model('Links Hello, my dog is cute ', max_length=250, \
>    ...:                 repetition_penalty=1.2, \
>    ...:                  do_sample=True, top_p=0.9, top_k=0, num_return_sequences=5)
> 
> In [8]: results
> Out[8]:
> [{'generated_text': 'Links Hello, my dog is cute  and amazing thanks to my little girl’s consistent loving. After over 25 years, of honing her character even in a parking lot behind the grocery store. It seems like every time we take our beloved Ava out, something else will change. So I’ll ask you two questions: What kind of place did she grow up in? What type of houses does your wonderful girl live in?? And also – how do all these changes look from when this picture was taken in 2014 but as I talked about earlier, it still holds true today. It’s worth noting that none of those homes are condos. There aren’t many empty houses, so things should be manageable. \n \n When I got home there were eight pets at home, six dog owners, three cats, one bunny. Nothing gets shipped or made for us. Before unloading them into their crates with everything on hand – furniture carriers, leashes, harnesses, treats, flashlights, supplies, food bowls, crates and such, etc., – between each person trying its best to figure out if it’s fair to invite more animals in, I helped unload some stuff ourselves … either by heaving boxes off two successive helpers, or helping friends heave in excess to build a makeshift bed inside the trailer. All too often, once we’ve cleaned up, left the mobile units set free, loaded them onto our pickup truck, we’re expected to head'},

The bug is fixed, thanks.  @LysandreJik 

@LysandreJik  What is the default temperature have you set ?

I check the official CTRL git, https://github.com/salesforce/ctrl 
it set the temperature to zero.

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.