# 第二章 大模型基础与上下文窗口

要精通上下文工程，首先必须深入理解大语言模型的工作机制，特别是上下文窗口的本质。上下文窗口既是大模型的核心能力所在，也是上下文工程需要优化和管理的关键资源。

本章将从技术原理层面解析大模型如何处理上下文，Token 的概念与计算方式，以及不同模型在上下文处理能力上的差异。这些知识是理解后续技术策略的必要基础。

## 本章内容

* [2.1 大语言模型工作原理](/context_engineering_guide/di-yi-bu-fen-ren-shi-shang-xia-wen-gong-cheng/02_llm_basics/2.1_how_llm_works.md)
* [2.2 上下文窗口的本质](/context_engineering_guide/di-yi-bu-fen-ren-shi-shang-xia-wen-gong-cheng/02_llm_basics/2.2_context_window.md)
* [2.3 Token 与上下文限制](/context_engineering_guide/di-yi-bu-fen-ren-shi-shang-xia-wen-gong-cheng/02_llm_basics/2.3_tokens.md)
* [2.4 主流模型的上下文能力对比](/context_engineering_guide/di-yi-bu-fen-ren-shi-shang-xia-wen-gong-cheng/02_llm_basics/2.4_model_comparison.md)
* [2.5 State Space Model 与 Transformer 的比较](/context_engineering_guide/di-yi-bu-fen-ren-shi-shang-xia-wen-gong-cheng/02_llm_basics/2.5_ssm_vs_transformer.md)
* [本章小结](/context_engineering_guide/di-yi-bu-fen-ren-shi-shang-xia-wen-gong-cheng/02_llm_basics/summary.md)


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://yeasy.gitbook.io/context_engineering_guide/di-yi-bu-fen-ren-shi-shang-xia-wen-gong-cheng/02_llm_basics.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
