TL;DR
DataFoundry shifts LLM data quality control upstream by recursively optimizing the data preparation pipeline itself rather than filtering its outputs post-hoc. By using a modular "Skills-as-Modules" architecture to diagnose and adapt pipeline components on small pilot sets, it significantly improves the downstream utility of synthetic training data across specialized domains.
What Problem Does This Paper Address?
Domain adaptation for Large Language Models (LLMs) heavily relies on high-quality, specialized training data. Currently, most data-preparation pipelines use a "construction-then-filtering" paradigm: they generate a massive pool of synthetic data and then apply post-hoc filters to discard low-quality, redundant, or invalid samples—often throwing away 50% to 90% of the generated data.
This creates a fundamental mismatch: quality issues originate during the construction process, but quality control is only applied to the final outputs. Furthermore, existing data pipelines are typically implemented as long, hardcoded, standalone scripts, making it incredibly difficult to systematically diagnose which stage broke down or how to iteratively update them for highly technical domains like law, medicine, or finance.
Methods
The authors introduce DataFoundry, a framework that evolves data preparators via Recursive Self-Improvement (RSI) on a small pilot dataset before scaling up to full production.
DataFoundry structures a data preparator as an evolvable runtime specification using a Skills-as-Modules architecture. A central Controller (driven by an LLM coding agent) orchestrates three core modular skills in a recursive loop:
- Construction-Runtime-Compiler: Translates the pipeline specification into an executable runtime with stable, isolated component interfaces (
corpus_chunk_manager,instruction_builder,response_generator, andbatch_generation_service). - Contextualized-Data-Assessor: Generates a small pilot dataset and evaluates it against domain-specific criteria (e.g., factual grounding, self-containment, or numerical correctness) to produce a detailed deficiency report.
- Evolution-Adapter-Designer: Traces the diagnosed errors back to specific pipeline components and designs an "adapter" (modifying prompts, policies, or configurations) to fix the upstream behavior without breaking the overall system architecture.
Once the specification has evolved over $T$ rounds, it is compiled into a final domain-adapted runtime for large-scale data production.
Datasets
The framework was evaluated using the DataPrep-Bench suite across four specialized domains:
- Mathematics: Source text from 136 math documents; evaluated on benchmarks including GSM8K, AMC 2023, AIME 2024, MinervaMath, MATH-5000, Gaokao 2024, and OlympiadBench.
- Finance: Source text from 80 finance documents; evaluated on CPA-KQA, FinEval-KR, and XFinBench.
- Law: Source text from 53 law documents; evaluated on LegalBench and LexGLUE.
- Medicine: Source text from 154 medical documents; evaluated on MedCaseReasoning, MedMCQA, and MedR-Bench.
For downstream evaluation, models were fine-tuned on a general instruction-following dataset (Dolly-15k) mixed with the domain-specific data synthesized by the respective generators.
Key Insights and Ideas
- Fix the Factory, Not the Product: Shifting quality interventions upstream prevents the pipeline from repeatedly generating flawed data, resulting in highly optimized, domain-specific data generation recipes.
- The Danger of Over-Evolution: More optimization rounds do not always equal better data. The authors observed that data quality and downstream model performance peak at around 2 rounds of self-improvement. Beyond that, excessive evolution causes "specification collapse" or over-optimization, leading to performance degradation.
- Cross-Model Generalization: Datasets prepared by DataFoundry (using a frontier LLM backbone for the controller) provide transferable training utility. The data consistently improved downstream performance across entirely different model families (Qwen2.5 and Llama-3), proving the data's intrinsic quality isn't overfitted to a single model.
Key Results
When evaluating downstream performance on a Qwen2.5-7B base model, DataFoundry achieved the highest overall scores across all four specialized domains, outperforming the strongest baseline generators:
- Math: Reached an average score of 28.8 (outperforming the best baseline by 3.3 points).
- Finance: Reached an average score of 66.1 (outperforming baselines by 1.3 points).
- Law: Reached an average score of 78.6 (outperforming baselines by 1.4 points).
- Medicine: Reached an average score of 46.0 (outperforming baselines by 2.2 points).
Ablation studies on a Llama-3.1-8B base model confirmed these gains, with DataFoundry outperforming competing data generators by 2.6, 4.8, and 3.8 points in Math, Finance, and Medicine, respectively.
Limitations and Future Work
- Sensitivity to Optimization Rounds: Because performance degrades after 2 rounds of recursive self-improvement, the framework requires careful early stopping or stronger regularization techniques to prevent the agent from introducing counterproductive pipeline modifications.
- Dependency on Strong Controller Models: The success of the framework relies heavily on the reasoning capability of the frontier LLM acting as the central controller. Future work is needed to explore how well smaller, open-source models can handle the complex task of pipeline diagnosis and adapter design.
Summary updated