I9 · Generative AI and Large Language Models in Practice

Module Review and Assessment

This review brings together Generative AI and Large Language Models in Practice: what LLMs are, tokens and context windows, embeddings, how LLMs are trained, sampling and temperature, prompting techniques, structured outputs, testing prompts, using an LLM API, chatbots with memory, retrieval-augmented generation, AI agents, image generation, hallucinations and grounding, and safety, privacy and cost, followed by a scored quiz.

15 min Intermediate · Sublevel Advanced Jump to the activity

What you need: The earlier topics of this module.

Definition

Could you now explain what happens between typing a prompt and reading the answer, design prompts and tests, call an API safely, add memory and grounding, and judge the risks and costs of a generative AI product?

This review brings together Generative AI and Large Language Models in Practice: what LLMs are, tokens and context windows, embeddings, how LLMs are trained, sampling and temperature, prompting techniques, structured outputs, testing prompts, using an LLM API, chatbots with memory, retrieval-augmented generation, AI agents, image generation, hallucinations and grounding, and safety, privacy and cost, followed by a scored quiz.

In simple words

Read the recap table, try the activities, then take the quiz. Each answer comes with an explanation. If you miss one, go back to that topic.

Why it matters

Generative AI is the fastest-moving area of AI. These foundations stay useful as models change, because they describe how every LLM product is built and where it can fail.

How it works

TopicKey idea
Tokens and contextModels see a limited window of tokens; cost scales with tokens
EmbeddingsMeaning vectors for semantic search and RAG
TrainingPre-training, instruction tuning, preference tuning; knowledge cutoff
SamplingLow temperature for consistency, higher for creativity; top-p
PromptingClear task, context, examples, format, delimiters, reasoning
Structured output and testsSchemas, validation, evaluation sets and one change at a time
APIs and memoryStateless calls, retries, keys on servers; memory built in your app
GroundingRAG, citations, tools and abstention reduce hallucinations
ImagesDiffusion removes noise step by step; label AI images
Safety, privacy, costInjection defences, least privilege, redaction, DPDP Act, right-sized models

Try it yourself

Match the problem to the fix

Which technique addresses each problem?

  • The bot invents scheme details
  • Extraction gives different answers each run
  • The bot forgets the user's name in long chats
  • A web page tricks the bot into leaking data
  • Costs are far above budget

True or false?

Decide for each statement.

  • LLM APIs remember earlier requests automatically

  • Temperature 0 guarantees correct answers

  • Output tokens count towards the context window

  • Diffusion models start generation from random noise

Common mistakes

  • Trusting fluent output without grounding or checking.
  • Shipping prompts without an evaluation set.
  • Ignoring privacy, injection and cost until after launch.

Check yourself

Question 1

1. What does the context window limit?

Question 2

2. Which training stage teaches the model to follow instructions?

Question 3

3. For extracting invoice totals, choose…

Question 4

4. Why include examples in a prompt?

Question 5

5. What is the purpose of an evaluation set?

Question 6

6. Where should a chatbot's API key be used?

Question 7

7. What does RAG do?

Question 8

8. A model invents a court case. This is a…

Question 9

9. How do diffusion models generate an image?

Question 10

10. Which is a privacy safeguard?

Question 11

11. A company wants its assistant to answer from policy documents that change every month. What is usually the better first choice?

Question 12

12. What makes LoRA parameter-efficient?

Question 13

13. How does a vision-language model handle an image input?

Summary

  • LLMs predict tokens within a context window; training stages shape knowledge and behaviour.
  • Prompts, sampling settings, schemas and tests turn models into reliable components.
  • Ground answers, protect keys and data, defend against injection and control cost.

Finished reading?

Sources: Jurafsky and Martin, Speech and Language Processing (3rd ed. draft) · OWASP Top 10 for Large Language Model Applications