← 返回目录

System prompting

第 10 / 34 卷日期:

区分系统提示、上下文提示和角色提示为设计意图明确的提示提供了框架,允许灵活组合,并更容易分析每种提示类型如何影响语言模型的输出。

让我们深入探讨这三种不同类型的提示。

系统提示

表 3 包含一个系统提示,我在其中指定了关于如何返回输出的附加信息。我提高了温度值以获得更高的创意水平,并设置了更高的令牌限制。但由于我对输出格式的明确指示,模型并未返回额外文本。

Goal将电影评论分类为正面、中性或负面。

模型gemini-pro 温度1令牌限制5

Top‑K 采样Top‑P 采样

40n`x0nà 提示Classify movie reviews as positive, neutral or negative. Only return the label in uppercase.

Review: "Her" is a disturbing study revealing the direction humanity is headed if AI is allowed to keep evolving, unchecked. It's so disturbing I couldn't watch it.

Sentiment:

输出负面

表 3. 系统提示示例

系统提示可用于生成符合特定要求的输出。' 系统提示 ' 这一名称实际代表 ' 为系统提供额外任务 '。例如,您可以使用系统提示生成与特定编程语言兼容的代码片段,或利用系统提示返回特定结构。请参阅表 4,其中我以 JSON 格式返回了输出。

Goal将电影评论分类为正面、中性或负面,返回JSON格式。
模型gemini-pro
温度1 令牌限制 1024

Top‑P

Top-K40n`x0nà

采样

提示词Classify movie reviews as positive, neutral or negative. Return valid JSON:

Review: "Her" is a disturbing study revealing the direction humanity is headed if AI is allowed to keep evolving, unchecked. It's so disturbing I couldn't watch it.

Schema:

``` MOVIE:

{ "sentiment": String "POSITIVE" | "NEGATIVE" | "NEUTRAL"

"name": String } MOVIE REVIEWS:

{ "movie_reviews": [MOVIE] } ``` JSON Response:

输出``` { "movie_reviews": [ { "sentiment": "NEGATIVE", "name": "Her"

} ] } ```

表 4. 使用 JSON 格式的系统提示示例

全站分卷索引 · 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