Ultimate Guide to AI Prompt Engineering That Easy to Follow

What do you get when you cross an AI language model with a human? A prompt engineering, of course!

Prompt engineers are the wizards behind the curtain, using their magic to make AI language models do amazing things. They excel at text creation, language translation (human and code), creative content writing, and answering questions.

But what is AI prompt engineering?
Why is it important?
And what are the best practices for becoming a prompt engineer?

Let’s discuss.

What Is Prompt Engineering?

Prompt engineering is the process of designing prompts that help large language models (LLMs) generate text, translate languages, write different kinds of creative content, and answer your questions in an informative way.

Prompts are essentially instructions that tell the LLM what to do. They can be as simple as a single word or as complex as a paragraph of text.

For example, if you want to know the weather, you could try an AI chatbot like Google Bard and then ask it a question with a suitable prompt. 

Example Prompt: Hi, what is the weather today in Yokohama, Japan?

We asked Google Bard "what is the weather today in Yokohama, Japan?"

How To Construct an Effective AI Prompt

One of the best ways to understand how to create an effective AI prompt is to look at the difference between a well-constructed prompt and a poorly constructed prompt via useful prompt engineering examples.

Well-Constructed Prompt

A well-constructed AI prompt is one that is clear, concise, and specific. It should provide the language model with all the information it needs to generate a high-quality response.

Here are some examples of well-constructed AI prompts:

  • Write a poem about a lost love.
  • Write a short story about a robot who falls in love with a human.
  • Translate this sentence from English to Spanish.
  • Write a code that prints the numbers from 1 to 10.

Poorly Constructed Prompt

A poorly constructed AI prompt, on the other hand, is vague, ambiguous, or incomplete. It may not provide the language model with enough information to generate a response, or it may lead the language model to generate a response that is not relevant to the prompt.

Here are some examples of poorly constructed AI prompts:

  • Write something.
  • Tell me a story.
  • Translate this.
  • Write a program.

These may not provide the language model with enough information to generate a response, or they may lead the language model to generate a response that is not relevant to the prompt. 

A great example highlighting the difference between a well-constructed prompt and a poorly constructed prompt can be seen when using any of the best AI tools for image generators, like MidJourneyDall-E2, and Stable Diffusion. 

Look at the illustrations produced by Dall-E2 when using the following prompt.

Example Prompt: An image of a dog

We used the AI prompt "an image of a dog" in Dall-E2

They look pretty basic, right? Now, let’s upgrade the prompt.

Example Prompt: An photorealistic image of a smiling cute corgi, wearing a blue jumper, full body angle, situated by an open window, through which gentle daylight is streaming, natural light on the scene

We used prompt engineering to get a better result in Dall-E2

Now isn’t he a lot cuter and happier?

Best Practices for AI Prompt Engineering

Creating effective prompts for AI chatbots can be quite nuanced, but that said, here are some key tips and examples.

1. Make Your AI Prompts Specific

Ensure your instructions are detailed and specific about the task you want the model to perform. The more descriptive the prompt, the better the results. 

For instance, if you want the AI to extract only the animals from a text, your prompt could be:

Example Prompt: Extract the names of animals from the following text.

Desired format:
Animal: <comma_separated_list_of_places>
Input: XXX

Screenshot of how to use prompt engineering for AI

Be mindful of the prompt’s length and avoid unnecessary details. Experimentation and iteration are key to optimizing prompts.

2. Make Your AI Prompts Precise

Being too clever or vague can lead to imprecise responses. Be direct and clear in your communication with AI. For instance, if you want a concise explanation of artificial general intelligence (AGI), do not feed it with a prompt like this:

Example Prompt: Explain to me what AGI is. Make it short and simple.

You need to be clearer about how many sentences and in what style you want the response. For example, take a look at this improved prompt.

Example Prompt: In 2 to 3 sentences, explain the concept of AGI to a high school student.

3. Avoid Prompts That Ask What Not to Do

Rather than instructing the model what not to do, specify what it should do. This encourages specificity and leads to more accurate responses.

For example, avoid this kind of prompt.

Example Prompt: This is an AI agent that recommends TV series to a customer. Do not ask about customer interests. Do not ask for personal information.

Customer: Please recommend a movie based on my interests.

Agent:

Instead, rephrase the prompt to something like this.

Example Prompt: The following is an AI agent that recommends TV series to a customer. The AI agent should recommend a TV series from IMDB. It should refrain from asking users for their interests and do not ask for personal information. If the agent doesn’t have a TV series to recommend, it should respond with “Sorry…”. 

Customer: Please recommend a movie based on my interests.

Agent: Sorry…

Applications and Use Cases for Prompt Engineering

Prompt engineering can be used for a variety of applications and uses. Let’s take a look at some interesting examples.

  • Generating creative content, such as poems, stories, and scripts
  • Translating languages
  • Answering questions
  • Writing different kinds of content, such as blog posts, articles, and reports
  • Generating code
  • Solving math problems
  • Creating art or images
  • Generating new ideas

Prompt Engineering for Developers

If you’re a developer that wants to dive deeper into AI and prompt engineering, we’d recommend this free prompt engineering course from DeepLearning.AI — sidebar, Stanford professor Andrew Ng also happens to be the founder.

OpenAI Course photo introducing the instructors

Based on our research, this course is great for learning how to use a large language model (LLM) to quickly create new and powerful applications and the best practices for creating effective prompts when interacting with AI chatbots.

If you want to take your prompt engineering skills to the next level, we highly suggest watching this course while it’s still free.

Final Thoughts

Prompt engineering is a powerful tool that can be used to unleash the full potential of LLMs. By following the best practices outlined in this article, you can create AI prompts that will help you achieve your desired results.

The key to being an effective prompt engineer isn’t so much about knowing the perfect prompt, it’s about having a good process to develop prompts that are effective for your application. — Andrew Ng

I hope you found this article helpful. Feel free to share any other ideas and best practices for better prompt engineering that you know about.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.