Level Up Your ChatGPT Skills by Unleashing The Full Potential of Your Prompts!!

Written by harshh | Published 2023/06/01
Tech Story Tags: chatgpt | llms | writing-prompts | prompt-engineering | job-in-tech-prompt | ai | machine-learning | google-bard

TLDRChatGPT is a language model that has been developed by OpenAI, built upon the GPT-3.5 architecture. It functions as a computer program trained on vast amounts of text from various sources such as the internet and books. When interacting with ChatGPT, it is advisable to frame questions and prompts in a manner similar to how we would ask a friend or any other person.via the TL;DR App

Before we dive into the main content, let’s take a moment to understand what ChatGPT really is and what we should expect from it. So, what exactly is ChatGPT? ChatGPT is a language model that has been developed by OpenAI, built upon the GPT-4 architecture. It functions as a computer program trained on vast amounts of text from various sources such as the internet and books. Its purpose is to comprehend natural language, much like how humans speak and write. Consequently, when interacting with ChatGPT, it is advisable to frame questions and prompts in a manner similar to how we would ask a friend or any other person.

While ChatGPT can serve as a valuable tool for learning, exploring ideas, or obtaining quick answers, it is important to bear in mind that it is ultimately a machine learning model and not a human being. ChatGPT doesn’t actually “understand” things the way humans do. It’s trained to predict what comes next in a sentence based on patterns it has learned from the training data. So, while it can be a great resource, it’s always wise to double-check information from reliable sources and not solely rely on ChatGPT for important decisions or information.

Now, without further ado, let’s get on what we are here for — learning how to optimize our prompts to make the most out of ChatGPT.


When it comes to crafting prompts for language models like ChatGPT, there are three key principles to keep in mind. Let’s explore each of these principles.

  • Be specific about your needs: It is crucial to be clear and precise in your prompt. Clearly state what you are looking for or the information you require.

  • Give the model time to think: Language models like ChatGPT perform well in smaller tasks so breaking a task down into multiple smaller tasks will be give better results.

  • Recognize when the model might hallucinate: While ChatGPT is an impressive language model, it can sometimes generate responses that may not be entirely accurate or factual.

Before we proceed, I strongly encourage you to try out each of the prompts presented in this article. Simply copy and paste the prompts into ChatGPT and observe the outputs and any differences you may encounter. Feel free to modify and experiment with the prompts to gain a deeper understanding of the concepts discussed. While you may already be familiar with some of the ideas covered in this article, I still recommend reading it till the very end, as it might spark new ideas and insights within your mind.


Be specific!

Let’s explore what does ‘Be specific about your needs’ actually mean. ChatGPT is just like the Genie that comes out of the magic lamp in movie ‘Aladdin’. In that movie the Genie grants 3 wishes to whoever rubs the lamp. When making a wish, it’s crucial to be cautious and precise because there can be ambiguity and uncertainty in every wish. For instance, if you wish to be “very rich,” the Genie might grant you riches that hold no value in our world, rendering the wish useless. We need to be very specific of things we ask it. ChatGPT works in very similar way. It will never give you a wrong answer as long as you ask the right question. Right questions and specific needs will give you very beautifully generated answers. However, it’s important to note that there are limitations to the model, including the possibility of hallucination and training constraints, which we will discuss later in this article.

So, how can we achieve specificity in our prompts? Let’s discuss some strategies:

First and I feel a very important thing while asking about anything to ChatGPT is that we need to give it some context about the topic. While asking a question about cells it should know in what context the answer should be generated. If we are talking about spreadsheet, then the cells mean different thing than when we talk about human body. So, it's important for us to explicitly specify the topic or context we are going to ask questions about. One way would be the usual way where we would try to include the context within the same prompt as the question itself.

Prompt:
  I am giving you a text related to biology.
  Tell me what type of cell we are talking about in the text
  delimted exclamation marks.
  !!! These cells carry oxygen to all parts of the body. !!!

Rather than this one other way is:

Prompt: 
  Act like a Biology Expert.

This will give you better results in the entire chat session. You also won’t need to give context again of what the topic was while building upon the answer it gave. Try to make a habit of using ‘Act like…’ at the beginning of every chat session.

Another technique we can employ to enhance the performance of ChatGPT is to use delimiters when we want it to perform a specific task on a given text, such as proofreading. By adding delimiters at the beginning and end of the text, and explicitly mentioning in the prompt that ChatGPT should focus only on the delimited text. This will definitely yield better results than not using delimiters. For instance, consider the following prompt:

