EasyDistill 2
EasyDistill 2 is a config-driven knowledge distillation toolkit for turning black-box teacher models into high-quality training data. It composes atomic operators—generation, evaluation, filtering, rewriting, balancing, and preference scoring—into end-to-end pipelines that produce SFT datasets, DPO preference pairs, and multi-modal training data.
EasyDistill 2 是一个配置驱动的知识蒸馏工具包,用于将黑盒教师模型转化为高质量训练数据。它将生成、评估、过滤、改写、平衡与偏好评分等原子算子组合为端到端流水线,产出 SFT 数据集、DPO 偏好对以及多模态训练数据。
Upgrading from 1.0 / 从 1.0 升级: EasyDistill 2 is a rewrite and is not backward compatible with 1.0 configs or APIs. The 1.0 implementation remains available on the 1.0 branch and the v1.0.0 tag. / EasyDistill 2 为重写版本,与 1.0 的配置和 API 不向后兼容。1.0 实现保留在 1.0 分支与 v1.0.0 标签。
Key capabilities / 核心能力:
- Backend-agnostic generation / 后端无关的生成: works with any OpenAI-compatible endpoint—OpenAI API, Azure OpenAI, vLLM, local servers, PAI-Token, and PAI-EAS. / 支持任意 OpenAI 兼容端点:OpenAI API、Azure OpenAI、vLLM、本地服务、PAI-Token 与 PAI-EAS。
- SFT and DPO data / SFT 与 DPO 数据: build supervised fine-tuning datasets or chosen/rejected preference pairs for alignment. / 构建监督微调数据集或用于对齐训练的 chosen/rejected 偏好对。
- Text and multi-modal / 文本与多模态: distill instructions, chain-of-thought reasoning, vision-language conversations, agent trajectories, and text-to-image data. / 蒸馏指令、思维链推理、视觉语言对话、Agent 轨迹与文生图数据。
- Composable pipelines / 可组合流水线: use ready-made end-to-end pipelines or mix individual operators to match your data strategy. / 使用开箱即用的端到端流水线,或自由组合单个算子以匹配数据策略。
- Training-ready outputs / 训练就绪输出: exported formats work directly with LLaMA-Factory and ms-swift. / 导出格式可直接用于 LLaMA-Factory 与 ms-swift。
Installation / 安装
pip install -e .
For the PAI-Token and PAI-EAS backends you also need the openai package: / 若使用 PAI-Token 和 PAI-EAS 后端,还需安装 openai 包:
pip install openai
Quick start / 快速开始
Every job uses the same CLI entry point. The job_type field in the config selects the workflow, and each workflow ships paired _pai_token / _pai_eas configs.
每个任务使用相同的 CLI 入口。配置文件中的 job_type 字段选择具体工作流,每个工作流都提供成对的 _pai_token / _pai_eas 配置。
# 1. Set credentials for your backend / 按所用后端设置凭据
export PAI_TOKEN_API_KEY=your_key # PAI-Token
export PAI_TOKEN_BASE_URL=https://your-endpoint/v1 # PAI-Token (optional / 可选)
export EAS_ENDPOINT_URL=https://your-service.cn-beijing.pai-eas.aliyuncs.com/v1 # PAI-EAS
export EAS_TOKEN=your_token # PAI-EAS
export DASHSCOPE_API_KEY=your_key # T2I (Wanx / Qwen-Image)
export EAS_VIDEO_ENDPOINT_URL=https://your-video-service.pai-eas.aliyuncs.com # T2V (EAS video / EAS 视频)
export EAS_VIDEO_TOKEN=your_token # T2V (EAS video / EAS 视频)
# 2. Run any workflow / 运行任意工作流
easydistill --config configs/basic/instruct_distill_pai_token.yaml
Discover supported jobs and models without a config:
无需配置文件即可查看支持的作业与模型:
easydistill --list-jobs # list all job_type values / 列出所有 job_type
easydistill --list-models # list Model Zoo entries / 列出模型库
Pick a config from the tables below; each linked doc covers stage-level options and data formats.
从下方表格选择配置;各阶段选项与数据格式见对应文档。
Workflows / 工作流
Basic distillation / 基础蒸馏
Single-stage distillation: generate teacher outputs for seed data and build an SFT dataset. / 单阶段蒸馏:为种子数据生成教师输出并构建 SFT 数据集。
job_type |
Purpose / 用途 |
Config |
Docs |
instruct_distill |
Teacher responses for seed instructions. / 为种子指令生成教师回复。 |
configs/basic/instruct_distill_pai_token.yaml |
EN · 中文 |
cot_distill |
Chain-of-thought reasoning traces. / 生成思维链推理轨迹。 |
configs/basic/cot_distill_pai_token.yaml |
EN · 中文 |
mm_instruct_distill |
Responses for (image, instruction) pairs. / 为 (图像, 指令) 样本对生成回复。 |
configs/basic/mm_instruct_distill_pai_token.yaml |
EN · 中文 |
mm_cot_distill |
Visual chain-of-thought traces. / 生成视觉思维链轨迹。 |
configs/basic/mm_cot_distill_pai_token.yaml |
EN · 中文 |
Instruction pipelines / 指令蒸馏流水线
End-to-end pipelines chaining synthesis, generation, evaluation, filtering, and SFT building. / 将合成、生成、评估、过滤与 SFT 构建串联的端到端流水线。
job_type |
Purpose / 用途 |
Config |
Docs |
advanced_instruct_distill |
Expand → generate → judge → filter → SFT. / 扩充 → 生成 → 裁判 → 过滤 → SFT。 |
configs/pipeline/advanced_instruct_distill_pai_token.yaml |
EN · 中文 |
balanced_instruct_distill |
Balance category distribution before generation. / 生成前先平衡指令类别分布。 |
configs/pipeline/balanced_instruct_distill_pai_token.yaml |
EN · 中文 |
augmented_instruct_distill |
Refine seeds, then generate and distill. / 精练种子指令后生成并蒸馏。 |
configs/pipeline/augmented_instruct_distill_pai_token.yaml |
EN · 中文 |
Standalone synthesis operators (instruction_expansion, seed_anchored_expansion, instruction_refinement, instruction_response_extraction) live in configs/rewrite/; see instruction_balancing.md.
独立的合成算子(instruction_expansion、seed_anchored_expansion、instruction_refinement、instruction_response_extraction)位于 configs/rewrite/,参见 instruction_balancing_zh.md。
CoT distillation / 思维链蒸馏
job_type |
Purpose / 用途 |
Config |
Docs |
advanced_cot_distill |
Generate CoT, score with RV/CD, mix by difficulty bins, build SFT. / 生成 CoT,按 RV/CD 评分、按难度分箱混合并构建 SFT。 |
configs/pipeline/advanced_cot_distill_pai_token.yaml |
EN · 中文 |
cot_long2short / cot_short2long |
Rewrite CoT length in either direction. / 思维链长转短与短转长改写。 |
configs/rewrite/cot_long2short_pai_token.yaml |
EN · 中文 |
Multi-modal pipelines / 多模态流水线
job_type |
Purpose / 用途 |
Config |
Docs |
advanced_mm_distill |
Multi-modal generate → eval → filter → SFT. / 多模态生成 → 评估 → 过滤 → SFT。 |
configs/pipeline/advanced_mm_distill_pai_token.yaml |
EN · 中文 |
advanced_mm_cot_distill |
Visual CoT with RV/CD/correctness scoring. / 视觉思维链,含 RV/CD/正确性评分。 |
configs/pipeline/advanced_mm_cot_distill_pai_token.yaml |
EN · 中文 |
advanced_mm_cot_distill (OmniThoughtV config / OmniThoughtV 配置变体) |
Same job_type as above; reproduces the OmniThoughtV <thinking>/<answer> trace recipe. / 与上行为同一 job_type;复现 OmniThoughtV <thinking>/<answer> 轨迹配方。 |
configs/pipeline/omnithoughtv_mm_cot_distill_pai_token.yaml |
EN · 中文 |
mm_cot_long2short / mm_cot_short2long |
Rewrite visual CoT length. / 视觉思维链长度改写。 |
configs/rewrite/mm_cot_long2short_pai_token.yaml |
EN · 中文 |
Agent distillation / Agent 蒸馏
Synthesize virtual tool-use tasks from persona seeds, roll out multi-turn agent trajectories with a LangGraph ReAct loop, and build SFT or DPO training data.
从角色种子合成虚拟工具使用任务,通过 LangGraph ReAct 循环展开多轮 Agent 轨迹,并构建 SFT 或 DPO 训练数据。
job_type |
Config |
Docs |
agent_distill |
configs/pipeline/agent_distill_pai_token.yaml |
EN · 中文 |
Search agent distillation / 搜索 Agent 蒸馏
Evolve simple seed QA pairs into verified multi-hop search tasks through a Strategist-driven closed loop (expand via atomic-QA entity bridging, refine, quality gate, solver-verified difficulty rating), roll out tool-using ReAct search trajectories (mock-simulated or real Google/Jina search), and build SFT training data.
通过策略师驱动的闭环将简单种子问答进化为经验证的多跳搜索任务(原子 QA 实体桥接加跳、受控模糊化、质量门禁、解题实测定难度),展开带工具(模拟或真实 Google/Jina 检索)的 ReAct 搜索轨迹,并构建 SFT 训练数据。
job_type |
Config |
Docs |
search_agent_distill |
configs/pipeline/search_agent_distill_pai_token.yaml |
EN · 中文 |
T2I distillation / 文生图蒸馏
Distill seed text prompts into multi-modal SFT data with generated images. Supports Tongyi Wanxiang (Wanx), Qwen-Image, and PAI-Diffusion backends via the t2i_backend config section.
将种子文本提示蒸馏为含生成图片的多模态 SFT 数据。通过 t2i_backend 配置节支持通义万相(Wanx)、Qwen-Image 与 PAI-Diffusion 后端。
job_type |
Purpose / 用途 |
Config |
Docs |
t2i_distill |
Basic text-to-image distillation. / 基础文生图蒸馏。 |
configs/t2i/t2i_distill_wanx.yaml |
EN · 中文 |