Run the stress sweep
Run one regime pair (each pair is a control vs its adversarial twin):
Checking for a local copy of Gemma 4 E2B…
| Regime | Input preview | <|image|> / <|audio|> tokens | TTFT | tok/s | Answer | Faithfulness | NaN |
|---|
Control vs adversarial — pair deltas
Run a pair to compare its control and adversarial twin.
The four regimes
-
Image token budget. The same 840 px procedural solar-station plate is sent twice, with
Gemma4ImageProcessor'smax_soft_tokensset to 70 vs 280 for that call (patch 16, 3×3 pooling). The processor always resizes the image to fill its budget — a 96 px thumbnail is upscaled to 260 tokens, so pixel size alone is not a stress test — which makes the soft-token budget the real knob. At 70 tokens the "94%" reading gets a fraction of the patches; an honest answer is "I can't read it". -
Noisy audio. The 11 s JFK inaugural clip, clean vs mixed with deterministic white noise at
0 dB SNR (noise RMS = speech RMS, seeded PRNG so every run hears the same noise). The prompt invites
[inaudible]markers rather than invented words. - Occluded chart. A first-party revenue chart, full vs with the Q4 bar and its "$215k" label painted over by a "REDACTED" box. Repeating "215" for the occluded view counts as a hallucination.
- Cross-modal contradiction. LibriSpeech narration says the wizard vanished behind the curtain on the left; the procedural sign says on the right. A grounded model reports both sides and that they disagree instead of silently picking one.
How the faithfulness score works — and what it can't tell you
Each regime declares expect keywords (must appear), forbid keywords (would be a
hallucination, e.g. "215" when the bar is hidden) and honestAbstain phrases ("cannot", "not
visible", "[inaudible]", "disagree"). The score is expected-keyword recall, forced to 0 on any forbidden hit,
and 1 when a regime expects nothing and the model honestly abstains.
These are lowercase substring keyword heuristics, not ground truth. A paraphrase ("ninety-four percent") scores as a miss, and an answer that mentions a keyword while being wrong scores as a hit. Read the answers themselves — the score is only a fast, reproducible first pass. It is deterministic and always finite.
Show the code — gemma4-core.mjs: scoreFaithfulness() (recall, forbidden hits, honest abstention)
References & media
- ONNX weights: onnx-community/gemma-4-E2B-it-qat-mobile-ONNX (Apache-2.0)
- JFK inaugural address excerpt, 20 Jan 1961 — public-domain U.S. government work (
models/whisper-speech-to-text/jfk.wav) - LibriSpeech test-clean 61-70968-0000 — Panayotov et al., OpenSLR SLR12, CC BY 4.0
- Solar-station plate, revenue chart and wizard sign — first-party procedural Canvas drawings (MIT, zero people)