How to Write the Perfect ChatGPT Prompt: A 2024 Guide

If you closely pay attention to how these AI chatbots like ChatGPT give responses it basically depends upon the way you are asking questions. That means the prompt you entered determines how well you got the response back. So if what you wrote perfectly presents your problem you will get the fine-tuned output. 

In this article, we will learn how to do so, and how to craft and refine prompts to get accurate results.

Also Read: 10 Amazing ChatGPT Prompt Templates You Should Know

Understanding Prompt Engineering

Prompt engineering is the process of creating and refining the prompts to get satisfactory results. Prompt engineering is important because these large language models (LLMs) like ChatGPT are totally designed to generate text responses based on the input so the quality of their output heavily depends on how well the prompt is structured. 

Writing effective prompts not only helps us refine the output better but also saves the time and effort wasted in asking a question again and again waiting for GPT to give the answers you want. It is also cost-effective if you use the OpenAI API in which the cost depends on the length of the prompt and the response. So if you refine your long prompt to a to-the-point prompt, you can save a good amount of money.

Let’s see how to write such effective prompts.

Writing the Perfect ChatGPT Prompt

Writing the perfect prompt is not something that can be achieved the first time interact with ChatGPT, it requires practice and continued use. However here are some key elements that make a prompt stand out and help you get the exact answer you are looking for.

If you don’t know how to use ChatGPT: How to Use ChatGPT

1. Assign a Role

ChatGPT can act like different persons and respond in different ways accordingly. Not only the style of responses but also the depth and examples change accordingly.

You can instruct it to act like your profession and get the response the way you want. Like if you are asking to write an article for your assignment then you can ask it to act like a student, or if you are writing for a newspaper then you can ask it to act like a journalist.

Let’s see a quick example of this.

For the prompt: Imagine you are a science student and explain ethanol

Assigning a role

For the prompt: Imagine you are a chemistry professor and explain ethanol

Assigning another role

See how the details and depths of the answer changed.

2. Mention the Problem Clearly

These AI chatbots will give better answers if you describe your question better. Try to describe as in-depth as possible.

For instance, if you just ask, “What is Mjolnir?”, you may not get the answer you want. Let’s demonstrate.

Problem

The answer looks a bit different from what we are actually searching for.

Let’s define the problem better and ask “What is Mjolnir in the Marvel Thor movies?”:

Define problem better

Now we got the answers from the perspective of Marvel.

3. Explain Output Requirements

You should always provide how you want the output. This can be in point-wise or table format which is best for comparison, or a one-liner, several paragraphs or the whole article. This is very common but still useful.

Example prompt: Give a recipe for Indian tea with ingredients and quantities in a table.

Add output requirements

4. Provide Rules and Constraints

Another important element you can add to your prompt is the rules and constraints. This controls the scope of the response like how long you want, what it includes, what to exclude, etc. This helps in getting straightforward answers.

For example: Explain foldable phones in 100 words and avoid using technical teams.

Add constraints

5. Add Context

If you want an answer in perspective of some specific thing, you can give ChatGPT context or reference about it to get a more relevant response. Like we did in the Mjolnir example, by giving context as Marvel.

Add context

6. Specify the Desired Tone

This is my favourite. Just like how ChatGPT can act like different persons and respond that way, it can also respond in different tones like formal, informal, humorous or motivational. Providing a tone when asking a question makes sure the response matches the exact purpose.

Let’s see the examples.

Specify the formal tone
Specify the informal tone

Additional Tips for Prompting

Once you have created your perfect prompt and given it a try, in some complex cases it is possible you won’t get the result you want. For that below are some additional tips beyond just crafting the prompt to get the desired output.

1. Request Multiple Perspectives

If you are constantly struggling and can not find the answer you want, you can ask your question from multiple perspectives for different views on the topic. Once you like a perspective that suits your needs, you can rewrite the prompt to focus on that specific aspect for a more targeted response. This is an iterative process and can be overwhelming but trust me it is very useful in getting the exact information you want to get

2. Guide the Correct Path

If you are continuously communicating with ChatGPT on the same tab, it remembers what you said before. So if during the conversation, you say something wrong or it misinterprets something, this leads to an unexpected change in the conversation. Like if you continuously ask about a specific algorithm, ChatGPT might sometimes change track to unrelated topics and disrupt the flow.

In such cases, try to find out from where the conversation started to deviate and edit that message. Editing a previous message will remove all subsequent messages and also that wrong information, this will bring GPT back on the right track.

3. Ask to Re-read the Prompt

ChatGPT often makes mistakes or misinterprets your prompts or questions in a way you did not intend. A simple hack for this is to ask it to re-read the prompts. You can even ask to re-read the prompts multiple times to get the desired output.

4. Doubting ChatGPT

Another good trick to check or review a response is to doubt ChatGPT. You can ask, “Are you sure the answer is correct?” to make it review the information it provided again. After this, ChatGPT also starts justifying the answer and gives you more details on how the answer is correct.

Doubting ChatGPT

Ask again for more justification:

Doubting ChatGPT again

Conclusion

In short, to craft the perfect ChatGPT prompt, assign a role to it, define your problem deeply with the output format, set rules and constraints, give better context, and select a tone. Additionally, request multiple perspectives, keep ChatGPT on track by editing wrong inputs, ask it to re-read prompts, and doubt its answers for validation. That’s it. Just remember, it takes time to get better at prompting and the key to mastering it is to keep trying.

Reference

https://www.reddit.com/r/ChatGPTPro/comments/14c9vx2/what_is_the_best_way_to_get_start_writing_prompts

Aditya Gupta
Aditya Gupta
Articles: 150