Skip to content

Chapter 2 of 6

Retrieval and Knowledge

At the heart of any RAG system is the retrieval pipeline, and chunking is its starting point. Chunking splits documents into smaller passages that can be indexed and retrieved effectively without losing too much meaning. Once chunks exist, embedding search converts the text into vectors and finds semantically similar passages even when exact keywords differ, allowing the system to match questions to relevant content based on meaning rather than literal wording.

Reranking then reorders retrieved passages using a stronger relevance model so the most useful context appears first in the prompt. This two-stage approach, broad retrieval followed by focused reranking, often outperforms using either stage alone. Retrieval quality is what ties these pieces together, measuring whether the right documents are found for a user question, and it matters because poor retrieval leads to poor answers even when the model is strong. A common mistake is blaming the model when the retrieved context was irrelevant.

When retrieval succeeds, source citation links the generated claims to the supporting documents or records, letting users verify answers and increasing trust. A common mistake here is citing sources that were not actually used or do not support the claim, which undermines the very trust citation is meant to build. Practicing retrieval quality and citation in a small realistic example, and asking what problem each technique is solving, what trade-off it creates, and how the result will be measured, makes these habits reliable before they are deployed at scale.

All chapters
  1. 1Foundations of LLM Applications
  2. 2Retrieval and Knowledge
  3. 3Prompts and Output
  4. 4Application Behavior
  5. 5Safety and Security
  6. 6Operations

Drill it

Reading is not remembering. These come from the Llm Application Design deck:

Q

What is an LLM application?

An LLM application combines a language model with product logic, data, tools, prompts, and user experience to solve a specific workflow.

Q

What is retrieval-augmented generation (RAG)?

RAG retrieves relevant external documents and adds them to model context so answers can use fresh or private knowledge.

Q

Why is grounding important in LLM apps?

Grounding ties model output to provided sources, records, or tool results, reducing hallucinations and making answers easier to verify.

Q

What is prompt injection?

Prompt injection is an attack where untrusted content tries to override instructions, reveal secrets, or force unintended actions.