GithubHelp home page GithubHelp logo

liudunxu / data-juicer Goto Github PK

View Code? Open in Web Editor NEW

This project forked from modelscope/data-juicer

0.0 0.0 0.0 13.54 MB

A one-stop data processing system to make data higher-quality, juicier, and more digestible for LLMs! 🍎 🍋 🌽 ➡️ ➡️🍸 🍹 🍷为大语言模型提供更高质量、更丰富、更易”消化“的数据!

License: Apache License 2.0

Shell 0.04% Python 99.93% Dockerfile 0.03%

data-juicer's Introduction

English | 中文

Data-Juicer: A One-Stop Data Processing System for Large Language Models

Data-Juicer

Paper Contributing

pypi version Docker version Document_List 文档列表 API Reference

ModelScope-10+ Demos ModelScope-20+_Refined_Datasets ModelScope-Reference_Models

HuggingFace-10+ Demos HuggingFace-20+_Refined_Datasets HuggingFace-Reference_Models

QualityClassifier AutoEvaluation

Data-Juicer is a one-stop data processing system to make data higher-quality, juicier, and more digestible for LLMs. This project is being actively updated and maintained, and we will periodically enhance and add more features and data recipes. We welcome you to join us in promoting LLM data development and research!

If you find Data-Juicer useful for your research or development, please kindly cite our work.


News

  • new [2023-10-13] Our first data-centric LLM competition begins! Please visit the competition's official websites, FT-Data Ranker (1B Track, 7B Track), for more information.

  • [2023-10-8] We update our paper to the 2nd version and release the corresponding version 0.1.2 of Data-Juicer!

Table of Contents

Features

Overview

  • Systematic & Reusable: Empowering users with a systematic library of 20+ reusable config recipes, 50+ core OPs, and feature-rich dedicated toolkits, designed to function independently of specific LLM datasets and processing pipelines.

  • Data-in-the-loop: Allowing detailed data analyses with an automated report generation feature for a deeper understanding of your dataset. Coupled with multi-dimension automatic evaluation capabilities, it supports a timely feedback loop at multiple stages in the LLM development process. Data-in-the-loop

  • Comprehensive Data Processing Recipes: Offering tens of pre-built data processing recipes for pre-training, fine-tuning, en, zh, and more scenarios. Validated on reference LLaMA models. exp_llama

  • Enhanced Efficiency: Providing a speedy data processing pipeline requiring less memory and CPU usage, optimized for maximum productivity. sys-perf

  • Flexible & Extensible: Accommodating most types of data formats (e.g., jsonl, parquet, csv, ...) and allowing flexible combinations of OPs. Feel free to implement your own OPs for customizable data processing.

  • User-Friendly Experience: Designed for simplicity, with comprehensive documentation, easy start guides and demo configs, and intuitive configuration with simple adding/removing OPs from existing configs.

Prerequisites

  • Recommend Python==3.8
  • gcc >= 5 (at least C++14 support)

Installation

From Source

  • Run the following commands to install the latest basic data_juicer version in editable mode:
cd <path_to_data_juicer>
pip install -v -e .
  • Some OPs rely on some other too large or low-platform-compatibility third-party libraries. You can install optional dependencies as needed:
cd <path_to_data_juicer>
pip install -v -e .  # install a minimal dependencies, which support the basic functions
pip install -v -e .[tools] # install a subset of tools dependencies

The dependency options are listed below:

Tag Description
. or .[mini] Install minimal dependencies for basic Data-Juicer.
.[all] Install all optional dependencies (including minimal dependencies and all of the following).
.[sci] Install all dependencies for all OPs.
.[dist] Install dependencies for distributed data processing. (Experimental)
.[dev] Install dependencies for developing the package as contributors.
.[tools] Install dependencies for dedicated tools, such as quality classifiers.

Using pip

  • Run the following command to install the latest released data_juicer using pip:
pip install py-data-juicer
  • Note:
    • only the basic APIs in data_juicer and two basic tools (data processing and analysis) are available in this way. If you want customizable and complete functions, we recommend you install data_juicer from source.
    • The release versions from pypi have a certain lag compared to the latest version from source. So if you want to follow the latest functions of data_juicer, we recommend you install from source.

Using Docker

  • You can
    • either pull our pre-built image from DockerHub:

      docker pull datajuicer/data-juicer:<version_tag>
    • or run the following command to build the docker image including the latest data-juicer with provided Dockerfile:

      docker build -t data-juicer:<version_tag> .

Installation check

import data_juicer as dj
print(dj.__version__)

Quick Start

Data Processing

  • Run process_data.py tool or dj-process command line tool with your config as the argument to process your dataset.
# only for installation from source
python tools/process_data.py --config configs/demo/process.yaml

# use command line tool
dj-process --config configs/demo/process.yaml
  • Note: For some operators that involve third-party models or resources which are not stored locally on your computer, it might be slow for the first running because these ops need to download corresponding resources into a directory first. The default download cache directory is ~/.cache/data_juicer. Change the cache location by setting the shell environment variable, DATA_JUICER_CACHE_HOME to another directory, and you can also change DATA_JUICER_MODELS_CACHE or DATA_JUICER_ASSETS_CACHE in the same way:
