Lesson 4 of 26 · see all lessons
  1. Start here: the exam, Python basics and responsible AI (skill area 1, 40-45%)

    1. 1. Start here: the AI-901 exam, the plan and what you already know
    2. 2. The Python and Azure basics AI-901 expects
    3. 3. Responsible AI: the six principles in practice
  2. AI models: how they work, choosing and deploying (skill area 1)

    1. 4. How generative AI models work
    2. 5. Choosing the right AI model for the job
    3. 6. Deploying a model: deployment options and configuration parameters
  3. AI workloads: text, speech, vision and extraction (skill area 1)

    1. 7. Common AI workloads: from chat and agents to vision and extraction
    2. 8. Text analysis: key phrases, entities, sentiment and summaries
    3. 9. Speech: recognition and synthesis
    4. 10. Computer vision and image generation
    5. 11. Extracting information from documents, images, audio and video
  4. Generative AI apps and agents in Foundry (skill area 2, 55-60%)

    1. 12. Writing system and user prompts
    2. 13. Deploying a model and chatting with it in the Foundry portal
    3. 14. Building a lightweight chat client with the Foundry SDK
    4. 15. Creating and testing a single agent in the Foundry portal
    5. 16. Building a lightweight client app for an agent
  5. Text, speech, vision and extraction apps in Foundry (skill area 2)

    1. 17. Building a text analysis app
    2. 18. Building speech apps: spoken prompts and Azure Speech
    3. 19. Building vision apps: images in prompts and generated images
    4. 20. Extracting information with Content Understanding: documents and forms
    5. 21. Content Understanding for images, audio and video, and a small extraction app
  6. Final review and four mock exams

    1. 22. Final review and exam day: every decision on one page
    2. 23. Mock exam 1
    3. 24. Mock exam 2
    4. 25. Mock exam 3
    5. 26. Mock exam 4
See the leaderboard

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?

[2]

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.

[31][32]

Rendering diagram…
Each circle sits inside the one before. Generative AI uses deep learning to create new content.

[31]

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.

  1. The model reads every token in the prompt.
  2. It works out which earlier tokens matter most for what comes next. This is called attention.
  3. It predicts the most likely next token and adds it to the sequence.
  4. 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.

[14]

Watch it happen · 14 s

Next-token prediction: one token at a time

The prompt is split into tokens: When, my, dog, was, a.

Scene 1 of 5

[14]

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.

[14][33][34]

[33]

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.

[33][34]

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.

[14][35]

In embedding space, similar meanings sit close togetherdogpuppycatrefund my tripget my money backskateboardcarDifferent words, same meaning:close vectors

[14]

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.

[35]

A language model's job is to sound likely. Being right is a separate job, and that's yours. Picture: Retro pixel art, 16-bit video game style.

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.

[32][34][36]

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.

[37][38][39]

[37]

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:

  1. Retrieval: search your own data, such as policy documents, for passages that match the question. Embeddings often power this search.
  2. 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.

[37][38]

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.

  1. The app searches Fernhill's policy documents for matching passages
  2. The model generates an answer based on that passage
  3. The customer asks the question
  4. The app adds the cancellation-policy passage to the prompt
  5. The app shows the answer with a link to the policy

[37]

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.

[39]

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.

[37]

A travel chatbot invents a museum that doesn't exist and describes its opening hours in detail. What is this called?

Pick one answer.

[37][38]

FlashcardsIndex cardsFlashcards ⚡

Card 1 of 17

[14][31][32][33][35][37]

Worth keeping

  1. AI > machine learning > deep learning > generative AI. Language models drive most of it.
  2. A language model predicts the next token, again and again. Likely isn't the same as true.
  3. Tokens set the context window, the cost and the rate limits.
  4. Embeddings turn meaning into vectors, so similar texts sit close: the basis of semantic search.
  5. 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.

  1. [2]Microsoft Learn: Study guide for Exam AI-901: Microsoft Azure AI Fundamentals
  2. [14]Microsoft Learn: Large language models (LLMs)
  3. [17]Microsoft Learn: Quickstart: Set up Microsoft Foundry resources
  4. [26]Microsoft Learn: Responsible AI (Introduction to AI concepts)
  5. [31]Microsoft Learn: Deep learning vs. machine learning in Azure Machine Learning
  6. [32]Microsoft Learn: Generative AI and agents (Introduction to AI concepts)
  7. [33]Microsoft Learn: Understand tokens
  8. [34]Microsoft Learn: Foundry Models sold by Azure
  9. [35]Microsoft Learn: Understand embeddings in Azure OpenAI
  10. [36]Microsoft Learn: Foundry Models from partners and community
  11. [37]Microsoft Learn: Understand retrieval-augmented generation
  12. [38]Microsoft Learn: Groundedness detection filter
  13. [39]Microsoft Learn: How generative AI and LLMs work