Prompt Engineering

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.

What is a prompt?

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"

If you're getting poor results from AI systems, it is probably your fault.

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).

What is prompt engineering?

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:

  • Background information on what your company name, history, and what you do
  • A request that a user has made to your AI system
  • A description of the personality that you want the AI system's response to embody
  • Guidelines on what to include or exclude
  • Any many other things, some of which we will look at next

Prompt engineering techniques

Prompt engineering technique:

Ask for what you want: Specify output format

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 what you want: Specify output length

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:

Clearly structure your prompts

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:

  1. Motivation for why it makes sense for the client to work with us
  1. …


Draft a proposal for this client:

"""

[Client information would be here]

"""

Loading...

Pro-tip: You can add empty newlines in ChatGPT by pressing SHIFT + ENTER

Other prompt engineering techniques

  • Provide context
  • Demonstrate examples
  • Assign a persona

Prompt engineering checklist

  • Specify output format (e.g. paragraphs, bullets, JSON, etc)
  • Specify output length
  • Clearly structure your prompts using spacing, headings, bullet points, etc
  • Provide background context
  • Assign a persona
  • Demonstrate examples

Prompt engineering is useful for AI engineers, not just non-technical users

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:

  • Read user profile information from a database
  • Get information (like the current weather, latest news, or a form response)

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.

Made with