# cache home
export DATA_JUICER_CACHE_HOME="/path/to/another/directory"
# cache models
export DATA_JUICER_MODELS_CACHE="/path/to/another/directory/models"
# cache assets
export DATA_JUICER_ASSETS_CACHE="/path/to/another/directory/assets"

Data Analysis

  • Run analyze_data.py tool or dj-analyze command line tool with your config as the argument to analyse your dataset.
# only for installation from source
python tools/analyze_data.py --config configs/demo/analyser.yaml

# use command line tool
dj-analyze --config configs/demo/analyser.yaml
  • Note: Analyser only compute stats of Filter ops. So extra Mapper or Deduplicator ops will be ignored in the analysis process.

Data Visualization

  • Run app.py tool to visualize your dataset in your browser.
  • Note: only available for installation from source.
streamlit run app.py

Build Up Config Files

  • Config files specify some global arguments, and an operator list for the data process. You need to set:
    • Global arguments: input/output dataset path, number of workers, etc.
    • Operator list: list operators with their arguments used to process the dataset.
  • You can build up your own config files by:
    • ➖:Modify from our example config file config_all.yaml which includes all ops and default arguments. You just need to remove ops that you won't use and refine some arguments of ops.
    • ➕:Build up your own config files from scratch. You can refer our example config file config_all.yaml, op documents, and advanced Build-Up Guide for developers.
    • Besides the yaml files, you also have the flexibility to specify just one (of several) parameters on the command line, which will override the values in yaml files.
python xxx.py --config configs/demo/process.yaml --language_id_score_filter.lang=en
  • The basic config format and definition is shown below.

    Basic config example of format and definition

Preprocess Raw Data (Optional)

  • Our formatters support some common input dataset formats for now:
    • Multi-sample in one file: jsonl/json, parquet, csv/tsv, etc.
    • Single-sample in one file: txt, code, docx, pdf, etc.
  • However, data from different sources are complicated and diverse. Such as:
    • Raw arXiv data downloaded from S3 include thousands of tar files and even more gzip files in them, and expected tex files are embedded in the gzip files so they are hard to obtain directly.
    • Some crawled data include different kinds of files (pdf, html, docx, etc.). And extra information like tables, charts, and so on is hard to extract.
  • It's impossible to handle all kinds of data in Data-Juicer, issues/PRs are welcome to contribute to process new data types!
  • Thus, we provide some common preprocessing tools in tools/preprocess for you to preprocess these data.
    • You are welcome to make your contributions to new preprocessing tools for the community.
    • We highly recommend that complicated data can be preprocessed to jsonl or parquet files.

For Docker Users

  • If you build or pull the docker image of data-juicer, you can run the commands or tools mentioned above using this docker image.
  • Run directly:
# run the data processing directly
docker run --rm \  # remove container after the processing
  --name dj \  # name of the container
  -v <host_data_path>:<image_data_path> \  # mount data or config directory into the container
  -v ~/.cache/:/root/.cache/ \  # mount the cache directory into the container to reuse caches and models (recommended)
  data-juicer:<version_tag> \  # image to run
  dj-process --config /path/to/config.yaml  # similar data processing commands
  • Or enter into the running container and run commands in editable mode:
# start the container
docker run -dit \  # run the container in the background
  --rm \
  --name dj \
  -v <host_data_path>:<image_data_path> \
  -v ~/.cache/:/root/.cache/ \
  data-juicer:latest /bin/bash

# enter into this container and then you can use data-juicer in editable mode
docker exec -it <container_id> bash

Documentation | 文档

Data Recipes

Demos

License

Data-Juicer is released under Apache License 2.0.

Contributing

We are in a rapidly developing field and greatly welcome contributions of new features, bug fixes and better documentations. Please refer to How-to Guide for Developers.

Welcome to join our Slack channel, or DingDing group for discussion.

Acknowledgement

Data-Juicer is used across various LLM products and research initiatives, including industrial LLMs from Alibaba Cloud's Tongyi, such as Dianjin for financial analysis, and Zhiwen for reading assistant, as well as the Alibaba Cloud's platform for AI (PAI). We look forward to more of your experience, suggestions and discussions for collaboration!

Data-Juicer thanks and refers to several community projects, such as Huggingface-Datasets, Bloom, RedPajama, Pile, Alpaca-Cot, Megatron-LM, DeepSpeed, Arrow, Ray, Beam, LM-Harness, HELM, ....

References

If you find our work useful for your research or development, please kindly cite the following paper.

@misc{chen2023datajuicer,
title={Data-Juicer: A One-Stop Data Processing System for Large Language Models},
author={Daoyuan Chen and Yilun Huang and Zhijian Ma and Hesen Chen and Xuchen Pan and Ce Ge and Dawei Gao and Yuexiang Xie and Zhaoyang Liu and Jinyang Gao and Yaliang Li and Bolin Ding and Jingren Zhou},
year={2023},
eprint={2309.02033},
archivePrefix={arXiv},
primaryClass={cs.LG}
}

data-juicer's People

Contributors

hylcool avatar zhijianma avatar yxdyc avatar chenhesen avatar drcege avatar pan-x-c avatar xieyxclack avatar alibaba-oss avatar beachwang avatar jongsky avatar xuruidong avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.