Skip to main content

How to Craft Perfect Prompts for ChatGPT?


ChatGPT is an artificial intelligence system that can generate text responses based on user inputs. It can be used for various purposes, such as chatting, writing, learning, and more. However, to get the most out of ChatGPT, users need to know how to craft perfect prompts that will elicit useful and relevant answers from the system.

A prompt is a text input that tells ChatGPT what kind of response you want from it. A good prompt should be clear, specific, and informative. It should also state your intent or goal, and direct the output format if needed. In this essay, I will share seven best practices for effective prompt engineering, and then I will give you a formula and some examples of perfect prompts.


Best Practices

1. Be specific

If you ask a vague question, you may get a vague answer. The more details you provide, the better ChatGPT can give you what you’re looking for. For example, instead of asking "tell me about all dog breeds that exist,” ask “What are the different breeds of small dogs suitable for apartment living?” This way, ChatGPT can narrow down its search and generate more relevant information.

2. State your intent

If there’s a specific purpose for your question, state it in the prompt. For example, instead of asking “explain quantum physics” you could say “I’m helping my fifth-grade son with his science homework. Could you explain quantum physics in a simple way?” This way, ChatGPT can adjust its tone and level of complexity to suit your audience and goal.

3. Use correct spelling and grammar

While ChatGPT can often interpret and correct spelling and grammar mistakes, providing clear and correct prompts helps ensure you get the best response. ChatGPT may also use your spelling and grammar as cues for the style and quality of the output. For example, if you write “how r u?” ChatGPT may respond with “im good thx” or something similar.

4. Direct the output format

If you want the answer in a specific format, state it in your question. For example, you could ask “Could you list the steps to bake a chocolate cake?” or “Could you explain the process of baking a chocolate cake in a paragraph?” This way, ChatGPT can structure its response accordingly and avoid confusion or ambiguity.

5. Ask follow-up questions

If the response wasn’t what you expected or if you need more information, feel free to ask follow-up questions to clarify. ChatGPT can remember the context of the previous prompts and responses and use them to generate more coherent and consistent answers. For example, if you ask, “What are the benefits of meditation?” and ChatGPT responds with “Meditation can help reduce stress, improve focus, and enhance well-being.” You could then ask, “How long should I meditate each day?” or “What are some good meditation techniques?”

6. Experiment with different phrasings

If you’re not getting the response you want, try asking the question in a different way. ChatGPT might understand one phrasing better than another, or generate different answers based on different wordings. For example, if you ask, “What is the meaning of life?” ChatGPT may respond with “That is a very deep and philosophical question that has no definitive answer.” But if you ask, “What gives life meaning?” ChatGPT may respond with “Life is what you make of it. You can find meaning in your relationships, your passions, your goals, and your values.”

7. Prompt for fact-checking

If you’re looking for reliable information, you can ask ChatGPT to provide sources or to fact-check information. For example, “Can you fact-check this statement: The tallest mountain in the world is Mount Everest?” ChatGPT may respond with “This statement is true according to most measurements, but some people argue that other mountains are taller based on different criteria. For example, Mauna Kea in Hawaii is taller than Mount Everest if measured from its base on the ocean floor.” ChatGPT may also provide links or references to support its claims.

Formula

Now that you know the seven best practices for effective prompt engineering, let me give you a formula for crafting perfect prompts for ChatGPT.

[Context] + [Specific Information] + [Intent/Goal] + [Response Format] = Perfect Prompt

The context is the background or situation that sets up your question. The specific information is the details or parameters that narrow down your question. The intent or goal is the purpose or objective that motivates your question. The response format is the structure or style that you want ChatGPT to use in its answer.

Here are two examples of perfect prompts using this formula.

Context: “I’m a beginner cook” 
Specific Information: “trying to make Italian cuisine” 
Intent/Goal: “Can you provide a simple and easy to follow recipe.” 
Response Format: “Write it as a step-by-step list?” 
Perfect Prompt: “I’m a beginner cook trying to make Italian cuisine. Can you provide a simple and easy to follow recipe for spaghetti carbonara? Write it as a step-by-step list.”

Context: “I’m a software developer” 
Specific Information: “working on a Python project” 
Intent/Goal: “Can you explain how to implement exception handling in Python?” 
Response Format: Write it in a simple paragraph or list. 
Perfect Prompt: "I’m a software developer working on a Python project. Can you explain how to implement exception handling in Python? Write it in a simple paragraph or list.

Conclusion

In conclusion, crafting perfect prompts for ChatGPT can help you get more useful and relevant answers from the system. By following the seven best practices and using the formula I shared, you can improve your prompt engineering skills and get the most out of ChatGPT.


Comments

Popular posts from this blog

Unlock protected blocks in Siemens SIMATIC Step 7

Recently I'd been called by Hindalco's Fabrication Plant division to unlock the protected blocks in Siemens SIMATIC Step 7. They were in need to unlock those blocks since an year because of 1 million Rupees of loss per month. They want to re-program those blocks but it was locked by the man who'd done the setup. From the people working in that department, I came to know that they were trying to call that man (someone from Italy) right here but he's not coming. Actually, what he'd done was that he'd locked some of the blocks and deleted the source file. And Siemens didn't provide any feature to unlock. Department people also told me that even the people working in Siemens don't know how to do it. Being a software engineer I know that any thing can be reverse engineered. So I took up the challenge. How did I unlocked the blocks? The first thing I'd done was searched about this software at Google and read about what is this software all about. Aft...

Launching a Jupyter Notebook with TensorFlow using Docker

This article will walk you through setting up a Jupyter Notebook environment with TensorFlow pre-installed using Docker. Docker allows you to run isolated containerized applications, providing a consistent environment regardless of your underlying operating system. Prerequisites: Docker: Ensure you have Docker installed and running on your system. You can download and install it from the official Docker website ( https://www.docker.com/ ). Steps: Start Docker: Open your Docker application (Docker Desktop for Windows/macOS or the command line if using Linux). Run the Jupyter Notebook container: For macOS/Linux: Open your terminal application and run the following command: docker run -it --rm -p 8888:8888 -v "${PWD}":/home/jovyan/work jupyter/tensorflow-notebook For Windows: Open your Command Prompt application and run the following command: docker run -it --rm -p 8888:8888 -v "%CD%":/home/jovyan/work jupyter/tensorflow-notebook Explanation of the command flags: -...

JS: The complete code example of Crypto.js (DES)

For one of the project I was trying to use crypto.js but I found that the Quick-start Guide have some deficiency in terms of library usage. So I am writing it here as a useful note for memory recap. <script src="http://crypto-js.googlecode.com/svn/tags/3.1.2/build/rollups/tripledes.js"></script> <script> var encrypted = CryptoJS.DES.encrypt("The secret message", "secret_key"); var e_msg = encrypted.toString(); console.log(e_msg); var decrypted = CryptoJS.DES.decrypt(e_msg, "secret_key"); var d_msg = decrypted.toString(CryptoJS.enc.Utf8); console.log(d_msg); </script>