编写Prompt的两个关键原则:让AI明白你的意图

在现代人工智能开发中,编写Prompt(提示)是与AI模型互动的重要一环。但如何编写Prompt以确保模型能够准确理解你的意图并提供有用的回应,却是一门艺术。本文将分享两个关键原则,这些原则将帮助你更好地编写Prompt,让你的AI交互更加高效。

原则一:编写清晰、具体的说明

原则一:编写清晰、具体的说明,这是编写Prompt时不可或缺的原则之一。为什么这么重要呢?因为只有当你提供清晰、具体的指令时,AI才能够准确理解你的需求,从而提供有针对性的回应。

策略1:使用分隔符清晰地标识出输入的各个部分

为了让模型明确知道哪些部分是关键信息,你可以使用分隔符来标识输入的各个部分。这些分隔符可以是三个反引号、引号、XML标签等,只要能够让模型明确地知道这是一个独立的部分即可。以下是一个示例:

Summarize the text delimited by triple backticks into a single sentence.

You should express what you want a model to do by providing instructions that are as clear and specific as you can possibly make them. This will guide the model towards the desired output, and reduce the chances of receiving irrelevant or incorrect responses.


这样的分隔符可以帮助模型更好地理解你的指令,从而提供更准确的回应。

### 策略2:提示模型以结构化格式输出结果

有时,你可能需要模型以特定的结构化格式输出结果,比如JSON、HTML等。在这种情况下,你可以明确要求模型按照特定格式提供回应。以下是一个示例:

