Skip to content
imaged

Text and image chat

Gemma 4 E2B

A chat model that answers, writes, explains and reads pictures, entirely on the device: Google's Gemma 4 E2B, 4-bit, with a drafter that speeds up answers. Apache-2.0.

Apache-2.0language modelllmchattext generationvision-languageimage understandinggemmagoogleofflineint4apache-2.0
Choose a variant

About this model

Gemma 4 E2B is a chat model: give it a conversation, with or without a picture, and it writes the next answer as text that streams while it is written. It answers questions, explains, drafts messages, writes code, describes photos, reads signs and receipts, in many languages, with no network connection.

It is Google's Gemma 4 E2B in its quantization-aware (QAT) checkpoint, trained to run with 4-bit weights. The pack holds the decoder (int4), its per-layer token table (int4), the vision tower (FP16), the tokenizer and the chat template, and Gemma's multi-token drafter: for greedy answers the drafter proposes 4 tokens and the model checks them in one step.

Slab reads the prompt 64 tokens at a time and writes the answer one token at a time, keeping the key/value cache in FP16 in the engine. The sliding-window layers keep their cache in a ring. A follow-up question reuses the cached tokens of the conversation so far. The pack is built for 4096 positions; a session that asks for more (context_length, up to the model's 131072) gets a longer cache, built at open from the graph the pack stores.

What you can build

  • An offline assistant inside an app: questions, explanations, drafts and short code
  • Describe a photo or answer questions about it
  • Read text in pictures: signs, labels, receipt totals
  • A private chat whose conversations and pictures never leave the device

Explain simply, then a follow-up

int4
Input
user: Explain why the sky is blue to a ten-year-old, in one short paragraph.
assistant: Imagine sunlight is made up of all the colors of the rainbow, but it's actually made of different colors of light waves. When this sunlight hits the Earth's atmosphere, it bumps into tiny little gas molecules and dust. These tiny particles are much better at scattering the shorter, bluer colors of light than the longer, redder colors. Because the blue light gets scattered all over the sky in every direction, that's the color our eyes see when we look up!
user: Now say it in one sentence.
Output
The sky is blue because the Earth's atmosphere scatters the shorter, bluer colors of sunlight more effectively than the other colors.

(Greedy decoding on Metal: the first answer 97 tokens, this one 27. The 125 tokens of the earlier turns were reused from the cache.)

Write

int4
Input
Write a short, friendly message reminding my team about Friday's 10 am meeting.
Output
Here are a few options, depending on your team's vibe:

**Option 1: Short & Sweet**

> Hi team! 👋 Just a friendly reminder about our meeting this Friday at 10 am. See you all then!

**Option 2: A Little More Enthusiastic**

> Hey everyone! Looking forward to catching up with you all on Friday at 10 am. See you then! 😊

**Option 3: Casual & Direct**

> Quick reminder: Don't forget our meeting this Friday at 10 am. Thanks!

**Option 4: If you need to include a link/location (Optional)**

> Hi team! Friendly reminder about our meeting this Friday at 10 am. [Insert Link/Location Here]. See you soon!

**Choose the one that best fits your team's communication style!**

(Greedy decoding on Metal, 182 tokens.)

Describe a photo

int4
Input
Black and white photo of a smiling older man in a flat cap and checked shirt at a street market

Wilfredor, CC0, https://commons.wikimedia.org/wiki/File:Fishmonger_smiling,_Maracaibo_street_market,_Venezuela.jpg

Describe this picture in two sentences.
Output
This is a black and white portrait of an older man with a warm, smiling expression. He is wearing a plaid shirt and a flat cap, and the background suggests an outdoor, possibly market or casual setting.

(Greedy decoding on Metal, 42 tokens.)

Read a sign

int4
Input
Blue Paris street sign: 3e Arr, Rue Conté, 1755-1805, chimiste et ingénieur, co-fondateur du Conservatoire national des arts et métiers

Benoît Prieur, CC0, https://commons.wikimedia.org/wiki/File:Rue_Cont%C3%A9_(Paris)_en_juin_2019_-_panneau_de_rue.jpg

Read this sign. What does it say, in English?
Output
Here is the text from the sign, translated into English:

**3e Arr** (This likely stands for "3rd Arrondissement" or a similar administrative division)

**RUE CONTÉ** (Conté Street)

**1755-1805**

**CHIMISTE ET INGÉNIEUR** (Chemist and Engineer)

**CO-FONDATEUR DU CONSERVATOIRE NATIONAL DES ARTS ET MÉTIERS** (Co-founder of the National Conservatory of Arts and Crafts)

(Greedy decoding on Metal, 110 tokens.)

A receipt's total

int4
Input
Photo of a printed restaurant receipt

CORD-v2 test receipt 1 (NAVER Clova), CC BY 4.0, https://huggingface.co/datasets/naver-clova-ix/cord-v2

What is the total amount on this receipt? Answer with the number only.
Output
91000

(Greedy decoding on Metal, 5 tokens. The labeled total is 91000.)

Variants & downloads

Choose the build for your app

Model files are hosted on Google Drive. Large files may open a confirmation page before downloading.

Standard

Slab

The QAT checkpoint's decoder and per-layer table stored as int4 (the precision Google trained it for), the vision tower and drafter in FP16, the drafter attached. One file.

Platforms: macos

gemma-4-e2b-int4.slab

2.92 GB · Hosted download

Download
SHA-256 checksum
032612229c8e031f008ff4df6317657496600c6b303d6168025da357f4e1d557

LICENSE-Apache-2.0.txt

11 KB

Download
SHA-256 checksum
aa0dac0cf2c24ddb8911645ff4086280474adae4861005ba9ec2a7b0bbe50ba9
Conversion details
command
hf download google/gemma-4-E2B-it-qat-q4_0-unquantized --revision 6befbaca7398925921802abd1f277b495b78b738 --local-dir gemma-4-E2B-it-qat hf download google/gemma-4-E2B-it-qat-q4_0-unquantized-assistant --revision ebc7e1a211354561464cb82ed6d886792138dcb6 --local-dir assistant SLAB_LOAD=slab-load python convert/gemma-4-e2b/build_gemma.py gemma-4-E2B-it-qat work int4 any-picture.jpg 4096 assistant cp work/gemma-int4.slab gemma-4-e2b-int4.slab

Integration examples

Python

python

import slab

cfg = slab.Config(cache_dir="/tmp/slab_cache", license=open("license.slablic.txt").read())
llm = slab.Session(cfg, "gemma-4-e2b-int4.slab")

chat = slab.Input()
chat.add_message("user", "Describe this picture in two sentences.", image=slab.Frame.open("market.jpg"))
chat.max_tokens = 200

for piece in llm.generate(chat):   # text as it is written
    print(piece, end="", flush=True)

Device & backend compatibility

Pack default: macos / GPU. The 4-bit weights run as int4 on the Apple GPU (Metal), 44 tokens/s; the CPU path is many times slower.

Available execution backends for Gemma 4 E2B
PlatformEngineStatusPrecision
apple

Metal

GPU

Supported

Measured on macOS. The default: int4 weights decoded in the GPU program, the cache and activations in FP16.

int4, f16
apple

CPU

CPU

Supported

Checked on macOS with a short answer (correct): 25 s for a 9-token answer while another job ran, so not measured; many times slower than the GPU.

—
apple

Apple Neural Engine

NPU

Not supported

Not tried.

—
android

Vulkan

GPU

Not supported

Tried on a Samsung Galaxy S23 Ultra (Adreno 740): the pack's int4 weights (precision.gpu = int4:f16) do not run on Slab's Vulkan GPU engine yet.

—
android

CPU

CPU

Not supported

Not offered on phones: a language model on a phone's CPU is too slow to use.

—

Performance

Results depend on the device, runtime, and test conditions. Each measurement keeps its own context.

Mac with Apple M1 Max

Slab · GPU

macOS 26.6.2

22.5 ms

Measured time · scope below

int4Session open (ms): 2640 Platform: macos Runs: 5 Input: a chat prompt of 25 tokens, 128 new tokens Measured: 2026-11-05

Milliseconds per generated token while streaming (44 tokens/s greedy with the drafter, 46 sampled at temperature 0.7), median of 5 answers with the cache cleared. The first piece of text after 79 ms (the prompt included); a prompt of 531 tokens read in 822 ms. Opening takes 38 s the first time on a device, while Slab compiles the GPU program and keeps it in the cache folder, then 2.6 s. Peak memory footprint over the whole run (open, 10 answers, the long prompt, 4 picture questions): 3.35 GB.

Mac with Apple M1 Max

Slab · GPU

macOS 26.6.2

659.0 ms

Measured time · scope below

int4Session open (ms): 2640 Platform: macos Runs: 3 Input: one 960 x 639 photo and a one-line question (278 prompt tokens), 64 new tokens Measured: 2026-11-05

Milliseconds to the first piece of text: the picture encoded by the vision tower, the prompt read, the first token written; then 23.7 ms per token. Median of 3, after a first run that compiles the vision tower.

Mac with Apple M1 Max

Slab · GPU

macOS 26.6.2

817.0 ms

Measured time · scope below

int4 Platform: macos Runs: 95 Input: a CORD-v2 receipt photo and a one-line question, up to 24 new tokens Measured: 2026-11-05

Milliseconds per receipt, median over the 95 CORD-v2 test receipts with a total: picture, prompt and answer (a number of about 5 tokens).

Accuracy checks

macos · GPU · int4

transformers 5.21 with the upstream QAT checkpoint in bf16 (its published weights) on MPS, greedy decoding of up to 100 tokens, on 30 everyday prompts (facts, how-to, writing, code, arithmetic, translation) with Gemma's chat template

The same answer, token for token, for 19 of 30 prompts. The others part from it after 29 tokens (median) and stay on topic; 1 differs within its first 5 tokens. The reference itself runs bf16 arithmetic, so exact agreement is not expected.

macos · GPU · int4

CORD-v2 test receipts (95 with a labeled total), asked "What is the total amount on this receipt? Answer with the number only.", the answer's digits compared with the label's

73 of 95 totals read correctly (77%).

Before you choose this model

  • A small model: it makes factual mistakes and its readings of pictures can be wrong. It read 73 of 95 receipt totals correctly in our check (see Accuracy). Check its answers where they matter.
  • It tends to write long, formatted answers (headings, bullet lists). Ask for a short answer or a sentence count when you want one.
  • Images go in at 280 soft tokens per picture. Small text in a large photo can be missed.
  • The first open on a device takes about 38 s on the GPU while Slab compiles the model; later opens take 2.6 s if the app keeps the cache folder.
  • Measured on a Mac. It runs on the CPU too, much slower than the GPU (see Backends).
  • 3.1 GB to download, about 3.4 GB of memory while it answers.