code wiki / (root) / nx_reader_mlp_train.nx

nx_reader_mlp_train.nx

buildroot/runtime/nx_reader_mlp_train.nx

16842 B346 linesdepth 5pulls 7 transitivereach 0 importersview sourcekind tooltopic reader
docsdependenciesstructsconstsfunctions

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

nx_autograd.nx nx_reader_mlp_train.nx

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

main gw sys_read gn nx_f32_div nx_f32_classify nx_f32_exp_field nx_f32_mant_field nx_f32_sign nx_f32_mant_field ↻ nx_f32_exp_field ↻ nx_i32_to_f32 ag_constf nx_f32_div ↻ nx_i32_to_f32 ↻ init_w ag_constf ↻ ag_leaf mlp_fwd ag_mul ag_mk nx_f32_mul nx_f32_classify ↻ nx_f32_sign ↻ nx_f32_mant_field ↻ nx_f32_exp_field ↻ ag_add ag_mk ↻ nx_f32_add nx_f32_classify ↻ nx_f32_sign ↻ nx_f32_mant_field ↻ nx_f32_exp_field ↻ ag_relu nx_f32_gt nx_f32_lt nx_f32_is_nan nx_f32_classify ↻ nx_f32_is_zero nx_f32_classify ↻

structs

none

consts

12const NP_MAGIC_2147483648: i64 = 2147483648
13const NP_MAGIC_8388608: i64 = 8388608
14const NP_MAGIC_67108864: i64 = 67108864
15const NP_MAGIC_4000: i64 = 4000
16const NP_MAGIC_80000: i64 = 80000
17const NP_MAGIC_8192: i64 = 8192
18const NP_MAGIC_4096: i64 = 4096
48const NF: i64 = 17 // 14 hand + 3 corpus-PPMI scalar embed features
49const H: i64 = 8
50const NP_MLP: i64 = 153 // W1[H*NF]=136 + b1[H]=8 + W2[H]=8 + b2=1
51const B1: i64 = 136 // b1 base (H*NF)
52const W2: i64 = 144 // W2 base (B1+H)
53const B2: i64 = 152 // b2 (W2+H)
54const NP_LIN: i64 = 18 // w[17] + b
55const NEG_K: i64 = 4 // negatives sampled per gold per epoch

functions

20func 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
21func gn(v: i64) -> i64
called by 1: main
28func f32_trunc(raw: i64) -> i64
called by 1: main
58func mlp_fwd(tape: *i64, np: *i64, xbase: i64) -> i64
called by 2: mlp_scoremain calls 3: ag_mulag_addag_relu
78func lin_fwd(tape: *i64, np: *i64, xbase: i64) -> i64
called by 2: mlp_scoremain calls 2: ag_mulag_add
91func mlp_score(tape: *i64, np: *i64, W: *i64, feat: *i64, is_mlp: i64) -> i64
called by 1: main calls 4: ag_leafmlp_fwdlin_fwdag_val
105func init_w(W: *i64, n: i64, mlp: i64) -> i64
called by 1: main calls 1: ag_constf
112func main() -> i64