RAG From Scratch in Python: Chunk, Embed, Retrieve (Local)
Build a working RAG system in plain Python with Ollama, and see exactly what it retrieves. No framework, no vector database, no API key.
Video #02 ยท RAG and vector search
Steps in the video
- 0:00 Build RAG in plain Python
- 0:16 What RAG is
- 0:47 Setup with Ollama
- 1:07 The documents
- 1:22 Chunk and embed
- 1:43 Find the closest chunks
- 2:06 Answer from the chunks
- 2:26 Running it
- 3:04 Check retrieval first
- 3:28 The chunk size trap
- 4:05 What this does not show
- 4:38 Four mistakes to avoid
- 5:00 My take and next steps
- 5:32 Recap
Files
- notes.txt (22 lines)
- rag.py (54 lines)
- truncation.py (25 lines)
Tested with
Python 3.12.15 | ollama==0.6.3
What this does not show
Seven made-up notes, a tiny embedding model (all-minilm) and a few questions on one laptop: not a benchmark. The truncation trap is shown with one example in Ollama. The advice pages were read as search results; the output on screen is the evidence.
Sources
Learning IT by Example.