Activating ChatGPT (From Beginner to Advanced in Prompt Engineering)#
Preface##
Just as good search engine techniques can significantly enhance your search efficiency, some flexible communication techniques with ChatGPT can greatly enhance your ability to use AI.
I divide the learning of these techniques into three stages:
-
Learning basic principles
-
Learning how to structure prompts
-
Exploring how to let GPT assist you in writing prompts
Below, I will explain these three stages in detail.
Basic Principles##
There are two basic principles: 1. Be as clear as possible 2. Encourage GPT to think more
Clarity##
The essence of GPT is making probabilistic inferences; the more information it has, the more accurate it becomes. In an extreme case, if you say "one" to ChatGPT, it will be confused, as it doesn't know what you are trying to express and cannot infer anything.
Suppose you want to know how to make authentic Sichuan Mapo Tofu. Previously, if you searched for "Mapo Tofu" on Google, the search engine would show you many recipe websites based on keywords. You could easily find the method by clicking on a few results on the first page.
However, if you directly tell the chatbot "Mapo Tofu," it may not accurately understand your needs. The chatbot might provide some answers unrelated to the actual method. In contrast, if you describe in detail: "Please provide a recipe for authentic Sichuan Mapo Tofu, including required ingredients, steps, tips, etc., and give explanations after each step, finally summarizing the taste characteristics of the dish," then the chatbot can accurately understand your needs and provide a specific and useful recipe.
This indicates that when using a chatbot, clear and specific descriptions are necessary rather than simple keywords to obtain high-quality answers. This is quite different from using search engines. Clear expression can help the chatbot better understand the needs, thus providing better responses. While ensuring a lower limit on output quality, it can also raise the upper limit of output quality!
This is completely different from past experiences with search engines like Google.
Encouraging GPT to Think More##
Encouraging GPT to think more means prompting GPT to reason rather than just answer directly.
Adding a requirement for step-by-step reasoning in the prompt allows the language model to spend more time on logical thinking, resulting in more reliable and accurate outputs. For example, in an official OpenAI example, if you need GPT to determine whether a student's answer is correct, the prompt is to judge whether the student's solution is correct. When faced with complex calculation problems and answers, GPT has a high probability of giving incorrect answers because it does not reason through the answer like a human before responding; it gives a judgment immediately. In a brief judgment, it cannot provide the correct answer (just as humans cannot quickly calculate complex math). Changing the prompt to: first solve the problem yourself, then compare your solution with the student's solution and evaluate whether the student's solution is correct. Do not determine whether the student's solution is correct before solving the problem yourself. Providing clear guidance and conditions in the prompt allows the GPT model to spend more time deriving the answer, thus achieving more accurate results.
Another effective method is to guide the GPT model to break a complex task into multiple simpler sub-tasks and complete them one by one.
This task decomposition method involves first dividing a large, complex task into several smaller, more manageable sub-tasks. Next, we guide the GPT model to focus on the reasoning process for each sub-task. After completing all sub-tasks, the results of each part are combined to form a comprehensive final result. The advantage of this method is that it allows the GPT model to concentrate more on each sub-task, effectively improving the accuracy and quality of the output.
Some Ready-to-Use, Performance-Enhancing Prompts##
The following phrases can be added to the end of any conversation to improve GPT's responses to some extent.
PS (Plan and Solve): Let's first understand the problem and devise a plan to solve the problem. Then, let's carry out the plan and solve the problem step by step.
PS+ (Plan and Solve): Let's first understand the problem, extract relevant variables and their corresponding numerals, and make a plan. Then, let's carry out the plan, calculate intermediate variables (pay attention to correct numerical calculation and commonsense), solve the problem step by step, and show the answer.
APE (Automatic Prompt Engineer): Let's work this out in a step-by-step way to be sure we have the right answer.
OPRO (Optimization by Prompting): Take a deep breath and work on this problem step-by-step.
A little bit of arithmetic and a logical approach will help us quickly arrive at the solution to this problem.
Let's combine our numerical command and clear thinking to quickly and accurately decipher the answer.
Structured Prompts##
When you want ChatGPT to accomplish more complex tasks, you need more complex prompts. So how do you write complex prompts? You can use the following structured prompt techniques.
What is structuring? Taking daily reading and writing as an example. In the books we read, various grammatical elements such as titles, subtitles, paragraphs, and sentences are used, and in our own writing process, we also express ideas by dividing content into chapters and paragraphs. In short, the concept of structured prompts is similar to the writing process: it helps us express our ideas clearly and systematically through structure.
Just as we use various writing templates in daily life for ease of reading and expression, such as ancient eight-legged essays, modern resume templates, student experiment report templates, and thesis templates, these structural templates help us present content in an organized manner. Similarly, writing structured prompts can also leverage various high-quality templates, which not only makes the writing process easier but also improves the effectiveness and efficiency of the content. Therefore, choosing or creating a suitable template, just like using a PPT template, can greatly enhance the quality of structured prompts.
One of my templates is:
Explain
Background Describe the task background #### Goal Task Tell GPT what its ultimate goal is #### Implementation Strategy Tell GPT how to achieve the above goal step by step #### Output Example Provide an output example #### Limitations and Important Points Tell GPT what limitations or important points there are#
In the implementation strategy section, you can use the AOT structure:
AoT (AOT algorithm of thoughts) mimics algorithmic thinking. Achieve tasks through the following workflows.
-
Define the problem: AoT first clearly states the problem.
-
Gather information: AoT prompts the LLM to obtain necessary information.
-
Analyze information: The LLM analyzes the collected information.
-
Propose hypotheses: Propose an initial solution.
-
Test hypotheses: The LLM refutes the hypothesis and envisions potential outcomes.
-
Draw conclusions: The LLM provides a complete solution.
Based on the above principles, let's look at the example of filtering a book list:
Book List Clustering
#### Background
I have a rich book list that covers various types of books.
#### Goal Task
Please classify them based on the content and characteristics of the books. The classification should not exceed 5 categories and ensure accuracy.
#### Implementation Strategy
take a deep breath and think step by step:
-
-
Identify possible book types and preliminarily classify them based on titles.
-
For each book, gather relevant summaries or content information.
-
Further classify the books based on the collected information.
-
Assess whether the books in each category have similar themes or content.
-
If books in a category are not sufficiently similar, consider further subdividing or adjusting the classification.
-
Finally, confirm that the books in each category are similar and label relevant keywords.
-
#### Limitations and Important Points
-
Please ensure that the classification is based on factual information, i.e., the actual content of the books.
-
Provide keywords for each category to help understand the characteristics of that category.
-
Ensure that there are no more than 5 categories.
#### The book list is as follows
Book List Filtering
#### Background
I am looking for detailed information about some books to decide whether to read them.
#### Goal Task
Please provide summaries for the following books. This will help me understand the content and characteristics of each book and assist me in making a decision.
#### Implementation Strategy
take a deep breath and think step by step:
-
-
For the provided book list, first determine the complete title and author of each book.
-
Search and collect detailed summaries for each book.
-
Simplify the collected summaries to ensure they are clear and complete.
-
Based on the information provided in the summaries, conduct a preliminary assessment of the books, including potential audience, style, themes, etc.
-
After integrating all the information, provide it to the user in the order of the book list.
-
Example
Book Title: "XXXX", Author: "AAAA":
-
-
Summary: This book describes...
-
Assessment: Suitable for readers who enjoy historical novels, with a descriptive style, focusing on...
-
#### Limitations and Important Points
-
The information provided must be based on facts.
-
If the specific content of a book is unknown, it should be directly stated that it is unknown.
-
Try to provide complete and concise summaries.
#### The book list is as follows
There is much more content to explore in structured prompts; interested friends can follow Li Jigang on Jike or refer to LangGPT.
Let GPT Help You Complete Prompts##
The real change is that you can teach GPT how to write prompts, allowing it to help you complete this task.
You can feed all the above techniques to GPT, turning it into a prompt writing expert. In this mode, you only need to provide a draft of a prompt, and GPT can automatically optimize it. This means that with a simple initial input, GPT can use the techniques it has learned to help you refine and enhance the quality of the prompt.
Specifically, the advantages of this method include:
-
Improving Prompt Quality: A well-trained GPT can write prompts based on best practices, ensuring structural completeness and maximizing the potential of the GPT model.
-
Saving Energy and Time: This method automates the originally tedious prompt writing process, allowing users to avoid starting from scratch in constructing the framework of the prompt, greatly saving time and energy.
-
Facilitating Iteration and Optimization: With GPT's assistance, users can quickly iterate and optimize versions of prompts, evaluate effectiveness, and choose the best template, thus easily achieving optimization.
-
Wide Adaptability: GPT can learn and master prompt writing techniques for different fields and tasks, easily adapting to new requirements.
Conclusion##
From the above content, we can see three levels of efficient communication with ChatGPT:
-
Understanding Basic Principles: This is the foundation of using ChatGPT, emphasizing clarity and prompting GPT to think deeply. Through vivid and illustrative analogies, we can better understand and apply these principles.
-
Mastering Structured Prompt Techniques: At this level, we learn how to use frameworks such as background, goals, strategies, and limitations to guide GPT in effectively solving complex problems.
-
Utilizing GPT to Assist in Prompt Writing: This represents a higher level of interaction with ChatGPT, achieving the goal of automatically generating high-quality prompts and reducing repetitive labor.
By gradually delving into these three levels, we can establish a more efficient and rich collaborative relationship with ChatGPT, fully leveraging its immense potential to create more value.