Analysis updated 2026-05-18
Learn how a retriever and generator work together in a RAG pipeline without relying on a framework.
Study a hand-written implementation of gradient math and contrastive learning in plain Python.
Run the included training and inference pipeline to see retrieval and generation work end to end.
| canwhite/microrag | exploitbench/exploitbench | supperzl/ita | |
|---|---|---|---|
| Stars | 112 | 112 | 112 |
| Language | Python | Python | Python |
| Setup difficulty | easy | hard | moderate |
| Complexity | — | 4/5 | — |
| Audience | researcher | researcher | ops devops |
Figures from each repo's GitHub metadata at analysis time.
Runs with only Python's standard library, no external ML dependencies.
MicroRAG is a minimal working example of a Retrieval-Augmented Generation system, written entirely in plain Python without any AI or machine learning libraries. RAG is an approach where an AI first searches a knowledge base to find relevant information, then uses that information to generate an answer. This project builds both halves from scratch to show how the technique works at a low level. The retriever half converts questions and stored documents into 32-dimensional numerical vectors using a small embedding matrix, then finds the closest match by cosine similarity. It is trained using a technique called contrastive learning, where matching question-document pairs are pushed together and non-matching pairs are pushed apart. The generator half is a single-layer self-attention transformer that takes a question combined with the retrieved document text and produces a character-by-character response. All the gradient mathematics that normally come from a library like PyTorch are implemented by hand using only Python's standard library. The project includes a complete training and inference pipeline that you can run with a single command. In the example output shown in the README, the system correctly retrieves a relevant document about the sun and then generates an answer stating the surface temperature and core temperature. The README explicitly describes the scope limitations: the knowledge base contains only 8 fixed question-answer pairs, the tokenizer works at the character level with a vocabulary of around 60 symbols, the transformer has just one layer, and the maximum text length is 64 characters before position encodings wrap. This is described as a learning and demonstration project, not a production system. It is suited for someone who wants to understand how retrieval and generation fit together without the abstraction of a full-sized framework.
MicroRAG is a minimal retrieval-augmented generation system built entirely in plain Python from scratch, with no AI libraries, to teach how RAG works.
Mainly Python. The stack also includes Python.
Setup difficulty is rated easy, with roughly 5min to a first successful run.
Mainly researcher.
This repo across BitVibe Labs
Verify against the repo before relying on details.