RAGite demoDatasette · SQLite · RAGite
pihme / ragite-demo

RAGite demo

Search the SQLite docs and Wikipedia in your browser with RAGite and Datasette, offline and in one SQLite file.

demo · uses the RAGite 1.0.1 release · Linux x86-64

datasette · ragite-demo
$ datasette serve app --load-extension ./libragite

SELECT i.title, c.score
FROM docs_chunks c JOIN doc_info i ON i.doc_id = c.doc_id
WHERE docs_chunks MATCH 'How do I copy a database while it is in use?'
LIMIT 1;

-- top hit: SQLite Backup API, score 0.0164

01What it is

RAGite demo is a small Datasette app that shows RAGite at work. It indexes the SQLite documentation, 20 Wikipedia articles and RAGite's own docs in one SQLite file and serves a search page next to Datasette's full SQL interface. Nothing runs on a server or calls an external service: the embedding model is built into the extension and runs on the CPU.

Type a question, optionally pick a source, and get passages with the document title, the heading path, the source link and a score. A very short hit, usually a bare heading, comes with the text that follows it, and each passage is shown once. Every search links to the same query as SQL.

How a search runs

From question to passage, in one SQLite file

Four steps through the demo app. Every screen runs on Datasette and the RAGite extension.

  1. Ask in plain words

    Type a question and narrow it to a source if you like. No keywords, no query syntax.

    Search box with the question “How do I copy a database while it is in use?” and source filter chips
  2. Get the best passage first

    Vector similarity and BM25 are fused into one ranking. Matching terms are marked in amber.

    Top result: SQLite Backup API passage with highlighted matches, labelled Best match
  3. It is just rows

    The same search as a canned query: title, URL, source, chunk. Export as JSON or CSV.

    Search results as a table with title, URL, collection and chunk columns
  4. Under the hood: one MATCH

    Documents and chunks are SQLite virtual tables. Query them from any SQLite client that loads the extension.

    select rowid, doc_id, chunk, score
    from docs_chunks
    where docs_chunks match :q
    limit 20;

02Quickstart

git clone https://github.com/pihme/ragite-demo.git
cd ragite-demo
python3 -m venv .venv && . .venv/bin/activate
pip install -r requirements.txt
scripts/build-demo-db        # downloads libragite.so and the pinned sources, builds app/demo.db
datasette serve app --load-extension ./libragite --port 8001
# open http://127.0.0.1:8001/search

03Search with SQL

The demo uses only RAGite's public interface: the Document table, its _chunks companion and the ragite_* functions. The examples/ folder has runnable SQL for creating a table, inserting each format, searching documents and chunks, and embedding text.

SELECT i.title, c.chunk, c.score
FROM docs_chunks c JOIN doc_info i ON i.doc_id = c.doc_id
WHERE docs_chunks MATCH 'How do I change the output mode of the sqlite3 shell?'
LIMIT 5;

04Data

CollectionDocumentsLicense
SQLite documentation 3.54.1 (subset)74Public domain
Wikipedia: SQLite, SQL, B-tree, RAG, BM25, embeddings, vector search and related topics (en, de)20CC BY-SA 4.0
RAGite README, SPEC, GLOSSARY, user guide, tinkering guide5MIT OR Apache-2.0

99 documents, 8,789 chunks in a 25 MB demo.db, rebuilt from pinned inputs by the build script in a few seconds and not committed. Table rows and lists of short items are joined into paragraphs before RAGite cuts them. Sources, revisions and attribution: DATA_SOURCES.md.

05License

The code is MIT. The indexed texts keep their own licenses (DATA_SOURCES.md, THIRD_PARTY_NOTICES.md).

RAGite is the other half of this pair: Embeddable, CPU-friendly retrieval (RAG) as a SQLite extension. Visit RAGite →