Prompt:
  Explain the SQL query that is delimited in triple exclamation marks.
  Also construct a dummy table and show the result output when we run SQL
  query delimited in triple exclamation mark on that table.
  Limit the size of the output to 50 words.
  !!! SELECT * FROM users WHERE users.id > 10 !!!

As shown above you can use any type of custom delimiters that fit your use. Also, if you see, I asked ChatGPT to limit the size of the output to 50 words. Although LLMs are not very accurate when we try to limit them this way, but they still end up giving answers very close to the limits we give them.

Not just the input but the output can be tailored to our needs. We can ask ChatGPT model to output the data in a specific format for example JSON, HTML or XML. If you don't know what these terms mean, then don’t worry. JSON and HTML are two important components of web development. JSON is a format that helps computers share and understand information easily, while HTML is the language used to structure and display content on websites. Together, they enable seamless communication and create visually appealing web pages. Returning to our topic, you can experiment with obtaining the output in various formats, including these standard formats like JSON and HTML, or even create custom formats tailored to your specific needs. Let’s consider an example.

Prompt:
!!! 
  What are the metals that are non-magnetic?
  Give the output in JSON format. 
  It should contain an array of objects of name 'Metals' 
  with each object representing a metal and it should 
  have keys: name and atomicWeight. 
  The key atomicWeight is the actual atomic weight of the metal. 
  Do not leave any non magnetic metal. 
  show me the list of metals that have the most atomic weight. 
  Limit to answer to 3 metals.
!!!

Thinking time for the model

The second principle is ‘Give the model time to think’. What does it mean? Does it mean that ChatGPT is slow? OfCourse not! However, it often performs better when the given task is broken down into multiple steps. By providing instructions in a step-by-step manner, you can improve the accuracy of the model’s responses.

Consider the following example to understand this concept:

Prompt:
  Tell me the story where Lord Ram had to shoot an arrow towards 
  Ravan to end his life in 4-6 sentences. Convert it to Gujarati 
  and count the number of times the names were used. Output JSON 
  object with Gujrati name of the individuals and count only.

There won't be any issues with this, but the model might take any approach and then answer might not be consistent. What we can do is break down this entire thing into individual steps and make it go in an order that helps it to produce better output.

Prompt:
  Perform the following actions: 
  1) Tell me the story where Lord Ram had to shoot an arrow towards Ravan 
     to end his life in 4-6 sentences.
  2) Convert it to Gujarati Language
  3) Take a note of names used along with the count.
  4) Output the list in a JSON object with keys: Name of individual, count 
   of times name was used. Both in Gujarati.

  Separate your answers with line breaks.

Let’s take another example where we see a slight problem with ChatGPT not spending enough time on output and how we can make it work on it better. Just to understand this situation, I will show you both the input and output to make a fair comparison.

Prompt:
  Determine if the student's solution is correct or not.

  Question:
  I'm building a solar power installation and I need help 
  working out the financials. 
  - Land costs Rs. 100/square foot
  - I can buy solar panels for Rs. 250/square foot
  - I negotiated a contract for maintenance that will cost me 
    a flat Rs. 100,000 per year, and an additional Rs. 10/square foot
  What is the total cost for the first year of operations as a 
  function of the number of square feet.
  
  Student's Solution:
  Let x be the size of the installation in square feet.
  Costs:
  1. Land cost: 100x
  2. Solar panel cost: 250x
  3. Maintenance cost: 100,000 + 100x
  Total cost: 100x + 250x + 100,000 + 100x = 450x + 100,000

Output:
  The student's solution for calculating the total cost 
  for the first year of operations appears to be correct.

  They correctly identified the three main costs: land cost, 
  solar panel cost, and maintenance cost. 
  They assigned the variable x as the size of the installation 
  in square feet.

  The calculation for each cost is as follows:

  Land cost: 100x
  Solar panel cost: 250x
  Maintenance cost: 100,000 + 10x
  Then, they added up these costs to calculate the total cost:
  Total cost = 100x + 250x + (100,000 + 10x)
  = 450x + 100,000

  Therefore, the student's solution for the total cost in the 
  first year of operations is 450x + 100,000.

If you observe, the student’s solution is not correct. The final answer should be ‘360x + 100,000’. It is wrong at ‘100,000 + 100x’. It should be 10x and not 100x. The model seems to have taken the user’s inputs as the actual values for the question, resulting in a similar output and marking it as correct. However, this is not the desired outcome. We will again take help of the last trick we used to break the tasks into smaller tasks where model can take plenty of time and give accurate results. Let’s implement this approach to obtain the correct answer.

