TL;DR
DataFlex is a unified, open-source framework built on top of LLaMA-Factory that integrates data selection, domain mixture optimization, and sample reweighting into a single training pipeline. By standardizing model-data interactions and supporting large-scale distributed infrastructure like DeepSpeed ZeRO-3, DataFlex bridges the gap between isolated data-centric algorithms and practical LLM training.
What Problem Does This Paper Address?
Data-centric AI shifts the focus of machine learning from architecture tweaking to data optimization—specifically, deciding which samples to train on, how to mix different data domains (e.g., code vs. web text), and how much weight to assign to each sample.
While many powerful data-centric algorithms (like LESS, DoReMi, and ODM) have been proposed, their adoption has been severely bottlenecked by software fragmentation. Most exist as isolated, unmaintained codebases with inconsistent interfaces and rigid data pipelines. This makes it incredibly difficult for researchers to reproduce results, conduct fair head-to-head comparisons, or scale these methods to modern distributed training setups. DataFlex addresses this by providing a unified, scalable infrastructure that treats data as a first-class optimization variable.
Methods
DataFlex introduces a modular data-model interaction architecture directly integrated into the widely used LLaMA-Factory ecosystem. It replaces the standard training layer with three unified trainer abstractions:
- Select Trainer: Dynamically filters or ranks data subsets during training.
- Mix Trainer: Dynamically adjusts domain-level sampling proportions.
- Weight Trainer: Modulates per-sample loss contributions during backpropagation.
Crucially, DataFlex standardizes shared model-dependent operations (such as embedding extraction, inference, and gradient computation). To handle the massive memory footprint of gradient-based data selection, DataFlex implements a distributed gradient collection mechanism compatible with DeepSpeed ZeRO-3 and FSDP, allowing full gradients to be reconstructed from partitioned shards.
Datasets
The authors evaluated DataFlex across several standard benchmarks:
- Open-Hermes-2.5: A 100,000-example subset used for instruction tuning, data selection, and sample reweighting experiments.
- SlimPajama: Used at two token scales (SlimPajama-6B and SlimPajama-30B) across seven text domains (CommonCrawl, C4, GitHub, Book, ArXiv, Wikipedia, StackExchange) to evaluate pretraining data mixture optimization.
- MMLU (Massive Multitask Language Understanding): The primary downstream benchmark used to evaluate model performance.
Key Insights and Ideas
- Data as a Dynamic Variable: Instead of treating data as a static pre-processing step, DataFlex demonstrates that actively orchestrating data usage based on real-time model feedback consistently yields better models.
- Complementary Strengths in Data Mixing: The framework allowed the authors to uncover unique algorithmic behaviors. Offline minimax methods (like DoReMi) excel at optimizing high-resource domains where the bulk of the data resides. Conversely, online bandit-based methods (like ODM) aggressively explore and upweight minority, specialized domains (e.g., ArXiv and StackExchange), leading to superior per-domain perplexity.
- Infrastructure Unlocks Algorithms: Many data-centric methods failed to gain traction simply because their original codebases couldn't scale. By providing native multi-GPU and distributed training support, DataFlex unlocks these methods for large-scale LLM deployment.
Key Results
- Data Selection Performance: On Mistral-7B, the dynamic selection method LESS implemented in DataFlex achieved the highest final MMLU accuracy of 0.452, outperforming the static full-data baseline (0.394) by 5.8 percentage points.
- Pretraining Data Mixture: When pretraining Qwen2.5-1.5B on SlimPajama-30B, DoReMi achieved the highest MMLU accuracy (25.97% vs. 25.51% baseline), while ODM achieved the best overall log perplexity (3.429 vs. 3.584 baseline).
- Efficiency Gains: DataFlex consistently reduced runtime compared to original implementations. For instance, it achieved a 3.7% to 7.1% runtime reduction for LESS on a single GPU. More importantly, while the original LESS codebase only supported a single GPU, DataFlex enabled multi-GPU scaling, cutting training time by 57.13% on an 8-GPU setup.
Limitations and Future Work
Although DataFlex significantly optimizes data-centric workflows, gradient-based operations still introduce non-trivial computational overhead. To mitigate this, the framework relies on interval-based updates and caching, which might miss rapid training dynamics. The authors suggest that future work should focus on automated hyperparameter tuning for scheduling parameters (warmup_step, update_step) and extending the framework to handle multimodal data-centric training paradigms.
Summary updated