Prompt Engineering 101: How to Write Good Prompts

Updated: 
April 10, 2024

Table of contents

Filters

Do you want to get the best possible outputs from AI tools ChatGPT? The key is learning how to speak the ‘AI's language’ through prompt engineering.

In this guide, you'll learn the essentials of crafting prompts that AI can't help but give great responses to.

We'll cover what makes a prompt good or bad and show you proven formulas to get impressive output every time.

1. What is prompt engineering?

Prompt engineering is the practice of writing prompts that get the best possible results from AI tools like ChatGPT.

Prompt engineering is about learning how AI thinks differently from humans and using that to craft great prompts. 

Although it sounds technical, it’s actually quite straightforward. You don't need to be technical to be a great prompt engineer.

What is a prompt?

A prompt is a set of instructions or a question given to an AI model to guide its response. It can be a single sentence or a longer passage with multiple components.

The goal is to provide enough context and direction for the AI to generate a relevant, coherent, and useful output.

This is a prompt:

Example of a simple prompt which instruct ChatGPT "tell me a simple joke"

But this is also a prompt:

Example of an extensive prompt which instruct ChatGPT to do a meeting planning following a comprehensive prompt structure.

Everything that you ask or instruct an AI is considered a prompt.

Why is prompt engineering important?

Well-crafted prompts set the model up for success, while poor ones lead to confusion and unhelpful responses. That’s why it’s important to engineer your prompts and think them through.

Instructing an AI isn't as simple as just asking it questions like you would ask a human.

AI models interpret language very differently from humans.

For example, if you request a ‘very good blog post’ or a ‘great email’ it’s hard for an AI to know what that means.

Asking an excellent writer from your team for a blog post would be enough. Also because the writer has the context of your company such as your target audience and the tone of voice.

These are all the things an AI is lacking and that’s what needs to be included in your prompt. 

2. What makes a good prompt?

A good prompt is the one that provides you good output. This can be a short prompt or a more comprehensive one.

However, prompts that deliver good output often have a few things in common: 

A clear task

A good prompt should explicitly define the task you want the AI to perform and your intent behind it. Are you looking for an analysis, creative writing sample, tutorial, data summary? Spell it out directly.

For example:

Your task is to write a 300-word product description for a new smartwatch, highlighting its key features and benefits.

The reason you want to be clear and straightforward is to leave no room for ambiguity. 

Enough context and background

Effective prompts provide enough context and background around the topic for the AI to fully understand the requirements. Offer relevant details about the subject, audience, use case, and other crucial background info.

For instance:

We're developing a fitness app for busy professionals. Provide 3-5 sample workout routines under 30 minutes that can be done at home without equipment. The workouts should mix cardio and strength training.

With this context, the AI knows to tailor its outputs for at-home, time-constrained, no-equipment workouts suited for office workers.

Specify the structure and format

Guide the desired structure and format of the AI's response by stipulating things like:

  • Word count or length range
  • Whether to use paragraphs, bullet points, numbered lists etc
  • Particular tones, styles or personas to adopt.

For example:

Write an engaging 500-word blog post draft about the rise of remote work aimed at professionals. Use a friendly, conversational tone. Include an intro paragraph, 3 body sections with H2 subheadings, and a concise conclusion.

The more specific you are about your formatting preferences, the better the AI can meet your requirements.

Provide examples

One of the most powerful ways to demonstrate expectations is to provide examples that illustrate the type of output you're looking for. This can be examples you create, or existing content to use as templates.

For instance, if you want the AI to mimic a particular writing style or document structure, you could say:

Replicate the tone and formatting of this example case study: [insert example content]

With clear guiding examples, the AI has a reference point to align its responses to your needs.

While there's no one-size-fits-all formula, following principles like these will help ensure your prompts are specific, comprehensive and easy for AI models to correctly interpret. The more thoughtful care you put into prompt creation, the better results you'll get out of the AI.

3. Prompting Frameworks

After covering what makes an effective prompt, it's time to look at specific prompting frameworks you can use to structure your inputs. Prompting frameworks provide reusable templates for clearly instructing your requirements to AI models.

Two popular options are the JTF framework and the RISEN framework.

The Job-Task-Format (JTF) framework

The JTF framework categorizes prompts into defined roles, tasks, and output formats.

The JTF structure looks like this:

Act as a [ROLE]. Give me a [TASK] in [FORMAT] format.

For example:

Act as a veteran life coach with 30 years of experience. Give me a plan to improve my work-life balance in a table format.

In this case, the role defines the persona and expertise level for the AI to adopt. The task specifies the content you want it to produce, while the format conveys your desired output structure.

