How Multimodal Omni Desk Works
Instead of chaining separate ASR, captioning, and text models, Gemma 4 E2B encodes image patches and raw
16 kHz log-mel audio frames directly into its shared token stream inside one WebGPU worker.
1. Direct Gemma4Processor Fusion
Because the upstream ONNX repo's preprocessor_config.json omits processor_class,
worker.js imports Gemma4Processor directly from Transformers.js 4.3.2 so
processor_config.json, Gemma4ImageProcessor (up to 280 soft tokens),
Gemma4AudioFeatureExtractor (40 ms/token, up to 750 tokens), GemmaTokenizer
(32.2 MB), and chat_template.jinja all initialize cleanly together.
2. Unified 4-Subgraph WebGPU Execution
Gemma4ForConditionalGeneration loads four QAT Mobile ONNX subgraphs onto WebGPU:
embed_tokens_q2f16 (1,296.6 MB), decoder_model_merged_q2f16 (995.4 MB),
vision_encoder_fp16 (187.5 MB), and audio_encoder_q2f16 (92.3 MB). Image and
audio embeddings replace <|image|> (258880) and <|audio|> (258881)
slots in a single forward pass.
3. Honest WebGPU Gate & Zero-Upload Privacy
Every subgraph ships Q2F16/FP16 WebGPU graphs (device: "webgpu"). On CPU-only browsers
without WebGPU, createModelLoader degrades honestly to unsupported with zero
fake output. Microphone access is strictly user-initiated under
Permissions-Policy: camera=(), microphone=(self), geolocation=().