Authors’ overview
The rapidly growing demand for high-quality data in Large Language Models (LLMs) has intensified the need for scalable, reliable, and semantically rich data preparation pipelines. However, current practices remain dominated by ad-hoc scripts and loosely specified workflows, which lack principled abstractions, hinder reproducibility, and offer limited support for model-in-the-loop data generation. To address these challenges, we present DataFlow, a unified and extensible LLM-driven data preparation framework. DataFlow is designed with system-level abstractions that enable modular, reusable, and composable data transformations, and provides a PyTorch-style pipeline construction API for building debuggable and optimizable dataflows. The framework consists of nearly 200 reusable operators and six domain-general pipelines spanning text, mathematical reasoning, code, Text-to-SQL, agentic RAG, and large-scale knowledge extraction. To further improve usability, we introduce DataFlow-Agent, which automatically translates natural-language specifications into executable pipelines via operator synthesis, pipeline planning, and iterative verification. Across six representative use cases, DataFlow consistently improves downstream LLM performance. Our math, code, and text pipelines outperform curated human datasets and specialized synthetic baselines, achieving up to +3% execution accuracy in Text-to-SQL over SynSQL, +7% average improvements on code benchmarks, and 1—3 point gains on MATH, GSM8K, and AIME. Moreover, a unified 10K-sample dataset produced by DataFlow enables base models to surpass counterparts trained on 1M Infinity-Instruct data. These results demonstrate that DataFlow provides a practical and high-performance substrate for reliable, reproducible, and scalable LLM data preparation, and establishes a system-level foundation for future data-centric AI development.
Introduction
Large language models (LLMs) have rapidly evolved from research prototypes to foundational infrastructure across natural language processing and beyond. Since OpenAI introduced the GPT family through large-scale human annotation and ignited the era of large language models (LLMs), scaling-law studies have consistently demonstrated that data quality and quantity are central to model performance. As model scales continue to grow and downstream tasks become increasingly complex, the size and semantic diversity of training corpora have expanded dramatically. Modern LLM development now relies on multi-stage, semantics-heavy data preparation pipelines that integrate synthetic, refinement, filtering, and domain-specific transformation across trillions of tokens.
However, despite the critical role of high-quality data, data preparation for LLMs remains fragmented and largely unstandardized. Most practitioners still rely on ad-hoc scripts and loosely standardized workflows, which lack explicit dataflow abstractions, well-defined atomic operators, or any form of pipeline-level optimization. The absence of a unified and programmable paradigm makes pipelines difficult to reproduce, extend, or compare across projects. This problem is amplified by the trend toward increasingly fine-grained post-training tasks, such as instruction tuning, chain-of-thought generation, or function calling, where both the semantic richness and the semantic accuracy in data preparation are essential for achieving precise task-level model behavior.
In response to this fragmentation, several systems have recently emerged with the goal of standardizing LLM data curation. Frameworks such as NeMo Curator and Data-Juicer offer substantial functionality—including captioning, rewriting, classification, and multimodal processing—and have significantly improved the efficiency of large-scale corpus construction. Yet these systems remain fundamentally extraction- and filtering-oriented, and their abstractions provide limited support for expressing iterative, model-in-the-loop generative workflows with fine-grained semantic control. As a result, they are ill-suited for pipelines in which data synthesis and multi-step semantic refinement are central rather than auxiliary.
This limitation is becoming increasingly consequential. LLMs are no longer only consumers of data, but also producers. Because large-scale human annotation is prohibitively expensive, recent work heavily leverages LLM-based data synthesis workflows to construct high-quality corpora at scale. Multiple recent reports show that, in many regimes, carefully synthesized data can outperform even high-quality selected data, further underscoring the importance of LLM-driven generation workflows.
Motivated by this shift, we introduce DataFlow, a unified and automated LLM-driven framework for end-to-end LLM data preparation, with a DataFlow-Agent that allows users to compose pipelines directly from natural-language specifications. DataFlow places LLMs at the center of the operator ecosystem: most operators are LLM-driven, with a small number implemented using heuristics or small models. The framework provides over 180 operators organized into four categories—generation, evaluation, filtering, and refinement—and includes more than 90 reusable prompt templates that enable operator-level composition and consistent behavior across tasks. Using these primitives, DataFlow includes a set of state-of-the-art (SOTA) synthesis pipelines that span mathematical reasoning, raw text, code, Text-to-SQL, agentic RAG-style data, and large-scale QA extraction from web or PDF corpora. All pipelines are expressed within DataFlow’s common abstractions and require no task-specific glue code, adhering to a generate–evaluate–filter workflow augmented with targeted refinement stages.
Data in LLM Development
The development of LLMs involves several key stages, among which training is particularly crucial, as the model learns fundamental linguistic patterns from large-scale corpora. During this stage, the model is exposed to vast amounts of text data from various domains, enabling it to acquire a broad understanding of language.
Consequently, the quality and diversity of training data directly impact the model’s ability to generalize effectively across different contexts. Recently, the rapid development of large language models has brought about a substantial increase in the volume of training data. In this scenario, the quality and quantity of data become even more paramount.
High-quality data can significantly enhance model performance. As the volume of data increases, ensuring high data quality becomes more challenging, as it requires additional resources for data cleaning, selection, and annotation. Poor-quality data can cause models to learn incorrect patterns and produce inaccurate predictions. Furthermore, insufficient data diversity may result in models performing well in specific domains but exhibiting poor generalization in cross-domain tasks. Additionally, distributional shifts in the data can exacerbate model over-reliance on training distributions, diminishing their applicability in real-world scenarios.
Data Preparation for LLMs
As disclosed by the above discussion, data preparation is a crucial step in training LLMs, significantly impacting the model’s performance and generalization capabilities. With the continuous expansion of LLM scales, the complexity and efficiency of data preparation have become key research focuses. However, although systems like Apache Spark, Dask, and Hadoop are powerful for large-scale Extract–Transform–Load (ETL), they are not a good fit for modern LLM data preparation. These frameworks can, in principle, run semantic cleaning by calling LLMs or embedding models as user-defined functions, but they provide no native support for model-in-the-loop processing, GPU-efficient batching, or token-level text operations. More importantly, their built-in operators focus on structured data and offer very limited functionality for unstructured text, meaning that essential steps—such as tokenization, language detection, document segmentation, semantic deduplication, or safety filtering—must be implemented manually with ad-hoc User-Defined Functions (UDFs). This leads to significant overhead and engineering complexity, making general big-data engines inadequate for the large-scale, semantics-heavy pipelines required for LLM corpus construction.
LLM-based methods have been widely used in data quality evaluation and data selection. For instance, MoDS leverages DeBERTa for scoring and retaining high-quality data, while Alphagasus uses ChatGPT to score data accuracy. Other studies have employed GPT-4 for data rewriting and quality improvement. For a comprehensive overview, refer to the data for LLM survey.
Existing LLM Data Preparation Systems
NeMo Curator is an open-source, GPU-accelerated library from NVIDIA that offers modular pipelines for large-scale LLM data curation, including data download and extraction (e.g., Common Crawl, arXiv, Wikipedia), language identification, text cleaning, heuristic and learned quality filtering, domain and toxicity classification, document- and semantic-level deduplication, privacy filtering, and even synthetic data generation, all built on Dask/RAPIDS and designed to scale to multi-node, multi-GPU environments.
Data-Juicer is a “one-stop” data processing system that abstracts LLM data recipes into composable operators: the original system already provides 50+ operators for constructing and evaluating text data mixtures, while the 2.0 version extends this to 100+ operators across text, image, video, and audio, supporting analysis, cleaning, synthesis, annotation, and post-training data pipelines with tight integration to Ray and HuggingFace Datasets.
These systems substantially improve the efficiency and quality of LLM data preparation, but they remain largely configuration-centric toolkits. In contrast, our framework is built around a rich library of nearly 200 reusable text-specific operators, enabling fine-grained control over cleaning, transformation, synthesis, and evaluation; multiple pipelines instantiated from these operators consistently yield strong downstream gains, and even simple mixtures of data produced by different pipelines remain highly effective. Moreover, the system adopts a modular, PyTorch-style “building-block” design with lightweight, well-defined interfaces, making it natural for data agents to compose, orchestrate, and invoke data-processing pipelines programmatically.
Global Storage Abstraction and Operator Interaction
At the core of DataFlow’s execution substrate is a unified storage abstraction that maintains the canonical tabular representation of the dataset and mediates all data access during workflow execution. LLM-oriented data—such as instructions, responses, chain-of-thought traces, scores, and metadata—is naturally expressed as key–value fields associated with each sample, making a tabular structure a suitable and expressive organizational format. The storage layer decouples data management from operator logic, exposing a minimal, backend-agnostic API through the DataFlowStorage base class. This design allows custom storage backends—such as file-system, object-store, or database implementations—to be integrated without altering operator behavior.
Because operators operate only against this logical abstraction, they can be reordered, recomposed, or batched without modifying their internals, and improvements to the storage backend (e.g., adding distributed or database-backed implementations) require no operator-level changes. The default storage implementation uses a Pandas as the execution substrate and supports common input/output formats such as JSON, JSONL, CSV, and Parquet.
Prompt Template Interface
Prompts serve as the primary mechanism guiding LLMs to perform task-specific transformations. Every LLM-driven operator relies on a prompt, and operators that share the same high-level logic often differ only in subtle prompt variations. For instance, in Text-to-SQL generation, synthesizing queries for SQLite and MySQL involves identical operator logic; the only difference lies in minor syntax adjustments communicated through the prompt. To support such reuse while accommodating domain-specific variations, DataFlow decouples prompt construction from operator implementation through a dedicated prompt template interface.
A prompt template encapsulates a reusable prompt pattern and provides parameterized slots that operators populate at execution time. Each LLM-driven operator initializes its associated template during __init__, following the same configuration–execution paradigm as other system components. During execution, the operator invokes the template’s build_prompt method, which assembles task-relevant information—such as input fields, schema hints, or contextual metadata—into a concrete prompt that is subsequently passed to the LLM serving layer. This encapsulation allows the operator’s transformation logic to remain agnostic to how prompts are rendered.
To facilitate one-to-many mappings between operators and templates, LLM-driven operators expose a unified op.ALLOWED_PROMPTS interface that enumerates all compatible prompt templates. This design enables operators to be flexibly reused across domains or tasks by simply switching or tuning templates, without modifying operator logic.
Pipeline Composition Interface
The pipeline API adopts a PyTorch -like design in which the __init__ method handles resource allocation and operator configuration, while the method encodes a single pass of execution. Within forward, operator-specific key bindings implicitly define the dataflow topology, allowing pipelines to be constructed in a modular, readable, and IDE-friendly manner.
Functionally, the pipeline interface provides a built-in compile procedure that performs static analysis of the operator sequence prior to execution. During compilation, DataFlow extracts operator dependencies and parameters, constructs the corresponding DAG, and conducts key-level validation to detect missing fields, type inconsistencies, and malformed dependency chains. Instead of executing operators immediately, compile records all operator configurations and dependency information to produce a deferred execution plan. This deferred-construction design follows the Factory Method pattern, in which object creation is separated from object execution: the actual invocation of each operator’s run method is deferred until the subsequent forward call.
The compiled execution graph first provides complete structural information to the DataFlow-Agent, enabling it to surface all key- and dependency-related errors in a single report. This significantly reduces the number of debugging rounds required by the agent and lowers the associated inference cost. Additionally, the compiled graph defines a minimal and efficient execution plan that supports advanced runtime features such as checkpointing and stepwise resumption, improving iterative development and large-scale pipeline construction.
DataFlow-Ecosystem
A unified data preparation framework must accommodate an open-ended set of algorithms and workflows, which naturally leads to an unbounded space of operators and pipelines. To structure this extensibility in a maintainable manner, DataFlow introduces the concept of a DataFlow-Extension: a modular package that encapsulates additional operators, prompt templates, and pipelines. User-contributed extensions collectively form the broader DataFlow-Ecosystem, a plug-and-play environment analogous to Python’s package ecosystem, where practitioners can readily publish, share, and reuse domain-specific components.
To streamline extension development, DataFlow provides automated project scaffolding through the DataFlow-CLI. Given a few high-level specifications, the CLI generates ready-to-use templates for operators, prompt templates, pipelines, and even full repository layouts suitable for distribution via PyPI or GitHub. Developers need only implement task-specific logic within these generated stubs. Both the core system and extension packages can be installed and imported through Python’s package manager, while lazy-loading mechanisms ensure that multiple extensions coexist with minimal environmental interference.
Complementing the CLI, the DataFlow-Agent supports natural-language–driven construction of operators and pipelines. Leveraging the domain knowledge embedded in large language models, the agent synthesizes effective data-transformation logic and automates common design steps, substantially reducing the cost of authoring high-quality DataFlow-Extensions.
Together, the DataFlow-CLI and DataFlow-Agent reduce the overhead of extension development and promote community-driven growth. Our goal is to cultivate a sustainable open-source ecosystem in which data preparation recipes—constructed from standardized operators, prompt templates, and pipelines—can be shared, reproduced, and improved, ultimately accelerating progress across the data-centric ML community.
Experimental Setting
In the field of AgenticRAG, the automatic generation of multihop questions has long been a challenging issue in research. This study constructs a multihop question dataset with a scale of 10k based on the DataFlow AgenticRAG Pipeline and conducts a comparative analysis with existing mainstream multihop question answering datasets (2WikiMultiHopQA, Musique, HotpotQA, and Bamboogle ).
This study adopts the ReCall framework to complete the model training and evaluation. In the training phase, Qwen2.5-7B-Instruct is selected as the base model, and the GRPO reinforcement learning algorithm is used for model optimization. In the evaluation phase, the model’s temperature parameter is set to 0.0.
For the retrieval component, E5-base-v2 is chosen as the retriever, and the 2018 Wikipedia dump is used as the corpus. All corpus indexing and embedding calculations are preprocessed using FlashRAG. Throughout the entire training and evaluation process, the model is allowed to independently specify the topk value for retrieval, and the default topk value is set to 5 to balance retrieval efficiency and performance.
Experimental Setting
To expand beyond the limited annotated data and take advantage of massive raw corpora from the Internet, we proposed the Knowledge Extraction pipeline, a semi-automated system for corpus cleaning and QA synthesis. The pipeline performs text normalization using MinerU, segments long documents, filters noisy or low-quality sentences, generates factuality-aware QA pairs, and conducts automated quality checks, ultimately producing a high-quality synthetic dataset used for supervised fine-tuning (SFT).
In our experiment, the training data is derived from 140M tokens of raw medical data drawn from three major sources. The first source is MedQA Books, a collection of 18 widely used medical textbooks from the USMLE curriculum. The second source consists of 9,330 publicly available StatPearls articles from the NCBI Bookshelf. The third source contains 45,679 clinical guideline documents aggregated from 16 professional guideline providers. These corpora serve as the input to the Knowledge Extraction pipeline, which converts them into structured, high-quality QA dataset, denoted as DataFlow-Knowledge which is suitable for model training.
Conclusion
In summary, DataFlow addresses a critical gap in the data-centric LLM ecosystem by providing the first unified, LLM-driven data preparation framework. It mitigates long-standing challenges in the field—such as the difficulty of sharing, reproducing, and comparing data preparation algorithms—through a modular and user-friendly programming interface. The framework integrates nearly 200 operators, over 80 prompt templates, and unified abstractions for serving and storage, all of which compose into six high-quality pipelines spanning the major LLM data domains. Extensive experiments demonstrate that these pipelines achieve strong, often state-of-the-art results, confirming that DataFlow effectively balances the tension between domain-specific customization and system-level standardization.
Built atop this foundation, the DataFlow-CLI and DataFlow-Agent further amplify extensibility by enabling rapid template generation, natural-language–driven workflow construction, and scalable extension development. Together, these components lay the groundwork for a sustainable and interoperable data preparation ecosystem that can evolve alongside increasingly complex data-centric AI workflows.
Looking forward, we aim to expand the DataFlow-Ecosystem along multiple modality axes, including DataFlow-Table, DataFlow-Graph, and DataFlow-Multimodal, to support richer data types and workflows. We also plan to develop domain-oriented variants, such as DataFlow-AI4S and DataFlow-Industry, tailored for large-scale production environments. These extensions will broaden the applicability of DataFlow and strengthen its role as a foundational substrate—and a common protocol—for future research, engineering practice, and community-driven innovation in LLM data preparation.


