arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2407.02486cs.CLcs.AIcs.LG
收藏

Neurocache:面向长程语言建模的高效向量检索

Neurocache: Efficient Vector Retrieval for Long-range Language Modeling

KUIS AI Center(KUIS人工智能中心);Koç University(科克大学)

Ali Safaya, Deniz Yuret

AI总结:

提出 Neurocache,通过外部压缩向量缓存、每 token 一次 kNN 检索及相邻状态窗口扩展 LLM 有效上下文,并在从零训练模型与 Llama2-7B、Mistral-7B 上验证其提速和任务性能。

摘要:

本文介绍 Neurocache,这是一种利用外部向量缓存存储大语言模型(LLM)过去状态,以扩展其有效上下文长度的方法。与近期的向量检索方法类似,Neurocache 使用高效的 k 近邻(kNN)算法检索相关的过去状态,并将其纳入注意力过程。Neurocache 对以往方法作出三点改进:(1)存储压缩状态,从而减小缓存大小;(2)每个 token 仅执行一次检索操作,从而提高推理速度;(3)将检索窗口扩展至相邻状态,从而同时提升语言建模和下游任务准确率。实验表明,无论是从零开始训练的模型,还是通过该缓存机制增强的 Llama2-7B、Mistral-7B 等预训练模型,Neurocache 都表现出有效性。我们还将 Neurocache 与文本检索方法进行比较,结果显示其在单文档问答和少样本学习任务上均有提升。源代码已发布于:https://github.com/alisafaya/neurocache

英文摘要:

This paper introduces Neurocache, an approach to extend the effective context size of large language models (LLMs) using an external vector cache to store its past states. Like recent vector retrieval approaches, Neurocache uses an efficient k-nearest-neighbor (kNN) algorithm to retrieve relevant past states and incorporate them into the attention process. Neurocache improves upon previous methods by (1) storing compressed states, which reduces cache size; (2) performing a single retrieval operation per token which increases inference speed; and (3) extending the retrieval window to neighboring states, which improves both language modeling and downstream task accuracy. Our experiments show the effectiveness of Neurocache both for models trained from scratch and for pre-trained models such as Llama2-7B and Mistral-7B when enhanced with the cache mechanism. We also compare Neurocache with text retrieval methods and show improvements in single-document question-answering and few-shot learning tasks. We made the source code available under: https://github.com/alisafaya/neurocache

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

↑