Skip to content

Commit c59b8f0

Browse files
committed
workin on content
1 parent 0d71d8c commit c59b8f0

File tree

2 files changed

+84
-36
lines changed

2 files changed

+84
-36
lines changed

03_Overview_AI_Concepts/README.md

Lines changed: 82 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55

66
A Large Language Models (LLM) is a type of AI that can process and produce natural language text. LLMs are "general purpose" AI models trained using massive amounts of data gathered from various sources; like books, articles, webpages, and images to discover patterns and rules of language.
77

8+
LLMs are complex and built using a neural network architecture. They are trained using large amounts of information, and calculate millions of parameters. From a developer perspective, the APIs expose by Azure OpenAI Service enable the LLMs to be easily integrated into enterprise solutions without requiring knowledge of how to build to train the models.
9+
810
Understanding the capabilities of what an LLM can do is important when deciding to use it for a solution:
911

1012
- **Understand language** - An LLM is a predictive engine that pulls patterns together based on pre-existing text to produce more text. It doesn't understand language or math.
@@ -29,77 +31,121 @@ Here are a few things that separate NLPs from LLMs:
2931
| Provides a set of labeled data to train the ML model. | Uses many terabytes of unlabeled data in the foundation model. |
3032
| Describes in natural language what you want the model to do. | Highly optimized for specific use cases. |
3133

34+
## Prompting and Prompt Engineering
3235

33-
https://learn.microsoft.com/en-us/training/modules/introduction-large-language-models/2-understand-large-language-models
36+
### What is a prompt?
3437

38+
A prompt is an input or instruction provided to an Artificial Intelligence (AI) model to direct its behavior and produce the desired results. The quality and specificity of the prompt are crucial in obtaining precise and relevant outputs. A well-designed prompt can ensure that the AI model generates the desired information or completes the intended task effectively. Some typical prompts include summarization, question answering, text classification, and code generation.
3539

40+
#### Guidelines for creating robust prompts
3641

37-
## Standard Patterns
42+
While it can be quick to write basic prompts, it can also be difficult to write more complex prompts to ge the AI to generate the responses necessary. When writing prompts, there are three basic guidelines to follow for creating useful prompts:
3843

39-
### Retrieval Augmentation Generation (RAG)
44+
- **Show and tell** - Make it clear what you want either through instructions, examples, or a combination of the two. If you want the model to rank a list of items in alphabetical order or to classify a paragraph by sentiment, include these details in your prompt to show the model.
45+
- **Provide quality data** - If you're trying to build a classifier or get the model to follow a pattern, make sure there are enough examples. Be sure to proofread your examples. The model is smart enough to resolve basic spelling mistakes and give you a meaningful response. Conversely, the model might assume the mistakes are intentional, which can affect the response.
46+
- **Check your settings** - Probability settings, such as `Temperature` and `Top P`, control how deterministic the model is in generating a response. If you're asking for a response where there's only one right answer, you should specify lower values for these settings. If you're looking for a response that's not obvious, you might want to use higher values. The most common mistake users make with these settings is assuming they control "cleverness" or "creativity" in the model response.
4047

41-
Retrieval Augmentation Generation (RAG) is an architecture that augments the capabilities of a Large Language Model (LLM) like ChatGPT by adding an information retrieval system that provides grounding data. Adding an information retrieval system gives you control over grounding data used by an LLM when it formulates a response. For an enterprise solution, RAG architecture means that you can constrain generative AI to your enterprise content sourced from vectorized documents, images, audio, and video.
48+
### What is prompt engineering
4249

