Training module · DAT-202 · Data and knowledge path

Chunking, embedding and retrieval

Building retrieval that agents can rely on: document parsing, chunking strategies, embedding model choice, hybrid search and reranking, permission-aware retrieval, index lifecycle and retrieval evals.

Contents
  1. Overview
  2. Learning objectives
  3. Agenda
  4. Participant guide
  5. Facilitator guide
  6. Related guides and policies
  7. Module downloads
CodeDAT-202
PathData and knowledge
Level200 Practitioner
Duration1 day
FormatCohort lab
PrerequisitesAIL-101, BLD-201
Plan sections4A, 9, 7
AI-SDLCP1, P2, P4

Overview

This module is for data and ML engineers who build ingestion and retrieval pipelines, and agent engineers who expose retrieval to agents as a tool. It assumes AIL-101 and BLD-201.

Afterwards you can take a document set from raw files to a governed, permission-aware index; defend a chunking strategy and an embedding model with evidence rather than defaults; combine lexical and vector search with fusion and reranking; and prove retrieval quality with a golden set you rerun on every index change.

The module teaches CoE plan section 4A (reference retrieval stack, index lifecycle, permission-aware retrieval, caching, knowledge-base integrity, KPIs), section 9 (retrieval choice) and section 7 (golden sets and the eval pyramid). In the AI-SDLC it supports P1 (data access design and eval thresholds for G1), P2 (retrieval evals in CI that must pass at G2) and P4 (index lifecycle and retrieval KPIs feeding the G4 autonomy review).

Learning objectives

  • Choose a chunking strategy for a document set and justify it with a measured comparison
  • Select and evaluate an embedding model for a domain, including its re-embedding cost
  • Combine lexical and vector search with rank fusion and reranking
  • Enforce source permissions at retrieval time, inside the query, with the user's delegated identity
  • Measure retrieval quality with a golden set and track it across index versions as a release gate

Agenda

Time Segment Method Materials
0:00 to 0:20 1. Why retrieval fails Discussion, card sort Failure-point cards
0:20 to 1:00 2. Parsing and layout-aware extraction Demo, talk Two synthetic PDFs
1:00 to 1:45 3. Chunking strategies Talk, worked example Chunking table
1:45 to 2:00 Break
2:00 to 2:50 Lab 1: Chunk a policy two ways Pairs Lab 1 sheet
2:50 to 3:30 4. Choosing an embedding model Talk, worksheet Storage worksheet
3:30 to 4:15 Lunch
4:15 to 5:00 5. Hybrid search, fusion, reranking, filters Talk, RRF by hand Whiteboard
5:00 to 5:50 Lab 2: Golden set and scoring Groups Lab 2 sheet, calculators
5:50 to 6:05 Break
6:05 to 6:35 6. Permissions, index lifecycle, evals as gates Talk, whiteboard Release-flow sketch
6:35 to 7:15 Lab 3: Permission-aware retrieval design Groups Lab 3 sheet
7:15 to 7:30 Knowledge check and close Individual, review Knowledge check

Participant guide

Key ideas

Failure points (Barnett et al.). Missing content; missed top-K; not in context (lost in consolidation); not extracted; wrong format; wrong specificity; incomplete. The first, second, sixth and seventh usually start in ingestion, chunking, ranking or metadata.

Pipeline. Parse, enrich, chunk, embed, index, retrieve (lexical and vector), fuse, rerank, assemble context, with filters applied inside retrieval. Every chunk carries document ID, version, status, page, section path, ACL and label, snapshot time, parser, chunker, and embedding model and version.

Parsing. Use a layout-aware parser for columns, tables, forms and scans; emit Markdown or JSON with element types and pages; keep tables whole or repeat the header per row; strip repeated headers and footers; scan for hidden text and quarantine uploads; score extraction on a sample.

Chunking. Sizes are starting points to test on your golden set. Roughly 100 tokens is about 75 English words.

