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

适配语言模型以压缩上下文

Adapting Language Models to Compress Contexts

Princeton University(普林斯顿大学);Princeton Language and Intelligence(普林斯顿语言与智能研究所)

Alexis Chevalier, Alexander Wettig, Anirudh Ajith, Danqi Chen

AI总结:

针对语言模型上下文窗口有限、长文本处理成本高的问题,提出AutoCompressors将长上下文压缩为摘要向量作为软提示,在困惑度优化、上下文学习、检索增强等任务中实现了效果提升与推理加速。

摘要:

基于Transformer的语言模型(LM)是功能强大且应用广泛的工具,但其效用受到有限上下文窗口以及处理长文本文档高昂计算成本的制约。我们提出将预训练LM适配为AutoCompressors(自动压缩器)。这类语言模型能够将长上下文压缩为紧凑的摘要向量,这些向量随后可作为软提示供模型访问。摘要向量通过无监督目标训练得到:将长文档分块处理,且所有先前分块的摘要向量都会用于语言建模任务。我们在最长达30720个token的序列上微调OPT和Llama-2模型,结果表明AutoCompressors能够利用长上下文来降低困惑度。我们通过压缩任务示例对AutoCompressors的上下文学习能力进行评估,发现摘要向量是纯文本示例的良好替代品,在提升准确率的同时降低了推理成本。最后,我们通过将摘要向量应用于检索增强语言建模和段落重排序任务,探索了为大型语料库预计算摘要向量的优势。总体而言,AutoCompressors是一种简单且低成本的方案,能够扩展LM的上下文窗口,同时加快长上下文下的推理速度。

英文摘要:

Transformer-based language models (LMs) are powerful and widely-applicable tools, but their usefulness is constrained by a finite context window and the expensive computational cost of processing long text documents. We propose to adapt pre-trained LMs into AutoCompressors. These language models are capable of compressing long contexts into compact summary vectors, which are then accessible to the model as soft prompts. Summary vectors are trained with an unsupervised objective, whereby long documents are processed in segments, and summary vectors from all previous segments are used in language modeling. We fine-tune OPT and Llama-2 models on sequences of up to 30,720 tokens and show that AutoCompressors can utilize long contexts to improve perplexity. We evaluate AutoCompressors on in-context learning by compressing task demonstrations and find that summary vectors are good substitutes for plain-text demonstrations, increasing accuracy while reducing inference costs. Finally, we explore the benefits of pre-computing summary vectors for large corpora by applying summary vectors to retrievalaugmented language modeling and a passage re-ranking task. Overall, AutoCompressors emerge as a simple and inexpensive solution to extend the context window of LMs while speeding up inference over long contexts.

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

↑