Gemma 4 E4B for A2UI Express
A browser-ready Gemma 4 E4B fine-tune for generating the A2UI Express DSL.
This is the selected step-40 adapter of the second E4B run, SHA-256
d53063f5f606317cd9db5dd4bfc904e034d7f73a06b068155607459acc819fe2,
used in the CopilotKit Express demo.
It succeeds the earlier
E2B export.
The root contains the adapted q4f16 ONNX text sessions for Transformers.js
and WebGPU, about 4.9 GB in total. adapter-mlx/ contains the original
77 MB mlx_lm adapter and its configuration. It was trained on a 4-bit MLX
conversion of the base (mlx_lm.convert -q, group size 64), so native loading
needs the same conversion.
What it generates
A2UI Express represents an interface with named component constructors, lists, events and data paths. The host compiles the generated source into A2UI 1.0 protocol messages and renders native application components. This model generates source text; the application supplies the catalog, compiler, renderer and event handling. This demo targets the A2UI 1.0 release candidate and the Express proposal.
system_prompt.txt contains the actual catalog-generated SDK system guide used
for training and the browser demo: the official ExpressPromptGenerator
output for the demo's components, followed by the demo's generation guidance
and three short syntax lessons. Its SHA-256 is
556fb4646aaba37240ab878b6262bb830aa5f826e2280f090759d9070af432ae.
Use the matching catalog and validate model output with the Express compiler.
Browser use
Tested with @huggingface/transformers 4.3.2, actual headed Chrome and WebGPU
with shader-f16. This export contains text sessions; image, audio and video
inference are outside its scope. Model files download before inference runs
locally. The first load includes substantial download and GPU setup time, and
each reply prefills the 7.6k-token system guide, which takes most of the wait.
Replace wolfmanfx/gemma-4-E4B-it-A2UI-Express-ONNX below with this repository's
Hub model ID. For a deployed application, pin revision to the uploaded Hub
revision rather than a moving branch.
import { pipeline, Gemma4Processor } from "@huggingface/transformers";
const modelId = "wolfmanfx/gemma-4-E4B-it-A2UI-Express-ONNX";
const revision = "main"; // Pin the published revision in your application.
const guide = await fetch(
`https://huggingface.co/${modelId}/resolve/${revision}/system_prompt.txt`,
).then(response => {
if (!response.ok) throw new Error("System guide unavailable");
return response.text();
});
const generate = await pipeline("text-generation", modelId, {
device: "webgpu",
dtype: "q4f16",
revision,
});
const processor = await Gemma4Processor.from_pretrained(modelId, { revision });
const result = await generate([
{ role: "system", content: guide },
{
role: "user",
content: "Create a polished informational card headed Blue Tide Aquarium. " +
"Include all these facts exactly: Open Wednesday–Sunday, 09:30–17:30. " +
"Harbor Gate 7. Adult admission €17.50. Use clear visual hierarchy. " +
"Do not add inputs, forms or buttons.",
},
], {
...(processor.chat_template ? { chat_template: processor.chat_template } : {}),
max_new_tokens: 3072,
do_sample: false,
tokenizer_encode_kwargs: { enable_thinking: false },
return_full_text: false,
});
console.log(result);
The request above is a public curated demo example. Broader requests can fail. The live application also supplies task and surface context, validates output, and can return compiler feedback for model-generated repairs. Raw generation with the guide alone has not been given a separate quality score.
Training
The rows were written by a local Gemma 4 26B-A4B teacher from 96 scenario seeds and checked with the real Express compiler, component graph and data-binding checks; invalid targets were rejected. The training file holds 159 rows (54 view creations, 54 answers to submitted forms, 51 edits of an existing view) and the validation file 21. Every row carries the full system guide, about 7.9k tokens, and the loss covers the assistant turn only. Spacing values in the targets were rewritten as the catalog's 4px steps before training. Eight held-out cases were kept outside training. Dataset rows and evaluation cases are not included in this model repository.
| Setting | Value |
|---|---|
| Training base | unsloth/gemma-4-E4B-it, 4-bit MLX conversion |
| Base revision | 4e22d7e59e078e63a14f351efdc5232ed366b621 |
| Trainer | mlx_lm.lora, LoRA on all layers |
| Adapter | Rank 8, scale 2.0 (alpha 16), dropout 0 |
| Learning rate | 0.0001, Adam |
| Batch / accumulation | 1 / 1, gradient checkpointing |
| Seed | 3407 |
| Sequence cap | 12,288 tokens, prompt masked |
| Selected checkpoint | Step 40 of a 160-step run |
| Browser weights | q4f16, adapted ONNX text sessions |
training_config.json records these settings. The run's validation loss fell
from 0.367 to 0.035 by step 80, but its later checkpoints dropped requested
facts from generated views, so the step-40 checkpoint was selected on the
held-out cases. The native adapter contains 684 tensors for 342 logical
adapted matrices. The browser export patches 300 ONNX matrices while
preserving the decoder graph structure.
Measured results and limits
- On the eight held-out cases (two informational cards, two forms, their two
submits and two edits) run with greedy decoding on MLX, this checkpoint
compiles 7/8 on the first attempt, shows all 14 requested facts and prices,
binds every input and writes gap values of 3 and 4. The one failure puts a
variantargument on a Text in an edit, which the demo's single-line repair corrects. The untuned base passed 4/8 of the same cases with an earlier prompt. Eight cases are a small sample, not a benchmark. - In actual Chrome WebGPU runs of the demo with this export, five requests committed on their first attempt: a fitting form (96 s), its submit (68 s, a summary card with all four entered values under the kept form), an edit adding an opening-hours line (81 s), the Book Delivery form (117 s, four price rows with amounts and eight inputs) and the aquarium card (81 s). These are demonstration checks on one machine rather than a benchmark.
- The adapter was trained on 4-bit weights and merged into fp16 ones before q4f16 quantization, so the browser model approximates the MLX one and can produce different output for the same request.
- Greedy decoding reduces sampling variation; GPU execution and runtime differences can still change results. Arbitrary requests, other catalogs, other languages, long conversations and other hardware are not validated. Validate output with the Express compiler and keep the repair loop.
Provenance and licence
The model family was developed by Google DeepMind. Training used
Unsloth's Gemma 4 E4B checkpoint.
The browser graph derives from
onnx-community/gemma-4-E4B-it-ONNX,
revision 2b6d2e26a962f70a33da8f7cd81e1afdd8d9cfb2.
The selected adapter was applied to the browser text weights and quantized
to q4f16. a2ui-export-manifest.json records identities and SHA-256 checksums
for the browser files. Private training paths and internal audit records have
been removed from the public manifest.
Gemma 4 is licensed under Apache License 2.0. See LICENSE and NOTICE.txt,
and the Google model card.
This is a community Express-focused fine-tune for an experimental demo.
The catalog-generated system guide includes MIT-licensed CopilotKit component
metadata. Its accompanying notice is in LICENSE-COPILOTKIT.txt.