The most complete guide! OpenAI releases GPT-4 usage guide, all the useful information is here

Since its birth, ChatGPT has been promoted to the altar of generative AI by countless people with its epoch-making innovation.

We always expect it to accurately understand our intentions, but we often find that its answers or creations are not 100% in line with our expectations. This gap may stem from our excessive expectations for model performance, or our failure to find the most effective communication channel when using it.

Just as explorers need time to adapt to new terrain, our interaction with ChatGPT also requires patience and skills. Previously, OpenAI officially released the GPT-4 usage guide Prompt engineering, which recorded six strategies for controlling GPT-4.

I believe that with it, your communication with ChatGPT will be smoother in the future.

Let’s briefly summarize these six strategies:

  • Write clear instructions
  • Provide reference text
  • Split complex tasks into simpler subtasks
  • Give the model time to "think"
  • Use external tools
  • Systematically test changes

Write clear instructions

Describe detailed information

ChatGPT cannot judge our implicit thoughts, so we should inform you of your requirements as clearly as possible, such as the length of the reply, the level of writing, the output format, etc.

The less we let ChatGPT guess and infer our intentions, the more likely it is that the output will meet our requirements. For example, when we ask him to write a psychology paper, the prompt words given should look like this

Please help me write a psychology paper about "The Causes and Treatment of Depression". Requirements: I need to search relevant literature and cannot plagiarize or plagiarize; I need to follow the academic paper format, including abstract, introduction, body, conclusion, etc.; The word count is 2000 words or more.

Let the model play a role

There are specializations in the industry, and the designated model plays a specialized role, and the content it outputs will appear more professional.

For example: Please play a police detective novelist and use Conan-style reasoning to describe a bizarre murder case. Requirements: Anonymous treatment is required, the word count is more than 1,000 words, and the plot has ups and downs.

Use delimiters to clearly divide different sections

Delimiters such as triple quotes, XML tags, and section titles can help divide text sections that need to be treated differently and help the model better disambiguate.

Specify the steps required to complete the task

Breaking some tasks into a series of clearly defined steps makes it easier for the model to execute these steps.

Provide examples

It is often more effective to provide a general explanation that applies to all examples than to demonstrate by example, but in some cases it may be easier to provide examples.

For example, if I tell the model that to learn to swim, all it takes is kicking its legs and swinging its arms, that's a general statement. And if I show the model a video of swimming, showing the specific movements of kicking and swinging the arms, that is explained through examples.

Specify output length

We can tell the model how long we want the output it generates to be, and this length can be counted in terms of words, sentences, paragraphs, bullet points, etc.

Limited by the internal mechanism of the model and the complexity of the language, it is best to divide it according to paragraphs and key points, so that the effect will be better.

Provide reference text

Have the model answer using reference text

If we have more reference information on hand, we can "feed" it to the model and let the model use the provided information to answer.

Have the model cite the reference text to answer

If the input already contains relevant knowledge documents, users can directly ask the model to add references to its answers by citing passages in the document, minimizing the possibility of the model talking nonsense.

In this case, the citations in the output can also be verified programmatically by matching strings in the supplied document to confirm the accuracy of the citation.

Split complex tasks into simpler subtasks

Use intent classification to identify instructions most relevant to user queries

When dealing with tasks that require many different operations, we can use a smarter approach. First, break the problem into different types and see what operations each type requires. It's like when we organize things, we put similar things together first.

Then, we can define some standard operations for each type, just like labeling each type of thing. In this way, some common steps can be defined in advance, such as search, comparison, understanding, etc.

This processing method can be advanced layer by layer. If we want to ask more specific questions, we can further refine it based on previous operations.

The advantage of this is that each time you answer a user question, you only need to perform the operations required for the current step, rather than doing the entire task at once. Not only does this reduce the chance of error, it also saves time, since completing the entire task at once can be costly.

For application scenarios that need to handle long conversations, summarize or filter previous conversations

