← 返回目录

Automatic Prompt Engineering

第 18 / 34 卷日期:

自动提示工程

此时你可能会意识到编写提示词可能很复杂。如果能自动化这一过程(用提示词生成提示词)

岂不美哉?确实存在这样的方法:自动提示工程( APE)。该方法 15 不仅减少了人工输入的需求,还提升了模型在各类任务中的表现。

你将通过提示模型生成更多提示词。评估这些提示词,对优质提示进行可能的修改,并循环这一过程。

例如,您可以使用自动提示工程来帮助训练一个商品 T 恤网店的聊天机器人。我们想要弄清楚顾客在购买乐队周边 T 恤时可能使用的各种表达方式。

  1. 编写能生成输出变体的提示。在本例中,我使用 gemini‑pro 生成 10 条指令。参见表 15:

提示We have a band merchandise t-shirt webshop, and to train a chatbot we need various ways to order: "One Metallica t-shirt size S". Generate 10 variants, with the same semantics but keep the same meaning.

输出1. 我想购买一件小号的 Metallica T 恤。

  1. 我可以订购一件小号的 Metallica T 恤吗?
  2. 我想买一件小号的 Metallica T 恤。
  3. 请给我一件小号的 Metallica T 恤。
  4. 我想要一件小号的 Metallica T 恤。
  5. 我想订购一件小号的 Metallica T 恤。
  6. 小号 Metallica T 恤,请给我一件。
  7. 我在找一件小号的 Metallica T 恤。
  8. 能给我一件小号的 Metallica T 恤吗?
  9. 请给我一件 Metallica 乐队的小号 T 恤。

表 15. 使用 LLM 生成提示词

  1. 通过选定指标(例如 BLEU 双语评估替补或 ROUGE 面向召回率的摘要评估)对所有候

选指令进行评分,完成评估。

  1. 选择评估分数最高的候选指令作为最终提示词,可直接应用于软件或聊天机器人。也可调

整所选提示词后重新评估。

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