Skip to main content
QUICK REVIEW

[论文解读] Inference with Reference: Lossless Acceleration of Large Language Models

Nan Yang, Tao Ge|arXiv (Cornell University)|Apr 10, 2023
Topic ModelingComputer Science被引用 14
一句话总结

LLMA 通过从参考文档复制匹配的文本片段来加速自回归 LLM 的解码,实现并行验证,并在不需要额外模型的情况下获得约 2x–3x 的加速。

ABSTRACT

We propose LLMA, an LLM accelerator to losslessly speed up Large Language Model (LLM) inference with references. LLMA is motivated by the observation that there are abundant identical text spans between the decoding result by an LLM and the reference that is available in many real world scenarios (e.g., retrieved documents). LLMA first selects a text span from the reference and copies its tokens to the decoder and then efficiently checks the tokens' appropriateness as the decoding result in parallel within one decoding step. The improved computational parallelism allows LLMA to achieve over 2x speed-up for LLMs with identical generation results as greedy decoding in many practical generation scenarios where significant overlap between in-context reference and outputs exists (e.g., search engines and multi-turn conversations).

研究动机与目标

  • 在不改变模型权重的前提下,提出降低自回归 LLM 推理成本的动机。
  • 利用生成文本与可用参考文档之间的重叠来加速解码。
  • 提出一种基于参考的解码机制,在保持与贪婪输出完全一致的前提下进行解码。
  • 在检索增强生成、缓存会话和多轮对话场景中展示实际的加速效果。

提出的方法

  • 引入 LLMA 解码,在参考中找到匹配的文本片段并将其标记的 token 拷贝到解码器输入中。
  • 发现匹配时预先拷贝长度为 k 的 token 序列,并对每个 token 的有效性与模型的下一个 token 概率进行核验。
  • 通过逐 token 验证确保输出与普通贪婪解码一致。
  • 以两个超参数 n(匹配长度)和 k(拷贝长度)来控制触发与拷贝的程度。
  • 支持两种部署场景:检索增强生成(RAG)和缓存辅助生成(CAG),并由此扩展至多轮对话。
  • 在标准自回归解码的基础上,增加拷贝并核验步骤实现,不需要训练或额外的草拟模型。
(a) Retrieval-augmented.
(a) Retrieval-augmented.

实验结果

研究问题

  • RQ1LLMA 在不同模型规模(7B、13B、30B)和场景(RAG、CAG)下可以实现多大程度的加速?
  • RQ2对于不同设置,最优的匹配长度 n 和拷贝长度 k 是多少?
  • RQ3与基线贪婪解码相比,LLMA 在每秒处理的 token 和总解码时间方面表现如何?
  • RQ4LLMA 在加速解码的同时,是否能保持与传统贪婪解码相同的生成结果?

主要发现

  • 在 RAG 和 CAG 场景下,7B、13B 和 30B 模型的 LLMA 约实现 2x–3x 的加速。
  • 不同模型和场景下,最优的匹配长度和拷贝长度各不相同,实验中 n 常为 1,k 大多在 14–18 左右。
  • 通过在接受拷贝前对拷贝的 token 进行验证,LLMA 能保持输出与贪婪解码完全一致。
  • 加速来自于更好的并行性和更少的解码步骤,尤其是对更大模型以及当 k 较大(达到 15 及以上)时。
  • 在基于 GPT-3.5/DaVinci-003 派生的提示上进行的实验表明,在使用检索或缓存参考的现实场景中也能实现实际收益。
(b) Cache-assisted.
(b) Cache-assisted.

阅读本论文

在 Nubint 阅读器中打开原文,边读边就任意段落提问。

在 Nubint 中阅读本论文

本解读由 AI 根据论文原文生成,引用前请核对原文。