Google T5 (Text-To-Text Transfer Transformer) Small


The T5 transformer model described in the seminal paper “Exploring the Limits of Transfer Learning with a Unified Text-to-Text Transformer”. This model can perform a variety of tasks, such as text summarization, question answering, and translation. More details about using the model can be found in the paper (

Live Demo Open in Colab Download

How to use

Either set the following tasks or have them inline with your input:

  • summarize:
  • translate English to German:
  • translate English to French:
  • stsb sentence1: Big news. sentence2: No idea.

The full list of tasks is in the Appendix of the paper:

document_assembler = DocumentAssembler() \
.setInputCol("text") \

t5 = T5Transformer() \
.pretrained("t5_small") \
.setInputCols(["documents"]) \

pipeline = Pipeline().setStages([document_assembler, t5])
results ="summaries.result").show(truncate=False)
val documentAssembler = new DocumentAssembler()

val t5 = T5Transformer

val pipeline = new Pipeline().setStages(Array(documentAssembler, t5))

val model =
val results = model.transform(dataDf)"summaries.result").show(truncate = false)
import nlu
nlu.load("en.t5.small").predict("""Put your text here.""")

Model Information

Model Name: t5_small
Compatibility: Spark NLP 2.7.1+
Edition: Official
Input Labels: [sentence]
Output Labels: [t5]
Language: en

Data Source