When the model processes dialogue, it is limited by the fixed context length and cannot remember all the dialogue history.

One way to solve this problem is to summarize the previous conversation. When the length of the input conversation reaches a certain limit, the system can automatically summarize the previous chat content and display part of the information as a summary, or it can While this is going on, the previous chat content is quietly summarized in the background.

Another solution is to dynamically select the parts of the conversation that are most relevant to the current issue while working on it. This approach involves a strategy called "efficient knowledge retrieval using embedding-based search."

To put it simply, it is to find the relevant parts of the previous conversation based on the content of the current question. This makes more effective use of previous information and makes the conversation more focused.

Summarize long documents segmentally and recursively build a full summary

Since the model can only remember limited information, it cannot be directly used to summarize very long texts. In order to summarize long documents, we can use a step-by-step summary method.

Just like when we read a book, we can summarize each section by asking questions chapter after chapter. The summaries of each section can be strung together to form a summary of the entire document. This process can be recursive layer by layer until the entire document is summarized.

If you need to understand what follows, you may need to use the previous information. Another useful tip in this case is to look at the abstract before reading to a certain point and get an idea of ​​what that point is about.

Give the model time to "think"

Instruct the model to come up with its own solution before rushing to conclusions

In the past, we might directly ask the model to look at the student's answer, and then ask the model whether the answer is correct. However, sometimes the student's answer is wrong. If the model is directly asked to judge the student's answer, it may not be accurate.

In order to make the model more accurate, we can first let the model do this math problem by itself and calculate the model's own answer first. Then let the model compare the student's answers with the model's own answers.

By letting the model do the calculations by itself first, it will be easier for it to determine whether the student's answer is correct. If the student's answer is different from the model's own answer, it will know that the student answered incorrectly. This allows the model to start thinking from the most basic first step, rather than directly judging the student's answer, which can improve the model's judgment accuracy.

Use inner monologue to hide the model’s reasoning process

Sometimes when answering a specific question it is important for the model to reason about the problem in detail. However, for some application scenarios, the model's inference process may not be suitable for sharing with users.

To solve this problem, there is a strategy called internal monologue. The idea of ​​this strategy is to tell the model to organize part of the output that the user does not want to see into a structured form, and then display only part of it, not all, when presented to the user.

For example, suppose we are teaching a certain subject and need to answer students' questions. If we directly tell the students all the reasoning ideas of the model, the students will not have to think about it themselves.

Therefore, we can use the "inner monologue" strategy: first let the model think about the problem completely by itself, think through all the solution ideas, and then only select a small part of the model's ideas and tell the students in simple language.

Or we can design a series of questions: first let the model think about the entire solution by itself, without allowing students to answer, and then give students a simple similar question based on the model's ideas. After the students answer, let the model judge whether the students' answers are correct. wrong.

Finally, the model uses easy-to-understand language to explain the correct solution ideas to the students. This not only trains the model's reasoning ability, but also allows the students to think for themselves without telling them all the answers directly.

Ask the model if it missed anything in the previous pass

Suppose we ask the model to find sentences related to a certain question from a large file, and the model will tell us one sentence at a time.

But sometimes the model makes a misjudgment and stops when it should continue looking for related sentences, resulting in related sentences being missed and not told to us later.

At this time, we can remind the model "Are there any other related sentences?", and then it will continue to query related sentences, so that the model can find more complete information.

Use external tools

Efficient knowledge retrieval using embedding-based search

If we add some external information to the model's input, the model can answer questions more intelligently. For example, if a user asks a question about a certain movie, we can input some important information about the movie (such as actors, directors, etc.) into the model so that the model can give smarter answers.

Text embedding is a vector that measures the relationship between texts. Similar or related text vectors are closer, while unrelated text vectors are relatively far away, which means we can leverage embeddings for efficient knowledge retrieval.

Specifically, we can cut the text corpus into chunks and embed and store each chunk. We can then embed a given query and find the most relevant embedded text chunk in the corpus (i.e. the text chunk that is closest to the query in the embedding space) via vector search.

