如何借助提示工程编写工作指导书

ChatGPT中文站
OpenAI image: “A boss cat giving instructions to a team of worker cats in the style of Picasso”

一旦你感到兴奋地向ChatGPT询问关于西方民主面临的最大威胁以及是否已经进入了奇点,你可以将其用于实际的优势。

我总是时间紧迫,现在需要向对项目或角色缺乏经验的新晋初级团队成员解释任务。其中一些人的英语是第二语言或第三语言,因此很重要我帮助他们将工作拆分为离散的步骤形式的作业说明。在这里,大型语言模型可以帮助。

我该使用什么代码?

我重新利用了DeepLearning.AI ChatGPT Prompt Engineering for Developers短课程的代码,将我的过程概述分解成工作指导。我利用了指南章节,该章节解释了编写清晰具体指导原则的提示原则。

这个活动使用OpenAI的gpt-3.5-turbo指令调整的LLM和Python openai库中的聊天完成端点。 您需要一个OpenAI API密钥,这是一个付费使用的服务。正如我在最后展示的那样,您也可以直接在ChatGPT Web界面中使用它。请注意,您与Web界面分享的信息。

提示性工程任务检查文本是否可以被分成步骤。例如,如果文本描述如何制作一杯咖啡,则输出将是一系列步骤,但如果文本是像杰克和吉尔的故事一样的叙述,则模型将认识到该文本不易转化为说明书。我拿着代码,将我的过程描述转变成逐步说明。

以下是 Google Colab 的使用方法。

安装软件包,打开并检查 API 连接。

!pip install openai
!pip install python-dotenv
# code from ChatGPT Prompt Engineering for Developers
import os
import openai


openai.api_key = "<YOUR API KEY>"


openai.ChatCompletion.create(
model="gpt-3.5-turbo",
messages=[
{"role": "user", "content": "Hello ChatGPT, does this work?"}
]
)

2 创建提示函数

这是来自DeepLearning.AI课程的辅助函数,它旨在使使用提示更加容易。

# code from ChatGPT Prompt Engineering for Developers
def get_completion(prompt, model="gpt-3.5-turbo"):
messages = [{"role": "user", "content": prompt}]
response = openai.ChatCompletion.create(
model=model,
messages=messages,
temperature=0, # this is the degree of randomness of the model's output
)
return response.choices[0].message["content"]

3 创建描述过程的文本

本课程的提示是提供清晰的提示,提供明确的指导;越长越好,因为它有助于为模型提供上下文。一旦您看到它生成多长的步骤,您可以进行实验和调整输入文本的长度。我使用 Google 文档的语音转录来捕捉我的描述(工具>语音输入)。您可以在下一步中查看转录的文本。

ChatGPT中文站
OpenAI image: “A cat dictating words into a dictaphone in the style of Picasso”

4 提供文本输入

这个短课程介绍了使用分隔符来指示输入不同部分的策略。我使用引号,但分隔符可以是任何东西,比如:```,“““,或。使用换行符号‘\’进行换行。

text = f"""
Getting users for reports is easy. First start with the list of current \
users since many of those will be eligible to use the new reports. \
Put all of those names into a spreadsheet and organise them by \
their business unit then add a column which will allow them to select one \
of the eligible user groups that has been approved for these reports. If there \
are any business rules then add them as well in another column. Ensure that there \
are options in the column in addition to the approved user groups, for example \
you will need to include options for people who do not meet eligibility criteria \
(i.e. 'Other' and 'None'). Once you've set up the spreadsheet, \
lock any part of the spreadsheet that you don't want the users to edit. \
Make sure that everybody who needs to fill in the spreadsheet has access \
to it then circulate the spreadsheet and ask them to validate which user \
groups these people should be in. Also ask them to delete any names of people
who do not require access and ask them to add the names of new users who do \
require access.
"""

5 将输入传递给函数。

这里是您创建提示的位置。我重新使用了短课程中的示例,该示例旨在检查条件是否满足并确定输入文本是否包含说明。我决定保留模型无法检测到说明的选项,因为这会提醒我输入文本写得很差。

# code adapted from ChatGPT Prompt Engineering for Developers
prompt = f"""
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.\"


\"\"\"{text}\"\"\"
"""
response = get_completion(prompt)
print("Work instructions:")
print(response)

6 运行代码并查看输出。

我跑了几次,指令的长度和冗长程度有所不同。您可以选择最适合您团队的风格。删掉不需要访问权限的人的姓名,并添加需要访问权限的新用户的姓名。以下是输出结果:

工作指示: 步骤1 — 开始与当前用户列表,将所有这些名称放入电子表格中。 步骤2 — 按业务单位组织列表。 步骤3 — 添加一个列,用于新报告批准的符合条件的用户组。 步骤4 — 在另一列中添加任何业务规则。 步骤5 — 在列中包含选项,以供不符合资格标准的人选择(即“其他”和“无”)。 步骤6 — 锁定您不想用户编辑的电子表格的任何部分。 步骤7 — 确保所有需要填写该电子表格的人都可以访问它。 步骤8 — 传播电子表格,并要求用户验证这些人应属于哪些用户组。 步骤9 — 要求用户删除不需要访问权限的任何人的名称,并添加需要访问权限的新用户的名称。

怎么样:您的团队可以遵循这9个简单的步骤!

将其调整适用于ChatGPT

你如果不会编程,也可以将这个应用于 ChatGPT 网页界面。我将我的描述放入了三个引号中,然后在描述下面的同一个提示框中添加了这些说明。


"""
<YOUR DESCRIPTION>
"""

You have been 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.\"

这如何节省时间。

以下是的HTML结构的翻译: 对我来说,口头描述需要做的事情并将其转录比尝试在写作中将其分解为顺序任务更为快捷。这意味着我可以只讨论需要处理的事情,模型就会执行下一步。理想情况下,我会口头向团队简要介绍,他们将将这个高层次的指令转化为任务。但是,初级团队成员仍在学习如何进行这种分析。另外,当他们对此领域还不熟悉时,他们缺乏背景知识,可能会难以从上下文信息中提炼出任务。

我学到了什么

虽然我不会啰嗦,但我能看出我在我的简报中添加了很多上下文,并且我是一个明确的传达者,负责提供信息。我也能看出,同时吸收这些上下文并尝试提炼出需要采取的行动对听众来说是很困难的。将来,我将在简报之前准备这些逐步说明。然后我会在简报后与团队分享它们,以便他们可以询问澄清问题。

祝教学高效!

ChatGPT中文站
OpenAI image: “A smiling cat leaving the office at 5pm in the style of Picasso”

2023-10-20 17:01:06 AI中文站翻译自原文