Strategy How it works Use when Starting point to test
Fixed-size N-token windows with overlap, ignoring structure Uniform text; baselines 256 to 512 tokens, 10 to 25% overlap; also about 200 with none
Recursive or structural Split on headings, then paragraphs, then sentences; prefix heading path Policies, manuals, contracts 200 to 500 tokens; sections and tables whole where they fit
Semantic Break where adjacent-sentence similarity drops Transcripts, notes without headings Tune threshold; cap maximum size
Late chunking Embed whole document, pool token vectors per chunk Pronoun- and reference-heavy text Document must fit the model's window
Contextual retrieval Model writes 50 to 100 tokens of context per chunk, prepended before embedding and BM25 High-value corpora where chunks lose meaning alone Measure with and without; budget the one-off cost
Parent-child Retrieve small chunks, pass their parent section Precise match, answer needs surroundings Child 100 to 200 tokens; parent the section

FAQs: one question and answer per chunk. Email: one message per chunk with thread metadata. Transcripts: speaker turns. Code: functions or classes.

Evidence: Chroma found strategy moved recall by up to 9% and 800 tokens with 400 overlap scored lowest on precision. Microsoft found 512-token chunks beat 8,191 (Recall@50 42.4 against 34.9) and 25% overlap helped slightly. Anthropic's contextual retrieval cut top-20 retrieval failures by 35% (contextual embeddings), 49% (adding contextual BM25) and 67% (adding reranking), from 5.7% to 1.9%, at a one-off $1.02 per million document tokens with prompt caching (September 2024 prices).

When not to retrieve. Corpora under about 200,000 tokens can go fully in the prompt with caching; structured or fast-changing sources use tools such as SQL or APIs; large unstructured corpora use hybrid RAG (plan section 9).

Embedding model selection.

Criterion Question Evidence
Domain fit Does it find our documents for our queries? Golden-set recall, MRR, nDCG by query type
Languages Every supported language covered? Per-language golden set
Input length and dimensions Longest chunk fits? Index size acceptable? Model card; storage worksheet
Truncation and quantisation Can vectors shrink safely? Golden set at reduced size
Licence, deployment, residency API or open weights? Commercial use? Region? Licence text; region pinning
Price and change cost Ingestion, query and re-embedding cost? Price list; blue/green plan

Leaderboards (MTEB, MMTEB) build a shortlist of three to five; your golden set decides. Products are named only as examples: hosted embedding APIs and open-weights families are all valid candidates.

Storage worksheet: chunks x dimensions x 4 bytes (float32). Two million chunks at 1,024 dimensions is about 8.2 GB; at 3,072 about 24.6 GB, before index overhead and replicas. Matryoshka-style truncation and int8 or binary quantisation shrink this; measure the recall loss first.

Re-embedding: two million chunks of 300 tokens is 600 million tokens; at a hypothetical $0.10 per million that is $60. The real costs are rate-limited pipeline time, doubled storage during blue/green, evaluation runs and approval.

Hybrid search, fusion, reranking.

  • Run BM25 and vector search over the same filtered candidates.
  • RRF: score(d) = sum over rankers of 1 / (k + rank(d)), k = 60 (Cormack, Clarke and Büttcher, 2009).
  • Example, k = 60: P5 is rank 1 in BM25 and 4 in vector, 1/61 + 1/64 = 0.0320; G-04 is rank 2 and 1, 1/62 + 1/61 = 0.0325. G-04 edges ahead and the reranker decides.
  • Weighted score fusion or learned weights only if the golden set beats RRF.
  • Rerank 50 to 100 fused candidates down to the 5 to 20 you pass the model (Anthropic found 20 best among 5, 10 and 20 in its tests). Dedicated rankers add under 100 ms; LLM rerankers 1 to 2 seconds.
  • Query rewriting (HyDE, decomposition) and agentic retrieval only where the golden set shows a gain.

Metadata filters. Status, effective date, jurisdiction, language, document type and permissions, applied inside the query to both legs before fusion. Very selective filters can lower recall in some approximate vector indexes, so include selective-filter queries in the golden set.

