AI State of the Art
SOTA/Multimodal AI/22 min
Section 173

Gemma 4: How Many Tokens Is an Image Worth?

Listen as a podcast →

The problem: the image has to fit inside a square

A vision-language model cuts the image into small squares (patches) turns each into a vector, and slides those vectors into the language model's sequence as though they were words. The full mechanism is described in Vision-Language Models.

One question that mechanism leaves unanswered: what size should the image be when it goes in? Almost every visual encoder gave the same answer, a single size, fixed once and for all, and square. Gemma 3, Google's previous generation, states it plainly in its model card: images are "normalized to 896 x 896 resolution and encoded to 256 tokens each".

One size, one price. That is simple, and that is the problem.

Take three ordinary documents:

What you hand itWhat the model receivesWhat happens
A photo of a cat, 1000 × 1000896 × 896no harm done, a little sharpness lost
A screenshot, 1920 × 1080896 × 896the image is crushed into a square: everything is horizontally distorted
A scanned A4 contract, 2480 × 3508896 × 896the characters drop below the legibility threshold

And the price is the same in all three cases: 256 tokens. The cat photo pays too much for what it contains; the scanned contract pays far too little for what is asked of it.

Gemma 3's patch: Pan & Scan

Google had already seen the problem and worked around it at inference time. The technique is called Pan & Scan, the cinema term for recropping a widescreen film onto a squarer screen. When the image is too large or too elongated, it is cut into pieces, and each piece goes through the encoder separately, at 896 × 896, for 256 tokens.

It works, in both senses. Legibility recovers. But each piece costs another 256 tokens, the encoder runs several times over the same image, and above all the model never sees the whole image at once: it sees thumbnails and has to mentally reassemble what was cut. A table straddling two crops is a table lost.

Gemma 4's idea: stop fixing the size, fix the budget

Gemma 4 is the generation released by Google DeepMind in July 2026: open-weight, natively multimodal models from 2.3 to 31 billion parameters, in dense and mixture-of-experts variants.

The change that interests us is a reversal. Where the previous generation asked "what size should I resize this image to?", Gemma 4 asks:

"How many tokens is this image allowed to consume?"

And the user answers, per call, from five values:

Nmax⁡∈{70,  140,  280,  560,  1120}N_{\max} \in \{70,\; 140,\; 280,\; 560,\; 1120\}

The technical report calls them soft tokens: the vectors that will come out of the visual side and take up places in the language model's sequence. Once that budget is given, the model works out the resize dimensions itself, while keeping the image's proportions.

The reversal, in one line

Before: the image size is imposed, the price follows and is always the same. Now: the price is chosen, the size follows, and the aspect ratio is preserved either way.

Gemma Team, Google DeepMind (2026), Gemma 4 Technical Report

From a budget to an image size

This is what Algorithm 1 of the report does, soberly titled Aspect-Ratio Preserving Image Resizing. It comes down to three ideas.

1. The grid, and its 48-pixel mesh

The visual encoder is a Vision Transformer (ViT) with 16 × 16 pixel patches. But those patches do not travel to the language model as they are: they are first grouped three by three, into 3 × 3 squares whose vectors are merged into one. This is pooling.

The consequence: the real billing unit is not the 16-pixel patch, but the block of

3×16=48 pixels a side3 \times 16 = 48 \text{ pixels a side}

One soft token = one 48 × 48 pixel square of the resized image. Everything else follows from that.

2. Scale up as far as the budget allows

The algorithm looks for the largest scaling factor such that the number of 48-pixel blocks stays within budget, then rounds both sides down to multiples of 48. The original width-to-height ratio is preserved.

A back-of-the-envelope calculation, to make the numbers tangible (this is an illustration, not a table from the report):

Budget requestedSquare image16:9 imageWhat it allows
70 tokens≈ 384 × 384 px≈ 528 × 288 pxrecognising a scene, captioning a photo
280 tokens≈ 768 × 768 px≈ 1056 × 576 pxthe setting used in the report's results tables
1120 tokens≈ 1584 × 1584 px≈ 2112 × 1200 pxreading a document, spotting a small object

The maximum budget is sixteen times the minimum in tokens, so, at equal area, four times the definition in each direction.

3. Patches know where they are

A technical detail, but the one that makes the rest possible. If an image can have any proportions, the patch grid changes shape from one image to the next: 8 × 8 here, 44 × 25 there. Under those conditions you cannot number patches 1, 2, 3… and learn one position per number: patch no. 20 is not in the same place depending on whether the grid is square or elongated.

So Gemma 4 gives each patch its (row, column) coordinates rather than a rank in a queue. Technically, the encoder combines axial 2D-RoPE (the same vector-rotation machinery as for text, but applied separately to height and width) with two-dimensional absolute positions. All of it with non-causal attention: unlike text, where each token sees only what precedes it, each patch of an image sees every other one. An image has no reading order.

