A visual encoder transforms an input image into a smaller image embedding: a compact representation that other model components can process more easily. section 11.4.2
In an image-segmentation system, the visual encoder processes the image while a prompt encoder represents a point or box. A mask decoder combines both embeddings to predict masks. section 11.4.2
Visual encoders also adapt images for multimodal Transformers:
- A Gemma visual encoder divides an image into 256 patches and encodes each patch as a 2,560-dimensional vector. section 16.4.2
- The resulting image representation has shape (256, 2560), matching Gemma’s hidden Transformer dimension. section 16.4.2
- These vectors become 256 image soft tokens spliced into the text sequence after token embedding, allowing the Transformer to process image and text together. section 16.4.2
From image to mask or answer
For segmentation, an image embedding joins a point or box embedding and produces candidate object masks. For multimodal prompting, image soft tokens join a text prompt so Gemma can answer questions such as what a pictured snake is wearing. section 11.4.2 section 16.4.2
Figure 11.9 The SAM high-level architecture overview
Architecture overview showing how the image encoder, prompt encoder, and mask decoder cooperate. section 11.4.2
Figure 16.6 Handling image input by splicing together text tokens and soft image tokens
Diagram of image soft tokens being spliced into a text-token sequence. section 16.4.2



