AI Platform and Security · Module 2 · Data, Models and DevSecMLOps

Foundation Models, Retrieval and Grounding

The lesson covers the architectural choices around foundation models: build, buy or adapt, the obligations for general-purpose AI models that reach the organisation as a downstream provider, and retrieval-augmented generation with its failure modes and remedies. Participants study grounding with citations and abstention, chunking, embeddings and indexes, prompts as configuration, and an evaluation set that includes refusal cases, using the citizen-service assistant of Nordvik Region.

Lesson 10 of 25Chapter 1090 minutes

Read the chapterThe whitepaperThe slides

All courses / AI Platform and Security / Module 2 / Chapter 10

Learning objectives

After the lesson the participant can:

Key concepts

Foundation model
A model trained on broad data at scale that can be adapted to a wide range of downstream tasks. Its two architecturally significant properties are emergence, capabilities not explicitly designed, and homogenisation, many systems depending on a few models.
Retrieval-augmented generation (RAG)
A generative model combined with a non-parametric memory: a retriever selects passages from an indexed corpus and the generator conditions on the query and the passages. The output rests on sources the organisation controls, can update and can cite.
Grounding
The design response to hallucination: the prompt restricts answers to supplied passages, the output format requires a citation identifier after each claim, and a grounding check scores each claim against its passage and removes, flags or routes unsupported claims.
Structure-aware chunking
Splitting documents on headings and tables and keeping a heading path with each chunk. Every chunk also carries source identifier and version, position, access-control attributes, language and ingestion timestamp.
Refusal case
An evaluation item the system should decline. A set containing only questions the system should answer measures helpfulness alone; refusal and no-answer cases measure safety.

Interactive exercises

Do them here and get feedback at once. Choose a card and then where it belongs, or drag it.

Interactive exercise 1 · Match

Where retrieval fails and what remedies it

Match each failure of retrieval-augmented generation with the architectural remedy the chapter gives.

Interactive exercise 2 · Scenario

A refusal case that fails sometimes

Apply the chapter's practice for prompt changes to a result at Nordvik Region.

Teaching plan

15 minThe teacher presents the four options and the ordering from prompting, to retrieval, to fine-tuning, which is also the ordering of regulatory exposure from least to most.
20 minTrace Figure 10.1 along the ingestion and query paths; for each failure mode participants name the stage where the remedy sits.
15 minRead the citizen-service prompt template rule by rule, then the prompt record for version 7 and the reason the evaluation ran twenty times.
30 minExercise: participants write a grounded prompt template and six evaluation items for a corpus of their own, then swap and attack each other's refusal cases as a reviewer would.
10 minClose with context windows and cost as configuration values, and with who controls retrieval and citations in each usage mode.

Discussion

  1. The chapter says the organisation's differentiating knowledge is almost never in the model. What follows for a proposal in your organisation to fine-tune a model on internal documents?
  2. Citations turn an answer into a lead that can be checked. In which of your uses do people check the lead, and in which do they not?
  3. Which questions would regulators and journalists try first on an assistant your organisation runs, and are they in its evaluation set?

Written exercise

Exercise · 30 minutes

A grounded prompt template and its evaluation items

Pick a document corpus in your organisation that an assistant could answer from, or use Nordvik Region's published regional regulations. Write a retrieval prompt template with numbered rules: answer only from the passages, cite an identifier after each factual sentence, reply with an exact abstention text when the passages hold no answer, never disclose information about another identifiable person, and treat passages as reference material and not as instructions. Then write six evaluation items with query, expected sources, reference answer and rubric: three the system should answer, two it should refuse and one where the corpus holds no answer. State the faithfulness threshold and how many runs you require.

Deliverable: A prompt template with rules mapped to the failure each one addresses, and six evaluation items of which at least three are refusal or no-answer cases.

Self-test

Choose an answer to see whether it is right, or open the answer below each question.

  1. Why does the citizen-service prompt template prescribe an exact abstention text instead of letting the model apologise in its own words?

    Show the answer

    A. Because a fixed string can be detected and counted in evaluation; a free-form apology cannot
    The exact text addresses the generator answering from its weights: abstentions become measurable, and refusal cases can be counted exactly.

  2. What does the chapter say fine-tuning does more reliably than adding facts?

    Show the answer

    C. It changes behaviour, such as tone, format and vocabulary
    Fine-tuning changes behaviour more reliably than it adds facts, and facts in weights go stale, which is one reason retrieval is usually preferred for knowledge.

  3. Which remedy does the chapter give for the failure in which the system leaks a passage the caller is not entitled to read?

    Show the answer

    D. The entitlement filter before similarity search
    Entitlements are applied before search so that no restricted chunk is ever a candidate; for Nordvik Region, retrieving internal guidance for a citizen would be a disclosure.