explaingit

honestsoul/rag_patterns

Analysis updated 2026-05-18

29PythonAudience · developerComplexity · 2/5Setup · easy

TLDR

Five simple Python scripts that each demonstrate a different Retrieval-Augmented Generation pattern, with no API keys or real models needed.

Mindmap

mindmap
  root((rag_patterns))
    What it does
      Teaches five RAG patterns
      Uses simulated models
      No API keys needed
    Tech stack
      Python
      NumPy
      NetworkX
    Use cases
      Learning RAG architectures
      Hybrid search study
      Knowledge graph prototyping
    Audience
      Developers
      AI learners
    Patterns
      Hybrid and graph RAG
      Agentic and corrective RAG
      Multimodal RAG

Code map

Detail Auto

An interactive map of this repo's files and how they connect — its source is parsed live in your browser. Click Visualize to build it.

filefunction / class

What do people build with it?

USE CASE 1

Learn how hybrid, graph-based, agentic, corrective, and multimodal RAG pipelines are structured.

USE CASE 2

Study a from-scratch BM25 keyword search implementation alongside vector similarity search.

USE CASE 3

Use the graph-based script as a starting point for building a knowledge graph from entities and relationships.

What is it built with?

PythonNumPyNetworkX

How does it compare?

honestsoul/rag_patternsadityasharmadotai-hash/docs-reader-rag-agentalekseiul/hermes-researcher-agent
Stars292929
LanguagePythonPythonPython
Setup difficultyeasyeasymoderate
Complexity2/52/52/5
Audiencedevelopervibe coderresearcher

Figures from each repo's GitHub metadata at analysis time.

How do you get it running?

Difficulty · easy Time to first run · 5min

Only numpy and networkx are required, no API keys since models and embeddings are simulated.

In plain English

This repository is a teaching collection of five small Python scripts, each one showing a different way to wire up a Retrieval-Augmented Generation system. RAG, in plain terms, is the technique of looking things up from a document store and then handing those snippets to a language model so it can write a better answer. The five scripts are kept simple on purpose: nothing calls a real cloud model, no API keys are needed, and the embeddings and LLM responses are faked with deterministic random numbers. The point is to see the shape of each pipeline, not to measure quality. The first script, hybrid RAG, runs two searches at once over the same documents. One uses dense vector similarity (the kind powered by neural embeddings) and the other uses BM25, a classic keyword scoring method written from scratch here. The two ranked lists are merged with Reciprocal Rank Fusion and the top results go to the model. The second script builds a knowledge graph with the networkx library, where people, companies, technologies, and locations become nodes and verbs like founded or ceo_of become labelled edges. A query first extracts entities, then walks the graph a few hops to gather a subgraph, then summarises that subgraph before sending it to the model. The third script, agentic RAG, sets up a planner that picks tools to call (vector search, web search, or SQL), runs them in a loop until confidence is high enough, and then asks a reasoner agent to write the final answer. The fourth script, corrective RAG, scores the retrieved chunks and branches on the verdict: keep them, rewrite the query and try again, or fall back to a simulated web search. The fifth script is multimodal, mapping text chunks, image captions, and tables into one shared vector space and re-ranking by the modality the query asks for. Dependencies are just numpy and networkx.

Copy-paste prompts

Prompt 1
Explain how the hybrid RAG script combines vector search and BM25 with Reciprocal Rank Fusion.
Prompt 2
Walk me through how the knowledge graph RAG script builds and queries its graph.
Prompt 3
What does the corrective RAG script do when retrieved chunks score poorly?
Prompt 4
How does the multimodal RAG script combine text, image captions, and tables into one search space?

Frequently asked questions

What is rag_patterns?

Five simple Python scripts that each demonstrate a different Retrieval-Augmented Generation pattern, with no API keys or real models needed.

What language is rag_patterns written in?

Mainly Python. The stack also includes Python, NumPy, NetworkX.

How hard is rag_patterns to set up?

Setup difficulty is rated easy, with roughly 5min to a first successful run.

Who is rag_patterns for?

Mainly developer.

Open on GitHub → Explain another repo

This repo across BitVibe Labs

Verify against the repo before relying on details.