Phase 1: RAG foundations
Make an AI answer from your own documents. A model only knows what it was trained on. RAG (retrieval-augmented generation) fetches the right pieces of your documents first and hands them to the model, so answers are specific and can cite a source. Nearly every useful AI product starts here.
After this phase you can
- Split documents into chunks and explain why the cut points matter
- Turn text into vectors and compare them with cosine similarity
- Combine keyword search (BM25) and vector search into a hybrid
Before you start: Basic Python: lists, dictionaries, functions, loops.
Lessons in this phase
- What is RAG? Beginner · 8 min
RAG (Retrieval-Augmented Generation) means you first find the relevant pieces of your own documents, then give only those pieces to a language model so it answers from them.
- Embeddings Beginner · 9 min
An embedding is a list of numbers that represents the meaning of a piece of text, so that texts with similar meaning get similar numbers.
- Tokenization Beginner · 8 min
Tokenization is splitting text into small units called tokens (words or word pieces) that a model can turn into numbers.
- Chunking Beginner · 8 min
Chunking is cutting long documents into smaller pieces so each piece can be embedded, searched and shown to the model on its own.
- Recursive Chunking Beginner · 8 min
Recursive chunking splits text on the biggest natural break first (paragraphs), and only falls back to smaller breaks (lines, sentences, words) for pieces that are still too long.
- Semantic Chunking Intermediate · 8 min
Semantic chunking starts a new chunk wherever the meaning of the text shifts, by comparing the embeddings of neighbouring sentences.
- Parent Child Chunking Intermediate · 8 min
Parent-child chunking searches over small "child" chunks for precise matches, then gives the model the larger "parent" chunk each child came from, for full context.
- Sliding Window Chunking Beginner · 6 min
Sliding window chunking makes fixed-size windows of text that move forward by a smaller step, so every border region appears inside at least one full window.
- Metadata Beginner · 6 min
Metadata is extra information stored next to each chunk — like source file, page, date, author or access level — used for citations, filtering and debugging.
- Vector Databases Intermediate · 8 min
A vector database stores embeddings with their text and metadata, and finds the vectors closest to a query vector quickly, even among millions.
- Cosine Similarity Beginner · 7 min
Cosine similarity measures how closely two vectors point in the same direction, from −1 (opposite) through 0 (unrelated) to 1 (same direction), ignoring their length.
- Euclidean Distance Beginner · 6 min
Euclidean distance is the straight-line distance between two points, so smaller means more similar and 0 means identical.
- Dot Product Beginner · 6 min
The dot product multiplies two vectors element by element and adds the results; a bigger number means the vectors are more aligned and/or longer.
- HNSW Advanced · 9 min
HNSW (Hierarchical Navigable Small World) is a graph-based index that finds approximate nearest neighbours by hopping from point to closer point, starting on sparse "express" layers and finishing on a dense bottom layer.
- IVF Index Advanced · 9 min
An IVF (Inverted File) index groups vectors into clusters, then at query time searches only the few clusters closest to the query instead of every vector.
- Hybrid Search Intermediate · 9 min
Hybrid search runs keyword search and embedding search side by side and merges their results, so you catch both exact-term matches and same-meaning matches.
- BM25 Intermediate · 10 min
BM25 is a classic keyword-ranking formula that scores a document higher when it contains the query's words often, when those words are rare across the collection, and when the document is not padded with extra text.
- Sparse Retrieval Intermediate · 8 min
Sparse retrieval represents text as very long vectors that are mostly zeros — one slot per vocabulary word — and finds documents by matching the words they share with the query.
- Dense Retrieval Intermediate · 9 min
Dense retrieval finds documents by comparing short, meaning-based embedding vectors of the query and the documents, so it matches ideas even when the words differ.
- Metadata Filtering Intermediate · 9 min
Metadata filtering restricts a search to chunks whose metadata matches rules — like "team = security" or "year ≥ 2025" — so results are relevant, current and allowed for this user.