ChatGPT is a powerful language model that can generate human-like text. However, it requires precise prompting to produce the desired output. In this article, I explore advanced ChatGPT prompting techniques to create more sophisticated and nuanced output.
If you have no experience using ChatGPT then please read how to chat with GPT first.
For website owners or bloggers you may also be interested in AI for website owners: How to harness its mind-blowing capabilities.
Let’s dive in to advanced ChatGPT prompting to help you boost your creativity and become productive.
Table of Contents
- Basics of ChatGPT Prompting
- Set Response Length: Using Prompts to Control Response Length
- Context: Add context to your Prompts
- Incorporating Structured Data into Your Prompts
- Logical Operators
- Generate answers by getting ChatGPT to write code
- Best Practices for Advanced ChatGPT Prompting
Basics of ChatGPT Prompting
Before diving into advanced techniques, it’s important to understand the basics of ChatGPT prompting. A prompt is a question you want answered or a set of tasks you want ChatGPT to perform.
Try to give clear, precise prompts to ChatGPT. Vague prompts may result in unhelpful responses.
You can continue to prompt ChatGPT after a response. ChatGPT remembers previous prompts and it’s responses.
To clear all previous memory of responses start a new conversation.
If you don’t get all the information you want in a response, say you get 8 out of 10 results. You can ask ChatGPT to “
continue“. You can also ask for more answers, e.g. “
Give me 5 more answers“.
Set Response Length: Using Prompts to Control Response Length
One of the common challenges when working with ChatGPT is getting responses that are the right length.
The easiest way is by giving ChatGPT the expected size of the response you want. For instance:
Write a SEO meta description of 160 characters or less on the topic "Are keto diets healthy?"
Here is another example:
Write a blog introduction of 300 words on the topic "Healthy recipes you can prepare in 20 minutes".
For lists set the number of items you want:
Give me 7 reasons why SEO is important for blogging. Provide the output as a bullet pointed list.
Context: Add context to your Prompts
Another important consideration when crafting ChatGPT prompts is context. By providing more context in your prompt, you can get more specific and targeted responses from ChatGPT.
For instance, if you want ChatGPT to help you write an article about the keto diet, the following information will help set the context:
- overweight person who is looking to lose weight
- doesn’t know anything about the keto diet
- daily food budget is $20
- meal prep time is 20 minutes or less
This information helps ChatGPT tailor it’s output to meet the target audience or niche you are writing about. To avoid bland and generic responses be sure to always provide context in your prompts.
Incorporating Structured Data into Your Prompts
ChatGPT can process structured data, which is information organized in a specific format such as a list or table. Supported input formats can vary based on the interface and model in use. You can always ask ChatGPT what input formats it will accept.
In this example I give ChatGPT a list of items and then ask questions about the data:
You can also ask for responses in your preferred format. In this example I ask for a list of planets with additional data provided in a table format:
If you would like to add the output to your website or blog you can do the following:
Can you markup the table using standard wordpress classes?
The output is below (the output stopped before it rendered Neptune):
|Average Distance (AU)
|Mass (Relative to Earth)
Logical operators such as “and,” “or,” and “not” can be used to further refine your prompts and generate more precise responses from ChatGPT.
Look at this example:
Generate a horror story that contains the word "ghost" but not the word "zombie".
In this example, the logical operator used is “but not“, which is used to exclude a specific word from the generated response. By including the logical operator in the prompt, ChatGPT will generate a horror story that includes the word “ghost” but will exclude any mention of the word “zombie”
By using logical operators in your ChatGPT prompts, you can exercise greater control over the generated responses and tailor them more closely to your desired output.
Conditionals are another powerful tool you can use when crafting ChatGPT prompts. By using conditionals, you can control the content of responses based on certain conditions, such as the presence or absence of certain keywords or entities.
Let’s go over some examples:
"Assuming I have a budget of $1000, what are some affordable vacation destinations?"
Here, the conditional “assuming I have a budget of $1000” indicates that the response should focus on destinations that fit within that budget, rather than suggesting more expensive options.
"If I'm looking for a healthy dinner option, what are some good recipes to try?"
In this prompt, the conditional “if I’m looking for a healthy dinner option” indicates that the response should focus on recipes that are nutritious and fit within a healthy diet, rather than suggesting less healthy options.
"If I were to visit Paris, what are some must-see attractions?"
In this prompt, the conditional “if I were to visit Paris” sets the context for the response, indicating that the answer should focus on attractions that would be of interest to someone planning a trip to Paris.
Generate answers by getting ChatGPT to write code
ChatGPT is better with words than numbers. Getting ChatGPT to directly answer math questions sometimes leads to wrong answers. The solution is to get ChatGPT to write code to answer the question.
ChatGPT can run python code so it’s best to ask for code in Python.
Best Practices for Advanced ChatGPT Prompting
To get the most out of ChatGPT, there are several best practices to keep in mind when crafting prompts. These include using clear and concise language, incorporating context and data, and testing and refining your prompts over time.
This is a more advanced tip but can be very useful if you are getting generic content.
Increase the temperature. What does that mean? The ChatGPT has a hyperparameter called “temperature”, this sets the randomness of the output. Higher temperature, higher randomness resulting in more unique content.
top_k hyperparameter: this sets the probability of the next word (technically next token) selected.
A value between 5 and 20 is often recommended to promote creativity and reduce the likelihood of producing generic content. However, setting a lower
top_k value may also result in the model generating less fluent or grammatically correct responses, so it’s important to strike a balance between uniqueness and quality.
ChatGPT will not accept values of less than 5. It responds with the following message:
I’m sorry, but setting the top_k hyperparameter to 2 would greatly limit the amount of text generated and may result in nonsensical output. It’s recommended to set the top_k to at least 5 to ensure coherent and meaningful output.
With its incredible language processing capabilities, ChatGPT is a powerful tool for generating text-based content. By mastering advanced prompting techniques, you can take full advantage of this technology and generate more targeted, specific, and effective responses from ChatGPT.