Ltri-LLM:基于无训练动态三角注意力模式的大语言模型流式长上下文推理
Ltri-LLM: Streaming Long Context Inference for LLMs with Training-Free Dynamic Triangular Attention Pattern
AI总结:
针对LLMs长上下文推理成本高的问题,分析发现其注意力分布具强局部相关性,提出Ltri-LLM框架通过划分KV跨度、离线索引存储及检索相关KV,在主流长文本基准上实现接近全注意力的性能与高效流式推理。
摘要:
当前大语言模型(LLMs)中注意力机制的二次计算复杂度导致长上下文推理成本过高。为应对这一挑战,多种方法通过键值(KV)压缩或稀疏注意力(SA)保留上下文的关键部分,以最优近似全注意力(FA),实现流式处理几乎无限长度的文本。然而,这些方法难以达到与FA相当的性能,尤其在检索任务中。本文对注意力头模式的分析表明,LLMs的注意力分布具有强局部相关性,自然反映了输入上下文的分块机制。我们提出Ltri-LLM框架,将KV划分为跨度,存储在离线索引中,并为各类查询检索相关KV到内存。在主流长文本基准上的实验结果显示,Ltri-LLM能在保持高效流式推理的同时,实现接近FA的性能。
英文摘要:
The quadratic computational complexity of the attention mechanism in current Large Language Models (LLMs) renders inference with long contexts prohibitively expensive. To address this challenge, various approaches aim to retain critical portions of the context to optimally approximate Full Attention (FA) through Key-Value (KV) compression or Sparse Attention (SA), enabling the processing of virtually unlimited text lengths in a streaming manner. However, these methods struggle to achieve performance levels comparable to FA, particularly in retrieval tasks. In this paper, our analysis of attention head patterns reveals that LLMs' attention distributions show strong local correlations, naturally reflecting a chunking mechanism for input context. We propose Ltri-LLM framework, which divides KVs into spans, stores them in an offline index, and retrieves the relevant KVs into memory for various queries. Experimental results on popular long text benchmarks show that Ltri-LLM can achieve performance close to FA while maintaining efficient, streaming-based inference.
机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。