Use code execution for more accurate calculations or calling external APIs

Language models are not always able to accurately perform complex mathematical operations or calculations that take a long time. In this case, we can tell the model to write some code to complete the task, rather than letting it do the calculations on its own.

Specifically, we can instruct the model to write the code that needs to be run in a certain format, such as surrounding it with triple backticks. When the code generates results, we can extract them and execute them.

Finally, if desired, the output of a code execution engine (such as the Python interpreter) can be used as input to the next question in the model. This enables tasks that require calculations to be completed more efficiently.

Another great example of using code execution is using external APIs (Application Programming Interfaces). If we tell the model how to use an API correctly, it can write code that calls that API.

We can provide the model with some documentation or code examples showing how to use the API, so that the model can be guided to learn how to utilize the API. Simply put, by providing the model with some guidance about the API, it can create code to achieve more functions.

Warning: Executing code generated by a model is inherently unsafe and any application attempting to do so should take precautions. In particular, sandboxed code execution environments are needed to limit the potential harm that untrusted code can cause.

Let the model provide specific functionality

We can pass it a list describing the functionality through an API request. In this way, the model is able to generate function parameters based on the provided pattern. The generated function parameters are returned in JSON format, which we then use to perform the function call.

Then, a loop can be implemented by feeding the output of the function call back to the model in the next request. This is the recommended way to call external functions using the OpenAI model.

Systematically test changes

When we make changes to a system, it is difficult to judge whether the changes are good or bad. Because there are so few examples, it is difficult to determine whether the results are truly improved or just a matter of luck. Sometimes a modification is good in some situations and bad in others.

So how do we evaluate the quality of system output? If there is only one standard answer to a question, the computer can automatically determine whether it is right or wrong. If there is no standard answer, other models can be used to judge quality.

In addition, we can also let humans evaluate the subjective quality, or combine computer and human evaluation. When the answer to the question is very long, and the quality of different answers does not differ much, then the model can evaluate the quality by itself.

Of course, as models become more advanced, more and more content can be automatically evaluated, and less and less manual evaluation is required. It is very difficult to improve the evaluation system, and combining computers and artificial intelligence is the best method.

Evaluate model output against gold standard answers

Suppose we are faced with a problem and need an answer. We already know the correct answer to this question, based on some facts. For example, the question is "Why is the sky blue?" The correct answer may be "Because when sunlight passes through the atmosphere, the light in the blue light band passes better than other colors."

This answer is based on the following facts:
Sunlight contains different colors (light bands)
The blue light band has less loss when passing through the atmosphere

After we have the question and the correct answer, we can use a model (such as a machine learning model) to judge the importance of each fact in the answer to the correct answer.

For example, the model determines that the fact that "sunlight contains different colors" in the answer is very important for the correctness of the answer. The fact that "the blue light band has less loss" is also important to the answer. This way we can know what key known facts the answer to this question depends on.

In the process of human-machine communication with ChatGPT, prompt words seem simple, but they are the most critical existence. In the digital age, prompt words are the starting point for splitting requirements. By designing clever prompt words, we can split the entire task. Divided into a series of concise steps.

Such decomposition not only helps the model better understand the user's intention, but also provides the user with a clearer operation path, just like giving a clue to guide us step by step to uncover the answer to the problem.

Your and my needs are like a surging river, and the prompt word is like a sluice that regulates the direction of the flow. It plays the role of a hub, connecting the user's thinking and the machine's understanding. It is no exaggeration to say that a good prompt word is not only an insight into the user's deep understanding, but also a tacit understanding of human-machine communication.

Of course, if you want to truly master the skills of using prompt words, it is not enough to rely on Prompt engineering alone, but OpenAI's official usage guide always provides us with valuable introductory guidance.

# Welcome to follow the official WeChat public account of aifaner: aifaner (WeChat ID: ifanr). More exciting content will be provided to you as soon as possible.

Ai Faner | Original link · View comments · Sina Weibo