Gemma 4 E2B for A2UI Express

A browser-ready Gemma 4 E2B fine-tune for generating the A2UI Express DSL. This is the selected step-100 adapter of the E2B run on the E4B recipe, SHA-256 eff96be9f058aec7993a0b1618d1d20c60eb4519d54f54c2352865ad297490f2, offered in the CopilotKit Express demo as the smaller comparison beside the default E4B export. It replaces this repository's earlier round-two Unsloth Studio adapter (0cf5af05c20f7dc5855122470ff57a7ff1630ea292bf8af7f6656c29b321f045), which stays available at revision 4560ee18bbca5c8bf7a1e1d0eeb36a40e94547fa.

The root contains the adapted q4f16 ONNX text sessions for Transformers.js and WebGPU, about 3.1 GB in total. adapter-mlx/ contains the original 52 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-E2B-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-E2B-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 are the same as the E4B export's: 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-E2B-it, 4-bit MLX conversion
Base revision d36bdd3855c82a6a1a23f7c459b749f5724ae75d
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 100 of a 120-step run
Browser weights q4f16, adapted ONNX text sessions

training_config.json records these settings. The stock trainer ran out of Metal memory on the 8k-token rows, so the run used the stock trainer with a loss that applies the tied-embedding head and the cross-entropy per 512-position block under gradient checkpointing. On a training row it computes the same loss and gradient norm as the default loss; it only lowers the peak memory. Validation loss fell from 0.484 to 0.054 at step 40, 0.043 at step 80 and 0.029 at step 120. The step-120 checkpoint invented syntax on one held-out card, so the step-100 checkpoint was selected on the held-out cases. The native adapter contains 550 tensors for 275 logical adapted matrices. The browser export patches 240 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 8/8 on the first attempt, shows all 14 requested facts and prices, binds every input, answers both submits and both edits in the existing view and writes gap values of 1 to 6. The earlier round-two adapter of this repository passed 4/8 of the same cases with the current guide: it built every view with all facts, but its submits left an input orphaned and its edits opened a duplicate view. 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 (51 s), its submit (39 s, a summary card with all four entered values under the kept form), an edit adding an opening-hours line (72 s; it rewrote the view with the values intact rather than patching it), the Book Delivery form (66 s, four amounts in one price row and eight inputs) and the aquarium card (38 s). That is roughly half the time of the E4B export on the same machine. 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 E2B checkpoint. The browser graph derives from onnx-community/gemma-4-E2B-it-ONNX, revision 6f21c99d7e18237f8d2ce92aadfdbfeba877f63a. 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.

Downloads last month
1,056
MLX
Hardware compatibility
Log In to add your hardware

Quantized

Inference Providers NEW
This model isn't deployed by any Inference Provider. ๐Ÿ™‹ Ask for provider support

Model tree for wolfmanfx/gemma-4-E2B-it-A2UI-Express-ONNX

Finetuned
(180)
this model