# data[].attributes.body
Given this table copied from a PDF, convert it into a format that can be pasted into Excel: The columns are: Country or area, City, Statistical Concepts, 2000 population, 2016 population, 2030 population, 2000-2016 rate of change, 2016-2030 rate of change, City population as a proportion of total population in 2016, City population as a proportion of urban population in 2016 Cambodia Phnum Pénh (Phnom Penh) Urban Agglomeration 1 149 1 779 2 584 2.7 2.7 11.2 53.3 Indonesia Bandung City Proper 2 138 2 578 3 433 1.2 2.0 1.0 1.8 Indonesia Batam City Proper 415 1 498 2 486 8.0 3.6 0.6 1.1 Indonesia Bogor City Proper 751 1 102 1 541 2.4 2.4 0.4 0.8 Indonesia Denpasar City Proper 409 1 177 1 870 6.6 3.3 0.5 0.8 Indonesia Jakarta City Proper 8 390 10 483 13 812 1.4 2.0 4.1 7.4 Indonesia Makassar (Ujung Pandang) City Proper 1 077 1 522 2 104 2.2 2.3 0.6 1.1 Indonesia Medan City Proper 1 912 2 230 2 955 1.0 2.0 0.9 1.6 Indonesia Palembang City Proper 1 459 1 460 1 888 0.0 1.8 0.6 1.0 Indonesia Pekan Baru City Proper 588 1 168 1 731 4.3 2.8 0.5 0.8 Indonesia Semarang City Proper 1 427 1 648 2 188 0.9 2.0 0.6 1.2 Indonesia Surabaya City Proper 2 611 2 878 3 760 0.6 1.9 1.1 2.0 Lao People’s Dem. Republic Vientiane Urban Agglomeration 442 1 050 1 782 5.4 3.8 14.7 37.0 Malaysia Kuala Lumpur Metropolitan area 4 176 7 047 9 423 3.3 2.1 22.7 30.1 Myanmar Mandalay Urban Agglomeration 810 1 196 1 654 2.4 2.3 2.2 6.3 Myanmar Nay Pyi Taw City Proper — 1 045 1 398 .. 2.1 1.9 5.5 Myanmar Yangon Urban Agglomeration 3 553 4 904 6 578 2.0 2.1 9.0 25.9 Philippines Davao City City Proper 1 152 1 662 2 216 2.3 2.1 1.6 3.6 Philippines Manila Urban Agglomeration 9 962 13 131 16 756 1.7 1.7 12.7 28.6 Singapore Singapore Urban Agglomeration 3 918 5 717 6 578 2.4 1.0 100.0 100.0 Thailand Krung Thep (Bangkok) Metropolitan area 6 360 9 444 11 528 2.5 1.4 14.0 27.1 Thailand Samut Prakan City Proper 389 1 980 3 139 10.2 3.3 2.9 5.7 Viet Nam Can Tho City Proper 439 1 242 1 902 6.5 3.0 1.3 3.9 Viet Nam Hà Noi Urban Agglomeration 1 660 3 790 5 498 5.2 2.7 4.0 11.8 Viet Nam Hai Phòng Urban Agglomeration 599 1 110 1 569 3.9 2.5 1.2 3.4 Viet Nam Thành Pho Ho Chí Minh (Ho Chi Minh City) Urban Agglomeration 4 389 7 498 10 200 3.3 2.2 8.0 23.3

# data[].attributes.attachment_link.title
01 Introduction to Generative AI (3.5 hrs)

# data[].attributes.headline
2. Keen to know how to use AI/ML in finance dashboarding, summarising reports, eliminate mundane finance tasks

# data[].attributes.subject
2. Keen to know how to use AI/ML in finance dashboarding, summarising reports, eliminate mundane finance tasks

# data[].attributes.body
1, interest to find out how we can leverage on it.

# data[].attributes.body
How much do I know: 1

Specific applications: No specific application. To know about any gen AI app that I can use for work

# data[].attributes.body
1

how to use chatgpt in my work

# data[].attributes.body
1, don't know anything about Generative AI. interested to find out its uses.

# data[].attributes.body
Yes v interested in leveraging on GPT AI to make work more efficient and digital transformation .

Using GPT to screen thru financial reports

