Automatic Prompt Engineering
自动提示工程
此时你可能会意识到编写提示词可能很复杂。如果能自动化这一过程(用提示词生成提示词)
岂不美哉?确实存在这样的方法:自动提示工程( APE)。该方法 15 不仅减少了人工输入的需求,还提升了模型在各类任务中的表现。
你将通过提示模型生成更多提示词。评估这些提示词,对优质提示进行可能的修改,并循环这一过程。
例如,您可以使用自动提示工程来帮助训练一个商品 T 恤网店的聊天机器人。我们想要弄清楚顾客在购买乐队周边 T 恤时可能使用的各种表达方式。
- 编写能生成输出变体的提示。在本例中,我使用 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 恤。
- 我可以订购一件小号的 Metallica T 恤吗?
- 我想买一件小号的 Metallica T 恤。
- 请给我一件小号的 Metallica T 恤。
- 我想要一件小号的 Metallica T 恤。
- 我想订购一件小号的 Metallica T 恤。
- 小号 Metallica T 恤,请给我一件。
- 我在找一件小号的 Metallica T 恤。
- 能给我一件小号的 Metallica T 恤吗?
- 请给我一件 Metallica 乐队的小号 T 恤。
表 15. 使用 LLM 生成提示词
- 通过选定指标(例如 BLEU 双语评估替补或 ROUGE 面向召回率的摘要评估)对所有候
选指令进行评分,完成评估。
- 选择评估分数最高的候选指令作为最终提示词,可直接应用于软件或聊天机器人。也可调
整所选提示词后重新评估。
全站分卷索引 · 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