跳到主要内容Skip to main content
← 深水指南Guides

工具箱:提示词、上下文预算、RAG 清单、选型表Toolkit: prompt and context

规划Planning

四个可直接复制的文本块:提示词结构、上下文预算表、RAG 分块与重排清单、模型选型工作表。

Four copyable text blocks: a prompt structure, a context budget table, a RAG chunking/reranking checklist and a model selection worksheet.

怎么用这页How to use

模板内的比例、样本数、阈值和权限策略是示例。请按任务、授权与风险确定实际条件;填完表格不等于已经通过验收。

四个块都是纯文本,复制到你的文档或仓库里改。括号里是占位,不是可直接运行的代码。

1. 提示词结构模板

角色:你是【角色】,只负责【任务范围】。
输入:用户给出【输入类型】;缺失信息请先问,不要猜。
约束:
- 必须引用【允许的知识源】,找不到就写「未找到」。
- 不得编造数字、日期、许可、作者。
- 输出格式:先结论,再依据,最后未确认项。
输出:
1) 结论(不超过 3 句)
2) 依据(每条带来源与日期)
3) 未确认项(没有就写「无」)
拒答条件:【列出不该回答的问题】

2. 上下文预算表

| 槽位            | 预算占比 | 内容                         |
|-----------------|----------|------------------------------|
| 系统指令        | 10%      | 角色、约束、输出格式         |
| 任务与示例      | 30%      | 当前任务、1–3 个正例/反例    |
| 检索资料        | 40%      | 分块原文,带来源编号         |
| 对话历史        | 10%      | 最近 3–5 轮,摘要化          |
| 保留余量        | 10%      | 给输出与重试                 |

按任务调整:先移除无关历史与重复内容,保留必要证据和边界,并为输出留空间。

3. RAG 分块与重排清单

- [ ] 分块按语义,不按固定字数;每块保留原文标题与 URL
- [ ] 每块不超过【N】字,超长再拆,不截断句子
- [ ] 表格与代码单独成块,不混进段落
- [ ] 元数据至少含:来源、日期、版本、章节
- [ ] 用 BM25/向量取回候选,再根据质量与延迟评估是否重排
- [ ] 重排后只留 top【K】块,按来源去重
- [ ] 冲突来源同时保留,标红,不合并
- [ ] 回答必须引用块编号;无命中写「未找到」
- [ ] 每次更新文档跑一遍回归问题集

4. 模型选型工作表

| 约束             | 你的答案 | 排除的产品 |
|------------------|----------|------------|
| 硬件(显存/平台)|          |            |
| 数据能否出网     |          |            |
| 许可(商用/自托管)|        |            |
| 上下文长度需求   |          |            |
| 并发与延迟       |          |            |
| 预算单位(席位/用量)|      |            |
| 中文/多语言要求  |          |            |
| 必须接的生态     |          |            |

结论:主选【 】,备选【 】;理由写三条,不写「综合最强」。

Copy these four plain-text blocks into your document or repository and replace bracketed fields. They are templates, not runnable code. Budget percentages are illustrative, not universal settings.

1. Prompt structure

Role: [role], limited to [task scope].
Input: [input type]; ask about missing information rather than guessing.
Constraints:
- Cite [permitted sources]; write “not found” if unsupported.
- Do not invent numbers, dates, licenses or authors.
- Return conclusion, evidence, then unresolved items.
Output:
1) Conclusion (up to three sentences)
2) Evidence (source and date for each)
3) Unknowns (or “none”)
Refusal conditions: [questions outside scope]

2. Context budget

Slot | Illustrative share | Content
System instructions | 10% | Role, constraints, format
Task/examples | 30% | Current task and 1–3 contrasting examples
Retrieved material | 40% | Passages with source IDs
Conversation history | 10% | Recent, summarized turns
Headroom | 10% | Output and retries

Adjust to the task: remove unrelated history and repetition first;
preserve necessary evidence and boundaries, and reserve output space.

3. Chunking/reranking checklist

- [ ] Preserve meaning, titles and source URLs when chunking
- [ ] Split long chunks at sentence boundaries; set [N] for the task
- [ ] Keep tables/code intact where their meaning requires it
- [ ] Keep source, date, version and section metadata
- [ ] Retrieve with BM25/vectors; assess whether reranking is needed
- [ ] Select top [K] supported passages and remove redundant copies
- [ ] Preserve conflicting sources separately
- [ ] Cite passage IDs; say “not found” without evidence
- [ ] Recheck fixed questions after document updates

4. Model-selection worksheet

Constraint | Your answer | Excluded products
Hardware/VRAM/platform | |
Outbound data allowed | |
Commercial/self-hosted licensing | |
Context requirement | |
Concurrency/latency | |
Seat/usage budget | |
Chinese/multilingual needs | |
Required integrations | |

Primary: [ ]; fallback: [ ]; give three specific reasons, not “best overall”.

常见误用Common misuses

  • 把模板当提示词直接跑:占位符没填,模型会自由发挥。
  • 预算表只算输入:输出与重试也要留余量。
  • RAG 只调 topK:不重排、不去重,噪声会挤掉正确块。
  • 选型表只填一半:未填的约束会在上线后变成返工。
  • Leaving placeholders unfilled does not give a model a concrete task.
  • Budget output and retries as well as input.
  • Adjusting top-K alone may leave ranking, duplication or evidence problems unresolved.
  • Unresolved selection constraints should remain visible rather than becoming hidden launch assumptions.

已填示例:把活动资料写成通知Filled example: turn event notes into a notice

以下为虚构教学材料,不是模型运行记录。

输入:周六 14:00,社区阅览室,旧书交换。未提供费用、电话、报名链接。

完整提示:仅依据上面三项资料,写一段不超过 100 字的通知。不要新增事实;未提供的报名信息不写。输出标题和两句正文。

可接受的示例:旧书交换活动。周六 14:00,欢迎到社区阅览室参加旧书交换。

检查:时间、地点、活动名称各核对一次;出现“免费”“扫码报名”或电话号码,先删除或补来源。材料没有给出这些信息。

交接记录:已确认三项事实;未确认费用与联系方式;下一步是核对排版和发布渠道。若需要补充报名信息,先取得真实资料,再改提示。

This is a fictional teaching example, not a model execution record.

Input: Saturday 14:00, community reading room, used-book exchange. No fee, contact number or registration URL was supplied.

Complete prompt: Use only those facts to write a notice under 100 Chinese characters. Add no facts and omit unspecified registration details. Return a title and two sentences.

Acceptable example: Used-book exchange. Join the exchange at the community reading room on Saturday at 14:00.

Check time, venue and event name. Remove or substantiate “free,” a signup link or a telephone number: none was supplied.

Handoff: three facts confirmed; fees and contacts unresolved; next check layout and publication channel. Obtain actual registration details before adding them.

出处Sources

来源Source链接URL
本站 · 深水指南(上下文工程、RAG 全链路、选型方法;2026-11-03)This site: context, retrieval and selection methods (2026-11-03)https://tools.specul.com/mcp/guides/planning.html

资料核验日期:2026-11-03。产品功能与条款可能变化,使用前请核对原始来源。Sources checked: 2026-11-03. Features and terms may change; check the original sources before use.