Skip to main content

LessRAG

LessRAG is a "Concise and Intelligent" RAG (Retrieval-Augmented Generation) framework designed to move beyond traditional, brute-force text cutting.

🌟 Core Philosophy

Traditional RAG systems often rely on fixed-length or character-based chunking, which can break semantic continuity. LessRAG leverages Large Language Models (LLMs) to understand document structure and perform Smart Chunking, ensuring that each piece of information remains contextually coherent and semantically complete.

✨ Key Features

  • 🧠 Intelligent Chunking: Uses LLMs to identify logical boundaries and semantic shifts for superior document splitting.
  • 🚀 Lightweight & Efficient: Extremely low resource consumption. Unlike heavy frameworks (e.g., FastGPT), LessRAG can run smoothly in environments with as little as 2 Cores and 2GB RAM.
  • ⚡ Asynchronous Architecture: Heavy tasks like document parsing, smart chunking, and embedding generation are handled by an internal async task manager, ensuring a responsive API.
  • 📊 Status Tracking: Real-time monitoring of document processing states (processing, completed, failed).
  • 🔍 Dual Retrieval Modes:
    • Match: Pure vector similarity search for quick verification.
    • Query: Full RAG pipeline with LLM-augmented generation.
  • 🛠️ Built-in CLI: Easy configuration and server management through a dedicated command-line interface.

🛠️ Tech Stack

  • Framework: Python 3.10+, FastAPI
  • LLM/Embedding: OpenAI API (compatible with any OpenAI-style provider)
  • Database: SQLite (managed via Peewee ORM)
  • Parsing: PyMuPDF (PDF), docx2txt (Word)
  • Package Management: uv

🚀 Getting Started

Installation

LessRAG is available on PyPI. It is recommended to use uv for the best experience:

1. Run without installation (one-off):

uvx lessrag config
uvx lessrag server

2. Install as a global CLI tool:

uv tool install lessrag
# or with UI support
uv tool install "lessrag[ui]"

# or via pip
pip install lessrag
pip install "lessrag[ui]"

lessrag config
# edit the config.toml with your API keys and model preferences
lessrag server
# or start the UI (Mesop web UI served at the root path)
lessrag server --with-ui

3. Install from source (for development):

git clone https://github.com/yourusername/LessRAG.git
cd LessRAG
uv sync

Configuration

LessRAG provides a convenient command to set up your configuration:

lessrag config

This will create a config.toml in your current directory. Open it and fill in your OpenAI API keys and preferred models:

[model]
model="gpt-4"
api_url="https://api.openai.com/v1/chat/completions"
api_key="sk-..."

[embedding]
model="text-embedding-3-small"
api_url="https://api.openai.com/v1/embeddings"
api_key="sk-..."

Running the Server

Start the LessRAG server with:

lessrag server

By default, the server runs on http://0.0.0.0:18800.

📖 API Usage

Document Management

  • POST /api/v1/document/upload: Upload a PDF or Word file.
  • GET /api/v1/document/list: List all uploaded documents and their processing status.
  • GET /api/v1/document/{doc_id}: Get details of a specific document.

Retrieval & Generation

  • POST /api/v1/query: Perform a RAG query to get an answer based on your documents.
  • POST /api/v1/match: Find the most relevant document chunks without LLM generation.

📂 Project Structure

├── app/                # CLI implementation and templates
├── server/             # FastAPI backend logic
│   ├── api/            # API Route definitions
│   ├── database/       # Models and database setup
│   ├── tasks/          # Async task manager and workers
│   └── utils/          # Config, parsing, and vector utilities
├── tests/              # API and unit tests
└── pyproject.toml      # Project metadata and dependencies

⚖️ License

MIT License (or specify your license)

Metadata

Release files for lessRAG 1.0.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 lessRAG 1.0.0
File Size Uploaded Provenance Actions
lessrag-1.0.0.tar.gz 21.4 kB Without provenance Details for lessrag-1.0.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for lessRAG 1.0.0
File Interpreter ABI Platform Actions
lessrag-1.0.0-py3-none-any.whl Python 3 none any Details for lessrag-1.0.0-py3-none-any.whl

Total release size: 45.0 kB

Release files / lessrag-1.0.0.tar.gz

Download URL lessrag-1.0.0.tar.gz
Size 21.4 kB
Tags Source
SHA-256 checksum
How to use checksums
417a4bf2b34a4796c92617e7b49a244b5069616e3b55f569cffc6f86320035a3
BLAKE2b-256 checksum
How to use checksums
c89ed34df91ec84e5ce131531d288c8fa33466ef0a4b2a8fa8c2e4d5559f0a5d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.13.7 {"installer":{"name":"uv","version":"0.13.7","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / lessrag-1.0.0-py3-none-any.whl

Download URL lessrag-1.0.0-py3-none-any.whl
Size 23.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
c2f91105b242f71774fbf9bdc94458b6621e310ad373228812f028d59ba3fad9
BLAKE2b-256 checksum
How to use checksums
87120285348fe45217da7a162e0c115ee782e870a58be65080f7803365242948
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.13.7 {"installer":{"name":"uv","version":"0.13.7","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Security for lessRAG 1.0.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

1.0.0 This release

2 release files No provenance

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