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

Minimal local-first Retrieval-Augmented Generation (RAG) library powered by SQLite + sqlite-vec.
Everything—documents, embeddings, cache—lives in a single .db file.
created by Julio Peixoto.
🌟 Features
- Local-first – All processing happens locally, no external services required for storage
- SQLite + sqlite-vec – Documents, embeddings, and cache in a single
.dbfile - 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, web pages, and images
- Image understanding – Uses GPT-4 Vision to analyze and describe images for semantic search
- Hybrid retrieval – Combines keyword search (FTS5) and semantic similarity
- Unified search – Query across text documents and image descriptions seamlessly
🚀 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 different types of content
rag.add_file("document.pdf")
rag.add_web("https://example.com/article")
rag.add_image("photo.jpg") # 🆕 Image support!
# Query across all content types
answer = rag.query("What is shown in the image and how does it relate to the document?")
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
-
Fork and clone the repository:
git clone https://github.com/yourusername/softrag.git cd softrag
-
Install dependencies with uv:
uv sync --dev
-
Activate the virtual environment:
source .venv/bin/activate # On Windows: .venv\Scripts\activate
Making Changes
- Create a new branch for your feature/fix
- Make your changes
- Add tests if applicable
- Ensure all tests pass
- Submit a pull request
Project Structure
src/softrag/- Main library codedocs/- Documentationexamples/- Usage examplestests/- 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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file softrag-0.1.4.tar.gz.
File metadata
- Download URL: softrag-0.1.4.tar.gz
- Upload date:
- Size: 12.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
04958cd3c0e95f3551c27730533fd4e6a9c36ef3f68e3f9b81499df8da5c915a
|
|
| MD5 |
645956bd0c9b091a3a1a21823e1bb2b3
|
|
| BLAKE2b-256 |
a597d2b6ce1e73a6bae5f7340075bf94c5ccd71d3f14d6f2e372a129c580de35
|
Provenance
The following attestation bundles were made for softrag-0.1.4.tar.gz:
Publisher:
python-publish.yml on JulioPeixoto/softrag
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
softrag-0.1.4.tar.gz -
Subject digest:
04958cd3c0e95f3551c27730533fd4e6a9c36ef3f68e3f9b81499df8da5c915a - Sigstore transparency entry: 227980170
- Sigstore integration time:
-
Permalink:
JulioPeixoto/softrag@ffecbf75575fb781fe049a842d8ae004efca39c0 -
Branch / Tag:
refs/tags/v0.1.4 - Owner: https://github.com/JulioPeixoto
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@ffecbf75575fb781fe049a842d8ae004efca39c0 -
Trigger Event:
push
-
Statement type:
File details
Details for the file softrag-0.1.4-py3-none-any.whl.
File metadata
- Download URL: softrag-0.1.4-py3-none-any.whl
- Upload date:
- Size: 10.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
25e7e911ced487a4b9188e94cd95d4276ebb28ffa4650f42db34234b4f632353
|
|
| MD5 |
bc4d28ea8438b72c4a519b8b512934ad
|
|
| BLAKE2b-256 |
9fc3bebb3623c45ba4381dbfe8bf2658fac843353bf7d79ba0efc24b718ddc49
|
Provenance
The following attestation bundles were made for softrag-0.1.4-py3-none-any.whl:
Publisher:
python-publish.yml on JulioPeixoto/softrag
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
softrag-0.1.4-py3-none-any.whl -
Subject digest:
25e7e911ced487a4b9188e94cd95d4276ebb28ffa4650f42db34234b4f632353 - Sigstore transparency entry: 227980176
- Sigstore integration time:
-
Permalink:
JulioPeixoto/softrag@ffecbf75575fb781fe049a842d8ae004efca39c0 -
Branch / Tag:
refs/tags/v0.1.4 - Owner: https://github.com/JulioPeixoto
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@ffecbf75575fb781fe049a842d8ae004efca39c0 -
Trigger Event:
push
-
Statement type: