需额外从 Hugging Face 下载官方 EAGLE-3 权重,仓库只认官方 checkpoint;Qwen2 作为目标模型时须用 bf16 而非 fp16 以避免数值溢出;默认主分支是 EAGLE-3/2 实现,用 EAGLE-1 需切到 v1 分支,且用 EAGLE 权重要在 from_pretrained 里设 use_eagle3=False。

EAGLE
SafeAILab更新放缓EAGLE 系列投机解码算法的官方实现,通过草稿模型加速大语言模型推理,在几乎不损失生成质量的前提下显著提升吞吐。
Official Implementation of EAGLE-1 (ICML'24), EAGLE-2 (EMNLP'24), and EAGLE-3 (NeurIPS'25).
git clone https://github.com/SafeAILab/EAGLE.git
cd EAGLE
python -m venv ~/venvs/ea_env
source ~/venvs/ea_env/bin/activate
pip install -r requirements.txtREADME 称可在 8x RTX 3090 上完成训练(1-2 天)与测试;推理示例在 2x RTX 3090、fp16 下运行 Vicuna 13B。README 未给出具体显存数值,也未说明是否支持 CPU 运行。
EAGLE 是 LLM 推测解码加速方案,用草稿模型外推特征,在保持输出分布一致的前提下提速生成
EAGLE 系列投机解码算法的官方实现,通过草稿模型加速大语言模型推理,在几乎不损失生成质量的前提下显著提升吞吐。
核心能力
- 外推 LLM 第二顶层上下文特征向量做草稿预测
- EAGLE-2 用草稿模型置信度动态调整草稿树结构
- EAGLE-3 融合低中高语义特征替代顶层特征预测
- 可与非贪婪采样结合并保持文本分布一致
- 可搭配 vLLM、SGLang、TensorRT-LLM 等主流框架
容易踩的坑
暂无 release 数据(可能没有发版,或尚未同步)。
用户点评
登录用户的真实使用记录,可按版本和硬件筛选还没有人点评。第一个说出真实体验的人最有价值。
EAGLE
EAGLE (Extrapolation Algorithm for Greater Language-model Efficiency) is a new baseline for fast decoding of Large Language Models (LLMs) with provable performance maintenance. This approach involves extrapolating the second-top-layer contextual feature vectors of LLMs, enabling a significant boost in generation efficiency.
- EAGLE is:
- certified by the third-party evaluation as the fastest speculative method so far.
- achieving 2x speedup on gpt-fast.
- 3x faster than vanilla decoding (13B).
- 2x faster than Lookahead (13B).
- 1.6x faster than Medusa (13B).
- provably maintaining the consistency with vanilla decoding in the distribution of generated texts.
- trainable (within 1-2 days) and testable on 8x RTX 3090 GPUs. So even the GPU poor can afford it.
- combinable with other parallelled techniques such as vLLM, DeepSpeed, Mamba, FlashAttention, quantization, and hardware optimization.
EAGLE-2 uses the confidence scores from the draft model to approximate acceptance rates, dynamically adjusting the draft tree structure, which further enhances performance.
- EAGLE-2 is:
- 4x faster than vanilla decoding (13B).
- 1.4x faster than EAGLE-1 (13B).
EAGLE-3 removes the feature prediction constraint in EAGLE and simulates this process during training using training-time testing. Considering that top-layer features are limited to next-token prediction, EAGLE-3 replaces them with a fusion of low-, mid-, and high-level semantic features. EAGLE-3 further improves generation speed while ensuring lossless performance.
- EAGLE-3 is:
- 5.6 faster than vanilla decoding (13B).
- 1.8x faster than EAGLE-1 (13B).
Inference is conducted on 2x RTX 3090 GPUs at fp16 precision using the Vicuna 13B model.
Support
EAGLE has been merged in the following mainstream LLM serving frameworks (listed in alphabetical order).
- AMD ROCm
- AngelSlim
- AWS NeuronX Distributed Core
- CPM.cu
- Intel® Extension for Transformers
- Intel® LLM Library for PyTorch
- MLC-LLM
- NVIDIA NeMo Framework
- NVIDIA TensorRT-LLM
- NVIDIA TensorRT Model Optimizer
- PaddleNLP
- SGLang
- SpecForge
- speculators
- vLLM
Update
2025.9.18: EAGLE-3 is accepted to NeurIPS'25.
2025.7.23: We strongly recommend using SpecForge for out-of-the-box training of EAGLE-3 with SGLang.
2025.3.19: EAGLE-3 is released.
2024.8.8: We now support Qwen-2.
2024.6.27: EAGLE-2 is released.
2024.2.25: EAGLE is certified by the third-party evaluation as the fastest speculative method.
2024.1.17: We now support Mixtral-8x7B-Instruct.
2023.12.8: EAGLE v1.0 is released.
Todo
- Support non-greedy inference (provably maintaining text distribution).
- Support more LLMs such as Mixtral 8x7B.
- Support LLaMA-3.
- Support Qwen-2.
- Support vLLM (please check vLLM's implementation).
- EAGLE-3.
- Training code of EAGLE-3.
- Support LLaMA-4.
- Support official EAGLE-3 for Qwen-3.
- EAGLE-4.
The default main branch is the implementation of EAGLE-3 and EAGLE-2. For using EAGLE-1, please switch to the v1 branch.
Contents
Setup & Installation
git clone https://github.com/SafeAILab/EAGLE.git
cd EAGLE
python -m venv ~/venvs/ea_env
source ~/venvs/ea_env/bin/activate
pip install -r requirements.txt
EAGLE-3 Weights
Note: This repository recognizes only official EAGLE-3 checkpoints. Performance of unofficial checkpoints may vary. If you want to compare with EAGLE-3, please compare with official checkpoints and official draft tree setups.
EAGLE-3 Models on Hugging Face
EAGLE Weights
Note: The current code defaults to using EAGLE-3. If you want to use EAGLE weights, please specify use_eagle3=False in EaModel.from_pretrained.
Note: When Qwen2 is the target model, please use bf16 precision instead of fp16 to avoid numerical overflow. The training dataset for the draft model of Qwen2 is ShareGPT, which has removed non-English data. Therefore, if you want to use it on non-English data such as Chinese, please train with the corresponding data.
EAGLE Models on Hugging Face
| Base Model | EAGLE Model | # EAGLE Parameters | Official |
|---|---|---|---|
| Vicuna-7B v1.3 | yuhuili/EAGLE-Vicuna-7B-v1.3 | 0.24B | Yes |
| Vicuna-13B v1.3 | yuhuili/EAGLE-Vicuna-13B-v1.3 | 0.37B | Yes |
| Vicuna-33B v1.3 | yuhuili/EAGLE-Vicuna-33B-v1.3 | 0.56B | Yes |
| LLaMA2-Chat 7B | yuhuili/EAGLE-llama2-chat-7B | 0.24B | Yes |
| LLaMA2-Chat 13B | yuhuili/EAGLE-llama2-chat-13B | 0.37B | Yes |
| LLaMA2-Chat 70B | yuhuili/EAGLE-llama2-chat-70B | 0.99B | Yes |
| Mixtral-8x7B-Instruct v0.1 | yuhuili/EAGLE-mixtral-instruct-8x7B | 0.28B | Yes |
| LLaMA3-Instruct 8B | yuhuili/EAGLE-LLaMA3-Instruct-8B | 0.25B | Yes |
| LLaMA3-Instruct 70B | yuhuili/EAGLE-LLaMA3-Instruct-70B | 0.99B | Yes |
| Qwen2-7B-Instruct | yuhuili/EAGLE-Qwen2-7B-Instruct | 0.26B | Yes |
| Qwen2-72B-Instruct | yuhuili/EAGLE-Qwen2-72B-Instruct | 1.05B | Yes |
| LLaMA3.1-Instruct 8B | yuhuili/EAGLE-LLaMA3.1-Instruct-8B | 0.25B | Yes |
| Qwen2.5-14B-Instruct | Zjcxy-SmartAI/Eagle-Qwen2.5-14B-Instruct | 0.33B | No |
Inference
The inference code we provide automatically allocates model weights (loading a model across multiple GPUs), allowing you to run models that exceed the memory of a single GPU.
With UI
We have provided a suggested web interface, which you can use by running the following command. After the model is fully loaded, a URL will be output in the terminal, which you can enter into your browser to access.
python -m eagle.application.webui --ea-model-path [path of EAGLE weight]\
--base-model-path [path of the original model]\
--model-type [vicuna\llama2\llama3]\
--total-token [int]
The total-token is the number of draft tokens. For smaller models and advanced GPUs, this value can be set larger. Adjusting according to the specific device and model can achieve better results. If set to -1, EAGLE-2 will automatically configure this parameter.
With Code
You can use our provided "eagenerate" for speedup generation just like using 'generate' from Hugging Face. Here is an example.
from eagle.model.ea_model import EaModel
from fastchat.model import get_conversation_template
model = EaModel.from_pretrained(
base_model_path=base_model_path,
ea_model_path=EAGLE_model_path,
torch_dtype=torch.float16,
low_cpu_mem_usage=True,
device_map="auto",
total_token=-1
)
model.eval()
your_message="Hello"
conv = get_conversation_template("vicuna")
conv.append_message(conv.roles[0], your_message)
conv.append_message(conv.roles[1], None)
prompt = conv.get_prompt()
input_ids=model.tokenizer([prompt]).input_ids
input_ids = torch.as_tensor(input_ids).cuda()
output_ids=model.eagenerate(input_ids,temperature=0.5,max_new_tokens=512)
output=model.tokenizer.decode(output_ids[0])
Note: Vicuna, LLaMA2-Chat, and LLaMA3-Instruct are both chat models. You need to use the correct chat template, otherwise it will cause abnormal output from the model and affect the performance of EAGLE.
Train
cd eagle/traineagle3
deepspeed main.py --deepspeed_config ds_config.json
We strongly recommend using SpecForge for out-of-the-box training of EAGLE-3 with SGLang.
Inference on custom models
If the original LLM structure differs from LLaMA and Mixtral, you can utilize EAGLE as follows:
Copy the modeling_basemodelname.py from the Transformers library and proceed to make modifications to leverage the pre-allocated kv_cache for enhanced speed in the base model. You can refer to model/modeling_llama_kv.py for guidance, where places that require modifications are annotated with # [MODIFIED]. These modifications are minimal.
Evaluation
You can test the speed of EAGLE on MT-bench using the following command. The models will be downloaded automatically and you may need to input your Hugging Face Access Tokens by huggingface-cli login.
python -m eagle.evaluation.gen_ea_answer_llama3chat --ea-model-path yuhuili/EAGLE3-LLaMA3.1-Instruct-8B --base-model-path meta-llama/Llama-3.1-8B-Instruct --use_eagle3
huggingface-cli login.
python -m eagle.evaluation.gen_ea_answer_qwen3 --ea-model-path /workspace/yunhai/Qwen3-4B_eagle3 --base-model-path Qwen/Qwen3-4B --use_eagle3
If you need specific acceleration ratios, you will also need to run the following command to get the speed of vanilla auto-regression.
python -m eagle.evaluation.gen_baseline_answer_llama3chat --ea-model-path yuhuili/EAGLE3-LLaMA3.1-Instruct-8B --base-model-path meta-llama/Llama-3.1-8B-Instruct
The above two commands will each generate a .jsonl file that records the generation results and wall time. Then, you can use evaluation/speed.py to calculate the ratio of speeds.
🌟 Our Contributors
A heartfelt thank you to all our contributors.
Reference
For technical details and full experimental results, please check the paper of EAGLE, the paper of EAGLE-2, and the paper of EAGLE-3.
@inproceedings{li2024eagle,
author = {Yuhui Li and Fangyun Wei and Chao Zhang and Hongyang Zhang},
title = {{EAGLE}: Speculative Sampling Requires Rethinking Feature Uncertainty},
booktitle = {International Conference on Machine Learning},
year = {2024}
}
@inproceedings{li2024eagle2,
author = {Yuhui Li and Fangyun Wei and Chao Zhang and Hongyang Zhang},
title = {{EAGLE-2}: Faster Inference of Language Models with Dynamic Draft Trees},
booktitle = {Empirical Methods in Natural Language Processing},
year = {2024}
}
@inproceedings{li2025eagle3,
author = {Yuhui Li and Fangyun Wei and Chao Zhang and Hongyang Zhang},
title = {{EAGLE-3}: Scaling up Inference Acceleration of Large Language Models via Training-Time Test},
booktitle = {Annual Conference on Neural Information Processing Systems},
year = {2025}
}
Acknowledgements
This project has been influenced by many excellent projects in the LLM community, such as Medusa, FastChat, and others. The logo is designed by GPT-4. We also appreciate many valuable discussions with the SGLang team (James Liu, Ke Bao, Yineng Zhang, Lianmin Zheng, Ying Sheng and many others), Tianle Cai, Hao Zhang, Ziteng Sun, and others.