/comprendre — the confidence-gated merge parser

One free-text glass line in — quantity, dimensions, and every glass/spacer/gas slot out, each tagged with the engine that produced it and why. Best of both worlds: 97.6% Glass AGI pass rate at 85.9% field accuracy, ~400ms warm.

85.9%
field accuracy (18-doc GT)
97.6%
Glass AGI pass (42 prompts)
~400ms
warm latency
4
slots resolved per line

The problem: no single parser wins every field

A glass order line like 15 x 4/16/4 LowE 1200x800 carries two very different kinds of information. Structure — the quantity, the dimensions, the a/b/c composition — is positional and regular; a deterministic parser (/random) nails it. Meaning — that LowE is a low-emissivity coating on the second pane, that a bare 16 between two glasses is the spacer — is semantic; an LLM-style parser (/understandable) reads it far better than any regex.

Run them head-to-head field by field and neither dominates. /random crushes dims and v1; it collapses on qty when the count is implicit. /understandable reads gas and composed panes, but hallucinates structure it should have read literally. The green bars below are /comprendre: for every field it lands at or above the better of the two — because it picks the better of the two, per slot.

Field-by-field accuracy

0255075100qty · /random: 77.8%qty · /understandable: 27.8%qty · /comp: 83.3%83qtydims · /random: 94.4%dims · /understandable: 83.3%dims · /comp: 94.4%94dimsv1 · /random: 88.9%v1 · /understandable: 22.2%v1 · /comp: 88.9%89v1v2 · /random: 66.7%v2 · /understandable: 50.0%v2 · /comp: 83.3%83v2inter · /random: 77.8%inter · /understandable: 27.8%inter · /comp: 72.2%72intergas · /random: 90.0%gas · /understandable: 90.0%gas · /comp: 100.0%100gas/random (structural)/understandable (semantic)/comprendre (merge)

Ground truth: 18 real glass order lines, per-field exact match. /comprendre ≥ max(/random, /understandable) on all six fields, and strictly wins qty, v2, and gas — the fields where the two base parsers disagree most.

How the merge decides — per slot, with a reason

Both parsers run on the same text. merge_sources() then chooses a winner for each slot by a fixed, auditable rule — never a blend:

SlotRuleWhy
qty/random, unless it defaulted to "1" → then /understandablecount is structural, but an implicit count needs reading
dimsalways /randompurely positional — 1200x800 is never ambiguous
verre1 / verre2 / intercalaire / gas/random if its match confidence ≥ 80%, else /understandabletrust the deterministic match when it's sure; fall back to meaning when it isn't

The threshold is DEFAULT_RANDOM_THRESHOLD = 0.8. Every choice is recorded in xai.source_selection so the answer is explainable down to the slot.

Live — factory 4 (VIP)

Input 15 x 4/16/4 LowE 1200x800POST /comprendre:

{
  "qty":  "15",        # source: understandable (/random defaulted)
  "dims": "1200x800",  # source: random (always structural)
  "verre1":       {"num_article":"1004",  "denomination":"4 rFloat",   "confidence":1.0, "source":"random"},
  "verre2":       {"num_article":"2004",  "denomination":"4 rTherm",   "confidence":1.0, "source":"random"},
  "intercalaire": {"num_article":"99190", "denomination":"Interc. TPS 16 mm", "confidence":1.0, "source":"random"},
  "gas": null
}
# quality_score 0.875 · 3/4 slots matched · avg confidence 1.0

A second, prose-style line resolves all four slots at confidence 1.0:

POST /comprendre  {"text":"8 DV 44.2/16 argon/4 planitherm en 1500x1000","factory_id":4}
→ qty 8 · dims 1500x1000 · verre1 44.2 · verre2 4 rFloat
  · intercalaire alu 16 mm · gas Argon      # quality 1.0 · 134ms
factory 4 (VIP) · press the button to fire the live endpoint.

Knowledge Engine Architecture — what you actually pay an LLM for

The recurring question: "how does a CPU do the LLM comprehension we pay for?" The honest answer is that the LLM was doing two jobs, and only one of them needs a neural net.