43-
GPT language models can be fine-tuned to achieve several common tasks such as sentiment analysis and named entity recognition. These tasks generally don't require additional background knowledge.
50+
[Prompt engineering](https://learn.microsoft.com/en-us/azure/ai-services/openai/concepts/prompt-engineering) is the iterative process of designing, evaluating, and optimizing prompts to produce consistently accurate responses from language models for a particular problem domain. It involves designing and refining the prompts given to an AI model to achieve the desired outputs. Prompt engineers experiment with various prompts, test their effectiveness, and refine them to improve performance. Performance is measured using predefined metrics such as accuracy, relevance, and user satisfaction to assess the impact of prompt engineering.
4451

45-
The RAG pattern facilitates bringing private proprietary knowledge to the model so that it can perform Question Answering over this content. Remember that Large Language Models are indexed only on public information.
46-
Because the RAG technique accesses external knowledge sources to complete tasks, it enables more factual consistency, improves the reliability of the generated responses, and helps to mitigate the problem of "hallucination".
52+
### General anatomy of a prompt
4753

48-
In some cases, the RAG process involves a technique called vectorization on the proprietary data. The user prompt is compared to the vector store and only the most relevant/matching pieces of information are returned and stuffed into prompt for the LLM to reason over and provide an answer. The next set of demos will go into this further.
54+
context, input, output indicator
55+
There are a several components that are used in the anatomy of constructing AI prompts:
4956

50-
https://learn.microsoft.com/en-us/azure/search/retrieval-augmented-generation-overview
57+
- Instructions
58+
- Primary content
59+
- System message
5160

52-
### Chain of Thought (CoT)
61+
https://learn.microsoft.com/en-us/semantic-kernel/prompts/
5362

54-
Instead of splitting a task into smaller steps, with Chain of Though (CoT) 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.
63+
https://learn.microsoft.com/en-us/azure/ai-services/openai/concepts/prompt-engineering
5564

56-
https://learn.microsoft.com/en-us/azure/ai-services/openai/concepts/advanced-prompt-engineering?pivots=programming-language-chat-completions#chain-of-thought-prompting
65+
https://learn.microsoft.com/en-us/semantic-kernel/prompt-engineering/
5766

58-
### ReAct
67+
https://learn.microsoft.com/en-us/training/modules/introduction-large-language-models/3-large-language-model-core-concepts
5968

60-
Reasoning and Acting (ReAct) leverages LLMs to generate both reasoning traces and task-specific actions. ReAct combines these to allow for greater synergy between the two. Reasoning traces help the model induce, track, and update action plans as well as handle exceptions, while actions allow it to interface with external data sources to gather additional information. When using LLMs to answer questions and verify facts, ReAct is used to overcome issues of hallucination and error propagation by interacting with the additional usage of external data sources.
69+
#### Instructions
6170

62-
### Others
71+
Instructions are likely the most commonly used prompt component. Instructions are simply that: instructions to the model on what to do. While simple in concept, they can be complex in practice.
6372

64-
#### Zero-shot prompting
73+
The following are examples of both simple and more complex instructions:
6574

66-
Zero-shot prompting is what we would consider the “default”. This is when we provide no examples of inputs/expected outputs to the model to work with. We’re leaving it up to the model to decipher what is needed and how to output it from the instructions.
75+
| Instruction Type | Prompt | Completion |
76+
| :--- | :--- | :--- |
77+
| Simple | 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! |
78+
| Complex | 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]. |
79+
| Complex | 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. |
6780

68-
#### Few-shot prompting
81+
#### Primary Content
6982

70-
Few-shot prompting is a technique that enables in-context learning for the LLM by providing examples or further information within the prompt to steer the model to generate a better response. Providing additional information in the prompt helps particularly in areas where the data used to train the model isn't enough to generate the desired output from the model.
83+
Primary content refers to some sort of text that is being processed or transformed by the model. Primary content is typically used in conjunction with instructions. A simple example would be language translation.
7184

72-
https://learn.microsoft.com/en-us/azure/ai-services/openai/concepts/advanced-prompt-engineering?pivots=programming-language-chat-completions#provide-grounding-context
85+
| Prompt | Completion |
86+
| :--- | :--- |
87+
| Can you please tell me how to get to the museum? <br/> Translate to French: | `Pouvez-vous s'il vous plaît me dire comment aller au musée?` |
7388

89+
Primary content can also be much longer. For example, the primary content could pass the introduction section of text content that could be hundreds of words long. Additionally, the primary content could be int he form of structured data as well, such as in JSON or TSV format.
7490

75-
## Vectorization and Vector Search
91+
#### System message
7692

77-
What are you trying to solve with finding relevant data through vector?
93+
https://learn.microsoft.com/en-us/azure/ai-services/openai/concepts/system-message
7894

79-
## Prompt Engineering
8095

81-
### What is a prompt
8296

83-
A prompt is an input or instruction provided to an Artificial Intelligence (AI) model to direct its behavior and produce the desired results. The quality and specificity of the prompt are crucial in obtaining precise and relevant outputs. A well-designed prompt can ensure that the AI model generates the desired information or completes the intended task effectively. Some typical prompts include summarization, question answering, text classification, and code generation.
8497

85-
Simple examples of prompts:
98+
## Standard Patterns
8699

87-
- _""_
88-
- _""_
100+
### Retrieval Augmentation Generation (RAG)
89101

