arXivDaily arXiv每日学术速递 周一至周五更新
arXiv周末暂无论文更新,休息一下吧,周末愉快~~
arXiv 2506.06266cs.CLcs.AIcs.LG
收藏

Cartridges:通过自学实现的轻量级通用长上下文表示

Cartridges: Lightweight and general-purpose long context representations via self-study

Department of XXX, University of YYY, Location, Country(XXX系,YYY大学,地点,国家);School of ZZZ, Institute of WWW, Location, Country(ZZZ学院,WWW研究所,地点,国家)

Sabri Eyuboglu, Ryan Ehrlich, Simran Arora, Neel Guha, Dylan Zinsley, Emily Liu, Will Tennien, Atri Rudra, James Zou, Azalia Mirhoseini, Christopher Re

AI总结:

针对大模型长上下文推理KV缓存成本高的问题,提出名为Cartridge的离线训练小型KV缓存方案,通过自学训练策略复现ICL性能,大幅降低内存占用、提升吞吐量,还可扩展有效上下文长度并支持推理时组合。

摘要:

大语言模型常通过将整个语料库置于上下文窗口并利用上下文学习(ICL),来回答基于大型文本语料库(如代码库、法律文档或聊天记录)的查询。尽管当前模型支持10万至100万token的上下文,但这种部署方式成本高昂,因为KV缓存的内存消耗随输入长度线性增长。我们探索了一种替代方案:针对每个语料库离线训练一个更小的KV缓存。推理时,我们加载这个训练好的KV缓存(我们称之为Cartridge)并解码生成回复。关键在于,训练一个Cartridge的成本可在所有引用同一语料库的查询间分摊。然而我们发现,在语料库上用下一词元预测训练Cartridge的朴素方法,性能无法与ICL匹敌。为此我们提出自学(self-study)训练方案:生成关于该语料库的合成对话,并以上下文蒸馏目标训练Cartridge。我们发现,经自学训练的Cartridge可复现ICL的功能,同时部署成本显著降低。在具有挑战性的长上下文基准测试中,经自学训练的Cartridge性能与ICL相当,同时内存占用减少38.6倍,吞吐量提升26.4倍。自学还扩展了模型的有效上下文长度(例如在MTOB基准上从128k token扩展至484k token),且出人意料的是,生成的Cartridge可在推理时直接组合,无需重新训练。

英文摘要:

Large language models are often used to answer queries grounded in large text corpora (e.g. codebases, legal documents, or chat histories) by placing the entire corpus in the context window and leveraging in-context learning (ICL). Although current models support contexts of 100K-1M tokens, this setup is costly to serve because the memory consumption of the KV cache scales with input length. We explore an alternative: training a smaller KV cache offline on each corpus. At inference time, we load this trained KV cache, which we call a Cartridge, and decode a response. Critically, the cost of training a Cartridge can be amortized across all the queries referencing the same corpus. However, we find that the naive approach of training the Cartridge with next-token prediction on the corpus is not competitive with ICL. Instead, we propose self-study, a training recipe in which we generate synthetic conversations about the corpus and train the Cartridge with a context-distillation objective. We find that Cartridges trained with self-study replicate the functionality of ICL, while being significantly cheaper to serve. On challenging long-context benchmarks, Cartridges trained with self-study match ICL performance while using 38.6x less memory and enabling 26.4x higher throughput. Self-study also extends the model's effective context length (e.g. from 128k to 484k tokens on MTOB) and surprisingly, leads to Cartridges that can be composed at inference time without retraining.

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

↑