nx_reader_mlp_train.nx
buildroot/runtime/nx_reader_mlp_train.nx
about
nx_reader_mlp_train.nx -- NEURAL-READER RUNG 2: train the span-reader scorer as an MLP on nx_autograd over
the REAL MODE-R candidate features (dumped by `nx_qabench dumpfeats` -> knowledge/index/reader_feats.bin),
and MEASURE whether nonlinearity beats the linear perceptron that plateaued (~250 vs oracle 727). Pairwise
hinge ranking loss: the gold candidate must score above each negative by a margin. Reports TRAIN ranking
accuracy (argmax==gold) for the MLP vs a linear baseline trained the same way -- the decisive de-risking
measurement before wiring integer inference into nx_qabench. Persists quantized integer weights ->
knowledge/index/reader_mlp.bin (Q12) for the no-float inference path.
TEETH: T1 data loaded (rows>=500) T2 MLP ranking-acc > linear ranking-acc (nonlinearity helps on REAL feats)
T3 MLP ranking-acc >= 500 permille T4 weights persisted+reloaded.
expect_exit: 0 license_tier: ORIGINAL
dependencies 1 imports · 0 importers
imports: nx_autograd.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
| 12 | const NP_MAGIC_2147483648: i64 = 2147483648 |
| 13 | const NP_MAGIC_8388608: i64 = 8388608 |
| 14 | const NP_MAGIC_67108864: i64 = 67108864 |
| 15 | const NP_MAGIC_4000: i64 = 4000 |
| 16 | const NP_MAGIC_80000: i64 = 80000 |
| 17 | const NP_MAGIC_8192: i64 = 8192 |
| 18 | const NP_MAGIC_4096: i64 = 4096 |
| 48 | const NF: i64 = 17 // 14 hand + 3 corpus-PPMI scalar embed features |
| 49 | const H: i64 = 8 |
| 50 | const NP_MLP: i64 = 153 // W1[H*NF]=136 + b1[H]=8 + W2[H]=8 + b2=1 |
| 51 | const B1: i64 = 136 // b1 base (H*NF) |
| 52 | const W2: i64 = 144 // W2 base (B1+H) |
| 53 | const B2: i64 = 152 // b2 (W2+H) |
| 54 | const NP_LIN: i64 = 18 // w[17] + b |
| 55 | const NEG_K: i64 = 4 // negatives sampled per gold per epoch |
functions
| 20 | func gw(s: *u8) -> i64 { var n: i64=0; while s[n]!=(0 as u8){n=n+1} sys_write(1,s,n); return 0 } called by 1: main |
| 21 | func gn(v: i64) -> i64 called by 1: main |
| 28 | func f32_trunc(raw: i64) -> i64 called by 1: main |
| 58 | func mlp_fwd(tape: *i64, np: *i64, xbase: i64) -> i64 |
| 78 | func lin_fwd(tape: *i64, np: *i64, xbase: i64) -> i64 |
| 91 | func mlp_score(tape: *i64, np: *i64, W: *i64, feat: *i64, is_mlp: i64) -> i64 |
| 105 | func init_w(W: *i64, n: i64, mlp: i64) -> i64 |
| 112 | func main() -> i64 |