按年被提到
20232023 · 13 次2026
大模型与语言模型›长上下文与测试时计算·arXiv:2307.03172 · cs.CL

Lost in the Middle: How Language Models Use Long Contexts

迷失在中间:语言模型如何利用长上下文
Nelson F. Liu, Kevin Lin, John Hewitt, Ashwin Paranjape, Michele Bevilacqua, Fabio Petroni, Percy Liang · 2023

相关信息放在长上下文中间时,模型表现明显下降

开始阅读 ↗PDFalphaXiv 讨论
被推荐 · 17 人首次 2023-07-07 · 最近 2026-07-29
17不同的人
11活跃月份
19讨论串
2,070被引(OpenAlex)

论文在多文档问答和键值检索两项需要从输入中找出相关信息的任务上,改变相关信息在上下文中的位置来考察语言模型。结果显示,信息位于开头或结尾时表现通常最好,位于长上下文中间时显著下降,即使是专为长上下文设计的模型也是如此。作者据此更好地解释了模型如何使用输入上下文,并提出了新的评估协议。

HN 为什么提它

评论者用它说明 LLM 难以利用长上下文中间的信息,因此把上下文塞满反而会降低质量,需要做上下文管理,且这个问题可能长期存在。

实证研究难度 2 / 5约 40 分钟有时效性
读之前最好知道
1大语言模型与上下文窗口
2检索增强生成(RAG)
3多文档问答
4Transformer 注意力机制

学习路径

读这篇之前,按顺序读书架上的 7 篇 · 参考文献来自 OpenAlex,顺序和要点由 Claude Code 排出

先熟悉 Transformer 以及各类长上下文与位置外推方法,再看这篇如何测量模型使用长上下文时的位置偏差。

  1. 1
    Attention Is All You Need注意力就是你所需要的一切 · 2017

    被测语言模型都是 Transformer,上下文位置问题来自自注意力的结构。

    读理解自注意力与位置编码;跳过翻译实验。

  2. 2
    Exploring the Limits of Transfer Learning with a Unified Text-to-Text Transformer探索迁移学习的极限:统一的文本到文本 Transformer · 2019

    T5 的编码器-解码器结构是论文对比解码器-only 与编码器-解码器模型的背景。

    读理解文本到文本的统一形式和编码器-解码器结构。

  3. 3
    Transformer-XL: Attentive Language Models Beyond a Fixed-Length ContextTransformer-XL:超越固定长度上下文的注意力语言模型 · 2019

    Transformer-XL 最早系统处理固定长度上下文的限制。

    读抓住段级循环与相对位置编码如何扩展有效上下文。

  4. 4
    Linformer: Self-Attention with Linear ComplexityLinformer:线性复杂度的自注意力 · 2020

    典型的线性复杂度注意力近似,代表长上下文效率路线。

    读抓住用低秩投影把二次复杂度降到线性的想法。

  5. 5
    Train Short, Test Long: Attention with Linear Biases Enables Input Length Extrapolation短训长测:用线性偏置注意力实现输入长度外推 · 2021

    ALiBi 通过位置偏置实现长度外推,涉及模型能否使用更长输入的问题。

    读理解按距离给注意力打线性惩罚如何支持外推。

  6. 6
    FlashAttention: Fast and Memory-Efficient Exact Attention with IO-AwarenessFlashAttention:具备 IO 感知的快速且省内存的精确注意力 · 2022

    FlashAttention 是让长上下文变得可行的底层工程手段。

    读抓住分块与减少显存读写的核心思路。

  7. 7
    Scaling Instruction-Finetuned Language Models扩展指令微调语言模型 · 2022

    Flan 指令微调模型是论文评测的模型类别之一。

    读了解指令微调的规模与任务设置,知道被测模型的来历。

  8. 8
    Lost in the Middle: How Language Models Use Long Contexts迷失在中间:语言模型如何利用长上下文 · 2023 · 就是这篇

    通过多文档问答和键值检索显示模型对中间位置信息利用较差。

    读抓住实验设计、U 形位置曲线,以及对架构和微调影响的分析。

HN 书评

推荐在前,同类按时间 · 每篇最多保留 20 条,统计用全部提及
推荐spmurrayzzz · 2023-08

