Mixture formatter

From cas-bigdatalab/piflow · View interactive version

Mixture formatter is an AI agent skill from the GitHub repository cas-bigdatalab/piflow. 混合格式化器。该类通过从每个数据集中随机选择样本并合并它们来混合多个数据集,然后将合并的数据集导出为新的混合数据集。 本SKILL使用依赖data_juicer,请在调用前安装好python环境并安装data_juicer,你可用以下指令进行安装: pip install py-data-juicer 当用户提到混合数据集、合并多个数据集、数据集混合、数据融合等需求时使用此skill。

How to use this skill

Skill file

功能概述

该算子用于混合多个数据集,通过从每个数据集中按权重随机选择样本并合并,生成新的混合数据集。

核心参数

| 参数 | 类型 | 必填 | 默认值 | 说明 |

|------|------|------|--------|------|

| dataset_path | string | 是 | - | 数据集路径,支持带权重格式 |

| output_path | string | 是 | - | 输出JSONL文件路径 |

| suffixes | list | 否 | None | 指定后缀列表 |

| text_keys | list | 否 | ['text'] | 文本字段名列表 |

| add_suffix | bool | 否 | False | 是否添加文件后缀信息 |

| max_samples | int | 否 | None | 混合数据集最大样本数 |

| num_proc | int | 否 | 1 | 并行处理的进程数 |

输入数据格式

dataset_path 支持以下格式:

例如:/path/to/dataset1.jsonl 0.5 /path/to/dataset2.jsonl 0.5

输出数据格式

输出为 JSONL 格式,每行一个样本。

使用示例

命令行调用

# 混合两个数据集,等权重
python scripts/run_mixture_formatter.py \
  --dataset_path "/path/to/dataset1.jsonl /path/to/dataset2.jsonl" \
  --output_path /path/to/output.jsonl

# 带权重的混合
python scripts/run_mixture_formatter.py \
  --dataset_path "0.7 /path/to/dataset1.jsonl 0.3 /path/to/dataset2.jsonl" \
  --output_path /path/to/output.jsonl

# 限制最大样本数
python scripts/run_mixture_formatter.py \
  --dataset_path "/path/to/dataset1.jsonl /path/to/dataset2.jsonl" \
  --output_path /path/to/output.jsonl \
  --max_samples 10000

参数说明

注意事项

  1. 权重格式:<权重> 路径,权重可选,不指定时默认为1.0
  2. 样本按权重比例分配,总和可能不等于 max_samples
  3. 每个数据集的样本是随机选择的
Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.