EAGLE Draft Models
EAGLE Draft Models (EAGLE 드래프트 모델)
EAGLE(Extrapolation Algorithm for Greater Language-model Efficiency)는 언어 모델의 효율을 높이기 위한 추외삽(external) 기반 드래프트 모델이에요. 아래 코드는 EAGLE 기반 드래프트 모델이 제안(proposal)을 생성하는 추측 디코딩을 vLLM에서 구성하는 예시예요. 오프라인 모드에서 요청 수준 수락율을 추출하는 방법을 포함한 더 자세한 예시는 examples/features/speculative_decoding/spec_decode_offline.py에서 찾을 수 있어요.
출처: 문서
본문
Eagle 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=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 드래프트 모델
다양한 EAGLE 드래프트 모델이 Hugging Face hub에서 제공돼요:
RedHatAI/speculator-modelsyuhuili/models
경고:
vllm<0.7.0을 사용한다면 이 스크립트를 사용해 스펙큘레이티브 모델을 변환하고,speculative_config에서"model": "path/to/modified/eagle/model"을 지정하세요.