Skip to content

examples: add zero-cloud local hybrid RAG with SQLite FTS5 and embeddings - #721

Open
Cagrik34 wants to merge 1 commit into
ollama:mainfrom
Cagrik34:example/sqlite-hybrid-rag-fts5
Open

examples: add zero-cloud local hybrid RAG with SQLite FTS5 and embeddings#721
Cagrik34 wants to merge 1 commit into
ollama:mainfrom
Cagrik34:example/sqlite-hybrid-rag-fts5

Conversation

@Cagrik34

Copy link
Copy Markdown

Summary

Adds a zero-cloud, standalone Hybrid Retrieval-Augmented Generation (RAG) reference example combining embedded SQLite FTS5 (BM25 token search) and Ollama dense embeddings with Reciprocal Rank Fusion (RRF, $k=60$) and grounded streaming citation synthesis.

Key Features

  • Zero-Cloud Embedded Dual Retrieval: Utilizes native SQLite FTS5 unicode61 token matching alongside ollama.embed dense vectors, eliminating the need for standalone vector database infrastructure.
  • Reciprocal Rank Fusion (RRF, k=60): Resolves score calibration mismatches between cosine similarity and BM25 rank, ensuring robust recall of exact alphanumeric values (policy limits, financial budgets, version tags).
  • Streaming Grounded Synthesis: Demonstrates real-time token streaming with ollama.chat(stream=True) and strict citation grounding ([1], [2]).
  • Resilient Execution: Includes graceful fallback simulation when the local Ollama daemon is offline, guaranteeing zero unhandled runtime exceptions during automated testing.

Files Added

  • examples/hybrid-rag.py
  • examples/README.md (Index entry under ### Hybrid RAG)

Verification

Tested and verified with Python 3.10+ and the Ollama Python SDK.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant