How to write work instructions with prompt engineering

fiona neilson onfidan
6 min readJun 17, 2023

--

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

Once you’ve got over the excitement of asking ChatGPT about the biggest threats to Western democracy and whether singularity is here, you can use it to practical advantage.

I am always time-pressed and right now, I need to explain tasks to new, junior team members who don’t have a lot of experience in the project or in their roles. Some of them also have English as a second or third language, so it’s important I help them break down work into discrete steps in the form of work instructions. Here is where Large Language Models can help.

What code I use

I repurposed code from the DeepLearning.AI ChatGPT Prompt Engineering for Developers short course to break down my overiew of a process into work instructions. I used the Guidelines chapter, which explains the prompting principle of writing clear and specific instructions.

This activity uses OpenAI’s gpt-3.5-turbo instruction-tuned LLM and the chat completions endpoint with the Python openai library. You need an OpenAI API key which is a pay-for-use service. As I show at the end, you can also use this directly in the ChatGPT web interface. Be mindful what information you share with the web interface.

The prompt engineering task checks whether a text can be broken into steps or not. For example if the text describes how to make a cup of coffee, the output will be a series of steps, but if the text is a narrative like the story of Jack and Jill, then the model will recognise that this text does not lend itself to being turned into instructions. I took the code and used it to turn my description of a process into step-by-step instructions.

Here’s how it works in Google Colab

1 Install packages, open and check the API connection

!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 Create the prompt function

This is the helper function from the DeepLearning.AI course which they designed to make it easier to use prompts.

# 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 Create the text that describes the process

The tips from the course are to provide a clear prompt by providing explicit instructions; the longer the better as it helps give context to the model. You can experiment and adjust the length of the input text once you see what length of steps it generates. I use Google Doc’s voice transcription to capture my description (Tools > Voice typing). You can see the transcribed text in the next step.

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

4 Provide the text input

The short course introduces the tactic of using delimiters to indicate distinct parts of the input. I use quotation marks but delimiters can be anything like: ```, “““, or < >. Use the newline symbol ‘\’ for line breaks.

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 Pass the input to the function

Here’s where you craft your prompt. I repurposed the example from the short course, which is designed to check whether conditions are satisfied and identify whether an input text contains instructions or not. I decided to leave in the option of the model not being able to detect instructions, as this would alert me to a poorly written input text.

# 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 Run the code and review the output

I ran this a few times and it varied the length and verbosity of the instructions. You can select the style that works best for your team. Here is the output:

Work instructions:
Step 1 — Start with the list of current users and put all of those names into a spreadsheet.
Step 2 — Organise the list by business unit.
Step 3 — Add a column for eligible user groups approved for the new reports.
Step 4 — Add any business rules in another column.
Step 5 — Include options in the column for people who do not meet eligibility criteria (i.e. ‘Other’ and ‘None’).
Step 6 — Lock any part of the spreadsheet that you don’t want the users to edit.
Step 7 — Ensure that everybody who needs to fill in the spreadsheet has access to it.
Step 8 — Circulate the spreadsheet and ask users to validate which user groups these people should be in.
Step 9 — Ask users to delete any names of people who do not require access and add the names of new users who do require access.

How about that: 9 easy steps for your team to follow!

Adapting this for ChatGPT

You can adapt this for use with the ChatGPT web interface if you don’t know how to code. I put my description into triple quotes and then I added these instructions in the same prompt box below the description:


"""
<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.\"

How this saves time

It’s quicker for me to describe what needs doing verbally and have this transcribed than to try and break it into sequential tasks as I write. It means I can just talk about what needs doing, and the model will do the next step. Ideally I will brief a team verbally and they will take this high level instruction and turn it into tasks. However, junior team members are still learning how to do this type of analysis. Added to that, when they are new to the domain, they lack context and can struggle to distill tasks from the contextual information.

What I learned

Whilst I don’t waffle, I can see that I add a lot of context to my briefings and that I am an explicit communicator who takes responsibility for providing information. I can also see that absorbing this context and trying to distill actions to take all at the same time, is a lot for the listener. In future, I will prepare these step-by-step instructions before the briefing. Then I will share them with the team after my briefing, so they can ask clarifying questions.

Here’s to efficient instructing!

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

--

--

fiona neilson onfidan

Newly minted data scientist | Passionate about using technology and analytics for social good