You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -19,27 +19,26 @@ GPT-3, GPT-3.5, and GPT-4 models from OpenAI are prompt-based. With prompt-based
19
19
20
20
While these models are extremely powerful, their behavior is also very sensitive to the prompt. This makes prompt construction an important skill to develop.
21
21
22
-
Prompt construction can be difficult. In practice, the prompt acts to configure the model weights to complete the desired task, but it's more of an art than a science, often requiring experience and intuition to craft a successful prompt. The goal of this article is to help bootstrap this learning process. It attempts to capture general concepts and patterns that apply to all GPT models. However it's important to say that each model behaves differently, so the learnings may not apply equally to all models.
22
+
Prompt construction can be difficult. In practice, the prompt acts to configure the model weights to complete the desired task, but it's more of an art than a science, often requiring experience and intuition to craft a successful prompt. The goal of this article is to help get you started with this learning process. It attempts to capture general concepts and patterns that apply to all GPT models. However it's important to understand that each model behaves differently, so the learnings may not apply equally to all models.
23
23
24
24
## Basics
25
25
26
26
This section covers the basic concepts and elements of GPT prompts.
27
27
28
-
### HELLO WORLD
28
+
### Hello World
29
29
30
-
Text prompts are how users interact with GPT models. As any generative language model does, it attempts to produce the next series of words that are most likely to follow from the previous text. It's as if we're saying *What is the first thing that comes to your mind when I say `<prompt>`?”*. The examples below demonstrate this behavior. Given the first words of famous content, the model is able to accurately continue the text.
30
+
Text prompts are how users interact with GPT models. As with all generative language model, GPT models attempt to produce the next series of words that are most likely to follow from the previous text. It's as if we're saying *What is the first thing that comes to your mind when I say `<prompt>`?”*. The examples below demonstrate this behavior. Given the first words of famous content, the model is able to accurately continue the text.
| Four score and seven years ago our | fathers brought forth on this continent, a new nation, conceived in Liberty, and dedicated to the proposition that all men are created equal. […]|
35
35
| "Call me Ishmael." | "Some years ago—never mind how long precisely—having little or money in my purse, and nothing particular no to interest me on shore, I thought I would sail about a little and see the watery part of the world." […]|
36
-
|
37
36
38
37
As you develop more complex prompts, it's helpful to keep this fundamental behavior in mind. Regardless of the prompt that is provided, the model is simply responding with what it determines is most likely (given its training data and training targets). If you ask a question in your prompt, the model isn't following a separate “Q&A” code path, but rather it appears to answer the question because an answer is the most likely sort of response given a question as input.
39
38
40
39
### Prompt components
41
40
42
-
When using the Completions API while there is no differentiation between different parts of the prompt, it can still be useful for learning and discussion to identify underlying prompt components. With the Chat Completions API there are distinct sections of the prompt that are sent to the API in the form of an array of dictionaries with associated roles: system, user, assistant. This guidance will focus more generally on how to think about prompt construction rather than providing prescriptive guidance that is specific to one API over another.
41
+
When using the Completion API while there is no differentiation between different parts of the prompt, it can still be useful for learning and discussion to identify underlying prompt components. With the Chat Completion API there are distinct sections of the prompt that are sent to the API in the form of an array of dictionaries with associated roles: system, user, assistant. This guidance will focus more generally on how to think about prompt construction rather than providing prescriptive guidance that is specific to one API over another.
43
42
44
43
It is also important to understand that while there could be other valid ways to dissect prompts, the goal of this breakdown is to provide a relatively simply way to think about prompt construction. With the Completion API, all the components are optional, but at least one must be present and most prompts include more than one component. There can be some grey area between components as well. The order presented below roughly corresponds to how commonly each component is used, from most to least.
45
44
@@ -51,12 +50,7 @@ Instructions are likely the most commonly used prompt component. Instructions ar
Simple instructions | Write an introduction for a weekly newsletter. | Welcome to our weekly newsletter. This week we have a special focus on productivity. We'll be sharing tips and tricks on how to be productive in all areas of your life. We hope you enjoy and please share with your friends! |
53
52
| Complex instructions | Write an introduction for a weekly newsletter to my company named Contoso. It should mention the great all hands meeting we had last week and thank the team for all their hard work over the tough past few months. | Complex Instructions Write an introduction for a weekly newsletter to my company named Contoso. It should mention the great all hands meeting we had last week and thank the team for all their hard work over the tough past few months. Welcome to Contoso's weekly newsletter! We had a great all hands meeting last week and I want to thank the team for all their hard work over the tough past few months. We're looking forward to a bright future and I'm confident that with our team's dedication and commitment, we will achieve great things. Thank you for being a part of our team and I look forward to working with you all in the coming weeks and months. Sincerely, [Your name]. |
54
-
| Complex Instructions | Write an introduction for a weekly newsletter, including the following:
55
-
- My company is named contoso
56
-
- An exuberant greeting
57
-
- Thanking the team for their hard work over a couple tough months
58
-
- Positive outlook for the coming quarter
59
-
- Signed by the SLT Hello Contoso team! I wanted to take a moment to thank you for all your hard work over the past few months. It's been a tough couple of months, but you've all pulled together and done an amazing job. I'm really proud of you all. Looking ahead to the next quarter, I'm feeling really positive. I think we're going to achieve some great things. Thanks again, The Senior Leadership Team. | Hello Contoso team! I wanted to take a moment to thank you for all your hard work over the past few months. It's been a tough couple of months, but you've all pulled together and done an amazing job. I'm really proud of you all. Looking ahead to the next quarter, I'm feeling really positive. I think we're going to achieve some great things. Thanks again, The SLT.|
53
+
| Complex Instructions | Write an introduction for a weekly newsletter, including the following: <br>- My company is named contoso <br>- An exuberant greeting <br>- Thanking the team for their hard work over a couple tough months <br>- Positive outlook for the coming quarter<br>- Signed by the SLT | Hello Contoso team! I wanted to take a moment to thank you for all your hard work over the past few months. It's been a tough couple of months, but you've all pulled together and done an amazing job. I'm really proud of you all. Looking ahead to the next quarter, I'm feeling really positive. I think we're going to achieve some great things. Thanks again, The Senior Leadership Team.|
60
54
61
55
### Primary Content
62
56
@@ -66,7 +60,7 @@ Primary content refers to some sort of text that is being processed or transform
66
60
|--------|-----------|
67
61
| Can you please tell me how to get to the museum? \nTranslate to French: |`Pouvez-vous s'il vous plaît me dire comment aller au musée?`|
68
62
69
-
Primary content can also be much longer. The following example the primary content is the introduction section from the [Wikipedia entry on time complexity](https://en.wikipedia.org/wiki/Time_complexity), which is almost 300 words long (clipped for display purposes here).
63
+
Primary content can also be much longer. The following example the primary content is the introduction section from the [Wikipedia entry on time complexity](https://en.wikipedia.org/wiki/Time_complexity), which is almost 300 words long. This content has been abbreviated in our table for ease of display.
70
64
71
65
| Prompt | Completion|
72
66
|--------|-----------|
@@ -77,12 +71,11 @@ GPT models can also handle primary content that is structured. In the example be
77
71
78
72
| Prompt | Completion |
79
73
|--------|------------|
80
-
| Belgian Beer Brands <br>Beer name Beer style color ABV Brewery<br>`"Chimay Gold: ""Doree""" trappist pale ale gold 4.80% Chimay Brewery (official trappist)`<br>`"Chimay Blue: ""Grande Reserve""" trappist dark ale dark 9.00%`<br>[…]
81
-
<br>Referencing the table above, how many beers are less than 6% ABV? | There are 10 beers in the table that are less than 6% ABV. |
74
+
| Belgian Beer Brands <br>Beer name Beer style color ABV Brewery<br>`"Chimay Gold: ""Doree""" trappist pale ale gold 4.80% Chimay Brewery (official trappist)`<br>`"Chimay Blue: ""Grande Reserve""" trappist dark ale dark 9.00%`<br>[…]<br>Referencing the table above, how many beers are less than 6% ABV? | There are 10 beers in the table that are less than 6% ABV. |
82
75
83
76
### Examples
84
77
85
-
Successful prompts often rely on the practice of “one-shot” or “few-shot” learning. This refers to the inclusion of one or more examples of the desired behavior of the model, typically by including input and output pairs. This is not learning in the sense that the model is permanently changed, but rather that the examples better condition the model to respond as desired for only the current inference. The use of prompts with no examples is sometimes referred to as “zero-shot” learning. Please note that with the Chat Completions API few-shot learning examples are typically added to the messages array in the form of example user/assistant interactions after the initial system message.
78
+
Successful prompts often rely on the practice of “one-shot” or “few-shot” learning. This refers to the inclusion of one or more examples of the desired behavior of the model, typically by including input and output pairs. This is not learning in the sense that the model is permanently changed, but rather that the examples better condition the model to respond as desired for only the current inference. The use of prompts with no examples is sometimes referred to as “zero-shot” learning. Please note that with the Chat Completion API few-shot learning examples are typically added to the messages array in the form of example user/assistant interactions after the initial system message.
@@ -95,9 +88,9 @@ The example above illustrates the utility of few-shot learning. Without the exam
95
88
96
89
Cues act as the “jumpstart” for the output the model, helping to direct the model to the desired output. It is often a prefix that model can build onto. In the example below, we show the cue directing the story to include key elements. Cues are often used along with instructions, but not always. In the examples below, the model is being used to summarize a long announcement email. A cue is used in one case to help focus the output of model and to suggest a specific output format (bullet points) in the other.
97
90
98
-
In the context of the Chat Completions API instructions take the form of the system message, and few-shot examples are indicated by providing a series of example user/assistant interactions to help prime the model.
91
+
In the context of the Chat Completion API instructions take the form of the system message, and few-shot examples are indicated by providing a series of example user/assistant interactions to help prime the model.
99
92
100
-
|# of Cues|Prompt | Completion|
93
+
|Number of Cues|Prompt | Completion|
101
94
|----------|-------|-----------|
102
95
| 0 | Performance reviews are a core component of our Performance & Development approach at Contoso. […] <br> Summarize the above email message: | The purpose of this email is to inform employees of recent changes to the performance review experience, which is part of Contoso's Performance & Development approach. The changes include an improved structure, upgraded in-tool user experience, and focused prompts. Additionally, there is now an optional Conversation Starters section for employees to flag topics they'd like to discuss with their managers. |
103
96
| 1 | Performance reviews are a core component of our Performance & Development (P&D) approach at Contoso. […] <br> Summarize the above email message:<br> The key takeaway of the message is | that Contoso is improving the performance review experience by making it more focused on core priorities, expectations and impact. Additionally, they are upgrading the in-tool user experience with tips, resources and guidance. Finally, they are adding guidance on how to activate company-wide core priorities. |
0 commit comments