Skip to content

About

RAG & Qdrant walkthrough — hands-on vector DB study

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

1 Commit

Folders and files

Repository files navigation

RAG & Vector DB Study — Qdrant Edition

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.

Project structure

.
├── .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

Quick start

Option A — Dev Container (recommended)

  1. Open this folder in VS Code
  2. Install the Dev Containers extension
  3. Press Ctrl/Cmd + Shift + P → Dev Containers: Reopen in Container
  4. The container will start with Python 3.11 and Qdrant running automatically
  5. Dependencies install via pip install -r requirements.txt on first launch

Option B — Local setup

# 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 .env

Usage

Steps 1–2 and the notebook (up to section 5) work entirely offline — no API keys needed.
Only step 3 (LLM generation) requires an OPENAI_API_KEY.

1. Index documents

python scripts/01_index_documents.py

This 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.

2. Search (no API key needed)

python scripts/02_search.py "Which planets have rings?"

3. Full RAG query (optional — requires OpenAI key)

# Set your key first
export OPENAI_API_KEY=sk-...

python scripts/03_rag_query.py "Compare the atmospheres of Venus and Mars"

4. Interactive notebook

Open notebooks/rag_walkthrough.ipynb and step through each cell.

Configuration

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

What you'll learn

  • 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

Adding your own documents

Drop .txt, .md, or .pdf files into data/ and re-run 01_index_documents.py. The loader picks them up automatically.

Tech stack

Component Technology
Vector DB Qdrant (Docker)
Embeddings sentence-transformers / OpenAI
LLM OpenAI GPT-4o-mini
Framework LangChain (optional)
Language Python 3.11

About

RAG & Qdrant walkthrough — hands-on vector DB study

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages