Skip to content

Commit 09b9f18

Browse files
committed
small fixes
1 parent e35381b commit 09b9f18

File tree

1 file changed

+11
-18
lines changed

1 file changed

+11
-18
lines changed

articles/cognitive-services/openai/concepts/prompt-engineering.md

Lines changed: 11 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ ms.topic: conceptual
77
ms.date: 03/21/2023
88
ms.custom: event-tier1-build-2022, references_regions
99
manager: nitinme
10-
author: mbullwinkle
10+
author: mrbullwinkle
1111
ms.author: mbullwin
1212
recommendations: false
1313
keywords:
@@ -19,27 +19,26 @@ GPT-3, GPT-3.5, and GPT-4 models from OpenAI are prompt-based. With prompt-based
1919

2020
While these models are extremely powerful, their behavior is also very sensitive to the prompt. This makes prompt construction an important skill to develop.
2121

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.
2323

2424
## Basics
2525

2626
This section covers the basic concepts and elements of GPT prompts.
2727

28-
### HELLO WORLD
28+
### Hello World
2929

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.
3131

3232
| Prompt |Completion |
3333
|------------------------------------|-----------|
3434
| 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. []|
3535
| "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-
|
3736

3837
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.
3938

4039
### Prompt components
4140

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.
4342

4443
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.
4544

@@ -51,12 +50,7 @@ Instructions are likely the most commonly used prompt component. Instructions ar
5150
|--------------------------------|---------------|--------------|
5251
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! |
5352
| 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.|
6054

6155
### Primary Content
6256

@@ -66,7 +60,7 @@ Primary content refers to some sort of text that is being processed or transform
6660
|--------|-----------|
6761
| 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?` |
6862

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.
7064

7165
| Prompt | Completion|
7266
|--------|-----------|
@@ -77,12 +71,11 @@ GPT models can also handle primary content that is structured. In the example be
7771

7872
| Prompt | Completion |
7973
|--------|------------|
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. |
8275

8376
### Examples
8477

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.
8679

8780
| Learning Type| Prompt| Completion|
8881
|------------------------------------- |-------|-----------|
@@ -95,9 +88,9 @@ The example above illustrates the utility of few-shot learning. Without the exam
9588

9689
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.
9790

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.
9992

100-
| # of Cues|Prompt | Completion|
93+
| Number of Cues|Prompt | Completion|
10194
|----------|-------|-----------|
10295
| 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. |
10396
| 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

Comments
 (0)