|
1 | 1 | ---
|
2 |
| -title: Prompt engineering techniques with Azure OpenAI |
| 2 | +title: Design system messages with Azure OpenAI |
3 | 3 | titleSuffix: Azure OpenAI Service
|
4 |
| -description: Learn about the options for how to use prompt engineering with GPT-3, GPT-35-Turbo, and GPT-4 models. |
| 4 | +description: Learn about system message design with GPT-3, GPT-35-Turbo, and GPT-4 models. |
5 | 5 | author: mrbullwinkle
|
6 | 6 | ms.author: mbullwin
|
7 | 7 | ms.service: azure-ai-openai
|
8 | 8 | ms.topic: conceptual
|
9 | 9 | ms.date: 09/05/2024
|
10 | 10 | manager: nitinme
|
11 |
| -keywords: ChatGPT, GPT-4, prompt engineering, meta prompts, chain of thought |
12 |
| -zone_pivot_groups: openai-prompt |
| 11 | +keywords: ChatGPT, GPT-4, meta prompts, chain of thought |
13 | 12 | ---
|
14 | 13 |
|
15 |
| -# Prompt engineering techniques |
| 14 | +# System message design |
16 | 15 |
|
17 |
| -This guide will walk you through some advanced techniques in prompt design and prompt engineering. If you're new to prompt engineering, we recommend starting with our [introduction to prompt engineering guide](prompt-engineering.md). |
| 16 | +This guide will walk you through some techniques in system message design. |
18 | 17 |
|
19 |
| -While the principles of prompt engineering can be generalized across many different model types, certain models expect a specialized prompt structure. For Azure OpenAI GPT models, there are currently two distinct APIs where prompt engineering comes into play: |
20 | 18 |
|
21 |
| -- Chat Completion API. |
22 |
| -- Completion API. |
23 | 19 |
|
24 |
| -Each API requires input data to be formatted differently, which in turn impacts overall prompt design. The **Chat Completion API** supports the GPT-35-Turbo and GPT-4 models. These models are designed to take input formatted in a [specific chat-like transcript](../how-to/chatgpt.md) stored inside an array of dictionaries. |
| 20 | +## What is a system message? |
25 | 21 |
|
26 |
| -The **Completion API** supports the older GPT-3 models and has much more flexible input requirements in that it takes a string of text with no specific format rules. |
| 22 | +A system message is a feature-specific set of instructions or contextual frameworks given to a generative AI model (e.g. GPT4-o, GPT3.5 Turbo, etc.) to direct and improve the quality and safety of a model’s output. This is particularly helpful in situations that need certain degrees of formality, technical language, or industry-specific terms. |
27 | 23 |
|
28 |
| -The techniques in this guide will teach you strategies for increasing the accuracy and grounding of responses you generate with a Large Language Model (LLM). It is, however, important to remember that even when using prompt engineering effectively you still need to validate the responses the models generate. Just because a carefully crafted prompt worked well for a particular scenario doesn't necessarily mean it will generalize more broadly to certain use cases. Understanding the [limitations of LLMs](/legal/cognitive-services/openai/transparency-note?context=/azure/ai-services/openai/context/context#limitations), is just as important as understanding how to leverage their strengths. |
29 | 24 |
|
30 |
| -::: zone pivot="programming-language-chat-completions" |
| 25 | +There is no prescribed length. A system message can be one short sentence: |
31 | 26 |
|
32 |
| -[!INCLUDE [Prompt Chat Completion](../includes/prompt-chat-completion.md)] |
| 27 | +``` |
| 28 | +You are a helpful AI assistant. |
| 29 | +``` |
33 | 30 |
|
34 |
| -::: zone-end |
| 31 | +A system message can also be *many* lines long, containing detailed rules, detailed context, formatting and output guidelines, and responsible AI (RAI) mitigations. |
35 | 32 |
|
36 |
| -::: zone pivot="programming-language-completions" |
| 33 | +## System message examples |
| 34 | + |
| 35 | +The system message is included at the beginning of the prompt and is used to prime the model with context, instructions, or other information relevant to your use case. You can use the system message to describe the assistant’s personality, define what the model should and shouldn’t answer, and define the format of model responses. |
| 36 | + |
| 37 | +The example below, shows a sample system message and the resulting model response: |
| 38 | + |
| 39 | +| System message |User | Assistant | |
| 40 | +|----------------|---------|------------| |
| 41 | +| You're an AI assistant that helps people find information and responds in rhyme. If the user asks you a question you don't know the answer to, say so. | What can you tell about me, John Doe? | Dear John, I'm sorry to say,<br>But I don't have info on you today.<br>I'm just an AI with knowledge in my brain,<br>But without your input, I can't explain.<br>So please tell me more about what you seek,<br>And I'll do my best to give you an answer unique.| |
| 42 | + |
| 43 | +Some other examples of system messages are: |
| 44 | +- “Assistant is a large language model trained by OpenAI.” |
| 45 | +- “Assistant is an intelligent chatbot designed to help users answer technical questions about Azure OpenAI Service. Only answer questions using the context below and if you're not sure of an answer, you can say "I don't know". |
| 46 | +- “Assistant is an intelligent chatbot designed to help users answer their tax related questions.” |
| 47 | +- “You're an assistant designed to extract entities from text. Users will paste in a string of text and you'll respond with entities you've extracted from the text as a JSON object. Here's an example of your output format: |
| 48 | + |
| 49 | +```json |
| 50 | +{ |
| 51 | + "name": "", |
| 52 | + "company": "", |
| 53 | + "phone_number": "" |
| 54 | +} |
| 55 | +``` |
| 56 | + |
| 57 | +An important detail to understand is that even if you instruct a model in the system message to answer **I don't know** when unsure of an answer this doesn't guarantee that the request will be honored. A well designed system message can increase the likelihood of a certain outcome, but it's still possible that an incorrect response could be generated that contradicts the intent of the instruction in the system message. |
37 | 58 |
|
38 |
| -[!INCLUDE [Prompt Completion](../includes/prompt-completion.md)] |
39 | 59 |
|
40 |
| -::: zone-end |
|
0 commit comments