What Is Prompt Engineering? Definition and Examples

Written by Coursera Staff • Updated on

Prompt engineering is the process of iterating a generative AI prompt to improve its accuracy and effectiveness. Learn all about prompt engineering and how it works.

[Featured Image] A man works at a desk on a laptop computer.

Picture this: You’re baking a chocolate cake for your friend’s birthday. You could use a boxed cake mix and just add oil, eggs, and milk. Or you could make the cake from scratch, gathering the bespoke ingredients to create a custom cake that reflects your friend’s preferences.

What if you added espresso powder or sea salt? Replaced cow’s milk with coconut milk? Topped it with fresh raspberries? 

This is how prompt engineering works–by taking a simple prompt and continuing to adjust it for an AI generator, you’ll receive results that better suit your needs. You’re engineering your request to create a specific output.

Whether you’re inputting prompts in ChatGPT to help you write your resume or using DALL-E to generate a photo for a presentation, anybody can be a prompt engineer. Read on to learn all about prompt engineering and how you can improve your prompts to optimize for accuracy and effectiveness.

What is prompt engineering?

Prompt engineering is the process of refining prompts that a person can input into a generative artificial intelligence (AI) service to create text or images. Anyone can do this using natural language in generators like ChatGPT or DALL-E. It's also a technique that AI engineers use when refining large language models (LLMs) with specific or recommended prompts. 

For example, if you're using ChatGPT to brainstorm a professional summary while refining your resume, you might write a command like, “Write a sample professional summary for a marketing analyst.” You might prompt ChatGPT’s response with feedback like “too formal” or “shorten to less than 100 words.” You can do the same for text-to-image models like DALL-E.

Why is it important in generative AI?

Prompt engineering is important for AI engineers to create better services, such as chatbots that can handle complex tasks like customer service or generate legal contracts. Making sure that generative AI services like ChatGPT are able to deliver outputs requires engineers to build code and train the AI on extensive and accurate data.

We’ve reached a point in our big data-driven world where training AI models can help deliver solutions much more efficiently without manually sorting through large amounts of data. Proper prompt engineering can also identify and mitigate prompt injection attacks (malicious attempts to hack the logic behind ChatGPT or chatbots) to ensure companies deliver consistent and accurate services.

Prompt engineering examples

Here are a few examples of prompt engineering to give you a better understanding of what it is and how you might engineer a prompt with a text and image model.

  • For text models like ChatGPT:

    • What’s the difference between a professional summary and an executive summary?

    • Write a professional summary for a marketing analyst looking for a marketing manager job.

    • Now trim it down to less than 60 words.

    • Rewrite it with a less formal tone.

  • For image models like DALL-E: 

    • A painting of a cat.

    • A painting of a cat chasing a mouse in Impressionist style.

    • Now use only warm tones in the painting.

How to engineer generative AI prompts

Here’s a quick step-by-step guide to engineering your prompts.

1. Express your query as clearly as possible.

Because generative AI is a deep learning model trained on data produced by humans and machines, it doesn’t have the capability to sift through what you’re communicating to understand what you’re actually saying. 

What you say is what you get.

When inputting a query into an AI generator, it’s best to query with specific, plain language and no unnecessary fillers. For example, instead of, “Write an outline that includes a title and next steps,” you could query, “Write an outline for an academic research proposal that includes sections for title, summary, and next steps.” 

2. Experiment to come up with best practices.

For each type of output, such as a brief outline, research proposal, or resume bullet points, you’ll want to experiment with the generative AI by using different variations of the same request. This way, you’ll determine whether you need to include guidance such as “in a formal tone of voice.” If you do need to include “tone” in your prompt, should you write “in a professional tone” or “in a formal tone”? 

Play with your inputs, too. Consider inputting sample outlines in a prompt or providing examples you’d like the generator to model.

3. Follow up with instructions or questions.

Once you’ve shaped your output into the right format and tone, you might want to limit the number of words or characters. Or, you might want to create two separate versions of the outline, one for internal purposes.

The generator can do this based on the output it provided earlier. Iteration is your friend. Continue to “engineer” the prompt until you achieve your desired results.

4. Play with different prompting techniques

Generative AI is still a new (and developing) technology, but that doesn't mean researchers haven't already developed some strategies for designing effective prompts. As you play with generative AI, try using some of these prompting techniques to achieve the results you're looking for:

  • Zero-shot prompting: This is the most direct and simplest method of prompt engineering in which a generative AI is simply given direct instruction or asked a question without being provided additional information. This is best used for relatively simple tasks rather than complex ones.

  • Few-shot prompting: This method involves supplying the generative AI with some examples to help guide its output. This method is more suitable for complex tasks than zero-shot prompting.

  • Chain-of-thought (CoT) prompting: This method helps improve an LLM's output by breaking down complex reasoning into intermediate steps, which can help the model produce more accurate results.

  • Prompt chaining: The prompter splits a complex task into smaller (and easier) subtasks, then uses the generative AI's outputs to accomplish the overarching task. This method can improve reliability and consistency for some of the most complicated t


These are just some of the prompting techniques that you might play with as you continue to explore prompt engineering. Often, in fact, the most effective prompt strategy is to combine several different techniques to achieve the desired output.

Learn how to prompt engineer a quiz

Check out this guided project to generate exam questions for a multiple-choice quiz. You’ll gain this skill in two hours or less.


The future of prompt engineering

Prompt engineering will continue to evolve in this era of AI and machine learning. Soon, there will be prompts that allow us to combine text, code, and images all in one. Engineers and researchers are also generating adaptive prompts that adjust according to the context. Of course, as AI ethics evolve, there will likely be prompts that ensure fairness and transparency.

Prompt engineer career path and job outlook

As far as a career in prompt engineering goes, it has a promising future. There are currently over 3,788 prompt engineer jobs open on Indeed, and jobs can pay up to $335k, according to TIME [1, 2]. 

Prompt engineers need to be skilled in the fundamentals of natural language processing (NLP), including libraries and frameworks, Python programming language, generative AI models, and contribute to open-source projects.

Most commonly, prompt engineers need a bachelor’s degree in computer science or a related field. However, there are some prompt engineers who have a less technical background, such as in writing, and gained experience by studying and experimenting with AI.

Learn prompt engineering with Vanderbilt

Take this Prompt Engineering for ChatGPT course from Vanderbilt University and learn the basics of prompt engineering in 18 hours or less. You’ll learn how to apply prompt engineering to work with large language models like ChatGPT and how to create prompt-based applications for your daily life.

Article sources


Indeed. “Prompt engineer, https://www.indeed.com/q-prompt-engineer-jobs.html?vjk=97f8ac1d0bbcb5df.” Accessed February 21, 2024.

Keep reading

Updated on
Written by:

Editorial Team

Coursera’s editorial team is comprised of highly experienced professional editors, writers, and fact...

This content has been made available for informational purposes only. Learners are advised to conduct additional research to ensure that courses and other credentials pursued meet their personal, professional, and financial goals.