RAG for Beginners: The Idea, Then 37 Lines of Python
I asked a model five questions about a cafe, and it got none right, until I gave it the facts.
Video #293 ยท RAG and vector search
Steps in the video
Files
- compare.py (11 lines)
- facts.py (19 lines)
- rag.py (37 lines)
Tested with
Python 3.12.15 | ollama==0.6.3
What this does not show
Eight made-up facts, five easy questions and one question the facts cannot answer; one seed, one small model (llama3.2), two facts retrieved. An answer counts as right if it contains one expected word. Run on one laptop; your counts may differ.
Sources
Learning IT by Example.