Permission-aware retrieval.

  • Delegated user identity on every search, never the agent's service identity.
  • ACLs and labels copied onto chunks at ingestion with snapshot time; filtered at query time.
  • Post-hoc filtering fails three ways: results starve; restricted text reaches the reranker, model or cache; counts and "no access" messages reveal that content exists.
  • Maximum revocation lag per risk tier, monitored; fail closed on restricted labels when sync fails.
  • Oversharing fixed at source before launch; permission-metadata writes restricted.
  • Caches partitioned by tenant and authorisation context; residency pinned for embedding, search and model services.
  • Threat reference: OWASP LLM08 (unauthorised access, cross-tenant leaks, embedding inversion, poisoning).

Index lifecycle. Incremental updates for content changes, with deletion detection from the first run. Blue/green rebuild for parser, chunker, embedding-model, schema or ACL-model changes, with the golden set (and leakage suite) on both indexes before the alias swap and a rollback window. Versioned index names behind a stable alias. Freshness SLA per index. Retrieval configuration ships in the release bundle with prompts, tools and models (plan section 15).

Retrieval metrics.

Metric Tells you Note
Recall@k Share of relevant chunks in top k Fix first; k = what you pass the model
Hit rate@k Queries with any relevant chunk in top k Easy for sponsors
MRR Mean of 1 / rank of first relevant chunk Rewards best-first ranking
nDCG@k Rank-discounted gain, graded relevance For partly relevant chunks
Context precision and recall Relevance and coverage of passed context RAGAS; model-graded, calibrate
Faithfulness, citation accuracy Answer supported by context Generation layer

Golden-set rules: start with 20 to 50 real queries, grow from incidents (plan section 7); SME labels with provenance; mixed types (identifier, paraphrase, table lookup, multi-hop, negation, no-answer, permission-negative, each language); versioned with the index; thresholds set at G1; gate merge and every index change.

Lab 1: Chunk a policy two ways

Scenario. Northwind Mutual, a synthetic insurer, is building a claims assistant. Its first document follows.

Northwind Mutual Claims Handling Authority Policy, CHA-POL-007, version 3.1, effective 1 March 2026. Owner: Head of Claims Operations.

Section 1. Purpose and scope. This policy sets the financial authority claims staff hold when they agree and pay claims. It applies to personal-lines motor and home claims handled by Northwind Mutual staff and approved third-party administrators. Commercial lines follow CHA-POL-009.

Section 2. Definitions. Settlement value means the total paid on a claim, including fees, excluding any excess. A vulnerable customer is one whose circumstances, such as health, a life event, low resilience or low capability, make them especially susceptible to harm. Second approver means a colleague whose authority limit at least equals the settlement value.

Section 3. Authority limits. Each role may agree a settlement up to its limit. Above it, the approver shown must sign off before payment. Limits rose on 1 March 2026; the Level 1 limit was previously £5,000.

Role Authority limit Approver above the limit
Claims Handler Level 1 £7,500 Team Leader
Claims Handler Level 2 £25,000 Team Leader
Team Leader £60,000 Claims Manager
Claims Manager £150,000 Head of Claims Operations

Section 4. Fast-track claims. 4.1 A claim may be fast-tracked when the settlement value is under £2,000, liability is clear and no fraud indicators are present. 4.2 Motor glass claims may be fast-tracked up to £3,500. 4.3 Fast-tracked claims are paid without a second approver. A fast-tracked claim that later shows fraud indicators must leave the fast track and follow section 5.

Section 5. Referral to the Special Investigations Unit. Staff must refer a claim to the Special Investigations Unit (SIU) within two working days of identifying any fraud indicator in the SIU indicator guide. Do not tell the customer about the referral. Payment is suspended until the SIU releases the claim.

Section 6. Vulnerable customers. Where a customer shows signs of vulnerability, the handler records the need and offers reasonable adjustments, such as a named contact or a call at an agreed time. A settlement for a vulnerable customer must be confirmed by call or the customer's preferred channel before payment, never by automated message alone.

Section 7. Records and retention. Claim notes, decisions and approvals are kept for seven years after closure. Call recordings are kept for three years, or seven years where the customer is recorded as vulnerable.