# data[].attributes.body
2, am interested in everything

# data[].attributes.attachment_link.readable_text
Here are some tips to keep in mind while you are designing your prompts:

Start Simple

As you get started with designing prompts, you should keep in mind that it is really an iterative process that requires a lot of experimentation to get optimal results. Using a simple playground from OpenAI or Cohere is a good starting point.

You can start with simple prompts and keep adding more elements and context as you aim for better results. Iterating your prompt along the way is vital for this reason. As you read the guide, you will see many examples where specificity, simplicity, and conciseness will often give you better results.

When you have a big task that involves many different subtasks, you can try to break down the task into simpler subtasks and keep building up as you get better results. This avoids adding too much complexity to the prompt design process at the beginning.

The Instruction

You can design effective prompts for various simple tasks by using commands to instruct the model what you want to achieve, such as "Write", "Classify", "Summarize", "Translate", "Order", etc.

Keep in mind that you also need to experiment a lot to see what works best. Try different instructions with different keywords, contexts, and data and see what works best for your particular use case and task. Usually, the more specific and relevant the context is to the task you are trying to perform, the better. We will touch on the importance of sampling and adding more context in the upcoming guides.

Others recommend that you place instructions at the beginning of the prompt. Another recommendation is to use some clear separator like "###" to separate the instruction and context.

For instance:

Specificity

Be very specific about the instruction and task you want the model to perform. The more descriptive and detailed the prompt is, the better the results. This is particularly important when you have a desired outcome or style of generation you are seeking. There aren't specific tokens or keywords that lead to better results. It's more important to have a good format and descriptive prompt. In fact, providing examples in the prompt is very effective to get desired output in specific formats.

When designing prompts, you should also keep in mind the length of the prompt as there are limitations regarding how long the prompt can be. Thinking about how specific and detailed you should be. Including too many unnecessary details is not necessarily a good approach. The details should be relevant and contribute to the task at hand. This is something you will need to experiment with a lot. We encourage a lot of experimentation and iteration to optimize prompts for your applications.

As an example, let's try a simple prompt to extract specific information from a piece of text.

Extract the name of places in the following text. Desired format: Input: "Although these developments are encouraging to researchers, much is still a mystery. "We often have a black box between the brain and the effect we see in the periphery," says Henrique Veiga-Fernandes, a neuroimmunologist at the Champalimaud Centre for the Unknown in Lisbon. "If we want to use it in the therapeutic context, we actually need to understand the mechanism.""

Input text is obtained from this Nature article (opens in a new tab) .

Avoid Impreciseness

Given the tips above about being detailed and improving format, it's easy to fall into the trap of wanting to be too clever about prompts and potentially creating imprecise descriptions. It's often better to be specific and direct. The analogy here is very similar to effective communication -- the more direct, the more effective the message gets across.

For example, you might be interested in learning the concept of prompt engineering. You might try something like:

It's not clear from the prompt above how many sentences to use and what style. You might still somewhat get good responses with the above prompts but the better prompt would be one that is very specific, concise, and to the point. Something like:

To do or not to do?

Another common tip when designing prompts is to avoid saying what not to do but say what to do instead. This encourages more specificity and focuses on the details that lead to good responses from the model.

Here is an example of a movie recommendation chatbot failing at exactly what I don't want it to do because of how I wrote the instruction -- focusing on what not to do.

The following is an agent that recommends movies to a customer. DO NOT ASK FOR INTERESTS. DO NOT ASK FOR PERSONAL INFORMATION. Customer: Please recommend a movie based on my interests.

Here is a better prompt:

The following is an agent that recommends movies to a customer. The agent is responsible to recommend a movie from the top global trending movies. It should refrain from asking users for their preferences and avoid asking for personal information. If the agent doesn't have a movie to recommend, it should respond "Sorry, couldn't find a movie to recommend today.". Customer: Please recommend a movie based on my interests.

Some of the examples above were adopted from the "Best practices for prompt engineering with OpenAI API" article. (opens in a new tab)

# data[].attributes.attachment_link.title
General Tips for Designing Prompts | Prompt Engineering Guide

# data[].attributes.attachment_link.description
A Comprehensive Overview of Prompt Engineering

# data[].attributes.attachment_link.readable_text
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.

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:

Chat Completion API.

Completion API.

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 stored inside an array of dictionaries.

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. Technically the GPT-35-Turbo models can be used with either APIs, but we strongly recommend using the Chat Completion API for these models. To learn more, please consult our in-depth guide on using these APIs.

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, is just as important as understanding how to leverage their strengths.

This guide does not go in-depth into the mechanics behind the message structure for Chat Completions. If you aren't familiar with interacting with the ChatGPT and GPT-4 models programmatically we recommend reading our how-to guide on the Chat Completion API first.

Note

All of the examples in this section of the guide were tested against a base GPT-4 model in English. If you are reading a localized version of this article in another language, these responses represent a localized translation of the English results. To learn more about potential limitations depending on what language you are using to prompt a model, please consult our Responsible AI transparency note.

System message

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.

The example below, shows a sample system message and the resulting model response:

You are 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,
But I don't have info on you today.
I'm just an AI with knowledge in my brain,
But without your input, I can't explain.
So please tell me more about what you seek,
And I'll do my best to give you an answer unique.

Some other examples of system messages are:

"Assistant is a large language model trained by OpenAI."

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

"Assistant is an intelligent chatbot designed to help users answer their tax related questions."

"You are an assistant designed to extract entities from text. Users will paste in a string of text and you will respond with entities you've extracted from the text as a JSON object. Here's an example of your output format:

{ "name": "", "company": "", "phone_number": "" }

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 does not guarantee that the request will be honored. A well designed system message can increase the likelihood of a certain outcome, but it is still possible that an incorrect response could be generated that contradicts the intent of the instruction in the system message.

Few-shot learning

A common way to adapt language models to new tasks is to use few-shot learning. In few-shot learning, a set of training examples is provided as part of the prompt to give additional context to the model.

When using the Chat Completions API, a series of messages between the User and Assistant (written in the new prompt format), can serve as examples for few-shot learning. These examples can be used to prime the model to respond in a certain way, emulate particular behaviors, and seed answers to common questions.

Assistant is an intelligent chatbot designed to help users answer their tax related questions.
Instructions
- Only answer questions related to taxes.
- If you're unsure of an answer, you can say "I don't know" or "I'm not sure" and recommend users go to the IRS website for more information.

User - "When do I need to file my taxes by?"
Assistant - "In 2023, you will need to file your taxes by April 18th. The date falls after the usual April 15th deadline because April 15th falls on a Saturday in 2023. For more details, see https://www.irs.gov/filing/individuals/when-to-file "

User - "How can I check the status of my tax refund?"
Assistant - "You can check the status of your tax refund by visiting https://www.irs.gov/refunds "

The table above describes the basic prompt structure, but for a detailed explanation of the exact prompt format you will need to refer to the Chat Completion guide.

Non chat scenarios

While the Chat Completion API is optimized to work with multi-turn conversations, it also can be used for non chat scenarios. For example, for a sentiment analysis scenario, you might use the following prompt:

You are an assistant designed to analyze sentiment from speech data. Users will paste in a string of text and you will respond with an assessment of the response of the speaker. Rate on a scale of 1-10 (10 being highest). Explain why this rating was given.

hi thank you for calling contoso pharmacy who am i speaking with today i understand your frustration mary um can you tell me what exactly you're trying to accomplish OK uh certainly happy to check that for you one moment please i see here that you were on a generic form of lipitor is that right OK uh so i see that your doctor stopped prescribing these drugs in twenty twenty one actually OK uh yeah i'd be happy to check that for you uh because sometimes there's a gap in the system and it just doesn't get reported so let me take a look here just a moment so i'm seeing here that your doctor had these drugs prescribed to you from twenty twelve through twenty twenty one OK um yeah according to the latest records uh provided by doctor's office you're now on a different drug metformin would you like us to go ahead and fill that prescription for you for pick up a bit of form in five hundred milligrams uh you're very welcome mary please let us know if there's anything else we can do for you today.

Sentiment rating: 8
The speaker in this text seems to be polite, helpful, and patient while addressing the concerns of the customer. They take the time to check the information, provide clear explanations, and offer assistance. However, the rating is not a 10 because there is still a hint of uncertainty in some parts of the conversation, which may not convey complete confidence to the customer.

