█

AI/TLDR

Buy me a coffee
Buy me a coffee

EAGLE

Speculative decoding that drafts tokens from an LLM's own features to speed up generation without changing its output

Serving & DeploymentOpen source
Language
Python
License
Apache-2.0
Coverage
1 story
$git clone https://github.com/SafeAILab/EAGLE.git
IN SHORT

What is EAGLE?

EAGLE (Extrapolation Algorithm for Greater Language-model Efficiency) is a speculative-decoding method for making large language models generate text faster, and this repository is its official implementation from SafeAI Lab. It sits in the Serving & Deployment category of the Models & Inference tools and is open-source, written in Python and licensed Apache-2.0.

Overview

EAGLE (Extrapolation Algorithm for Greater Language-model Efficiency) is a speculative-decoding method for making large language models generate text faster, and this repository is its official implementation from SafeAI Lab. Instead of running a separate small model as the drafter, EAGLE attaches a lightweight draft head to the target model that works from the model's own internal feature vectors to guess several tokens ahead; the full model then verifies those guesses in one pass. Because verification decides what is kept, the method is designed to preserve the distribution of the text the original model would have produced — the speed-up comes without a change in output quality.

The repository covers three generations of the idea. EAGLE-1 extrapolates the second-top-layer features of the LLM. EAGLE-2 uses the draft model's confidence scores to approximate acceptance rates and reshapes the draft tree on the fly. EAGLE-3 drops the feature-prediction constraint, simulates it during training with a "training-time test", and fuses low-, mid- and high-level features instead of relying on the top layer alone. The main branch implements EAGLE-3 and EAGLE-2; EAGLE-1 lives on the `v1` branch.

Bar chart of decoding speed-up over vanilla decoding for Vicuna 13B, LLaMA-Instruct 3.1 8B, LLaMA-Instruct 3.3 70B and DeepSeek R1 LLaMA 8B, comparing speculative sampling, Medusa, HASS, EAGLE, EAGLE-2 and EAGLE-3, with EAGLE-3 the tallest bar in each group at 5.6x, 4.4x, 4.1x and 5.0x
Speed-ups reported by the EAGLE authors: EAGLE-3 against vanilla decoding and earlier speculative methods on four base models.EAGLE README ↗

In practice you pair a base model from Hugging Face with a matching EAGLE draft checkpoint. The project publishes official EAGLE-3 weights for Vicuna-13B, Llama 3.1 8B, Llama 3.3 70B and DeepSeek-R1-Distill-Llama-8B, plus EAGLE-1 weights for Vicuna, Llama 2/3 chat, Mixtral and Qwen2 models, and its README lists community checkpoints for Qwen3, Llama 4, GPT-OSS and others. You can then chat with the pair through a Gradio web UI, call an `eagenerate` method that mirrors Hugging Face's `generate`, benchmark it on MT-bench, or train your own draft head.

The method has spread beyond this codebase: the README lists EAGLE support in serving and optimization frameworks including vLLM, SGLang, NVIDIA TensorRT-LLM, TensorRT Model Optimizer, NeMo, MLC-LLM, AWS NeuronX, AMD ROCm and PaddleNLP. For training EAGLE-3 heads to use with SGLang, the maintainers recommend SpecForge. The repository itself is Python and Apache-2.0.

What it does

  • Official implementations of EAGLE-1, EAGLE-2 (dynamic draft trees) and EAGLE-3 (multi-level feature fusion with training-time test)
  • Designed to keep the base model's output distribution while generating several tokens per verification step, including non-greedy sampling
  • `EaModel.from_pretrained` plus `eagenerate`, a drop-in counterpart to Hugging Face `generate`, with weights spread across multiple GPUs automatically
  • A Gradio web UI for chatting with a base model and its EAGLE head, with a tunable number of draft tokens (or `-1` to let EAGLE-2 choose)
  • DeepSpeed training code for EAGLE-3 draft heads and MT-bench scripts that measure speed against vanilla autoregressive decoding
  • Published draft weights for Vicuna, Llama 2/3/3.1/3.3, Mixtral, Qwen2 and DeepSeek-R1-Distill models, with community checkpoints for many more

Getting started

The repository runs as a Python package in its own virtual environment. You need a base model and a matching EAGLE checkpoint; the README's tables list which draft weights go with which base model.

Install

bashbash
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

Try it in the web UI

Point the UI at an EAGLE checkpoint and its base model. When loading finishes, a URL is printed in the terminal to open in your browser. `--total-token` is the number of draft tokens; larger values suit smaller models and faster GPUs, and `-1` lets EAGLE-2 configure it automatically.

bashbash
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]

Generate from code

`eagenerate` is used like Hugging Face's `generate`. EAGLE-3 is the default; pass `use_eagle3=False` to `from_pretrained` to load EAGLE-1 weights. Chat models need their correct chat template, or output quality and speed-up both suffer.

pythonpython
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()
conv = get_conversation_template("vicuna")
conv.append_message(conv.roles[0], "Hello")
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])

Measure the speed-up

Run MT-bench with EAGLE and then with plain autoregressive decoding; each command writes a .jsonl file with outputs and wall time, and `evaluation/speed.py` computes the ratio. Models download automatically, which may require `huggingface-cli login`.

bashbash
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

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

Train your own draft head

The EAGLE-3 trainer runs under DeepSpeed. For out-of-the-box EAGLE-3 training aimed at SGLang, the maintainers recommend SpecForge instead.

bashbash
cd eagle/traineagle3
deepspeed main.py --deepspeed_config ds_config.json

Commands and code are distilled from the project's own documentation — always check the official repo for the latest.

When to use it

  • Reach for it when generation latency is the bottleneck and you want faster decoding from an existing LLM without accepting a change in its outputs
  • Reach for it to train an EAGLE draft head for a model that has no published checkpoint, then deploy it in a serving engine that supports EAGLE
  • Reach for it to benchmark speculative decoding on your own hardware and model before enabling it in production
  • Reach for it when you are researching speculative decoding and need the reference code behind EAGLE-1, EAGLE-2 and EAGLE-3

How EAGLE compares

EAGLE alongside other open-source serving & deployment tools AI/TLDR tracks, ranked by GitHub stars.

ToolStarsWhat it does
Transformers★ 169kHugging Face Transformers is a Python framework that defines and runs state-of-the-art pretrained models for text, vision, audio, and multimodal tasks, for both inference and training.
vLLM★ 96.2kA high-throughput LLM serving engine that uses PagedAttention and continuous batching to serve many requests at once.
SGLang★ 38.4kA serving framework for LLMs and multimodal models that boosts throughput by reusing shared prompt prefixes across requests.
Modular Platform★ 30.1kModular's AI platform: the MAX inference framework with an OpenAI-compatible serving endpoint and GPU kernel library, plus the Mojo language and compiler.
DeepInfer★ 25.2kDeepSeek's own large-scale inference framework for its models, with expert parallelism, confidence-scheduled speculative decoding and NVIDIA plus Ascend support.
TensorRT-LLM★ 15kNVIDIA's library that compiles LLMs into optimized engines for the fastest inference on its data-center GPUs.
OpenLLM★ 12.6kA tool to run any open-source LLM as an OpenAI-compatible API endpoint locally or in the cloud.
EAGLE★ 2.6kSpeculative decoding that drafts tokens from an LLM's own features to speed up generation without changing its output