Repository navigation
Closed
Labels
enhancementNew feature or requestnext-upNext in queue for implementationpriority:highFix in next releasescope:coreCore engine work
Description
Summary
Add FTS5 full-text search as a parallel retrieval channel alongside existing vector similarity search, merged via Reciprocal Rank Fusion (RRF).
Background
Industry research (Sibyl-Memory benchmark, vstash paper arxiv:2604.15484, sqlite-memory, wmem) shows that hybrid FTS5 + vector search outperforms either approach alone:
- FTS5 wins on exact entity lookup, named entity queries, structured data (e.g., "alamat PT Maju Jaya")
- Vector wins on conceptual/semantic queries, paraphrased queries (e.g., "cara deploy yang kita bahas bulan lalu")
- Hybrid (RRF) merges both, taking the best of each
Sibyl Benchmark Evidence
- FTS5-only: 350/350 retrieval on structured data (500 companies, 1 token difference)
- But vector systems fail on near-duplicates where 1 token distinguishes entities
- All vector systems scored 0/50 on trap questions (fake entities) — always returns nearest neighbor
Implementation Plan
1. FTS5 Virtual Table
CREATE VIRTUAL TABLE IF NOT EXISTS memories_fts USING fts5(
content,
tags,
namespace,
content=memories,
content_rowid=rowid
);
-- Triggers to keep FTS5 in sync
CREATE TRIGGER memories_ai AFTER INSERT ON memories BEGIN
INSERT INTO memories_fts(rowid, content, tags, namespace)
VALUES (new.rowid, new.content, new.tags, new.namespace);
END;
CREATE TRIGGER memories_ad AFTER DELETE ON memories BEGIN
INSERT INTO memories_fts(memories_fts, rowid, content, tags, namespace)
VALUES (delete, new.rowid, new.content, new.tags, new.namespace);
END;2. Dual Search Execution
pub fn recall_hybrid(&self, query: &str, limit: usize) -> Vec<SearchResult> {
let vector_results = self.vector_search(query, limit * 3);
let fts_results = self.fts5_search(query, limit * 3);
rrf_merge(vector_results, fts_results, limit)
}3. RRF Merge Algorithm
fn rrf_merge(vector: Vec<SearchResult>, fts: Vec<SearchResult>, k: u32 = 60) -> Vec<SearchResult> {
// Standard RRF: score = 1/(k + rank)
// Each result gets score from both channels, summed
}4. Config
[recall]
strategy = "hybrid" # "hybrid" | "vector" | "fts5"
rrf_k = 60 # RRF constant
fts5_weight = 1.0 # FTS5 channel weight
vector_weight = 1.0 # Vector channel weight5. Schema Migration
- Add FTS5 virtual table + triggers in
schema.rs - Existing
search_content(LIKE-based) → upgrade to FTS5 recallcommand auto-routes: hybrid when FTS5 exists, vector-only otherwise
Scope
- New module:
uteke-core/src/memory/fts5.rs - Modify:
store.rs(FTS5 table creation + triggers) - Modify:
operations.rs(hybrid recall logic) - Modify:
config.rs(recall strategy config) - Modify:
schema.rs(migration for existing DBs)
Acceptance Criteria
- FTS5 virtual table auto-created on init
-
recalluses hybrid by default when FTS5 exists - Config toggle: hybrid / vector-only / fts5-only
- Backward compatible: existing DBs get FTS5 table on next open
- Benchmark: hybrid recall >= vector-only on semantic queries, >> vector-only on exact match
References
- vstash paper: https://arxiv.org/abs/2604.15484
- sqlite-memory hybrid: https://github.com/sqliteai/sqlite-memory
- wmem hybrid: https://github.com/andrkelemen/wmem
- Sibyl benchmark: https://blog.sibylcap.com/beta-analysis-v2
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestnext-upNext in queue for implementationpriority:highFix in next releasescope:coreCore engine work
Activity
feat(#250): FTS5 hybrid search with Reciprocal Rank Fusion (RRF) (#261)
feat(#250): FTS5 hybrid search with Reciprocal Rank Fusion (RRF) (#261)