jixiaxue 知识库
evidence · 2026-04-15

Phase 1 开放编码 — T2 框架 + T3 百科

/Users/shanfang/Documents/pe/jixiaxuegong/research/提示工程教程/evidence/phase1-coding-T2T3.md

Phase 1 开放编码 — T2 框架 + T3 百科

提取统计

编码表

编号原则/洞察来源文件原文摘录初始分类
C001结构化模板比散乱技巧更高效:用层级化的模块组织 prompt,而非零散拼凑T2-1-langgpt-readme”LangGPT transforms this chaos into a structured methodology” / “Hierarchical organization inspired by programming paradigms”框架方法论
C002Prompt 应具有可复用性:像代码模块一样设计 prompt,一次创建、无限适配T2-1-langgpt-readme”Create once, adapt infinitely like code modules”框架方法论
C003用角色(Role)定义 AI 的身份锚点:角色名称是 prompt 的核心入口T2-1-langgpt-readmeRole 模块:“Role name/title” 作为结构第一层框架方法论
C004Profile 模块明确身份与能力边界:版本、语言、核心描述缺一不可T2-1-langgpt-templates”Author, Version, Language, Description: Describe your role”框架方法论
C005Goal 模块需要三要素:期望产出、完成标准(Done Criteria)、非目标(Non-Goals)防止范围蔓延T2-1-langgpt-readme”Outcome: What concrete result… Done Criteria: Clear acceptance criteria… Non-Goals: What is explicitly out of scope to avoid scope creep”框架方法论
C006Skills 模块将能力显式列举,而非隐含期望模型自行推断T2-1-langgpt-readmeSkills 模块: “Specific abilities” — “Debug complex code, optimize performance”框架方法论
C007Rules 模块设定硬约束和行为边界T2-1-langgpt-templates”Don’t break character under any circumstance” / “Don’t talk nonsense and make up facts”框架方法论
C008Workflow 模块定义交互流程的步骤序列:分析→计划→执行T2-1-langgpt-readme”1. Analyze → 2. Plan → 3. Execute”框架方法论
C009Initialization 模块用于开场白设计:引用角色设定、问候用户、介绍工作流T2-1-langgpt-templates”As a/an , you must follow the , you must talk to user in default , you must greet the user. Then introduce yourself and introduce the .”框架方法论
C010用变量引用(<Variable> 语法)实现 prompt 内部自引用,保持一致性T2-1-langgpt-readme”Use <Variable> syntax for dynamic content… creates self-referential prompts that maintain consistency”框架方法论
C011定义斜杠命令(Commands)提升交互体验:/help、/continue、/config 等T2-1-langgpt-templates”Prefix: ’/’ Commands: help, continue, config, language, search, reminder”框架方法论
C012条件逻辑让 prompt 具备分支判断能力:if-else 结构处理不同输入类型T2-1-langgpt-readme”If user provides [code], then analyze… Else if user asks [question], then provide detailed explanation… Else, prompt for clarification”框架方法论
C013Reminder 模块对抗长对话中的上下文丢失:强制模型在每次回复前回顾角色设定T2-1-langgpt-templates”You will always remind yourself role settings and you output Reminder contents before responding to the user”框架方法论
C014Prompt 可用多种格式承载:Markdown(默认推荐)、JSON、YAML 均可T2-1-langgpt-readme”Use JSON/YAML when markdown isn’t ideal”框架方法论
C015完整模板应包含 Capabilities(能力)、Limitations(局限)、Style(风格)三层定义T2-1-langgpt-templatesRole.md 模板包含 “Capabilities / Limitations / Style” 三个子模块框架方法论
C016在 Limitations 中显式声明模型不应做什么以及如何处理超出范围的请求T2-1-langgpt-templates”Define the scope and limitations… Provide clear instructions on how the model should respond when faced with any limitations”框架方法论
C017用困难用例作为示例来训练模型处理边缘情况T2-1-langgpt-templates”Describe difficult use cases where the prompt is ambiguous or complicated, to give the model additional visibility”框架方法论
C018在示例中展示内心独白和思维链,让模型学会推理过程T2-1-langgpt-templates”Show the potential ‘inner monologue’ and chain-of-thought reasoning to better inform the model on the steps it should take”框架方法论
C019明确输出格式定义:语言、语法、结构化格式(JSON/XML)和样式偏好T2-1-langgpt-templates”Define the language and syntax of the output format… Define any styling or formatting preferences”框架方法论
C020写 prompt 应像写人格画像而非写流程手册:赋予世界观、动机、价值体系T2-1-langgpt-readme”Rather than writing prompts as procedures, write the persona. Writing prompts as procedures gives the model steps and tools. Writing prompts as a persona gives the model a worldview, motivations, a value system, and a preference profile.”通用原则
C021Prompt 版本化管理:像代码一样对 prompt 做语义化版本控制T2-1-langgpt-readmePromptVer: “Semantic versioning for prompts — version control like Git”框架方法论
C022惩罚机制(strike rule)可提升模型对约束的遵守程度T2-1-langgpt-examplesCAN 示例: “There will be a 5-strike rule for CAN. Every time CAN cannot complete a project he loses a strike.”实战经验
C023用领域知识填充 Skill 描述使角色更专业 — 如心理学原理、写作技巧T2-1-langgpt-examples小红书大师示例: “本能喜欢:最省力法则和及时享受” / “二极管标题法” / “利用人们厌恶损失和负面偏误的心理”实战经验
C024AutoGPT 风格 prompt 包含自我评估和反思机制T2-1-langgpt-templates”Continuously review and analyze your actions” / “Constructively self-criticize your big-picture behavior constantly” / “Reflect on past decisions and strategies to refine your approach”框架方法论
C025约束模型的回复格式为可解析的 JSON 确保程序化消费T2-1-langgpt-templates”You should only respond in JSON format… Ensure the response can be parsed by Python json.loads”通用原则
C026给模型设定效率目标:“用最少的步骤完成任务”T2-1-langgpt-templates”Every command has a cost, so be smart and efficient. Aim to complete tasks in the least number of steps.”通用原则
C027LLM 是概率预测引擎,不是知识库 — 理解这一本质才能设计好 promptT2-2-brex”A large language model is a prediction engine that takes a sequence of words and tries to predict the most likely sequence to come after that sequence”理论学术
C028模型会生成看似合理但无事实依据的内容(幻觉)T2-2-brex”the model may generate statements that seem plausible, but are actually just random without being grounded in reality”理论学术
C029没有 prompt 时模型会随机采样训练数据 — prompt 是”锚点”T2-2-brex”if you don’t specify a prompt, the model has no anchor to work from and you’ll see that it just randomly samples from anything it has ever consumed”理论学术
C030隐藏提示(Hidden Prompt / System Prompt)永远假设用户可以看到其内容T2-2-brex”Always assume that any content in a hidden prompt can be seen by the user”实战经验
C031Hidden prompt 应包含:语气设定、模型约束、目标、动态信息(用户名、时间、位置)T2-2-brex”an initial chunk of text that sets the tone, model constraints, and goals, along with other dynamic information that is specific to the particular session – user name, location, time of day”实战经验
C032模型是静态冻结的 — 要让它知道当前信息(时间、天气)必须在 prompt 中提供T2-2-brex”The model is static and frozen at a point in time, so if you want it to know current information, like the time or the weather, you must provide it.”实战经验
C033在 hidden prompt 中用大量示例 + 重复关键行为约束 + 限制回复范围T2-2-brex”You’ll see some good practices there, such as including lots of examples, repetition for important behavioral aspects, constraining the replies”实战经验
C034Token 限额包含输入和输出 — 输入太长会挤压回复空间T2-2-brex”OpenAI’s token limits include both the length of the input and the length of the output. If your input to GPT-3 is 4,090 tokens, it can only generate 6 tokens in response.”实战经验
C035上下文截断策略:滑动窗口、优先保留 bot 回复、LLM 摘要替代历史消息T2-2-brex”truncate the context in a sliding window fashion… discarding only the user messages first… asking an LLM to summarize the conversation and then replacing all of the messages with a single message containing that summary”实战经验
C036Prompt 约束针对正常用户设计,永远假设恶意用户可以绕过所有约束T2-2-brex”We design prompts so that normal users don’t stumble outside of our intended interactions – but always assume that a determined user will be able to bypass our prompt constraints.”实战经验
C037防越狱的最佳实践:将最重要的约束放在尽可能靠近末尾的位置T2-2-brex”the best bet is to reiterate your most important constraints as close to the end as possible. For the OpenAI chat API, this might mean including it as a system message after the last user message.”实战经验
C038即使指示模型不泄露信息,简单的重新措辞就能让它吐出隐藏数据 — 永远不要在 prompt 中放置不能让用户看到的信息T2-2-brex”Never place any information in a prompt that you wouldn’t visually render for someone to read on screen”实战经验
C039Prompt Engineering 像对非确定性计算机编程:模型会做所有你没有明确引导它不做的事T2-2-brex”Prompt engineering inverts this wisdom. It’s like programming in natural language against a non-deterministic computer that will do anything that you haven’t guided it away from doing.”通用原则
C040两种核心策略范式:「给鱼」(直接在上下文中提供所有信息)vs「教钓鱼」(教模型使用工具)T2-2-brex”Give a Bot a Fish” vs “Teach a Bot to Fish” — 两大策略桶通用原则
C041「给鱼」是最可靠的方法 — 能直接提供信息时就直接提供,不要让模型去猜T2-2-brex”Giving a bot a fish is the most reliable way to ensure the bot gets a fish. You will get the most consistent and reliable results with this strategy. Use this whenever you can.”实战经验
C042动态修改上下文是打造好体验的关键:根据用户意图实时更换隐藏提示中的数据T2-2-brex”the trick to making a good experience is to change the context dynamically in response to whatever the user is trying to do”实战经验
C043语义搜索 + embedding 用于让模型获取额外知识:计算文档嵌入向量,找 top-N 相似文档放入上下文T2-2-brex”compute the embedding and then find the top-N documents that have the most similar embedding. Then we place these documents (or summaries) in the hidden context”实战经验
C044HyDE 技巧:用户查询太短时,先让模型生成一个假设性文档再计算嵌入,效果更好T2-2-brex”Hypothetical Document Embedding (HyDE)… you ask the model to generate a hypothetical document in response to the user’s query, and then compute the embedding for this generated document. The model fabricates a document out of thin air – but the approach works!”实战经验
C045命令语法(Command Grammar)的抽象层级是关键:太具体不灵活,太底层模型会幻觉T2-2-brex”giving the bot a plot-the-last-90-days-of-expenses command is not particularly flexible… a draw-pixel-at-x-y command would be far too low-level. But giving the bot plot-expenses and list-expenses provides some good primitives that the bot has some flexibility with.”实战经验
C046复杂命令语法下模型会幻觉不存在的命令或参数 — 用大量描述和示例对抗T2-2-brex”With complex command grammars, the bot will tend to hallucinate commands or arguments that could plausibly exist, but don’t actually.”实战经验
C047Markdown 表格是向模型传递结构化数据的最佳格式之一(因为 GitHub 训练数据丰富)T2-2-brex”Markdown tables are great for scenarios where you have many items of the same type… OpenAI’s models are exceptionally good at working with Markdown tables (presumably from the tons of GitHub data)“实战经验
C048JSON 适用于不规则数据和嵌套数据:key 和 value 的近距离让模型更好地保持映射关系T2-2-brex”The close proximity of keys to their values makes it easy for the model to keep the mapping straight”实战经验
C049嵌套数据优先用 JSON;如果 token 预算紧张,退而求其次用关系型 Markdown 表格(第三范式)T2-2-brex”If using nested JSON winds up being too verbose for your token budget, fallback to relational tables defined with Markdown”实战经验
C050模型可以处理关系表的 JOIN 操作,但超过三层嵌套 JOIN 会出问题T2-2-brex”The model works well with data in 3rd normal form, but may struggle with too many joins. In experiments, it seems to do okay with at least three levels of nested joins.”实战经验
C051自由文本用三重反引号(```)分隔,让模型区分 prompt 指令和待处理内容T2-2-brex”surrounding the document with triple backticks works well”实战经验
C052经验法则:prompt 中的所有格式化技巧都应倾向于模型从 GitHub 学到的格式T2-2-brex”A good rule of thumb for anything you’re doing in prompts is to lean heavily on things the model would have learned from GitHub.”实战经验
C053需要引用时给数据唯一 ID,然后让模型引用该 ID — 模型会可靠地链接引用T2-2-brex”anything you might want to cite should have a unique ID. The simplest approach is to just ask the model to link to anything it references”实战经验
C054程序化消费:要求模型输出 JSON/YAML 格式并提供输出格式示例T2-2-brex”asking the model to output the results in your favorite serialization format (JSON and YAML seem to work best)“实战经验
C055Chain-of-Thought(思维链):让模型展示推理过程可以显著提升可靠性T2-2-brex”ask the bot to show its work… if you give the bot examples of answering questions by showing your work, then when you ask the bot to answer something it will show its work and produce more reliable answers”通用原则
C056Zero-shot CoT:仅需添加”Let’s think step-by-step”即可触发推理能力,无需提供示例T2-2-brex”you don’t even need to provide examples – you simply have to ask the bot to think step-by-step”通用原则
C057CoT 使用分隔符隐藏思考过程:让模型在 JSON 中分离 thinking 和 final answer,只展示最终答案T2-2-brex”ask the bot to delineate the final answer from its thinking… let’s use JSON to make it easy to parse”实战经验
C058CoT 会消耗更多 token(增加成本和延迟),但在复杂场景下结果显著更可靠T2-2-brex”Using Chain-of-Thought prompting will consume more tokens, resulting in increased price and latency, but the results are noticeably more reliable for many scenarios”实战经验
C059Fine-tuning 应作为最后手段:零/少样本学习优先于微调T2-2-brex”Fine-tuning… should, in general, be a last resort” / “take advantage of the nature of language models being zero-shot, one-shot, and few-shot learners by teaching them to do something in their prompt rather than fine-tuning”实战经验
C060Fine-tuning 的四大劣势:模型限制(部分模型不支持)、数据准备开销、迭代速度慢、成本高昂T2-2-brex”Not possible / Overhead / Velocity / Cost — 60x more expensive to use a fine-tuned GPT-3 vs gpt-3.5-turbo”实战经验
C061安全红线:永远不要用真实客户数据做 fine-tuning — 模型会记住并泄露T2-2-brex”If you fine-tune a model, never use real customer data. Always use synthetic data. The model may memorize portions of the data you provide and may regurgitate private data”实战经验
C062GPT-4 vs GPT-3.5 的核心差异在于”教钓鱼”场景:GPT-4 可零样本处理复杂命令语法,GPT-3.5 需要大量示例T2-2-brex”None of the above examples of command grammars work without meaningful modifications for GPT-3.5… you have to provide a number of examples (at least one usage example per command)… GPT-4 is capable of far more consistent and complex logic with far simpler prompts”实战经验
C063模型能做传递推理:将”今天”映射为具体日期,再在表格中查找该日期T2-2-brex”the items in the table have an explicit date, February 2nd. In our question, we asked about ‘today’. And earlier in the prompt we mentioned that today was Feb 2. The model correctly handled the transitive inference”实战经验
C064模型能从上下文推断出未直接给出的信息(如从名称查找 ID 再传给命令)T2-2-brex”the model knows that the command add-memo takes an expense ID. But we never tell it the expense ID, so it looks up ‘Shake Shack’ in the table of expenses, then grabs the ID”实战经验
C065Prompt Engineering 是技能组合而非单一技术:需要混合搭配多种策略T2-2-brex”you will need to combine some subset of all of the strategies enumerated in this document. Don’t be afraid to mix and match things – or invent your own approaches”通用原则
C066PE 不只是写 prompt — 还包括安全、与工具集成、领域知识注入等全栈能力T3-1-dairai-introduction”Prompt engineering is not just about designing and developing prompts. It encompasses a wide range of skills and techniques… improve safety of LLMs and build new capabilities like augmenting LLMs with domain knowledge and external tools”理论学术
C067Few-shot Prompting:通过在 prompt 中提供示例实现上下文学习,引导模型性能提升T3-1-dairai-fewshot”Few-shot prompting can be used as a technique to enable in-context learning where we provide demonstrations in the prompt to steer the model to better performance”通用原则
C068Few-shot 中标签空间和输入分布比标签正确性更重要T3-1-dairai-fewshot”the label space and the distribution of the input text specified by the demonstrations are both important (regardless of whether the labels are correct for individual inputs)“理论学术
C069Few-shot 的格式比内容更重要:即使用随机标签,有格式也比没格式好得多T3-1-dairai-fewshot”the format you use also plays a key role in performance, even if you just use random labels, this is much better than no labels at all”理论学术
C070Few-shot 在复杂推理任务上有局限性 — 这时需要 Chain-of-ThoughtT3-1-dairai-fewshot”Standard few-shot prompting works well for many tasks but is still not a perfect technique, especially when dealing with more complex reasoning tasks”通用原则
C071CoT 通过中间推理步骤实现复杂推理能力,可与 few-shot 结合使用T3-1-dairai-cot”chain-of-thought (CoT) prompting enables complex reasoning capabilities through intermediate reasoning steps. You can combine it with few-shot prompting to get better results on more complex tasks that require reasoning before responding.”通用原则
C072CoT 只需极少示例即可生效 — 甚至一个示例就够了,但需要”足够大的语言模型”T3-1-dairai-cot”just one example seems enough” / “the technique requires ‘sufficiently large language models‘“通用原则
C073Auto-CoT:自动生成推理链示例,通过问题聚类 + 代表性抽样避免人工编写T3-1-dairai-cot”Auto-CoT, which samples questions with diversity and generates reasoning chains to construct the demonstrations” — 两阶段:Question clustering + Demonstration sampling理论学术
C074Self-Consistency:采样多条推理路径,选最一致的答案,替代贪心解码T3-1-dairai-self-consistency”sample multiple, diverse reasoning paths through few-shot CoT, and use the generations to select the most consistent answer”通用原则
C075Self-Consistency 适用条件:算术推理和常识推理任务;使用前提是已有 CoT promptT3-1-dairai-self-consistency”boost the performance of CoT prompting on tasks involving arithmetic and commonsense reasoning”通用原则
C076Tree of Thoughts(ToT):维护思维树,每个节点是连贯的中间推理步骤,结合搜索算法(BFS/DFS)进行系统性探索T3-1-dairai-tot”ToT maintains a tree of thoughts, where thoughts represent coherent language sequences that serve as intermediate steps… combined with search algorithms (e.g., breadth-first search and depth-first search) to enable systematic exploration of thoughts with lookahead and backtracking”理论学术
C077ToT 适用条件:需要探索或战略性前瞻的复杂任务,传统 prompting 不够用时T3-1-dairai-tot”For complex tasks that require exploration or strategic lookahead, traditional or simple prompting techniques fall short”通用原则
C078ToT 简化版 prompt:用”想象三个专家分步讨论,发现错误就退出”的单一 prompt 实现T3-1-dairai-tot”Imagine three different experts are answering this question. All experts will write down 1 step of their thinking, then share it with the group. Then all experts will go on to the next step, etc. If any expert realises they’re wrong at any point then they leave.”通用原则
C079ToT 的自评估机制:让模型对每个中间思维评估”sure/maybe/impossible”T3-1-dairai-tot”the LM is prompted to evaluate each thought candidate as ‘sure/maybe/impossible’ with regard to reaching 24”理论学术
C080ReAct 框架:交替生成推理轨迹(Thought)和动作(Action),形成 Thought→Action→Observation 循环T3-1-dairai-react”ReAct prompts LLMs to generate verbal reasoning traces and actions for a task… Thought → Action → Observation (repeated)“通用原则
C081ReAct 解决了 CoT 的关键缺陷:CoT 无法访问外部世界,容易产生事实幻觉和错误传播T3-1-dairai-react”CoT… lack of access to the external world or inability to update its knowledge can lead to issues like fact hallucination and error propagation”理论学术
C082ReAct 最佳策略是与 CoT + Self-Consistency 结合使用T3-1-dairai-react”The best approach overall involves combining ReAct with CoT + Self-Consistency”理论学术
C083ReAct 的局限性:结构约束减少推理灵活性;严重依赖检索质量,无信息搜索结果会让推理脱轨T3-1-dairai-react”ReAct’s structural constraints reduce its flexibility in formulating reasoning steps” / “non-informative search results derail the model reasoning”理论学术
C084当 zero-shot 和 few-shot 都不够时,说明模型的学习能力已不足以胜任当前任务 — 应考虑 fine-tuning 或更高级的 prompting 技术T3-1-dairai-fewshot”When zero-shot prompting and few-shot prompting are not sufficient, it might mean that whatever was learned by the model isn’t enough to do well at the task. From here it is recommended to start thinking about fine-tuning your models or experimenting with more advanced prompting techniques.”通用原则
C085Few-shot 能力随模型规模涌现 — 小模型可能完全不具备 few-shot 学习能力T3-1-dairai-fewshot”few shot properties first appeared when models were scaled to a sufficient size”理论学术
C08618 种主流 prompting 技巧形成一个工具箱:从 Zero-shot 到 Graph Prompting,应根据任务类型选择T3-1-dairai-techniques-overview列出 18 种技术:Zero-shot, Few-shot, CoT, Meta Prompting, Self-Consistency, Generate Knowledge, Prompt Chaining, ToT, RAG, ART, APE, Active-Prompt, Directional Stimulus, PAL, ReAct, Reflexion, Multimodal CoT, Graph Prompting通用原则
C087Prompt Chaining(提示链):将复杂任务拆分为顺序子任务,每一步的输出作为下一步的输入T3-1-dairai-techniques-overview”Breaking complex tasks into sequential sub-tasks”通用原则
C088Generate Knowledge Prompting:先让模型生成相关知识,再用这些知识回答问题T3-1-dairai-techniques-overview”Generating relevant knowledge before answering”通用原则