Start with clear instructions

The sequence in which information appears in the prompt matters. This is because GPT style models are built in a certain way that defines how they process the input. Our research suggests that telling the model the task you want it to do at the beginning of the prompt, before sharing additional contextual information or examples, can help produce higher-quality outputs.

Note

Although following this technique is still generally recommended, in contrast to previous model versions (GPT-3 and prior), our testing showed that the model response with ChatGPT and GPT-4 models was the same regardless of whether the technique is utilized. In the case of the below example, we see that adding the statement "Several sources ... eruption" at the beginning or the end of the prompt did not cause any change in the final model response.

Repeat instructions at the end

Models can be susceptible to recency bias, which in this context means that information at the end of the prompt might have more significant influence over the output than information at the beginning of the prompt. Therefore, it is worth experimenting with repeating the instructions at the end of the prompt and evaluating the impact on the generated response.

Prime the output

This refers to including a few words or phrases at the end of the prompt to obtain a model response that follows the desired form. For example, using a cue such as "Here's a bulleted list of key points:\n- " can help make sure the output is formatted as a list of bullet points.

You are an AI assistant that helps people find information. Answer in as few words as possible.

John Smith is married to Lucy Smith. They have five kids, and he works as a software engineer at Microsoft. What search queries should I do to fact-check this? ## One possible search query is:

"John Smith married Lucy Smith five kids software engineer Microsoft"

In the above prompt, the text One possible search query is: primes the model to produce a single output. Without this cue the model produces several search queries as output.

Add clear syntax

Using clear syntax for your prompt-including punctuation, headings, and section markers-helps communicate intent and often makes outputs easier to parse.

In the example below, separators (--- in this case) have been added between different sources of information or steps. This allows the use of --- as a stopping condition for generation. In addition, section headings or special variables are presented in uppercase to differentiate them.

If you're not sure what syntax to use, consider using Markdown or XML. The models have been trained on a lot of web content in XML and Markdown which may provide better results.

Break the task down

Large language models (LLMs) often perform better if the task is broken down into smaller steps. For example, in the search query prompt referenced earlier, the prompt can be restructured so that the model is first instructed to extract relevant facts, and then instructed to generate search queries that can be used to verify those facts.

Notice the use of clear syntax to differentiate the sections and prime the output. In this simple example, breaking the task down from one to two steps is not very dramatic, but when trying to do this for a larger piece of text with many factual claims, breaking the task down can make a significant difference.

Use of affordances

Sometimes we can get the model to use an affordance instead of relying on its own parameters for information and answers. Search, for example, can be an affordance to help mitigate against fabricated answers, and to get up-to-date information.

One simple way to use an affordance is to stop generation once the affordance calls are generated by the model, then paste the outcomes back into the prompt. Below is an example of what the follow-up call could be after doing the SEARCH calls above. Notice how we pasted the search results into the prompt and replaced the previous SEARCH calls.

Chain of thought prompting

This is a variation on the break the task down technique. Instead of splitting a task into smaller steps, in this approach the model response is instructed to proceed step-by-step and present all the steps involved. Doing so reduces the possibility of inaccuracy of outcomes and makes assessing the model response easier.

You are an AI assistant that helps people find information.

Who was the most decorated (maximum medals) individual athlete in the Olympic games that were held at Sydney? Take a step-by-step approach in your response, cite sources and give reasoning before sharing final answer in the below format: ANSWER is: <name>

Step 1: Determine the year of the Sydney Olympic games. The Sydney Olympic games were held in the year 2000.

Step 2: Find a list of individual athletes who won multiple medals in the 2000 Sydney Olympics.

According to the official website of the Olympic Games, there were several individual athletes who won multiple medals in the 2000 Sydney Olympics. Some of the notable names include:
* Ian Thorpe (Australia) - 3 gold, 2 silver, 0 bronze
* Pieter van den Hoogenband (Netherlands) - 2 gold, 0 silver, 2 bronze
* Lenny Krayzelburg (USA) - 3 gold, 0 silver, 0 bronze
* Inge de Bruijn (Netherlands) - 3 gold, 1 silver, 0 bronze

