FastRAG
Ask questions about the FastAPI tutorial and get answers grounded in the docs themselves. Built from scratch, with no LangChain or LlamaIndex, so every step of the pipeline stays visible.
Overview
Most RAG failures are retrieval failures, not generation failures. FastRAG is built around that insight: index the FastAPI docs once, then test retrieval on its own before ever asking an LLM to write an answer.
INDEXING (once)
FastAPI docs --> chunker_v2.py --> chunks --> embedding model --> ChromaDB (rag_db/)
QUERYING (every question)
question --> embedding model --> closest chunks --> prompt --> AI writes the answer
Key features
- No framework RAGChunking, embeddings, search and prompting wired by hand.
- Docs aware chunkerKeeps code blocks whole, stamps the heading trail on every chunk, inlines referenced code.
- Shared configOne model name / DB folder / collection, so indexing and search can never drift apart.
- Retrieval eval
eval.py + questions.jsonchecks if the answer is inside the top chunks. - Keyword baseline
rag_lite.py(stdlib only) gives a score to beat: 2/7 top 1, 3/7 top 3. - Local answersPaste the prompt anywhere, or answer via local Ollama.
How it works
- Clone the FastAPI docs and run
index.pyto chunk, embed and store them in ChromaDB. - Run
search.py "your question"to fetch the closest chunks and a prompt ready to paste. - Run
ask.pyfor the full loop, oreval.pyto score retrieval in isolation.
python index.py # embed all chunks (run once)
python search.py "How do I make a query parameter optional?"
python eval.py
python ask.py "How do I make a query parameter optional?"
Stack
Python 3.10+
sentence-transformers
ChromaDB
Ollama
RAG