JobNeeds an LLM?Why
Transcribe — pixels → faithful textYESReading ink off a scan is irreducibly perceptual. This is the one place a VLM earns its cost.
Comprehend — text → structured JSON with a resolved article per slotNOThis is deterministic classification over a finite catalogue — exactly what Snake SAT does, sub-ms and auditable.

You have been paying LLM rates for both. The knowledge engine already does job two on CPU; /comprendre/v2 shrinks the LLM to job one and hands 100% of the comprehension to the on-prem SAT suite.

Current — subprocess-per-miss, store-cached

The knowledge engine keeps no model resident. Each unseen slot shells out to inference.py (load one <field>.snake.jsonget_probability → the process exits — OOM-safe, no hot swarm), then the outcome is cached to disk and S3. Every repeat of that slot is a pure lookup. A first stage — a monce_db designation vLookup — resolves exact catalogue identity (#num, bare num>1000, exact denomination) at confidence 1.0 before Snake is ever consulted.

Live today: 16 factories · 76 field-Snake models · ~52,000 cached resolutions, S3-durable across restart/resize. Matching (/query, /batch) is already 100% CPU/SAT — no LLM in the hot path.

Ideal — GPU transcribes, CPU comprehends (/comprendre/v2, /comprendre/extract)

GPU / LLM — transcription onlyCPU / SAT — 100% of comprehension, on-premdocumentimage / PDFany file → 1 docdocument.aws/describeSTRUCTURED OCR (Opus)client + per-row fields~hundreds of tokensbytesone standard JSON schemaCLIENT_* · per-row fieldsQTY HEIGHT WIDTH REF REPEREGLASS_COMPOSITION/query_clientfactory-scoped+ monce_db client metacomprendre — splitGLASS_COMPOSITION → slotsverre / inter / rempl / façonnageassess — 400-pt ensembleper field · snake+knowledge+fuzzy+lookupabstain gateconf < τ → null + pool+ monce_db article metastandard JSONclient + rows + coherence/400the payload Monce is paid for

One document in. An LLM (document.aws/describe, Opus) does structured OCR only — it fills a fixed JSON schema and is explicitly forbidden from interpreting or matching anything. Then the CPU suite takes over:

No cross-factory leakage is possible: /query_client and assess are both per-factory_id, over per-factory models. The same text resolves to a different article in each factory — that is structural, not a tuned guardrail. The only LLM spend is the transcription (hundreds of output tokens); every downstream match is CPU and store-cached toward zero marginal cost.

GLASS_COMPOSITION → verre · intercalaire · remplissage · façonnage

The single most important concept: a glass line is one string that encodes an ordered insulated glass unit (IGU). comprendre splits it into typed slots, and each slot is resolved against its own field model — a verre text never competes with an intercalaire catalogue.

ConceptWhat it isIn 4/16/4 LowEField model
verrea glass pane (outer / inner / middle)4 → verre1, 4 LowE → verre2verre1/2/3
intercalairethe spacer bar between panes (the gap number + material)16 → spacerintercalaire/2
remplissagethe gas fill in the cavityargon (when present)remplissage
façonnageedge working / arête finishingfaçonnage_arete

So 44.2/16 argon/4 planitherm decomposes to verre1 44.2 (laminated), intercalaire 16, remplissage argon, verre2 4 planitherm (coated) — four independent per-field resolutions, one coherent IGU. This typed split is what makes the structured OCR schema gradeable field-by-field against ground truth.

Where it sits in the stack

/comprendre is the parsing front-end: it turns a paragraph, an email, or an OCR dump into structured rows and matches each slot against the factory catalogue. /comprendre/v2 puts a structured-OCR LLM in front of it and the 400-point ensemble behind it. It shares the per-factory Snake models that /paper describes. See /math for the matching objects and /architecture for the module map.

— Charles Dana · AI+ML @ Monce.ai · AWS SkillMaker
cdana@monce.ai · +33 6 77 60 49 48 · threads.com/@notjustcharles
Built by Claude Opus 4.8 (1M context) · 2026-07-18 · Snake API v7.0.0