Papers · 2025 to 2026 · Reading: 23 min, plus 3 in closed details.

Encoder-Decoder Gemma and T5Gemma 2 (T5Gemma)

Biao Zhang, Fedor Moiseev, Joshua Ainslie, Paul Suganthan, Min Ma, Surya Bhupatiraju, Fede Lebron, Orhan Firat, Armand Joulin, Zhe Dong (Google); for T5Gemma 2, Biao Zhang, Paul Suganthan, Gaël Liu, Ilya Philippov et al. (Google DeepMind, 20 authors)
April 2025 (arXiv v1, 8 April 2025); December 2025 (arXiv v1 16 December, v2 23 December 2025)

In one line: Adapts pretrained decoder-only Gemma checkpoints into encoder-decoder models by copying weights and continuing with UL2 or PrefixLM; adaptation beats pretraining from scratch on PT and IT scores from about 400M parameters up (scratch wins most scores at the two smallest sizes), and after instruction tuning 9B-9B beats Gemma 2 9B by 4.9 points and 2B-2B beats Gemma 2 2B by 7.1, single runs at similar inference FLOPs but about twice the parameters. T5Gemma 2 carries the recipe to Gemma 3 and, pretrained, scores 81.7 on RULER 32K at 4B-4B against Gemma 3 4B's 66.8, a lead that narrows to 5.9 at 128K and reverses there after post-training.

How far to trust it: Believe the recipe and its direction: copied decoder weights plus a bidirectional encoder match the source model after pretraining and beat it after tuning, at matched inference cost. Treat the size of the wins as single runs from models with about twice the parameters, and the long-context lead as real at 32K but narrowing by 128K. The evidence, judged.

+7.1 points
2B-2B over Gemma 2 2B after instruction tuning and RLHF
46.1 against 39.0 on the IT average; +1.8 before tuning · Table 2
1.05× the latency
of Gemma 2 2B for the 9B-2B on GSM8K
with 73.8 against 58.0 accuracy (decoded from the figure) · Figure 4
81.7 vs 66.8
RULER 32K, T5Gemma 2 4B-4B against Gemma 3 4B
pretrained at 16K; the gap narrows to 57.6 against 51.7 at 128K · T5Gemma 2 Table 4

Filed as one page rather than two because the second paper is the same recipe extended, and reading them separately would repeat the method twice.

