A visual encoder converts an image into a sequence of vectors that a larger multimodal model can process alongside text. This works because Transformers learn patterns in sequences, not only text. section 16.4.2
Turning an image into soft tokens
Gemma’s 420-million-parameter image encoder cuts an image into 256 patches and encodes each patch as a 2,560-dimensional vector. The resulting (256, 2560) sequence matches Gemma’s hidden dimension and can be spliced into the text sequence after token embedding. The special token <start_of_image> becomes 256 placeholders, which are replaced by these image vectors. Unlike fixed-ID hard tokens, soft tokens can take any vector value produced by the encoder. section 16.4.2
Use the encoder according to the surrounding model architecture:
- For multimodal generation, align the encoder output dimension with the Transformer hidden dimension so image vectors can join the text sequence. section 16.4.2
- For segmentation, pass the smaller image embedding to a mask decoder together with a prompt embedding; the encoder alone does not produce the final mask. section 11.3.2
- Treat image encoding as a separable training stage when preparing a multimodal model, then train on mixed image-and-text sequences. section 16.4.2
Figure 16.6 Handling image input by splicing text tokens and soft image tokens together
Shows how image soft tokens and text tokens occupy one Transformer input sequence. section 16.4.2



