Programming with Data: Test-Driven Data Engineering for Self-Improving LLMs from Raw Corpora
| Authors | Chenkai Pan et al. |
| Year | 2026 |
| HF Upvotes | 84 |
| arXiv | 2604.24819 |
| Download | |
| Code | https://github.com/OpenRaiser/ProDa |
Abstract
Reliably transferring specialized human knowledge from text into large language models remains a fundamental challenge in artificial intelligence. Fine-tuning on domain corpora has enabled substantial capability gains, but the process operates without feedback: when a model fails on a domain task, there is no method to diagnose what is deficient in the training data, and the only recourse is to add more data indiscriminately. Here we show that when a structured knowledge representation extracted from the source corpus serves as the shared foundation for both training data and evaluation, the complete data-engineering lifecycle maps onto the software development lifecycle in a precise and operative way: training data becomes source code specifying what the model should learn, model training becomes compilation, benchmarking becomes unit testing, and failure-driven data repair becomes debugging. Under this correspondence, model failures decompose into concept-level gaps and reasoning-chain breaks that can be traced back to specific deficiencies in the data and repaired through targeted patches, with each repair cycle producing consistent improvements across model scales and architectures without degrading general capabilities. We formalize this principle as Programming with Data and instantiate it across sixteen disciplines spanning the natural sciences, engineering, biomedicine, and the social sciences, releasing a structured knowledge base, benchmark suite, and training corpus as open resources. By demonstrating that the relationship between training data and model behaviour is structurally traceable and systematically repairable, this work establishes a principled foundation for the reliable engineering of human expertise into language models.
Engineering Breakdown
Plain English
This paper addresses a critical gap in domain-specific LLM fine-tuning: the lack of diagnostic feedback when models fail on specialized tasks. The authors propose mapping the data-engineering lifecycle onto the software development lifecycle by using a structured knowledge representation extracted from source corpora as the foundation for both training data and evaluation. This approach enables engineers to treat training data like source code—where failures can be traced back to specific deficiencies in the training corpus rather than requiring blind, indiscriminate data expansion. The key insight is that structured knowledge acts as a shared contract between data quality (what the model should learn) and evaluation (whether it learned it), enabling systematic diagnosis and iterative improvement of domain adaptation.
Core Technical Contribution
The core novelty is reframing domain fine-tuning as a software engineering problem by establishing a structured knowledge representation as the single source of truth for both training and evaluation. Rather than the current practice of fine-tuning on domain corpora with no feedback mechanism, the authors introduce a closed-loop system where model failures map directly to gaps or errors in the structured knowledge base. This transforms domain adaptation from a trial-and-error process into a debuggable pipeline with clear cause-and-effect relationships. The technical contribution is showing that this mapping is 'precise and operative'—meaning it's not just conceptually sound but practically implementable with clear semantics for what constitutes a training failure and how to remediate it.
How It Works
The approach begins by extracting a structured knowledge representation from the domain corpus—this could be a knowledge graph, ontology, or other machine-readable format that captures the semantic content the model should learn. This structured representation serves as the foundation layer. Training data is then generated from or aligned with this representation, becoming declarative specifications of what the model must learn (analogous to source code specifying program behavior). Separately, evaluation tasks and metrics are derived from the same structured knowledge, ensuring that tests measure whether the model has internalized the intended knowledge. When a model fails on an evaluation task, engineers can trace the failure back through the knowledge representation to identify whether the problem is: (1) missing knowledge in the structured representation, (2) insufficient or poor-quality training examples derived from that knowledge, or (3) an actual model learning failure. This diagnostic capability enables targeted data augmentation rather than bulk addition, substantially reducing data-engineering overhead.
Production Impact
In production, this approach converts domain fine-tuning from a black-box tuning problem into a systematic, debuggable engineering process. Teams can now maintain domain knowledge as a versioned artifact (like code), track which model failures correspond to which knowledge gaps, and implement a proper code-review cycle for domain data changes. This reduces wasted effort: instead of training researchers adding 10,000 random domain examples hoping for improvement, they can add targeted examples addressing specific evaluation failures. The trade-off is upfront cost: extracting or building the structured knowledge representation requires domain expertise and tooling, and maintaining it over time adds overhead analogous to maintaining source code. Latency and compute costs are likely reduced (fewer overfitting iterations, more targeted training data), but the approach requires existing domain expertise to build the initial knowledge structure—it cannot extract knowledge from unstructured corpora automatically. For teams with clear domain specifications or regulatory requirements (legal, medical, financial), this approach is transformative; for broad, open-domain tasks it is less applicable.
Limitations and When Not to Use This
The paper assumes that domain knowledge can be meaningfully represented in a structured format—but many domains have tacit, ill-defined, or rapidly evolving knowledge that resists formalization. The approach requires upfront investment in knowledge engineering, which may not be economical for domains with limited data or unclear requirements. The paper does not address how to handle knowledge representation errors: if the structured knowledge itself is incomplete or incorrect, the entire pipeline inherits those flaws (garbage in, garbage out). Additionally, the abstract does not detail how the approach scales to massive domains (hundreds of thousands of concepts) or how it handles knowledge that is ambiguous, contradictory, or context-dependent. There is also an open question about whether structured knowledge extraction from text is itself reliable enough to serve as the foundation for this closed-loop system, or whether it requires manual curation.
Research Context
This work builds on longstanding research in knowledge-based machine learning and data-centric AI, particularly recent work showing that training data quality often matters more than quantity or model size. It also draws from software engineering practices (version control, testing, debugging) that have proven essential for maintaining complex systems at scale. The paper likely improves upon prior domain fine-tuning work (e.g., domain-specific BERT, adapter modules, LoRA-style approaches) by adding systematic evaluation and diagnostic feedback—prior work fine-tunes but lacks the closed-loop verification mechanism. This opens a research direction toward treating LLM training as a software-like process with formal specifications, testing frameworks, and regression detection, potentially bridging AI research and software engineering practices in novel ways.
:::tip Subscribe Get weekly breakdowns of papers like this in AI Letters - the newsletter for engineers building production AI systems. :::
