Skip to main content

Local-first RAG toolkit backed by a single SQLite database

Project description

raglite-sqlite

CI License: MIT Python: 3.10+

PyPI

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-test builds a temporary database from the demo corpus, runs three canned queries, prints titles/snippets, reports the active vector backend, and dumps stats.
  • raglite stats now returns document, chunk, embedding counts plus backend, embedding model/dimensions, FTS status, and alpha.
  • raglite benchmark / raglite eval invoke the new tiny scripts under scripts/.

Vector backends

Raglite automatically selects the most capable vector backend:

  1. SQLite extension (sqlite-vec or sqlite-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)
    
  2. 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.
  3. 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.py compares 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.py duplicates 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 --tiny for <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 *.db and *.db-wal files.
  • 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 .ragliteignore patterns 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

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

raglite_sqlite-0.2.0.tar.gz (28.6 kB view details)

Uploaded Source

Built Distribution

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

raglite_sqlite-0.2.0-py3-none-any.whl (32.6 kB view details)

Uploaded Python 3

File details

Details for the file raglite_sqlite-0.2.0.tar.gz.

File metadata

  • Download URL: raglite_sqlite-0.2.0.tar.gz
  • Upload date:
  • Size: 28.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.5

File hashes

Hashes for raglite_sqlite-0.2.0.tar.gz
Algorithm Hash digest
SHA256 e3697cbeb43769adf1adc6fdf4969bbc21fc73a4505d322a71e4307749ebea0a
MD5 b2bfd92f995fdc0ab19c342c57d11b36
BLAKE2b-256 a96af87ed01497eef66d7c0fb8c05f1448a676ec05e8e56c3408c596c132c024

See more details on using hashes here.

File details

Details for the file raglite_sqlite-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: raglite_sqlite-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 32.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.5

File hashes

Hashes for raglite_sqlite-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 4b97655353a6a06b955b9a67188b577f62849ebbab14eb724d23f1625539c580
MD5 9fa5de8d7d786f4d4d285557ed4d80c5
BLAKE2b-256 88e1dc9ad1b703f4bd8eef3d88996238e3cc5f553efeeb63d5da7e6d9cbbe0db

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