Many different AI tools like ChatGPT, Google Bard, New Bing, etc. have taken the world by storm, by showcasing their capabilities, and future potential. With the advancements in Artificial Intelligence, the world is now moving at a fast pace. I have seen many people use tools like ChatGPT once or twice, ask something very vague, or in an improper way, and then when it does not come up with the desired output, they just come to a conclusion that this model doesn’t have the ability to do it, when actually the prompt that they had given to the model wasn’t enough to get the required output.

How to write better prompts?

So, it is clear that it is important to write better prompts, to get a better output. But now the question is how? How can we write better prompts, to get better results? This is what we are going to discuss in this article. By the end of this article, you should have a broad idea about what things you need to follow, in order to be able to write better prompts, than ever before.

Why should we write better prompts?

Seems to be a very basic question, but carries a deep importance – Why should we write better prompts? Well, there’s a short answer to this, to get better outputs, but I will try to explain so that you can understand the need of crafting better prompts.

Let’s say that you want to write an email to your boss Ratanlaal, telling him that the product launch for our new smartphone Gem Diamondphone 2 was successful, and we received 50,000 pre-orders, which is double our expectations. So for that, you can write some prompts like this –

Write an email to my boss sharing the update on our new product launched, Gem diamondphone 2, and we received 50,000 pre-orders.

If you try to give the above prompt to ChatGPT, or Google Bard, you would get an email as you requested, and it may feel even better at first sight, but as you go on reading the email, you might feel that it doesn’t fit your needs completely, and you need to work more on that, so despite of getting an email in the first few seconds, you would need more minutes, or more conversation with the model, to get to your desired output, before you would be able to deliver the mail to your boss.

It’s not as simple as it seems, because our prompt is going to influence the model behavior and output. The thing is that the above prompt is missing enough information, which can be used to write a better email. Just like this, when we write our prompts for other cases, we need to make sure that we are providing enough information to the model so that it can act upon it, and provide a better response.

Think of it this way – Let’s say that you told some work to someone in your office. Now, if you told it in a very generic way, and not giving enough information about the task, you might get a response from the worker, but it would be quite generic, or not up to your expectations.

In a similar way, when you are giving the prompt to these models, they need to be given enough information to act on, so that the output that you get is near the expectations.

So, indeed it’s important to write better prompts, to be able to get desired output. So, let’s discuss some of the important tips, and techniques, that should help you write better prompts, and get better results.

How can we write better prompts?

Now, when you know that it’s important to write better prompts, it’s the question of how? how can we write better prompts? We are going to discuss some tips and components, which can help you write better prompts, and get better outputs.

We have been talking that we need to write better prompts, but what do we mean by a “prompt”? Well, prompt is the text that we provide to the model, to get the output from the model. The prompt actually influences the model behavior and the output, so it’s very important how you prompt to model.

Let’s go through some of the tips, which would help you a lot, when you are crafting your prompts, and should eventually help you get better results.

1. Provide a Persona

While it’s not necessary to provide a persona all the time in your prompt, it can help you at times, giving a different output. At times, when we write some prompt, it is often associated with some role, which might be better able to perform the task.

By persona, we just mean that we need to provide some role to the model, according to which it would perform the task. For example, for example, if you want to get a workout plan for your gym, you might want the model to act as a professional gym trainer, then add some more information in the prompt, and then observe the output you get, versus the generic output.

Here’s a quick example of that

Provide a 90 days training plan for a 60 kg male.

The above prompt suggests the model provides a 90 days training plan for a male who weighs 60 KG. With this prompt, you would get a response, but that response would be too much generic. This can be even made better with some additional information, and also providing a persona. Again, providing a persona is not a compulsory thing, but it’s important to provide enough information in the prompt. Here’s an example of that –

Act as a professional gym trainer. Your task is to provide a 90 days training plan for a male who weighs 60 kg, and wants to put on another 5 kg muscle gain in the coming 90 days. Also, generate a supportive vegetarian diet plan for helping the muscle gain.

Using this prompt, you might get somewhat better results because you have provided the persona, and also somewhat more information, which would support the upcoming output. You can try comparing the output of both the above prompts yourself, and you might see a little difference in the output. Though we can add more information, for an even better output, giving persona can still help a lot.

2. Provide enough context

