← 返回目录

Be specific about the output

第 25 / 34 卷日期:

明确输出要求

需明确期望的输出内容。简短的指令可能无法为大型语言模型提供足够引导或过于笼统。在提示中提供具体细节(通过系统或上下文提示)有助于模型聚焦相关要素,从而提升整体准确性。

& @ Ñ € € 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 卷
  1. 1Introduction
  2. 2Prompt engineering
  3. 3LLM output configuration
  4. 4Sampling controls
  5. 5Top-K and top-P
  6. 6Putting it all together
  7. 7Prompting techniques
  8. 8One-shot & few-shot
  9. 9System, contextual and role prompting
  10. 10System prompting
  11. 11Role prompting
  12. 12Contextual prompting
  13. 13Step-back prompting
  14. 14Chain of Thought (CoT)
  15. 15Self-consistency
  16. 16Tree of Thoughts (ToT)
  17. 17ReAct (reason & act)
  18. 18Automatic Prompt Engineering
  19. 19Code prompting
  20. 20Prompts for explaining code
  21. 21Prompts for translating code
  22. 22Prompts for debugging and reviewing code
  23. 23What about multimodal prompting?
  24. 24Design with simplicity
  25. 25Be specific about the output
  26. 26Control the max token length
  27. 27Experiment with input formats and writing styles
  28. 28Adapt to model updates
  29. 29JSON Repair
  30. 30Working with Schemas
  31. 31Experiment together with other prompt engineers
  32. 32CoT Best practices
  33. 33Summary
  34. 34Endnotes