```markdown
Generate a list of three made-up book titles along with their authors and genres.
Provide them in JSON format with the following keys: book_id, title, author, genre.</code></pre>
<p>这样的指令可以帮助模型生成符合你要求的结构化数据,使得结果更易于处理和理解。</p>
<h3>策略3:让模型检查是否满足条件</h3>
<p>有时,你可能需要模型检查输入文本是否满足特定条件,并根据条件输出不同的回应。以下是一个示例:</p>
<pre><code class="language-markdown">You will be provided with text delimited by triple quotes. 
If it contains a sequence of instructions, re-write those instructions in the following format:

Step 1 - ...
Step 2 - ...
...
Step N - ...

If the text does not contain a sequence of instructions, then simply write "No steps provided."</code></pre>
<p>这样的指令可以帮助模型进行条件判断,并根据情况提供不同的回应,增加了交互的灵活性。</p>
<h2>原则二:给予模型思考的时间</h2>
<p><strong>原则二</strong>:给予模型思考的时间,这是另一个关键原则。有时候,模型需要一些时间来处理复杂的任务或生成有深度的回应,因此,你需要明确要求模型不要匆忙得出结论,而是要找出自己的解决方案。</p>
<h3>策略1:明确说明完成任务所需的步骤</h3>
<p>为了确保模型不匆忙,你可以明确要求模型按照一系列步骤来完成任务。这样,模型将会仔细思考每一步,而不是仓促生成回应。以下是一个示例:</p>
<pre><code class="language-markdown">Your task is to perform the following actions: 
1 - Summarize the following text delimited by triple backticks with 1 sentence.
2 - Translate the summary into French.
3 - List each name in the French summary.
4 - Output a json object that contains the following keys: french_summary, num_names.

Separate your answers with line breaks.

Text:
``<code>In a charming village, siblings Jack and Jill set out on a quest to fetch water from a hilltop well. As they climbed, singing joyfully, misfortune struck—Jack tripped on a stone and tumbled down the hill, with Jill following suit. Though slightly battered, the pair returned home to comforting embraces. Despite the mishap, their adventurous spirits remained undimmed, and they continued exploring with delight.</code>``</code></pre>
<p>这样的指令将确保模型不会仓促生成回应,而是按照步骤仔细思考任务。</p>
<h3>策略2</h3>
<p>:提示模型不要匆忙得出结论,而是要找出自己的解决方案</p>
<p>有时,你可能需要模型对某个问题进行分析,并给出自己的解决方案,而不是仅仅回答问题。以下是一个示例:</p>
<pre><code class="language-markdown">Your task is to determine if the student's solution is correct or not.
To solve the problem do the following:
- First, work out your own solution to the problem. 
- Then compare your solution to the student's solution and evaluate if the student's solution is correct or not. 
Don't decide if the student's solution is correct until you have done the problem yourself.

Use the following format:
Question:
``<code>question here</code>``
Student's solution:
``<code>student&#039;s solution here</code>``
Actual solution:
``<code>steps to work out the solution and your solution here</code>``
Is the student's solution the same as actual solution just calculated:
``<code>yes or no</code>``
Student grade:
``<code>correct or incorrect</code>``

Question:
```I'm building a solar power installation and I need help working out the financials. 
- Land costs $100 / square foot
- I can buy solar panels for $250 / square foot
- I negotiated a contract for maintenance that will cost me a flat $100k per year, and an additional $10 / square foot
What is the total cost for the first year of operations as a function of the number of square feet.``` 
Student's solution:
```Let x be the size of the installation in square feet.
Costs:
1. Land cost: 100x
2. Solar panel cost: 250x
3. Maintenance cost: 100,000 + 100x
Total cost: 100x + 250x + 100,000 + 100x = 450x + 100,000```
Actual solution:

这样的指令要求模型首先思考问题,然后进行比较和评估,确保回应是经过深思熟虑的。

结论

编写Prompt时,清晰明了的指令和给予模型足够的思考时间是两个关键原则。只有当你的指令清晰明了,模型才能够准确理解你的需求;而给予模型足够的思考时间,可以确保回应是经过深思熟虑的。遵循这两个原则,你将能够更好地与AI模型互动,获得更有价值的结果。

参考

本文由作者 王大神 原创发布于 大神网的AI博客。

转载请注明作者:王大神

原文出处:编写Prompt的两个关键原则:让AI明白你的意图

(0)
打赏 微信扫一扫 微信扫一扫
上一篇 2023年10月6日
下一篇 2023年10月6日

相关推荐

  • 享受未来AI助手的魔力:Claude注册和使用教程

    有没有想过,如果你的工作中有一个智能伙伴,会是什么样的体验?能够理解你的语言习惯、思维方式,能够进行连贯、知识丰富且上下文感知的对话,甚至有着自己的个性化语言表达。那该有多好!今天,让我为你介绍一款…

    2023年9月15日
    00
  • 深入了解AutoGen:构建下一代LLM应用的多代理对话框架

    在这个快速发展的技术时代,我们经常遇到一些挑战,这些挑战需要我们不断寻找新的解决方案。想象一下,如果我们可以通过构建一个高效、互动、并能处理复杂任务的多代理对话系统来克服这些挑战。这正是Microsoft推出…

    2023年11月17日
    00
  • 追逐激情,赢在人生起跑线:40岁前的成功逆袭秘籍

    为什么我们总是在人生路上迷失? 嗨,各位朋友们,我是你的老朋友王大神。今天,我要和你分享一些独特的见解,关于如何在40岁之前成功逆袭。每个人都经历了人生中的起起伏伏,但是有一些人能够在40岁之前脱颖而出,…

    2023年9月27日
    00
  • GPT-4V曝光意外漏洞:智能模型的新挑战

    最近,GPT-4V这一备受瞩目的多模态智能模型接连曝出了一系列重大缺陷,引起了广泛的关注。这些意外漏洞让我们重新审视了人工智能领域的发展,同时也提出了重要的挑战。本文将深入探讨这些问题,以及它们可能对未来…

    2023年11月14日
    00
  • AI绘画Stable Diffusion研究:SD采样方法详解与选择指南

    自然语言处理领域的快速发展,使得人工智能技术在诸多领域中广泛应用,其中包括了创作与绘画。AI绘画中的Stable Diffusion(稳定扩散)技术,作为人工智能在创作领域的重要应用,已经涌现出众多采样方法。在本文中…

    2023年9月3日
    00
  • 人工智能图像识别:优雅的使用yolov5打麻将

    在数字化时代,人工智能技术正不断演进,为各行各业带来创新的可能性。其中,YOLO(You Only Look Once)是一个广受欢迎的对象检测算法,它的快速和高效性使其成为许多应用的首选。然而,有人选择用YOLO来检测残次…

    2022年6月25日
    00
  • 打造你的AI游戏伙伴:训练人工智能玩游戏

    嗨,亲爱的游戏爱好者!你是否曾想过拥有一个强大的游戏伙伴,一个能够与你一同征战虚拟世界的AI助手?或许你在某个游戏关卡卡住了,需要一个精湛的合作伙伴来帮助你度过难关。那么,不妨让我告诉你,这个梦想可以…

    2023年9月25日
    00
  • 创建高效的AI教程:使用OpenAI的Completions API

    在数字时代,人工智能(AI)正逐渐渗透到我们的生活和工作中。无论是在自动化任务、自然语言处理还是其他领域,AI技术都成为了不可或缺的一部分。OpenAI作为领先的AI研究机构之一,提供了一系列强大的AI模型和工具…

    2023年11月25日
    00
  • 微软画图推出AI图像生成器“Cocreator”:让创意成为现实

    随着科技的不断进步,人工智能已经成为我们生活中不可或缺的一部分。而今天,微软为Windows 11 PC用户带来了一项令人兴奋的新功能——AI图像生成器“Cocreator”。这个功能不仅让用户可以通过文本描述将他们的想象变为…

    2023年12月3日
    00
  • AI PC:电脑进化的新时代

    在2024年,全球科技行业正迎来一场重大的革命,那就是AI PC(人工智能个人电脑)的崛起。根据IDC的预测,AI PC的装配比例将在未来几年中迅速攀升,预计到2027年将达到81%,成为PC市场的主流。这一趋势的兴起,被许…

    2024年1月14日
    00