RAGiteRust · SQLite extension · Model2Vec · Linux x86-64
pihme / ragite

RAGite

Embeddable, CPU-friendly retrieval (RAG) as a SQLite extension.

1.0 · releases tagged ragite/vX.Y.Z

sqlite3 · ragite
sqlite> .load ./libragite
sqlite> CREATE VIRTUAL TABLE docs USING ragite;
sqlite> INSERT INTO docs(text, source, format)
   ...> VALUES (readfile('manual.md'),
   ...>         'manual.md', 'text/markdown');
sqlite> SELECT chunk, source, score FROM docs_chunks
   ...> WHERE docs_chunks MATCH 'How do I install it?'
   ...> LIMIT 5;

-- chunked, embedded on the CPU and indexed on INSERT;
-- MATCH fuses vector similarity and BM25 (RRF)

01What it is

RAGite is an embeddable retrieval component for retrieval-augmented generation (RAG). It splits text into chunks, computes embeddings on the CPU and finds the best-matching passages with a hybrid search (vector similarity plus full-text BM25), always with a link back to the source document and position.

It ships as a loadable SQLite extension, so any application in any language that can load SQLite extensions can use it: SQLite for RAG. Documents, chunks, vectors and the full-text index live in the same database file, in process, with no server.

See it in the demo

Ask, rank, query

RAGite demo runs hybrid search over the SQLite documentation, 20 Wikipedia articles and these docs, in a single SQLite file.

  1. Search box with a plain-language question

    Ask

    A plain question, optionally filtered by source.

  2. Best matching passage with highlighted terms

    Rank

    Vectors and BM25 fused; the hit is marked in amber.

  3. Search results as a SQL table

    Query

    Results are rows: SQL, JSON or CSV.

Try RAGite demo →

02Quickstart

Download libragite.so from the latest release (Linux x86-64) or build it with cargo build -p ragite-sqlite --release. Start sqlite3 in the directory that holds the file:

SELECT load_extension('./libragite');
SELECT name, technical_id FROM ragite_default_model();
CREATE VIRTUAL TABLE docs USING ragite;
INSERT INTO docs(text, source, format)
VALUES ('# Installation

Run the installer and restart the application.', 'manual.md', 'text/markdown');
SELECT chunk, source, score FROM docs_chunks WHERE docs_chunks MATCH 'How do I install it?' LIMIT 5;

Pass the path without .so; SQLite adds the suffix. This block is run as a test, so it stays correct. The user guide covers formats, updates and transactions, linking results to your own tables, the embedding functions and models; its examples run in CI too.

03Interface

PartWhat it does
CREATE VIRTUAL TABLE docs USING ragiteThe Document table. INSERT, UPDATE and DELETE chunk, embed and index the text; ROLLBACK undoes all of it
docs MATCH 'question'Hybrid search, one row per Document, ranked by its best chunk
docs_chunks MATCH 'question'Hybrid search over chunks, with doc_id, source, start, end, heading_path and score
Formatstext/plain, text/markdown, text/html and DoclingDocument JSON
ragite_embed and friendsEmbed text with a table's model, list the models, show the default and a table's model

Scores come from Reciprocal Rank Fusion (k = 60) of the vector ranking and the BM25 ranking, 50 candidates from each. Chunks hold at most 512 Unicode scalars with a 64-scalar overlap.

04Model

The built-in default model is potion-retrieval-32M, a static Model2Vec model trained for retrieval (English, MIT, 512 dimensions). Its weights are embedded in the extension, so the release libragite.so is about 135 MB. A different model can be built in at build time; each table stores its model's technical id, and a build that does not contain that model refuses the table instead of mixing vectors. A model is not loaded from a path or a URL at run time. No GPU and no ONNX Runtime are needed.

The chunker, the scoring and the other presets are fixed, the same for every caller. Where they live in the code, and how to add a document type, write or change a chunker or change the fusion: docs/tinkering.md.

05Demo

RAGite demo puts RAGite to work: a small Datasette app that searches the SQLite documentation, a few Wikipedia articles and these docs, offline and in one SQLite file.

06License

Licensed under either of MIT or Apache-2.0 at your option (SPDX: MIT OR Apache-2.0). Bundled model weights keep their own license; all third-party licenses are in THIRD_PARTY_NOTICES.md.

RAGite demo is the other half of this pair: Search the SQLite docs and Wikipedia in your browser with RAGite and Datasette, offline and in one SQLite file. Visit RAGite demo →