90-
### What is prompt engineering
102+
[Retrieval Augmentation Generation (RAG)](https://learn.microsoft.com/en-us/azure/search/retrieval-augmented-generation-overview) is an architecture that augments the capabilities of a Large Language Model (LLM) like ChatGPT by adding an information retrieval system that provides grounding data. Adding an information retrieval system gives you control over grounding data used by an LLM when it formulates a response. For an enterprise solution, RAG architecture means that you can constrain generative AI to your enterprise content sourced from vectorized documents, images, audio, and video.
91103

92-
Prompt engineering is the iterative process of designing, evaluating, and optimizing prompts to produce consistently accurate responses from language models for a particular problem domain. It involves designing and refining the prompts given to an AI model to achieve the desired outputs. Prompt engineers experiment with various prompts, test their effectiveness, and refine them to improve performance. Performance is measured using predefined metrics such as accuracy, relevance, and user satisfaction to assess the impact of prompt engineering.
104+
GPT language models can be fine-tuned to achieve several common tasks such as sentiment analysis and named entity recognition. These tasks generally don't require additional background knowledge.
93105

94-
### General anatomy of a prompt
106+
The RAG pattern facilitates bringing private proprietary knowledge to the model so that it can perform Question Answering over this content. Remember that Large Language Models are indexed only on public information. For an enterprise solution, RAG architecture means you can constrain the generative AI to your enterprise content sourced from vectorized documents, images, audio, and video.
95107

96-
Instruction, context, input, output indicator
108+
Because the RAG technique accesses external knowledge sources to complete tasks, it enables more factual consistency, improves the reliability of the generated responses, and helps to mitigate the problem of "_hallucination_".
97109

98-
https://learn.microsoft.com/en-us/semantic-kernel/prompts/
110+
In some cases, the RAG process involves a technique called vectorization on the proprietary data. The user prompt is compared to the vector store and only the most relevant/matching pieces of information are returned and stuffed into prompt for the LLM to reason over and provide an answer. The next set of demos will go into this further.
99111

100-
https://learn.microsoft.com/en-us/azure/ai-services/openai/concepts/prompt-engineering
112+
### Chain of Thought (CoT)
101113

102-
https://learn.microsoft.com/en-us/semantic-kernel/prompt-engineering/
114+
Instead of splitting a task into smaller steps, with [Chain of Thought (CoT)](https://learn.microsoft.com/en-us/azure/ai-services/openai/concepts/advanced-prompt-engineering?pivots=programming-language-chat-completions#chain-of-thought-prompting) 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.
103115

104-
https://learn.microsoft.com/en-us/training/modules/introduction-large-language-models/3-large-language-model-core-concepts
116+
| System message | Prompt | Response |
117+
| :--- | :--- | :--- |
118+
| 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. <br/> <br/> Step 2: Find a list of individual athletes who won multiple medals in the 2000 Sydney Olympics. <br/> <br/> 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: <br/> - Ian Thorpe (Australia) - 3 gold, 2 silver, 0 bronze <br/> - Pieter van den Hoogenband (Netherlands) - 2 gold, 0 silver, 2 bronze <br/> - Lenny Krayzelburg (USA) - 3 gold, 0 silver, 0 bronze <br/> - Inge de Bruijn (Netherlands) - 3 gold, 1 silver, 0 bronze <br/> <br/> 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). <br/> <br/> Therefore, the ANSWER is: Ian Thorpe. |
119+
120+
### ReAct
121+
122+
Reasoning and Acting (ReAct) leverages LLMs to generate both reasoning traces and task-specific actions. ReAct combines these to allow for greater synergy between the two. Reasoning traces help the model induce, track, and update action plans as well as handle exceptions, while actions allow it to interface with external data sources to gather additional information. When using LLMs to answer questions and verify facts, ReAct is used to overcome issues of hallucination and error propagation by interacting with the additional usage of external data sources.
123+
124+
### Others
125+
126+
#### Zero-shot prompting
127+
128+
Zero-shot prompting is what we would consider the “default”. This is when we provide no examples of inputs/expected outputs to the model to work with. We’re leaving it up to the model to decipher what is needed and how to output it from the instructions.
105129

130+
Example:
131+
132+
| Prompt | Completion |
133+
| :--- | :--- |
134+
| Headline: Coach confident injury won't derail Warriors <br/> Topic: | The coach is confident that the injury won't derail the Warriors' season. The team is still focused on their goals and that they will continue to work hard to achieve them. |
135+
136+
#### Few-shot prompting
137+
138+
Few-shot prompting is a technique that enables in-context learning for the LLM by providing examples or further information within the prompt to steer the model to generate a better response. Providing additional information in the prompt helps particularly in areas where the data used to train the model isn't enough to generate the desired output from the model.
139+
140+
Example:
141+
142+
| Prompt | Completion |
143+
| :--- | :--- |
144+
| Headline: Twins' Correa to use opt-out, test free agency <br/> Topic: Baseball <br/> Headline: Qatar World Cup to have zones for sobering up <br/> Topic: Soccer <br/> Headline: Yates: Fantasy football intel for Week 6 <br/> Topic: Football <br/> Headline: Coach confident injury won't derail Warriors <br/> Topic: | Basketball |
145+
146+
https://learn.microsoft.com/en-us/azure/ai-services/openai/concepts/advanced-prompt-engineering?pivots=programming-language-chat-completions#provide-grounding-context
147+
148+
149+
## Vectorization and Vector Search
150+
151+
What are you trying to solve with finding relevant data through vector?

05_Provision_Azure_Resources/README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,5 @@ Currently deploying the following:
99
- Azure OpenAI resource
1010
- Chat GPT-3.5 `completions` model
1111
- text-embedding-ada-002 model `embeddings` model
12+
- Azure App Service to host Front-End SPA written in React
13+
- Azure App Service to host Back-end API written in Python

0 commit comments

Comments
 (0)