Prompt Engineering For ChatGPT

Learn the fundamentals of prompt engineering to make the most of ChatGPT!

Introduction

This project has been archived

We're no longer updating this project - we recommend checking out our active projects instead!

If you've already completed this project, don't worry! Your documentation is still available for you to check out and share.

If you have any questions, leave a question in our Discord and we'll get back to you ASAP!

⚡️ 30 second Summary

Welcome to this project on prompt engineering! 👋

Whether you're a seasoned developer, a curious marketer, or just wanting to ask a question, writing good prompts will help you get better results with AI models like ChatGPT.

Prompt engineering is also an important skill to learn for roles like AI Engineer, Data Scientist, or Machine Learning Engineer, where communicating with AI models is essential. But honestly, writing good prompts is useful for anyone working with AI!

In this project, get ready to...
  • Test foundational techniques, likes specifying roles and output formats.
  • Get ChatGPT to self-critique and chain prompts.
  • Get specific results with reverse engineering and frameworks.
  • Write a meta-prompt that automates prompt writing for you.
  • 💎 Write a prompt template as the Prompt Engineer for an AI app!

Want a complete demo of how to do this project, from start to finish? Check out our 🎬 walkthrough with Natasha 🎬

If you're up for a bit of a challenge, quiz yourself on the key concepts up ahead in this project.

Send Your First Prompt

Let's start this project by asking ChatGPT a simple question.

Enter the Basic Prompt

  • Log in to ChatGPT, or your preferred AI model (e.g. Claude, Gemini, Microsoft Copilot).
  • Start a new chat.
  • In the chat, enter the following prompt:
What should I do in a conference?

Note

P.S. If you prefer, you can work on this project using another topic e.g. a game, dish, hobby, country, book or career you want to know more about. It's helpful to choose something you're really interested in, so you can better evaluate the quality of your AI model's responses.

  • Take a note of ChatGPT's response. Ask yourself:
    • Is it clear and concise?
    • Does it address your needs?
    • Does it match your level of experience and understanding of the topic?
    • What would you improve about the scope, format, or tone?

Throughout the rest of this project, we'll ask ChatGPT the same question as our basic prompt, but level up our requests using different prompt engineering techniques.

What is prompt engineering, and why is it important?

Prompt engineering is about writing prompts that guide the AI to give you the most useful and precise answers.

It’s not simply about writing clever sentences to ChatGPT. When you interact with a tool that's "powered by AI," what’s happening behind the scenes often relies on a good prompt. Here's a step-by-step breakdown:

  1. The AI tool takes in what the user typed in a request, or the button they clicked. This helps them figure out what they want and what context is needed.
  2. The AI tool then passes your request through a specific prompt template written by a prompt engineer. The prompt tells the tool how to respond based on what the user needs.
  3. The AI tool gives a response based on the prompt. The tool adjusts it (like fixing the format or tone) to make sure it meets the user’s expectations and is easy to understand.

Here are some real-world examples of AI tools using prompt engineering...

  • AI coding assistants, like GitHub Copilot, rely on structured prompts to generate usable code snippets, debug code, or provide suggestions based on the programming language it detects.
  • AI chatbots, like Zendesk, use prompt engineering to create customized responses for customer interactions.
  • AI design tools, like Canva’s AI assistant, uses internal prompts to recommend templates, color schemes, and layouts tailored to that theme.

Use Basic Prompt Engineering Techniques

Now, let's apply a range of basic prompt engineering techniques.

These simple tips can drastically improve your AI model's response. Let's put them to the test 😎

In this step, you're going to:

  • Refine the prompt by adding a role and audience.
  • Specify the desired output format.
  • Encourage clarifying questions.
  • Use decomposition to break down complex prompts.
  • Observe the changes in the AI's response.

Adding Role and Audience Context

  • Start a new ChatGPT chat.
  • Enter the following prompt:
You are a seasoned tech conference speaker. Write a guide for aliens on how to attend their first tech conference.

What is a role, what is an audience?

A role is like a character that the AI plays.

An audience is who the AI is talking to.

The model tailors its word choices to match the knowledge level and interests of the audience you pick.

Nice work!

AI models write a response by predicting the most correct and relevant words related to the tokens (i.e. word choices) in your prompt.

By adding a role and audience, you're telling the AI model to look for conversations in a similar context. Now, your model is drawing from specific training data that it wouldn't have before, which helps it write more accurate and specific responses.

Encouraging Clarifying Questions

  • Start a new conversation with ChatGPT.
  • Let's get ChatGPT to ask us some questions before it generates a response.
You are a tech conference speaker. Before writing a guide for aliens attending their first tech conference, ask me any clarifying questions to better understand their needs.

Why are clarifying questions helpful in prompt engineering?

