--- license: cc-by-nc-4.0 base_model: google/gemma-4-E4B-it tags: - gemma4 - system-1 - decision-model - multimodal - calibrated - non-autoregressive - jev - laya language: - en pipeline_tag: image-text-to-text --- # Gemma Decide E4B v1 **Gemma Decide E4B v1** is the single-24GB-GPU production workhorse of the **Gemma Decide** multimodal **System 1 decision model** family, adapted from [`google/gemma-4-E4B-it`](https://huggingface.co/google/gemma-4-E4B-it) to answer multiple structured decision questions (`noul`, `choice`, `score`) over **text, JSON, or image** states in a **single non-autoregressive forward pass** with calibrated probabilities — compatible with the [Jev](https://systemonemodels.org) and [Laya](https://huggingface.co/convaiinnovations/laya) decision schema. - **Code, server, & training/eval repo:** [github.com/firworksyt/gemma-decide](https://github.com/firworksyt/gemma-decide) - **Gemma Decide v1 Family:** - **[`Firworks/gemma-decide-e2b-v1`](https://huggingface.co/Firworks/gemma-decide-e2b-v1)** *(`10.32 GB` `bf16`, lightweight edge / co-located sidecar)* - **[`Firworks/gemma-decide-e4b-v1`](https://huggingface.co/Firworks/gemma-decide-e4b-v1)** *(this model — `16.14 GB` `bf16`, single-24GB-GPU production workhorse)* - **[`Firworks/gemma-decide-26b-a4b-v1`](https://huggingface.co/Firworks/gemma-decide-26b-a4b-v1)** *(`51.91 GB` `bf16`, 4B active MoE — multimodal & knowledge-heavy flagship)* > **License notice:** The `gemma-decide` codebase is licensed under **Apache-2.0**. These `v1` preview weights are released under **CC-BY-NC-4.0 (research / non-commercial)** because the v1 training mix includes public research/non-commercial and copyleft benchmark train splits (listed transparently below). The derived training dataset is not redistributed. A clean synthetic/permissive-only Apache-2.0 `v2` release is planned. --- ## Key Highlights - **Single-24GB-GPU sweet spot (`16.14 GB` merged `bf16`):** Fits comfortably in `bf16` on a single RTX 4090 / RTX 3090 / L4 with room to spare — delivering **24–38 ms** text and **45 ms** multimodal latency *even before `torch.compile`*. - **Ties 26B-A4B on multi-question agent states with the tightest calibration:** Hits **`69.1%`** on `2,000` unseen `typed_decisions` questions (`+6.6 pts` over E2B) with **`0.100` ECE**, **`0.198` Brier**, **`8.3%`** option-order flip rate, and **`88.1%` accuracy at `>=0.90` confidence**. - **Rock-solid order invariance & guardrails:** **`0.0%` option-order flip rate** on `mnli` (`87.8%` acc, `@0.90: 97.2%` @ 71% cov), **`96.3%`** on `sst2` (`0.023` ECE, `@0.80: 98.9%` @ 95% cov), **`83.3%`** on 77-way `banking77` (`@0.90: 97.1%` @ 61% cov), and **`0.882` Spearman** / **`0.045` ECE** on 5-level ordinal `sst5`. - **Strong step up in vision & zero-CoT knowledge:** **`54.8%`** on unseen `mmstar` (`+6.5 pts` over E2B, `45 ms` eager) and **`46.5%`** on unseen 10-way `mmlu_pro` (`+9.5 pts` over E2B, `@0.80: 87.2%` / `@0.90: 93.1%`). --- ## Gemma Decide v1 Family Comparison (`n <= 400` / 4,400 Questions) All models trained on the identical `20,997`-bundle training split (`LocalLLaMA/typed-decisions`, `Lin-Chen/MMStar`, and `TIGER-Lab/MMLU-Pro` **100% unseen**): | Benchmark *(Q's)* | **E2B v1** *(10.3 GB)* | **E4B v1** *(this model, 16.1 GB)* | **26B-A4B v1** *(51.9 GB, 4B active)* | | :--- | :---: | :---: | :---: | | **Held-out Val** *(1,000 bundles)* | `0.495` / `85.6%` | `0.432` / `87.4%` | **`0.332` / `90.1%`** | | **`typed_decisions`** *(2,000 unseen)* | `62.5%` *(ρ `0.810`)* | **`69.1%`** *(ECE **`0.100`**)* | **`69.1%`** *(ρ **`0.853`**)* | | **`sst2`** *(400, binary `noul`)* | `94.0%` *(ECE `0.030`)* | `96.3%` *(ECE `0.023`)* | **`97.0%`** *(ECE **`0.019`**)* | | **`sst5`** *(400, 5-pt `score`)* | `59.0%` *(ρ `0.863`)* | `62.5%` *(ECE **`0.045`**)* | **`65.3%`** *(ρ **`0.888`**)* | | **`mnli`** *(400, 3-way NLI)* | `86.0%` *(flip `2.5%`)* | `87.8%` *(flip **`0.0%`**)* | **`91.0%`** *(ECE **`0.028`**)* | | **`mmstar`** *(400, unseen vision)* | `48.3%` *(ECE `0.171`)* | `54.8%` *(ECE `0.153`)* | **`66.3%`** *(ECE **`0.118`**)* | | **`banking77`** *(400, 77-way)* | `82.0%` *(ECE **`0.031`**)* | `83.3%` *(ECE `0.050`)* | **`84.5%`** *(flip **`3.3%`**)* | | **`mmlu_pro`** *(400, 10-way 0-CoT)* | `37.0%` *(ECE `0.109`)* | `46.5%` *(ECE `0.112`)* | **`59.0%`** *(ECE **`0.057`**)* | --- ## Architecture 1. **Tree-Masked Causal Backbone (`google/gemma-4-E4B-it`):** - `state` (text/JSON/images) occupies positions `0 .. L_state - 1`. - Every question branch `Q_i` starts at logical position `L_state` and attends only to `state` + its own causal prefix (zero cross-question leakage, mathematically verified against sequential forward passes). - Preserves Gemma 4 E4B's KV-shared layers (`logits_to_keep = num_question_tokens`), sliding/global attention, Per-Layer Embeddings (PLE), and native multimodal vision tower. 2. **2-Layer Bidirectional `DecisionHead` (`110.77M` params, `hidden_size=2560`, `ffn_dim=3584`, `num_heads=8`):** - Each option line ends with Gemma 4's built-in `` token. - A 2-layer Pre-Norm bidirectional transformer runs over each question branch so all options cross-attend (handling `"Other / None of the above"` and minimizing option-order bias) before a 2-layer MLP outputs calibrated option logits. 3. **Standalone Merged Checkpoint (`16.14 GB`, zero PEFT):** - Trained with LoRA (`r=32, alpha=64`) on language, PLE, and vision encoder layers + unfrozen `embed_vision` projector (`88.34M` params) + full `DecisionHead` (`110.77M` params; `199.11M` total trainable), then folded into base weights via `merge_and_unload()` (verified `max_prob_diff = 0.00641` text / `0.00006` multimodal). --- ## Detailed Benchmarks (`n <= 400` / 4,400 Questions, Eager `bf16` on RTX PRO 6000 Blackwell) `LocalLLaMA/typed-decisions`, multimodal `Lin-Chen/MMStar`, and `TIGER-Lab/MMLU-Pro` are **100% unseen during training** (zero leakage). | Benchmark | Q's | Acc | ECE ↓ | Brier ↓ | Spearman / MAE | p50 ms (eager) | @0.80 Conf (Acc / Cov) | @0.90 Conf (Acc / Cov) | Flip Rate (60Q) | | :--- | ---: | ---: | ---: | ---: | ---: | ---: | ---: | ---: | ---: | | **`typed_decisions`** *(100% unseen)* | 2,000 | **69.1%** | **0.100** | **0.198** | 0.807 / **0.410** | **37.9** | **82.2%** (56% cov) | **88.1%** (35% cov) | **8.3%** | | **`sst2`** *(binary `noul`)* | 400 | **96.3%** | **0.023** | **0.049** | — | **24.5** | **98.9%** (95% cov) | **98.9%** (91% cov) | — | | **`sst5`** *(5-pt ordinal `score`)* | 400 | **62.5%** | **0.045** | 0.501 | **0.882** / 0.470 | **24.4** | 75.0% (13% cov) | 50.0% (0.5% cov) | — | | **`mnli`** *(3-way NLI `choice`)* | 400 | **87.8%** | **0.036** | **0.177** | — | **24.5** | **93.3%** (82% cov) | **97.2%** (71% cov) | **0.0%** | | **`mmstar`** *(100% unseen vision)* | 400 | **54.8%** | 0.153 | 0.591 | — | **45.0** | **74.2%** (40% cov) | **84.1%** (27% cov) | **10.0%** | | **`banking77`** *(77-way dynamic `choice`)* | 400 | **83.3%** | 0.050 | **0.243** | — | **54.5** | **93.6%** (74% cov) | **97.1%** (61% cov) | 10.0% | | **`mmlu_pro`** *(100% unseen 10-way, 0-CoT)* | 400 | **46.5%** | 0.112 | 0.653 | — | **24.8** | **87.2%** (29% cov) | **93.1%** (22% cov) | 55.0% | **`typed_decisions` per-primitive accuracy (2,000 unseen questions):** `choice = 68.3%`, `noul = 76.2%`, `score = 64.3%` (`MAE = 0.410` on 0–4 scale, `Spearman = 0.807`). --- ## Training Data & Upstream Attributions Trained on `21,997` bundles (`45,319` calibrated questions; `20,997` train / `1,000` held-out validation & calibration; `5,997` multimodal bundles) for 2 epochs (`2,625` steps, `grad_accum=16`, `lora_lr=1e-4`, `head_lr=3e-4`, `131.1 min`) on 1× NVIDIA RTX PRO 6000 Blackwell (96 GB). Soft probability targets were distilled from **Gemma 4 31B (`google/gemma-4-31B-it`, Apache-2.0)** using 2-permutation order-debiased logprobs alongside train-split ground-truth anchors. Upstream sources used (train splits only; strict zero-overlap with all eval sets): - **Synthetic software/agent JSON states** generated by Gemma 4 31B across 24 domains × 4 tones (Apache-2.0 outputs) - **Conversational states** adapted from `wildchat-1m` (ODC-BY) and `no_robots` (CC-BY-NC-4.0), labeled by Gemma 4 31B - **Multimodal vision states** adapted from `A-OKVQA` (research/NC), `ChartQA` (GPL-3.0), `DocumentVQA` (research/NC), and `ScienceQA-IMG` (CC-BY-NC-SA-4.0), labeled by Gemma 4 31B - **Text ground-truth train anchors:** `PolyAI/banking77` (CC-BY-4.0), `SetFit/sst2` & `SetFit/sst5`, `nyu-mll/glue` (`mnli`), `google/boolq` (CC-BY-SA-3.0), `allenai/ai2_arc` (CC-BY-SA-4.0), `allenai/sciq` (CC-BY-NC-3.0) --- ## Usage ### Install ```bash uv pip install "gemma-decide[serve] @ git+https://github.com/firworksyt/gemma-decide.git" # or clone the repo: # git clone https://github.com/firworksyt/gemma-decide && cd gemma-decide && uv sync --extra serve ``` ### Python ```python import torch from gemma_decide.model import GemmaDecideModel from gemma_decide.schema import ChoiceQuestion, DecisionRequest, NoulQuestion, ScoreQuestion model, processor = GemmaDecideModel.from_checkpoint( "Firworks/gemma-decide-e4b-v1", dtype=torch.bfloat16, device_map="cuda:0", ) model.compile_for_inference(dynamic=True) req = DecisionRequest( state={"ticket": "My debit card was declined twice at the grocery store."}, questions={ "urgent": NoulQuestion(instructions="Requires immediate customer support action."), "intent": ChoiceQuestion( instructions="Select the customer intent.", criteria={ "declined_card_payment": "Card payment was declined", "lost_or_stolen_card": "Card was lost or stolen", "card_delivery": "Waiting for card delivery", }, ), "frustration": ScoreQuestion( instructions="Rate user frustration level.", criteria=["Calm", "Mildly annoyed", "Frustrated", "Very angry"], ), }, ) resp = model.decide(req, processor) print(resp.model_dump_json(indent=2)) ``` ### FastAPI Server (`/v1/decisions` & `/v1/systemone`) ```bash uv run python scripts/serve.py \ --checkpoint Firworks/gemma-decide-e4b-v1 \ --compile --warmup --host 127.0.0.1 --port 8080 ``` --- ## Limitations & Intended Use - **System 1, not System 2:** Ideal for single-24GB-GPU production routing, multi-question agent state evaluation, RAG grounding/NLI guardrails, and ordinal rubric scoring — **not** multi-step math, code synthesis, or complex chain-of-thought reasoning. Pair with a confidence threshold (e.g., `confidence >= 0.80`) to escalate uncertain cases to a frontier LLM, or step up to [`gemma-decide-26b-a4b-v1`](https://huggingface.co/Firworks/gemma-decide-26b-a4b-v1) for heavy multimodal and domain-knowledge triage. - **Vision resolution:** Trained at a `280` soft-token image budget. Fine dense OCR or tiny chart text may still require higher-resolution System-2 VLMs. - **Non-commercial v1 weights:** Use for research, evaluation, and non-commercial prototypes; await a clean Apache-2.0 v2 checkpoint for commercial production deployments.