Learning Objectives
By the end of this chapter, you will be able to:
- Apply a chunking strategy for a given document structure and model constraints
- Filter extraneous content in source documents that degrades quality of a RAG application
- Choose the appropriate Python package to extract document content from provided source data and format
- Define operations and sequence to write given chunked text into Delta Lake tables in Unity Catalog
- Identify needed source documents that provide necessary knowledge and quality for a given RAG application
- Use tools and metrics to evaluate retrieval performance
- Design retrieval systems using advanced chunking strategies
- Explain the role of re-ranking in the information retrieval process
Executive Summary
- Source selection determines the ceiling of a RAG system; no chunking, embedding, or re-ranking trick rescues a corpus that lacks the answer.
- Chunking is a joint decision across document structure, embedding model context length, generator context budget, and retrieval top-k.
- Cleaning and filtering happen before chunking so token budgets are spent on signal, not navigation HTML or repeated footers.
- Delta Lake tables in Unity Catalog hold both the raw extraction layer and the chunked-with-embeddings layer, and Mosaic AI Vector Search reads from the chunked Delta table through Change Data Feed.
- Retrieval is measured with recall@k, precision@k, MRR, and nDCG against a curated evaluation set; re-ranking improves precision at small k once recall is already adequate.
Assumptions
- The reader has practitioner experience with Python, PySpark, Delta Lake, and the Mosaic AI Vector Search APIs covered in Chapter 1.
- Examples assume a Unity Catalog metastore is attached to the workspace and a catalog and schema already exist for the RAG application.
- Identifiers in code samples follow the pattern
catalog.schema.tableand use fictional names (acme_rag.bronze.docs_raw,acme_rag.silver.chunks, etc.). - All terms defined in Chapter 1 are reused without re-definition; only new terms introduced here are defined on first use.
