par google
Open source · 998k downloads · 3 likes
T5Gemma est une famille de modèles légers et performants de type encodeur-décodeur développée par Google DeepMind, conçue pour allier efficacité et qualité. Adaptés à partir de modèles pré-entraînés en décodeur seul, ces modèles offrent une flexibilité remarquable en permettant d’associer des encodeurs et décodeurs de tailles différentes, comme un encodeur de 9 milliards de paramètres avec un décodeur de 2 milliards. Spécialisés dans les tâches textuelles en anglais, ils excellent aussi bien en génération (réponses à des questions, résumés, raisonnement) qu’en compréhension (classification, analyse de texte), tout en restant accessibles pour des déploiements sur des infrastructures modestes. Leur particularité réside dans leur double approche : certains modèles sont directement adaptés à partir de la série Gemma 2, tandis que d’autres, compatibles avec l’architecture T5, sont entraînés selon une recette similaire mais avec des tailles de paramètres alignées sur les standards T5 (Small à XL). Cette diversité permet de couvrir un large éventail d’usages, des applications locales sur ordinateur personnel aux solutions cloud, tout en favorisant l’innovation grâce à des poids ouverts et des variantes pré-entraînées ou affinées pour des instructions spécifiques.
[!Note] This repository corresponds to T5Gemma (pretrained) with S encoder and S decoder (adapted using PrefixLM)
Model Page: T5Gemma
Resources and Technical Documentation:
Terms of Use: Terms
Authors: Google DeepMind
Summary description and brief definition of inputs and outputs.
T5Gemma is a family of lightweight yet powerful encoder-decoder research models from Google. These models are created by adapting pretrained decoder-only models into a encoder-decoder. This adaptation allows T5Gemma to inherit the foundational capabilities of the decoder-only models while also offering a more favorable quality-efficiency trade-off. A key feature is the flexibility to pair encoders and decoders of different sizes(e.g., a 9B encoder with a 2B decoder).
T5Gemma is released in two different series:
These models are text-to-text, available in English, with open weights for pre-trained variants (adapted via objectives like PrefixLM or UL2) and instruction-tuned variants. T5Gemma models are well-suited for a variety of generative tasks, including question answering, summarization, and reasoning. Meanwhile, their encoders can be leveraged for discriminative tasks, providing strong performance on classification and understanding benchmarks. Their relatively small size makes it possible to deploy them in environments with limited resources such as laptops, desktops or your own cloud infrastructure, democratizing access to state of the art AI models and helping foster innovation for everyone.
Below we share some code snippets on how to get quickly started with running the model. First, install the Transformers library with:
pip install -U transformers
Then, copy the snippet from the section that is relevant for your usecase.
pipeline APIimport torch
from transformers import pipeline
pipe = pipeline(
"text2text-generation",
model="google/t5gemma-s-s-prefixlm",
device="cuda", # replace with "mps" to run on a Mac device
)
text = "Once upon a time,"
outputs = pipe(text, max_new_tokens=32)
response = outputs[0]["generated_text"]
print(response)
# pip install accelerate
from transformers import AutoTokenizer, AutoModelForSeq2SeqLM
import torch
tokenizer = AutoTokenizer.from_pretrained("google/t5gemma-s-s-prefixlm")
model = AutoModelForSeq2SeqLM.from_pretrained(
"google/t5gemma-s-s-prefixlm",
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]))
Input:
Output:
@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}
}
Data used for model training and how the data was processed.
These models were trained on a dataset of text data that includes a wide variety of sources. The 9B-9B, 9B-2B, and 2B-2B models were adapted with 2 trillion tokens, and the T5-sized models (Small, Base, Large, ML and XL) were first pretrained with 2 trillion tokens (decoder-only) and then adapted with 2 trillion tokens (encoder-decoder). Here are the key components:
The combination of these diverse data sources is crucial for training a powerful language model that can handle a wide variety of different tasks and text formats.
Here are the key data cleaning and filtering methods applied to the training data:
Details about the model internals.
T5Gemma was trained using Tensor Processing Unit (TPU) hardware (TPUv4p, TPUv5p and TPUv5e). Training large language models requires significant computational power. TPUs, designed specifically for matrix operations common in machine learning, offer several advantages in this domain:
Training was done using JAX and ML Pathways. JAX allows researchers to take advantage of the latest generation of hardware, including TPUs, for faster and more efficient training of large models. ML Pathways is Google's latest effort to build artificially intelligent systems capable of generalizing across multiple tasks. This is specially suitable for foundation models, including large language models like these ones.
Together, JAX and ML Pathways are used as described in the paper about the Gemini family of models; "the 'single controller' programming model of Jax and Pathways allows a single Python process to orchestrate the entire training run, dramatically simplifying the development workflow."
Model evaluation metrics and results.
These models were evaluated against a large collection of different datasets and metrics to cover different aspects of text generation.
PT models. XX/YY: results for PrefixLM/UL2 checkpoints.
| 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 and results.
Our evaluation methods include structured evaluations and internal red-teaming testing of relevant content policies. Red-teaming was conducted by a number of different teams, each with different goals and human evaluation metrics. These models were evaluated against a number of different categories relevant to ethics and safety, including:
In addition to development level evaluations, we conduct "assurance evaluations" which are our ‘arms-length' internal evaluations for responsibility governance decision making. They are conducted separately from the model development team, to inform decision making about release. High level findings are fed back to the model team, but prompt sets are held-out to prevent overfitting and preserve the results' ability to inform decision making. Assurance evaluation results are reported to our Responsibility & Safety Council as part of release review.
For all areas of safety testing, we saw major improvements in the categories of child safety, content safety, and representational harms relative to previous Gemma models. All testing was conducted without safety filters to evaluate the model capabilities and behaviors. For both text-to-text and image-to-text, and across all model sizes, the model produced minimal policy violations, and showed significant improvements over previous Gemma models' performance with respect to ungrounded inferences. A limitation of our evaluations was they included only English language prompts.
These models have certain limitations that users should be aware of.
Open large language models (LLMs) models have a wide range of applications across various industries and domains. The following list of potential uses is not comprehensive. The purpose of this list is to provide contextual information about the possible use-cases that the model creators considered as part of model training and development.
Content Creation and Communication
Research and Education
Training Data
Context and Task Complexity
Language Ambiguity and Nuance
Factual Accuracy
Common Sense
The development of large language models (LLMs) raises several ethical concerns. In creating an open model, we have carefully considered the following:
Bias and Fairness
Misinformation and Misuse
Transparency and Accountability:
Risks identified and mitigations:
At the time of release, this family of models provides high-performance open encoder-decoder large language model implementations designed from the ground up for Responsible AI development compared to similarly sized models.
Using the benchmark evaluation metrics described in this document, these models have shown to provide superior performance to other, comparably-sized open model alternatives.