Skip to main content

Minimal local-first Retrieval-Augmented Generation (RAG) library using SQLite with sqlite-vec

Project description

softrag License: MIT Python 3.12+ PyPI version

SoftRAG mascot – periquito

Minimal local-first Retrieval-Augmented Generation (RAG) library powered by SQLite + sqlite-vec.
Everything—documents, embeddings, cache—lives in a single .db file.


🌟 Features

  • Local-first – All processing happens locally, no external services.
  • SQLite + sqlite-vec – Documents, embeddings, and cache in a single .db file (no separate vector store or account needed).
  • No cloud service dependency – Plug in any LLM backend; no forced API keys for the core storage layer.
  • Blazing-fast – Designed for minimal overhead and maximum throughput on small- and medium-scale corpora.
  • Perfect for small & medium use cases – Ideal when you need a lightweight, self-contained RAG solution.
  • Configurable chunking – Default RecursiveCharacterTextSplitter (400/100) or your own strategy.
  • Model-agnostic – Works with OpenAI, Hugging Face, Ollama, etc.
  • Zero heavy deps – Core pulls only minimal extras (langchain-text-splitters optional).

📋 Requirements

  • Python 3.12+
  • Dependencies: sqlite-vec, trafilatura, pymupdf (for PDFs)
  • Access to embedding models and LLMs (uses OpenAI by default)

🚀 Installation

pip install softrag

🔧 Basic Usage

from softrag import Rag
from langchain_openai import ChatOpenAI, OpenAIEmbeddings

chat  = ChatOpenAI(model="gpt-4o")
embed = OpenAIEmbeddings(model="text-embedding-3-small")

rag = Rag(embed_model=embed, chat_model=chat)  # Uses default chunk splitter (RCTS)

# Add documents to your knowledge base
rag.add_file("document.pdf")
rag.add_web("https://example.com/page")

# Query your knowledge base with context-augmented answers
answer = rag.query("What is the main information in this content?")
print(answer)

also

_set_splitter(splitter=None): Configure the text chunking strategy. _retrieve(query, k): Retrieve the most relevant text chunks for a given query. _persist(text, metadata): Persist raw text into the database with optional metadata.

📚 Examples

See the examples/ folder for more detailed examples:

  • simple.py: Basic example with OpenAI
  • local.py: Example using local Transformers models

🔄 How It Works

SoftRAG uses a hybrid approach for retrieval:

  1. Extraction: Content is extracted from documents and web pages
  2. Splitting: Text is divided into smaller chunks
  3. Indexing: Each chunk is indexed by text (SQLite FTS5) and vector embedding
  4. Retrieval: Queries combine keyword search and vector similarity
  5. Generation: The most relevant chunks are sent to the LLM along with the question

🤝 Contributing

Contributions are welcome! Please feel free to submit Pull Requests.

📜 License

This project is licensed under the MIT License - see the LICENSE file for details.

Developed with ❤️ for AI community

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

softrag-0.1.2.tar.gz (10.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

softrag-0.1.2-py3-none-any.whl (8.7 kB view details)

Uploaded Python 3

File details

Details for the file softrag-0.1.2.tar.gz.

File metadata

  • Download URL: softrag-0.1.2.tar.gz
  • Upload date:
  • Size: 10.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for softrag-0.1.2.tar.gz
Algorithm Hash digest
SHA256 23ea596664894227802dffbe323551ead3479570a59055224db14d54a279db8e
MD5 e8521a57ffc657b9fbd3789a84f72ff0
BLAKE2b-256 377208b137659457c0f797e22b75ec6ca699891fa4feece1eb477e4af9edbcd7

See more details on using hashes here.

Provenance

The following attestation bundles were made for softrag-0.1.2.tar.gz:

Publisher: python-publish.yml on softrag/softrag

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file softrag-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: softrag-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 8.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for softrag-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 492ea126b716e15e038a4bbd13739bd7fbbb178349d5d286a565ab7b2a9e9da2
MD5 3fe73fe5aea9391f868b90791620cc25
BLAKE2b-256 f13f7c1187b45ff266d2175f76ca019eb9a0e442dcdd683751869619e7905d9b

See more details on using hashes here.

Provenance

The following attestation bundles were made for softrag-0.1.2-py3-none-any.whl:

Publisher: python-publish.yml on softrag/softrag

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page