Valrico-400M-v3: typed decisions with modular routing and calibration

By Timothy Epping.

Valrico-400M-v3 keeps the frozen Valrico-400M-v2 encoder weights (400M parameters, built on Ettin, Apache 2.0) byte-identical and wraps them in a modular serving engine (valrico_engine.py) that adds deterministic missing-field abstention, single-pass structured order & arithmetic routing, per-workflow few-shot calibration, and confidence-based abstention. Base model probabilities (v2_probs) are preserved identically on every call, with exact fallback to Valrico-400M-v2 whenever no module fires.

What changed over Valrico-400M-v2

Capability Module How it works
Order & numeric reasoning (opt-in) ValricoEngine.load(..., enable_order_extractor=True) + bundled order_extractor/ Extracts structured header and line-item fields in the same forward pass as base scoring (no extra encoder pass), verifies consistency checks, and executes exact Decimal arithmetic (CMP, CMP-DATE, DIFF-DAYS, DIFF, AGG, COUNT, ARG, EQ). Opt-in dedup_records=True reuses decoded extractions across multiple questions on the same record.
Per-workflow calibration WorkflowCalibrator Fits per-workflow abstain_bias, yes_bias, L2-regularized multi-class option_biases (matched by normalized label), and scalar temperature from k = 10–20 labelled examples. Default (b = 0.0, T = 1.0) is byte-identical to raw v2.
Missing-field abstention FieldPresenceGuard Deterministic parser (JSON, Key: value, pipe/markdown tables) checks caller-specified required_fields (and optional aliases) for absent, null, or redacted values (TBD, N/A, [REDACTED], etc.) before model inference when abstain_index is supplied.
Confidence-based abstention min_confidence / min_margin Optional thresholds escalate low-confidence or tight-margin predictions (route = "abstain_low_confidence") to abstain_index while keeping the underlying calibrated probabilities and original_answer intact.
Option-order symmetrization (opt-in) ValricoEngine(..., symmetrize=True) Scores original and reversed option orders, centers logits, and averages them to reduce option-slot bias on multi-option choice tasks while preserving v2_probs. Recommended for 3+ option choice workflows only (see Evaluation Summary).

Precedence in ValricoEngine.decide_many(): abstain_missing_field β†’ extracted β†’ calibrated / model β†’ abstain_low_confidence.


How to use

Code written for valrico.py continues to work unchanged, and ValricoEngine adds the v3 layers on top:

from valrico_engine import FieldPresenceGuard, ValricoEngine, WorkflowCalibrator

# 1. Plain engine with single-pass structured order routing enabled
eng = ValricoEngine.load("eppingt/Valrico-400M-v3", enable_order_extractor=True)

# 2. Optional per-workflow calibration (from k = 10-20 labelled decisions) + missing-field guard
cal = WorkflowCalibrator()
# cal.fit_workflow("approvals", abstain_items=[...], yes_items=[...], option_items=[...], temp_items=[...])

eng = ValricoEngine.load(
    "eppingt/Valrico-400M-v3",
    calibrator=cal,
    field_guard=FieldPresenceGuard(),
    enable_order_extractor=True,
    min_margin=0.15,  # optional human-review escalation when abstain_index is given
)

res = eng.decide(
    record="Request: REQ-901\nAmount: 450.00\nApprover: TBD",
    question="Policy: approve only when an assigned approver signed off. Approve?",
    options=["Approve", "Deny", "Cannot tell"],
    record_type="Approval request",
    workflow="approvals",
    abstain_index=2,
    required_fields=["approver", "amount"],
)
# res -> {"route": "abstain_missing_field", "answer": 2, "probs": ..., "margin": ..., "v2_probs": ...}

Offline / air-gapped usage

Valrico-400M-v3 runs 100% locally with zero network egress:

  • FieldPresenceGuard, single-pass order routing, and pre-fitted WorkflowCalibrator JSON files (~2 KB fitted offline from k = 10–20 examples) require no external API calls.
  • When min_confidence or min_margin triggers (route = "abstain_low_confidence"), ValricoEngine returns answer = abstain_index alongside the true probs, margin, and original_answer so offline workflows can fail safe to human review or log uncertain items for deferred batch audit.
  • For domain-specific workflows without labelled policy tuning, fit_head.py and WorkflowCalibrator support lightweight local adaptation.

Evaluation Summary

1. Base Valrico-400M-v2 public benchmarks (weights unchanged)

Benchmark Valrico-400M-v2 (zero-shot)
Typed-decisions benchmark (public test) 0.642 (Choice 0.597, Yes/No 0.788, Score 0.566)
Holistic judgement suite (2,000 items) 0.676 / ECE 0.121
Held-out daily-use panel (12 public sources) 0.706 / ECE 0.080 (Abstention 0.514, Reworded 0.701)
Decision Index 0.3 (public suite) 19.90

2. Structured order extraction & routing

Evaluated on a held-out synthetic order suite (1,367 records / 13,071 questions across json, kv, table, bullets, and prose layouts, with 10,000-draw record-clustered bootstrap and zero overlap with extractor training records):

