Translation pipeline bug after 398 characters
Author: MoritzLaurer
Pull request: no

# 🐛 Bug

The translation pipeline with T5 does not seem to allow longer translations than 400~ character. It either automatically stops at 398, or if I play with the min/max_length parameters, it produces gibberish after 400~ characters.  

## Information
I am using the translation pipeline (T5)
I tried both:
translator_de = pipeline(task='translation_en_to_de')
translator_fr = pipeline(task='translation_en_to_fr')

I tried the different suggestions in this short twitter discussion, but couldn't get it to work: https://twitter.com/PatrickPlaten/status/1244747294664200193

## To reproduce
Steps to reproduce the behavior:

```Python
translator_de = pipeline(task='translation_en_to_de')

text_en = "The 2019–20 coronavirus pandemic is an ongoing pandemic of coronavirus disease 2019 (COVID-19), caused by severe acute respiratory syndrome coronavirus 2 (SARS-CoV-2).[6] The outbreak was first identified in Wuhan, Hubei, China, in December 2019. The World Health Organization (WHO) declared the outbreak to be a Public Health Emergency of International Concern on 30 January 2020 and recognized it as a pandemic on 11 March.[7][8] As of 30 March 2020, more than 745,000[4] cases of COVID-19 have been reported in over 190 countries and territories, resulting in approximately 35,000[4] deaths. More than 156,500[4] people have since recovered.[5]"

text_trans_de = translator_de(text_en, min_length=len(text_en), early_stopping=False)
text_trans_de[0]['translation_text']
```

Output: 
'Zu den Bemühungen, die Ausbreitung des Virus zu verhindern, zählen Reisebeschränkungen, Quarantäne, Sperrzeiten, Arbeitsplatz-Gefahrkontrollen, Verschiebungen und Annullierungen von Veranstaltungen und Anlagenschließungen, darunter die Quarantäne in Hubei, nationale oder regionale Quarantäne in anderen Teilen der Welt, Sperrmaßnahmen in China und Südkorea, verschiedene Grenzschließungen oder Einreise\xad\xad\xad\xad\xad\xad\xad\xad\xad\xad\xad\xad\xad\xad\xad\xad\xad\xad\xad\xad\xad\xad\xad\xad\xad\xad\xad\xad\xad\xad\xad\xad\xad\xad\xad\xad\xad\xad\xad\xad\xad\xad\xad\xad\xad\xad\xad\xad\xad\xad\xad\xad\xad\xad\xad\xad\xad\xad\xad\xad\xad\xad\xad\xad\xad\xad\xad\xad\xad\xad\xad\xad\xad\xad\xad\xad\xad\xad\xad\xad\xad\xad\xad\xad\xad\xad\xad\xad\xad\xad\xad\xad\xad\xad\xad\xad\xad\xad\xad\xad\xad\xad\xad\xad\xad\xad\xad\xad\xad\xad\xad\xad\xad\xad\xad\xad\xad\xad\xad\xad\xad\xad\xad\xad\xad\xad\xad\xad\xad\xad\xad\xad\xad\xad\xad\xad\xad\xad\xad\xad\xad\xad\xad\xad\xad\xad\xad\xad\xad\xad\xad\xad\xad\xad\xad\xad\xad\xad\xad\xad\xad\xad\xad\xad\xad\xad\xad\xad\xad\xad\xad\xad\xad\xad\xad\xad\xad\xad\xad\xad\xad\xad\xad\xad\xad\xad'


## Expected behavior

Ideally, it would allow me to translate text of any length.

## Environment info
- `transformers` version: 2.7.0
- Platform: MacOS Catalania 10.15.3 (19D76)
- Python version: 7.3
- Using GPU in script?: No, CPU
- Using distributed or parallel set-up in script?: No. 


Comments:
Hi @MoritzLaurer, 

I played around with your example a bit and I don't get a good translation either! I think one of the main problems is that T5 was pretrained on a per sentence level - not on whole texts. 
Therefore you get quite good results when you split your text into sentences and translate each sentence on its own as follows: 


```
from transformers import pipeline
translator_de = pipeline(task='translation_en_to_de')

text_en = "The 2019–20 coronavirus pandemic is an ongoing pandemic of coronavirus disease 2019 (COVID-19), caused by severe acute respiratory syndrome coronavirus 2 (SARS-CoV-2).[6] The outbreak was first identified in Wuhan, Hubei, China, in December 2019. The World Health Organization (WHO) declared the outbreak to be a Public Health Emergency of International Concern on 30 January 2020 and recognized it as a pandemic on 11 March.[7][8] As of 30 March 2020, more than 745,000[4] cases of COVID-19 have been reported in over 190 countries and territories, resulting in approximately 35,000[4] deaths. More than 156,500[4] people have since recovered.[5]"

translation_list = []
text_list = text_en.split('.')

for text in text_list:
    translation_list.append(translator_de(text + '.'))
```

I would actually always do this when using T5 on translation and then concatenate the sentences back together afterward. It's very rare that you need to know the previous or next sentence in order to get good translation results.

PS:
You have to be careful when using `len(text_en)` it gives you the number of characters in your string not the number of words. Also note that `min_length` and `max_length` represent the number of minimal and maximal tokens (which is usually a bit less than the number of words). 

Here the results, I got in German: 

```
[[{'translation_text': 'Die Koronavirus-Pandemie 2019–20 ist eine anhaltende Pandemie der Koronavirus-Krankheit 2019 (COVID-19), verursacht durch das schwere akute Atemwegssyndrom Koronavirus 2 (SARS-CoV-2).'}],
 [{'translation_text': '[6] Der Ausbruch wurde erstmals im Dezember 2019 in Wuhan, Hubei, China, festgestellt.'}],
 [{'translation_text': 'Die Weltgesundheitsorganisation (WHO) hat den Ausbruch am 30. Januar 2020 als öffentlichen Gesundheitsnotstand von internationaler Bedeutung erklärt und ihn am 11. März als Pandemie anerkannt.'}],
 [{'translation_text': '[7][8] Zum 30. März 2020 wurden in über 190 Ländern und Gebieten mehr als 745 000 Fälle von COVID-19 gemeldet, was zu etwa 35 000 Todesfällen führte.'}],
 [{'translation_text': 'Mehr als 156.500[4] Menschen haben sich seitdem erholt.'}],
 [{'translation_text': '[5].'}]]
```


Hi @patrickvonplaten, 

Great, thank you very much for the response! It makes sense and splitting in sentences seems like a good solution. (also thanks for clarifying that min_length refers to tokens and not characters)