code wiki / _hdl_build / nx_vec_vq.nx
nx_vec_vq.nx
buildroot/runtime/_hdl_build/nx_vec_vq.nx
about
nx_vec_vq.nx -- R-VEC-4 of the onsite-search S-class ladder: SOVEREIGN vector quantization (LIBRARY). Raw f32
embedding vectors blow the RAM budget at 366k scale (Rule 21); VQ compresses each vector to ONE codebook index
-- "a codebook" of representative centroids (cited srch_vq.raw, Vector_quantization). k-means (Lloyd): assign
each vector to its nearest centroid, move each centroid to the mean of its members, repeat. Integer, no-float,
deterministic init (evenly-spaced seeds). HONEST SCOPE: single-codebook VQ; PRODUCT quantization (split the
vector into sub-spaces, a codebook per sub-space) is the named extension for finer compression.
exports: vr_vq_train, vr_vq_encode, vr_vq_decode. license_tier: ORIGINAL
dependencies 1 imports · 1 importers
imports: nx_syscalls.nx
imported by: nx_vec_vq_gate.nx
structs
| none |
consts
| none |
functions
| 12 | func vq_l2(a: *i64, b: *i64, D: i64) -> i64 { var s: i64=0; var i: i64=0; while i<D { let d: i64=a[i]-b[i]; s=s+d*d; i=i+1 } return s } called by 1: vr_vq_encode |
| 15 | func vr_vq_encode(vec: *i64, cb: *i64, K: i64, D: i64) -> i64 |
| 22 | func vr_vq_decode(cb: *i64, idx: i64, D: i64) -> *i64 { return ((cb as i64)+idx*D*8) as *i64 } called by 1: main |
| 25 | func vr_vq_train(V: *i64, N: i64, D: i64, K: i64, iters: i64, cb: *i64) -> i64 |