Evaluation Metric Measured
Order accuracy (n = 11,425 answerable rows) v3 vs v2 accuracy 0.9779 vs 0.6405 (+0.3374, 95% CI [0.3233, 0.3517])
Flip consistency (3,000 paired flips) Both-correct rate 0.9567 vs 0.4263 (95% CI [0.9453, 0.9670])
Routed precision & coverage Accuracy / coverage / harm 1.000 (10,817 / 10,817), Wilson lower 0.9996, 94.7% coverage, 0 harm, 0 conflicting records
Coverage by rendering (1.000 routed acc on each) json / kv / table / bullets / prose 0.9816 / 0.9790 / 0.9790 / 0.9768 / 0.8175
Missing / removed order totals (n = 1,046 / 600) False routes / accuracy 0 routes; accuracy 0.5956 / 0.6150 (identical to base v2)
Held-out non-order guard (10,652 rows, 3 workflows) False routes 0 / 10,652
Broad non-order safety sweep (157,293 rows, 22 sets) False routes / wrong 0 / 157,293 (2,304 truncated long records cleanly skipped)
Order-like adjacent workflows (6,013 ops + 900 judgement rows) False routes / harm 0 routes, 0 harm (falls back to base v2)

3. Serving parity, latency & optional engine modes

  • Base-probability identity (169,105 rows across 24 datasets): 169,105 / 169,105 byte-identical v2_probs (0.0 max hook deviation).
  • Single-pass latency overhead (GPU p50, order extraction enabled): 1.108Γ— at batch N = 1, 1.102Γ— at N = 10, and 1.080Γ— at N = 50, with identical peak GPU memory to base valrico.py.
  • GPU bf16 vs CPU fp32 assembly parity (1,000 records): 995 / 1,000 (99.5%) identical assembled JSON, 1,000 / 1,000 route agreement, 999 / 1,000 answer agreement.
  • Per-record extraction deduplication (dedup_records=True, 6,528 rows): Reduces cross-question JSON inconsistencies across multi-question records from 92 / 3,404 β†’ 5 / 3,404, with 0 extracted errors and 6,528 / 6,528 v2_probs equality (kept opt-in, default=False).
  • Option-order symmetrization (symmetrize=True, 3,760 rows across 7 domains): Kept opt-in (default=False). Improves multi-option choice accuracy (0.9615 β†’ 0.9646) and abstention balanced accuracy (0.7777 β†’ 0.7980), but lowers binary Yes/No flip consistency (0.9679 β†’ 0.9409) and worsens ECE (0.0376 β†’ 0.0527) at ~`1.9Γ—latency because the base model was trained strictly with canonical["false", "true"]` option ordering; use on 3+ choice workflows only.

4. Per-workflow calibration (WorkflowCalibrator, k = 20 cross-fitted across 7 domains)

  • Shifted workflow offsets (k = 0 β†’ k = 20 balanced accuracy): approvals abstention 0.5244 β†’ 0.6257 (+0.101), support abstention 0.6261 β†’ 0.6995 (+0.073), retrieval abstention 0.8831 β†’ 0.9421 (+0.059), and retrieval flip consistency 0.7672 β†’ 0.8103 (+0.043); well-calibrated domains (security, code_review, moderation) shift by <= 0.02.
  • Multi-class option_biases + scalar temperature (k = 20 50-split cross-fit): 10-bin ECE drops across all 7 domains (raw β†’ calibrated): approvals 0.0243 β†’ 0.0183, code_review 0.0223 β†’ 0.0168, moderation 0.1054 β†’ 0.0852 (option_biases alone 0.0786, balanced acc 0.8225 β†’ 0.8469), retrieval 0.0475 β†’ 0.0000, security 0.0183 β†’ 0.0008, support 0.0606 β†’ 0.0555 (option_biases alone 0.0507, balanced acc 0.9809 β†’ 0.9833), and tools 0.0487 β†’ 0.0076.

Scope & Limitations

  • Order extractor scope: Built for labelled, Key: value, JSON, pipe/table, and prose order records using closed-form numeric, date, and line-item questions. Unlabelled fixed-width/positional grids with omitted field labels and non-order operational workflows are out of scope and fall back to the base model.
  • Per-workflow calibration requires k = 10–20 labelled decisions per workflow; when a workflow has no calibration entry, base Valrico-400M-v2 logits are unchanged.
  • Field-presence abstention fires only on structured records when callers supply required_fields and an explicit abstain_index.
  • Inherits Valrico-400M-v2 limitations: English-only, 2,048-token max sequence length, policy must be stated in the question, free-text multi-step reasoning is weak, and not intended for consequential decisions without human review.

License

Copyright (c) 2026 Timothy Epping. Released under the Apache License 2.0 (with NOTICE passing on Ettin's MIT notice and training-data attributions).

Downloads last month
22
Safetensors
Model size
0.4B params
Tensor type
F32
Β·
Inference Providers NEW
This model isn't deployed by any Inference Provider. πŸ™‹ Ask for provider support

Model tree for eppingt/Valrico-400M-v3

Finetuned
(39)
this model