Programming with Data: Test-Driven Data Engineering for Self-Improving LLMs from Raw Corpora

Chenkai Pan, Xinglong Xu, Yuhang Xu, Yujun Wu, Siyuan Li, Jintao Chen, Conghui He, Jingxuan Wei, Cheng TanarXiv 2026

TL;DR

The paper introduces Programming with Data (ProDa), a paradigm that treats LLM data engineering like software development using Test-Driven Development (TDD) principles. By linking training data and evaluation through a shared, structured knowledge base, ProDa enables a closed-loop "compile-test-debug" cycle where model failures can be precisely traced to data deficits and fixed with targeted patches.

What Problem Does This Paper Address?

Domain-specific fine-tuning for Large Language Models (LLMs) is currently an "open-loop" process. When a fine-tuned model fails a task, misapplies a principle, or hallucinates, there is no structural link between the evaluation benchmark and the training data.

Because practitioners cannot diagnose why or where the data failed the model, they resort to "undirected augmentation"—blindly throwing more data at the model. This approach is computationally expensive, poorly interpretable, and offers no structural guarantee of improvement. The authors address this by creating a shared representation that links training data and evaluation at the knowledge level.

Figure 2: From open-loop data engineering to Programming with Data. a, The pre-training playbook breaks for domain fine-tuning because failures cannot be traced back to data without a shared struc- ture. b, Software engineering solved this by deriving code and tests from a shared specification. c, Programming with Data applies the same principle, using a shared knowledge structure to close the loop between training data and evaluation. d, Formal correspondence between the two paradigms.

Methods

The authors introduce the ProDa framework, which operationalizes a closed-loop pipeline using three core components:

  1. The Builder (Knowledge Extraction & Synthesis): Extracts a three-level knowledge structure top-down from raw text: L1 Key Concepts (definitions), L2 Knowledge Relations (relational triples), and L3 Reasoning Chains (multi-step inferential pathways). It then synthesizes initial Supervised Fine-Tuning (SFT) data from L1 and L2 entries.
  2. The Tester (Benchmark Construction): Dynamically constructs reasoning-intensive benchmarks from L3 chains before training begins (adhering to the "test-first" principle). It injects adversarial distractors (e.g., reversing causality or swapping adjacent concepts) to ensure the model genuinely understands the logic rather than relying on simple elimination.
  3. The Debugger (Diagnosis & Repair): Treats benchmark failures like runtime errors. It classifies errors into concept gaps (missing/confused facts) or reasoning deficits (broken logical chains), traces them back to specific knowledge nodes, and generates targeted data patches (knowledge-reinforcement or chain-of-thought samples) for the next training cycle.

This entire lifecycle is governed by the CORE principle: Contextualized within document scope, Organized into stratified layers, Rigorous in enforcing non-overlap, and Evolving through iterative feedback.

Datasets

The authors introduce ProDaLib, a comprehensive resource suite spanning 16 disciplines across the natural sciences, engineering, biomedicine, and social sciences. It contains:

  • 227,869 atomic concepts (L1)
  • 186,784 relational statements (L2)
  • 43,953 reasoning chains (L3)
  • 16,000 evaluation items (forming the ProDa-16 benchmark)
  • 160,000 synthesized training samples

To validate construct validity, the ProDa-16 benchmark was evaluated against 11 established international benchmarks (including GPQA, MMLU-Pro, and GSM8K), demonstrating strong statistical consistency ($\rho = 0.847$).

Key Insights and Ideas

  • Data as Code: By viewing training data as source code, model training as compilation, and benchmarks as unit tests, data engineering shifts from an artisanal craft to a rigorous, traceable discipline.
  • Top-Down Extraction Eliminates Orphans: Extracting L3 reasoning chains first and decomposing them down to L1 concepts ensures a 0% "orphan rate." Every single concept in the training data is guaranteed to be reachable and testable by the benchmark.
  • The Static Synthesis Ceiling: A single round of static data injection (V1) inevitably leaves conceptual blind spots. Overcoming this ceiling requires a dynamic, feedback-driven debugging loop (V2) to address model-specific errors.
  • Debugging Restores General Capabilities: Targeted data patching doesn't just fix domain errors; it actively mitigates catastrophic forgetting, recovering general capability losses (measured via MMLU and C-Eval) introduced during the initial fine-tuning phase.

Key Results

  • Consistent Scaling Gains: Iterative data debugging yielded performance improvements across all tested model families (Llama-3.1, Qwen-2.5, Qwen-3) and parameter scales (3B to 32B), with no exceptions.
  • Surpassing Frontier Models: After just a single round of data debugging, a ProDa-tuned 32B open-source base model achieved a 16-discipline average score that outperformed closed-source giants like GPT-5.4, Gemini-3-flash, and DeepSeek-v3.2.
  • Exceptional Sample Efficiency: Fine-tuning on merely 1K targeted repair samples (ProDa V2) achieved an average score of 68.72%, strictly outperforming peak baseline synthesis methods (Alpaca, EasyDataset, DataFlow) even when they used much larger data volumes (up to 10K samples).

Limitations and Future Work

  • Macro-level Architecture: The paper establishes the overarching blueprint for Programming with Data, but the authors note that each individual module (Builder, Tester, Debugger) represents an open research problem with room for optimization.
  • RAG Integration: A promising future direction is intersecting this paradigm with Retrieval-Augmented Generation (RAG) to better ground synthesized data in primary sources.
  • Mechanistic Interpretability: Combining ProDa's data-level tracing with mechanistic interpretability could unlock even finer-grained, weight-level model diagnostics and repairs.

Summary updated

BibTeX
@misc{pan2026programming,
  author = {Chenkai Pan and Xinglong Xu and Yuhang Xu and Yujun Wu and Siyuan Li and Jintao Chen and Conghui He and Jingxuan Wei and Cheng Tan},
  title = {{Programming with Data: Test-Driven Data Engineering for Self-Improving LLMs from Raw Corpora}},
  year = {2026},
  eprint = {2604.24819},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2604.24819},
}

Loading related content...

Figure