code wiki / _hdl_build / nx_mt_r0_gate.nx
nx_mt_r0_gate.nx
buildroot/runtime/_hdl_build/nx_mt_r0_gate.nx
about
nx_mt_r0_gate.nx -- GATE for MT-R0: the first rung of the SOVEREIGN NEURAL MACHINE TRANSLATION
arc (GEN-WL-WL-NN-TRANSLATION). Proves, by RUNNING, that a sovereign neural net LEARNS to
translate -- from random/zero init via the team's own scalar-tape autograd, NOT a hardcoded
table. The trainable atom of neural MT = a learned bilingual map: one-hot source word ->
linear layer W (the learned parameters) -> output vector -> argmax -> target word. Composes
ONLY shipped+gated organs (nx_autograd TRAIN-R1 GREEN + nx_f32 tower). No attention/weights
loaded; this is the BACKWARD/learning half proven on a translation task in miniature, the
foundation the rest of the arc (sequences -> FNet-mix context -> BPE vocab -> corpus -> the
/video /translate endpoint) climbs on.
Demo dictionary (English -> Spanish), TARGET INDICES ARE A PERMUTATION (not identity) so a
pass cannot come from a trivial copy:
src EN: 0 hello 1 family 2 love 3 good 4 day 5 water
tgt ES: 0 familia 1 bueno 2 hola 3 dia 4 agua 5 amor (vocab in a DIFFERENT order)
map: hello->hola(2) family->familia(0) love->amor(5) good->bueno(1) day->dia(3) water->agua(4)
=> tgt = [2,0,5,1,3,4] (a real permutation the net must LEARN)
FOUR GATES:
A LEARNS: after training, argmax == tgt for ALL 6 pairs (acc 6/6) AND mean loss < 1/1000
AND loss decreased. The exact statement of "the net learned to translate".
B UNTRAINED FAILS (liar-kill): the zero-epoch (W=0) model scores < 6/6 -> the LEARNING did
it, not the harness/architecture.
C BIT-EXACT REPRODUCIBLE: train twice from zero-init; final W bits identical (determinism
exceed-axis carried into ML, like TRAIN-R1 gate C).
D DATA-DRIVEN (anti-hardcode liar-kill): train against a DIFFERENT permutation tgt2; the net
learns tgt2 (acc_vs_tgt2 == 6/6) AND no longer matches the original (acc_vs_tgt < 6/6).
Kills any "the answer was baked in" cheat -- it learns whatever data it is given.
genealogy_id: linnainmaa_1970_reverse_mode_ad + rumelhart_1986_backprop (realized_in nx_autograd)
lineage_id: sovereign_neural_mt_r0_learned_wordmap_v1
license_tier: ORIGINAL
dependencies 2 imports · 0 importers
imports: nx_autograd.nxnx_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
| 35 | const MT_LOG: *u8 = "knowledge/status/mt_r0.log" |
| 36 | const MT_S: i64 = 6 // source vocab size |
| 37 | const MT_T: i64 = 6 // target vocab size |
| 40 | const EN0: *u8 = "hello" as *u8 |
| 41 | const EN1: *u8 = "family" as *u8 |
| 42 | const EN2: *u8 = "love" as *u8 |
| 43 | const EN3: *u8 = "good" as *u8 |
| 44 | const EN4: *u8 = "day" as *u8 |
| 45 | const EN5: *u8 = "water" as *u8 |
| 46 | const ES0: *u8 = "familia" as *u8 |
| 47 | const ES1: *u8 = "bueno" as *u8 |
| 48 | const ES2: *u8 = "hola" as *u8 |
| 49 | const ES3: *u8 = "dia" as *u8 |
| 50 | const ES4: *u8 = "agua" as *u8 |
| 51 | const ES5: *u8 = "amor" as *u8 |
| 52 | const ESQ: *u8 = "?" as *u8 |
functions
| 54 | func mt_en(i: i64) -> *u8 called by 1: mt_demo |
| 63 | func mt_es(j: i64) -> *u8 called by 1: mt_demo |
| 74 | func mt_w(fd: i64, s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } sys_write(fd, s, n); return 0 } |
| 75 | func mt_wn(fd: i64, v: i64) -> i64 |
| 86 | func mt_f32_to_milli(v: i64) -> i64 |
| 106 | func mt_argmax(W: *i64, i: i64) -> i64 |
| 119 | func mt_accuracy(W: *i64, tgt: *i64) -> i64 |
| 131 | func mt_train(epochs: i64, tgt: *i64, Wout: *i64, lfirst: *i64, llast: *i64) -> i64 |
| 179 | func mt_demo(fd: i64, W: *i64) -> i64 |
| 191 | func mt_emit(fd: i64, r: *i64) -> i64 |
| 204 | func main() -> i64 |