Lesson 4 of 26 · see all lessons
Start here: the exam, Python basics and responsible AI (skill area 1, 40-45%)
AI models: how they work, choosing and deploying (skill area 1)
AI workloads: text, speech, vision and extraction (skill area 1)
Generative AI apps and agents in Foundry (skill area 2, 55-60%)
Text, speech, vision and extraction apps in Foundry (skill area 2)
- 17. Building a text analysis app
- 18. Building speech apps: spoken prompts and Azure Speech
- 19. Building vision apps: images in prompts and generated images
- 20. Extracting information with Content Understanding: documents and forms
- 21. Content Understanding for images, audio and video, and a small extraction app
Final review and four mock exams
18 min
How generative AI models work
Understand tokens, embeddings, transformers and how a language model predicts the next word.
By the end of this lesson you can
- Place AI, machine learning, deep learning and generative AI in one picture
- Explain how a language model turns a prompt into a reply, one token at a time
- Describe tokens, context windows and embeddings, and why they matter for cost and search
- Explain why models make confident mistakes, and how grounding with RAG helps
From earlier lessons · 1 of 2
Fernhill's chatbot must tell customers it is an AI and explain what it can't do. Which responsible AI principle is this?
Pick one answer.
From earlier lessons · 2 of 2
In Foundry code, what do you pass as model= when you call a deployed model?
Pick one answer.
Fernhill tests a chatbot on its own policies. A customer asks, "Can I cancel my Kyoto tour for free?" The bot replies, warmly and confidently, that cancellations are free up to 24 hours before departure. Fernhill's real rule is 14 days. Nobody typed that wrong answer anywhere. So where did it come from?
AI, machine learning, deep learning and generative AI
Exam depth: recognize it.
Four terms, each inside the one before:
- Artificial intelligence (AI): software that mimics human abilities such as seeing, reading or deciding.
- Machine learning: AI that learns patterns from data instead of following rules a person wrote.
- Deep learning: machine learning that uses neural networks, models with many layers that each transform the data a little.
- Generative AI: AI that creates new content, such as text, images, audio, video or code.
Most generative AI you'll meet on AI-901 is built on language models: deep learning models trained on huge amounts of text, often from the internet and other public sources.
A language model predicts the next token
Exam depth: know it cold.
You send a prompt, the text you give the model. It returns a completion, the text it generates. Think of predictive text on a phone, at a much larger scale.
- The model reads every token in the prompt.
- It works out which earlier tokens matter most for what comes next. This is called attention.
- It predicts the most likely next token and adds it to the sequence.
- It repeats with the longer sequence, until it predicts the reply has ended.
The design that does this is the transformer. You only need to recognize the name and that it uses attention.
The model never looks anything up. It generates words that are likely, which isn't always the same as true.
Watch it happen · 14 s
Next-token prediction: one token at a time
The prompt is split into tokens: When, my, dog, was, a.
A colleague says the chatbot "looks up the answer in its memory". Which description of a language model is accurate?
Pick one answer.
Tokens and the context window
Exam depth: know it cold.
A token is the unit a model reads and writes. It can be a whole word, part of a word (like "un" in "unlikely"), or punctuation. Each token gets a number ID. Splitting text into tokens is called tokenization.
Tokens matter for three things:
- Context window: the most tokens a model can handle in one request, counting input and output together. More input leaves less room for the reply.
- Cost: pricing is usually per token, and input and output tokens can be priced differently.
- Rate limits: services cap tokens per minute (TPM) for each deployment.
A long chat history, a pasted document and the reply all share the same context window.
Fernhill pastes a 300-page supplier contract into one prompt. The request fails before any reply. What limit did it most likely hit?
Pick one answer.
Embeddings: meaning as numbers
Exam depth: know it cold.
An embedding is a list of numbers, called a vector, that captures what a piece of text means. Texts with similar meanings get vectors that sit close together. "Dog" and "puppy" land near each other; "skateboard" lands far away.
Inside a language model, embeddings let it relate tokens to each other. Apps also use them directly:
- Semantic search: find documents by meaning, not exact words. "Cheap flights" finds "low-cost airfare".
- Grounding: find the passages that best match a question, then give them to a model.
Closeness is often measured with cosine similarity, the angle between two vectors. An embedding model is a model that turns text into these vectors.
Fernhill wants its help search to find "how do I get my money back" when the article is titled "Refund policy". The two share no words. What makes this possible?
Pick one answer.
Large, small and multimodal models
Exam depth: recognize it.
| Large language model (LLM) | Small language model (SLM) | |
|---|---|---|
| Size. | More training data and more parameters. | Fewer parameters, more focused. |
| Strength. | General: handles many topics well. | Focused tasks, cheaper, easy to run locally or on devices. |
| Trade-off. | Costs more to train and use. | Less broad knowledge. |
A parameter is one of the learned numbers inside a model.
A multimodal model accepts more than one kind of input, such as text plus images, or text, images and audio. Some models also produce more than text, such as speech. You'll use multimodal models in lessons 18 and 19.
Why models make confident mistakes
Exam depth: know it cold.
Three limits explain most wrong answers:
- Hallucination, also called fabrication: the model generates a confident answer that no reliable source supports. It's predicting likely words, not checking facts.
- Knowledge cut-off: the model only knows what was in its training data, up to the date it was trained. It doesn't know your private data either, like Fernhill's cancellation policy.
- Non-determinism: the same prompt can give different answers each time, because generative models are designed to produce varied content.
Fernhill's bot didn't know the 14-day rule, so it generated a plausible-sounding one.
Grounding and retrieval-augmented generation (RAG)
Exam depth: recognize it.
Grounding means giving the model trusted information to base its answer on. A grounded response sticks to that information instead of guessing.
Retrieval-augmented generation (RAG) is the usual way to ground:
- Retrieval: search your own data, such as policy documents, for passages that match the question. Embeddings often power this search.
- Augmented generation: add those passages to the prompt and ask the model to answer from them.
RAG doesn't change the model. Update the documents, and answers stay current with no retraining. Apps can also return citations so users can check the source.
Put in order
Put the steps of a RAG answer to "Can I cancel my Kyoto tour for free?" in order
Drag, or focus an item and press Space, move with the arrow keys, then Space to drop.
- The app searches Fernhill's policy documents for matching passages
- The model generates an answer based on that passage
- The customer asks the question
- The app adds the cancellation-policy passage to the prompt
- The app shows the answer with a link to the policy
Exam-style practice
For this statement, select Yes if it is true. Otherwise, select No. "If you send a generative AI model the same prompt twice, it always returns the same reply."
Pick one answer.
A bank's assistant must answer from the bank's current fee schedule, which changes monthly. The solution must avoid retraining the model. What should you use?
Pick one answer.
A travel chatbot invents a museum that doesn't exist and describes its opening hours in detail. What is this called?
Pick one answer.
Worth keeping
- AI > machine learning > deep learning > generative AI. Language models drive most of it.
- A language model predicts the next token, again and again. Likely isn't the same as true.
- Tokens set the context window, the cost and the rate limits.
- Embeddings turn meaning into vectors, so similar texts sit close: the basis of semantic search.
- Hallucinations, cut-offs and non-determinism are normal. Ground answers with RAG instead of retraining.
The Foundry model catalog lists a long menu of models: chat, reasoning, embeddings, images, speech. Fernhill needs four different jobs done. Lesson 5 shows how to pick the right model for each.
Leaderboard
Loading…
50 XP for each lesson you finish, 10 for each right answer. Names show only for learners who turn on Show me on leaderboards.
Embed this practice on your site
Free for classrooms, blogs and study groups. Paste this into any page that accepts HTML.
Report a copyright problem with this lesson
Sources for this lesson (13)
Each fact in the lesson is marked with the number of the page it comes from.
- [2]Microsoft Learn: Study guide for Exam AI-901: Microsoft Azure AI Fundamentals
- [14]Microsoft Learn: Large language models (LLMs)
- [17]Microsoft Learn: Quickstart: Set up Microsoft Foundry resources
- [26]Microsoft Learn: Responsible AI (Introduction to AI concepts)
- [31]Microsoft Learn: Deep learning vs. machine learning in Azure Machine Learning
- [32]Microsoft Learn: Generative AI and agents (Introduction to AI concepts)
- [33]Microsoft Learn: Understand tokens
- [34]Microsoft Learn: Foundry Models sold by Azure
- [35]Microsoft Learn: Understand embeddings in Azure OpenAI
- [36]Microsoft Learn: Foundry Models from partners and community
- [37]Microsoft Learn: Understand retrieval-augmented generation
- [38]Microsoft Learn: Groundedness detection filter
- [39]Microsoft Learn: How generative AI and LLMs work