The JTF framework is a great option for all kinds of uses. Its simplicity makes it an easy, versatile option for many applications.

The RISEN Framework

RISEN is a great framework for complex and multi-step tasks. The acronym stands for:

  • R - Role
  • I - Instructions
  • S - Steps
  • E - End Goal
  • N - Narrowing Factors

RISEN helps break down complex, multi-step tasks. It covers the role for the AI, instructions, steps to follow, the desired goal, and any constraints. 

For example: 

  1. Role: You are an expert customer experience analyst skilled in qualitative data analysis.
  2. Task: Analyze a file of customer feedback submissions to identify key themes, pain points, and opportunities for improvement.
  3. Steps to Complete Task:
    1. Read through all customer feedback thoroughly to gain familiarity with the data.
    2. Code the feedback into categories and themes based on the types of comments.
    3. Determine which themes represent the most frequent issues, biggest areas of praise, etc.
    4. For major themes, dive deeper into the specifics of what customers are saying.
  4. Goal: Provide a summary report detailing the main themes and insights discovered in the customer feedback file. The report should clearly highlight areas that need addressing and suggest potential solutions.
  5. Constraints:
    • Only analyze the provided feedback file, no other data sources.
    • Summarize feedback succinctly while including enough context and representative quotes.
    • Limit the total report to 800 words maximum.

Both frameworks provide preset templates to reduce ambiguity. The structure ensures you cover all crucial pieces like the AI's role, task details, requested format, and more.

The key is experimenting to find the right prompting approach for your use case. Over time, you'll develop frameworks tailored to the AI models and tasks you use most.

4. Common errors and troubleshooting

Getting AI to give you what you want can be tricky. Even if you write prompts carefully, the AI might misunderstand your meaning.

Let's look at solving the most common prompting issues.

Doesn’t listen or give the right results

If the AI's answer doesn't match what you wanted, don't get upset. You may need to try a few times.

This can happen because:

  • Your prompt was unclear or confusing
  • You didn't give enough important details or rules
  • You left too much open for the AI to make incorrect guesses

You can troubleshoot and solve this in a few ways:

  1. Review and rewrite your prompt

Sometimes using vague wording or contradictions leads to bad results. Carefully review how you explained the task. Rewrite with specific details.

  1. Add examples showing the output you want. 

Sometimes it’s hard to phrase what the output should look like, an example will fix that. Provide an example of what you want the output to look like—this often solves the problem.

  1. Ask the AI for Clarification

One effective technique is asking the AI directly why its response didn't meet your needs. You can pose a question like:

"I asked you to [original prompt]. But your response [problems with the response]. Could you explain your approach and thought process here?"

The AI's explanation often reveals misunderstandings. With this insight, you can rephrase for better results or ask the AI to rephrase the prompt for you. 

  1. Start a new conversation

If revising prompts doesn't work, start a new chat. 

Previous context can negatively impact new prompts, especially if you never got the right results. A clean slate may improve results.

Inconsistent results 

Another issue is inconsistent output. The first message was great, then it gets worse over time.

For example, if you instruct the AI to write a specific way initially, it can forget those instructions as the conversation continues.

Solutions:

  1. Remind the AI of your initial instruction

Sometimes reminding the AI of original instructions helps. You can copy part of your initial prompt and say:

Stick to the writing style I instructed: [writing style]

  1. Start a new chat

The longer chats go, the harder it is for the AI to stay consistent. Starting a new chat can lead to better, more consistent results.

5. Conclusion

In this guide we covered the crucial role prompt engineering plays in communicating effectively with AI models like ChatGPT.

Some key takeaways to keep in mind:

  • Craft prompts thoughtfully using clear, direct language and instructions
  • Provide helpful context like your audience, desired output, and examples
  • Break complex tasks into step-by-step prompts

With these tips, you'll be able to get better results from AI that are more relevant and tailored to what you need. It takes some practice, but mastering this skill will help you unlock the full power of AI as a helpful tool.

No matter what kind of work you do - writing, analyzing data, coding, or anything else - learning how to prompt AI effectively will let you combine your own skills with artificial intelligence in creative and productive ways. So keep practicing and improving your prompts - the possibilities are endless!

Get a head-start by exploring our library of proven and expert-crafted prompts that you can directly copy and use in your work.

Details

Last updated: 

April 10, 2024

Category: 

AI & Prompting

Get smarter on AI

Subscribe to receive the latest blog posts to your inbox every week.

Thank you! Your submission has been received!
Oops! Something went wrong while submitting the form.
Learn every week what you can do with the latest AI, for free.
Thanks for subscribing to aiGators! Look out for our newsletter in your inbox every Tuesday morning.
Oops! Something went wrong while submitting the form.