DEER 项目最佳实践教程

DEER 项目最佳实践教程

DEER This is the repository of DEER, a Dynamic Early Exit in Reasoning method for Large Reasoning Language Models. DEER 项目地址: https://gitcode.com/gh_mirrors/deer6/DEER

1. 项目介绍

DEER(Dynamic Early Exit in Reasoning Models)是一个为大型推理语言模型设计的动态早期退出方法。此方法通过在潜在的推理转换点监控模型行为,当模型对一个尝试性答案表现出高度自信时,动态终止后续推理链的生成。根据官方描述,该方法在11个系列和大小各异的前沿推理LLM模型上均表现出一致性效果,平均减少了19.1% - 80.1%的CoT序列长度,同时提高了0.3% - 5.0%的准确性。

2. 项目快速启动

安装

首先,需要克隆项目仓库:

git clone https://github.com/iie-ycx/DEER.git
cd DEER

接着,安装项目所需的依赖:

pip install -r requirements.txt

运行 DEER

对于基于vLLM框架的模型,推荐以下命令进行结果复现:

CUDA_VISIBLE_DEVICES=1 python ../vllm-deer.py \
--model_name_or_path "./DeepSeek-R1-Distill-Qwen-14B" \
--dataset_dir "./data/" \
--output_path "./outputs" \
--dataset "math" \
--threshold 0.95 \
--max_generated_tokens 16000 \
--think_ratio 0.6 \
--batch_size 2000 \
--policy avg1 \
--dtype bfloat16 \
--gpu-memory-utilization 0.9

对于Qwen3系列模型,由于它们在置信度预测上往往过于自信,官方进行了一些实现上的调整。以下是对Qwen3模型的运行命令:

CUDA_VISIBLE_DEVICES=1 python ../vllm-deer-qwen3.py \
--model_name_or_path "./Qwen3-4B" \
--dataset_dir "./data/" \
--output_path "./outputs" \
--dataset "math" \
--threshold 0.95 \
--max_generated_tokens 16000 \
--think_ratio 0.8 \
--batch_size 2000 \
--dtype bfloat16 \
--policy avg2 \
--gpu-memory-utilization 0.9

如果使用HuggingFace Transformers而不使用vLLM,可以运行以下脚本:

bash ./bashes/bash-vanilla-deer.sh

3. 应用案例和最佳实践

评估

DEER支持在7个推理基准上进行评估。评估基于来自LIMO项目的代码实现。以下是一个评估示例:

python ../check.py \
--model_name_or_path "./DeepSeek-R1-Distill-Qwen-14B" \
--data_name "math" \
--generation_path "your_output.jsonl"

或者运行脚本:

bash ./bashes/bash-check-correct.sh

引用

如果您的研

DEER This is the repository of DEER, a Dynamic Early Exit in Reasoning method for Large Reasoning Language Models. DEER 项目地址: https://gitcode.com/gh_mirrors/deer6/DEER

创作声明:本文部分内容由AI辅助生成(AIGC),仅供参考

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

穆灏璞Renata

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值