code wiki / _hdl_build / nx_semantic_retrieval.nx

nx_semantic_retrieval.nx

buildroot/runtime/_hdl_build/nx_semantic_retrieval.nx

3597 B71 linesdepth 3pulls 3 transitivereach 1 importersview sourcekind librarytopic semantic
docsdependenciesstructsconstsfunctions

about

nx_semantic_retrieval.nx -- SPEC A built bits-up: match a query BEYOND exact terms via co-occurrence. Terms that appear together across the corpus are related; so a document can be relevant to a query even when it never contains the query word, as long as it contains terms that CO-OCCUR with it. This is the rung where retrieval can exceed BM25 (which scores 0 when the exact term is absent). Built on Layer-8 integer ALU ops only (the spec's primitives): COUNT (term presence), IMUL+IADD (vector dot product), ISQRT (cosine magnitude) -- no floats, no learned embeddings. Honest boundary: co-occurrence over a small corpus is a weak proxy for true semantics; learned embeddings (the EMBED_TRAIN primitive the Researcher flagged) are the LLM rung, not faked here. license_tier: ORIGINAL Pairs with nx_research_extract (re_has/re_count) + nx_bm25 (exact baseline).

dependencies 2 imports · 1 importers

nx_research_extract.nx nx_syscalls.nx nx_semantic_retrieval.nx nx_semantic_retrieval_test.nx

imports: nx_research_extract.nxnx_syscalls.nx

imported by: nx_semantic_retrieval_test.nx

structs

none

consts

none

functions

15func sr_isqrt(x: i64) -> i64
called by 2: sr_cosine_millimain
26func sr_doc(ptrs: *i64, k: i64) -> *u8 { return ptrs[k] as *u8 }
29func sr_cooc(ptrs: *i64, lens: *i64, N: i64, a: *u8, b: *u8) -> i64
called by 1: sr_build_qvec calls 2: re_hassr_doc
36func sr_build_qvec(ptrs: *i64, lens: *i64, N: i64, qterm: *u8, vocab: *i64, V: i64, qvec: *i64) -> i64
called by 1: main calls 1: sr_cooc
43func sr_score(ptrs: *i64, lens: *i64, k: i64, qvec: *i64, vocab: *i64, V: i64) -> i64
called by 2: sr_bestmain calls 2: re_hassr_doc
50func sr_exact(ptrs: *i64, lens: *i64, k: i64, qterm: *u8) -> i64 { return re_count(sr_doc(ptrs, k), lens[k], qterm) }
called by 1: main calls 2: re_countsr_doc
52func sr_best(ptrs: *i64, lens: *i64, N: i64, qvec: *i64, vocab: *i64, V: i64) -> i64
called by 1: main calls 1: sr_score
59func sr_cosine_milli(ptrs: *i64, lens: *i64, k: i64, qvec: *i64, vocab: *i64, V: i64) -> i64
called by 1: main calls 3: re_hassr_docsr_isqrt