Coders In Hoods
  • Courses
  • Roles
  • Blog
  • Setup

Coders In Hoods AI Academy

Every course is free. Sign in to start, and your progress, quiz scores and bookmarks follow you.

AI Academy

  • Courses
  • Paths
  • Setup guides
  • How we teach

Role roadmaps

  • AI Engineer
  • Forward Deployed Engineer
  • Machine Learning Engineer
  • All roles

Coders In Hoods

  • The agency
  • Coaching for teams
  • Blog
  • LinkedIn
  • X (Twitter)

Contact

codersinhoods@gmail.com

© Coders In Hoods · since 2019

Course overview

Retrieval and Knowledge Systems

Free · sign in to start and track progress

1 · Building the index

  • 1Embeddings in practice
  • 2Chunking structured documents

    Exercise answers

    • Answer: Structure-aware and contextual chunking, measured
    • Answer: Try late chunking (stretch)
  • 3Vector indexes and databases
  • 4Measuring retrieval

2 · Retrieval that reasons

  • 5Hybrid search and reranking
  • 6Agentic retrieval
  • 7Knowledge graphs and GraphRAG
  • 8Long context versus RAG
CapstoneA measured retrieval service for cases and reference documentsReference implementation

Module 1 · Building the index · Lesson 2

Chunking structured documents

How to cut contracts, records, reports and correspondence into retrievable units along their own structure, and how contextual retrieval and late chunking give each chunk back the context it lost.

70 min 1 video 3 exercises 6-question quiz Answers
Setup for the exercises:Python with uvInstall Claude CodeGet an OpenRouter keyLocal models with OllamaRun Hugging Face models on CPU

By the end of this lesson you can

  • Explain the trade-off between small and large chunks for retrieval precision, recall and citation
  • Implement a structure-aware chunker that splits on clause and schedule boundaries and keeps provenance to page and block
  • Compute the cost of contextual retrieval for a long contract with and without prompt caching
  • Compare contextual headers, contextual retrieval and late chunking, and choose one for a given corpus

On this page

  • What a chunk is for
  • Cut along the document's own structure
  • A structure-aware chunker
  • Small to big: retrieve one unit, return another
  • Give each chunk its context back
  • 1. Contextual headers (free)
  • 2. Contextual retrieval (an LLM call per chunk)
  • Worked example: contextualising one lease
  • 3. Late chunking (one long embedding pass)
  • Metadata travels with every chunk
  • Connections
  • Summary
  • Sources & further reading
  • Quiz

In this lesson

  1. 01What a chunk is for
  2. 02Cut along the document's own structure
  3. 03Give each chunk its context back
  4. 04Metadata travels with every chunk
  5. 05Connections
  6. 06Summary

Sources & further reading

  • Late Chunking: Contextual Chunk Embeddings Using Long-Context Embedding ModelsPaper · Günther, Mohr, Williams, Wang, Xiao · Jina AI · 2024Embed the whole document first, then pool token vectors per chunk. Section 3 explains the method in a page and a diagram; no retraining needed.
  • Is Semantic Chunking Worth the Computational Cost?Paper · Qu, Tu, Bao · 2024A careful negative result. Embedding-similarity "semantic" chunking did not consistently beat fixed-size chunking. Read the results tables before paying for clever splitting.
  • Rethinking Chunk Size For Long-Document Retrieval: A Multi-Dataset AnalysisPaper · Bhat, Rudat, Spiekermann, Flores-Herr · 2025Evidence that the best chunk size depends on the answer type and the embedding model. Small chunks won for short factual answers, larger chunks for answers that need context.
  • Introducing Contextual RetrievalLab research · Anthropic · 2024The main reading. The method, the exact prompt, the measured reductions in retrieval failures (35%, 49% and 67%) and the cost model. Read it all; it is short.
  • Voyage contextualized chunk embeddingsDocs · Voyage AIA commercial API in the same spirit as late chunking. You send each document's chunks as one list and get back chunk vectors that reflect the whole document.
Free · sign in to start

Sign in to keep reading.

Free, no card. We use your account to save progress, quiz scores, bookmarks and occasionally send updates from our team.

  • 6 more sections
  • 3 hands-on exercises
  • A 6-question quiz
  • Progress, quiz scores and bookmarks