readme: ---
  language:
  - nl
  - en
  datasets:
  - yhavinga/mc4_nl_cleaned
  - yhavinga/ccmatrix
  tags:
  - t5
  - translation
  - seq2seq
  
  pipeline_tag: translation
  widget:
  - text: "It is a painful and tragic spectacle that rises before me: I have drawn back the curtain from the rottenness of man. This word, in my mouth, is at least free from one suspicion: that it involves a moral accusation against humanity."
  - text: "Young Wehling was hunched in his chair, his head in his hand. He was so rumpled, so still and colorless as to be virtually invisible. His camouflage was perfect, since the waiting room had a disorderly and demoralized air, too. Chairs and ashtrays had been moved away from the walls. The floor was paved with spattered dropcloths."
  
  license: apache-2.0
  ---
  
  # t5-small-24L-ccmatrix-multi
  
  A [t5-small-24L-dutch-english](https://huggingface.co/yhavinga/t5-small-24L-dutch-english) model finetuned for Dutch to English and English to Dutch translation on the CCMatrix dataset.
  Evaluation metrics of this model are listed in the **Translation models** section below.
  
  You can use this model directly with a pipeline for text translation:
  
  ```python
  model_name = "yhavinga/t5-small-24L-ccmatrix-multi"
  from transformers import AutoTokenizer
  from transformers import AutoModelForSeq2SeqLM
  from transformers import pipeline
  import torch
  device_num = 0 if torch.cuda.is_available() else -1
  device = "cpu" if device_num < 0 else f"cuda:{device_num}"
  tokenizer = AutoTokenizer.from_pretrained(model_name)
  model = AutoModelForSeq2SeqLM.from_pretrained(model_name).to(device)
  params = {"max_length": 128, "num_beams": 4, "early_stopping": True}
  en_to_nl = pipeline("translation_en_to_nl", tokenizer=tokenizer, model=model, device=device_num)
  print(en_to_nl("""Young Wehling was hunched in his chair, his head in his hand. He was so rumpled, so still and colorless as to be virtually invisible.""",
                 **params)[0]['translation_text'])
  nl_to_en = pipeline("translation_nl_to_en", tokenizer=tokenizer, model=model, device=device_num)
  print(nl_to_en("""De jonge Wehling zat gebogen in zijn stoel, zijn hoofd in zijn hand. Hij was zo stoffig, zo stil en kleurloos dat hij vrijwel onzichtbaar was.""",
                 **params)[0]['translation_text'])
  ```
  
  This **t5 eff** model has **249M** parameters.
  It was pre-trained with masked language modeling (denoise token span corruption) objective on the dataset
  `mc4_nl_cleaned` config `large_en_nl` for **1** epoch(s) and a duration of **4d10h**,
  with a sequence length of **512**, batch size **128** and **851852** total steps (**56B** tokens).
  Pre-training evaluation loss and accuracy are **1,18** and **0,74**.
  Refer to the evaluation section below for a comparison of the pre-trained models on summarization and translation.
  
  
  ## Tokenizer
  
  The model uses a cased SentencePiece tokenizer configured with the `Nmt, NFKC, Replace multi-space to single-space` normalizers
  and has 32003 tokens.
  It was trained on Dutch and English  with scripts from the Huggingface Transformers [Flax examples](https://github.com/huggingface/transformers/tree/master/examples/flax/language-modeling).
  See [./raw/main/tokenizer.json](tokenizer.json) for details.
   
  ## Dataset(s)
  
  All models listed below are pre-trained on 
  [cleaned Dutch mC4](https://huggingface.co/datasets/yhavinga/mc4_nl_cleaned),
  which is the original mC4, except
  
    * Documents that contained words from a selection of the Dutch and English [List of Dirty Naught Obscene and Otherwise Bad Words](https://github.com/LDNOOBW/List-of-Dirty-Naughty-Obscene-and-Otherwise-Bad-Words) are removed
    * Sentences with less than 3 words are removed
    * Sentences with a word of more than 1000 characters are removed
    * Documents with less than 5 sentences are removed
    * Documents with "javascript", "lorum ipsum", "terms of use", "privacy policy", "cookie policy", "uses cookies",
      "use of cookies", "use cookies", "elementen ontbreken", "deze printversie" are removed.
   
  The Dutch and English models are pre-trained on a 50/50% mix of Dutch mC4 and English C4.
  
  The translation models are fine-tuned on [CCMatrix](https://huggingface.co/datasets/yhavinga/ccmatrix).
  
  ## Dutch T5 Models
  
  Three types of [Dutch T5 models have been trained (blog)](https://huggingface.co/spaces/yhavinga/pre-training-dutch-t5-models).
  `t5-base-dutch` is the only model with an original T5 config.
  The other model types t5-v1.1 and t5-eff have `gated-relu` instead of `relu` as activation function,
  and trained with a drop-out of `0.0` unless training would diverge (`t5-v1.1-large-dutch-cased`).
  The T5-eff models are models that differ in their number of layers. The table will list
  the several dimensions of these models. Not all t5-eff models are efficient, the best example being the inefficient
  `t5-xl-4L-dutch-english-cased`. 
  
  |                   | [t5-base-dutch](https://huggingface.co/yhavinga/t5-base-dutch)   | [t5-v1.1-base-dutch-uncased](https://huggingface.co/yhavinga/t5-v1.1-base-dutch-uncased)   | [t5-v