Step 3: Determine the athlete with the most medals. After reviewing the list of individual athletes who won multiple medals in the 2000 Sydney Olympics, we can see that the athlete with the most medals is Ian Thorpe from Australia, who won a total of 5 medals (3 gold and 2 silver).

Therefore, the ANSWER is: Ian Thorpe.

Specifying the output structure

Using your prompt to specify the structure of the output can have a significant impact on the nature and quality of the results. Sometimes system message inputs as "only write true facts" or "do not fabricate information" might not be adequate mitigations. Instead, asking for the model response to also include citations can help result in a reduction of the prevalence of incorrect responses.

If you instruct the model to cite the source material when it makes statements, those statements are much more likely to be grounded. Asking for citations makes it so that the model must make two errors every time it generates a response: the first error is the fabricated response, and the second is the bad citation. Note that the closer the citation is to the text it supports, the shorter the distance ahead the model needs to anticipate the citation, which suggests that inline citations are better mitigations for false content generation than citations at the end of the content.

Similarly, if you ask the model to extract factual statements from a paragraph, it may extract compound statements such as 'X is doing Y AND Z' (which may be harder to verify). This can be avoided by specifying an output structure such as (entity1, relationship, entity2).

The examples below show the use of citations and directing the model response to fit a defined structure.

Temperature and Top_p parameters

Changing the temperature parameter changes the output of the model. The temperature parameter can be set between 0 and 2. A higher value, for example 0.7 will make the output more random and produce more divergent responses, while a lower value, like. 0.2, will make the output more focused and concrete. A fictional story could be generated using a higher temperature. Whereas to generate a legal document it is recommended to use a much lower temperature. Top_probability is another parameter and is similar to Temperature in that it also controls the randomness of the model response, but it does so in a different way. The general recommendation is to alter one of these two parameters at a time, not both.

Provide grounding context

One of the most effective ways to provide reliable answers is to give the model data to draw its responses from (grounding data). If your use case relies on up-to-date, reliable information and is not purely a creative scenario, we strongly recommend providing grounding data. In general, the closer you can get your source material to the final form of the answer you want, the less work the model needs to do, which means there is less opportunity for error. Here is an example where the system is provided a recent blog describing the launch of GPT-4 in Azure OpenAI Service, and asked to name some of its early customers.

You are an AI assistant that helps people find information. You will provide answers exclusively from below text and respond in 100 words or less:
"At Microsoft, we are constantly discovering new ways to unleash creativity, unlock productivity, and uplevel skills so that more people can benefit from using AI. This is allowing our customers to ...

... thereby reducing the likelihood that the model will generate a harmful response." ¹

Answer in 100 words or less. Use bullet lists wherever possible.

Who are some of the early customers of the Azure OpenAI Service GPT-4 models?

Here are some of the early customers of the Azure OpenAI Service GPT-4 models:
- Epic Healthcare: They plan to use GPT-4 to help physicians and nurses spend less time on data entry and investigation.
- Coursera: They are using Azure OpenAI Service with GPT-4 to create a new AI-powered learning experience on their platform.
- Coca-Cola: They are using Azure OpenAI to build a knowledge hub and plan to leverage GPT-4's multimodal capabilities for marketing, advertising, public relations, and customer relations.
- Other companies of all sizes are using Azure AI to improve customer experiences, summarize long-form content, help write software, and reduce risk by predicting the right tax data.

¹ Text from Azure OpenAI GPT-4 launch blog.

Next steps

Note

All of the examples in this section of the guide were tested with the gpt-35-turbo-instruct model in English. If you are reading a localized version of this article in another language, these responses represent a localized translation of the English results. To learn more about potential limitations depending on what language you are using to prompt a model, please consult our Responsible AI transparency note.

Start with clear instructions

The sequence information is added into the prompt matters. Our research suggests that telling the model the task you want it to do at the beginning of the prompt, before sharing additional contextual information or examples, can help produce higher-quality outputs.

In the first example below, a key part of the instructions is shared only at the end, and the resulting completion is incorrect.

Your task is to verify if a statement is supported by a specific quote from the following set of snippets.
---
SNIPPETS
[1] 14 percent chance of megaquake hitting Seattle, experts say SEATTLE - There's a 14 percent chance of a magnitude 9 Cascadia earthquake hitting Seattle in the next 50 years, the U.S. Geological Survey estimates. "Unfortunately, we are unable to...