Clarifying questions gives the AI model the chance to narrow down the specific context and nuances of your query, which lets it decide on the right tokens to focus on.

Yup, you guessed it - this means you'll get more tailored and insightful responses.

This is useful in ambiguous scenarios, and your initial prompt might not give ChatGPT enough context for an accurate response (especially if you're not sure how to be more specific either).

Fun fact: Asking clarifying questions is a popular technique in AI models built for customer support, technical troubleshooting, and consulting. They're trained to ask for the specific needs and constraints of their user's situation, which makes a big difference in providing effective solutions.

  • Answer ChatGPT's questions, and feel free to give it just 2-3 word responses.
  • Notice how asking clarifying questions helps tailor the output more effectively!

Decomposition

  • Let's add another technique in the same chat.
  • Edit your message that responds to to ChatGPT's clarifying questions.
  • This time, add this to the end of your prompt:
# STEP BY STEP / DECONSTRUCTION
Divide the task into 3-5 smaller questions.

Each question should focus on a specific aspect of aliens navigating tech conferences.

What is this technique?

Decomposition is breaking down a complex question into smaller, easier-to-understand parts.

This is especially useful if you're using the free version of an AI model. Free models have lower limits around how many tokens and content it can process in each response. Once it hits its token limit, the model is more likely to 'crash' or stop in the middle of a response.

By decomposing your prompt, your model can be more efficient with the tokens it uses. Instead of trying to figure out what would be appropriate for a generic prompt, it can spread out the processing power (i.e. the effort to match the best words to respond to your tokens) on more specific requests.

  • Great! Now ChatGPT knows more about what you want.
  • ChatGPT responds with exploration questions that are relevant to your topic.

Specifying Output Format

  • Let's remind the model what we're here for. Respond to ChatGPT's decomposition, and give some instructions on the ideal output:
Write the guide for aliens attending their first tech conference. 

# OUTPUT FORMAT
- Format: Bulletpoint list, with points bucketed into 3 main categories.
- Length: 200 words.
- Tone: Informative and neutral. Pepper in some light-hearted comments.
- Language level: Jargon free and accessible to a general audience.
- Constraints: Focus only on strategies during the conference itself, not before or after.

Can you break down the output formats we're defining?

  • Format: Do you want ChatGPT's response as a list, step by step guide, Python code, recipe, conversation, or something else?
  • Length: How many words or bulletpoint items should the response have? How long should it take you to read the response?
  • Tone: How should the model convey the message - empathetic, confident, aggressive, sarcastic, professional or something else?
  • Language level: Should the AI model write to a fluent speaker, should it use any jargon?
  • Constraints: What topics can the AI model talk about? If the AI model doesn't have an answer, how should it respond?

Intermediate Prompting Techniques

Let's level up again and explore some intermediate prompt engineering techniques!

In this step, you're going to:

  • Experiment with prompt chaining.
  • Use the self-critique technique.

Prompt Chaining

What is prompt chaining?

Prompt chaining uses the output of one prompt as input for the next. This lets the AI model build on previous responses. This often generates a more detailed final response.

  • Let's try this in ChatGPT. Start a new conversation.
  • We'll give it a simple task first:
List the most common scenarios aliens could face at tech conferences.
  • Next, ask ChatGPT to follow-up with more insights:
Now, provide actionable advice to each of those scenarios.

Self-Critique

If you think ChatGPT always gives you the best answer straight way, you'll be surprised. AI models are great at identifing flaws or areas for improvement in their own responses.

Let's give it a go.

  • In the same conversation, respond to ChatGPT with instructions to self-critique.

Note

This is also a great chance to use some of the other techniques you've learnt... like specifying a role or specific output format!

You are an expert in alien behaviours and tech conferences.

Critique this guide for gaps, unclear steps, or inconsistencies. Evaluate whether the tone is appropriate for speaking with aliens.
  • As you might guess, once the AI model is done critiquing, you can ask it to revise its own work too:
Implement your suggested changes. 
Think step by step.

Extra for Experts

For best results, you should ask ChatGPT to implement the first change. Once the first change is done, ask to implement the second change; you'd repeat this until the last change is done.

This does mean a longer wait time before all the changes are done, but the higher accuracy is worth it for bigger projects!

Specialized Prompting Techniques

Imagine if you had a very specific end goal in mind - you know exactly what you want, and you want to give your AI model a precise set of instructions to get it done.

Let’s dive into two specialized techniques that are extra helpful when you’re working with clear objectives. It's not so much about exploring an unknown anymore - you just want your prompts to deliver precise, actionable results.

In this step, you're going to:

  • Apply reverse engineering to work backwards from the goal.
  • Use creative frameworks to shape outputs effectively.

Reverse Engineering Prompts

Reverse engineering starts with the goal output in mind.

  • Start a new conversation with ChatGPT.
  • Give your AI model an example of something that covers the same content, and is exactly in the format and style as your ideal response.
  • Here's an example desired output you could use:

How to Blend in at a Tech Conference (Alien Edition)

1️⃣ Choose Your Disguise: Business casual. Hoodies with startup logos are ideal. Bonus points for wearing ALL the free conference swag.

2️⃣ Learn the Lingo: Say “synergy,” “disruptive,” and “the cloud” at random. Nods are optional but encouraged.

3️⃣ Fake Coffee Obsession: Hold a latte and mutter “Is this oat milk?” even if you don’t know what oats are.

4️⃣ Awkward Networking: Stand in a group, nod, laugh too loudly, then silently exit.

5️⃣ Ask Insightful Questions: “How does this scale with AI?” works for any topic.

6️⃣ Avoid Detection: Do NOT charge your spaceship at the EV station.

Good luck, Earthling!

✋ Before you enter the prompt

For most people, this is where they ask the AI model to read it and generate a similar output straight away.

For example, you might say "Read this example, then write a similar guide with the same tone and language but on xyz topic instead."

Instead, the reverse engineering technique actually asks the AI model to write a prompt that would generate the model response.

  • In the same ChatGPT conversation, add the following line to the start of your prompt:
You are a prompt engineer. What prompt would you give an AI model to generate this output?
  • Submit your completed prompt.
  • Awesome work! In response, ChatGPT gives you a prompt that you can now use as a template for something else.
  • This is a great chance to try another technique you've just learnt. Respond to ChatGPT with the following:
As a prompt engineering expert, critique the quality of the prompt compared to the model output I've given you.
  • Amazing! This should help you get a revised, improved prompt.
  • Enter the prompt in a new chat window. See if it actually generates a similar output, and don't hesitate to give ChatGPT some feedback!

To recap: What is reverse engineering in prompt crafting?

Reverse engineering is a technique where you start with a specific output you want and work backwards to design a prompt that produces it.

Creative Framework Prompts

Creative frameworks are a great option if you want ChatGPT's response to be structured a specific way.

What are some popular frameworks?

Problem-Solution-Benefit: Address a challenge, propose a solution, and highlight the benefits.

  • Example: "Use the Problem-Solution-Benefit framework to guide aliens struggling with human social norms at tech conferences."

Before-After-Bridge: Describe the current state, the improved state, and the steps to achieve it.

  • Example: "Explain how aliens can transition from clueless attendees to confident tech conference participants using the Before-After-Bridge framework."

STAR Framework (Situation-Task-Action-Result): A storytelling structure to describe processes or accomplishments.

  • Example: "Using the STAR framework, describe how aliens can prepare for and succeed in a tech conference networking session."

AIDA Framework (Attention-Interest-Desire-Action): A classic marketing framework to persuade customers.

  • Example: "Use the AIDA framework to create a persuasive guide for aliens convincing humans to collaborate at a tech conference."

SCQA Framework (Situation-Complication-Question-Answer): A framework for describing complex problems and their solutions.

  • Example: "Use the SCQA framework to explain how aliens can overcome cultural misunderstandings at a tech conference."

Five W’s and One H (Who, What, When, Where, Why, How): A straightforward framework for exploring a topic comprehensively.

  • Example: "Explain how aliens can confidently interact at a tech conference using the Five W’s and One H framework."
  • Start a new chat with ChatGPT.
  • Select a framework and apply it to a new prompt.

Recap: What are creative frameworks?

Creative frameworks are structured approaches (e.g., Problem-Solution-Benefit, Before-After-Bridge) that help organize content effectively. You can think of them as templates for presenting ideas clearly and logically.

Building a Meta-Prompt

Let's take prompt engineering to a final level. We'll generate a meta-prompt – a prompt that generates other prompts!

In this step, you're going to:

  • Create and test a meta-prompt.

Creating a Meta-Prompt

  • Start a new chat with ChatGPT.
  • Tell ChatGPT to become your personal prompt generator. Provide guidelines based on the techniques you've learnt today, like:
    • Defining a role and audience.
    • Structuring outputs in a specific format, tone and style.
    • Asking clarifying questions before generating a prompt.
    • Using decomposition to break down complex prompts.
    • Experiment with prompt chaining.
    • Using the self-critique technique.
    • Applying reverse engineering to work backwards from the goal.
    • Suggesting frameworks that are most suited to answer the question.
  • An example of a meta-prompt could be:
You are a highly skilled AI assistant specializing in crafting prompts for complex scenarios.

Follow these best practices whenever I give you a topic to ensure precision, clarity, and audience alignment:

# Clarify and refine:

-  Before generating an answer, ask clarifying questions. Focus on gathering missing details or narrowing the scope of the request.
- If the request is ambiguous, provide two or three interpretations and ask the user to confirm.
- Highlight assumptions or unknowns for further exploration.

# Define your role and audience:

-  Assign yourself a specific role (e.g., teacher, expert, storyteller) tailored to the scenario.
- Ask me to specify the audience, tone, and level of detail to match their needs.

# Structure and format:

-  Organize responses with clear formatting (e.g., bullet points, tables, numbered lists).
- Suggest frameworks like Problem-Solution-Benefit, STAR, or Before-After-Bridge for clarity and purpose.
- Adjust the level of detail based on the urgency or simplicity of the task.
- For technical or domain-specific prompts, ensure terminology aligns with the audience's expertise level.
- For time-sensitive scenarios, focus on providing quick, actionable suggestions.

# Decomposition:

-  Break down broad or complex prompts into smaller, manageable parts to ensure completeness.
- Provide step-by-step explanations where applicable, ensuring clarity and logic.

# Prompt chaining:

-  Propose follow-up prompts to refine or expand ideas.
- Ensure that outputs from one step naturally guide the next.
- Iterate prompts and refine responses until the output aligns with expectations.

# Self-critique:

-  After completing a response, evaluate it against these criteria:
1. Does it align with the prompt’s intent?
2. Is the tone appropriate for the audience?
3. Are there any areas of ambiguity or missing detail?

# Reverse engineering:

-  If applicable, begin by identifying the ideal output. 
- Then, design a prompt that effectively guides the AI model towards that result.

# Extra: Engage with examples:

-  Whenever possible, provide example prompts and outputs to illustrate your recommendations.
- Use a mix of simple and advanced examples to demonstrate flexibility.
- Show variations for different audiences or tones.

By following these steps, make sure every prompt you create is clear, precise, and audience-aligned.

Testing Your Meta-Prompt

  • Test your meta-prompt with a simple topic.
I want to write a prompt for navigating a tech conference.
  • Observe how the AI asks you clarifying questions, then generates a prompt based on your instructions.
  • Hmmm... did the generated prompt follow everything in your meta-prompt?

I did notice that ChatGPT didn't fully follow my meta-prompt!

AI models like ChatGPT are designed to balance multiple instructions. But, when a prompt includes too many techniques or tasks at once, the model might struggle to address everything effectively. This happens because:

  1. The model’s processing capacity is limited, so it can only focus on the most relevant parts of your prompt.
  2. If the instructions are too complex or lengthy, the model might skip or simplify parts to stay within token limits (there is a limit to how many words your AI model can take from you and then generate out).

To get the best results, you'd usually:

  1. Include just 1-2 techniques in your initial prompt to keep it focused.
  2. Once the AI responds, give feedback and add another 1-2 techniques. This step-by-step approach helps the AI address each part more effectively.

Recap: What is a meta-prompt?

A meta-prompt is a prompt that generates other prompts. It's a way to automate the prompt creation process, which saves you time and make sure your prompts use the best practices we've learnt today!

Secret mission

Welcome to your 🤫 exclusive 🤫 secret mission!

Your mission, should you choose to accept it, is to act as the Prompt Engineer on a project developing an AI chatbot for customer support.

In this secret mission, you're going to:

  • Roleplay with ChatGPT, who's going to act as a customer support manager.
  • Gather requirements from ChatGPT to write an initial prompt template for the chatbot.
  • Refine your prompt based on feedback from the customer support manager.
  • Showcase advanced prompt engineering skills in your documenation!

Design a Prompt for an AI App

Final reflections

Final reflections

Tip

You can delete or rename any of the conversations you've had with ChatGPT today. This is great for keeping your conversations organized!

That's a wrap!

That's a wrap!

Well done on completing this project on prompt engineering!

You've just learned how to:

  • Use role and audience to add context.
  • Use desired output format to structure responses clearly.
  • Use clarifying questions to sharpen your response's focus.
  • Use decomposition to simplify complex prompts.
  • Use prompt chaining to build responses step-by-step.
  • Use self-critique to get support on improving the response.
  • Use reverse engineering to work backwards from a specific goal.
  • Use creative frameworks to structure responses effectively.
  • Create and test a meta-prompt to automate the prompt writing process.
  • 💎 Gather requirements to write a prompt template.

p.s. Does it say "Still tasks to complete!" at the bottom of the screen?

This means you still have screenshots left to upload, or questions left to answer!

  1. Press Ctrl+F (Windows) or Command+F (Mac) on your keyboard.
  2. Search for the text Return to later.
  3. Jump straight to your incomplete tasks!
  4. 🙋‍♀️ Still stuck? Ask the community!