Sometimes, we fail to provide enough context and end up getting a basic output. So, it is very important for us to provide enough context in the prompt, so as to get better output. When we provide enough context, we are providing enough information through the prompt, which can lead to a better output. Context can be any information that you think can be useful for getting better output.

Here’s a quick example of that –

Write an email to my boss sharing the update on our new product launched, Gem diamondphone 2, and we received 50,000 pre-orders.

This prompt is similar to what we saw earlier, but this prompt is kind of basic and lacks more context. We can make it better by providing more information like what was the number of pre-orders that we had expected, and anything else that you think might be helpful to be included in the email. So, let’s say the prompt now looks somewhat like this –

You are a senior marketing manager at Gem, a smartphone company, and you have recently revealed the company’s new product, Gem diamondphone 2, which received tremendous support and love from the customers all over the Country, and we received 50,000 pre-orders, which is 20 times more than the target. Write an email to your boss, Ratanlaal, sharing this positive news.

You can try to execute these prompts and check the output. You would find a slight difference in the output, and that difference is due to the context provided. You just need to provide enough information so that you can get better output.

3. Provide examples, which support the output that you want

Whenever you want to make someone understand something, it’s better to provide them with some examples. Something similar is with the models. If we provide examples to the model, related to the input, and the output as well, the model can respond accordingly. Let’s have a look at an example –

Let’s say that here’s a basic prompt, for sentiment analysis –

Can you classify the below statement as positive, negative, or neutral –
This restaurant was so good, and the staff was also polite and cooperative.

With the above prompt, you would get a response from the model, which might end up telling that the response is positive, and why it is positive. But let’s say that you wanted only ‘positive’ or ‘negative’ or ‘neutral’. giving examples can help. Here’s an example of that –

Review: I didn’t like the food.
Sentiment: Negative

Review: This is the best restaurant i have ever visited.
Sentiment: Positive

Review: The food was tasty, but the staff was not cooperative.
Sentiment: Neutral

Review: This restaurant was so good, and the staff was also polite and cooperative.
Sentiment:

You can try giving this prompt, and you would see the difference. This time, you would get Sentiment as positive, and that could be the output that you wanted. By giving the examples, you are providing the style of the input, and the output that you want, and this can help a lot. While giving examples may not be necessary, it can help a lot.

4. Give Clear and Concise instructions.

At times, the reason behind not getting the desired output is that we are not clear enough in our prompt, and the model gave something that is generic. So, being clear and concise can help a lot. So, whenever you are writing a prompt, make sure you include enough information. Always remember, The more comprehensive your prompt, the better the results.
Here’s an example prompt for that –

Write a blog post on How to beat procrastination

The above prompt is a basic prompt, which would give you a blog post on “How to beat procrastination”, but it is kind of basic! Now have a look at the below prompt.

Write me a 900 words blog post on “How to beat procrastination”, which should start with a question, or a potential statement on Procrastination. Include different sections for “What are the causes of procrastination”, “Tips for beating procrastination”, and in the end, include a call to action, encouraging the reader to get rid of procrastination, before it hurts your career and life.

This prompt can certainly provide a better blog post than the above basic prompt. You can try comparing the outputs from both the prompts, and observe the quality of the outputs.

5. Evaluate and Iterate

If you are thinking that I should have this prompt, and I’m done, or I should have that prompt, and then I’m done. But it may not happen the way you think. At times, you might want to evaluate the output due to some prompt, and then try to make some changes, and then retry with the new prompt. Prompt Engineering is an iterative process, where you would try some prompts, and then make some changes to the prompts so that you can get better output.

Conclusion

In this article, we tried to understand some basic tips to write better prompts. It is very important to write some better prompts, so as to get better output. The prompts that we write are greatly going to influence the model behavior and output, so always when you are writing some prompts, make sure that you are using some or all of the above-discussed tips, and write better prompts.

I hope that you could get the importance of writing prompts, and also understand how to write better prompts.

FAQs related to How to write better prompts

Q: What is a prompt?

Ans: Prompt can be understood as some set of instructions that we are passing to the model so that it does the specified task. The prompt is going to guide the model to the output.

Q: What are the mistakes that we need to avoid while writing prompts?

Ans: Well, there are many mistakes that we should avoid while writing prompts. this includes not giving enough context, being too vague, being too long, using jargon, etc.

Q: What is Prompt Engineering?

Ans: Prompt Engineering can be understood as the art and science of creating effective prompts, which can lead to effective and desired output.