// LOADING
Every lab from the curriculum, in three modes: walk through the code section by section, practice tasks with AI verification, or experiment freely with the Gemini explainer.
RAG starts with documents. In real systems they come from PDFs, web pages, or a database; here we hard-code four short strings to keep the focus on the pipeline. Each string is one 'chunk'. In production, long documents get split into 200–800-token chunks first — but the rest of the pipeline doesn't change.
These four chunks are intentionally about different subtopics. That makes retrieval trivial here — in production, similar chunks are the hard case.
from openai import OpenAI
import numpy as np
client = OpenAI()
DOCS = [
"Pinecone is a managed vector database...",
"Weaviate supports hybrid (BM25 + vector) search...",
"BGE-M3 is an open-source multilingual embedding model...",
"RAGAS measures faithfulness, answer relevancy, context precision/recall.",
]