Learn Everything

AI & LLM Systems

RAG & Vector Databases

Retrieval-Augmented Generation: semantic embeddings, vector indices, and context synthesis.

Retrieval-Augmented Generation (RAG) grounds LLMs on external authoritative knowledge without expensive fine-tuning. By chunking documents, calculating dense semantic embeddings, indexing with HNSW or IVF, and retrieving relevant passages at runtime, RAG prevents hallucinations and provides cited answers.

intermediateEst. 6-8 hrs study time4 Live LabsPart of AI Engineer Path ↗

Virtual Lab Ready

Automated testing sandbox running in your browser.

Launch First Lab ⚡

No local installation required

Hands-on Practice

Interactive Terminal Labs

Real environment tasks with automated validation. Write real commands, verify state, and debug errors.

4 tasks available
LAB 01
intermediatePractice Task

Build a Vector Index Pipeline Config

Topic: Embeddings and Vector Search

Configure a document chunking and vector index pipeline specification with chunk size and overlap parameters.

Key Checks:

  • Directory ~/rag-pipeline exists
  • File ~/rag-pipeline/indexing-config.yaml exists
Env: ubuntu:24.04Open Lab ↗
LAB 02
beginnerPractice Task

Split a Document into Chunks

Topic: Chunking Documents

Retrieval pipelines split documents into chunk files before embedding them. Create a chunks directory holding two one-line chunks, then write a manifest.txt that lists both filenames.

Key Checks:

  • Directory ~/rag-lab/chunks exists
  • Files chunk-01.txt and chunk-02.txt exist
Env: ubuntu:24.04Open Lab ↗
LAB 03
intermediatePractice Task

Configure the Vector Store

Topic: The Vector Store

The vector store holds the embeddings and answers the nearest-neighbour queries. Write the store configuration - index type, vector dimension and how many replicas it runs.

Key Checks:

  • Directory ~/rag exists
  • File ~/rag/store.yaml exists
Env: ubuntu:24.04Open Lab ↗
LAB 04
advancedChallenge

Blend Dense and Sparse Retrieval

Topic: The Vector Store

Dense vectors find meaning, keyword search finds exact identifiers. Blend the two and add a reranker on top - then say how much weight each side gets.

Key Checks:

  • File ~/rag/hybrid-search.yaml exists
  • The config defines a dense and a sparse retriever
Env: ubuntu:24.04Open Lab ↗

System Design

The RAG Ingestion & Query Pipeline

Understand how this tool operates internally before running production workloads.

Internal Mechanics

During ingestion, documents are parsed, chunked, and embedded into vectors stored in an index. At query time, the user prompt is converted to a query vector, matched against top-k similar chunks, and synthesized by the LLM.

Mental Model Rule of Thumb

Never treat RAG & Vector Databases as a black box. Understanding its boundary with the kernel, filesystem, and network stack prevents 90% of production outages.

Core Architectural Subsystems

Document Parser & Chunker

Splits PDFs, Markdown, and HTML into semantic chunks with overlap.

Embedding Model

Transforms text into high-dimensional vectors (e.g. OpenAI text-embedding-3).

Vector Database (Qdrant/Pinecone/pgvector)

Performs fast approximate nearest neighbor (ANN) search.

Reranker (Cohere/BGE)

Cross-encoder scoring retrieved candidates to place highest quality context first.

Developer Reference

Command Reference & Cheatsheet

Curated commands, flags, and one-liners tested for everyday operational productivity.

Setup
python -m pip install qdrant-client sentence-transformers

Install vector DB client and local open-source embedding models

Ingest
python ingest.py --chunk-size 512 --overlap 50

Run ingestion pipeline splitting documents and building index

Query
python query.py --top-k 5 --hybrid

Query vector index using combined semantic and keyword retrieval

Fundamental Primitives

Key Terminology & Primitives

Core abstractions you must master to communicate and build with confidence.

Cosine vs Dot Product

Measures of vector proximity; for normalized embeddings, dot product equals cosine similarity and computes faster.

Hybrid Search (Dense + Sparse)

Combines dense vector semantic search with BM25 keyword matching to capture exact technical terms and acronyms.

Lost in the Middle

The tendency of LLMs to attend best to tokens at the very beginning and end of long context prompts, ignoring mid-prompt information.

Context Window Packing

Fitting relevant chunks within the model context limit while preserving room for reasoning and generation.

Production War-Stories

Common Pitfalls & Debugging Playbook

The exact errors that take down production systems and how to diagnose and resolve them.

!

Hallucinations despite RAG retrieval

Symptom

Model invents answers not found in the provided context documents.

Resolution

Add strict system prompt constraints ('Answer strictly using the provided context. If the answer cannot be found, respond with I do not know'). Use a reranker to filter out irrelevant chunks.

Reliability Standards

Production Readiness Checklist

Review this checklist before deploying workloads to staging or production clusters.

  • ✓Evaluate retrieval quality using RAGAS or TruLens (Context Precision, Recall, Faithfulness).
  • ✓Implement hybrid search (vector + BM25) for technical documentation with code identifiers.
  • ✓Use rerankers before passing retrieved context into expensive frontier model prompts.
  • ✓Track latency across every step: embedding calculation, vector query, and model generation.

Full Curriculum Track

Master RAG & Vector Databases as part of the AI Engineer path

Tools do not exist in isolation. Learn how RAG & Vector Databases connects with other systems, CI/CD pipelines, and infrastructure patterns.