DeepSpec 是一个用于训练和评估推测解码中草稿模型的完整代码库,提供数据准备、训练和评估流程,支持 DSpark、DFlash 和 Eagle3 等算法。

Stars

6,801

7 天增长

暂无数据

Fork 数

633

开放 Issue

23

开源协议

MIT

最近更新

2026-07-09

AI 仓库情报摘要
FR-AI / ANALYSIS

为什么值得关注

它是 DeepSeek 开源的综合性工具包,整合了多种先进的推测解码算法、多个目标模型的预训练检查点,以及从数据生成到基准评估的完整工作流,有助于可重复研究与实践部署。

适合谁使用

  • 研究推测解码和大模型推理加速的机器学习研究员
  • 部署大语言模型并追求低延迟的工程师
  • 为生产级 LLM 服务开发草稿模型的团队

典型使用场景

  • 训练草稿模型加速目标 LLM 的推理(通过推测解码)
  • 在 GSM8K、MATH500、HumanEval 等标准基准上评估草稿模型性能
  • 复现 DSpark 论文结果或与 DFlash/Eagle3 基线进行对比

项目优势

  • 覆盖从数据准备到评估的完整流程,配有清晰的脚本和配置文件
  • 支持三种前沿草稿模型算法(DSpark、DFlash、Eagle3),并发布了 Hugging Face 检查点
  • 提供 9 个评估数据集的基准测试,以及针对四种目标模型(Qwen3-4B/8B/14B、Gemma-4-12B)的预配置
  • 代码源自经过充分测试的开源项目(SpecForge、DFlash),附有详细的 NOTICE 文件以确保合规

使用前须知

  • 数据准备需要推理引擎且目标缓存极大(默认设置约 38 TB),运行成本高
  • 训练脚本假定单节点 8 张 GPU;使用更少 GPU 需手动调整 CUDA_VISIBLE_DEVICES
  • 不包含思考模式的微调指南;用户需针对特定领域或思考模式重新训练

README 快速开始

DeepSpec

DeepSpec is a full-stack codebase for training and evaluating draft models for speculative decoding. It contains data preparation utilities, draft model implementations, training code, and evaluation scripts.

Environment

Install the Python dependencies:

python -m pip install -r requirements.txt

Data preparation additionally requires an inference engine to serve the target model when regenerating answers; see scripts/data/README.md for details.

Workflow

Run the stages in order — each stage's output feeds the next:

  1. Data Preparation — download prompts, regenerate target answers, and build the target cache.
  2. Training — train a draft model against the cached target outputs.
  3. Evaluation — measure speculative-decoding acceptance on benchmark tasks.

Data Preparation

See scripts/data/README.md for the step-by-step data pipeline:

  1. download and split training data,
  2. regenerate answers,
  3. prepare the target cache (storage warning: this can be very large — roughly 38 TB for the default Qwen/Qwen3-4B setting).

Training

bash scripts/train/train.sh

train.sh launches train.py, which spawns one worker per visible GPU. Select the algorithm and target model by pointing config_path at one of the configs under config/ (e.g. config/dspark/dspark_qwen3_4b.py); see the script header for the full list of configs, how to override config_path / target_cache_dir, and how to use --opts to override individual config fields. Checkpoints are written to ~/checkpoints///step_*.

Hardware: the default configs and scripts assume a single node with 8 GPUs. For fewer GPUs, reduce CUDA_VISIBLE_DEVICES.

Evaluation

bash scripts/eval/eval.sh

eval.sh runs eval.py against a trained draft checkpoint over the speculative-decoding benchmarks in eval_datasets/ (gsm8k, math500, aime25, humaneval, mbpp, livecodebench, mt-bench, alpaca, arena-hard-v2). Set:

  • target_name_or_path — the target model the draft was trained against (e.g. Qwen/Qwen3-4B),
  • draft_name_or_path — the draft checkpoint, e.g. ~/checkpoints/deepspec/dspark_block7_qwen3_4b/step_latest, or one of the Hugging Face repo IDs listed in Released Checkpoints.

Released Checkpoints

The checkpoint

项目描述

DeepSpec: a full-stack codebase for training and evaluating speculative decoding algorithms

相关仓库与替代方案

根据分类、Topic 和编程语言匹配的相似项目。

lopopolo
精选
lopopolo GitHub avatar

harness-engineering

Harness Engineering is a methodology for improving coding agent outputs by carefully crafting the environment around them—providing curated context, tools, and executable constraints that encode an organization’s nonfunctional requirements and cumulative lessons.

AI 与机器学习AI 智能体
2,390
slvDev
精选
slvDev GitHub avatar

esp32-ai

A 28.9 million parameter language model runs on an $8 ESP32-S3 microcontroller entirely on-device, generating simple stories at about 9.5 tokens per second.

AI 与机器学习大语言模型
1,960
littledivy
精选
littledivy GitHub avatar

mimic

mimic captures traffic from any iOS or web app and automatically generates a Python client library that lets you call the app's API like a regular library.

AI 与机器学习
1,482