liveBook · Manning

Chapter 6: RAG fundamentals with ChromaDB

What you will learn in chapter 6 of AI Agents and Applications

The chapter introduces meaning-based search across documents and identifies RAG and vector stores as foundations for the Q&A systems it will build.

After this chapter you will be able to

Section by section

Introduction

The chapter introduces meaning-based search across documents and identifies RAG and vector stores as foundations for the Q&A systems it will build.

Key terms: semantic search, Q&A over documents, querying a knowledge base, RAG, vector store, semantic search systems

6.1 Semantic search

Defines semantic search and explains how meaning-based retrieval differs from keyword matching.

Key terms: semantic search, query, document fragments, document store, keyword-based searches

6.1.1 A basic Q&A chatbot over a single document

This section uses a single-document Q&A example to explain how a chatbot answers from supplied context, supports follow-up questions, and can produce unreliable answers when the text lacks the requested information.

Key terms: document, prompt, context, LLM-based chatbot, synthesize, Q&A engine, chatbot, stateful session, history of the conversation, additional context

6.1.2 A more complex Q&A chatbot over a knowledge base

This section explains why an enterprise Q&A chatbot needs focused content from a knowledge base rather than a prompt containing all company information.

Key terms: prompt, session, conversation history, knowledge base, context window, retrieve, context, ChatGPT, My GPTs, RAG design pattern

6.1.3 The RAG design pattern

Explains how a RAG chatbot prepares documents for semantic retrieval, then uses retrieved chunks as context for an LLM-generated answer.

Key terms: Retrieval Augmented Generation (RAG), content ingestion stage (indexing), question-answering stage (Q&A; retrieval and generation), context, content ingestion, chunks, embedding, vector database, semantic search, retriever

6.2 Vector stores

This introduction previews an explanation of what vector stores are, their purpose, what they offer, and examples.

6.2.1 What’s a vector store?

Defines vector stores and explains how stored embeddings support semantic similarity searches.

Key terms: vector store, high-dimensional vectors, embeddings, indexes, text chunks, similarity searches, query embedding, stored chunks, closest vectors, semantic similarity

6.2.2 How do vector stores work?

This section introduces vector similarity search, contrasts dense and sparse vectors, and traces vector stores from image search to text-based search.

Key terms: vector distance, Euclidean distance, cosine distance, Hamming distance, k-Nearest Neighbors (KNN), Approximate Nearest Neighbor (ANN), dense vector search, sparse vectors, image embeddings, lexical search

6.2.3 Vector libraries vs. vector databases

The section contrasts early vector libraries with vector databases and explains why their terminology has converged.

Key terms: vector libraries, vector databases, immutable data structures, CRUD, querying during import, embeddings, original data, unique identifier, metadata, vector store

6.2.4 Most popular vector stores

This subsection frames Table 6.1 as a provisional overview of popular vector stores rather than a definitive comparison.

Key terms: vector stores, rapid evolution and convergence

6.2.5 Storing text and performing a semantic search using Chroma

This section shows how to store text chunks in Chroma, retrieve semantically similar chunks, and distinguish retrieval from answer generation.

Key terms: in-memory client, collection, chunks, documents, embeddings, metadata, semantic search, distance, closest result, vector database

6.3 Implementing RAG from scratch

Introduces a RAG chatbot that retrieves content from ChromaDB so a user can ask a question without supplying the source text in the prompt.

Key terms: RAG, ChromaDB, GPT-5-nano, original question

6.3.1 Retrieving content from the vector database

This subsection wraps an existing vector-store semantic search in a reusable function and checks that it retrieves the expected text.

Key terms: semantic search, vector store, retrieved chunk

6.3.2 Invoking the LLM

This section shows how to send a retrieved-context Q&A prompt to an LLM and use prompt instructions to reduce unsupported answers.

Key terms: prompt, user’s question, context, vector database, LLM, hallucinations, retrieved context, hallucination-safe RAG prompt

6.3.3 Building the chatbot

This section presents a basic chatbot that answers questions from text imported into a vector database and states the limits of its answers.

Key terms: chatbot, vector database, hallucinate

6.3.4 Recap of RAG terminology

This subsection points readers to a RAG glossary and previews a LangChain reimplementation.

6.4 Summary

Summarizes why RAG scales Q&A beyond a single supporting document, how its retrieval pipeline works, and what affects retrieval quality.

Where this is used later

Concepts explained in this chapter

← Chapter 5: Agentic workflows with LangGraph Chapter 7: Q&A chatbots with LangChain and LangSmith →

These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.