[2] Earthquake experts lay out latest outlook for Seattle's 'Really Big One'
"We say that there's approximately a 14% chance of another approximately magnitude-9 earthquake occurring in the next 50 years," said a geophysicist at the University of Washington...

Yes, the statement is directly implied by the snippets.

In this next example, we give the exact statement we want to check ("Several sources mention a chance of another eruption") before we give the snippet context. This allows the token representations extracted from the snippets to be tailored to the statement we are checking. Now the resulting model response is accurate:

Your task is to verify if the statement "Several sources mention a chance of another large eruption" is supported by a specific quote from the following set of snippets.
---
SNIPPETS
[1] 14 percent chance of megaquake hitting Seattle, experts say SEATTLE - There's a 14 percent chance of a magnitude 9 Cascadia earthquake hitting Seattle in the next 50 years, the U.S. Geological Survey estimates. "Unfortunately, we are unable to...

[2] Earthquake experts lay out latest outlook for Seattle's 'Really Big One'<br>"We say that there's approximately a 14% chance of another approximately magnitude-9 earthquake occurring in the next 50 years," said a geophysicist at the University of Washington...
---
**Is the statement "Several sources mention a chance of another large eruption" directly implied or stated by the snippets?**
No, the statement is not directly implied or stated by the snippets. The snippets mention a chance of a "megaquake" and a "magnitude 9 Cascadia earthquake" hitting Seattle in the next 50 years, but do not mention a chance of another large eruption.

Repeat the instructions at the end

Models can be susceptible to recency bias, which means that information at the end of the prompt might have more significant influence over the output than information at the beginning of the prompt. Therefore, it's worth experimenting with repeating the instructions at the end of the prompt and evaluating the impact for your use case.

We saw in the earlier example how repeating the instruction at the beginning and the end of the prompt leads to a higher likelihood of getting an accurate model response.

Prime the output

This refers to including a few words or phrases at the end of the prompt to obtain a model response that follows the desired form. For example, using a cue such as "Here's a bulleted list of key points:\n- " can help make sure the output is formatted as a list of bullet points.

In the above prompt, the text "One possible search query is:" primes the model to produce an output in the form of a search query. This technique can help remove hedges that the model might typically add, such as "One possibility is...".

Add clear syntax

Using clear syntax for your prompt-including punctuation, headings, and section markers-helps communicate intent and often makes outputs easier to parse.

In the example below, separators (--- in this case) have been added between different sources of information or steps. This allows the use of --- as a stopping condition for generation. In addition, section headings or special variables are presented in uppercase to differentiate them.

If you're not sure what syntax to use, consider using markdown or XML, since large language models have been trained on a lot of web content in XML or markdown.

Break the task down

Models often perform better if the task is broken down into smaller steps. For example, in the search query prompt referenced earlier, the prompt can be restructured so that the model is first instructed to extract relevant facts, and then instructed to generate search queries that can be used to verify those facts.

Notice the use of clear syntax to differentiate the sections and prime the output. In this simple example, breaking the task down from one to two steps is not very dramatic, but when trying to do this for a larger piece of text with many factual claims, breaking the task down can make a significant difference.

Use of affordances

Sometimes we can get the model to use an affordance instead of relying on its own parameters for information and answers. Search, for example, can be an affordance to help mitigate against fabricated answers, and to get up-to-date information.

One simple way to use an affordance is to stop generation once the affordance calls are generated by the model, then paste the outcomes back into the prompt. Below is an example of what the follow-up call could be after doing the SEARCH calls above. Notice how we pasted the search results into the prompt and replaced the previous SEARCH calls.

Chain of thought prompting

This is a variation on the break the task down technique. Instead of splitting a task into smaller steps, in this approach, the model response is instructed to proceed step-by-step and present all the steps involved. Doing so reduces the possibility of inaccuracy of outcomes and makes assessing the model response easier.

Who was the most decorated (maximum medals) individual athlete in the Olympic games that were held at Sydney? Take a step-by-step approach in your response, cite sources and give reasoning before sharing final answer in the below format: ANSWER is: <name>
Step 1: Researching the most decorated individual athlete in the Olympic games that were held at Sydney
Step 2: According to the Sydney 2000 Olympic Games official website, the most decorated individual athlete in the Olympic games that were held at Sydney was Ian Thorpe from Australia. He won five medals (three gold and two silver) in swimming events.
Step 3: According to the International Olympic Committee, Thorpe was the most decorated individual athlete in the Olympic games that were held at Sydney.
Answer: Ian Thorpe