Section 8. Exceptions. Exceptions need written approval from the Head of Claims Operations, logged with the reason and an expiry date.

Your task.

  1. Method A: chunk into windows of about 75 words with about 15 words of overlap, ignoring headings and table structure. Label chunks A1, A2 and so on.
  2. Method B: one chunk per section, table whole with its header, each prefixed "CHA-POL-007 v3.1 > Section n Title". Label P1 to P8.
  3. For each test question, name the chunk or chunks needed under each method and whether one chunk suffices.
    • T1. Who must approve a £70,000 settlement?
    • T2. What is the fast-track limit for motor glass?
    • T3. Within how many days must a claim go to the SIU?
    • T4. Can a fast-tracked claim end up with the SIU, and by when must it be referred?
    • T5. How long are call recordings kept for a vulnerable customer?
  4. Write a 50 to 100-token contextual prefix for P3 and P5.
  5. Recommend a method and one experiment to confirm it on a real corpus.

Hand in. Both chunk lists, the comparison table, two prefixes, a two-sentence recommendation.

Success criteria. All questions mapped under both methods; at least three concrete method A failures; prefixes name document, version and what the section governs; the recommendation includes a measurement.

Lab 2: Golden set and scoring

Scenario. Northwind Mutual's index holds policy sections P1 to P8; two superseded v2.0 sections (X-02 authority limits, showing a £5,000 Level 1 limit; X-03 exceptions); and guidance notes G-01 authority FAQ (no amounts), G-02 vulnerable-customer guidance, G-03 policy library index, G-04 SIU indicator guide, G-05 group records schedule (excludes claims), G-06 glass repair network guide (no thresholds), G-07 staff social events FAQ. A colleague drafted this golden set; it may contain errors.

ID Query Relevant (as drafted) Type
Q1 What is the maximum settlement a Claims Handler Level 2 can approve? P3
Q2 CHA-POL-007 section 4.2 P4
Q3 Can I settle with a customer in hardship by automated message? P6
Q4 When must a claim go to the fraud team? P5
Q5 How long do we keep claim notes? P7
Q6 fast track threshold motor glass P4
Q7 Who approves exceptions to authority limits? P8
Q8 Does a Team Leader need a second approver above £25,000? P3
Q9 What counts as a vulnerable customer? P6
Q10 Is the Level 1 limit still £5,000? X-02
Q11 What is the travel expense limit for loss adjusters? none
Q12 Who does the policy apply to? P1
Q13 SIU referral within how many days P5
Q14 Can a fast-tracked claim be referred to the SIU later, and how quickly? P4, P5
Q15 Retention period for call recordings of customers who need reasonable adjustments P6, P7

Top five results, best first:

ID System A: vector only System B: hybrid, RRF, reranker
Q1 P3, X-02, P8, P2, G-01 P3, P8, X-02, P2, P4
Q2 P1, G-03, P8, P6, P2 P4, P1, P3, G-03, P8
Q3 P6, G-02, P2, P4, P7 P6, P2, G-02, P4, P8
Q4 G-04, P5, P8, P4, P1 P5, G-04, P4, P8, P2
Q5 P7, G-05, P6, P1, P2 P7, P6, G-05, P1, P3
Q6 G-01, P3, G-06, P4, P1 G-06, P4, P3, G-01, P8
Q7 P3, P8, X-03, P1, G-01 P8, P3, X-03, P1, P2
Q8 X-02, P8, P3, G-01, P2 P3, X-02, P8, P2, G-01
Q9 P6, G-02, P7, P1, P4 P2, P6, G-02, P7, P1
Q10 X-02, X-03, G-01, P8, P2 X-02, P3, X-03, P8, G-01
Q11 G-07, P1, G-05, P3, P8 G-07, P8, P1, G-05, P3
Q12 P1, P2, G-03, P8, P7 P1, P2, P8, G-03, P5
Q13 G-04, P4, P8, G-06, P1 P5, G-04, P4, P8, P1
Q14 P4, G-06, P3, G-04, P1 P4, G-04, G-06, P3, P8
Q15 P6, G-05, P2, G-02, P1 P7, P6, G-05, P2, G-02

