A hands-on project for learning Retrieval-Augmented Generation (RAG) with Qdrant as the vector database.
No API keys required to get started. Indexing, embeddings, and similarity search all run locally using open-source models. An OpenAI key is only needed if you want to try the LLM generation step.
.
├── .devcontainer/ # Dev container config (VS Code / Codespaces)
│ ├── devcontainer.json
│ ├── docker-compose.yml
│ └── Dockerfile
├── data/ # Documents to index
│ └── sample.txt # Pre-loaded Solar System guide (sample knowledge base)
├── notebooks/
│ └── rag_walkthrough.ipynb # Step-by-step interactive notebook
├── scripts/
│ ├── 01_index_documents.py # Load → chunk → embed → upsert
│ ├── 02_search.py # Similarity search demo
│ └── 03_rag_query.py # Full RAG pipeline (needs OpenAI key)
├── src/
│ ├── config.py # Centralised settings from .env
│ ├── document_loader.py # Load & chunk text/PDF files
│ ├── embeddings.py # Local (sentence-transformers) & OpenAI embeddings
│ ├── rag_chain.py # Retrieve + Generate chain
│ └── vector_store.py # Qdrant collection & search helpers
├── .env.example
├── .gitignore
├── requirements.txt
└── README.md
- Open this folder in VS Code
- Install the Dev Containers extension
- Press
Ctrl/Cmd + Shift + P→ Dev Containers: Reopen in Container - The container will start with Python 3.11 and Qdrant running automatically
- Dependencies install via
pip install -r requirements.txton first launch
# Start Qdrant
docker run -d -p 6333:6333 -p 6334:6334 qdrant/qdrant
# Create and activate a virtual env
python3 -m venv .venv && source .venv/bin/activate
# Install dependencies
pip install -r requirements.txt
# Copy env file (OpenAI key is optional — only needed for step 3)
cp .env.example .envSteps 1–2 and the notebook (up to section 5) work entirely offline — no API keys needed.
Only step 3 (LLM generation) requires anOPENAI_API_KEY.
python scripts/01_index_documents.pyThis loads everything in data/, chunks it, generates embeddings with all-MiniLM-L6-v2 (local, free), and upserts the vectors into Qdrant. No API key needed.
python scripts/02_search.py "Which planets have rings?"# Set your key first
export OPENAI_API_KEY=sk-...
python scripts/03_rag_query.py "Compare the atmospheres of Venus and Mars"Open notebooks/rag_walkthrough.ipynb and step through each cell.
All settings live in .env (copied from .env.example):
| Variable | Default | Description |
|---|---|---|
QDRANT_URL |
http://localhost:6333 |
Qdrant server URL |
OPENAI_API_KEY |
— | Required only for generation (step 3) |
EMBEDDING_MODEL |
all-MiniLM-L6-v2 |
sentence-transformers model name |
COLLECTION_NAME |
rag_study |
Qdrant collection name |
CHUNK_SIZE |
512 |
Characters per chunk |
CHUNK_OVERLAP |
50 |
Overlap between consecutive chunks |
- How text is converted into vector embeddings
- How Qdrant stores, indexes, and retrieves vectors
- How similarity search works (cosine distance)
- How RAG combines retrieval with LLM generation
- How chunk size, overlap, and top-K affect quality
- How to use LangChain with Qdrant as a comparison
Drop .txt, .md, or .pdf files into data/ and re-run 01_index_documents.py. The loader picks them up automatically.
| Component | Technology |
|---|---|
| Vector DB | Qdrant (Docker) |
| Embeddings | sentence-transformers / OpenAI |
| LLM | OpenAI GPT-4o-mini |
| Framework | LangChain (optional) |
| Language | Python 3.11 |