T5 (Text-to-Text Transfer Transformer) is a series of large language models developed by Google AI. Introduced in 2019,[1][2] T5 models are trained on a massive dataset of text and code using a text-to-text framework. The T5 models are capable of performing the text-based tasks that they were pretrained for. They can also be finetuned to perform other tasks. They have been employed in various applications, including chatbots, machine translation systems, text summarization tools, code generation, and robotics.[3]

Text-to-Text Transfer Transformer (T5)
Original author(s)Google AI
Initial release23 October 2019; 4 years ago (23 October 2019)
Stable release
Repositoryhttps://github.com/google-research/text-to-text-transfer-transformer
Type
LicenseApache-2.0
Websiteblog.research.google/2020/02/exploring-transfer-learning-with-t5.html

Like the original Transformer model,[4] T5 models are encoder-decoder Transformers, where the encoder processes the input text, and the decoder generates the output text.

Training

edit

The original T5 models are pre-trained on the Colossal Clean Crawled Corpus (C4), containing text and code scraped from the internet. This pre-training process enables the models to learn general language understanding and generation abilities. T5 models can then be fine-tuned on specific downstream tasks, adapting their knowledge to perform well in various applications.

The T5 models were pretrained on many tasks, all in the format of <input text> -> <output text>.

 
How a T5 can be finetuned for a summarization task.[5]

Some examples are:

  • restoring corrupted text: Thank you <X> me to your party <Y> week. -> <X> for inviting <Y> last <Z>, where the <Z> means "end of output", and the <X> and <Y> denote blanks to be filled, called "sentinels" in the original report.
  • translation: translate English to German: That is good. -> Das ist gut..
  • judging the grammatical acceptability of a sentence (CoLA sentence): The course is jumping well. -> not acceptable .

Architecture

edit
 
T5 encoder-decoder structure, showing the attention structure. In the encoder self-attention (lower square), all input tokens attend to each other; In the encoder–decoder cross-attention (upper rectangle), each target token attends to all input tokens; In the decoder self-attention (upper triangle), each target token attends to present and past target tokens only (causal).[5]

The T5 series encompasses several models with varying sizes and capabilities, all encoder-decoder Transformers, where the encoder processes the input text, and the decoder generates the output text.

These models are often distinguished by their parameter count, which indicates the complexity and potential capacity of the model. The original paper[1] reported the following 5 models:

Model Parameters # layers       # heads
Small 60M 6 512 2048 64 8
Base 220M 12 768 3072 64 12
Large 770M 24 1024 4096 64 16
3B (XL) 3B 24 1024 16384 128 32
11B (XXL) 11B 24 1024 65536 128 128

In the above table,

  • # layers: Number of layers in the encoder; also, number of layers in the decoder. They always have the same number of layers.
  • # heads: Number of attention heads in each attention block.
  •  : Dimension of the embedding vectors.
  •  : Dimension of the feedforward network within each encoder and decoder layer.
  •  : Dimension of the key and value vectors used in the self-attention mechanism.

Variants

edit

Several subsequent models used the T5 architecture, with non-standardized naming conventions used to differentiate them. This section attempts to collect the main ones. An exhaustive list of the variants released by Google Brain is on the GitHub repo for T5X.[6]

Some models are trained from scratch while others are trained by starting with a previous trained model. By default, each model is trained from scratch, except otherwise noted.

  • T5 small, base, large, XL, XXL (2019): The original models.[1][2] Note that "XL" and "XXL" were renamed from "3B" and "11B" used in the original paper.[6]
  • LM-adapted T5 (2021): a series of models (from small to XXL) that started from checkpoints of the T5 series, but trained further on 100B additional tokens from C4.[7]
  • Switch Transformer (2021): a mixture-of-experts variant of T5, by replacing the feedforward layers in the encoder and decoder blocks with mixture of expert feedforward layers.[8][9]
  • T0 3B, 11B (2021): a series of models that started from checkpoints of LM-adapted T5, and further trained to perform tasks based only on task instruction (zero-shot).[10] Different entries in the series uses different finetuning data.[11]
  • ByT5 (2021): a byte-level version of T5, trained on mC4 (multilingual C4) dataset.[12] It operates on text encoded as UTF-8 bytes, without tokenizers.
  • Flan-T5-XL (2022): a model that started with a checkpoint of T5 XL, then instruction-tuned on the FLAN dataset.[13][14][15][16]
  • T5X (2022): a JAX-based re-implementation of the original T5 codebase. It is not a model.[17] The original T5 codebase was implemented in TensorFlow with MeshTF.[2]
  • UL2 20B (2022): a model with the same architecture as the T5 series, but scaled up to 20B, and trained with "mixture of denoisers" objective on the C4.[18]
  • Flan-UL2 20B (2022): UL2 20B instruction-finetuned on the FLAN dataset.[18][15]
  • Pile-T5 (2024): has the same architecture of T5, except it used the Llama tokenizer. It was trained on The Pile. It came in sizes of base, large, XL, XXL.[19]

Applications

edit

The T5 model itself is an encoder-decoder model, allowing it to be used for instruction following. The encoder encodes the instruction, and the decoder autoregressively generates the reply.

The T5 encoder can be used as a text encoder, much like BERT. It encodes a text into a sequence of real-number vectors, which can be used for downstream applications. For example, Google Imagen[20] uses T5-XXL as text encoder, and the encoded text vectors are used as conditioning on a diffusion model. As another example, the AuraFlow diffusion model[21] uses Pile-T5-XL.

References

