RAG from Scratch is now live on GitHub
Posted by purellmagents@reddit | LocalLLaMA | View on Reddit | 3 comments
It’s an educational open-source project, inspired by my previous repo AI Agents from Scratch, available here: https://github.com/pguso/rag-from-scratch
The goal is to demystify Retrieval-Augmented Generation (RAG) by letting developers build it step by step. No black boxes, no frameworks, no cloud APIs.
Each folder introduces one clear concept (embeddings, vector stores, retrieval, augmentation, etc.) with tiny runnable JS files and a CODE.md file that explains the code in detail and CONCEPT.md file that explains it on a more non technical level.
Right now, the project is about halfway implemented:
the core RAG building blocks are already there and ready to run, and more advanced topics are being added incrementally.
What’s in so far (roughly first half)
- How RAG works (tiny <70-line demo)
- LLM basics with
node-llama-cpp - Data loading & preprocessing
- Text splitting & chunking
- Embeddings + cosine similarity
- In-memory vector store + k-NN search
- Basic retrieval strategies
Everything runs fully local using embedded databases and node-llama-cpp for inference, so you can learn RAG without paying for APIs.
Coming next
Still missing / coming next
- Query preprocessing & normalization
- Hybrid search, multi-query retrieval
- Query rewriting & re-ranking
- Post-retrieval reranking
- Prompt engineering for RAG (citations, compression)
- Full RAG pipelines with errors, fallbacks & streaming
- Evaluation metrics (retrieval + generation)
- Caching, observability, performance monitoring
- Metadata & structured data
- Graph DB integration (embedded with kuzu)
- Templates (simple RAG, API server, chatbot)
Why this exists
At this stage, a good chunk of the pipeline is implemented, but the focus is still on teaching, not tooling:
- Understand RAG before reaching for frameworks like LangChain or LlamaIndex
- See every step as real, minimal code - no magic helpers
- Learn concepts in the order you’d actually build them
Feel free to open issues, suggest tweaks, or send PRs - especially if you have small, focused examples that explain one RAG idea really well.
Thanks for checking it out and stay tuned as the remaining steps (advanced retrieval, prompt engineering, evaluation, observability, etc.) get implemented over time
Icy_Gas8807@reddit
Looks promising, will definitely check it out.
Irrationalender@reddit
Nice project, like the structure!
Either-Rest-3309@reddit
Seems dope will check it out.