[Probably a bug] - T5TokenizerFast is not the same as T5Tokenizer  - it adds id 1 when using batch encode plus 
Author: Oxi84
Pull request: no

Ubuntu 18.04
Transformers 4.12.5

I tried  T5TokenizerFast and it is much faster but the generation output is different.  Encoding part seems like adds one addition 1 (id) while the decoder seem to work fine.  But as results output is very different.

    1)
    from transformers import T5ForConditionalGeneration,T5Tokenizer, T5TokenizerFast
    model1a = T5ForConditionalGeneration.from_pretrained(my_model_path)
    tokenizer1 = T5Tokenizer.from_pretrained('t5-large')
    encoding = tokenizer1_decode.batch_encode_plus(text,pad_to_max_length=True)
    encoding {'input_ids': [[9, 5, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0]   
    2)

    from transformers import T5ForConditionalGeneration,T5Tokenizer, T5TokenizerFast
    model1a = T5ForConditionalGeneration.from_pretrained(my_model_path)
    tokenizer1 = T5TokenizerFast.from_pretrained('t5-large')
    encoding = tokenizer1.batch_encode_plus(text,pad_to_max_length=True)
    encoding {'input_ids': [[9, 5, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0] 

Is this normal behavior, i expected the results to be exactly  the same and they are very different.

Solution:
1) for encoding use  standard tokenizer
2) for decoding use fast tokenizer (it seems to work fine so far)


Comments:
Hi @Oxi84, 

I'm not able to reproduce this error. 
In the code cell you gave, at the first block you define `tokenizer1` but you are using `tokenizer1_decode` as a tokenizer instance. 

The error may come from this line : `encoding = tokenizer1_decode.batch_encode_plus(text,pad_to_max_length=True)` ?

Thanks for the answer, i solved it. Tokenizerfast already adds s so i had this character 2 times.

    from transformers import T5ForConditionalGeneration,T5Tokenizer, T5TokenizerFast
    tokenizer = T5Tokenizer.from_pretrained('t5-large')
    tokenizerFast = T5TokenizerFast.from_pretrained('t5-large')
 
    sentence_list = ["I really like beer. It's better than whiskey."]
    print("sentence_list",sentence_list)
    text = []
    text1 = []
    for sentence in sentence_list:
        text.append("paraphrase: " + sentence + " 
")  
        text1.append("paraphrase: " + sentence) 
        
    encoding = tokenizer.batch_encode_plus(text,pad_to_max_length=True)
    encoding1 = tokenizerFast.batch_encode_plus(text,pad_to_max_length=True)
    encoding1a = tokenizerFast.batch_encode_plus(text1,pad_to_max_length=True)
    input_ids, attention_masks = encoding["input_ids"], encoding["attention_mask"]
    input_ids1, attention_masks1 = encoding1["input_ids"], encoding1["attention_mask"]
    input_ids1a, attention_masks1a = encoding1a["input_ids"], encoding1a["attention_mask"]
    
    print("encoding",input_ids)
    print("encoding",input_ids1)
    print("encoding",input_ids1a)
    print("attention_masks",attention_masks)
    print("attention_masks",attention_masks1) 
    print("attention_masks",attention_masks1a)


So the results was:

    encoding [[3856, 27111, 10, 27, 310, 114, 6061, 5, 94, 31, 7, 394, 145, 27971, 5, 1]]
    encoding [[3856, 27111, 10, 27, 310, 114, 6061, 5, 94, 31, 7, 394, 145, 27971, 5, 1, 1]]
    encoding [[3856, 27111, 10, 27, 310, 114, 6061, 5, 94, 31, 7, 394, 145, 27971, 5, 1]]
    attention_masks [[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]]
    attention_masks [[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]]
    attention_masks [[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]]





I sometimes even get better results with 
 added 2 times which is interesting :)

@Oxi84 - is there still an issue?

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.