Your task.

  1. Tag each query's type: identifier, keyword, paraphrase, table lookup, version-sensitive, multi-hop or no-answer.
  2. Check every label against the Lab 1 policy; correct and justify any errors.
  3. Decide how Q11 enters your averages.
  4. With corrected labels, compute per-query and average recall@5 (share of relevant chunks in the top 5) and MRR@5 (1 / rank of the first relevant chunk, 0 if none) for both systems.
  5. Stretch: compute nDCG@5 with binary relevance; discuss partial credit for G-04 on Q4.
  6. Name the one change that fixes Q10 in both systems, and where System B still fails.
  7. Write three new labelled queries covering gaps.

Hand in. Corrected golden set, scoring table, three new queries.

Success criteria. Both labelling errors found; averages over the right queries; the Q10 fix identified as a metadata filter; at least one new query is permission-negative or a table lookup.

Lab 3: Permission-aware retrieval design

Scenario. Northwind Mutual is launching "Claims Copilot", an internal Tier 2 knowledge agent, for two groups. claims-handlers (about 600) may read the policy, guidance and their team's claim files. siu-investigators (25) may also read SIU case notes and detailed indicator thresholds, which must never reach handlers: revealing that a claim is under investigation risks tipping off the customer. Four handlers are seconded to the SIU until month end; an investigator returns to claims on Friday; permission sync runs nightly; an "SIU referrals tracker" was shared with all staff by mistake last year; the platform team wants a semantic response cache to save cost.

Your task.

  1. List the metadata every chunk needs for access control and audit.
  2. Describe how the agent authenticates to search and how groups are resolved.
  3. Write the query-time filter in plain words and say where it runs.
  4. Set a revocation-lag target for SIU content, how you meet it, and what happens if sync fails.
  5. Decide the cache policy.
  6. Write the agent's reply when the only relevant content is restricted.
  7. Design a leakage test suite, including the secondment and Friday cases.
  8. List pre-launch clean-up actions.

Hand in. A one-page design covering all eight points.

Success criteria. Filtering inside the request with delegated identity; restricted text never reaches reranker, model, cache or open logs; lag has a target, monitor and fail-closed behaviour; the reply does not confirm restricted content exists; zero-leak target.

Knowledge check

  1. In Barnett et al.'s failure points, what is "missed top-K"?
    • A. The source was never ingested
    • B. The answer is in the index but ranked too low to reach the model
    • C. The model ignored a chunk it was given
    • D. The answer was in the wrong format
  2. What is the CoE's default retrieval stack?
    • A. Vector search only, with large chunks
    • B. Agentic retrieval for every query
    • C. Hybrid BM25 plus vector search with a reranker, chunking tuned per corpus
    • D. Keyword search with query rewriting always on
  3. How should you treat "512 tokens with 20% overlap"?
    • A. As a starting point to test on your golden set
    • B. As the CoE standard for all corpora
    • C. As the size embedding models are trained for
    • D. As an audit requirement
  4. What does contextual retrieval do?
    • A. Retrieves whole documents
    • B. Uses conversation history as the query
    • C. Filters chunks by user context
    • D. Prepends a model-written, chunk-specific context before embedding and BM25 indexing
  5. You change embedding model. What must happen?
    • A. Only new documents use the new model
    • B. The corpus is re-embedded into a new index and evaluated before switching
    • C. New-model queries run against old vectors
    • D. Nothing, if dimensions match
  6. Why is RRF convenient for hybrid search?
    • A. It needs a model trained per corpus
    • B. It needs scores normalised to 0 to 1
    • C. It combines ranks, so BM25 and cosine scores need no common scale
    • D. It always prefers the vector result
  7. No retriever returned the relevant chunk. Will a reranker fix it?
    • A. No; it only reorders the candidates it receives
    • B. Yes; rerankers search the whole corpus
    • C. Yes, if it is an LLM reranker
    • D. Only if RRF's k rises
  8. Why does the CoE forbid post-hoc permission filtering?
    • A. It is slower than no filtering
    • B. Vector databases do not support it
    • C. It makes recall@k impossible to compute
    • D. Restricted text can reach downstream components and results can starve
  9. The first relevant chunk is at rank 3. What is the reciprocal rank?
    • A. 0.25
    • B. 0.33
    • C. 0.5
    • D. 3
  10. Why record embedding model and version on every chunk?
    • A. To improve BM25 scores
    • B. To let the model cite sources
    • C. To make mixed-version indexes visible and plan re-embedding
    • D. To satisfy the RRF formula

