Intro To Intelligent Apps Workshop
Intro To Intelligent Apps Workshop
Machine Learning
Machine Learning
1997 Subset of AI that enables machines to learn from
existing data and improve upon that data to make
decisions or predictions
Generative AI
Generative AI 2021 Create new written, visual, and auditory content
given prompts or existing data.
Why so much hype around ChatGPT?
Time to reach
ChatGPT 100M users
100m users in 2.5 months
100M
Most “human-like” interaction
Facebook: 4.5
Prompt:
In 100 words or less, please tell me what a large language model is
Prompt:
A futuristic abstract rendering of a large language model
Traditional model development
High cost and slow deployment—each service is trained disjointly
EAGLE
EA GLE
Labeled ML Model
Classification Classification
Data training
Large
Labeled ML Model
Entity Extraction Unlabeled Language Entity Extraction
Data training
Data Model
(Many TBs) Training
… …
($$$)
Labeled ML Model
Summarization Summarization
Data training
Question and
answering
Data
Sentiment
Text analysis
Images Information
extraction
Foundation
Training Adaption
Speech model
Image
captioning
Structured data
Transformer model Object
3d signals
recognition
Instruction
follow
Model use out of the box - prompting
Entity Recognition Prompt Instruction
Decoder Extract the name of this person in this text. Conversational AI
Text: “My name is Simon, order status?”
Topic Classification Application
NLU Completion
Agent: Sentiment:
Sentiment Analysis Entity (Name): Simon
How can I help you today? Positive
Prompt Instruction
Decide whether a phrase’s sentiment is positive, Customer: Sentiment:
Other NLU tasks
neutral, or negative. My name is Simon, Positive
NLP Phrase: “How can I help you today?” order status?
Understand facts
There are no separate modes for “information
retrieval” and “creative writing”.
Understand anything
The output is just a combination of the training
data and the prompt.
• OpenAI is an AI research and deployment company
• Focus: Groundbreaking research, Latest models & Fast innovation
• Mission is to ensure that artificial general intelligence benefits all of humanity.
https://blogs.microsoft.com/blog/2023/01/23/microsoftandopenaiextendpartnership/
Generative AI
Prompt: Prompt: Prompt: A white Siamese cat What is the fastest animal on land?
Business
Users
Application Platform
AI Builder
Power BI Power Apps Power Automate Power Virtual Agents
Scenario-Based Services
Applied AI Services
Bot Service Cognitive Search Form Recognizer Video Indexer Metrics Advisor Immersive Reader
Customer question: Hi there, do you know how to apply for financial aid?
Classified topic: 3
Classify customer's question. Classify between category 1 to 3. Classify customer's question. Classify between category 1 to 3.
Detailed guidelines for how to choose: Detailed guidelines for how to choose:
choose 1 if the question is about auto insurance. choose 1 if the question is about auto insurance.
choose 2 if the question is about home flood insurance. choose 2 if the question is about home flood insurance.
choose 3 if the question is not relevant to insurance. choose 3 if the question is not relevant to insurance.
Customer question: Hi there, do you know how to apply for financial aid?
Classified topic: 3
6. Generate many outputs, and then use the model to pick the best one
Answer: The answer is 11. Answer: Roger started with 5 balls. 2 cans of 3 tennis balls
each is 6 tennis balls. 5+6 = 11. The answer is 11.
The cafeteria has 23 apples. If they used 20 to make lunch
and bought 6 more, how many do they have? The cafeteria has 23 apples. If they used 20 to make lunch
and bought 6 more, how many do they have?
The answer is 27
The cafeteria had 23 apples originally. They used 20 to
make lunch. So they had 23-20 = 3. They bought 6
more apples, so they have 3 + 6 = 9. The answer is 9.
Model Reasoning—Chain-of-Thought
Before After
What is the annual water demand of a single-family What is the annual water demand of a single-family
household containing four people who are at home an household containing four people who are at home an
average of 200 days per year and use an average of 100 average of 200 days per year and use an average of 100
liters of water per day? liters of water per day?
The annual water demand of a single-family household Let’s think step by step and explain the calculation
containing four people who are at home an average of step by step.
200 days per year and use an average of 100 liters of
water per day is 8,000,000 liters per year. Step 1: Calculate the total number of days in a year:
There are 365 days in a year.
Let’s think step by step and explain the calculation In one minute, Joe throws 25 punches.
step by step. In three minutes, Joe throws 3 * 25 = 75 punches.
In five rounds, Joe throws 5*75 = 375 punches.
In one minute, Joe throws 25 punches.
In three minutes, Joe throws 3 * 25 = 75 punches. Therefore, the answer (Arabic numerals) is
In five rounds, Joe throws 5*75 = 375 punches.
Few-Shot– Chain-of-Thought--Examples
Math Word Problems (free response) Math Word Problems (multiple choice) CSQA (commonsense)
Q: Roger has 5 tennis balls. He buys 2 more cans of Q: How many keystrokes are needed to type the Q: Sammy wanted to go to where the people were.
tennis balls. Each can has 3 tennis balls. How many numbers from 1 to 500? Answer Choices: (a) 1156 (b) Where might he go? Options: (a) race track (b)
tennis balls does he have now? 1392 (c) 1480 (d) 1562 (e) 1788 populated areas (c) desert (d) apartment (e) roadblock
A: Roger started with 5 balls. 2 cans of 3 tennis balls A: There are 9 one-digit numbers from 1 to 9. There are A: The answer must be a place with a lot of people. Race
each is 6 tennis balls. 5 + 6 = 11. 90 two-digit numbers from 10 to 99. There are 401 tracks, desert, apartments, and roadblocks don't have a
three-digit numbers from 100 to 500. 9 +90(2) + 401(3) lot of people, but populated areas do.
The answer is 11.
= 1392.
So the answer is (b).
The answer is (b).
StrategyQA
Sports Understanding
Q: Yes or no: Would a pear sink in water?
Date Understanding
Q: Is the following sentence plausible? "Joao Moutinho
Q: The concert was scheduled to be on 06/01/1943, but
A: The density of a pear is about 0.6 g/cm^3, which is caught the screen pass in the NFC championship.“
less than water. Thus, a pear would float was delayed by one day to today. What is the date 10
days ago in MM/DD/YYYY? A: Joao Moutinho is a soccer player. The NFC
So the answer is no. championship is part of American football, not soccer.
A: One day after 06/01/1943 is 06/02/1943, so today is
06/02/1943. 10 days before today is 05/23/1943. So the answer is no.
14 times
How much time does it take for Amy to climb and slide?
How much time does it take for Amy to climb and slide? She can slide 3 times before the water slides close.
Add new
fact to
context
Decomposes problem into a smaller task (Reasoning)
Hierarchy of language model customization
Fine-tune
Train
Building your house with LLMs
I was enjoying the sun, but then a huge cloud came and
Input text covered the sky.
Expected Ich genoss die Sonne, aber dann kam eine riesige Wolke
completion und bedeckte den Himmel.
Translate the following sentence into German.
Sentence: I was enjoying the sun, but then a huge cloud came and covered
the sky.
German translation:
Exercise 2 – Negation
I was enjoying the sun, but then a huge cloud came and
Input text covered the sky.
Expected I was not enjoying the sun, and then a huge cloud did not
completion come and cover the sky.
Exercise 3 – Classification
"Not much to write about here, but it does exactly what it's
supposed to. filters out the pop sounds. now my recordings are
Input text much more crisp. it is one of the lowest prices pop filters on
amazon so might as well buy it, they honestly work the same
despite their pricing"
I was enjoying the sun, but then a huge cloud came and
Input text covered the sky.
Expected She was enjoying the sun, but then a huge cloud came and
completion covered the sky.
Exercise 6 – Multiple Tasks
I was enjoying the sun, but then a huge cloud came and
Input text covered the sky.
{
"translated": "Ich genoss die Sonne, aber dann kam eine riesige Wolke und
Hello, my name is Mateo Gomez. I lost my Credit card on August 17th, and I would like to request its
cancellation. The last purchase I made was of a Chicken parmigiana dish at Contoso Restaurant, located
near the Hollywood Museum, for $40. Below is my personal information for validation:
Input text
Profession: Accountant
Social Security number is 123-45-6789
Date of birth: 9-9-1989
Phone number: 949-555-0110
Personal address: 1234 Hollywood Boulevard Los Angeles CA
Linked email account: mateo@contosorestaurant.com
Swift code: CHASUS33XXX
completion
"name": "Mateo Gomez",
"ssn": "123-45-6789",
"dob": "09/09/1989"
}
Exercise 8 – Fashion product description
Season: Winter
Style: Sweater
Input text Gender: Female
Target group: Teenager
Material: Cotton
Expected Stay warm and stylish this winter with our cozy cotton
sweaters, perfect for the fashion-forward teenager. Refresh
completion your wardrobe with the latest winter styles from our
(or similar) collection.
Exercise 9 – Write a Blog
Input text
be helping me to brainstorm blog post outline ideas for the
topic <Topic 1>:
Step 2: Write 3 engaging and informative paragraphs about <Idea
1 description>
Step 3: Write 3 engaging and informative paragraphs about <Idea
2 description>
Step 4: Tags <List of relevant #hashtags>
Exercise 10 – Call Center
Data samples Paul Atreides, a brilliant and gifted young man born into a great destiny beyond his understanding, must travel to the
most dangerous planet in the universe to ensure the future of his family and his people. As malevolent forces explode
into conflict over the planet's exclusive supply of the most precious resource in existence-a commodity capable of
unlocking humanity's greatest potential-only those who can conquer their fear will survive.
['Action', 'Adventure', 'Science Fiction’]
A botched store robbery places Wonder Woman in a global battle against a powerful and mysterious ancient force that
puts her powers in jeopardy.
['Action', 'Adventure', 'Fantasy']
After the devastating events of Avengers: Infinity War, the universe is in ruins due to the efforts of the Mad Titan,
Thanos. With the help of remaining allies, the Avengers must assemble once more in order to undo Thanos' actions
and restore order to the universe once and for all, no matter what consequences may be in store.
['Adventure', 'Science Fiction', 'Action']
A widowed new dad copes with doubts, fears, heartache and dirty diapers as he sets out to raise his daughter on his
own. Inspired by a true story.
['Drama', 'Family', 'Comedy’]
New data:
Harry, Ron and Hermione walk away from their last year at Hogwarts to find and destroy the remaining Horcruxes,
putting an end to Voldemort's bid for immortality. But with Harry's beloved Dumbledore dead and Voldemort's
unscrupulous Death Eaters on the loose, the world is more dangerous than ever.
You are adding tag categories to movies, based on their descriptions.
###
Movie description: Paul Atreides, a brilliant and gifted young man born into a great destiny beyond his understanding, must travel to the most dangerous planet in the universe to ensure the
future of his family and his people. As malevolent forces explode into conflict over the planet's exclusive supply of the mos t precious resource in existence-a commodity capable of unlocking
humanity's greatest potential-only those who can conquer their fear will survive.
Tags: ['Action', 'Adventure', 'Science Fiction’]
###
Movie description: A botched store robbery places Wonder Woman in a global battle against a powerful and mysterious ancient f orce that puts her powers in jeopardy.
Tags: ['Action', 'Adventure', 'Fantasy']
###
Movie description: After the devastating events of Avengers: Infinity War, the universe is in ruins due to the efforts of the Mad Titan, Thanos. With the help of remaining allies, the Avengers
must assemble once more in order to undo Thanos' actions and restore order to the universe once and for all, no matter what consequences may be in store.
Tags: ['Adventure', 'Science Fiction', 'Action']
###
Movie description: A widowed new dad copes with doubts, fears, heartache and dirty diapers as he sets out to raise his daught er on his own. Inspired by a true story.
Tags: ['Drama', 'Family', 'Comedy’]
###
Movie description: Harry, Ron and Hermione walk away from their last year at Hogwarts to find and destroy the remaining Horcruxes, putting an end to Voldemort's bid for immortality. But with
Harry's beloved Dumbledore dead and Voldemort's unscrupulous Death Eaters on the loose, the world is more dangerous than ever .
Tags:
Exercise 12 – NL to SQL with Codex
Query
A query that returns the top 10 orders and show the customer name
Exercise - Bring Your Own Data
Write a prompt that uses some of your own data and ask it questions.
Exercise It could be data copied from a website or document for example.
Expected <<ARE YOU GETTING THE RESULT YOU EXPECTED? IF NOT, WHY?>>
completion
Intro to Azure OpenAI, Prompt Engineering Q&A
Intro to AI Orchestration Building Blocks
Foundation + Context
Context =
‘Specific world
knowledge’
Components – Pick the Model
Prompt: the natural language text you send to the LLM.
Tokens: prompts encoded into tokens for the LLM to use
Embeddings: Vectors (arrays) of numbers, that represent the meaning & context of the tokens.
Your
Prompt Vectorized &
LLM API Intelligent
Design Other Data
App
59
Components – Prompt
LLMs have limits to how many tokens they can process &
charge based on the number of tokens you submit.
Your
Prompt Vectorized &
LLM API Intelligent
design Other Data
App
60
Components – Is Vector Store Needed
Embedding: An array of numbers, or vector, that
represent the semantic meaning of a piece of text.
Vectorized Your
Prompt
LLM API & Other Intelligent
design Data App
61
Components – Vector Database
Vector DB: A database designed to store and retrieve data represented as vectors.
Querying in a vector db (‘vectorized search’) finds similar assets by searching for neighboring data points.
Vectorized Your
Prompt
LLM API & Other Intelligent
design Data App
62
Foundation + Context + Components = Intelligence
Vectorized Your
Prompt
LLM API & Other Intelligent
design Data App
63
Tokens
You can think of tokens as pieces of words used for
natural language processing. For English text, 1 token
is approximately 4 characters or 0.75 words.
Animal: Cat
Names: Captain Sharpclaw, Agent Fluffball, The Incredible Feline
Animal: Dog
Names: Ruff the Protector, Wonder Canine, Sir Barks-a-Lot
Animal: Horse
Names:
[ 15 34 24 13 …] [16 22 89 26 …] [ 20 13 31 89 …]
Embeddings represent your data REALISTIC CARTOON
Example: 1-dimensional vector
MAMMAL
BIRD
MAMMAL
Where would I live in this
embedding space?
BIRD
Embedding models
Different Azure OpenAI embedding models are specifically
created to be good at a particular task.
user
embedding result set
input
“What is a neutron star?” [ 13 33 34 13 … ]
Clustering
where text strings are grouped by similarity
Recommendations
where items with related text strings are recommended
Anomaly detection
where outliers with little relatedness are identified
Diversity measurement
where similarity distributions are analyzed
Classification
where text strings are classified by their most similar label
Demo Embeddings
Product Finder
https://ecommerce.redisventures.com/
Doc Search
https://docsearch.redisventures.com/
Intro to AI Orchestration
Why do we need AI Orchestration?
Flow
AI Orchestration
AI UX
BYO Chat
Models
User BYO Model AI App
Devs
Foundation Models
Semantic Kernel
Integrate AI into your existing apps using C#, Python & Java
AI UX
Semantic Kernel
Copilot Chat
Models
User Azure AI Models AI App
Devs
Foundation Models
Microsoft Corporation
Prompt Chaining
Entity Extraction Summarization Sentiment Analysis
Please extract entities from the Please summarize the information Please provide a sentiment for the
following news article: 'The new about the product following text:
iPhone model is set to be released
next month. It has been highly [{'text': 'iPhone', 'type': 'PRODUCT'}, The iPhone is a line of smartphones
anticipated by Apple fans and is {'text': 'Apple', 'type': designed and marketed by Apple
expected to feature a larger screen 'ORGANIZATION’}] Inc. These devices combine a
and improved camera computer, camera, and internet
The iPhone is a line of smartphones connectivity in a single device,
{'text': 'iPhone', 'type’: designed and marketed by Apple and are known for their sleek
'PRODUCT'}, {'text': 'Apple’, Inc. These devices combine a design and user-friendly interface.
'type': 'ORGANIZATION'}] computer, camera, and internet
connectivity in a single device, and Positive
are known for their sleek design and
user-friendly interface.
Then all summaries are passed to GPT again to
Prompt Chunking (token limit) summarize, i.e. second round of summarization. The sum
of the summaries has to fit within the token limit.
User Question
LLM Workflow
Query My Data Search Index
Large Language
Query Model Model
Send Results
Retrieval augmented generation: bring your data to the prompt
Prompt
Sources:
Prompt
Azure OpenAI Service
User
application
Documents
General Recommendations
PowerBI Insights
(near real-time)
Caller Intelligent
Transcription
Conversation Trends
Audio
Person-to-Person & Insights
Files Azure OpenAI
Conversation
Service
Speech-to-Text
Telephony Azure
Server Storage CRM
Azure Cognitive Services –
Speech & Azure OpenAI Service
Call-Center Agent
Solution Demo
Accelerator Website
Azure OpenAI Service | Sample Use Cases
Customer conversation in
Example:
English (or other language) Azure OpenAI
Servcice Prompt
Output as JSON
ChatGPT with Enterprise Data
Extract precise answers from your unstructured documents
Do I get a
discount when I
have contract x
and y?
Vector search
Azure ?
OpenAI Questions
Service
Embeddings
Users
Answers
Search Layer
Knowledge Base
Top k Azure
paragraphs
Raw Extracted Azure OpenAI Vectors OpenAI
documents paragraphs Service Service
Embeddings Answering
Prompt
Azure Storage RediSearch Yes, you’ll get 10
Azure Form Euros off, if you
Recognizer
Unstructured documents
Embedding of paragraphs have a 24m long
(pdf, docx, etc.)
using Azure OpenAI Service contract. Here’s the
full link.
Solution Demo
Accelerator Website
ChatGPT with Enterprise Data
Extract precise answers from your unstructured documents
Do I get a
discount when I
have contract x
and y?
?
Questions/ Query Knowledge
Users
Answers
Search Layer
Knowledge Base
Top k Azure
paragraphs OpenAI
Raw Extracted
Service
documents paragraphs
Answering
Prompt
Azure Storage Yes, you’ll get 10
Azure Form Euros off, if you
Recognizer
Unstructured documents have a 24m long
(pdf, docx, etc.) Azure Cognitive Search
contract. Here’s the
full link.
Solution
Accelerator Blog Post
2 announcements and public cases in Germany
Siemens’ Teamcenter® software for product lifecycle First generative AI-based bot in the automotive industry! Just the beginning!
management (PLM) with Microsoft’s collaboration platform Teams (Car Configurator search & voice assistant)
and the language models in Azure OpenAI Service as well as
other Azure AI capabilities.
Siemens & Microsoft drive industrial productivity with AI | LinkedIn
Siemens Software
© Siemens 2023
Retrieval Augmented Generation + Enterprise Data
Demo AI Apps
Sample Demos in the repo, or feel free to use your own:
https://github.com/Azure/intro-to-intelligent-apps/blob/main/presentations/aiapps-
demos.md
Lunch
Hands-on with AI Orchestration
Setup for Labs
https://github.com/Azure/intro-to-intelligent-apps/blob/main/labs/00-setup/README.md
Aha Moments
You cannot just point an LLM at your Enterprise Data and get good results
Engineering the right prompt is not easy
Integrating AI into an App is fairly easy once you understand the building blocks
Closing Remarks Cont.
How to get started?
1. What is the business problem trying to be solved?
2. Do I have access to the data needed to solve/answer the question(s)?
3. Add needed data to a sample Prompt in Azure OpenAI Studio and ask Question(s)
(Remember, a Prompt is only so big ☺)
1. If you did not get the right response, iterate again with a different Prompt or add additional data
2. If you got a response that was in the general right direction, time to think about AI Orchestration
4. Decide on AI Orchestration, Data, Embedding & Vector Store Strategies
5. Implement Enterprise Grade API + Data + Azure OpenAI
MS Learning
https://learn.microsoft.com/en-us/training/paths/develop-ai-solutions-azure-openai/