Hybrid Retrieval & RAG

FTS5 precision plus local Nomic embeddings and optional reranking

Existing foundation

SourceCorpus already provides game-scoped FTS5 with URL/hash versioning. Extend it rather than replacing it. The live LM Studio endpoint exposes text-embedding-nomic-embed-text-v1.5, making local semantic search feasible.

Recommended retrieval stack

query + game_id + spoiler policyFTS5 BM25 candidates+vector candidatesreciprocal-rank fusionmetadata/spoiler filteroptional local rerankerbounded evidence pack

Build-vs-buy

DecisionRecommendationWhy
Metadata/full textKeep SQLite FTS5Already present, reliable, inspectable and easy to back up.
VectorsStart with SQLite table storing float32 blobs + brute-force per-game cosineYAGNI for early corpus sizes; avoids native extension packaging in UWP bridge.
Scale-upEvaluate sqlite-vec only after benchmarksAdd dependency only if measured latency/corpus size requires it.
EmbeddingsLM Studio OpenAI-compatible endpointLocal and already exposes Nomic model; cache by chunk hash + model.
RerankingOptional small local generative judge after fusionBackground/quality mode only; lexical+vector must work without it.

Chunking

Retrieval contract

retrieve(game_id, query, spoiler_level, source_types?, as_of?, limit=8)
→ [{chunk_id, exact_text, source_version_id, title, uri, page,
    lexical_score, semantic_score, fused_score, trust, spoiler_tags}]

Evaluation set

Create Torment-specific questions across exact names, paraphrases, quest state, mechanics and spoiler constraints. Measure Recall@k, source correctness, forbidden-spoiler leakage, latency and context tokens. Compare FTS-only against hybrid before enabling by default.

Acceptance