Scenario 1. A vendor says its new embedding model tops the leaderboard and asks you to switch the production index this week. What do you do, in order?

Scenario 2. A handler who left the SIU on Monday could still retrieve SIU case notes on Wednesday. What happened, and what do you change?

Job aid

  • Corpus scope, owners and sources listed; retrieval choice justified (full context, tools or hybrid RAG).
  • Residency pinned; oversharing fixed at source; permission-metadata writes restricted.
  • Layout-aware parsing; extraction sampled; hidden-text scan and upload quarantine on.
  • Provenance on every chunk: ID, version, status, page, section path, ACL, label, snapshot time, parser, chunker, embedding model and version.
  • Two or more chunking strategies compared on the golden set; tables whole; contextual retrieval tested where chunks lose meaning.
  • Embedding shortlist from leaderboards, decision from the golden set; licence, residency and re-embedding cost checked.
  • Hybrid BM25 plus vector with RRF; reranker within the latency budget.
  • Status, date and permission filters inside the query; delegated identity on every search.
  • Caches partitioned by tenant and authorisation context; no semantic cache for personalised or sensitive answers.
  • Golden set versioned, SME-labelled, mixed types including no-answer and permission-negative; thresholds set at G1 and gating merge.
  • Blue/green rebuilds behind an alias with rollback; deletion detection on; freshness and revocation lag monitored.
  • KPIs on the dashboard: recall@k, nDCG@k, missing-content rate, freshness lag, orphans, permission-sync lag.

Further reading

Facilitator guide

Session plan and talking points for trainers. The knowledge-check answer key and lab model answers in full are in the facilitator guide download.

Show the facilitator guide

Before the session

  • Sandbox: a notebook with a text splitter, one embedding model, an index supporting BM25 and vector search, and a cross-encoder reranker. Any open-source stack works; all labs also run on paper.
  • Load the Lab 1 policy as Markdown, plus one-paragraph stubs for the Lab 2 distractors (only their IDs matter).
  • Print the Lab 2 tables per group; provide calculators or a spreadsheet.
  • Make failure-point cards: the seven Barnett et al. failure points and twelve short synthetic incident descriptions.
  • Two synthetic PDFs for the demo: a two-column report with a table across a page break, and a scanned form. Never use client or employer documents.
  • Roles: lead facilitator, lab support, timekeeper; one helper per four groups above 16 participants.

Segment 1: Why retrieval fails (0:00 to 0:20)

Purpose: anchor the day in failure modes so each technique answers a specific failure.

  • If the right passage never reaches the context, no prompt fixes it. The CoE triages with Barnett et al.'s seven failure points (plan section 4A).
  • Agents call retrieval repeatedly; a weak tool multiplies retries and tokens.
  • The CoE default: hybrid search with a reranker, chunking tuned per corpus, agentic retrieval only where evals show a gain.

Activity: groups sort the incident cards onto failure points (8 minutes). Debrief: which failures show in a trace, which need a golden set, which need someone reading the source?

Watch-out: "it cited the old version" is filed under the model. It is wrong specificity, fixed by a status filter.

Segment 2: Parsing and layout-aware extraction (0:20 to 1:00)

Purpose: show that extraction quality caps chunking quality.

  • Plain extraction scrambles columns, scatters tables, repeats footers and drops image text.
  • Layout-aware parsers label elements with page and position. Examples: open-source document converters, cloud document-intelligence services, vision-language models reading page images.
  • Parsing needs its own eval, and is a security control: hidden-text scans and upload quarantine (plan section 4A).

