raglite-sqlite
Local-first retrieval augmented generation toolkit built on SQLite. Raglite bundles ingestion, chunking, hybrid BM25/vector search, Typer CLI workflows, and a FastAPI microservice. Everything runs on CPU and stores state in a single SQLite database.
Quickstart in 6 lines
python -m venv .venv && source .venv/bin/activate
pip install "raglite-sqlite[server]"
raglite init-db --db demo.db
raglite ingest --db demo.db --path demo/mini_corpus
raglite query --db demo.db --text "quick start guide" --k 5 --alpha 0.6
raglite serve --db demo.db --host 127.0.0.1 --port 8080
On Windows use \.venv\Scripts\activate for step two.
Installation
Raglite is published as raglite-sqlite on PyPI. Install the
core toolkit with:
pip install raglite-sqlite
To enable the optional FastAPI server, install the server extra:
pip install "raglite-sqlite[server]"
Development dependencies (linters, type checkers, packaging utilities) can be installed
with the dev extra:
pip install "raglite-sqlite[dev]"
Features
- Deterministic chunking and debug embeddings for air-gapped demos, with an easy upgrade path to SentenceTransformer models.
- Hybrid BM25 + cosine search with rerank option and automatic Python fallback when SQLite vector extensions are unavailable.
- Typer CLI (
raglite), FastAPI server (raglite serve), and Python API for scripted use. - Offline demo kit (
demo/mini_corpus) with one-shot run scripts and proof artifacts. - Tiny eval and benchmark scripts that run in seconds and provide reproducible metrics.
Demo & proof artifacts
Explore the bundled two-minute corpus and scripts inside demo/:
demo/mini_corpus/: 12 varied documents (how-to, FAQ, articles, product docs).demo/run_demo.sh/demo/run_demo.ps1: create a virtual environment, install Raglite, ingest the demo corpus, run a sample query, and start the FastAPI server with curl hints.demo/eval_set.jsonl: 25 ground-truth query snippets for offline evaluation.
A placeholder animation (demo/demo.gif) can be replaced with your own screenshots once
you run the scripts.
CLI highlights
raglite self-testbuilds a temporary database from the demo corpus, runs three canned queries, prints titles/snippets, reports the active vector backend, and dumps stats.raglite statsnow returns document, chunk, embedding counts plus backend, embedding model/dimensions, FTS status, and alpha.raglite benchmark/raglite evalinvoke the new tiny scripts underscripts/.
Vector backends
Raglite automatically selects the most capable vector backend:
- SQLite extension (
sqlite-vecorsqlite-vss): if loadable, cosine similarity runs directly inside SQLite for best performance. Example load step:import sqlite3 conn = sqlite3.connect("raglite.db") conn.enable_load_extension(True) conn.load_extension("sqlite_vec") conn.enable_load_extension(False)
- Python fallback (default): BM25 prefilters the top 200 rows and cosine similarity is computed with NumPy arrays in Python. This works cross-platform with zero extra dependencies.
- None: if the embeddings table is absent, vector search is skipped and BM25 answers requests alone.
raglite self-test, raglite stats, and the benchmark script print which path you are on.
Expect the Python fallback to be a few milliseconds slower per query but fully portable.
Architecture
erDiagram
documents ||--o{ chunks : contains
chunks ||--o{ embeddings : has
documents {
int id
text path
text title
text mime
text meta_json
datetime created_at
}
chunks {
int id
int document_id
int chunk_idx
text text
int tokens
text tags_json
}
embeddings {
int id
int chunk_id
text model
int dim
blob embedding
}
%% Additional structure
%% chunk_fts is an FTS5 virtual table with triggers syncing chunk text changes.
chunk_fts is a virtual FTS5 table kept in sync with the chunks table via insert/update
triggers; see src/raglite/schema.sql for details.
Evaluations & benchmarks
python scripts/eval_small.pycompares BM25, Hybrid (α=0.6), and optional rerank on the bundled dataset. Hybrid matches BM25 on this micro-set by default and rerank (if installed) can further improve conversational queries.python scripts/bench_basic.pyduplicates the demo corpus to ~2k chunks, reports indexing throughput, query latency (p50/p95) with and without vector fallback, database size, and backend selection.- Both scripts support
--tinyfor <30s smoke runs and fall back to packaged data when installed from wheels.
Limitations & Guidance
- Designed for small/medium local corpora, not massive ANN workloads. For millions of vectors, adopt a dedicated vector database.
- Best with a single writer; readers work fine with WAL mode. Remember to back up both
*.dband*.db-walfiles.- Increase α to ≥0.6 when keyword precision matters; lower it or enable rerank (with
raglite-sqlite[rerank]) for conversational questions.- Raglite is local-first—avoid ingesting secrets or PII. Use
.ragliteignorepatterns or preprocess files to filter sensitive content.
Tests & quality
Run the full suite that matches CI:
ruff check src tests
black --check src tests
mypy src
pytest -q
raglite self-test
License
MIT
Metadata
Release files for raglite-sqlite 0.2.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| raglite_sqlite-0.2.0.tar.gz | 28.6 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| raglite_sqlite-0.2.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 61.2 kB
Release files / raglite_sqlite-0.2.0.tar.gz
| Download URL | raglite_sqlite-0.2.0.tar.gz |
|---|---|
| Size | 28.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
e3697cbeb43769adf1adc6fdf4969bbc21fc73a4505d322a71e4307749ebea0a
|
|
BLAKE2b-256 checksum How to use checksums |
a96af87ed01497eef66d7c0fb8c05f1448a676ec05e8e56c3408c596c132c024
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.13.5
|
Release files / raglite_sqlite-0.2.0-py3-none-any.whl
| Download URL | raglite_sqlite-0.2.0-py3-none-any.whl |
|---|---|
| Size | 32.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
4b97655353a6a06b955b9a67188b577f62849ebbab14eb724d23f1625539c580
|
|
BLAKE2b-256 checksum How to use checksums |
88e1dc9ad1b703f4bd8eef3d88996238e3cc5f553efeeb63d5da7e6d9cbbe0db
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.13.5
|