---
title: "什么是 Context Window？"
canonical: https://wavect.io/zh/glossary/context-window/
language: zh
description: "LLM 一次能够考虑的最大文本量，以 token 计量，也是你为什么不能简单地把整个知识库粘进每个 Prompt 的原因。"
image: "https://wavect.io/img/general/bak/open_graph_preview.jpg"
---

技术

# Context Window

LLM 一次能够考虑的最大文本量，以 token 计量，也是你为什么不能简单地把整个知识库粘进每个 Prompt 的原因。

最近审阅: 2026-06-02 审阅人 [Kevin Riedl](/zh/team/kevin-riedl/) [wiki ↗](https://www.wikidata.org/wiki/Q139796365)

上下文窗口是模型对单次请求的工作记忆，以 token 计量（一个 token 大约是四分之三个单词）。所有内容都必须装进其中：你的系统 Prompt、对话历史、你粘进去的任何文档，以及模型生成的回答。一旦超出窗口，模型实际上就看不到溢出的部分。

即使窗口很大，「直接把所有东西放进 Prompt」也会因三个原因而失败。第一，成本：大多数提供商按 token 计费，所以把一份巨大的文档塞进每次调用会让账单成倍增长。第二，延迟：更多 token 意味着更慢的响应。第三，也是最不明显的，质量，模型对埋在很长上下文中间的信息关注得不那么可靠，所以更多并不总是更好。一个聚焦的 Prompt 往往胜过一个臃肿的。

这正是 RAG 存在的原因。你不是把整个语料库倒进窗口，而是只为每个问题检索出少数相关的文本块，并只发送这些。你获得了大型知识库的好处，却无需为在每次请求中处理全部内容而付费。上下文窗口是预算，检索和好的 [Prompt 工程](/zh/glossary/prompt-engineering/) 是你如何明智地花掉它。

那个让团队意外的「迷失在中间」效应，举个实际例子：一家公司把一份 40 页的政策文档粘进 Prompt，问了一个答案落在第 20 页的问题。即便整份文档在技术上都在窗口之内，模型仍然答错，因为对埋在长上下文中间的材料，注意力会衰减。同一个模型，只递给它检索抽出来的那两段相关文字，就答对了。更大的窗口没有修好这个问题；更精准的上下文修好了。当一个新模型带着抢眼的窗口尺寸发布时，这正是创始人会忽略的反直觉之处：更大的容量并不等于更高的可靠性。

实用的要点：把上下文窗口当作一项带价签的稀缺资源，而不是免费空间。更大的窗口降低了压力，却没有消除它，成本和延迟仍然随你放进去的内容而增长。我们在 [人工智能](/zh/services/artificial-intelligence/) 下有意围绕这个预算来设计。

// FAQ

## 常见问题

### 什么是上下文窗口？

LLM 在一次请求中能够处理的最大文本量，以 token 计量。系统 Prompt、对话历史、粘贴的文档和生成的回答都必须装进其中。

### 为什么不直接把所有东西放进 Prompt？

成本、延迟和质量。更多 token 花费更多、响应更慢，而模型对埋在很长上下文中的信息关注得不那么可靠。一个聚焦的 Prompt 通常胜过一个臃肿的。

### 上下文窗口与 RAG 有什么关系？

RAG 存在就是为了管理它。你不是把整个语料库加载进窗口，而是为每个问题只检索相关的文本块，从而获得大型知识库的好处，却无需每次都为处理全部内容付费。

相关术语

- [LLM](/zh/glossary/llm/)
- [RAG](/zh/glossary/rag/)
- [Prompt Engineering](/zh/glossary/prompt-engineering/)

相关服务

- [人工智能](/zh/services/artificial-intelligence/)

相关案例研究

- [Twinsoft AI](/zh/case-studies/twinsoft-ai/)

相关指南

- [如何为 MVP 选择技术栈](/zh/software-development-guide/how-to-choose-a-tech-stack-for-mvp/)

聊聊

## Structured Data

```json
{
  "@context": "https://schema.org",
  "@graph": [
    {
      "@id": "https://wavect.io/#organization",
      "@type": [
        "Organization",
        "ProfessionalService",
        "LocalBusiness"
      ],
      "employee": [
        {
          "@id": "https://wavect.io/team/kevin-riedl/#person",
          "@type": "Person",
          "jobTitle": "Managing Director",
          "name": "Kevin Riedl",
          "url": "https://wavect.io/team/kevin-riedl/",
          "worksFor": {
            "@id": "https://wavect.io/#organization",
            "@type": [
              "Organization",
              "ProfessionalService",
              "LocalBusiness"
            ]
          }
        },
        {
          "@id": "https://wavect.io/team/christof-jori/#person",
          "@type": "Person",
          "jobTitle": "Managing Director",
          "name": "Christof Jori",
          "url": "https://wavect.io/team/christof-jori/",
          "worksFor": {
            "@id": "https://wavect.io/#organization",
            "@type": [
              "Organization",
              "ProfessionalService",
              "LocalBusiness"
            ]
          }
        }
      ],
      "founder": [
        {
          "@id": "https://wavect.io/team/kevin-riedl/#person",
          "@type": "Person",
          "jobTitle": "Managing Director",
          "name": "Kevin Riedl",
          "url": "https://wavect.io/team/kevin-riedl/",
          "worksFor": {
            "@id": "https://wavect.io/#organization",
            "@type": [
              "Organization",
              "ProfessionalService",
              "LocalBusiness"
            ]
          }
        },
        {
          "@id": "https://wavect.io/team/christof-jori/#person",
          "@type": "Person",
          "jobTitle": "Managing Director",
          "name": "Christof Jori",
          "url": "https://wavect.io/team/christof-jori/",
          "worksFor": {
            "@id": "https://wavect.io/#organization",
            "@type": [
              "Organization",
              "ProfessionalService",
              "LocalBusiness"
            ]
          }
        }
      ],
      "legalRepresentative": [
        {
          "@id": "https://wavect.io/team/kevin-riedl/#person",
          "@type": "Person",
          "jobTitle": "Managing Director",
          "name": "Kevin Riedl",
          "url": "https://wavect.io/team/kevin-riedl/",
          "worksFor": {
            "@id": "https://wavect.io/#organization",
            "@type": [
              "Organization",
              "ProfessionalService",
              "LocalBusiness"
            ]
          }
        },
        {
          "@id": "https://wavect.io/team/christof-jori/#person",
          "@type": "Person",
          "jobTitle": "Managing Director",
          "name": "Christof Jori",
          "url": "https://wavect.io/team/christof-jori/",
          "worksFor": {
            "@id": "https://wavect.io/#organization",
            "@type": [
              "Organization",
              "ProfessionalService",
              "LocalBusiness"
            ]
          }
        }
      ],
      "name": "Wavect GmbH",
      "subjectOf": {
        "@id": "https://wavect.io/verified-claims.json#dataset",
        "@type": "Dataset",
        "creator": {
          "@id": "https://wavect.io/#organization",
          "@type": [
            "Organization",
            "ProfessionalService",
            "LocalBusiness"
          ]
        },
        "description": "A machine-readable registry of quantitative and qualitative claims published by Wavect, with review dates, localized page appearances and public third-party citations where available.",
        "inLanguage": "en",
        "isAccessibleForFree": true,
        "license": "https://creativecommons.org/licenses/by/4.0/",
        "name": "Wavect verified publication claims",
        "url": "https://wavect.io/verified-claims.json"
      },
      "url": "https://wavect.io/"
    },
    {
      "@id": "https://wavect.io/team/kevin-riedl/#person",
      "@type": "Person",
      "jobTitle": "Managing Director",
      "name": "Kevin Riedl",
      "sameAs": [
        "https://www.wikidata.org/wiki/Q139796365",
        "https://www.linkedin.com/in/wsdt",
        "https://github.com/wsdt"
      ],
      "url": "https://wavect.io/team/kevin-riedl/",
      "worksFor": {
        "@id": "https://wavect.io/#organization",
        "@type": [
          "Organization",
          "ProfessionalService",
          "LocalBusiness"
        ]
      }
    },
    {
      "@id": "https://wavect.io/team/christof-jori/#person",
      "@type": "Person",
      "jobTitle": "Managing Director",
      "name": "Christof Jori",
      "sameAs": [
        "https://www.wikidata.org/wiki/Q139796367",
        "https://www.linkedin.com/in/jocr77/",
        "https://github.com/jo-chris"
      ],
      "url": "https://wavect.io/team/christof-jori/",
      "worksFor": {
        "@id": "https://wavect.io/#organization",
        "@type": [
          "Organization",
          "ProfessionalService",
          "LocalBusiness"
        ]
      }
    },
    {
      "@id": "https://wavect.io/#website",
      "@type": "WebSite",
      "inLanguage": [
        "en",
        "de",
        "es",
        "zh"
      ],
      "name": "Wavect",
      "potentialAction": {
        "@type": "SearchAction",
        "query-input": "required name=search_term_string",
        "target": {
          "@type": "EntryPoint",
          "urlTemplate": "https://wavect.io/search/?q={search_term_string}"
        }
      },
      "publisher": {
        "@id": "https://wavect.io/#organization",
        "@type": [
          "Organization",
          "ProfessionalService",
          "LocalBusiness"
        ]
      },
      "url": "https://wavect.io/"
    }
  ]
}
```

```json
{
  "@context": "https://schema.org",
  "@graph": [
    {
      "@id": "https://wavect.io/zh/glossary/context-window/#term",
      "@type": "DefinedTerm",
      "alternateName": [],
      "description": "LLM 一次能够考虑的最大文本量，以 token 计量，也是你为什么不能简单地把整个知识库粘进每个 Prompt 的原因。",
      "inDefinedTermSet": "https://wavect.io/zh/glossary/#termset",
      "name": "Context Window",
      "termCode": "context-window",
      "url": "https://wavect.io/zh/glossary/context-window/"
    },
    {
      "@id": "https://wavect.io/zh/glossary/context-window/#webpage",
      "@type": "WebPage",
      "about": {
        "@id": "https://wavect.io/#organization",
        "@type": [
          "Organization",
          "ProfessionalService",
          "LocalBusiness"
        ]
      },
      "author": {
        "@id": "https://wavect.io/team/kevin-riedl/#person",
        "@type": "Person",
        "name": "Kevin Riedl",
        "url": "https://wavect.io/team/kevin-riedl/"
      },
      "dateModified": "2026-06-02",
      "description": "LLM 一次能够考虑的最大文本量，以 token 计量，也是你为什么不能简单地把整个知识库粘进每个 Prompt 的原因。",
      "headline": "Context Window",
      "inLanguage": "zh",
      "isPartOf": {
        "@id": "https://wavect.io/#website",
        "@type": "WebSite"
      },
      "lastReviewed": "2026-06-02",
      "mainEntity": {
        "@id": "https://wavect.io/zh/glossary/context-window/#term"
      },
      "mentions": [
        {
          "@id": "https://wavect.io/#organization",
          "@type": [
            "Organization",
            "ProfessionalService",
            "LocalBusiness"
          ]
        },
        {
          "@type": "Service",
          "name": "人工智能",
          "url": "https://wavect.io/zh/services/artificial-intelligence/"
        }
      ],
      "name": "Context Window",
      "reviewedBy": {
        "@id": "https://wavect.io/team/christof-jori/#person",
        "@type": "Person",
        "name": "Christof Jori",
        "url": "https://wavect.io/team/christof-jori/"
      },
      "speakable": {
        "@type": "SpeakableSpecification",
        "cssSelector": [
          ".gls-single__h1",
          ".gls-single__tldr"
        ]
      },
      "url": "https://wavect.io/zh/glossary/context-window/"
    },
    {
      "@type": "BreadcrumbList",
      "itemListElement": [
        {
          "@type": "ListItem",
          "item": "https://wavect.io/zh/",
          "name": "首页",
          "position": 1
        },
        {
          "@type": "ListItem",
          "item": "https://wavect.io/zh/glossary/",
          "name": "技术、产品与合作模式术语表",
          "position": 2
        },
        {
          "@type": "ListItem",
          "item": "https://wavect.io/zh/glossary/context-window/",
          "name": "Context Window",
          "position": 3
        }
      ]
    }
  ]
}
```

```json
{
  "@context": "https://schema.org",
  "@type": "FAQPage",
  "mainEntity": [
    {
      "@type": "Question",
      "acceptedAnswer": {
        "@type": "Answer",
        "text": "LLM 在一次请求中能够处理的最大文本量，以 token 计量。系统 Prompt、对话历史、粘贴的文档和生成的回答都必须装进其中。"
      },
      "name": "什么是上下文窗口？"
    },
    {
      "@type": "Question",
      "acceptedAnswer": {
        "@type": "Answer",
        "text": "成本、延迟和质量。更多 token 花费更多、响应更慢，而模型对埋在很长上下文中的信息关注得不那么可靠。一个聚焦的 Prompt 通常胜过一个臃肿的。"
      },
      "name": "为什么不直接把所有东西放进 Prompt？"
    },
    {
      "@type": "Question",
      "acceptedAnswer": {
        "@type": "Answer",
        "text": "RAG 存在就是为了管理它。你不是把整个语料库加载进窗口，而是为每个问题只检索相关的文本块，从而获得大型知识库的好处，却无需每次都为处理全部内容付费。"
      },
      "name": "上下文窗口与 RAG 有什么关系？"
    }
  ],
  "speakable": {
    "@type": "SpeakableSpecification",
    "cssSelector": [
      ".faq-question",
      ".faq-answer"
    ]
  }
}
```
