Artificial Intelligence

How to make an AI give you exactly what you want

Summary

Learn about prompt engineering to be able to properly communicate with an AI and receive the desired results

Image by rawpixel.com on Freepik: <a href=”https://fr.freepik.com/photos-gratuite/poignee-main-robot-main-affaires-transformation-numerique-intelligence-artificielle_18463036.htm#query=Human-AI%20interaction&position=19&from_view=search&track=ais">Image de rawpixel.com</a> sur Freepik

Introduction

We are currently in the AI revolution. Since the release of OpenAI’s ChatGPT in November 2022, dozens of new AI technologies came and continue coming. We use these technologies for any kind of task: answering questions, programming, performing calculations, translating, generating images, making videos, recognizing speech, text querying, fraud detection, analyzing sentiments, receiving recommendations, analyzing data, document summarization, email filtering, composing music, managing e-commerce businesses, and many more.

These AI technologies are really easy to use because they work with prompts. Everyone knows how to ask questions and give orders right? You tell the AI what you want, and the AI returns a response. But the problem is that sometimes the AI isn’t giving you exactly what you want. Yes, AIs make mistakes sometimes, but a lot of times, humans are the ones who are making the wrong prompt. It’s really important in our days to understand AI’s behavior. Once we do this, the AI is gonna become a much more powerful tool.

Note: Most of these techniques apply to chatbots, like ChatGPT, some of them may work with other AIs like Midjourney but not all of them.

What is prompt engineering?

Prompt engineering refers to the deliberate and strategic crafting of prompts or instructions provided to an artificial intelligence (AI) system to shape its behavior and output. It involves refining and optimizing the input given to an AI model to elicit desired responses or outcomes. It is the skill of giving the AI the right instructions and asking the right questions to receive the best response possible.

It’s like a teacher who must give complicated homework to his students. If the teacher explains briefly and then asks his students to do it, they are gonna do it, but probably by making a lot of errors. Well, it’s the same thing with AI. If you don’t design your prompt to be as explicit as possible, the AI is gonna give you a poor response and will potentially make some errors.

Prompt engineering is a set of techniques that are meant to create a scenario where the AI fully understands the user’s requirements and then gives him what he wants. It’s really important to acquire this skill in our constantly evolving world.

Everyone can learn it

Prompt engineering is very easy to learn. It sounds like a very complicated subject for which you need a Harvard degree but it isn’t. Everyone can learn it. It doesn’t require programming, data science, engineering, or any other hardly achievable skills. You need just a basic level of English, nothing else. You will need to understand the techniques I will show you and apply them. That’s it, the rest is just practice. Let’s start exploring the techniques.

Defining the AI’s personality

Before asking your question or giving an instruction, consider giving a personality to the AI. Giving a personality means making someone act like someone else. The task that the AI must solve defines the personality or behavior that the AI must have.

If you must perform a complex math calculation, you will ask the AI to act like a mathematician, if you are building a website, you will ask the AI to act like a website developer and an HTML professional, if you search for a marketing advice, you will ask him to act like a marketing expert, and so on. Give the AI the behavior of a professional in the subject figuring in your prompt. By doing this, the AI’s response is gonna be much more precise, accurate, and reliable.

The response will be always better if the AI is focused on answering questions about a specific subject. Asking the AI to perform a task without specifying the behavior is like asking someone who has little knowledge about many subjects to perform that same task. Giving the right behavior for the task is like asking a person who knows a lot about this specific subject, but a little about the other subjects. You don’t care about the other subjects, you care about the one you are dealing with currently, so option two is best.

Example:

Prompt:

Image by author

Response from ChatGPT:

Content generated by ChatGPT

Clear instructions and syntax

An AI is like a human, the more the instructions are clear and comprehensible, the more chance of receiving the response you wanted. AIs can understand prompts, but they cannot enter your mind and read your thoughts (at least for the moment), that’s why you must give precise and clear instructions.

The order in which the information is presented in the input matters. It is better to start with the main instruction (what you want the AI to do) and then continue with the details. By doing this, the AI will get the main idea, and then complete the response with the details. Always start with the main instruction, and then the details, not the opposite.

Syntax plays an important role too. Consider using the right punctuation but also separators, paragraphs, section markers, headings, and capital letters. A good presentation of the input can lead to a better understanding of the task that the AI must accomplish and eventually to a better-presented output.

Example:

Prompt:

Image by author

Response from ChatGPT:

Content generated by ChatGPT

Breaking the task down

If the task is complex and long, a good solution is to break it down, to divide it into multiple smaller parts. This will result in a better understanding of the task by the AI and maybe a better presentation.

Sometimes when given a multi-step task without separating the steps, the AI is confused and doesn’t give a complete response. It does only half of the job by taking in count only the main instruction and ignoring the rest. The solution is to specify that he must solve the problem step by step.

