Deterministic Validation Over Probabilistic Extraction: Production Document Pipelines for European Operations
Why naive LLM wrappers fail on multi-language RFQs, customs packets, BOMs, and ERP order intake—and the typed-schema, rule-checked, human-in-the-loop architecture that reaches sub-1% field error rates in 4-to-8-week fixed-fee pilots.
Contents
Abstract
Across European freight forwarding, manufacturing, and wholesale distribution, millions of commercial orders, customs packets, bills of materials (BOMs), and multi-line RFQs still arrive as unstructured email threads, scanned PDFs, and inconsistent supplier spreadsheets. Teams that deploy a bare large language model (LLM) over these documents typically hit a deceptive 85–90% demo accuracy—and then abandon the rollout because the remaining 10–15% consists of silent, plausible-looking financial and regulatory errors. This paper presents the four-stage production architecture Eldevia deploys for European operational teams: deterministic layout pre-parsing, typed JSON-schema extraction with page-level provenance, a deterministic business-rule and ERP master-data verification gate, and an exception-only operator review queue. By treating the LLM strictly as a candidate parser and delegating numerical, regulatory, and catalog truth to deterministic code, production pipelines routinely hold field-level error rates below 1% while cutting operator handling time by 65–85%.
Key Engineering Takeaways
- Probabilistic models should never own arithmetic or catalog truth: Every extracted subtotal, VAT rate, weight sum, Incoterms rule, SKU, or HS tariff code must be verified by deterministic code against ERP master records before a draft reaches an operator.
- European locale variance breaks generic US wrappers: Mixed decimal separators (
1.250,00vs1,250.00), multi-language headers (PL/LT/DE/EN in a single shipment packet), and non-standard scanned CMR tables require layout-aware preprocessing and explicit unit normalization. - Exception-only routing beats "human reads everything": Operators should never re-read 40 clean line items; the UI should highlight only the 2 fields where schema confidence or a deterministic invariant failed, linked straight to the source PDF bounding box.
- Read-only shadow mode eliminates ERP rollout risk: Every production deployment begins with 1–2 weeks of read-only execution against live incoming documents, comparing machine drafts against completed human entries before enabling ERP write APIs.
1. Why Naive LLM Document Wrappers Fail in Production
When an engineering or operations team runs a quick proof-of-concept by uploading ten supplier PDFs to a frontier model with a prompt like "extract all order lines as JSON," the output looks immediately impressive. On clean digital PDFs with ten rows, modern multimodal models frequently get 90% of fields right on the first try.
In real European mid-market operations—a customs brokerage clearing 400 shipments a day, a steel or components distributor quoting 80-line engineering BOMs, or a medical wholesale desk reconciling supplier invoices—that remaining 10% is not random noise. It concentrates in five repeatable failure modes that erode operator trust within the first week:
| Failure Mode | Typical Trigger in EU Ops | Operational Consequence |
|---|---|---|
| Locale & Unit Drift | Mixed 1.450,50 (DE/PL) and 1,450.50 (UK/US); packs vs pieces vs pallets | 10× or 1,000× quantity errors silently drafted into ERP orders |
| Multi-Page Row Truncation | 60+ line BOMs or packing lists spanning 4–12 PDF pages with repeated headers | Model skips rows 38–42 without raising an error; invoice totals no longer reconcile |
| Plausible Code Hallucination | Blurry scan of an 8-digit HS/CN tariff code or internal SAP material number | Customs hold at border or wrong component shipped; looks syntactically valid |
| Email-vs-Attachment Contradiction | Email body says "use the revised delivery date from Friday, ignore column D" | Attachment-only OCR misses commercial override written in the email thread |
| Unflagged Missing Fields | Missing Incoterms, unstated currency, or expired supplier certificate | Model guesses the most common default instead of routing to an exception queue |
Once an operator discovers two silent hallucinations in a batch of twenty orders, human psychology takes over: the operator stops trusting the automation and re-checks every single cell from scratch. At that point, the AI system becomes slower than manual re-keying and gets quietly turned off.
2. The Four-Stage Production Architecture
The architectural shift that solves this is simple in principle and strict in execution: separate probabilistic reading from deterministic verification. The language model's only job is to read messy human artifacts and emit structured candidates with exact source coordinates. Deterministic code decides whether the candidate is mathematically, structurally, and commercially valid.
Incoming Packet (Email + PDFs + Excel + Scans)
│
▼
[Stage 1: Deterministic Ingestion & Normalization]
• Thread-to-attachment binding (email body + attachments as one packet)
• Native PDF text/table extraction + OCR fallback with page & bbox coordinates
• Document classification & split (commercial invoice vs packing list vs CMR vs email)
│
▼
[Stage 2: Strict Typed-Schema LLM Extraction]
• Constrained JSON schema (zero free-form prose, nullable fields instead of guesses)
• Per-field source_page + verbatim source_quote provenance
• Document-chunked extraction for 50+ line tables to prevent output truncation
│
▼
[Stage 3: Deterministic Verification & ERP Cross-Check Gate]
• Arithmetic invariants: sum(qty * unit_price) == net_total; net + vat == gross; sum(weights) == gross_kg
• Master-data lookups: exact SKU / customer / HS code match against read-only ERP mirror
• Policy rules: credit limit, Incoterms completeness, margin floor, date sanity
│
├── ALL INVARIANTS PASS ──► Draft Order / Structured Payload Ready (or auto-post within cap)
│
└── ANY CHECK FAILS ──────► [Stage 4: Exception-Only Operator Queue]
• Only flagged fields highlighted next to cropped PDF source
• One-click approve / edit / request clarification email draft
• Every human correction logged as a regression test case2.1 Stage 1: Packet-Level Ingestion, Not File-Level OCR
Real operational inputs rarely arrive as a single clean PDF. A typical European logistics or wholesale inquiry consists of an email thread in Lithuanian, Polish, or English, two vendor PDFs, and a modified Excel quote. Processing attachments in isolation loses critical commercial instructions contained in the email body (such as partial shipment splits, urgent delivery windows, or explicit price overrides).
Stage 1 normalizes the entire communication into an immutable packet with stable identifiers, separating native vector PDFs (where exact text and cell coordinates can be read deterministically without OCR loss) from raster scans (which route through high-accuracy vision/OCR while preserving page-level bounding boxes).
2.2 Stage 2: Strict Typed Schemas with Null-Over-Guess Discipline
Every extraction call enforces a strict JSON schema with explicit null semantics and required provenance pointers (source_file, page, raw_text). Crucially, the schema separates raw extracted strings (e.g., raw_amount: "1.450,00 EUR") from normalized values (amount: 1450.00, currency: "EUR"). Keeping both makes locale bugs immediately auditable in Stage 3.
For long BOMs or packing lists (over 35 line items), the pipeline chunks extraction by page range with overlapping table headers rather than asking a single completion to emit 200 rows—eliminating middle-of-table skips and output-token exhaustion.
2.3 Stage 3: Deterministic Invariants as the Source of Truth
Stage 3 is pure, unit-tested application code (TypeScript or Rust) with zero LLM involvement. It runs three classes of checks on every extracted packet:
- Mathematical Conservation Checks: Does the sum of line-item totals match the printed invoice subtotal within €0.02? Does
net + VATequalgross? Does the sum of per-pallet weights match the header gross weight on the CMR? If even one row was missed by Stage 2, the conservation check fails deterministically and flags the exact page for re-extraction or operator review. - ERP / Master-Data Referential Integrity: Every extracted part code, customer VAT ID, warehouse code, and currency is checked against a read-only replica of the company's ERP (SAP, Microsoft Dynamics, Navision, Rivile, Optima, or custom SQL). Near-matches (e.g., an OCR confusion between
0andOin a part code) are surfaced as explicit candidate suggestions rather than silently accepted. - Commercial & Compliance Policy Rules: Required customs fields for non-EU origin shipments, valid ADR hazard classifications, missing delivery addresses, or supplier price variances above ±3% vs contracted price lists automatically trigger a named exception code.
2.4 Stage 4: Exception-Only Human-in-the-Loop
Instead of forcing operators to proofread an entire 30-field form, the review screen shows green checkmarks for deterministically reconciled fields and focuses human attention exclusively on flagged discrepancies, side-by-side with the highlighted crop of the source document. Where the buyer or supplier sent incomplete data—which accounts for 15–30% of real inbound European RFQs—the system drafts a concise, plain-text clarification message listing the exact missing tolerances or codes for one-click approval.
3. Production Unit Economics and Latency Budgets
A common executive objection to AI document pipelines is unpredictable token spend. In practice, disciplined model tiering keeps inference costs orders of magnitude below manual labor costs:
| Pipeline Stage | Execution Tier | Typical Latency / Packet | Cost per 1,000 Packets |
|---|---|---|---|
| Layout Parse & Classification | Deterministic PDF parser + fast vision/classifier | 0.4 – 1.8 s | €1 – €4 |
| Typed-Schema Extraction | Fast structured model (cached static prompt prefix) | 2.5 – 6.0 s | €8 – €28 |
| Deterministic ERP & Math Gate | Local TypeScript / Rust rules engine | < 50 ms | ~€0 (included in host) |
| Ambiguous Dispute Escalation (5–10%) | Frontier reasoning model (triggered on failed check only) | 6 – 14 s (subset only) | €6 – €18 |
At €15–€50 per 1,000 multi-page packets—roughly €0.02–€0.05 per order—inference cost is negligible compared to 8–18 minutes of skilled operations staff time per packet (€3–€10 in loaded EU labor cost). The real economic lever is exception rate reduction: every recurring supplier format converted into a deterministic rule or verified alias pushes straight-through accuracy higher and shrinks the operator queue.
4. Read-Only Shadow Mode: Zero-Risk Pilot Validation
No operations director should grant an untested AI system write access to SAP, Navision, or customs filing software. Every Eldevia document pilot follows a three-phase rollout bounded to 4–8 weeks at a fixed fee:
- Week 1–2 (Historical Corpus Benchmark): Build the schema, parser, and deterministic checks against 50–100 historical anonymized packets and their ground-truth ERP records. Establish exact baseline field accuracy and failure taxonomy.
- Week 3–4 (Read-Only Live Shadow Mode): Mirror live inbound emails/PDFs into the pipeline with zero write permissions. Measure exact agreement against human-keyed ERP orders and log every discrepancy into an automated regression suite.
- Week 5–6 (Operator-Approved Draft Queue): Operators work from pre-filled, rule-verified drafts with highlighted exceptions. Only after the single agreed pilot metric is beaten (for example, ≥70% reduction in handling time at <0.5% post-review field error) does the organization decide whether to enable direct ERP posting within defined monetary thresholds.
5. Conclusion
Reliable operational AI in Europe is not a prompt-engineering exercise; it is a systems-engineering discipline. By confining probabilistic models to structured parsing with source citations, enforcing arithmetic and ERP truth in deterministic code, and routing only genuine anomalies to human operators, mid-market companies can remove hours of daily manual re-keying without sacrificing auditability or control.