edit
  1. ^ a b c Raffel, Colin; Shazeer, Noam; Roberts, Adam; Lee, Katherine; Narang, Sharan; Matena, Michael; Zhou, Yanqi; Li, Wei; Liu, Peter J. (2020). "Exploring the Limits of Transfer Learning with a Unified Text-to-Text Transformer". Journal of Machine Learning Research. 21 (140): 1–67. ISSN 1533-7928.
  2. ^ a b c google-research/text-to-text-transfer-transformer, Google Research, 2024-08-21, retrieved 2024-08-21
  3. ^ Jiang, Yunfan; Gupta, Agrim; Zhang, Zichen; Wang, Guanzhi; Dou, Yongqiang; Chen, Yanjun; Fei-Fei, Li; Anandkumar, Anima; Zhu, Yuke (2022-10-06). "VIMA: General Robot Manipulation with Multimodal Prompts". arXiv.org. Retrieved 2024-08-23.
  4. ^ Vaswani, Ashish; Shazeer, Noam; Parmar, Niki; Uszkoreit, Jakob; Jones, Llion; Gomez, Aidan N; Kaiser, Łukasz; Polosukhin, Illia (2017). "Attention is All you Need". Advances in Neural Information Processing Systems. 30. Curran Associates, Inc.
  5. ^ a b Zhang, Aston; Lipton, Zachary; Li, Mu; Smola, Alexander J. (2024). "11.9. Large-Scale Pretraining with Transformers". Dive into deep learning. Cambridge New York Port Melbourne New Delhi Singapore: Cambridge University Press. ISBN 978-1-009-38943-3.
  6. ^ a b "t5x/docs/models.md at main · google-research/t5x". GitHub. Retrieved 2024-08-05.
  7. ^ Lester, Brian; Al-Rfou, Rami; Constant, Noah (2021-09-02), The Power of Scale for Parameter-Efficient Prompt Tuning, doi:10.48550/arXiv.2104.08691, retrieved 2024-08-21
  8. ^ Fedus, William; Zoph, Barret; Shazeer, Noam (2022-06-16), Switch Transformers: Scaling to Trillion Parameter Models with Simple and Efficient Sparsity, doi:10.48550/arXiv.2101.03961, retrieved 2024-08-05
  9. ^ "SwitchTransformers". huggingface.co. Retrieved 2024-08-05.
  10. ^ Sanh, Victor; Webson, Albert; Raffel, Colin; Bach, Stephen H.; Sutawika, Lintang; Alyafeai, Zaid; Chaffin, Antoine; Stiegler, Arnaud; Scao, Teven Le (2022-03-17), Multitask Prompted Training Enables Zero-Shot Task Generalization, doi:10.48550/arXiv.2110.08207, retrieved 2024-08-05
  11. ^ "bigscience/T0 · Hugging Face". huggingface.co. 2024-03-04. Retrieved 2024-08-21.
  12. ^ Xue, Linting; Barua, Aditya; Constant, Noah; Al-Rfou, Rami; Narang, Sharan; Kale, Mihir; Roberts, Adam; Raffel, Colin (2022-03-25). "ByT5: Towards a Token-Free Future with Pre-trained Byte-to-Byte Models". Transactions of the Association for Computational Linguistics. 10: 291–306. doi:10.1162/tacl_a_00461. ISSN 2307-387X.
  13. ^ Chung, Hyung Won; Hou, Le; Longpre, Shayne; Zoph, Barret; Tay, Yi; Fedus, William; Li, Yunxuan; Wang, Xuezhi; Dehghani, Mostafa; Brahma, Siddhartha; Webson, Albert; Gu, Shixiang Shane; Dai, Zhuyun; Suzgun, Mirac; Chen, Xinyun (2024). "Scaling Instruction-Finetuned Language Models". Journal of Machine Learning Research. 25 (70): 1–53. ISSN 1533-7928.
  14. ^ Longpre, Shayne; Hou, Le; Vu, Tu; Webson, Albert; Chung, Hyung Won; Tay, Yi; Zhou, Denny; Le, Quoc V.; Zoph, Barret; Wei, Jason; Roberts, Adam (2023-07-03). "The Flan Collection: Designing Data and Methods for Effective Instruction Tuning". Proceedings of the 40th International Conference on Machine Learning. PMLR: 22631–22648.
  15. ^ a b google-research/FLAN, Google Research, 2024-08-03, retrieved 2024-08-05
  16. ^ "google/flan-t5-xl · Hugging Face". huggingface.co. 2024-01-04. Retrieved 2024-08-05.
  17. ^ Roberts, Adam; Chung, Hyung Won; Mishra, Gaurav; Levskaya, Anselm; Bradbury, James; Andor, Daniel; Narang, Sharan; Lester, Brian; Gaffney, Colin; Mohiuddin, Afroz; Hawthorne, Curtis; Lewkowycz, Aitor; Salcianu, Alex; Zee, Marc van; Austin, Jacob (2023). "Scaling Up Models and Data with t5x and seqio". Journal of Machine Learning Research. 24 (377): 1–8. ISSN 1533-7928.
  18. ^ a b Tay, Yi; Dehghani, Mostafa; Tran, Vinh Q.; Garcia, Xavier; Wei, Jason; Wang, Xuezhi; Chung, Hyung Won; Shakeri, Siamak; Bahri, Dara (2023-02-28), UL2: Unifying Language Learning Paradigms, doi:10.48550/arXiv.2205.05131, retrieved 2024-08-05
  19. ^ Sutawika, Lintang; Komatsuzaki, Aran; Raffel, Colin (2024-04-15). "Pile-T5". EleutherAI Blog. Retrieved 2024-05-05.
  20. ^ "Imagen: Text-to-Image Diffusion Models". imagen.research.google. Retrieved 2024-08-23.
  21. ^ "AuraFlow". huggingface.co. Retrieved 2024-08-23.