通过可扩展分词实现大语言模型上下文的灵活扩展
Flexibly Scaling Large Language Models Contexts Through Extensible Tokenization
AI总结:
本文提出可扩展分词(Extensible Tokenization),通过将原始 token 嵌入转换为更紧凑的可扩展嵌入,在不微调的情况下灵活扩展大语言模型的上下文长度,并可作为即插即用组件兼容原始模型及其微调版本。
摘要:
大语言模型(LLMs)需要足够的上下文来处理许多关键应用,例如检索增强生成和少样本学习。然而,由于窗口大小受限,LLMs 只能访问有限上下文内的信息。尽管可以通过微调来扩展上下文窗口的大小,但这会在训练和推理阶段都带来巨大的成本。在本文中,我们提出可扩展分词(Extensible Tokenization)作为一种替代方法,实现 LLMs 上下文的灵活扩展。可扩展分词位于分词后的上下文与 LLM 之间,充当中间件,将原始 token 嵌入转换为可扩展嵌入。这种嵌入为长上下文提供了更紧凑的表示,在此基础上,LLM 能够在相同的上下文窗口内感知更多信息。可扩展分词还具有灵活性特点:扩展因子可以在可行范围内灵活确定,从而在推理时实现任意上下文长度的扩展。此外,可扩展分词作为一个即插即用组件被引入,不仅可以无缝接入 LLM 本身,还可以接入其微调衍生模型,在完全保留 LLM 现有能力的同时带来扩展的上下文信息。我们在长上下文语言建模和理解任务上进行了全面实验,验证了可扩展分词是一种有效、高效、灵活且兼容的 LLM 上下文扩展方法。我们的模型和源代码将公开发布。
英文摘要:
Large language models (LLMs) are in need of sufficient contexts to handle many critical applications, such as retrieval augmented generation and few-shot learning. However, due to the constrained window size, the LLMs can only access to the information within a limited context. Although the size of context window can be extended by fine-tuning, it will result in a substantial cost in both training and inference stage. In this paper, we present Extensible Tokenization as an alternative method which realizes the flexible scaling of LLMs' context. Extensible Tokenization stands as a midware in between of the tokenized context and the LLM, which transforms the raw token embeddings into the extensible embeddings. Such embeddings provide a more compact representation for the long context, on top of which the LLM is able to perceive more information with the same context window. Extensible Tokenization is also featured by its flexibility: the scaling factor can be flexibly determined within a feasible scope, leading to the extension of an arbitrary context length at the inference time. Besides, Extensible Tokenization is introduced as a drop-in component, which can be seamlessly plugged into not only the LLM itself and but also its fine-tuned derivatives, bringing in the extended contextual information while fully preserving the LLM's existing capabilities. We perform comprehensive experiments on long-context language modeling and understanding tasks, which verify Extensible Tokenization as an effective, efficient, flexible, and compatible method to extend LLM's context. Our model and source code will be made publicly available.
机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。