跳到内容

MLP 草稿模型

以下代码配置了 vLLM 以使用投机采样(Speculative Decoding),其中草稿由草稿模型生成,这些模型基于上下文向量和已采样的标记(tokens)来调整草稿预测。有关更多信息,请参阅投机采样指南(The Hitchhiker's Guide to Speculative Decoding)以及 IBM 研究院的技术报告

MLP 草稿模型示例

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.1-8B-Instruct",
    tensor_parallel_size=1,
    speculative_config={
        "model": "ibm-ai-platform/llama3-8b-accelerator",
        "draft_tensor_parallel_size": 1,
        "method": "mlp_speculator",
    },
)
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}")

已知问题

ibm-ai-platform/llama3-70b-accelerator 可能会失败并报错:AttributeError: 'MLPSpeculatorConfig' object has no attribute 'num_attention_heads'。请关注以下链接以跟踪状态: #34106 #34163

预训练的 MLP 草稿模型

HF hub 上提供了多种此类投机模型