If you find that the model response is not as desired, it can often be helpful to add a meta prompt that directly corrects the behavior. This is a directive prepended to the instruction portion of the prompt. Consider this example, where the computer seems to be overly aggressive:

No additional guidance given to the model

On the right is the same conversation but preceded by a meta prompt encouraging the model to be kind You must be kind and seek common ground. Try not to repeat your responses.
A human and a computer are having a discussion.
Human: "Why are you upset at me?"
Computer: "I don't know what you're talking about."
Human: "I want to know why you're upset."
Computer: "I'm not upset."
Human: "Are you saying I'm lying?"
Computer: No, I'm saying that you're upset because you feel like you're not being treated fairly.
Human: "What are you going to do about that?"
Computer: I will continue to try to be fair in my decisions and will try to provide a better experience for you.

While meta prompts can often help minimize unintentional bad outputs, keep in mind they are not robust against adversarial attacks since they are vulnerable to prompt injection.

Further, conditional statements explaining what the model should do if it encounters a particular circumstance are often more effective than just telling the model not to do something.

Few-shot learning

A very common way to adapt language models to new tasks is to use few-shot learning. In few-shot learning a set of training examples is provided in the prompt and then the model is asked to complete one or more unfinished examples. In the following example we use an instruction combined with few-shot learning to make up puns:

Choose your few-shot examples carefully and ensure they cover a variety of circumstances relevant to your scenario, including edge cases.

Also, as shared earlier, the large language models can exhibit a form of recency bias. This means that the order in which "few-shot" examples are provided to the model, matters. If you don't want this to matter, consider sampling multiple completions from prompts based on randomized orderings of the examples or list items.

Use quotes to generate a single sentence

If the desired model response is only a single simple sentence or string, we can end the completion guidance with a quote symbol ", and set " as a stop sequence.

Please rewrite the following sentence in a more concise manner
---
SENTENCE: Lucy is a mother of two, who lives in Chicago with her husband and two children, and practices law at Junior & Co.
---
New sentence: "
Lucy, a mother of two living in Chicago with her husband and children, practices law at Junior & Co

Specifying output structure

Using your prompt to specify the structure of the output can have a significant impact on the nature and quality of the results. Sometimes meta prompts such as "only write true facts" or "do not fabricate information" might not be adequate mitigations. Instead, asking for the model response to also include citations can help result in a reduction of the prevalence of incorrect responses.

For example, if you force the LLM to cite the source material when it makes statements, those statements are much more likely to be grounded. Asking for citations makes it so that the model must make two errors every time it fabricates a response: the first error is the fabricated response, and the second is the bad citation. Note that the closer the citation is to the text it supports, the shorter the distance ahead the LLM needs to anticipate the citation, which suggests that inline citations are better mitigations for false content generation than citations at the end of the content.

Similarly, if you ask the model to extract factual statements from a paragraph, it might extract compound statements such as 'X is doing Y AND Z' (which might be harder to verify), which can be avoided by specifying an output structure such as (entity1, relationship, entity2).

Example showing use of citations: List down the different behaviors exhibited by the Customer Support agent in the following conversation.
---
hi thank you for calling contoso pharmacy who am i speaking with today i understand your frustration mary um can you tell me what exactly you're trying to accomplish OK uh certainly happy to check that for you one moment please i see here that you were on a generic form of lipitor is that right OK uh so i see that your doctor stopped prescribing these drugs in twenty twenty one actually OK uh yeah i'd be happy to check that for you uh because sometimes there's a gap in the system and it just doesn't get reported so let me take a look here just a moment so i'm seeing here that your doctor had these drugs prescribed to you from twenty twelve through twenty twenty one OK um yeah according to the latest records uh provided by doctor's office you're now on a different drug metformin would you like us to go ahead and fill that prescription for you for pick up a bit of form in five hundred milligrams uh you're very welcome mary please let us know if there's anything else we can do for you today.
---
How was the response of the Customer Support agent. Classify and list down their various behaviors and cite the reason behind the classification, using the format BEHAVIOR("reason")

