← All projects
ContactResume
Project

ragkit

A RAG toolkit in plain Python

Dependency-free retrieval-augmented generation toolkit: chunking, BM25, vector and hybrid retrieval, answers with cited sources.

PythonBM25TF-IDFRRFGitHub Actions
scroll
Overview

What it is

ragkit is a small retrieval-augmented generation toolkit written with only the Python standard library. It keeps the shape of a production pipeline (chunk, index, retrieve, generate) while staying runnable anywhere Python runs, with no API keys or model downloads needed to test or demo it.

Chunking

Fixed-size windows with overlap, or sentence-aware chunks that never split a sentence.

BM25 retrieval

Okapi BM25 with document-length normalisation and metadata filters.

Vector retrieval

In-memory cosine similarity over pluggable embedders. Ships with a hashing embedder and a corpus-fit TF-IDF embedder (no neural embeddings by default).

Hybrid search

Reciprocal rank fusion over the lexical and vector rankings.

Cited answers

Every answer carries its source chunks and scores so it can be cited.

Pluggable LLM

One-method protocol for embedders and LLMs; an offline echo LLM is included for tests and demos.

Flow

How it works

Chunk

Split documents into overlapping windows or whole-sentence chunks.

Index and retrieve

Rank chunks with BM25, vector similarity, or both fused with RRF.

Generate with sources

Build the prompt from the top chunks and return the answer with its cited sources.

Standard library only. Python 3.9+. Tested, with GitHub Actions CI.

Run it

git clone https://github.com/Prajit-22/ragkit.git cd ragkit python examples/quickstart.py
Next projectKaleshAI →