提示设计是创建提示以从语言模型引出所需回复的过程。编写结构化良好的提示是确保从语言模型获得准确优质回复的重要环节。本页面介绍了一些基本概念、策略和最佳实践,可帮助您开始设计提示。
什么是提示
提示是提交到语言模型以接收回复的自然语言请求。提示可以包含问题、说明、语境信息、样本以及模型完成或继续的部分输入。模型收到提示后,可以生成文本、嵌入、代码、图片、视频和音乐等,具体取决于所用的模型类型。
提示内容类型
提示可以包含以下一种或多种内容类型:
输入
输入是您希望模型为其提供回复的提示中的文本,它是必需的内容类型。输入可以是模型回答的问题(问题输入)、模型执行的任务(任务输入)、模型操作的实体(实体输入),或模型完成或继续的部分输入(补全输入)。
问题输入
问题输入是您向提供回答的模型询问的问题。
What's a good name for a flower shop that specializes in selling bouquets of dried flowers? Create a list of 10 options with just the names. Here are 10 names for a flower shop specializing in dried flowers: 1. Everlasting Blooms 2. Dried & Delightful 3. The Petal Preserve 4. Whispers of Wildflowers 5. Forever Blooms 6. The Botanical Muse 7. Timeless Blooms 8. Dried Flower Co. 9. Bloom & Co. 10. The Sun-Kissed Petals |
任务输入
任务输入是您希望模型执行的任务。例如,您可以指示模型为您提供某个主题的想法或建议。
Give me a simple list of just the things that I must bring on a camping trip. The list should have 10 items. Here's a list of 10 essential items for a camping trip: 1. **Tent:** Your shelter from the elements. 2. **Sleeping Bag:** Stay warm and comfortable. 3. **Sleeping Pad:** Insulation and cushioning for a good night's sleep. 4. **Headlamp or Flashlight:** Light for nighttime activities. 5. **First Aid Kit:** Be prepared for minor injuries. 6. **Water Bottle/Hydration Pack:** Stay hydrated. 7. **Food and Snacks:** Fuel for your adventures. 8. **Cooking Gear:** Camp stove, fuel, utensils, etc. 9. **Knife and Multitool:** Essential for various tasks. 10. **Camp Chair:** Enjoy your campfire and meals comfortably. |
实体输入
实体输入是模型对其执行操作(例如分类或汇总)的对象。添加说明对这种类型的输入有帮助。
Classify the following items as [large, small]. Elephant Mouse Snail Here's the classification: * **Elephant:** Large * **Mouse:** Small * **Snail:** Small |
补全输入
补全输入是您希望模型补全或继续往下写的文本。
Complete the following prompt: Some simple strategies for overcoming writer's block include... Some simple strategies for overcoming writer's block include: * **Freewriting:** Write non-stop for a set amount of time (5-10 minutes) without worrying about grammar, spelling, or even making sense. Just keep your pen moving and let your thoughts flow freely. This can help you loosen up and access ideas you might not have considered otherwise. * **Brainstorming:** Make a list of everything that comes to mind related to your topic, no matter how silly or unrelated it seems. You can also use mind mapping or other visual brainstorming techniques. * **Changing your environment:** Sometimes a change of scenery can be all you need to get the creative juices flowing. Go for a walk, work in a coffee shop, or even just move to a different room in your house. * **Reading:** Immerse yourself in the work of other writers, especially those who inspire you. Pay attention to their style, their structure, and their use of language. * **Taking a break:** Sometimes the best way to overcome writer's block is to simply step away from the project for a while. Go for a walk, watch a movie, listen to music, or do something else that you enjoy. You might be surprised at how much clearer your head feels when you return to your writing. * **Focusing on a single element:** Instead of tackling the entire project, focus on a single sentence, paragraph, or scene. Once you get something down on paper, it can be easier to build from there. * **Starting with the ending:** If you're stuck on the beginning, try writing the ending first. This can help you to clarify your overall vision for the project and provide a framework for your ideas. * **Talking it out:** Share your ideas and challenges with a friend, a writing group, or a writing coach. Discussing your project with someone else can help you to see it from a new perspective and find solutions to your writing problems. Remember, writer's block is a common experience, and it's not a sign that you're a bad writer. Just be patient with yourself, try some of these strategies, and keep writing! |
上下文
语境可以是以下项之一:
- 指定模型行为方式的说明。
- 模型使用或引用来生成回复的信息。
当您需要向模型提供信息时,请在提示中添加语境信息,或者将回复的边界限制为仅提示中的内容。
Marbles: Color: red Number: 12 Color: blue Number: 28 Color: yellow Number: 15 Color: green Number: 17 How many green marbles are there? There are 17 green marbles. |
示例
样本是您在提示中添加的输入-输出对,以便为模型提供理想的回复样本。在提示中添加样本是自定义回复格式的有效策略。
Classify the following. Options: - red wine - white wine Text: Chardonnay The answer is: white wine Text: Cabernet The answer is: red wine Text: Moscato The answer is: white wine Text: Riesling The answer is: The answer is: white wine |
后续步骤
- 现在,您已经了解了问题设计,不妨尝试使用 Google AI Studio 编写自己的问题。
- 如需深入了解提示设计,请参阅提示策略主题。
- 如需了解多模态提示,请参阅使用媒体文件进行提示。