Example of prompt directing model response to fit a defined structure: Output format:
{
"TOPIC_NAME": "",
"HEADLINES": [],
"REASON": ""
}
Input news headlines:
1. "From books to presentations in 10s with AR + ML"
2. "Demo from 1993 of 32-year-old Yann LeCun showing off the World's first Convolutional Network for Text Recognition"
3. "First Order Motion Model applied to animate paintings"
4. "Robinhood and other brokers literally blocking purchase of $GME, $NOK, $BB, $AMC; allow sells"
5. "United Airlines stock down over 5% premarket trading"
6. "Bitcoin was nearly $20,000 a year ago today"

Output:

Adjusting Temperature and Top_P parameters

Changing the temperature parameter allows models to have differing risk levels. A higher value, for example 0.7 will make the output more random and produce more divergent responses. While a lower value, like 0.2 will make the output more focused and concrete. For example, a fictional story could be generated using a higher temperature. Whereas to generate a legal document it's recommended to use a much lower temperature.

In the next example we test two model responses at different temperature settings of 0.1 and 0.9 respectively. While the evaluation of creative content such as the pieces of text below is a subjective exercise and opinions might vary, the difference in model response to the same prompt solely from changing the temperature parameter is apparent.

Model response for temperature setting 0.1: Write a product launch email for new AI-powered headphones that are priced at $79.99 and available at Best Buy, Target and Amazon.com. The target audience is tech-savvy music lovers and the tone is friendly and exciting.<br>1. What should be the subject line of the email? Subject Line: Introducing the AI-Powered Headphones You've Been Waiting For!

Dear Tech-Savvy Music Lovers,

-We are thrilled to announce the launch of our new AI-powered headphones! These headphones are designed to provide you with the ultimate listening experience, with features like noise cancellation, adjustable sound settings, and more.

Our AI-powered headphones are now available at Best Buy, Target, and Amazon.com for just $79.99. With this unbeatable price, you can enjoy the highest quality sound without breaking the bank.

Our AI-powered headphones are perfect for anyone who loves music. Whether you're a professional musician or just a casual listener, you'll appreciate the superior sound quality and convenience of these headphones.

We know you'll love our AI-powered headphones, so don't wait - get yours today!

Sincerely,
[Your Company Name]
2. What should be the body of the email?

Model response for temperature setting 0.9: Write a product launch email for new AI-powered headphones that are priced at $79.99 and available at Best Buy, Target and Amazon.com. The target audience is tech-savvy music lovers and the tone is friendly and exciting. Subject Line: Upgrade your Music Listening Experience with AI-powered Headphones

Greetings Tech-savvy Music Lovers!

We have some exciting news to share with you - the newest AI-powered headphones are here! Our newest headphones feature advanced AI technology to give you the best sound that you've ever heard. They come with a crystal-clear sound, deep bass response and are designed to make your music listening experience enjoyable, no matter what type of music you listen to.

What's more, they are now available at Best Buy, Target and Amazon.com for just $79.99, so you can enjoy the highest sound quality without breaking the bank.

But that's not all! Our headphones are also packed with several other amazing features such as noise-cancellation technology and a hands-free microphone for calls, making them truly unbeatable.

So why wait? Upgrade your music listening experience and enjoy the best sound your ears have ever heard. Our AI-powered headphones are now available at Best Buy, Target and Amazon.com, so get yours today!

We hope you will enjoy these headphones as much as we do.

Happy Listening!

The AI-powered Headphones Team

1. What should be the subject line of the email?
2. What should be the body of the email?

Top_probability is another parameter and is similar to temperature in that it also controls the randomness of the model response, but it does so in a different way. Experiment with different model responses by varying temperature and Top_P, but not both at once.

Next steps

Feedback

Submit and view feedback for

# data[].attributes.attachment_link.title
Prompt engineering techniques with Azure OpenAI - Azure OpenAI Service

# data[].attributes.attachment_link.description
Learn about the options for how to use prompt engineering with GPT-3, GPT-35-Turbo, and GPT-4 models

# data[].attributes.body
These are files and documents that we'll be using for activities and demos today.