Basics · modality ablation · WebGPU q2f16 / fp16 · 2,603.9 MB · Apache-2.0

Modality ablation — what each input stream costs Gemma 4 E2B

Five passes through the same 2.6 GB checkpoint: text alone, text with the thinking channel, an image, a raw 16 kHz audio clip, and image + audio fused into one prompt. Every row reports the real time-to-first-token, decode speed and the text / <|image|> / <|audio|> split counted from the processor's input_ids — measured on your GPU, never canned.

Run the ablation — five modes, one model

The thinking mode always gets at least 512 new tokens (the worker maximum) so the <|channel>thought trace has room to close before the answer. Decoding is greedy (no sampling), so reruns are comparable.

Checking for a local copy of Gemma 4 E2B…

Live output

The active mode's answer streams here token-by-token.

Prompt token mix of the active mode

Counted from the real input_ids once a mode prefills.

Results — side by side

Token counts come from the processor's input_ids (258880 = <|image|>, 258881 = <|audio|>). Keyword hits are a deterministic recall check against the expected facts for each prompt.
Mode Status TTFT tok/s Out tok Text <|image|> <|audio|> Keywords NaN

Time to first token (lower is better)

Run at least one mode.

Decode speed, tok/s (higher is better)

Run at least one mode.

Prompt token mix per mode

Each finished mode adds its real text / image / audio bar here.

The inputs every mode shares

Image: solar station plate

Loading the procedural plate…

Audio: JFK inaugural, 16 kHz mono

Loading the ledgered clip…

What each mode adds

Speeds depend on your GPU and driver; the first run after initialisation also pays shader compilation. Run all five twice if you want warm numbers.

How it works

Each mode calls Gemma4Engine.generate() in a module Web Worker with the mode's prompt, optional RGBA plate and optional 16 kHz PCM. The worker reports the real token split at prefill, streams tokens back, and the page scores the final answer with the pure helper below.

Show the code — gemma4-core.mjs: scoreFaithfulness() (keyword-hit check per mode)
Show the code — gemma4-core.mjs: buildMessages() (audio → image → text content order)

References