code wiki / _hdl_build / nx_vec_fuse.nx
nx_vec_fuse.nx
buildroot/runtime/_hdl_build/nx_vec_fuse.nx
about
nx_vec_fuse.nx -- R-VEC-5 of the onsite-search S-class ladder: SOVEREIGN hybrid-search rank fusion (LIBRARY).
THE felt S-class jump: lexical BM25 nails exact terms, vector cosine (R-VEC-0/1) nails paraphrase -- fusing
their two ranked lists gets the best of both. "Data fusion in information retrieval combines results from
multiple search systems or retrieval models" (cited srch_ir.raw).
Reciprocal Rank Fusion (Cormack/Clarke/Buettcher 2009): score(d) = SUM_lists 1/(k + rank_i(d)), k=60 canonical;
sort docs by descending score. The defining behavior: a doc ranked MODERATELY in BOTH lists outranks a doc
ranked #1 in only ONE -- agreement across retrievers beats a single strong signal.
NO-FLOAT (operator doctrine): the reciprocal is computed in fixed point, weight = SCALE/(k+rank), SCALE=1e6.
Determinism: strict-greater selection sort keeps ascending doc-id order on ties.
exports: vr_rrf_w, vr_fuse_add, vr_fuse_rank. license_tier: ORIGINAL
dependencies 1 imports · 2 importers
imports: nx_syscalls.nx
imported by: nx_vec_fuse_gate.nxnx_vec_hybrid_gate.nx
structs
| none |
consts
| 16 | const VF_K: i64 = 60 // canonical RRF rank constant (Cormack et al. 2009) |
| 17 | const VF_SCALE: i64 = 1000000 // fixed-point scale for the reciprocal (no-float) |
functions
| 20 | func vr_rrf_w(rank: i64) -> i64 { return VF_SCALE / (VF_K + rank) } called by 1: vr_fuse_add |
| 23 | func vr_fuse_add(score: *i64, list: *i64, n: i64) -> i64 |
| 31 | func vr_fuse_rank(score: *i64, maxdoc: i64, out_ids: *i64) -> i64 |