arXiv:2505.16983cs.CL2025-05ACL被引 12

用分组位置编码让大模型高效处理流式输入,无需重编码

LLM as Effective Streaming Processor: Bridging Streaming-Batch Mismatches with Group Position Encoding

  • 提出分组位置编码解决流式与批量处理的三类不匹配问题
  • 实验证明仅输入注意力不匹配影响性能,输出重编码可省去
  • 不改架构、通用性强,适合需要实时处理的场景

大型语言模型(LLMs)主要面向批量处理设计。现有将LLMs适配到流式处理的方法要么依赖昂贵的重新编码,要么采用专用架构且扩展性差。本文识别出三类关键不匹配:(1)输入-注意力,(2)输出-注意力,(3)位置编号。尽管普遍认为后两类需频繁重编码,但分析表明,只有输入-注意力不匹配显著影响性能,说明输出重编码基本无需。为解释这一与常识的差异,本文首次系统分析了位置编码在流式场景下的影响,发现保持源和目标上下文内的相对位置比维持绝对顺序更为重要。基于此,我们提出一种基于批处理架构的分组位置编码范式,以增强流式与批量模式的一致性。跨语言与跨模态任务上的大量实验表明,该方法优于现有方案。本方法无需架构修改,在流式与批量模式下均表现出强泛化能力。代码已开源:https://github.com/EIT-NLP/StreamingLLM。

原文摘要 · Abstract (English)

Large Language Models (LLMs) are primarily designed for batch processing. Existing methods for adapting LLMs to streaming rely either on expensive re-encoding or specialized architectures with limited scalability. This work identifies three key mismatches in adapting batch-oriented LLMs to streaming: (1) input-attention, (2) output-attention, and (3) position-ID mismatches. While it is commonly assumed that the latter two mismatches require frequent re-encoding, our analysis reveals that only the input-attention mismatch significantly impacts performance, indicating re-encoding outputs is largely unnecessary. To better understand this discrepancy with the common assumption, we provide the first comprehensive analysis of the impact of position encoding on LLMs in streaming, showing that preserving relative positions within source and target contexts is more critical than maintaining absolute order. Motivated by the above analysis, we introduce a group position encoding paradigm built on batch architectures to enhance consistency between streaming and batch modes. Extensive experiments on cross-lingual and cross-modal tasks demonstrate that our method outperforms existing approaches. Our method requires no architectural modifications, exhibits strong generalization in both streaming and batch modes. The code is available at repository https://github.com/EIT-NLP/StreamingLLM.

流式处理位置编码大模型

Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。