Skip to main content
QUICK REVIEW

[论文解读] Focused Transformer: Contrastive Training for Context Scaling

Szymon Tworkowski, Konrad Staniszewski|arXiv (Cornell University)|Jul 6, 2023
Topic ModelingComputer Science被引用 13
一句话总结

论文提出 Focused Transformer (FoT),一种带记忆注意力的对比学习方法,用以扩展上下文长度,使微调的 OpenLLaMA 模型(LongLLaMA)能够处理高达 256k token 的长上下文任务并提升长上下文任务表现。

ABSTRACT

Large language models have an exceptional capability to incorporate new information in a contextual manner. However, the full potential of such an approach is often restrained due to a limitation in the effective context length. One solution to this issue is to endow an attention layer with access to an external memory, which comprises of (key, value) pairs. Yet, as the number of documents increases, the proportion of relevant keys to irrelevant ones decreases, leading the model to focus more on the irrelevant keys. We identify a significant challenge, dubbed the distraction issue, where keys linked to different semantic values might overlap, making them hard to distinguish. To tackle this problem, we introduce the Focused Transformer (FoT), a technique that employs a training process inspired by contrastive learning. This novel approach enhances the structure of the (key, value) space, enabling an extension of the context length. Our method allows for fine-tuning pre-existing, large-scale models to lengthen their effective context. This is demonstrated by our fine-tuning of $3B$ and $7B$ OpenLLaMA checkpoints. The resulting models, which we name LongLLaMA, exhibit advancements in tasks requiring a long context. We further illustrate that our LongLLaMA models adeptly manage a $256 k$ context length for passkey retrieval.

研究动机与目标

  • 识别在多文档注意力中限制上下文扩展的分心问题。
  • 开发 FoT,通过塑造 (key, value) 空间在无需从头重新训练的情况下扩展上下文长度。
  • 展示对现有模型(OpenLLaMA)的实际微调,以创建具有更长上下文的 LongLLaMA。
  • 实证评估在 passkey 检索、问答与少样本任务上的长上下文能力;显示超出训练长度的外推。

提出的方法

  • 增加在推理时通过 kNN 检索额外 (key, value) 上下文的记忆注意力层。
  • 通过受对比学习启发的 crossbatch 过程进行训练,使记忆注意力暴露给 positives(当前/先前上下文)和 negatives(其他文档)。
  • 移除记忆层中的位置编码(除了 LongLLaMA 之外),以实现外推;使用 FAISS 进行精确的 kNN 检索。
  • 使用 FoT 微调 OpenLLaMA-3B 和 OpenLLaMA-7B 以生成 LongLLaMA 模型;在 passkey 检索、Qasper、TREC、WebQS 与长上下文数据集(PG-19、arXiv、GitHub、Isabelle)上进行评估。
  • 演示 FoT 改善键值空间结构,使注意力可以对扩展上下文进行关注而无需大规模再训练。
  • 显示基于 FoT 的模型可以超出训练上下文长度进行外推(例如在 passkey 检索中达到 256k token)。

实验结果

研究问题

  • RQ1FoT 是否能够通过扩展 Transformer 的上下文跨越大量文档时缓解分心问题?
  • RQ2FoT 是否能够在不在这些长度上训练的情况下实现对更长上下文的外推?
  • RQ3FoT 训练的模型在更长的上下文下是否维持或提升困惑度与少样本任务表现?
  • RQ4在 passkey 检索与文档问答等长上下文任务上的实际收益是多少?
  • RQ5FoT 在不同模型大小与数据集(PG-19、arXiv、GitHub、Isabelle、Qasper、TREC、WebQS)上的表现如何?

主要发现

  • FoT 通过通过跨 batch 对比训练来塑造键值空间,从而缓解分心问题。
  • LongLLaMA-3B 与 LongLLaMA-7B 外推到 256k tokens,在 passkey 检索上在 100k 时达到 94.5% 的准确率,在 256k 时达到 73%。
  • LongLLaMA 模型在更长上下文下对 TREC 与 WebQS 显示出准确性提升,相比基线。
  • FoT 能够超越训练上下文长度进行外推,与标准微调基线不同。
  • 在 PG-19、arXiv、GitHub、Isabelle 上,FoT 在更长上下文下困惑度得到改善,相比基线在高达 64k 上下文的收益。
  • FoT 是一种简单的即插即用扩展,允许微调现有模型以扩展上下文且不改变架构。

阅读本论文

在 Nubint 阅读器中打开原文,边读边就任意段落提问。

在 Nubint 中阅读本论文

本解读由 AI 根据论文原文生成,引用前请核对原文。