# DataFlex

Data Select ยท Mix ยท Reweight โ€” Right in the LLM Training Loop

[![Documents](https://img.shields.io/badge/Documents-Click_here-brightgreen?logo=read-the-docs)](https://OpenDCAI.github.io/DataFlex-Doc/) [![](https://img.shields.io/github/license/OpenDCAI/DataFlex)](https://github.com/OpenDCAI/DataFlex/blob/main/LICENSE) [![](https://img.shields.io/github/stars/OpenDCAI/DataFlex?style=social)](https://github.com/OpenDCAI/DataFlex) [![](https://img.shields.io/github/contributors/OpenDCAI/DataFlex)](https://github.com/OpenDCAI/DataFlex/graphs/contributors) [![](https://img.shields.io/github/repo-size/OpenDCAI/DataFlex?color=green)](https://github.com/OpenDCAI/DataFlex) [![Ask DeepWiki](https://deepwiki.com/badge.svg)](https://deepwiki.com/OpenDCAI/DataFlex) ๐ŸŽ‰ If you like our project, please give us a star โญ on GitHub for the latest update. [็ฎ€ไฝ“ไธญๆ–‡](./README-zh.md) | English
## ๐Ÿ“ฐ 1. News - [2026-04-04] ๐ŸŽ‰ Our [technical report](https://huggingface.co/papers/2603.26164) ranked #1 on the Hugging Face Daily Papers leaderboard for that day. - [2026-03-17] We now support gradient computation under DeepSpeed ZeRO-3, enabling training and analysis of larger-scale models. - [2025-12-23] ๐ŸŽ‰ Weโ€™re excited to announce the first Data-Centric Training System DataFlex, is now released! Stay tuned for future updates. ## ๐Ÿ” 2. Overview **DataFlex** is an advanced dynamic training framework built on top of [LLaMA-Factory](https://github.com/hiyouga/LLaMA-Factory). It intelligently schedules training data during optimization and integrates several difficult-to-reproduce repositories into a unified framework. The system provides reproducible implementations of **Data Selection**, **Data Mixture**, and **Data Reweighting**, thereby improving both experimental reproducibility and final model performance. DataFlex integrates seamlessly with LLaMA-Factory, offering researchers and developers more flexible and powerful training control. For goals and design philosophy, please refer to [DataFlex-Doc](https://opendcai.github.io/DataFlex-Doc/). We summarize repositories related to Data Selection, Data Mixture, and Data Reweighting. โŒ indicates that no official repository is available; โœ… indicates that an official repository is available; โš ๏ธ indicates that an official repository exists but contains issues. - **Data Selection**: Dynamically selects training samples according to a given strategy (e.g., focus on โ€œhardโ€ samples). The data selection algorithms are summarized as follows:
| Method | Category | Requires Model-in-the-Loop? | Official Repo | |:------:|:--------:|:---------------------------:|:-------------:| | **LESS** | Gradient-Based | โœ… Yes | โš ๏ธ[official code](https://github.com/princeton-nlp/LESS) | | **NICE** | Gradient-Based | โœ… Yes | โš ๏ธ[official code](https://github.com/JTWang2000/NICE) | | **Loss** | Loss-Based | โœ… Yes | โŒ | | **Delta Loss** | Loss-Based | โœ… Yes | โŒ | | **NEAR** | Data Distribution-Based | โŒ No | โŒ | | **TSDS** | Data Distribution-Based | โŒ No | โœ…[official code](https://github.com/ZifanL/TSDS) | | **Static** | No Selection | โŒ No | โŒ | | **Random** | Random Sampling | โŒ No | โŒ |
- **Data Mixture**: Dynamically adjusts the ratio of data from different domains during training. The data mixture algorithms are summarized as follows:
| Method | Category | Requires Model-in-the-Loop? | Official Repo | |:------:|:--------:|:---------------------------:|:-------------:| | **DOREMI** | Offline Mixture | โœ… Yes | โš ๏ธ[official code](https://github.com/sangmichaelxie/doremi) | | **ODM** | Online Mixture | โœ… Yes | โš ๏ธ[official code](https://github.com/alon-albalak/online-data-mixing) |
- **Data Reweighting**: Dynamically adjusts sample weights during backpropagation to emphasize data preferred by the model. The data reweighting algorithms are summarized as follows:
| Method | Category | Requires Model-in-the-Loop? | Official Repo | |:------:|:--------:|:---------------------------:|:-------------:| | **Loss Reweighting** | Loss-Based | โœ… Yes | โŒ | | **Joint-Update-Aware Reweighting** | Batch-Aware | โœ… Yes | โŒ |
- **Full compatibility with LLaMA-Factory**, drop-in replacement. ## ๐Ÿ“Œ 3. Quick Start Please use the following commands for environment setup and installation๐Ÿ‘‡ Install torch first, so pip does not resolve a different build and then have to replace it: ```bash pip install --index-url https://download.pytorch.org/whl/cu124 \ torch==2.6.0 torchvision==0.21.0 torchaudio==2.6.0 python -c "import torch; print(torch.__version__, torch.cuda.is_available())" ``` Then install DataFlex: ```bash pip install dataflex ``` Or install from source for development: ```bash git clone https://github.com/OpenDCAI/DataFlex.git cd DataFlex pip install -e . ``` Every config under `examples/deepspeed` needs DeepSpeed, which ships as an optional extra: ```bash pip install "dataflex[deepspeed]" # from source: pip install -e ".[deepspeed]" ``` > **Note:** Requires Python 3.11+ and LlamaFactory 0.9.5+, installed automatically along with the other core dependencies. Works on transformers 4.55 through 5.6; the newer model families (Qwen3.5, Gemma 4) need transformers 5.5+. We recommend transformers 5.3+ if you need `train_from_scratch` under DeepSpeed ZeRO-3. > > The `deepspeed` extra stays below 0.17 on purpose: 0.17+ fails to import on the torch pinned above. On a newer torch you are free to lift that cap. > > The LESS selector needs TRAK, which is another optional extra: `pip install dataflex[less]`. The launch command is similar to [LLaMA-Factory](https://github.com/hiyouga/LLaMA-Factory). Below is an example using [LESS](https://arxiv.org/abs/2402.04333) : ```bash dataflex-cli train examples/train_lora/selectors/less.yaml ``` Unlike vanilla LLaMA-Factory, your `.yaml` config file must also include **DataFlex-specific parameters**. For details, please refer to [DataFlex-Doc](https://opendcai.github.io/DataFlex-Doc/). ## ๐Ÿ“– Skills - [How to Use DataFlex](skills/how_to_use.md) โ€” Installation, CLI commands, YAML configuration, training modes, and supported algorithms. - [How to Add a New Algorithm](skills/how_to_add_algorithm.md) โ€” Architecture overview, registry system, base class interfaces, and step-by-step guide for adding selectors/mixers/weighters. ## ๐Ÿ“š 4. Experimental Results Using DataFlex can improve performance over the default LLaMA-Factory training. ### Data Selector & Reweightor Results We use a subset of [Open-Hermes-2.5](https://huggingface.co/datasets/OpenDCAI/DataFlex-selector-openhermes-10w) as the training dataset. The data selection algorithms and data reweighting algorithm outperform the random selector baseline on the [MMLU benchmark](https://huggingface.co/datasets/OpenDCAI/dataflex-selector-MMLUSubset-test) subset relevant to the training dataset. For the Less and Nice algorithm, we set the validation set as the [MMLU-Validation-Set](https://huggingface.co/datasets/OpenDCAI/dataflex-selector-MMLUSubset-valid-cot), using a GPT-5-generated trajectory.

### Data Mixture Results We use subsets of [SlimPajama-627B](https://huggingface.co/datasets/cerebras/SlimPajama-627B) for data mixture. The data mixture algorithms outperform the baseline (default data mixture) on MMLU accuracy while also achieving lower perplexity across different data domains.
Method Acc โ†‘ Perplexity (PPL) โ†“
MMLU ALL CC C4 SE Wiki GitHub ArXiv Book
Slim-Pajama-6B
Baseline 25.27 4.217 4.278 4.532 3.402 3.546 2.640 3.508 4.778
DoReMi 25.84 4.134 4.108 4.358 3.788 3.997 3.420 3.413 4.661
ODM 26.04 4.244 4.326 4.555 3.243 3.699 2.704 2.904 4.613
Slim-Pajama-30B
Baseline 25.51 3.584 3.723 3.505 2.850 3.215 3.163 4.540 5.329
DoReMi 25.97 3.562 3.731 3.503 2.706 2.985 2.973 4.441 5.214
ODM 25.63 3.429 3.598 3.519 2.382 2.713 2.255 3.487 4.746
## ๐Ÿงฉ 5. Ecosystem DataFlex focuses on data scheduling during training. For a complete pipeline starting from raw data, it pairs well with [DataFlow](https://github.com/OpenDCAI/DataFlow):
[DataFlow](https://github.com/OpenDCAI/DataFlow) converts raw files into LLM training data through composable operator pipelines โ€” document parsing, knowledge cleaning, QA / CoT synthesis, and training format conversion. The output JSON can be fed directly into DataFlex. The two projects are independent with no code dependency, connected only by standard data formats. DataFlex accepts training data from any source โ€” DataFlow, manual annotation, HuggingFace datasets, or custom processing scripts. ## ๐Ÿค 6. Acknowledgements We thank [LLaMA-Factory](https://github.com/hiyouga/LLaMA-Factory) for offering an efficient and user-friendly framework for large model fine-tuning, which greatly facilitated rapid iteration in our training and experimentation workflows. We thank Zhongguancun Academy for their API and GPU support. Our gratitude extends to all contributors in the open-source communityโ€”their efforts collectively drive the development of DataFlex. ## ๐Ÿ“œ 7. Citation If you use DataFlex in your research, feel free to give us a cite. ```bibtex @article{liang2026dataflex, title={DataFlex: A Unified Framework for Data-Centric Dynamic Training of Large Language Models}, author={Liang, Hao and Zhao, Zhengyang and Qiang, Meiyi and Chen, Mingrui and Ma, Lu and Yu, Rongyi and Feng, Hengyi and Sun, Shixuan and Meng, Zimo and Ma, Xiaochen and others}, journal={arXiv preprint arXiv:2603.26164}, year={2026} } @article{liang2026towards, title={Towards Next-Generation LLM Training: From the Data-Centric Perspective}, author={Liang, Hao and Zhao, Zhengyang and Han, Zhaoyang and Qiang, Meiyi and Ma, Xiaochen and Zeng, Bohan and Cai, Qifeng and Li, Zhiyu and Tang, Linpeng and Zhang, Wentao and others}, journal={arXiv preprint arXiv:2603.14712}, year={2026} } ``` ## ๐Ÿค 8. Community & Support We welcome contributions of new trainers and selectors! Please ensure code formatting is consistent with the existing style before submitting a PR. We also welcome you to join the [DataFlex](https://github.com/OpenDCAI/DataFlex) and [DataFlow](https://github.com/OpenDCAI/DataFlow) open-source community to ask questions, share ideas, and collaborate with other developers! โ€ข ๐Ÿ“ฎ [GitHub Issues](../../issues): Report bugs or suggest features โ€ข ๐Ÿ”ง [GitHub Pull Requests](../../pulls): Contribute code improvements โ€ข ๐Ÿ’ฌ Join our community groups to connect with us and other contributors!