Workspace sync: auto commit 2026-04-23 12:02:11

This commit is contained in:
2026-04-23 12:02:11 +08:00
parent 6a8362bb5a
commit c59cc07327
57 changed files with 3427 additions and 30 deletions

View File

@@ -1,21 +1,32 @@
---
title: "Context Window"
type: concept
last_updated: 2026-04-10
tags: [llm, context-window, token, embedding, rag]
last_updated: 2025-01-16
---
## Definition
模型的 Context Window 是指单次 API 请求能处理的最大 token 数量(包括输入 prompt + 历史对话 + 输出 response。超过这个上限就会触发"Context Limit Exceeded"错误
Context Window(上下文窗口)是 LLM 或 Embedding Model 一次性处理的最大 token 数量。超过该限制的内容无法被模型感知,必须切分或截断
## Key Facts
- **DeepSeek-reasoner**: 16K tokens context window
- **MiniMax-M2.7**: 200K tokens context window
- 16K context 模型配合 OpenClaw safeguard 模式预留 16K tokens = 实际可用 0 tokens
## Key Numbers
- **Embedding Model**:通常 512~8192 token如 BAAI/bge 系列)
- **LLM**:差异极大,从 4KGPT-3.5)到 200K+Claude 3不等
## Related
- [[Compaction]]: OpenClaw 通过上下文压缩管理 token 消耗
- [[Model-Fallback]]: 模型切换的触发机制
- [[Agent-Routing-Rules]]: Telegram channel 绑定特定模型的方式
## Practical Impact
### 对 Embedding Model
- 决定单次可 Embedding 的最大文本长度
- 超过则需 Split切分文档
## Sources
- [[养虾日记4-一次「context-limit-exceeded」错误排查-我以为是小问题-结果踩了大坑]]
### 对 LLMGeneration 阶段)
- 决定用户问题 + 检索上下文 + 系统 Prompt 的总 token 预算
- 超过则需截断(可能丢失关键信息)
## Token Estimation
- **英文**1 token ≈ 3~4 个字母
- **中文**1 token ≈ 1 个汉字
## Related Concepts
- [[Split]] — 文档需要切分以满足 Context Window 约束
- [[Embedding]] — Embedding Model 的 Context Window 限制
- [[Token]] — Context Window 的计量单位
- [[Generation]] — LLM 的 Context Window 决定最终可输入的上下文量