EAGLE 드래프트 모델

EAGLE 드래프트 모델 (EAGLE Draft Models)

EAGLE(Extrapolation Algorithm for Greater Language-model Efficiency)는 스펙큘레이티브 디코딩에서 높은 수용률로 유명한 모델 기반 방법이에요. vLLM에서 EAGLE 기반 드래프트 모델로 제안을 생성하도록 설정하는 방법을 살펴볼게요.

출처: vLLM 공식 문서 — EAGLE Draft Models

Eagle Drafter 예시

아래 코드는 EAGLE 기반 드래프트 모델이 제안을 생성하도록 vLLM을 구성해요. 오프라인 방식의 더 자세한 예시(요청 수준 수용률 추출 포함)는 examples/offline_inference/spec_decode.py에서 볼 수 있어요.

from vllm import LLM, SamplingParams

prompts = ["The future of AI is"]
sampling_params = SamplingParams(temperature=0.8, top_p=0.95)

llm = LLM(
    model="meta-llama/Meta-Llama-3-8B-Instruct",
    tensor_parallel_size=4,
    speculative_config={
        "model": "yuhuili/EAGLE-LLaMA3-Instruct-8B",
        "draft_tensor_parallel_size": 1,
        "num_speculative_tokens": 2,
        "method": "eagle",
    },
)

outputs = llm.generate(prompts, sampling_params)

for output in outputs:
    prompt = output.prompt
    generated_text = output.outputs[0].text
    print(f"Prompt: {prompt!r}, Generated text: {generated_text!r}")

Eagle3 Drafter 예시

from vllm import LLM, SamplingParams

prompts = ["The future of AI is"]
sampling_params = SamplingParams(temperature=0.8, top_p=0.95)

llm = LLM(
    model="meta-llama/Meta-Llama-3-8B-Instruct",
    tensor_parallel_size=2,
    speculative_config={
        "model": "RedHatAI/Llama-3.1-8B-Instruct-speculator.eagle3",
        "draft_tensor_parallel_size": 2,
        "num_speculative_tokens": 2,
        "method": "eagle3",
    },
)

outputs = llm.generate(prompts, sampling_params)

for output in outputs:
    prompt = output.prompt
    generated_text = output.outputs[0].text
    print(f"Prompt: {prompt!r}, Generated text: {generated_text!r}")

사전 훈련된 Eagle 드래프트 모델 (Pre-trained models)

다양한 EAGLE 드래프트 모델이 Hugging Face hub에서 제공돼요.

⚠️ vllm<0.7.0을 쓴다면 이 변환 스크립트로 스펙큘레이티브 모델을 변환하고, speculative_config에서 "model": "path/to/modified/eagle/model"을 지정해야 해요. (변환 스크립트 링크는 원문 참고 — 확인 필요)

더 알아보기 (Learn more)