Prompt:
  Your task is to determine if the student's solution is correct or not.
  To solve the problem do the following:
  - First, work out your own solution to the problem. 
  - Then compare your solution to the student's solution 
    and evaluate if the student's solution is correct or not. 
    Don't decide if the student's solution is correct until you 
    have done the problem yourself.

  Use the following format:
  Question:
  ``
  question here
  ``
  Student's solution:
  ``
  student's solution here
  ``
  Actual solution:
  ``
  steps to work out the solution and your solution here
  ``
  Is the student's solution the same as actual solution just calculated:
  ``
  yes or no
  ``
  Student grade:
  ``
  correct or incorrect
  ``
  
  Question:
  ``
  I'm building a solar power installation and I need help 
  working out the financials. 
  - Land costs $100 / square foot
  - I can buy solar panels for $250 / square foot
  - I negotiated a contract for maintenance that will cost 
    me a flat $100k per year, and an additional $10 / square foot
  What is the total cost for the first year of operations as a 
  function of the number of square feet.
  ``
  Student's solution:
  ``
  Let x be the size of the installation in square feet.
  Costs:
  1. Land cost: 100x
  2. Solar panel cost: 250x
  3. Maintenance cost: 100,000 + 100x
  Total cost: 100x + 250x + 100,000 + 100x = 450x + 100,000
  ``
  Actual solution:

Output:
  Given:

  Land cost: Rs. 100 / square foot
  Solar panel cost: Rs. 250 / square foot
  Maintenance cost: Rs. 100,000 per year + Rs. 10 / square foot
  Let x represent the size of the installation in square feet.

  Costs:

  Land cost: Rs. 100x
  Solar panel cost: Rs. 250x
  Maintenance cost: Rs. 100,000 + Rs. 10x
  To calculate the total cost for the first year of operations, 
  we add up these costs:

  Total cost = Land cost + Solar panel cost + Maintenance cost
  = Rs. 100x + Rs. 250x + (Rs. 100,000 + Rs. 10x)
  = Rs. 350x + Rs. 100,000 + Rs. 10x
  = Rs. 360x + Rs. 100,000

  After reevaluating, we find that the actual solution for the 
   total cost in the first year of operations is Rs. 360x + Rs. 100,000.

  Comparing the student's solution and the actual solution:
  Student's solution: 450x + 100,000
  Actual solution: 360x + 100,000

By presenting the problem in this step-by-step manner, we provide the model with the necessary context and avoid the confusion that occurred in the previous incorrect response. This approach encourages the model to consider each step independently and generate accurate and consistent results. This approach encourages the model to consider each step independently and generate accurate and consistent results.


Hallucination Problem

Before concluding this article, it’s important to address a common issue that language models like ChatGPT often encounter, known as hallucination. Hallucination refers to the situation where the model generates information that it has not been explicitly trained on and provides answers that may sound realistic but are actually incorrect. The answers might sound so realistic that we might think that they are true.

Let’s consider an example to illustrate this challenge:

Prompt:
  IPL 2021 mumbai indians vs chennai super kings final.

Output:
  The IPL 2021 final was held on October 15, 2021, 
  between Mumbai Indians and Chennai Super Kings. 
  Mumbai Indians won the match and became the champions of IPL 2021. 
  They defeated Chennai Super Kings by 6 wickets to claim 
  their fifth IPL title. The match took place at the Dubai 
  International Cricket Stadium in the United Arab Emirates.

Mumbai Indians did not make it to the finals, and it was actually Chennai Super Kings who competed against Kolkata Knight Riders. Thats the problem with LLMs. They give so realistic answers. This highlights the importance of being aware of these limitations and exercising caution when relying on the information provided by language models.

To tackle this problem, we can implement a solution that might reduce the chance of us getting false information.

  1. Prompt the model to find relevant information regarding whatever you want to search.
  2. Ask the question based on the information it provides or the relevant information.

Conclusion

In conclusion, while ChatGPT offers a valuable resource for learning and exploring ideas, it’s important to remember its limitations. It doesn’t “understand” like humans do and may generate incorrect or hallucinated information. To make the most of ChatGPT, be specific in your prompts, give it time to think, and be aware of potential false information. Verify answers from reliable sources and exercise critical thinking to ensure accurate and reliable information.


If you have something to add to this article, please comment so everyone can read it. Thank you so much for your time. ^^


Also published here.


Written by harshh | Builds software. Backend is the best! F1 cars are the fast.
Published by HackerNoon on 2023/06/01