Activity: run both PDFs through a plain extractor and a layout-aware parser; groups list each difference that would change a retrieval result.

Watch-out: "fix parsing later" means re-chunking and re-embedding everything later.

Segment 3: Chunking strategies (1:00 to 1:45)

Purpose: give a decision table and a testing habit, not a magic number.

  • Too large and an embedding blurs topics; too small and the chunk loses its meaning.
  • Walk the chunking table and the evidence paragraph in Key ideas; present every number as the author's result on the author's data.
  • Late chunking needs a long-context embedding model that exposes token-level outputs; contextual retrieval needs a one-off model pass per chunk.

Activity: show one section chunked three ways; ask which chunk answers "who approves above the Team Leader limit?"

Watch-outs: overlap is not context (it repeats neighbours; it does not say which document a chunk came from). Semantic chunking is slower to ingest and gives uneven sizes.

Segment 4: Choosing an embedding model (2:50 to 3:30)

Purpose: replace "top of the leaderboard" with a selection method that includes lifetime cost.

  • Leaderboards build shortlists; MTEB's authors found no method dominates all tasks.
  • Walk the selection table in Key ideas. Query and document vectors must come from the same model version, so a change means a blue/green re-embed and a golden-set run before switching.

Activity: groups complete the storage worksheet for two million chunks. Debrief: what dominates the cost of a model change?

Watch-out: comparing models on hand-picked queries, or with different chunking per candidate.

Segment 5: Hybrid search, fusion, reranking and filters (4:15 to 5:00)

Purpose: explain the hybrid-plus-reranker default and where latency goes.

  • BM25 wins on identifiers and rare words; vectors on paraphrase. In Microsoft's benchmark, pure keyword queries scored 11.7 NDCG@3 with vectors alone against 79.2 with keyword search.
  • Teach RRF, reranker latency and filter placement from Key ideas.

Activity: work the RRF example on the whiteboard, then set k = 1 and compare.

Watch-out: a reranker cannot rescue a chunk nobody retrieved. Fix recall first.

Segment 6: Permissions, index lifecycle and evals as gates (6:05 to 6:35)

Purpose: connect retrieval engineering to CoE controls and gates.

  • Teach the permission and lifecycle rules from Key ideas: delegated identity, filtering inside the request, revocation lag per tier, blue/green rebuilds.
  • The golden set is a regression suite (eval pyramid layer 2): thresholds set at G1, passed at G2, rerun on every index change.

Activity: whiteboard building v8, comparing with v7 on the golden set, swapping the alias and keeping v7 for rollback.

Watch-out: teams treat ACL sync as the identity team's problem. The retrieval owner owns the lag metric.

Running the labs

Lab 1 (pairs, 50 minutes). Method A: fixed windows of about 75 words with about 15 words of overlap, ignoring structure. Method B: one chunk per section, table whole, heading-path prefix.

Expected findings: method B answers all five test questions; method A typically fails as follows.

  • The authority table splits, so a row such as "Team Leader, £60,000, Claims Manager" loses its column headers (T1).
  • Clause 4.2 lands mid-window without its section title, and the cross-reference ending 4.3 separates from section 5 (T2, T4).
  • "Within two working days" can land in a window lacking "Special Investigations Unit" (T3).
  • "Call recordings are kept for three years, or seven years where the customer is recorded as vulnerable" can be cut after "three years", giving a confidently wrong T5 answer. Under method B, P7 answers T5 alone.
  • T4 needs P4 and P5 under either method: use it to introduce multi-hop questions and parent-child or agentic retrieval.

Model prefix for P5: "From Northwind Mutual's Claims Handling Authority Policy CHA-POL-007 v3.1, effective 1 March 2026. Section 5 sets when claims staff must refer suspected fraud to the Special Investigations Unit, the deadline, and that payment is suspended." For P3: "From CHA-POL-007 v3.1, effective 1 March 2026. Section 3 lists each claims role's settlement authority limit and who approves above it; it replaced the v2.0 limits."

