nx_embfeat_lib.nx
buildroot/runtime/nx_embfeat_lib.nx
about
nx_embfeat_lib.nx -- DENSE EMBEDDING FEATURES for a hashed linear sequence model: the ONE library reader of the estate's
trained word embeddings (knowledge/index/embed_v1.bin, written by nx_embed_train: a 24-byte header [NXEMB1, nv, dim] then
nv x dim Q10 integers, row index shared with the PPMI vocabulary that nx_ppmi_lib resolves) turned into discrete features a
perceptron or CRF can weight. Each coordinate is quantised to a signed bucket at half-RMS steps and clamped at
+-EF_BUCKET_MAX; the step is DERIVED from the table itself at load (the RMS over every coordinate), never typed, so the
buckets follow the model's own scale. A word the vocabulary does not know reads EF_NONE at every coordinate and its
feature spells a single byte, degrading to the base features rather than to garbage. Two gates already read this file
inline (the reader gates); this is the copy both can import. license_tier: ORIGINAL No hw writes (Rule 26). LIB.
dependencies 3 imports · 2 importers
imports: nx_syscalls.nxnx_reviewmine_lib.nxnx_ppmi_lib.nx
imported by: nx_absa_seq.nxnx_embfeat_gate.nx
structs
| none |
consts
| 13 | const EF_G_BYTES: i64 = 1024 // the PPMI lib's g-block (its contract: a zeroed block of at least 632 bytes) |
| 14 | const EF_HDR: i64 = 24 // magic 8 + nv 8 + dim 8 |
| 15 | const EF_I64_BYTES: i64 = 8 |
| 16 | const EF_MAGIC_N: i64 = 78 |
| 17 | const EF_MAGIC_X: i64 = 88 |
| 18 | const EF_MAGIC_E: i64 = 69 |
| 19 | const EF_MAGIC_M: i64 = 77 |
| 20 | const EF_MAGIC_B: i64 = 66 |
| 21 | const EF_MAGIC_1: i64 = 49 |
| 22 | const EF_BUCKET_MAX: i64 = 4 // buckets -4..4: nine cells at half-RMS steps resolve a bell-shaped coordinate |
| 23 | const EF_STEP_DIV: i64 = 2 // step = rms / 2 |
| 24 | const EF_NONE: i64 = 0 - 1 |
| 25 | const EF_CH_ZERO: i64 = 48 |
| 26 | const EF_CH_AT: i64 = 64 |
functions
| 38 | func ef_reset() -> i64 |
| 50 | func ef_load(ppmi_path: *u8, emb_path: *u8) -> i64 |
| 85 | func ef_ok() -> i64 { return ef_ready } |
| 86 | func ef_dim_of() -> i64 { return ef_dim } |
| 87 | func ef_nv_of() -> i64 { return ef_nv } called by 1: main |
| 88 | func ef_step_of() -> i64 { return ef_step } called by 1: main |
| 89 | func ef_rms_of() -> i64 { return ef_rms } called by 1: main |
| 90 | func ef_lookup_count() -> i64 { return ef_lookups } |
| 91 | func ef_hit_count() -> i64 { return ef_hits } |
| 93 | func ef_wid(s: *u8, n: i64) -> i64 |
| 103 | func ef_coord(wid: i64, d: i64) -> i64 { return ef_tab[wid * ef_dim + d] } |
| 105 | func ef_bucket(v: i64) -> i64 |
| 112 | func ef_spell(wid: i64, d: i64, out: *u8) -> i64 |
| 121 | func ef_plant(path: *u8, buf: *u8, offs: *i64, lens: *i64, vecs: *i64, nw: i64, dim: i64) -> i64 |