Leanpub Header

Skip to main content

Retrieval-Augmented Generation

A Comprehensive Guide to Building Intelligent Search-Powered AI Systems

Retrieval-Augmented Generation
This book is 100% completeLast updated on 2026-10-08

Build smarter AI systems that go beyond the limits of large language models. Retrieval-Augmented Generation is a practical guide to designing, implementing, and scaling RAG applications with modern retrieval techniques, vector databases, and real-world deployment strategies.

Minimum price

$19.00

$29.00

You pay

Author earns

$

Also available for 1 book credit with a Reader Membership

PDF
EPUB
WEB
APP
137
Pages
About

About

About the Book

Large language models are powerful but fundamentally limited -- they hallucinate facts, carry stale knowledge, and cannot access your organization's private data. Retrieval-Augmented Generation (RAG) solves these problems by connecting LLMs to external knowledge sources at inference time. This book takes you from the foundational concepts of RAG through advanced production implementation, covering architecture design, embedding strategies, vector databases, retrieval techniques, evaluation frameworks, security considerations, and real-world deployment patterns. Every chapter includes practical Python code examples using LangChain, LlamaIndex, ChromaDB, Pinecone, and other popular tools, so you can build, deploy, and scale RAG systems with confidence.

Bundle

Bundles that include this book

Author

About the Author

Steve Publications

Steve is a technology professional with over 20 years of experience in software development, server infrastructure, cybersecurity, vulnerability research and reverse engineering. He specializes in analyzing complex systems, identifying weaknesses and improving security.

Beyond his professional work, Steve collaborates with researchers and industry experts to create practical technical books covering software development, cybersecurity, cloud computing, DevOps, AI and enterprise technologies. His goal is to help IT professionals, students and enthusiasts develop practical skills through clear explanations, real-world examples and hands-on exercises.

At Steve Publications, we use AI to assist with translation, proofreading and editing but not to replace the research, technical expertise or hands-on experience behind our books. Some authors publish under pseudonyms for privacy or professional reasons.

Every book is written, reviewed and maintained by experienced professionals, supported by a private community of over 420 engineers and researchers. We prioritize technical accuracy, practical value and regularly updated content over mass-produced AI-generated text.

We welcome experienced professionals interested in writing or reviewing books, especially in specialized and emerging technology fields. If you'd like to contribute, contact us with your area of expertise.

We stand behind our work. If a book doesn't meet your expectations, Leanpub offers a 60-day money-back guarantee.

Contents

Table of Contents

A Comprehensive Guide to Building Intelligent Search-Powered AI Systems

Introduction: The Context Revolution

  1. What You Will Learn
  2. Who This Book Is For
  3. How to Use This Book

Chapter 1: The RAG Revolution – Why Context Is Everything

  1. The Knowledge Gap in Large Language Models
  2. From Fine-Tuning to Retrieval: A Paradigm Shift
  3. What RAG Actually Is (and Is Not)
  4. Why RAG Dominates Production AI Today
  5. How This Book Is Structured

Chapter 2: Foundations – LLMs, Embeddings and the Information Retrieval Landscape

  1. How Large Language Models Think (and Where They Fail)
  2. The Anatomy of Text Embeddings
  3. Information Retrieval: From TF-IDF to Dense Vectors
  4. The Similarity Math Behind Retrieval
  5. Bridging the Gap: Why These Three Must Work Together

Chapter 3: RAG Architecture – The Big Picture

  1. The Three Phases of a RAG Pipeline
  2. Indexing: Turning Raw Data into Searchable Knowledge
  3. Retrieval: Finding What Matters
  4. Generation: Synthesizing Answers from Context
  5. Architectural Patterns: Naive, Modular and Advanced RAG

Chapter 4: Data Ingestion and Chunking Strategies

  1. The Chunking Problem: Why It Matters More Than You Think
  2. Fixed-Size and Recursive Text Splitting
  3. Semantic and Structure-Aware Chunking
  4. Metadata Extraction and Enrichment
  5. Building a Production Document Ingestion Pipeline

Chapter 5: Embeddings – The Bridge Between Language and Search

  1. How Embedding Models Work Under the Hood
  2. Choosing the Right Embedding Model for Your Use Case
  3. Open Source vs. Commercial Embeddings: A Practical Comparison
  4. Fine-Tuning and Adapting Embedding Models
  5. Evaluating Embedding Quality

Chapter 6: Vector Databases – Storing and Searching at Scale

  1. What Makes a Vector Database Different
  2. Indexing Algorithms: HNSW, IVF, PQ and Beyond
  3. The Vector Database Landscape: Choosing Your Store
  4. Schema Design for Vector Stores
  5. Performance Tuning and Scaling

