CACHE-ED2: Compiling LLM Reasoning into Reusable Extraction Programs for Document Extraction at Scale
Abstract
Extracting structured information from visually rich documents at enterprise scale demands both the reasoning capability of large language models and the efficiency of deterministic execution. Current approaches either deploy LLMs as instance-level analysts, incurring per-document inference costs that are prohibitive for repetitive templates, or rely on manually authored vendor-specific prompts that do not scale beyond a handful of high-volume vendors. We present CACHE-ED2, a framework that repositions the LLM as a system-level developer: given a novel document format, a multimodal ReAct-based agent synthesizes a reusable Document Extraction DSL (DocExDSL) program encoding the complete extraction logic (strategies, disambiguation, transforms, and automated reasoning validation), then caches it for deterministic, LLM-free execution on all subsequent documents of the same format. A contrastive Document Format Encoder routes incoming documents to cached programs with perfect hit rates, and a HITL Feedback Analysis Agent incorporates analyst corrections to refine programs over time. On public benchmarks (CORD v2, FATURA) and 5,000 real-world invoices across 5 vendors, CACHE-ED2 achieves near-perfect extraction accuracy (0.99 average) with 1.0 extraction rate and perfect format detection across 50+ templates, matching or exceeding manually authored vendor-specific prompts, while reducing cumulative token consumption by ~2.6x over 1,000 documents.