ChatGPT提示词指令分享·技巧篇⑤
<h1>技巧5:把指令和文本内容用特殊符号分开。</h1><p>根据我的测试,使用 <code>"""</code> 把任务指令和待处理文本隔开,能显著提高 AI 回答的准确度。</p>
<p>举个例子,下面的写法相对效果一般,因为 AI 不太清楚哪部分是指令,哪部分是文本:</p>
<pre><code>Please summarize the following sentences to make them easier to understand.
OpenAI is an American artificial intelligence (AI) research laboratory...
请将以下句子总结并简化,使其更容易理解。
OpenAI 是一家美国人工智能(AI)研究实验室……
</code></pre>
<p>而用三重引号分割后,效果更好:</p>
<pre><code>Please summarize the following sentences to make them easier to understand.
Text: """
OpenAI is an American artificial intelligence (AI) research laboratory...
"""
请将以下内容总结并简化,使其更容易理解。
文本:"""
OpenAI 是一家美国的人工智能(AI)研究实验室……
"""
</code></pre>
<p>此外,<code>###</code> 也可以作为分隔符。但我个人偏爱 <code>"""</code>,因为有时会用 <code>#</code> 做格式,连续的 <code>#</code> 会让提示变得难以阅读😂。</p>
<p>除了三重引号,还能用其他符号如 <code><tag></tag></code> 或尖括号 <code>< ></code> 来分隔内容。比如用 Python 代码定义文本和提示:</p>
<pre><code>text = f"""
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...
"""
prompt = f"""
Summarize the text delimited by triple backticks \
into a single sentence.
`{text}`
"""
text = f"""
你应该尽可能清晰、具体地表达你希望模型执行的任务……
"""
prompt = f"""
请将由三个反引号括起来的文本总结成一句话。
`{text}`
"""
</code></pre>
<p>如果你正开发一个允许用户输入内容并自动总结的 AI 应用,这个分隔符技巧会非常实用,能帮 AI 更好理解输入内容和任务指令,提升输出质量。</p>
页:
[1]