“More reading on that problem if you're curious: Lost in the Middle”

推荐延伸阅读:模型对长上下文开头和结尾的利用好于中间
What's new in Llama 2 and how to run it locally原评论 ↗
引用saliagato · 2023-07

“it is probably one of the worst drawbacks of this technology”

称这是这项技术最糟的缺陷之一:LLM 会忽略长上下文中间的信息
Llama 32K Context Released by Together AI原评论 ↗
引用williamzeng0 · 2023-08

“My stance is with models ignoring long contexts, we'll have this problem for a long time.”

引作证据:模型会忽略长上下文,这个问题将长期存在
Launch HN: Sweep (YC S23) – A bot to create simple PRs in your codebase原评论 ↗
引用gk1 · 2023-08

“We also found[1] that context stuffing leads (generally) to worse quality results, as did a recent study.[2]”

引用它:上下文塞得太满通常会让结果质量变差
You probably don’t need to fine-tune LLMs原评论 ↗
引用ajhai · 2023-09

“there are things like lost in the middle problems that one may have to deal with.”

提醒要处理“迷失在中间”问题,LLM 难以利用上下文中间的信息
A Comprehensive Guide for Building Rag-Based LLM Applications原评论 ↗
引用sandkoan · 2023-10

“For anyone who's curious, the paper in question, entitled,”

给出被讨论的那篇论文,讲 LLM 为何漏掉长上下文中间的信息
MemGPT – LLMs with self-editing memory for unbounded context原评论 ↗
看全部 16 条 →
引用msp26 · 2023-10

“Relevant paper: Lost in the Middle: How Language Models Use Long Contexts”

贴出相关论文,讲长上下文 LLM 为何没有充分利用中间的信息
Microsoft says GPT 3.5 has 20B parameters?原评论 ↗
引用Der_Einzige · 2023-11

“Even full quadratic attention models seem to forget or not value information given in the middle of the prompt.”

指出即便是完整二次注意力的模型,也会遗忘提示中间的信息
GPT-4 Update: 32K Context Window Now for All Users原评论 ↗
引用Swizec · 2023-11

“LLMs are known to struggle with remembering stuff that isn't at the start or end of the input.”

说明 LLM 难以记住输入开头和结尾之外的内容
New models and developer products announced at OpenAI DevDay原评论 ↗
引用msp26 · 2023-11

“degraded performance on long contexts has been observed in plenty of other models [Lost in the Middle”

引作证据:许多其他模型在长上下文上也观察到性能下降
Benchmarking GPT-4 Turbo – A Cautionary Tale原评论 ↗
引用bayesian_limit · 2023-12

“I could not help but notice the Contriever curve is so much higher on y-axis Recall than the other methods (figure 11 in Lost in the Middle).”

指出论文图 11 中 Contriever 的召回率远高于其他方法
Build a search engine, not a vector DB原评论 ↗
引用araghuvanshi · 2024-04

“the issue is with the fundamentals of how LLMs actually work. Proof: Lost in the Middle”

引作证明:问题出在 LLM 的根本工作方式,会忽略长上下文中间的信息
LLMs and the Harry Potter problem原评论 ↗
引用funnygiraffe · 2024-07

“Does Claude under this usage paradigm not struggle with very long contexts”

借它质疑 Claude 在这种用法下处理很长上下文是否会吃力
Codestral Mamba原评论 ↗
引用xinweihe · 2025-08

“Throwing all that at agents usually leads to poor performance due to context bloat see Lost in the Middle.”

引用它说明把一切都扔给智能体会因上下文臃肿而性能变差
Show HN: TraceRoot – Open-source agentic debugging for distributed services原评论 ↗
引用wonnage · 2026-07

“Not sure if this is still up to date (2023), but Lost in the Middle shows that performance degrades mostly in the middle of the context.”

引用它:性能下降主要出在上下文中间,但不确定现在是否仍然成立
OpenAI reduces Codex Model Context Size from 372k to 272k原评论 ↗
引用supermatt · 2026-07

“From my experience this holds true to this day.”

凭经验认为论文的结论至今仍成立:模型难以利用长上下文中间的信息
Handbook.md shows that long policy documents do not reliably govern agents原评论 ↗
被提交为 story · 3 次