arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2402.16617cs.CL
收藏

使用并行上下文编码的长上下文语言建模

Long-Context Language Modeling with Parallel Context Encoding

Princeton Language and Intelligence (PLI)(普林斯顿语言与智能中心)

Howard Yen, Tianyu Gao, Danqi Chen

AI总结:

本文提出 CEPE 框架,通过小型编码器逐块编码长上下文并以交叉注意力注入冻结 decoder-only LLM,将 LLAMA-2 扩展至 128K 且显著降本增效。

摘要:

扩展大型语言模型(LLM)以处理更长输入,对于广泛的应用至关重要。然而,transformer 的巨大计算成本以及位置编码有限的泛化能力限制了其上下文窗口的大小。我们提出 Context Expansion with Parallel Encoding(CEPE,并行编码上下文扩展),这是一个可应用于任何现有 decoder-only LLM 以扩展其上下文窗口的框架。CEPE 使用一个小型编码器逐块处理长输入,使冻结的解码器能够通过交叉注意力利用额外上下文。CEPE 高效、可泛化且用途广泛:仅使用 8K token 文档训练,它便将 LLAMA-2 的上下文窗口扩展到 128K token,提供 10 倍吞吐量,而内存仅为 1/6。CEPE 在语言建模和上下文学习方面取得了强劲性能。CEPE 在检索增强应用中也表现出色,而现有长上下文模型在使用检索到的上下文时会出现性能退化。我们进一步提出一种 CEPE 变体,仅使用无标注数据即可扩展指令微调模型的上下文窗口,并在 LLAMA-2-CHAT 上展示其有效性,从而得到一个强大的指令遵循模型,能够在下游任务中利用极长上下文。

英文摘要:

Extending large language models (LLMs) to process longer inputs is crucial for a wide range of applications. However, the substantial computational cost of transformers and limited generalization of positional encoding restrict the size of their context window. We introduce Context Expansion with Parallel Encoding (CEPE), a framework that can be applied to any existing decoder-only LLMs to extend their context window. CEPE employs a small encoder to process long inputs chunk by chunk, enabling the frozen decoder to utilize additional contexts via cross-attention. CEPE is efficient, generalizable, and versatile: trained with 8K-token documents, it extends the context window of LLAMA-2 to 128K tokens, offering 10x the throughput with only 1/6 of the memory. CEPE yields strong performance on language modeling and in-context learning. CEPE also excels in retrieval-augmented applications, while existing long-context models degenerate with retrieved contexts. We further introduce a CEPE variant that can extend the context window of instruction-tuned models using only unlabeled data, and showcase its effectiveness on LLAMA-2-CHAT, leading to a strong instruction-following model that can leverage very long contexts on downstream tasks.

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

↑