XL3M:一种基于分段推理的免训练大语言模型长度扩展框架
XL3M: A Training-free Framework for LLM Length Extension Based on Segment-wise Inference
AI总结:
本文提出免训练框架XL3M,通过分段推理和相关性筛选构建关键上下文,使短序列训练的LLM能推理超长序列,Llama2-7B在8卡NPU上可处理2000万长度。
摘要:
长度泛化失败问题,即大语言模型(LLM)无法泛化到超过其最大训练长度的文本,极大地限制了LLM在具有流式长输入场景中的应用。为解决这一问题,现有方法要么需要大量成本,要么引入精度损失。在本文中,我们通过实验发现,LLM预测的准确性与它的确定性高度相关。基于此,我们提出了一种高效的免训练框架,名为XL3M(意为超长的大语言模型),该框架使得在短序列上训练的LLM能够推理极长的序列,而无需任何进一步训练或微调。在XL3M框架下,输入上下文首先被分解为多个短的子上下文,其中每个子上下文包含一个独立的片段和一个共同的“问题”,该“问题”是原始上下文末尾的几个词元。然后,XL3M提供了一种方法来衡量每个片段与“问题”之间的相关性,并通过按时间顺序拼接所有相关片段来构建一个简洁的关键上下文。该关键上下文进一步用于替代原始上下文来完成推理任务。在综合基准上的评估显示了XL3M的优越性。使用我们的框架,一个Llama2-7B模型能够在具有每卡64GB内存的8卡华为昇腾910B NPU机器上推理2000万长度的序列。
英文摘要:
Length generalization failure problem, namely the large language model (LLM) fails to generalize to texts longer than its maximum training length, greatly restricts the application of LLM in the scenarios with streaming long inputs. To address this problem, the existing methods either require substantial costs or introduce precision loss. In this paper, we empirically find that the accuracy of the LLM's prediction is highly correlated to its certainty. Based on this, we propose an efficient training free framework, named XL3M (it means extra-long large language model), which enables the LLMs trained on short sequences to reason extremely long sequence without any further training or fine-tuning. Under the XL3M framework, the input context will be firstly decomposed into multiple short sub-contexts, where each sub-context contains an independent segment and a common ``question'' which is a few tokens from the end of the original context. Then XL3M gives a method to measure the relevance between each segment and the ``question'', and constructs a concise key context by splicing all the relevant segments in chronological order. The key context is further used instead of the original context to complete the inference task. Evaluations on comprehensive benchmarks show the superiority of XL3M. Using our framework, a Llama2-7B model is able to reason 20M long sequences on an 8-card Huawei Ascend 910B NPU machine with 64GB memory per card.
机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。