You can do this easily with the proper syntax. You can either use the “first, then, finally” technique or separate the steps with separators or other signs of punctuation to make the steps visible and easy to understand. You can use paragraphs as well.

Example:

Prompt:

Image by author

Response from ChatGPT:

Content generated by ChatGPT

Specifying the output structure

Just like the AI needs a well-designed and presented prompt, you need a well-presented response. If the task is to write a review, explain a quote, re-write a text, or write an essay, you generally don’t need to specify the output structure (of course it depends on what you want to accomplish). But if you must perform text summarization, data management, math calculations, or other complex stuff, you must specify an output structure.

The output structure refers to how the response is ordered and classified/presented. You can ask the AI to create a table, to order by paragraphs, to separate all sentences, to give the response in the form of an e-mail, and much more. Sometimes, the response can be really hard to read because it’s long or complex. By specifying the output structure of your choice, you can very easily navigate and extract valuable information from the response.

Example:

Prompt:

Image by author

Response from ChatGPT:

Content generated by ChatGPT

Defining your personality

The first technique I’ve shown you was to give the AI a personality in order to focus the knowledge on one subject to receive a better result. This step consists of making the same thing but with yourself. You can not only make the AI pretend to be someone else, but you can ask the AI to give you a response based on the personality you chose for yourself.

If you must analyze a very complex and long poem, you can ask the AI to explain it to you as if you were a 12-year-old child. If you have trouble understanding a particular math problem, you can ask the AI to explain to you as if you were a person who has a really low level in mathematics and needs additional help, etc.

This technique is generally used to better understand what the AI is saying. By telling him that you are a 12-year-old child who doesn’t know a lot about the specified subject, the AI is gonna be more explicit and will probably use more simple terms. You can use this technique to skip annoying details too. If you are really skilled in the specified subject, you can tell the AI that you are already in touch with the basics of what he’s gonna say and that he doesn’t need to explain everything. You can save your time with this.

Example:

Prompt:

Image by author

Response from ChatGPT:

Content generated by ChatGPT

Bad prompts VS Engineered prompts

Before concluding this article, I’m gonna show you some examples of bad prompts which lead to minimum results, and good prompts or engineered prompts which lead to much better results. Before showing the prompts and their responses, I will explain to you what I want the AI to do.

Example 1: The math equation

Here the situation is simple. I have a math equation that I must solve but I don’t know how.

Bad prompt:

Image by author

Response:

Content generated by ChatGPT

It gives me the solution with a short explanation but it isn’t ordered and you can get confused.

Engineered prompt:

Image by author

Response from ChatGPT:

Content generated by ChatGPT

You now see that the AI is giving me a much better response. The output is like I requested, it’s separated by steps each one having its explanation and it is clear enough to understand.

Example 2: The richest companies in 2019

In this example, I want to receive some information about the richest companies in the world in 2019. The information must be easily extractable.

Bad prompt:

Image by author

Response:

Content generated by ChatGPT

This time we received a pretty good response. But it can be more complete, better presented, and contain the specific information we want. Let’s do this by making a better prompt.

Engineered prompt:

Image by author

Response:

Content generated by ChatGPT

Conclusion

As AI continues to evolve, prompt engineering will remain a valuable skill for leveraging AI models effectively. It empowers users to interact with AI systems in a more intentional and targeted manner, opening up possibilities for innovative applications across various domains, from creative writing and content generation to decision support systems and scientific research.

Ultimately, prompt engineering serves as a bridge between human intent and AI capabilities, enabling users to harness the full potential of AI models and obtain desired outputs. By understanding the principles of prompt engineering and its application, individuals can leverage AI as a powerful tool to augment human abilities, foster creativity, and contribute to the advancement of society.

Of course, if the question or the task is really simple, you don’t need to make these kinds of stuff. Before interacting with the AI, you must analyze if the task is simple or a little bit more complex. If it is complex, then use these prompt engineering techniques, if it isn’t, don’t.

Resources

More content at PlainEnglish.io.

Sign up for our free weekly newsletter. Follow us on Twitter, LinkedIn, YouTube, and Discord.


How to make an AI give you exactly what you want was originally published in Artificial Intelligence in Plain English on Medium, where people are continuing the conversation by highlighting and responding to this story.

https://ai.plainenglish.io/how-to-make-an-ai-give-you-exactly-what-you-want-3de49ce8e022?source=rss—-78d064101951—4
By: Maks Lunev
Title: How to make an AI give you exactly what you want
Sourced From: ai.plainenglish.io/how-to-make-an-ai-give-you-exactly-what-you-want-3de49ce8e022?source=rss—-78d064101951—4
Published Date: Tue, 13 Jun 2023 09:17:16 GMT

Did you miss our previous article…
https://e-bookreadercomparison.com/when-gpt-becomes-gym-and-personal-trainer/

Leave a Reply

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