跳到主要内容Skip to main content

长上下文Long Context

Long Context

  • 核心概念Core concepts
  • 第四站 · 看懂Station 4 · Under the Hood
  • 引用核验 2026-11-03refs checked 2026-11-03
解决什么问题What problem it solves

让模型一次读入几十万字的技术,和它为什么贵。The technology behind reading hundreds of thousands of words at once — and why it is expensive.

这是什么What it is

注意力的计算量随文本长度平方增长——文本长十倍,计算多百倍。

各家靠改注意力、改位置编码、做缓存来压这个成本。

窗口从几千 token 走到百万级。

窗口长不等于读得准:超长文本里模型对中间部分的把握会下降。

Attention cost grows with the square of text length — 10x the text means 100x the compute.

Vendors tame the cost with modified attention, positional encoding, and caching; windows grew from thousands of tokens to millions.

A long window does not mean accurate reading: grasp of the middle of very long text drops.

为什么需要知道Why it matters

「能塞进去」和「能用好」是两回事。选模型看窗口数字之前,先看你真需要多长、它长文实测怎么样。"Can fit it in" and "can use it well" are different things. Before comparing window sizes, check how long you actually need and how the model performs on long text in practice.

出处Sources
  • Attention Is All You Need(复杂度表:自注意力每层 O(n²·d))Attention Is All You Need (complexity table) ↗
  • Google 官方博客:Gemini 1.5 宣布 100 万 token 窗口(私有预览)Google blog: Gemini 1.5 1M-token context (private preview) ↗