nx_distrib_embed.nx
buildroot/runtime/nx_distrib_embed.nx
about
nx_distrib_embed.nx -- R3 rung 2 (R3b): a SOVEREIGN DISTRIBUTIONAL embedder = the Jina-Embeddings replacement,
count-based (NOT a trained neural net, NO float, NO training loop): "you shall know a word by the company it
keeps" (Firth 1957 / Turney-Pantel 2010). Word vector = its co-occurrence row over a corpus; doc vector = sum
of its words' rows; similarity = integer cosine (isqrt). This is the SEMANTIC lever nx_vec_index needed. THE
PROOF (what BM25 canNOT do): query 'cat' retrieves the DOG doc over the CAR doc even though NEITHER contains
the word 'cat' -- pure semantic (shared context), zero lexical overlap. main() = KAT gate + neg-control.
HONEST SCOPE: proves the METHOD on a controlled mini-corpus (docs pre-tokenized to word-IDs to isolate the
embedder from string-tokenization). Scaling to the real 519-doc library (tokenizer + big matrix) = R3b-scale.
license_tier: ORIGINAL expect_exit: 0
dependencies 1 imports · 0 importers
imports: nx_syscalls.nx
imported by: nobody (leaf or entry point)
call flow from main pre-order; caps 40 nodes / depth 6 declared; ↻ = already shown
structs
| none |
consts
| 11 | const K_MAGIC_4096: i64 = 4096 |
functions
| 13 | func dw(s: *u8) -> i64 { var n: i64=0; while s[n]!=(0 as u8){n=n+1} sys_write(1,s,n); return 0 } |
| 14 | func dn(v: i64) -> i64 { let bb: *u8=sys_mmap(28); var m: i64=v; if m<0{m=0-m; sys_write(1,"-" as *u8,1)} let t: *u8=sys_mmap(28); var k: i64=0; if m==0{t[0]=48 as u8;k=1} while m>0{t[k]=(48+(m%10)) as u8;m=m/10;k=k+1} var i: i64=0; while i<k{bb[i]=t[k-1-i];i=i+1} sys_write(1,bb,k); return 0 } |
| 16 | func isqrt(n: i64) -> i64 called by 1: cos2 |
| 25 | func vdot(a: *i64, ao: i64, b: *i64, bo: i64, d: i64) -> i64 called by 1: cos2 |
| 32 | func cos2(a: *i64, ao: i64, b: *i64, bo: i64, d: i64) -> i64 |
| 44 | func add_doc(M: *i64, V: i64, doc: *i64, len: i64) -> i64 called by 1: main |
| 55 | func doc_vec(M: *i64, V: i64, doc: *i64, len: i64, out: *i64) -> i64 called by 1: main |
| 62 | func chk(label: *u8, got: i64, exp: i64, tot: *i64) -> i64 |
| 68 | func main() -> i64 |