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 required for storage
  • SQLite + sqlite-vec – Documents, embeddings, and cache in a single .db file
  • Model-agnostic – Works with OpenAI, Hugging Face, Ollama, or any compatible models
  • Blazing-fast – Optimized for minimal overhead and maximum throughput
  • Multi-format support – PDF, DOCX, Markdown, text files, and web pages
  • Hybrid retrieval – Combines keyword search (FTS5) and semantic similarity

🚀 Quick Start

pip install softrag
from softrag import Rag
from langchain_openai import ChatOpenAI, OpenAIEmbeddings

# Initialize
rag = Rag(
    embed_model=OpenAIEmbeddings(model="text-embedding-3-small"),
    chat_model=ChatOpenAI(model="gpt-4o")
)

# Add documents
rag.add_file("document.pdf")
rag.add_web("https://example.com/article")

# Query with context
answer = rag.query("What is the main topic discussed?")
print(answer)

📚 Documentation

For complete documentation, examples, and advanced usage, see: docs/softrag.md

🛠️ Next Steps

  • Documentation Creation: Develop comprehensive documentation using tools like Sphinx or MkDocs to provide clear guidance on installation, usage, and contribution.
  • Image Support in RAG: Integrate capabilities to handle image data, enabling the retrieval and generation of content based on visual inputs. This could involve incorporating models like CLIP for image embeddings.
  • Automated Testing: Implement unit and integration tests using frameworks such as pytest to ensure code reliability and facilitate maintenance.
  • Support for Multiple LLM Backends: Extend compatibility to include various language model providers, such as OpenAI, Hugging Face Transformers, and local models, offering users flexibility in choosing their preferred backend.
  • Enhanced Context Retrieval: Improve the relevance of retrieved documents by integrating reranking techniques or advanced retrieval models, ensuring more accurate and contextually appropriate responses.
  • Performance Benchmarking: Conduct performance evaluations to assess Softrag's efficiency and scalability, comparing it with other RAG solutions to identify areas for optimization.
  • Monitoring and Logging: Implement logging mechanisms to track system operations and facilitate debugging, as well as monitoring tools to observe performance metrics and system health.

🤝 Contributing

We welcome contributions! Here's how to get started:

Development Setup

This project uses uv for dependency management. Make sure you have it installed:

# Install uv if you haven't already
curl -LsSf https://astral.sh/uv/install.sh | sh

Getting Started

  1. Fork and clone the repository:

    git clone https://github.com/yourusername/softrag.git
    cd softrag
    
  2. Install dependencies with uv:

    uv sync --dev
    
  3. Activate the virtual environment:

    source .venv/bin/activate  # On Windows: .venv\Scripts\activate
    

Making Changes

  1. Create a new branch for your feature/fix
  2. Make your changes
  3. Add tests if applicable
  4. Ensure all tests pass
  5. Submit a pull request

Project Structure

  • src/softrag/ - Main library code
  • docs/ - Documentation
  • examples/ - Usage examples
  • tests/ - Test suite

📜 License

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

Give to us your star ⭐

Developed with ❤️ for 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.2.tar.gz (11.4 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.2-py3-none-any.whl (9.1 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: softrag-0.1.3.2.tar.gz
  • Upload date:
  • Size: 11.4 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.3.2.tar.gz
Algorithm Hash digest
SHA256 24e511c24680c3a9dd770a72e3baec1214699afba63bd8e049d393cbdd7c1d65
MD5 8b4b7ddfabb474c4bb94ff867ad26154
BLAKE2b-256 aac3819e46ab4eee827289054a46dfb762cad386de6b201f0a22713b84f2300f

See more details on using hashes here.

Provenance

The following attestation bundles were made for softrag-0.1.3.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.3.2-py3-none-any.whl.

File metadata

  • Download URL: softrag-0.1.3.2-py3-none-any.whl
  • Upload date:
  • Size: 9.1 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.3.2-py3-none-any.whl
Algorithm Hash digest
SHA256 b8880bdabf3042d11a8babc457d1aba5382fa5c6ef6c988d8cc75e4ec1ca1f2e
MD5 cd4a1308a9e60c4f28fc39806199f8be
BLAKE2b-256 d1e6e29739b0858ec0ed65a13a08779b52c6b9d9bc2e33a581e91f77e0d214e3

See more details on using hashes here.

Provenance

The following attestation bundles were made for softrag-0.1.3.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