Skip to main content

easy-rag

RAG in 3 lines of code. Zero dependencies. Load documents, ask questions, get answers.

from easy_rag import EasyRAG

rag = EasyRAG("./my_docs/")
answer = rag.ask("What does the contract say about termination?")
print(answer)

That's it. No API keys, no vector databases, no configuration.

Why easy-rag?

easy-rag LangChain LlamaIndex
Lines to get started 3 50-100+ 30-80+
Dependencies 0 50+ 40+
Setup time Instant Minutes Minutes
Requires API key No Usually Usually
Install size < 50 KB 200+ MB 150+ MB

Installation

pip install easy-rag

Optional extras

pip install easy-rag[pdf]      # PDF support (pdfplumber)
pip install easy-rag[openai]   # OpenAI embeddings
pip install easy-rag[local]    # Local embeddings (sentence-transformers)
pip install easy-rag[all]      # Everything

Quick Start

Search your documents

from easy_rag import EasyRAG

# Load an entire folder of documents
rag = EasyRAG("./contracts/")

# Ask a question
result = rag.ask("What is the payment schedule?")
print(result)
# [contract_v2.pdf | Score: 0.87]
# Payment is due within 30 days of invoice date...

Add documents on the fly

rag = EasyRAG()

# Add individual files
rag.add_document("report.md")
rag.add_document("notes.txt")

# Add raw text directly
rag.add_text("The meeting is scheduled for Friday at 3pm.", source="email")

# Search
results = rag.search("meeting schedule", top_k=3)
for r in results:
    print(f"[{r.score:.2f}] {r.chunk.text[:100]}")

CLI usage

# Search documents from the command line
easy-rag ./docs/ "What are the key findings?"

# Show index statistics
easy-rag ./docs/ --stats

# Customize chunk size
easy-rag ./docs/ "query" --chunk-size 1000 --top-k 5

Check index stats

rag = EasyRAG("./docs/")
print(rag.stats())
# {
#   'num_chunks': 142,
#   'num_sources': 12,
#   'num_unique_terms': 3847,
#   'chunk_size': 500,
#   'overlap': 50
# }

Supported File Formats

Format Support Notes
.txt Built-in Plain text files
.md Built-in Markdown files
.json Built-in Extracts all string values
.pdf Optional Requires pip install easy-rag[pdf]

How It Works

  1. Load — Reads all supported files from a directory
  2. Chunk — Splits text into overlapping pieces at smart boundaries (paragraphs, sentences)
  3. Index — Builds a TF-IDF index using only Python's standard library
  4. Search — Finds the most relevant chunks using cosine similarity
  5. Return — Gives you the best matching text with source and score

No neural networks, no API calls, no GPU needed. Just fast, reliable text search.

API Reference

EasyRAG(path=None, chunk_size=500, overlap=50)

Create a new RAG index.

  • path — Directory or file to load (optional, can add later)
  • chunk_size — Max characters per chunk (default: 500)
  • overlap — Character overlap between chunks (default: 50)

.ask(question, top_k=3) -> RAGResult

Ask a question and get a formatted answer with sources.

.search(query, top_k=5) -> List[SearchResult]

Search for relevant chunks (raw results).

.add_document(filepath) -> int

Add a single file to the index. Returns number of chunks created.

.add_text(text, source="inline") -> int

Add raw text to the index. Returns number of chunks created.

.stats() -> dict

Get index statistics.

License

MIT

Metadata

Release files for easyrag-kit 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for easyrag-kit 0.1.0
File Size Uploaded
easyrag_kit-0.1.0.tar.gz 11.2 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for easyrag-kit 0.1.0
File Interpreter ABI Platform
easyrag_kit-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 25.4 kB

Release files / easyrag_kit-0.1.0.tar.gz

Download URL easyrag_kit-0.1.0.tar.gz
Size 11.2 kB
Tags Source
SHA-256 checksum
How to use checksums
9fc78aba8989ae3f06d3d93d1ed288bc975092332622cab0ac73aec0330ea73a
BLAKE2b-256 checksum
How to use checksums
60f1bf657c953bd91fe57a53948a2305afe6e5fefb39cf5b5cb1d533e1904f96
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.3

Release files / easyrag_kit-0.1.0-py3-none-any.whl

Download URL easyrag_kit-0.1.0-py3-none-any.whl
Size 14.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
cfccd338deb8cebc01a4cd468e90e13ba329f863d229f2db855eb0295c68af4c
BLAKE2b-256 checksum
How to use checksums
b7b560dea91b51478b6d5cbadcba272b0c0c92c2e3a99d6f9aa494ae6b574e3e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.3

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page