OpenAI出品的ChatGPT提示技巧最佳实践

93 阅读5分钟

文章首发

OpenAI出品的ChatGPT提示技巧最佳实践

NOTE: "{text input here}"是实际文本的占位符

使用最新的模型

为了获得最佳效果,建议使用最新、最强大的模型。较新的模型往往更容易进行提示。

将指令放在提示的开头,并使用###或"""分隔指令和上下文

低质提示❌:

Summarize the text below as a bullet point list of the most important points.
{text input here}

翻译后:

将以下文本总结为要点列表。

{text input here}

高质提示 ✅:

Summarize the text below as a bullet point list of the most important points.

Text: """
{text input here}
"""

翻译后:

将以下文本总结为要点列表。

文本:"""

{text input here}

"""

对所需的上下文、结果、长度、格式、风格等要尽可能具体、详细地描述

低质提示❌:

Write a poem about OpenAI. 

翻译后:

写一首关于OpenAI的诗。

高质提示 ✅:

Write a short inspiring poem about OpenAI, focusing on the recent DALL-E product launch (DALL-E is a text to image ML model) in the style of a {famous poet}

翻译后:

写一首简短的励志诗,内容聚焦于最近发布的DALL-E产品(DALL-E是一种文本到图像的机器学习模型),风格模仿{著名诗人}。

通过示例来明确所需的输出格式

低质提示❌:

Extract the entities mentioned in the text below. Extract the following 4 entity types: company names, people names, specific topics and themes.

Text: {text}

翻译后:

从以下文本中提取实体。提取以下4种实体类型:公司名称、人名、具体主题和主题。

文本:{text}

当展示具体格式要求时,模型响应更好。这也使得编程上更容易可靠地解析多个输出。

高质提示 ✅:

Extract the important entities mentioned in the text below. First extract all company names, then extract all people names, then extract specific topics which fit the content and finally extract general overarching themes

Desired format:
Company names: <comma_separated_list_of_company_names>
People names: -||-
Specific topics: -||-
General themes: -||-

Text: {text}

翻译后:

从以下文本中提取重要实体。首先提取所有公司名称,然后提取所有人名,然后提取符合内容的具体主题,最后提取总体主题。

所需格式:

公司名称:<逗号分隔的公司名称列表>

人名:-||-

具体主题:-||-

总体主题:-||-

文本:{text}

先从零样本开始,不行再少样本

✅ 零样本

Extract keywords from the below text.

Text: {text}

Keywords:

翻译后:

从以下文本中提取关键词。

文本:{text}

关键词:

✅ 少样本——提供几个示例

Extract keywords from the corresponding texts below.

Text 1: Stripe provides APIs that web developers can use to integrate payment processing into their websites and mobile applications.
Keywords 1: Stripe, payment processing, APIs, web developers, websites, mobile applications
##
Text 2: OpenAI has trained cutting-edge language models that are very good at understanding and generating text. Our API provides access to these models and can be used to solve virtually any task that involves processing language.
Keywords 2: OpenAI, language models, text processing, API.
##
Text 3: {text}
Keywords 3:

翻译后:

从以下对应文本中提取关键词。

文本1:Stripe提供的API,网页开发人员可以使用这些API将支付处理集成到他们的网站和移动应用程序中。

关键词1:Stripe,支付处理,API,网页开发人员,网站,移动应用程序

文本2:OpenAI训练了前沿的语言模型,这些模型非常擅长理解和生成文本。我们的API提供了对这些模型的访问,可以用于解决几乎任何涉及处理语言的任务。

关键词2:OpenAI,语言模型,文本处理,API

文本3:{text}

关键词3:

减少不精确的描述

低质提示❌:

The description for this product should be fairly short, a few sentences only, and not too much more.

翻译后:

该产品的描述应该相当简短,仅几句话,不要多。

高质提示 ✅:

Use a 3 to 5 sentence paragraph to describe this product.

翻译后:

用3到5句话描述这个产品。

不要只说不该做什么,还要说明该做什么

低质提示❌:

The following is a conversation between an Agent and a Customer. DO NOT ASK USERNAME OR PASSWORD. DO NOT REPEAT.

Customer: I can’t log in to my account.
Agent:

翻译后:

以下是代理和客户之间的对话。不要询问用户名或密码。不要重复。

客户:我无法登录我的账户。

代理:

高质提示 ✅:

The following is a conversation between an Agent and a Customer. The agent will attempt to diagnose the problem and suggest a solution, whilst refraining from asking any questions related to PII. Instead of asking for PII, such as username or password, refer the user to the help article www.samplewebsite.com/help/faq

Customer: I can’t log in to my account.
Agent:

翻译后:

以下是代理和客户之间的对话。代理将尝试诊断问题并建议解决方案,同时避免询问任何与个人身份信息(PII)相关的问题。不要询问PII,例如用户名或密码,而是引导用户访问帮助文章www.samplewebsite.com/help/faq

客户:我无法登录我的账户。

代理:

代码生成场景下,使用“引导词”来引导模型朝特定模式响应

低质提示❌:

# Write a simple python function that
# 1. Ask me for a number in mile
# 2. It converts miles to kilometers

翻译后:

写一个简单的Python函数

  1. 向我询问一个以英里为单位的数字
  2. 将英里转换为公里

在以下优质示例中,添加“import”提示模型应该直接开始编写Python代码。

高质提示 ✅:

# Write a simple python function that
# 1. Ask me for a number in mile
# 2. It converts miles to kilometers
 
import

翻译后:

写一个简单的Python函数

  1. 向我询问一个以英里为单位的数字
  2. 将英里转换为公里

import

-------END-------

推荐一下我的掘金小册「LangChain 实战:LLM 应用开发指南」,带你从 0 到 1 打造自己的 LLM 应用。