Machine Learning Spot

How to Master Prompt Engineering: 3 Simple Steps (Beginners)

Prompt engineering is a new era of hope for those who know how to do it effectively. In today’s world, prompt engineering is the language that you need to learn to communicate with the machine effectively, and it is a language that you already know; you just need to learn how to effectively use that language in a way that you get your desired result.

Prompt engineering beginning of new era!

We are here to help you learn it simply, so today we will discuss ways to learn prompt engineering as a beginner. So, let’s start with the exact prompt.

Don’t get scared; yes, indeed, it is a result of massive coding and problem-solving. But to become an effective, prompt engineer, you don’t need to know that at all. Although knowledge will surely help you, here we will discuss some basics, so no coding experience is required!

What is prompt engineering all about?

Prompt, as its name suggests, is all about stimulating the AI model to generate the desired results that we want to see. It involves carefully crafting prompts or instructions to guide the AI model in producing specific outputs.

Since AI is all about neural networks, in which we try to mimic human intelligence, take it this way. Imagine approaching an institution or organization and then interacting with its representative at the reception. Let’s say a mall or a hospital.

Prompt engineering Analogy

Now, how you interact with that person your words will stimulate that person’s brain and bring a proper response or output in the form of information based on the query used to gather information.

Prompt engineering: Molding of Desired Pottery

So now you know what the prompt is all about. Coming to the next point, what prompts engineering itself is prompt Engineering is called engineering as here we craft our prompts the same way craftsman crafts his desired products, moulding clay in such a way that it can hold water the way the craftsman wants it to.

Prompt Engineering Molding Analogy

When a prompt engineer hits the enter button, he throws that well-moulded and crafted pot or utensil to fetch water from the well. In the realm of generative AI, that well is the massive amount of data the model is trained on. A prompt engineer is responsible for ensuring that the model, i.e., ChatGPT, Gemini, etc., provides the written information or results by providing appropriate details, context, and constraints.

I called it analogous to clay or even wax, which can be moulded into anything because of endless possibilities. By crafting the right model, you can mould the model in any way you want, whether it be a personal assistant, a personal teacher, or even a best friend!

Let’s start with prompt engineering by exploring the three simple steps to take as a complete beginner.

Step 1: Understand The Behavioral Science Behind Prompt Engineering

Since the human mind inspires neural networks, but they are not human minds in reality, we need to know how their models respond and how they work.

LLM, i.e., large language models, helps you establish communication between you and your machine. LLM is an expert in communication trained on vast amounts of human language data from books, websites, articles, etc.

Understanding it will help you understand how a model responds to your given prompt. I will further enlighten you on how your perfect partner, i.e., a generative AI like Chat GPT or Gemini, is just a computer-generated illusion perfectly designed to help you based on your prompts. Then, after processing, it weaves all the relevant words together to generate a human-like response to the given prompt.

To get a little idea, take a look at the images below to see how LLM sees your sentences.

Word food as a Token in Prompt Engineering Mindset
A small word like “Food” is taken as a single token
Tokeinzation importance in Prompt engineering 'Tokenization' taken as two tokens
The word ‘Tokenization’ is taken as two tokens

Observe how longer words like tokenization are broken down into two separate tokens. Token + ization.
You can also try it!

Step 2: Exploring Creative Practice in Prompt Engineering

Now, the second step is to practice creatively. The more you practice, the more you learn. But here is a catch: practice, but practice right. To do that, you need to give it detailed prompts.

There are two types of famous prompting: zero-shot prompting, in which we expect the model to know, and few-shot prompting, in which we give model examples. Both examples of prompting can be seen in the pictures below.

An Example of Zero-shot Prompting in Which We Expect the Model to Know Everything
An Example of Few-shot Prompting: Providing Model Examples for Context

To elevate your creativity, you can provide additional instructions and give it a persona so that it responds with that personality while interacting with you. Furthermore, you can specify a format. For example, you can ask it to generate a checklist or create a tabular form, among other options.

Let’s explore a humorous example: I asked ChatGPT to be my girlfriend. There are two examples below: in image 1, it apologizes, while in image 2, it starts behaving like a girlfriend.

Example of Poorly Crafted Prompt in prompt engineering
Example of Poorly Crafted Prompt
well thought and performed Prompt engineering example
Example of a Well-Crafted Prompt

These examples demonstrate the significance of prompt engineering in achieving the desired output. As prompt engineers, we shape the prompts to achieve optimum results. You just need to explore your limitless creativity.!

Step 3: Setting Clear Goals for Effective Prompt Engineering

Without knowing your proper goal, you are just moving around unnecessarily. The first step is always to understand your goal and the type of prompt engineering you want to learn. There are different generative AI models trained for various purposes, such as text-to-speech, text-to-image, and text-to-text. Defining your goal helps you stay focused and learn more effectively.

For example, if you simply want to learn text-to-text generation, which I recommend for beginners, then define your goal. Specify why you want to learn it. Are you a web developer aiming to use a particular model for web development, or are you a high school or undergraduate student looking to learn and apply it? This way, you are narrowing your focus, which will help you find the right course tailored to your field, available both for free and for a fee on the web.

Recommended Learning Resources for Beginners

You can start with “Generative AI for Everyone” by Andrew Ng to increase your knowledge about LLM and how generative AI works. Andrew Ng is a superstar teacher in the AI world; he is a co-founder of Google Brain and Coursera and the founder of deeplearning.ai. In this course, you will learn the basics of generative AI without any need to code. If given 1 hour a week, you can finish it in 3 weeks.

To practice prompt engineering, you can refer to this guidebook” The Prompt Engineering Guide V2″ designed with multiple prompt examples by Julian Melanson and Benza Maman. They are both experts in the field. In this short guidebook, there are various examples of prompts that will help you grasp and use your skills better

These resources to learn as a beginner are enough, but to move from beginner to advanced, you need to keep exploring, keep practising, keep learning, and, in the end, keep updating yourself.

Conclusion:

Now that you have learned about prompt engineering, it’s high time to try it out on LangChain, a framework used to build LLM-powered apps just like ChatGPT, Gemini, and many others.

To get started, check out my post on what is LangChain, to learn how to use LangChain, read this article, and to learn how to make prompt templates to utilize your prompt engineering skills, use this article. Feel free to reach out to us for any feedback or suggestions.

Liked the Post?  You can share as well

Facebook
Twitter
LinkedIn

More From Machine Learning Spot

Get The Latest AI News and Insights

Directly To Your Inbox
Subscribe

Signup ML Spot Newsletter

What Will You Get?

Bonus

Get A Free Workshop on
AI Development