Skip to content

Hybrid retrieval and evidence ​

A student remembers a quotation. A researcher remembers the report number. Both should be able to reach the same original passage.

A red thread connects one selected card in a catalog to a landscape photograph.

LinkedIn opens a draft you can review before posting.

DRAFT · SQLITE UNDER EVALUATION

Search for an exact report number, then try again using only a paraphrase of its conclusion. The first query rewards precise text matching. The second may need a vector search. Once you find a passage, a relationship can take you to its definition or a competing account.

This draft evaluates keeping those operations together in SQLite using FTS5 BM25, a vector extension, and indexed graph relationships. Locality could save network round trips. Compare SQLite with a dedicated service using the same relevance targets, access filters, ingestion load, and latency measurements before selecting either.

Three complementary signals ​

SignalProposed roleImplementation candidate
LexicalNames, identifiers, exact terminologyFTS5 BM25
SemanticRelated meaning and paraphrasesVersioned vector extension
RelationshipsDefinitions, dependencies, related evidenceTyped graph tables with forward/reverse indexes

FTS5 supplies BM25 ranking; numerically lower scores are better matches. Its tokenizer and document granularity need corpus-specific evaluation. FTS5 documentation

Vector capability decision ​

Compare exact and approximate search using an exact reference set. SQLite's own Vec1 extension offers ANN and exhaustive modes. Its ANN mode uses trained index structures, supports qualifying metadata predicates, and has query-shape considerations for filtered joins. It is a separately compiled/loaded extension, not an assumed feature of every SQLite binary. Vec1 overview, Vec1 manual

sqlite-vec is a separate candidate. Its release stream includes different stable and prerelease capabilities; inspect the pinned release before claiming ANN support. sqlite-vec releases

The retrieval adapter must declare exact/ANN behavior, supported metrics, filtering semantics, snapshot identity, interruption behavior, and incremental-update behavior. Unsupported capabilities are explicit errors or documented fallbacks. Hiding these differences behind one unconstrained search() call would weaken correctness.

Check filtering with a difficult case. If the closest overall matches are all outside the reader’s permitted scope, filtering only after a global top-k search can discard them and miss relevant eligible material. Test restrictive filters against an exact eligible reference set. Check filters inside candidate generation, overfetch behavior, selective tenants, empty subsets, and query plans. Measure recall and latency as the candidate budget changes. Enforce authorization before evidence reaches a model or browser, including passages found by following graph links.

Try a four-passage fixture. A global ranking puts A, B and C first, all from a different library. Passage D ranks fourth overall and is the only passage the reader may see. D contains the expected answer.

Retrieval path with a limit of threeResult for the reader
Take the global top three, then apply access scopeEmpty. The candidate list discarded D before checking the scope.
Apply scope first, then rank every eligible passage exactlyD. This is the reference result for this query.

Run each candidate adapter against this fixture and record whether it returns D, whether it returns any ineligible ID, and how long it takes. Then repeat on a representative set of restricted queries before interpreting recall or latency.

Candidate composition ​

Use reciprocal rank fusion as an initial baseline, then evaluate candidate windows and weights. Raw BM25 scores and vector distances do not share a useful common scale. Graph expansion follows selected seeds with hop, edge-type, result-count, and deadline limits. Always fetch original supporting passages.

Evidence model ​

RecordRequired information
Document revisionStable document ID, content hash, revision, source metadata, access scope
ChunkRevision, parent section, original text, normalized view, source anchors
MentionSurface form, source span, local context, extraction version
Entity resolutionCandidate IDs, selected/unresolved identity, decision version
ClaimSubject/predicate/object or event structure, polarity, modality, relevant time
EvidenceClaim-to-source link, source revision and span, extraction provenance
AugmentationGenerated content, dependencies, processing version, ranking role

The graph is a derived view of source-backed assertions. Two documents can disagree. Deleting one revision retracts its evidence; another current source may still support the claim. Similar names and embeddings do not by themselves justify an entity merge. Recursive SQL supports graph traversal, but large high-fanout analytics need independent evaluation. SQLite graph queries

SQLite operating boundary ​

Standard WAL mode permits readers alongside a writer, with one writer at a time per database. Processes sharing that WAL must be on one host. Long reads can delay checkpoint progress. SQLite WAL

Use a local publication owner, short transactions, bounded database threads, and precomputed ingestion artifacts. Release retrieval snapshots before waiting on model output. Keep database calls off Tokio's asynchronous execution threads. Multiple hosts must use explicit shard ownership or an evaluated replication design; NATS notifications do not replicate database files.

Selection gates ​

Measure filtered p95/p99 retrieval latency during concurrent ingestion, ANN recall, relevance, graph contribution, memory, checkpoint behavior, and update-to-searchable delay. Keep canonical IDs and evidence contracts independent of the vector extension. See ADR 002.

Study and compare ​

Use the concept guide for BM25, ANN, and rank fusion, implementation resources for concrete SQLite candidates, and similar projects for alternative graph-retrieval designs.

IS373 · Documentation and contract labs available · Research runtime planned