arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2405.04065cs.CL
收藏

FlashBack:面向快速推理的高效检索增强语言建模

FlashBack: Efficient Retrieval-Augmented Language Modeling for Fast Inference

School of Computer Science and Technology, Beijing Institute of Technology(计算机科学与技术学院,北京理工大学)

Runheng Liu, Xingchen Xiao, Heyan Huang, Zewen Chi, Zhijing Wu

AI总结:

FlashBack通过将检索文档追加到上下文末尾并引入标记令牌,利用KV缓存提升检索增强语言模型的推理速度,在7B模型上比前置方法快4倍,同时保持生成质量。

摘要:

检索增强语言建模(RALM)通过将大型语言模型(LLM)与外部语料库中的相关文档相结合,是一种已被证明能使LLM生成超出其预训练语料库范围信息的方法。以往的工作通过简单地将检索到的内容前置到输入中,带来了高运行时问题,这降低了LLM的推理效率,因为它们未能高效利用键值(KV)缓存。在本文中,我们提出了FlashBack,一种模块化的RALM,旨在通过追加上下文模式提高RALM的推理效率,同时通过低秩适配(Low-Rank Adaption)微调后保持良好性能。FlashBack将检索到的文档追加到上下文末尾,而非前置,以高效利用KV缓存。我们还引入了标记令牌(Marking Token)作为两个特殊的提示令牌,用于在微调期间标记追加上下文的边界。我们关于生成质量的实验表明,FlashBack在困惑度方面能保持不错的生成质量。在运行时测试中,FlashBack在7B LLM(Llama 2)上的推理速度比前置对应方法快高达4倍。通过绕过不必要的重新计算,它展示了实现显著更快推理速度的进步,而这种高效率将大幅降低推理成本。

英文摘要:

Retrieval-Augmented Language Modeling (RALM) by integrating large language models (LLM) with relevant documents from an external corpus is a proven method for enabling the LLM to generate information beyond the scope of its pre-training corpus. Previous work utilizing retrieved content by simply prepending it to the input poses a high runtime issue, which degrades the inference efficiency of the LLMs because they fail to use the Key-Value (KV) cache efficiently. In this paper, we propose FlashBack, a modular RALM designed to improve the inference efficiency of RALM with appending context pattern while maintaining decent performance after fine-tuning by Low-Rank Adaption. FlashBack appends retrieved documents at the end of the context for efficiently utilizing the KV cache instead of prepending them. And we introduce Marking Token as two special prompt tokens for marking the boundary of the appending context during fine-tuning. Our experiments on testing generation quality show that FlashBack can remain decent generation quality in perplexity. And the inference speed of FlashBack is up to $4\times$ faster than the prepending counterpart on a 7B LLM (Llama 2) in the runtime test. Via bypassing unnecessary re-computation, it demonstrates an advancement by achieving significantly faster inference speed, and this heightened efficiency will substantially reduce inferential cost.

机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。

↑