Common mistakes: treating words as tokens (about 75 English words per 100 tokens is a rule of thumb); dropping the table header; prefixes that summarise the whole document instead of situating the chunk.

Lab 2 (groups, 50 minutes). Part A: two labelling errors. Q9 must include P2 (definitions) as well as P6. Q10 is labelled X-02 (superseded); the correct label is P3. Q11 has no answer in the corpus and is excluded from recall and MRR, so averages are over 14 queries. Accept arguments that G-04 is partly relevant to Q4 and use them to introduce graded relevance and nDCG.

Part B, corrected labels:

Metric System A (vector only) System B (hybrid + reranker)
Recall@5 9.5 / 14 = 0.68 13.5 / 14 = 0.96
MRR@5 8.58 / 14 = 0.61 13.0 / 14 = 0.93
Hit rate@5 11 / 14 = 0.79 14 / 14 = 1.00
nDCG@5 (stretch, binary) 0.57 0.92

System A misses Q2 (exact reference) and Q13 (identifier-heavy) entirely, misses Q10 because the superseded section outranks the current one, and finds only one of two chunks for Q9, Q14 and Q15. System B still ranks X-02 first for Q10 and misses P5 on multi-hop Q14. Scored with the uncorrected labels, System A's recall@5 rises to 0.79 and MRR to 0.69: a wrong golden set flatters a weak system.

Part C: good additions are a table-cell lookup ("Who approves a £70,000 settlement?"), a negation ("Which claims can't be fast-tracked?"), and a permission-negative query run as a user without SIU access.

Common mistakes: including Q11 in averages; scoring a two-chunk query as recall 1 when one chunk was found. Debrief: the Q10 fix is a status = current filter, not a better model; Q11 shows retrieval always returns something, so abstention is graded at the generation layer.

Lab 3 (groups, 40 minutes). Model solution:

  • Chunk metadata: allowed groups and users, deny entries, sensitivity label, source system, status, snapshot time.
  • Identity: the agent searches on behalf of the user with a delegated token; groups are resolved including nested groups, with a directory lookup when the token carries too many groups.
  • Filter: allowed groups intersect the user's groups, no deny entry matches, label at or below clearance, status current. It runs inside the request for both legs, before fusion and reranking.
  • Revocation lag: event-driven sync on siu-investigators membership changes plus nightly reconciliation; target one hour or less, monitored, fail closed for the SIU label if sync fails.
  • Cache: no semantic response cache; any tool-result cache keyed by tool, arguments and caller identity.
  • No-access response: "I can't find information you have access to on that." Never confirm a restricted document or investigation exists; no counts from restricted content.
  • Tests: for each restricted document, handler-persona queries return zero SIU chunks and investigator-persona queries retrieve them; add secondment-expiry and Friday-move cases.
  • Before launch: fix the overshared tracker at source, scan for all-staff grants on SIU folders, restrict who can write permission metadata.

Common mistakes: filtering after the reranker; using the service account; a "that is restricted" message that tips off the investigation; forgetting the cache. Debrief question: what happens if sync fails silently for two days?

Adapting the module

  • Half day: segments 1, 3 and 5 plus Lab 2; Lab 1 as pre-work; Lab 3 model solution as a handout.
  • Two days: add a build day: an end-to-end pipeline, a contextual-retrieval run and an embedding bake-off on a synthetic corpus.
  • Sectors: insurance and banking add information barriers and tipping-off rules to Lab 3; healthcare adds special-category labels and consent-scoped retrieval; legal adds matter-based ethical walls and legal hold on indexes.
  • Client delivery: run Lab 2 on 15 approved, anonymised client questions so the golden set becomes a G1 artefact the client owns at P5.

The deep-dive guides go further than this module; the policies and procedures are what learners will be held to on the job.

Module downloads

The facilitator guide (with the answer key), the participant guide (with labs, knowledge check and job aid) and an editable starter deck. Vendor-neutral and built on synthetic examples; adapt before client delivery.

↑