In this doc you'll find pro-tips for how to write prompts that get AI systems like ChatGPT to ACTUALLY do what you want, instead of just sounding like ChatGPT.
If you're already familiar with this, fill in the worksheet to get a free evaluation of how your prompt engineering skills stack up to others, and join the mission to help us AI-Enable 1,000,000 people.
Prompts are the text input that you provide to AI systems that understand language and use it to generate responses or take actions.
An example prompt might be:
"Explain the importance of cultural diversity on team performance in the workplace"
Large language models like ChatGPT's GPT-4-turbo are extremely powerful, but not all knowing mind-readers.
If you don't specify a desired output format, length, personality, or have left out important context, then of course, the result is not going to hit any of those targets.
If you gave the same badly defined task to your smartest employee, they probably wouldn't do a good job either (but it would for sure take them longer and cost more).
Prompt engineering is the act of combining different parts of text to form a prompt that gets an AI system to do what you actually want it to do.
For example, you might combine:
Prompt engineering technique:
Ask for structured outputs (e.g. bullet points, JSON, etc)
Before specifying output format:
Explain the importance of cultural diversity on team performance in the workplace
After specifying output format:
Explain the importance of cultural diversity on team performance in the workplace.
Provide the key important points in bullet points, summarised in a sentence, and start each bullet with a key word that summarises that point.
Prompt engineering technique:
Ask for your output to be a specific length (how many pages, paragraphs, words, bullets, etc)
Before specifying output length:
Explain the importance of cultural diversity on team performance in the workplace
After specifying output length:
Explain the importance of cultural diversity on team performance in the workplace in two paragraphs, each between 200 and 400 words long.
Prompt engineering technique:
Use spacing, headings, bullet points, numbered lists, quotes, etc to make it clear to the AI system where each section begins and ends.
Before specifying output format:
Draft a proposal for this client: [Client information would be here]
After specifying output format:
PERSONA
You are an expert ESG consultant with 20 years in financial regulation…
BACKGROUND CONTEXT
Acme Corp is an expert provider in the following solutions…
TASK
When writing a proposal, include the following things:
Draft a proposal for this client:
"""
[Client information would be here]
"""
Pro-tip: You can add empty newlines in ChatGPT by pressing SHIFT + ENTER
If you're really looking to systemetise things, you might be writing code that makes requests to an AI language model, such as GPT-4-turbo (the model that powers ChatGPT as of writing).
For example, you might write code to:
And then combine this information into a complete prompt.
For example, if you were writing in Python, your code might look like this:
user = get_user()
prompt = f"""
You are an expert weather forecast host, that provides a daily weather report to a user based on their current location.
The current weather is:
{get_weather(user.location)}
The user's name is {user.name} and their bio contains the following information: {user.bio}.
The user's current location is: {user.location}.
Respond with valid JSON with the following keys:
- script: Exactly what will be said by the AI weather forecase presenter, which should be between 800 and 1000 words.
- title: An interesting title for the video based on location and weather conditions
For example:
{
"script": "Hello Chris and welcome to today's personalised weather report...",
"title": "Big waves and sunny skies - a great day for surfing!"
}
"""
response = get_ai_response(prompt)Note how this prompt makes use of several techniques described earlier (provide context, assign a persona, specify output formatting, specify output length, give examples).
It is interesting to think about how as the power of these AI systems increases and more can be done with prompts, code is becoming less and less of writing the actual algorithm logic, and more and more of pulling together a prompt that tells the AI system what to do, using it's own logic - that is, more and more prompt engineering.
Prompt Engineering