Chapter 7: Retrieval Techniques – Beyond Simple Similarity Search

  1. The Limits of Pure Vector Search
  2. Hybrid Search: Combining Dense and Sparse Retrieval
  3. Query Transformation Techniques
  4. Re-Ranking: The Secret Weapon of Good RAG
  5. Multi-Vector and Graph-Based Retrieval

Chapter 8: Generation – Crafting Better Answers from Retrieved Context

  1. Prompt Design for Context-Augmented Generation
  2. Managing Context Window Constraints
  3. Citation and Attribution in Generated Responses
  4. Handling Conflicting or Insufficient Information
  5. Multi-Turn Conversations and State Management

Chapter 9: Evaluation – Measuring What Matters

  1. What to Measure in a RAG System
  2. Retrieval Metrics: Recall, Precision and MRR
  3. Generation Metrics: Faithfulness, Answer Relevance and More
  4. Automated Evaluation Frameworks (RAGAS, DeepEval, Arize)
  5. Building an Evaluation Pipeline for Continuous Improvement

Chapter 10: Optimization – Making RAG Fast and Cost-Effective

  1. The Latency Budget: Where Time Goes in a RAG Request
  2. Caching Strategies at Every Layer
  3. Model Selection and Cost Optimization
  4. Batch Processing and Throughput Scaling
  5. Infrastructure Patterns for Production RAG

Chapter 11: Advanced RAG Patterns – Agentic, Multi-Modal and Beyond

  1. Agentic RAG: Letting Models Decide How to Retrieve
  2. Multi-Hop Reasoning with Iterative Retrieval
  3. Self-RAG and Reflective Retrieval Patterns
  4. Multi-Modal RAG: Beyond Text
  5. The Frontier: What’s Next for RAG

Chapter 12: Security, Privacy and Governance

  1. Data Privacy and PII Protection
  2. Prompt Injection and Jailbreak Attacks
  3. Access Control and Row-Level Security in RAG
  4. Audit Trails and Compliance
  5. Building a Security-First RAG Architecture

Chapter 13: Real-World Case Studies and Production Deployments

  1. Enterprise Knowledge Bases and Internal Search
  2. Customer Support and Helpdesk Automation
  3. Legal Document Analysis and Contract Review
  4. Healthcare and Medical Literature Retrieval
  5. Lessons from Production: What Works and What Does Not

Chapter 14: Building a Complete RAG Application – A Hands-On Project

  1. Project Setup and Architecture Decisions
  2. Building the Document Ingestion Pipeline
  3. Implementing Retrieval with Hybrid Search and Re-Ranking
  4. The Generation Layer with Streaming and Citations
  5. Deployment, Monitoring and Iteration

Conclusion: The Future of Context-Aware AI

Get the free sample chapters

Click the buttons to get the free sample in PDF or EPUB, or read the sample online here

The Leanpub 60 Day 100% Happiness Guarantee

Within 60 days of purchase you can get a 100% refund on any Leanpub purchase, in two clicks.

See full terms...

Earn $8 on a $10 Purchase, and $16 on a $20 Purchase

We pay 80% royalties on purchases of $7.99 or more, and 80% royalties minus a 50 cent flat fee on purchases between $0.99 and $7.98. You earn $8 on a $10 sale, and $16 on a $20 sale. So, if we sell 5000 non-refunded copies of your book for $20, you'll earn $80,000.

(Yes, some authors have already earned much more than that on Leanpub.)

Learn more about writing on Leanpub

Free Updates. DRM Free.

If you buy a Leanpub book, you get free updates for as long as the author updates the book! Many authors use Leanpub to publish their books in-progress, while they are writing them. All readers get free updates, regardless of when they bought the book or how much they paid (including free).

Most Leanpub books are available in PDF (for computers) and EPUB (for phones, tablets and Kindle). The formats that a book includes are shown at the top right corner of this page.

Finally, Leanpub books don't have any DRM copy-protection nonsense, so you can easily read them on any supported device.

Learn more about Leanpub's ebook formats and where to read them

Write and Publish on Leanpub

You can use Leanpub to easily write, publish and sell in-progress and completed ebooks and online courses!

Leanpub is a powerful platform for serious authors, combining a simple, elegant writing and publishing workflow with a store focused on selling in-progress ebooks.

Leanpub is a magical typewriter for authors: just write in plain text, and to publish your ebook, just click a button. (Or, if you are producing your ebook your own way, you can even upload your own PDF and/or EPUB files and then publish with one click!) It really is that easy.

Learn more about writing on Leanpub