DeepSpec README

The project's README from github.com/deepseek-ai/DeepSpec. As one markdown file: README.md.

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/<project_name>/<exp_name>/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:

Released Checkpoints

The checkpoints below are the ones used for Table 1 in the paper. Each checkpoint was trained on open-perfectblend data generated by its corresponding target model in non-thinking mode, and is the direct output of the corresponding training configuration under config/.

Algorithm Qwen/Qwen3-4B Qwen/Qwen3-8B Qwen/Qwen3-14B google/gemma-4-12B-it
Eagle3 deepseek-ai/eagle3_qwen3_4b_ttt7 deepseek-ai/eagle3_qwen3_8b_ttt7 deepseek-ai/eagle3_qwen3_14b_ttt7 deepseek-ai/eagle3_gemma4_12b_ttt7
DFlash deepseek-ai/dflash_qwen3_4b_block7 deepseek-ai/dflash_qwen3_8b_block7 deepseek-ai/dflash_qwen3_14b_block7 deepseek-ai/dflash_gemma4_12b_block7
DSpark deepseek-ai/dspark_qwen3_4b_block7 deepseek-ai/dspark_qwen3_8b_block7 deepseek-ai/dspark_qwen3_14b_block7 deepseek-ai/dspark_gemma4_12b_block7

[!IMPORTANT] If you cite these results in a new paper, align your setup with the training settings in this repository; otherwise, the comparison is not meaningful. For domain-specific use, fine-tune the draft model again for better results, especially if the target model is expected to run in thinking mode.

Supported Algorithms

Currently, DeepSpec includes three draft models: DSpark, DFlash and Eagle3.

License

DeepSpec is released under the MIT License. It includes code adapted from third-party projects under their own licenses; see NOTICE for the full attribution.

Acknowledgements

DeepSpec builds on the ideas and code of several excellent open-source projects:

We thank the authors and maintainers of these projects. Contributions of new algorithms are welcome.

Citation

@misc{cheng2026dsparkconfidencescheduledspeculativedecoding,
      title={DSpark: Confidence-Scheduled Speculative Decoding with Semi-Autoregressive Generation}, 
      author={Xin Cheng and Xingkai Yu and Chenze Shao and Jiashi Li and Yunfan Xiong and Yi Qian and Jiaqi Zhu and Shirong Ma and Xiaokang Zhang and Jiasheng Ye and Qinyu Chen and Chengqi Deng and Jiping Yu and Damai Dai and Zhengyan Zhang and Yixuan Wei and Yixuan Tan and Wenkai Yang and Runxin Xu and Yu Wu and Zhean Xu and Xuanyu Wang and Muyang Chen and Rui Tian and Xiao Bi and Zhewen Hao and Shaoyuan Chen and Huanqi Cao and Wentao Zhang and Anyi Xu and Huishuai Zhang and Dongyan Zhao and Wenfeng Liang},
      year={2026},
      eprint={2607.05147},
      archivePrefix={arXiv},
      primaryClass={cs.AI},
      url={https://arxiv.org/abs/2607.05147}, 
}

DeepSpec (deepseek-ai/DeepSpec)

Searching Database…

这是做什么的?DeepSpec 是 DeepSeek 的一套全栈 Python 代码库,用于训练和评估投机解码(speculative decoding)的草稿模型——这是一种由小草稿模型加速更大目标大语言模型的技术。
它是能装进我应用里的库,还是一套要自己跑的脚本?它是一套按阶段流程运行的研究代码——先用 scripts/data/README.md 做数据准备,再用 train.sh 训练,最后用 eval.sh 评估——并不是一个可安装的推理库。
我怎么把它跑起来?先安装 Python 依赖,然后按顺序跑三个阶段:数据准备(scripts/data/README.md 里有详细步骤)、用 train.sh 训练、用 eval.sh 评估——每个阶段的输出会作为下一个阶段的输入。
我需要一台完整的 GPU 机器才能跑吗?默认配置假设单机 8 张 GPU——train.sh 会为每张可见 GPU 启动一个 worker,GPU 数量少一些也可以,通过 CUDA_VISIBLE_DEVICES 控制——另外在数据准备阶段还需要一个推理引擎来提供目标模型的服务。
我该预留多少磁盘空间?要预留很多:在数据准备阶段生成的目标模型缓存,在默认的 Qwen/Qwen3-4B 设置下大约会达到 38 TB,所以存储是最先要解决的问题。
官方发布的草稿模型能直接用在我自己的任务上吗?不一定:它们是在 open-perfectblend 数据上配合各自的目标模型(非思考模式)训练出来的。如果要用于特定领域,README 建议重新微调草稿模型,尤其是当你的目标模型会以思考模式运行时。
所有代码都是从零写的吗?不是——DeepSpec 的训练框架基于 SpecForge(Apache-2.0 许可证)和 Eagle3,流程配方基于 DFlash(MIT 许可证);改动的文件在文件内附有来源说明,完整的许可声明见 NOTICE,DeepSpec 本身采用 MIT 许可证。
我能在自己的论文里引用它的基准测试数据吗?只有在你的实验设置与本仓库的训练设置保持一致时才可以——README 明确警告,设置不一致的比较没有意义。
What are similar projects?jeeves, NanoJev, open-r1, jeff, Valen, CLM, Intern-Decision, airllm
Size
4 MB
Stars
7.2K
Updated
CommitJul 09
Age
3mo
Commits · 90 Days