🚀 T5Gemma model card
T5Gemma is a lightweight yet powerful encoder - decoder research model from Google, suitable for various generative tasks and capable of being deployed in resource - limited environments.
🚀 Quick Start
This repository corresponds to T5Gemma (pretrained) with S encoder and S decoder (adapted using UL2). To quickly start using the model, follow these steps:
First, install the Transformers library:
pip install -U transformers
Basic Usage
import torch
from transformers import pipeline
pipe = pipeline(
"text2text-generation",
model="google/t5gemma-s-s-ul2",
device="cuda",
)
text = "Once upon a time,"
outputs = pipe(text, max_new_tokens=32)
response = outputs[0]["generated_text"]
print(response)
Advanced Usage
from transformers import AutoTokenizer, AutoModelForSeq2SeqLM
import torch
tokenizer = AutoTokenizer.from_pretrained("google/t5gemma-s-s-ul2")
model = AutoModelForSeq2SeqLM.from_pretrained(
"google/t5gemma-s-s-ul2",
device_map="auto",
)
input_text = "Write me a poem about Machine Learning. Answer:"
input_ids = tokenizer(input_text, return_tensors="pt").to("cuda")
outputs = model.generate(**input_ids, max_new_tokens=32)
print(tokenizer.decode(outputs[0]))
✨ Features
- Flexible Architecture: Allows pairing encoders and decoders of different sizes, such as a 9B encoder with a 2B decoder.
- Multiple Series: Released in Gemma 2 Series and T5 - compatible Series, covering a wide range of model sizes and architectures.
- Suitable for Various Tasks: Well - suited for generative tasks like question answering, summarization, and reasoning, and its encoders can be used for discriminative tasks.
- Resource - Friendly: Relatively small size enables deployment in resource - limited environments like laptops, desktops, or personal cloud infrastructure.
📦 Installation
To install the necessary library for using T5Gemma, run the following command:
pip install -U transformers
💻 Usage Examples
Inputs and outputs
- Input: A text string, such as a question, a prompt, or a document to be summarized.
- Output: Generated English - language text in response to the input, such as an answer to a question or a summary of a document.
Citation
@article{t5gemma_2025,
title={Encoder-Decoder Gemma: Improving the Quality-Efficiency Trade-Off via Adaptation},
author={Zhang, Biao and Moiseev, Fedor and Ainslie, Joshua and Suganthan, Paul and Ma, Min and Bhupatiraju, Surya and Lebron, Fede and Firat, Orhan and Joulin, Armand and Dong, Zhe},
year={2025}
}
📚 Documentation
Model Information
T5Gemma is a family of lightweight yet powerful encoder - decoder research models from Google. It is created by adapting pretrained decoder - only models into an encoder - decoder, inheriting the capabilities of decoder - only models while offering a better quality - efficiency trade - off.
It has two series:
- Gemma 2 Series: Models directly adapted from the official Gemma 2 2B and 9B checkpoints, including 2B - 2B, 9B - 9B, and 9B - 2B variants.
- T5 - compatible Series: Models pretrained from scratch using the Gemma 2 recipe, with architectures and parameter counts aligning with traditional T5 models (Small, Base, Large, XL), and an ML (Medium - Large, ~2B) model.
Model Data
Training Dataset
The models were trained on a diverse text dataset:
- Web Documents: Provide a wide range of linguistic styles, topics, and vocabulary, mainly in English.
- Code: Helps the model learn programming language syntax and patterns.
- Mathematics: Enables the model to learn logical reasoning and address mathematical queries.
Data Preprocessing
- CSAM Filtering: Rigorous filtering to exclude child sexual abuse material.
- Sensitive Data Filtering: Automated techniques to filter out personal and sensitive data.
- Additional Methods: Filtering based on content quality and safety according to Google's policies.
Implementation Information
Hardware
T5Gemma was trained using Tensor Processing Unit (TPU) hardware (TPUv4p, TPUv5p, and TPUv5e), which offers advantages in performance, memory, scalability, and cost - effectiveness.
Software
Training was done using JAX and ML Pathways, as described in the paper about the Gemini family of models.
Evaluation
Benchmark Results
The models were evaluated against a large collection of datasets and metrics for text generation. The following table shows the results:
Benchmark |
Metric |
2B - 2B |
9B - 2B |
9B - 9B |
S - S |
B - B |
L - L |
ML - ML |
XL - XL |
MMLU |
5 - shot, top - 1 |
46.8/50.4 |
60.3/64.8 |
71.3/72.1 |
24.7/25.2 |
24.8/25.7 |
27.3/27.5 |
27.3/29.1 |
34.8/36.6 |
HellaSwag |
10 - shot |
74.9/74.0 |
75.7/74.3 |
81.0/82.5 |
30.9/30.5 |
40.5/38.6 |
57.3/54.9 |
65.4/64.5 |
68.9/69.0 |
PIQA |
0 - shot |
79.0/78.8 |
78.3/78.2 |
81.1/82.4 |
62.8/61.5 |
67.0/66.2 |
71.2/70.9 |
74.3/75.5 |
76.2/78.0 |
BoolQ |
0 - shot |
75.6/77.5 |
84.6/85.1 |
85.6/87.0 |
53.1/61.1 |
52.3/49.6 |
62.2/62.3 |
62.6/61.7 |
69.9/68.0 |
WinoGrande |
partial score |
69.5/69.8 |
68.1/58.8 |
78.7/78.2 |
52.0/50.0 |
53.9/51.6 |
58.1/56.7 |
64.6/62.4 |
64.7/65.1 |
ARC - e |
0 - shot |
77.1/76.5 |
82.9/81.1 |
85.3/86.0 |
42.3/43.8 |
48.5/47.9 |
59.5/56.9 |
65.8/63.5 |
71.2/69.2 |
ARC - c |
25 - shot |
52.0/53.5 |
59.9/59.6 |
65.0/66.5 |
23.0/23.4 |
25.1/25.7 |
32.7/31.5 |
41.4/40.4 |
46.5/45.9 |
TriviaQA |
5 - shot |
51.2/51.1 |
66.2/58.3 |
75.2/73.3 |
3.2/3.3 |
7.2/5.9 |
19.4/15.9 |
33.2/25.4 |
41.0/34.3 |
Natural Questions |
5 - shot |
28.4/28.3 |
37.1/33.9 |
43.1/44.0 |
7.1/7.7 |
10.8/10.9 |
15.6/15.3 |
21.5/19.6 |
23.7/21.8 |
HumanEval |
pass@1 |
27.4/28.0 |
33.5/22.0 |
40.2/37.2 |
0.6/0.0 |
3.7/1.8 |
12.8/8.5 |
17.1/15.9 |
23.2/19.5 |
MBPP |
3 - shot |
37.4/36.4 |
43.4/38.6 |
55.6/55.2 |
1.4/0.0 |
4.6/3.4 |
15.0/11.8 |
27/24.6 |
30.0/28.0 |
GSM8K |
5 - shot, maj@1 |
41.7/35.8 |
48.7/39.7 |
72.8/74.0 |
2.0/0.8 |
2.2/1.5 |
6.6/4.1 |
13.7/17.5 |
25.8/22.4 |
MATH - 500 |
4 - shot |
24.2/20.4 |
23.6/18.4 |
37.8/39.2 |
1.0/1.2 |
1.8/2.4 |
5.0/4.8 |
11.0/12 |
15.6/12.4 |
AGIEval |
3 - 5 - shot |
35.0/37.0 |
43.6/45.7 |
53.1/56.4 |
20.8/21.4 |
21.8/21.3 |
22.5/23.0 |
23.4/24.5 |
28.0/27.4 |
BIG - Bench |
3 - shot, CoT |
51.9/50.5 |
51.6/52.1 |
74.7/76.3 |
24.7/22.7 |
23.0/24.8 |
29.9/31.3 |
37.3/35.9 |
44.5/43.1 |
Ethics and Safety
Evaluation Approach
The evaluation methods include structured evaluations and internal red - teaming testing of relevant content policies. Categories for evaluation include child safety, content safety, and representational harms.
Evaluation Results
Significant improvements were seen in child safety, content safety, and representational harms compared to previous Gemma models. All testing was conducted without safety filters, and the models produced minimal policy violations. However, the evaluations only included English - language prompts.
Usage and Limitations
Intended Usage
The models can be used for content creation, communication, research, and education, such as text generation and summarization, and NLP research.
Limitations
- Training Data: Quality and diversity of training data can affect the model's capabilities.
- Context and Task Complexity: Struggle with open - ended or highly complex tasks.
- Language Ambiguity and Nuance: Difficulty in understanding subtle nuances in natural language.
- Factual Accuracy: May generate incorrect or outdated factual statements.
- Common Sense: Lack the ability to apply common sense reasoning in some situations.
Ethical Considerations and Risks
- Bias and Fairness: Trained models may reflect socio - cultural biases, but pre - processing and evaluations were conducted.
- Misinformation and Misuse: Can be misused to generate false or harmful text, and guidelines for responsible use are provided.
- Transparency and Accountability: This model card provides details about the model, and the open model promotes innovation and accountability.
Benefits
At release, this family of models offers high - performance open encoder - decoder large language model implementations for Responsible AI development, outperforming similarly sized models in benchmark evaluations.
🔧 Technical Details
- Model Type: Encoder - decoder research model
- Training Data: A diverse dataset including web documents, code, and mathematics, with specific pre - processing steps.
- Hardware: Trained on Tensor Processing Units (TPUv4p, TPUv5p, and TPUv5e).
- Software: Trained using JAX and ML Pathways.
Property |
Details |
Model Type |
Encoder - decoder research model |
Training Data |
Diverse text dataset including web documents, code, and mathematics, with pre - processing like CSAM filtering, sensitive data filtering |
📄 License
The license for this model is Gemma. To access Gemma on Hugging Face, you’re required to review and agree to Google’s usage license. To do this, please ensure you’re logged in to Hugging Face and click below. Requests are processed immediately. Acknowledge license
⚠️ Important Note
This repository corresponds to T5Gemma (pretrained) with S encoder and S decoder (adapted using UL2).
💡 Usage Tip
When using the model, make sure to follow the responsible use guidelines provided in the Responsible Generative AI Toolkit.