mrm8488's EmbeddingGemma 2 Fine-Tune Rivals 4B Models at 300M Parameters
A 0.3B EmbeddingGemma 2 fine-tune turns workflow states into typed, calibrated answers to yes/no, multiple-choice and ranked-level questions.
Takeaways
- A 0.3B EmbeddingGemma 2 fine-tune that returns typed, calibrated answers to workflow decision questions.
- Handles three primitives:
choice, orderedscore, and probabilistic yes/nonoul. - Reaches 76.4% test accuracy on the typed-decisions benchmark, up from 67.7% with a frozen encoder.
- Schema is plain data, so options and questions can be edited without retraining.
- Apache 2.0, multilingual-capable, must run in bfloat16 or float32 (float16 NaNs silently).
- Targets agent trace triage, customer service routing, invoice decisions and security alerts.
Manuel Romero, who publishes as mrm8488, has released embeddinggemma-2-ft-typed-decision, a 300-million-parameter fine-tune of Google’s EmbeddingGemma 2. Given a JSON-like workflow state and a question schema, the model returns temperature-calibrated probability distributions with typed values. The Apache 2.0-licensed checkpoint is available on Hugging Face and supports bfloat16 inference on a single GPU.
Repeated agent and business workflows often apply the same routing questions to every state. This model evaluates those questions in one call, preserves uncertainty for downstream thresholds, and removes free-text output parsing. Its parameter count is also substantially lower than that of multi-billion-parameter instruction models, although the release provides no latency or throughput comparison.
Typed questions from one state
| Type | Purpose | Example |
|---|---|---|
choice |
Selects one labeled option from a schema. | Continue, observe, review, or stop |
score |
Assigns an ordered level from a rubric. | Risk from 0 to 3 |
noul |
Returns a probabilistic Boolean decision. | Escalate: true or false |
Each example in the typed-decisions benchmark pairs one state with five questions. The benchmark describes this as a System One task, meaning bounded classification without multi-step generation. Every response retains the probability assigned to each allowed label.
The scoring head compares the text of every option with the state and question. Developers can rename options, revise descriptions, or add questions without retraining the checkpoint. Reliability can decline when a new schema differs substantially from the training distribution.
Semantic similarity, then correction
EmbeddingGemma 2 independently encodes the state, each question, and each option. Mean pooling averages the token representations into 768-dimensional vectors, which are then normalized to unit length. A schema-conditioned head of roughly 500,000 parameters combines those vectors.
Each option’s logit starts with cosine similarity, a measure of semantic alignment between normalized vectors. A learned, gated correction term then adjusts that zero-shot baseline. The implementation also converts state fields into readable key: value lines, such as trace summary · constraint violations: 1. This renderer lives in modeling_gemmadecision.py and forms part of the learned input interface, so changing it requires revalidation.
Two training phases share the work
- Phase 1: The encoder remains frozen while the head trains on cached embeddings.
- Phase 2: The encoder blocks and head train together, while the token-embedding table stays frozen. The encoder uses a learning rate of
2e-5, the head uses1e-4, and training runs for five epochs with batches of 32.
Training optimizes cross-entropy against soft teacher distributions, a Brier term that penalizes squared probability error, and an ordinal-distance penalty for score questions. A separate temperature for each question type is fitted on held-out rows and stored with the weights to calibrate confidence.
End-to-end tuning adds 8.7 points
| Metric | Frozen encoder | End-to-end tuning |
|---|---|---|
| Accuracy | 67.7% | 76.4% |
| Soft cross-entropy | 0.968 | 0.887 |
| Brier score | 0.113 | 0.065 |
End-to-end tuning raises accuracy by 8.7 percentage points. The lower cross-entropy and Brier scores indicate that the predicted distributions also move closer to the soft target distributions.
| Question type | Accuracy |
|---|---|
choice |
71.2% |
score |
74.0% |
noul |
84.8% |
The public leaderboard entry reports 0.770 accuracy, 0.119 KL divergence from the gold distribution, and a 0.065 Brier score. Those results place the 0.3B checkpoint near reported fine-tuned models with 2B to 4B parameters.
An English-Spanish translation probe found that mean cosine similarity between translation pairs increased from 0.869 to 0.901 after fine-tuning, while retrieval at rank one remained at 100%. The probe indicates that bilingual embedding alignment survived training; it does not measure decision accuracy or calibration on Spanish schemas.
Calling the custom API
The repository exposes a decide method through custom Transformers code. The following example loads the checkpoint in bfloat16 on a CUDA device:
import torch
from transformers import AutoModel
model = AutoModel.from_pretrained(
"mrm8488/embeddinggemma-2-ft-typed-decision",
trust_remote_code=True,
torch_dtype=torch.bfloat16,
).to("cuda").eval()
answers = model.decide(
state,
questions,
workflow="agent_trace_observability",
)
for qid, answer in answers.items():
print(
qid,
answer.value,
answer.confidence,
answer.probabilities,
)
Enabling trust_remote_code=True executes Python from the model repository. Production deployments should review that code and pin a tested repository revision.
Returned fields
- The selected label.
- A typed value represented as
str,int, orbool. - A calibrated confidence value.
- The complete probability mapping for all allowed labels.
- An expected level for
scorequestions.
When selecting precision, use bfloat16 or float32. The repository warns that float16 can silently overflow inside EmbeddingGemma 2 and produce NaN values.
Where the specialist fits
The strongest use cases apply a stable schema repeatedly: agent-trace triage, customer-service routing, invoice approval, and security-alert handling. These workflows can consume the full probability distribution to set escalation thresholds or request human review.
Each workflow in the dataset contains 400 rows, with soft target labels derived from three samples of a teacher model. The targets therefore encode teacher variability and near-ties instead of reducing every row to a single hard label.
Deployment constraints
- Numeric values inside state text are harder for an embedding encoder to interpret than descriptive language, making ordered
scorequestions the weakest area. - Three teacher samples produce coarse probability estimates, especially when labels are nearly tied.
- Temperature calibration is fitted on held-out benchmark rows and may drift under a new domain or class distribution.
- Unseen schemas require task-specific validation, particularly when their language or decision structure differs from the training set.
- The release reports quality metrics but provides no hardware-specific latency, throughput, or memory benchmarks.
Production evaluation should measure per-workflow accuracy, calibration under realistic traffic, failure behavior on missing fields, and inference cost on the target hardware. The checkpoint is designed for repeated typed decisions; open-ended reasoning, extraction, and explanation generation fall outside its training objective.