Google Prompt 学习
date
Nov 13, 2024
slug
google-prompt
status
Published
tags
AI
summary
学习 Google prompt 官方教程
type
Post
提示最佳实践
- 清楚地传达最重要的内容或信息。
- 构造提示:先定义其角色,提供上下文/输入数据,然后提供指令。
- 使用具体的、多样化的示例来帮助模型缩小其关注点,以生成更准确的结果。
- 使用约束来限制模型输出的范围。这有助于避免指示与事实不符。
- 将复杂的任务分解为一系列更简单的提示。
- 指示模型在生成之前评估或检查其自己的响应。(“确保将你的回答限制在 3 句话以内”、“以简洁起见,以 1-10 分的等级评价你的工作”、“你认为这是正确的吗?。
- 最重要的:创意和坚持
Prompt 的类型
- 零样本提示(zero-shot):仅仅提供背景、角色、指令/问题(必要)、限制,不提供示例。
- 单样本、少样本、多样本提示(One-, few-, and multi-shot):除了上述的信息,也提供希望模型返回的示例,用户和模型对话的示例
- 思维链提示(Chain-of-thought prompting):思维链 (CoT) 提示让LLM解释出它的推理过程。将其与少样本提示相结合,可以在更复杂的任务上获得更好的结果,这些任务需要在响应之前进行推理。
- 零样本思维链(Zero-shot CoT ):采用零样本提示并添加一条指令:“让我们一步一步地思考“。能够LLM从此指令中产生一个思维链,通常也得出更准确的答案。这是为单词问题等问题生成正确答案的好方法LLMs。
Prompt 的迭代
- Repeat key words, phrases, or ideas
重复关键的词汇、短语或想法
- Specify your desired output format (CSV, JSON, etc.)
指定你所需要的输出格式(CSV、JSON 等)
- Use all caps to stress important points or instructions. You can also try exaggerations or hyperbolic language; for example: "Your explanation should be absolutely impossible to misinterpret. Every single word must ooze clarity!"
使用全部大写字母来强调要点或说明。你也可以尝试夸张或夸张的语言;例如:“你的解释应该是绝对不可能误解的。每一个字都必须清晰明了!
- Use synonyms or alternate phrasing (e.g., instead of "Summarize," try appending "tldr" to some input text). Swap in different words or phrases and document which ones work better and which are worse.
使用同义词或替代措辞(例如,尝试将“tldr”附加到某些输入文本中,而不是“Summarize”)。
换入不同的单词或短语,并记录哪些效果更好,哪些效果更差。
"tldr" is an acronym meaning "too long; didn't read." In the context of prompt engineering, it's used as an alternative to "Summarize" when requesting a brief overview of text.
- Try the sandwich technique with long prompts: Add the same statement in different places.
尝试在长提示里使用sandwich技术:在不同的地方添加相同的语句
- Use a prompt library for inspiration. Prompt Hero and this prompt gallery are two good places to start.
使用提示库获取灵感。Prompt Hero 和提示库。