The idea in one sentence: turn a pretrained decoder-only LLM into an encoder-decoder by copying its weights into both halves (the encoder only switches its attention mask from causal to bidirectional, and cross-attention is the one new part), then keep pretraining for up to 2T tokens: at about the same inference FLOPs, the adapted model is level with its source after pretraining and ahead after instruction tuning (2B-2B: 46.1 against Gemma 2 2B's 39.0), and a 9B encoder with a 2B decoder answers at the 2B model's latency.

You need: encoder-decoder, prefix LM and UL2 as families and objectives, from Families and objectives; logit distillation from Distillation and small language models.

  • Adaptation: initialising an encoder-decoder from a decoder-only checkpoint and continuing pretraining, instead of pretraining from scratch.
  • Balanced, unbalanced: encoder size, then decoder size; 2B-2B has both halves from Gemma 2 2B, 9B-2B a 9B encoder and a 2B decoder.
  • PT score, IT score: the papers' averages over 22 benchmarks for pretrained models and 10 for instruction-tuned ones.
  • Merged attention: T5Gemma 2's single decoder attention over its own tokens and the encoder output, with one softmax.

One decoder-only checkpoint fills both halves; only cross-attention is new

Gemma 2 2B, decoder-only

Embeddings
Self-attention, causal
Feed-forward

26 layers, 2.6B parameters

copy
weights
→↓

Encoder: a copy

Embeddings
Self-attention, bidirectional
Feed-forward

no new weights: only the mask changes; reads the input once

Decoder: a copy plus one part

Embeddings
Self-attention, causal
Cross-attention (new) reads the encoder output
Feed-forward

2B-2B: cross-attention starts from the self-attention weights; 9B-2B: random, trained alone for 1,000 steps first

Then: continue training on Gemma 2's data, up to 2T tokens, with PrefixLM plus distillation from the source model (or UL2); then the usual SFT and RLHF. T5Gemma 2 runs the same recipe on Gemma 3, with images fed to the encoder and the decoder's two attentions merged into one.

Redrawn from Figure 1 and §3 of the first paper (both papers are under arXiv's non-exclusive licence, so their figures are not reproduced). Mask icons: lower triangle causal, full square bidirectional. The same recipe, layer by layer on the real configurations, is Fig. 1 in Idea.

Problem

§1 Introduction

The decoder-only architecture won, but the argument was never settled on the merits (§2). An encoder-decoder (a bidirectional encoder that reads the input, with no autoregressive constraint on something you only read, and a causal decoder that writes the output and reads the encoder through cross-attention; the family is drawn on Families and objectives) also allows independent sizing of the two halves: a large encoder with a small decoder when understanding the input matters more than generating the output, as in summarisation, which "doesn't need to generate any new information" (§3.1).

The blocker was cost: nobody would pretrain a competitive encoder-decoder from scratch when strong decoder-only checkpoints already existed at every size. So the question is narrower and more useful:

The question: can you adapt an existing decoder-only checkpoint into an encoder-decoder, cheaply, and end up ahead (§1)?

Idea: copy the decoder into both halves

§3, Figure 1, Table 1

Architecture (§3.1). As close to the source model as possible, so initialisation is mostly a copy. The encoder is the decoder-only model with self-attention switched from causal to bidirectional. Each decoder block keeps its feed-forward network and self-attention and adds a cross-attention with the same heads and head size, attending to the whole encoder output. Testbed: Gemma 2 2B and 9B, plus four small decoder-only models pretrained in mT5 sizes, S, B, L and XL (Table 1).

Initialisation (§3.2). The encoder is fully initialised from the checkpoint, since it introduces no new weights; the decoder's feed-forward and self-attention come from the corresponding layers. Cross-attention is the only genuinely new part:

  • Balanced (encoder and decoder share a configuration, 2B-2B): cross-attention is initialised from the self-attention weights.
  • Unbalanced (9B encoder, 2B decoder): the shapes differ, so cross-attention starts random and trains alone for a warmup of K = 1,000 steps with everything else frozen (§4). The warmup is sensitive: none costs 0.7 points and 5,000 steps cost 2.3 (§6).

Fig. 1 runs the recipe on the real checkpoints' configurations: one slab per layer (26 in Gemma 2 2B, 42 in 9B, 18 in Gemma 3 270M), each split into self-attention (blue), cross-attention (purple; orange while random) and feed-forward (green), widths to scale by the layer's parameters within each mode; embedding tables are the yellow bases. The mask plate on each stack is its attention mask: lower triangle causal, full square bidirectional. The T5Gemma 2 mode adds the two parameter-saving changes described further down.

  1. The checkpoint. Gemma 2 2B, a decoder-only model: one causal stack of 26 blocks and an embedding table that is also its softmax. Its 2.61B parameters (2.02B outside the embedding) are all the knowledge the encoder-decoder will start from.
  2. Encoder: a full copy, with the mask opened. Every encoder weight is copied from the checkpoint, so the encoder adds no new weights. The only change is the attention mask: causal (each token sees the ones before it) becomes bidirectional (every token sees every token). Nothing is retrained yet.
  3. Decoder: self-attention and feed-forward copied. The decoder is the checkpoint again, layer for layer, still causal. Its embedding stays tied to its softmax, as in Gemma 2; the encoder has its own copy of the table, so the model now holds two.
  4. Cross-attention: initialised from self-attention. Each decoder block gains a cross-attention with the same heads and head size, reading the whole encoder output. In a balanced model the shapes match, so it starts as a copy of that block's self-attention: 368M parameters, 26 × 14.2M. This is the part the paper's Table 1 leaves out of its 4.0B.
  5. Adapt: train everything. All 5.60B parameters are trained on up to 2T tokens of the Gemma 2 mixture, with PrefixLM plus distillation (or UL2), then instruction-tuned with the Gemma 2 recipe; the encoder's output now flows into every decoder block. The released 2B-2B has 5,596.9M parameters; the recount gives 5,596.7M.

Counts recomputed from the configs; they match Hugging Face's counts of the released T5Gemma checkpoints to 0.01%, and of T5Gemma 2 to 0.1% (its vision encoder taken as the paper's 417M) (the recount). The embedding tables and the vision encoder are drawn at a fixed size, not to scale.

One thing the paper's own size table leaves out
Table 1 gives 4.0B (2B-2B), 16.7B (9B-9B) and 10.4B (9B-2B) non-embedding parameters: encoder plus decoder without cross-attention. With it, the released checkpoints have 4.42B, 18.50B and 10.78B; cross-attention adds 0.37B, 1.85B and 0.44B. T5Gemma 2's Table 1 uses the full count (4,417M for 2B-2B, T5Gemma 2 Table 1).

Objectives and setup

§3.3, §4

An encoder-decoder needs an input and a separate target. Two classical objectives are compared, and they do not agree (§3.3):

  • PrefixLM: split each sequence in half and predict the second half from the first. Here with knowledge distillation from the Gemma 2 teacher, whose logits came with Gemma 2's pretraining data (§4).
  • UL2 (Tay et al. 2022): a mixture of span-corruption denoisers and prefix LM, each flagged by a mode token (taught on Families and objectives; T5's span corruption is animated on the T5 page). Used here without distillation: mapping teacher logits onto corrupted spans is "non-trivial".

Data. The Gemma 2 pretraining mixture (8T tokens) cut into 4096-4096 input-target pairs for PrefixLM and 8192-8192 for UL2; adaptation runs on up to 2T tokens. SFT and RLHF follow Gemma 2's recipe, with the learning rate retuned (§4).

Evaluation, three scores: a PT score averaged over 22 benchmarks for pretrained models, an IT score over 10 for instruction-tuned ones, and SuperGLUE, fine-tuned with a classification head on the last token of the encoder (of the decoder, for decoder-only), as the test of "contextual representations". Generation is greedy throughout (§4).

The benchmarks in each score

PT: BoolQ, SIQA, PIQA, ARC-c and ARC-e, MMLU, MMLU Pro, HellaSwag, Winogrande, TruthfulQA, AGIEval, BBH, DROP, GPQA, GSM8K, HumanEval, Lambada, MATH-500, MBPP, NQ, TriviaQA, WMT23, zero- or few-shot. IT: GSM8K, MMLU, MMLU Pro, MBPP, HumanEval, MATH-500, BBH, GPQA Diamond, WMT23, MGSM, with task instructions. SuperGLUE: COPA, WiC, WSC, RTE, MultiRC, CB and BoolQ as classification, dev-set accuracy, with learning rate, batch size and dropout grid-searched per task.

Results

§5, Table 2, Figures 2 to 4

Adaptation converges fast. Balanced models come close to their source's PT score "after only tens of billions of tokens"; 9B-2B is slower, since its cross-attention starts random, but climbs past Gemma 2 2B towards 9B (Figure 2). Decoded from the figure: at 42B tokens 2B-2B is 1.3 points short of Gemma 2 2B, and it passes it at about B (9B-9B passes 9B at about B; curves). More tokens help some tasks a lot, such as GSM8K and DROP (§5).

The objective choice splits by what you want. UL2 gives better representations and wins SuperGLUE at most scales (11 of 14 pairs, Table 2(b)); PrefixLM with distillation gives better generative models and wins most PT and IT pairs (9 of 14), by up to 3.6 points at 9B-2B. The rest of the paper uses PrefixLM. There is no free combination: merging the two checkpoints gave similar or much worse models, and switching objectives for the last 10% of training gave mixed results (Figure 5).

The gain arrives after instruction tuning, not before. Adapted models are comparable or slightly better than their decoder-only counterparts after pretraining, and substantially better after instruction tuning (Table 2):

PairPT: Gemma 2 → adaptedgainIT after RLHF: Gemma 2 → adaptedgain
9B-9B against Gemma 2 9B61.7 → 63.1+1.459.6 → 64.5+4.9
2B-2B against Gemma 2 2B47.9 → 49.7+1.839.0 → 46.1+7.1
XL-XL against XL (SFT)39.7 → 39.5−0.223.5 → 30.7+7.2

IT compares RLHF models (the adapted SFT models lead by 3.3 and 7.4). Below 2B the adapted models trail on PT by 0.2 to 0.7 (S-S, L-L, XL-XL; B-B is +0.2) while still gaining on IT (§5).

Not every task moves the same way. After pretraining Gemma 2 9B wins 8 of 17 tasks against 9B-9B, mostly knowledge recall (ARC-C by 4.1, while losing Winogrande by 4.4); after RLHF the encoder-decoder wins 10 of 11, trailing only on WMT23, by 0.9 (Table 3, per task).

Encoder-decoder wins SuperGLUE everywhere: all 24 comparisons in Table 2(b) (six sizes, both objectives, pretrained and tuned), by at least 1.2 points, which the paper attributes, "likely", to bidirectional self-attention.

Our cost model, illustrative: at batch size 1 each generated token streams the decoder's weights (with cross-attention and softmax) from memory once, bytes / bandwidth; reading the prompt costs 2 × parameters × tokens FLOPs at peak. Hardware: one TPU v5e, 819 GB/s and 197 bf16 TFLOP/s (Google Cloud); the paper does not name its hardware, and KV-cache reads and overheads are left out, so compare ratios. Measured points: Figure 4, decoded.

Latency: a 9B encoder at 2B speed

§5, Figures 3 and 4

The asymmetric result is the one to remember. At matched inference FLOPs the encoder-decoders sit on the quality-efficiency frontier (Figure 3); since FLOPs are not latency, the paper also timed GSM8K queries at batch size 1 (Figure 4).

the 9B-2B has a 9B encoder in front of a 2B decoder. Answering a GSM8K question, how does its latency compare with Gemma 2 2B's?

The animation answers one question with each model, step by step; the sliders set the prompt and answer lengths, and the bars under it compare all four models with the paper's measured latencies.

  1. Read the prompt. The encoder reads all prompt tokens at once, in parallel, with bidirectional attention. This pass is limited by compute, not memory: encoder parameters × 2 FLOPs × prompt tokens. The cross-attention keys and values are computed here too, once.
  2. Generate token 1. Now only the decoder runs: its weights, its cross-attention and the softmax are streamed from memory to produce one token. The encoder (9B in the 9B-2B) is not touched again.
  3. Generate token 2. Same again: one full pass of the decoder per token. Cost grows with the answer's length times the decoder size.
  4. Generate token 3. The decoder keeps attending to the same encoder output through cross-attention; the prompt is never re-read.
  5. Every token, to the end of the answer. Total = prompt pass + answer tokens × per-token time. What you pay per token is the decoder's size, so the 9B-2B runs close to a 2B and far from a 9B (the bars under the animation).

The model gets the shape (9B-2B near 2B, far from 9B) but not every detail: measured, 2B-2B is faster than Gemma 2 2B ( against ms), which a per-token cost cannot explain; answer lengths, which the paper does not report, may differ.

Ablations: the likely objections

§6 Discussion, Table 4
is the gain just extra training? Gemma 2 2B (PT 47.9) is trained for another 6 trillion tokens as a decoder-only model. Where does its PT score land, against the adapted 2B-2B's 49.7?
  • Bidirectional encoder attention matters. A causal 2B-2B encoder scores 45.6 PT and 41.7 IT, 4.1 and 4.7 points below the bidirectional one, yet still beats Gemma 2 2B on IT by 2.7: bidirectionality "contributes greatly" but "is not the only factor" (§6; in the toy the bidirectional encoder also learns faster, 90% at step 275 against 450).
  • Warmup matters for the unbalanced model. Preliminary 9B-2B runs (UL2, 800B tokens, BoolQ and GSM8K only): 62.5 with 1K warmup steps, 61.8 with none, 60.2 with 5K.
  • Adaptation against pretraining from scratch on 8T tokens (Table 4): scratch wins everything at S-S (29M non-embedding parameters) and PT and SuperGLUE at B-B (113M); adaptation wins PT and IT from L-L (409M) up and all three only at XL-XL (1.6B) and 2B-2B. So the old summary's "better above roughly 100M" is too generous.
Two more findings from §6
  • Multi-head attention in the encoder: mixed. The encoder runs in parallel, so Gemma 2's grouped-query attention is no longer needed there; expanding it to full multi-head by replicating heads raised 2B-2B's PT by 0.5 (to 50.2) but cut IT by 2.9 (to 43.5), so GQA stays (§6).
  • Does the PT score predict the tuned score? Across all ablations and sizes, yes (Spearman ρ 0.97 for IT and 0.89 for SuperGLUE); within one size, no (averaged ρ 0.42 and 0.05, not significant). Weaker PT checkpoints sometimes tune better, so pick checkpoints on IT too (Figure 6).

T5Gemma 2: the recipe on Gemma 3, with images and 128K

T5Gemma 2: §1, §2, Table 1

T5Gemma 2 repeats the adaptation on Gemma 3 (270M, 1B, 4B) with UL2 and drops distillation: UL2 with and without it were within 0.4 points, not worth the data-loading overhead (§1, Table 3). The block is Gemma 3's (GQA with QK-norm, RMSNorm, RoPE, local and global layers 5:1). It adds three things and tests a fourth, merged attention, which ships and has its own section below (§2):

  • Images. Gemma 3's frozen 400M SigLIP encoder turns an image into 256 tokens, always fed to the encoder, so vision inherits bidirectional visibility for free (Figure 2).
  • Long context by positional interpolation: pretrained at most 16K long, evaluated to 128K.
  • Tied word embeddings across encoder input, decoder input and decoder softmax, a return to T5's choice (the first T5Gemma had separate tables). On the 2B-2B ablation: "nearly no quality change" (47.8 to 47.7) for 10.5% fewer parameters (Table 1; recount 10.54%).

One rejected variant: cross-attention only on global-attention layers cost 1.3 points (Table 1).

The rejected global-layers variant, recounted

The paper describes it as "one cross-attention sub-layer every six decoder layers", an obvious saving. The recount says it was not one in six: its 4,233M parameters are exactly the baseline minus cross-attention on 13 of Gemma 2 2B's 26 layers, Gemma 2's one-in-two pattern (one in six would be 4,106M). All four ablations ran on Gemma 2 2B with PrefixLM and distillation for 400B tokens, not on the shipped Gemma 3 and UL2 setup.

Sizes, training setup, and why distillation was dropped

Sizes (Table 2). With merged attention the decoder has exactly the encoder's weights, so each model is two copies of a Gemma 3 stack, one shared embedding and the vision encoder: 270M-270M is 417M + 168M + 100M + 100M, 1B-1B is 417M + 302M + 2 × 698M, 4B-4B is 417M + 675M + 2 × 3,209M. Recounted from Gemma 3's configs and checked against the released weights (786.0M, 2,116.0M and 7,508.9M parameters on Hugging Face).

Setup (§3). Gemma 3's pretraining mixture (multilingual web, code, maths, images), turned into UL2 data of at most 16K input and 16K target tokens with five denoisers mixed 1:1:1:1:4: mean span 3 at 15% corruption, 12 at 50%, 32 at 15%, 32 at 50%, and one long prefix-style task (span three quarters of the input, 75% corrupted, one span). Image data uses prefix LM only (everything up to the last image is input). About 2T tokens, batch 4.2M tokens, cosine learning rate with 100 warmup steps, gradient clipping at 1.0, weight decay, a learning-rate grid search per size, and the final checkpoint averaged over the last five (saved 10K steps apart). Post-training is "slight": distillation only, "much less compute" than Gemma 3's, no RL, so its results are a lower bound.

Why distillation was dropped (Table 3). PrefixLM with distillation was the worst of three at both 270M and 1B; UL2 and UL2 with distillation were within 0.4 points (1B-1B: 40.2 with, 39.8 without; 270M-270M: 30.5 and 30.6). With the first paper's mixed results, the authors conclude that distillation's value depends on teacher and student capacity, and drop it for its "expensive data loading overhead".

Merged attention: one softmax over both

T5Gemma 2: §2, Equations 1 to 5

Merged attention: one module with shared weights does the decoder's self- and cross-attention at once, over the encoder output concatenated onto the decoder's input, with one softmax. It saves 6.5% of parameters for about 0.3 points (recount: 368.1M, 6.58%) and makes the decoder a Gemma 3 decoder again, which eases initialisation.

Q = X Wq   K = [X; H] Wk   V = [X; H] Wv
A = softmax(QK⊤/√dh ⊙ M) V   O = A Wo
Equations 1 to 5 (T5Gemma 2 §2): X is the decoder's input, H the encoder's output, and the mask M is causal over decoder tokens and open over encoder tokens; "attention logits are also normalized jointly". In the Transformers code the cross part of the mask is never windowed and encoder keys get no rotary position (modeling_t5gemma2.py).
in merged attention, decoder token 3 can see its 3 decoder tokens and 6 encoder tokens. How much attention weight, in total, can the encoder tokens receive?
  1. Two kinds of input. The decoder's own tokens X (4 here, each with a query and a key) and the encoder's output H (6 tokens: keys and values). Each vector is drawn as signed bars on a plinth; the plate on the floor is the mask, one row per decoder query, one column per key.
  2. Separate, first: self-attention. In a standard decoder block (the first T5Gemma), decoder token 3's query scores only the decoder keys up to its own position (causal: the dark cells are masked) and normalises them with its own softmax, which sums to 1.
  3. Separate: cross-attention, a second softmax. A second sub-layer scores the same query against all 6 encoder keys with its own softmax, which also sums to 1. The two outputs are added through two residual branches, so the encoder always gets a full share.
  4. Merge: one key set [X; H] and one mask. T5Gemma 2 concatenates the encoder output onto the decoder's input and runs one module with shared weights: the two plates close into one mask M, causal over the decoder keys and open over the encoder keys.
  5. One softmax over all 9 visible keys. The bars rescale into a single distribution: decoder and encoder keys now compete, and the encoder's total can be anything between 0 and 1. With this page's seeded weights, row 3 and relevance 0, it is 7.7%, against a full 1 in the separate block.
  6. One output. Every visible value streams into the output z in proportion to its weight: one attention instead of two, with no cross-attention weights. The cosine compares it with the separate block's output on the same weights.

Fig. 2 follows the widget in the answer above: change its row, the encoder relevance or the weights and the stage redraws with them. Illustrative inputs; the equations are the paper's.

T5Gemma 2 results: long context, images, tuning

T5Gemma 2: §4, Tables 4 and 5

Long context is the strongest single result in the line (Table 4). Pretrained, T5Gemma 2 4B-4B scores 81.7 on RULER 32K against Gemma 3 4B's 66.8, and 57.6 against 51.7 at 128K; 270M-270M scores 57.3 against Gemma 3 270M's 21.3, though pretrained only at 16K. The first T5Gemma (Gemma 2, 8K context) scores about 0.

at 4B, T5Gemma 2 leads Gemma 3 by 14.9 points on RULER at 32K. At 128K, the lead is

The authors' explanation: encoder parameters are spent only on reading the input, bidirectionally, and cross-attention attends to "high-level representations of the input" (§4).

Text-only models become multimodal. Gemma 3 270M and 1B are text-only, yet with SigLIP in front of the encoder they score 35.1 and 49.8 on the multimodal average; the 1B-1B trails Gemma 3 4B by only 8.7 points (6.9 on long context) "despite being much smaller" (§4). Much smaller means about half, 2.12B parameters against 4.30B, not the old summary's "a quarter".

Pretrained, comparable; post-trained, ahead. Per capability, T5Gemma 2 minus Gemma 3 at the same size, in the chart beside this section.

Pretrained, the two small models clearly beat their sources and 4B-4B is on par (−1.6 on reasoning, +0.4 to +6.4 elsewhere); after the light post-training T5Gemma 2 leads in every category (§4). EmbeddingGemma comes from this line: its paper adapts a 300M Gemma 3 with the T5Gemma recipe and UL2 and initialises from that encoder (EmbeddingGemma §2); the T5Gemma 2 paper calls it a user of its checkpoints (§5).

Post-trained, T5Gemma 2 leads in every category; pretrained, the 4B-4B is on par

Category averages from Table 4 and Table 5; Gemma 3 has multimodal scores only at 4B. Each T5Gemma 2 holds two copies of its source plus the vision encoder: times the parameters (text weights alone ).

How much of this to believe

What holds up.

  • Breadth and consistency. 22 pretraining and 10 tuned benchmarks, seven sizes, two objectives, two model families, and the direction holds almost everywhere: SuperGLUE in all 24 comparisons, IT gains at every size. The decoded figures agree with the tables to the printed decimal.
  • The obvious confounds were tested (extra compute, causal encoder, scratch, warmup), and the authors state limits themselves: FLOPs "may not correlate well with actual running speed", benchmark choice can mislead, PT scores do not predict tuned scores within a size, T5Gemma 2's post-training is a lower bound. That counts in their favour.
  • Released weights for every size; the parameter counts reproduce from the configs to 0.1%.

What is weaker.

  • Not like for like on parameters. Matched inference FLOPs, not size: 2B-2B has 5.6B parameters against Gemma 2 2B's 2.6B, T5Gemma 2 4B-4B 7.5B against Gemma 3 4B's 4.3B. Some of the gain may be capacity.
  • Single runs, no error bars, and several deciding margins are small: merged attention 0.3, UL2 with or without distillation 0.4, warmup 0.7, objective switching ±1.4 (Figure 5).
  • The controls cover less than the headlines. The extra-compute control is one 2B run on PT only, while the headline gain is on IT; the warmup test is preliminary (UL2, not the PrefixLM recipe; two tasks).
  • "Cheaper than scratch" counts only the adaptation, fair when a checkpoint already exists (the premise); scratch gets 8T tokens, adapted models up to 2T on top of their own pretraining, and scratch still wins at the two smallest sizes.
  • Tables that say less than the text. The first paper's sizes omit cross-attention (1.85B at 9B-9B); T5Gemma 2's ablations ran on Gemma 2 with PrefixLM, not the shipped models, and its global-layers count matches every second layer, not "every six".
  • Long context: large at 32K, but the lead shrinks with length, reverses at RULER 128K after post-training, the small baselines run at or past their 32K windows, and only two benchmarks are used.
  • Few-shot prompting is not tested: every IT result is after tuning, so the in-context ability that made the field choose decoder-only (GPT-3) gets no comparison.
Verdict
Believe the recipe and its direction: copied decoder weights plus a bidirectional encoder match the source model after pretraining and beat it after tuning, at matched inference cost, and the 9B-2B's latency result is measured, not estimated. Treat the size of the wins as single runs from models with about twice the parameters, and the long-context lead as real at 32K but narrowing by 128K.

What it takes to use this

  • Weights. First generation released 9 July 2025: S, B, L, ML, XL, 2B-2B, 9B-2B and 9B-9B, each in PrefixLM and UL2 versions, pretrained and instruction-tuned (collection, blog). T5Gemma 2: 270M-270M, 1B-1B and 4B-4B, pretrained only, announced 18 December 2025 (blog). All under the Gemma terms of use, behind a licence click-through on Hugging Face.
  • Code. Inference and fine-tuning in Transformers (T5Gemma, T5Gemma 2). The adaptation code was never released (the paper's "code and checkpoints at XXX (coming soon)" became checkpoints only), so adapting another family means reimplementing the weight mapping, the warmup and the UL2 preprocessing.
  • Budget. Up to 2T tokens; for T5Gemma 2, 2T tokens at 4.2M per batch is about 476,000 steps (derived), on TPU v4p, v5p and v5e (model card). Figure 2 suggests balanced models pass their source within about 125 to 200B tokens.
  • What worked. Balanced pairs from XL (1.6B non-embedding) up, and 9B-2B for long input and short output; at 113M and below scratch beat adaptation on most scores. PrefixLM with distillation for generation, UL2 for representations (UL2 for everything in T5Gemma 2).
  • When it pays off: long inputs and short outputs (summarisation, extraction, classification, retrieval and reranking, document QA), fine-tuning rather than prompting, encoder embeddings, images in the input. When it buys little: long generations, where the decoder dominates, and few-shot prompting, which neither paper measures.

Why it matters (beyond the papers)

It is the first serious modern test of the architecture question T5 originally answered. T5 measured encoder-decoder above decoder-only in 2019 (T5) and the field went decoder-only anyway, for few-shot prompting at scale. This line redoes the measurement at 2025 scale and the answer holds, with the honest qualification that the advantage concentrates in fine-tuned and long-context settings rather than raw pretraining scores.

Adaptation makes the architecture question cheap to ask: no from-scratch budget is needed to try an encoder-decoder, which is why this could change what people build. The recipe is not Gemma-specific; the authors name LLaMA, Qwen and DeepSeek, and note that "in theory" models from different families could be paired (§3.1).

Asymmetric sizing is the underexploited idea. A large encoder with a small decoder is the right shape wherever the input is long and the output short (extractive and retrieval-augmented QA, classification, routing, reranking), and a decoder-only model structurally cannot offer it. The 9B-2B is a proof of concept; the paper lists more unbalanced setups, 27B, other families and dense with MoE pairings as future work (§7), and T5Gemma 2 released only balanced models.

Long context is where the architecture earns its keep, at least at 32K: encoder parameters are spent only on reading, and cross-attention retrieves from a high-level representation instead of re-scanning raw tokens, the same intuition as the latent-context compression line (Latent Context Language Models) from the other direction.

Downstream, the encoder half is reused for what encoders are good at. EmbeddingGemma (about 300M parameters) starts from a T5Gemma-adapted encoder (EmbeddingGemma).

Later, as of 25 October 2026
  • EmbeddingGemma reported itself first on the MTEB multilingual, English and code leaderboards among models under 500M parameters as of 23 September 2025 (its paper); leaderboard positions move, so check MTEB for today's order.
  • Google's T5Gemma 2 checkpoints on Hugging Face are still the three balanced, pretrained ones (270M-270M, 1B-1B, 4B-4B): no unbalanced Gemma 3 pair and no tuned T5Gemma 2 (Hub listing of google/t5gemma-2, checked 25 October 2026; models).

Connections

  • T5 (2019): the original claim being retested, the span corruption that UL2 extends, and the source of the tied embeddings T5Gemma 2 returns to.
  • Seq vs Seq (Ettin) (2025): the compute-matched encoder against decoder comparison from the representation-learning side; T5Gemma is the same question from the generation side.
  • Bitune (2024): the other route to bidirectional prompt processing, a bidirectional pass inside a decoder-only model instead of splitting the model in two.
  • Latent Context Language Models (2026): the complementary answer for long inputs, compressing the context into latents for a decoder rather than restructuring the model around an encoder.
  • GPT-3 (2020): the reason the field went the other way, and the capability neither T5Gemma paper tests.
  • Lab page: Google DeepMind: Gemini and Gemma, where T5Gemma sits in the Gemma family. Topics: llms (the Gemma family and the encoder-decoder lineage), llm-training-and-post-training (UL2, adaptation, PrefixLM plus distillation), rag-and-retrieval (EmbeddingGemma downstream).