Be specific about the output
明确输出要求
需明确期望的输出内容。简短的指令可能无法为大型语言模型提供足够引导或过于笼统。在提示中提供具体细节(通过系统或上下文提示)有助于模型聚焦相关要素,从而提升整体准确性。
& @ Ñ € € 0õ ð xP
" ^ xP~
Generate a 3 paragraph blog post about the top 5 video game consoles.
The blog post should be informative and engaging, and it should be written in a conversational style.
禁止事项:
Generate a blog post about video game consoles.
优先使用指令而非约束条件
提示工程中通过指令和约束条件来引导大语言模型的输出。
•指令明确规定了响应所需的格式、风格或内容,指导模型应当执行的操作或生成的内容。
•约束条件是对响应的限制或边界,规定了模型不应执行或需要避免的事项。
越来越多的研究表明,在提示中关注正向指令比过度依赖约束条件更为有效。这种方法与人类偏好正向指令而非禁令清单的心理相契合。
指令直接传达期望结果,而约束条件可能让模型对允许行为产生猜测。它在既定范围内提供灵活性并鼓励创造性,而约束可能限制模型潜力。冗长的约束清单
还可能出现自相矛盾的情况。
约束条件在特定场景下仍具价值:例如需要防止模型生成有害 / 偏见内容时,或要求严格遵守输出格式 / 风格时。
如有可能,请使用正向指令:与其告诉模型不要做什么,不如告诉它应该做什么。这样可以避免混淆并提高输出的准确性。
" ^ xP~
Generate a 1 paragraph blog post about the top 5 video game consoles.
Only discuss the console, the company who made it, the year, and total sales.
禁止:
Generate a 1 paragraph blog post about the top 5 video game consoles.
Do not list video game names.
最佳实践是优先使用指令,明确说明您希望模型执行的操作,仅在出于安全、清晰度或特定需求时使用约束条件。通过实验和迭代测试不同指令与约束的组合,找到最适合您特定任务的方案,并予以记录。
全站分卷索引 · 34 卷
- 1Introduction
- 2Prompt engineering
- 3LLM output configuration
- 4Sampling controls
- 5Top-K and top-P
- 6Putting it all together
- 7Prompting techniques
- 8One-shot & few-shot
- 9System, contextual and role prompting
- 10System prompting
- 11Role prompting
- 12Contextual prompting
- 13Step-back prompting
- 14Chain of Thought (CoT)
- 15Self-consistency
- 16Tree of Thoughts (ToT)
- 17ReAct (reason & act)
- 18Automatic Prompt Engineering
- 19Code prompting
- 20Prompts for explaining code
- 21Prompts for translating code
- 22Prompts for debugging and reviewing code
- 23What about multimodal prompting?
- 24Design with simplicity
- 25Be specific about the output
- 26Control the max token length
- 27Experiment with input formats and writing styles
- 28Adapt to model updates
- 29JSON Repair
- 30Working with Schemas
- 31Experiment together with other prompt engineers
- 32CoT Best practices
- 33Summary
- 34Endnotes