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.3.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.3-py3-none-any.whl (8.7 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for softrag-0.1.3.tar.gz
Algorithm Hash digest
SHA256 620dbc7b43f527ddd093a663e6591491a7a8cbd1093ebdf09c1e48907a7cdb20
MD5 62ea04f827738d8e96531249b2f1eb58
BLAKE2b-256 8dcdea407b1041a006e7a93c58250513baaa576511cb8bed7f41810a846f16c4

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for softrag-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 c317664227bb468c77e3ff059ef8ddbe53468dd2b12a2a136316cfedad39b8bf
MD5 afc2e0d68fed8c4cc0334b3ba7d55357
BLAKE2b-256 8948d2aa471cf87f4096320059e9ad6ef440fa7b7778a04b551c14b44868095a

See more details on using hashes here.

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