Not an isolated invention

Native resolution with 16-pixel patches and two-dimensional positions did not originate at Google: Pixtral, at Mistral, made that choice back in 2024, with an encoder trained from scratch for it, see Pixtral. What Gemma 4 adds is the per-call adjustable budget, which remains uncommon among open-weight models.

The odd one out: the 12B model, which has no encoder at all

The report's second move deserves a mention, because it is more radical and it sheds light on the first.

Across the lineup, each model carries a visual encoder: 150 million parameters for the small ones (E2B, E4B), 550 million for the large ones. Except one. The unified 12B model has no visual encoder. It has no audio encoder either. Instead:

  • the image is cut into 48 × 48 pixel colour patches;
  • each is flattened into a list of numbers and passed through a single matrix multiplication, of 35 million parameters;
  • the result goes straight into the language model, with its two-dimensional coordinates.

No Vision Transformer. No pre-trained visual model to graft on. A linear projection, and the language decoder does all the visual work itself.

The coincidence that isn't one

48 × 48 pixels: that is exactly the mesh of the classic path, 3 × 3 patches of 16 pixels after pooling.

In other words, the question the 12B model asks is: once we accept that the useful unit is the 48-pixel block, is the visual encoder in between still earning its keep? Its answer is that a plain matrix product of 35 million parameters replaces 550 million parameters of ViT. It is the movement described in Unified Multimodal Models, pushed to its conclusion.

What it changes in practice

The price of an image becomes a parameter, not a fate. Inside a context window, the same image at 70 tokens and at 1120 tokens do not weigh the same, a factor of sixteen. Since attention cost grows with the square of sequence length, the real difference is larger still. You can now serve the same application with a low budget for sorting photos and a high budget for reading a contract, without switching models.

A scanned document is no longer mutilated on the way in. This is the most direct gain for anything touching OCR and document understanding: a portrait A4 stays portrait, and at 1120 tokens it arrives at a definition that keeps characters legible, in a single view rather than in reassembled pieces.

The setting becomes a choice you have to own. That is the flip side. A budget is a call parameter: a badly chosen default silently degrades quality without raising a single error. The report itself publishes its vision results at two different settings, 280 tokens for the general table, 1120 for the detailed one. Comparing two models without saying at which budget they were measured no longer means much.

The point to retain

Three practical consequences.

On billing. Providers charge per token. A model where an image costs 256 tokens no matter what is simple to contract for. A model where it costs between 70 and 1120 depending on a call parameter requires the budget in use to appear somewhere, in the price list, in the order form, or at minimum in the technical documentation annexed to it.

On quality commitments. An accuracy rate promised on document extraction is only meaningful relative to an input definition. "95% on our invoices" at 1120 tokens and the same figure at 140 tokens do not describe the same service. The budget is a service-level parameter, not an implementation detail.

On publication. The adjustable budget and the aspect-ratio-preserving resize are mechanisms publicly described in a technical report dated July 2026: anyone can study them, reimplement them and compare them. The report also lists 322 declared authors, a good reminder of the industrial scale these projects have reached.

Key points

  1. The problem: visual encoders imposed a fixed, square input size (896 × 896 for 256 tokens in Gemma 3) which distorts elongated images and makes dense documents illegible, while charging the same price for a photo and for a scanned contract.
  2. The previous patch, Pan & Scan, cut the image into separately encoded pieces: legibility recovers, but the cost multiplies and the model never sees the whole image again.
  3. Gemma 4's reversal: you no longer fix the size, you fix the token budget (70, 140, 280, 560 or 1120) and the model derives the resize dimensions from it, preserving proportions.
  4. The real unit is the 48 × 48 pixel block: 16-pixel patches, pooled three by three. One soft token, one 48-pixel block.
  5. What makes free proportions possible: each patch receives its (row, column) coordinates via axial 2D-RoPE and two-dimensional absolute positions, with non-causal attention, an image has no reading order.
  6. The limiting case: the unified 12B model removes the visual encoder outright (550M parameters) and projects raw 48 × 48 pixel patches through a single 35M-parameter matrix.
  7. The practical consequence: the cost of an image varies by a factor of sixteen depending on a call parameter, which belongs in a price list, in a quality commitment, and in any numerical comparison between models.
Vérifiez votre compréhension0 / 5

1. What does a Gemma 4 user choose when sending an image, that earlier generations did not let them choose?

2. Why does the billing unit of an image, in soft tokens, correspond to a 48 × 48 pixel square?

3. Why does Gemma 4 give each patch its (row, column) coordinates rather than a simple rank in the sequence?

4. What sets the unified 12B model apart from the rest of the Gemma 4 lineup?

5. What contractual consequence does the adjustable token budget carry?