code wiki / _hdl_build / nx_lossless_language_test.nx

nx_lossless_language_test.nx source

↩ module page · 41 lines · 3194 B

1// nx_lossless_language_test.nx -- model building a lossless language for the net-new spec 2// "Diora Baird golfing as a video". Each refinement step is a real conditioning lever (the 3// generate->measure->refine loop), and the fidelity-to-spec it attains is the measured input. 4// The system must find WHEN the language became lossless and at what rate, monotonically. 5// Exit 0 if all hold. license_tier: ORIGINAL 6 7import "nx_lossless_language.nx" 8import "nx_syscalls.nx" 9 10func lt_puts(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } sys_write(1, s, n); return 0 } 11func lt_num(v: i64) -> i64 { let bb: *u8 = sys_mmap(28); var m: i64=v; if m<0 {m=0-m; sys_write(1,"-" as *u8,1)}; let t: *u8 = sys_mmap(28); var k: i64=0; if m==0 {t[0]=48;k=1}; while m>0 {t[k]=48+(m%10); m=m/10; k=k+1}; var i: i64=0; while i<k {bb[i]=t[k-1-i]; i=i+1}; sys_write(1, bb, k); return 0 } 12 13func main() -> i64 { 14 lt_puts("=== build a LOSSLESS LANGUAGE: 'Diora Baird golfing as a video' (fidelity-to-spec permil) ===\n" as *u8) 15 // each refinement is a conditioning lever; the number is the MEASURED fidelity-to-spec it reaches 16 let scores: *i64 = sys_mmap(8 * 8) as *i64 17 scores[0] = 600 // base prompt "woman golfing" -- generic, wrong identity 18 scores[1] = 740 // + structured caption (pose: golf swing, setting: fairway) 19 scores[2] = 820 // + identity embedding (the named entity) 20 scores[3] = 905 // + identity LoRA (sharpen likeness) 21 scores[4] = 965 // + style/control (camera, lighting) -> crosses lossless 22 scores[5] = 975 // + temporal/video control (motion coherence) 23 let N: i64 = 6 24 var i: i64 = 0 25 while i < N { lt_puts(" step " as *u8); lt_num(i); lt_puts(": fidelity=" as *u8); lt_num(scores[i]); lt_puts(" distortion=" as *u8); lt_num(ll_distortion(scores[i])); lt_puts(" marginal=" as *u8); lt_num(ll_marginal(scores, i)); lt_puts("\n" as *u8); i = i + 1 } 26 27 let conv: i64 = ll_converge_step(scores, N, LL_LOSSLESS_FLOOR) 28 lt_puts(" -> language became LOSSLESS at refinement step " as *u8); lt_num(conv); lt_puts(" (rate = " as *u8); lt_num(conv); lt_puts(" levers); distortion removed = " as *u8); lt_num(ll_distortion_removed(scores, N)); lt_puts(" permil\n" as *u8) 29 30 let r: *i64 = sys_mmap(8*8) as *i64 31 r[0] = 0; if conv == 4 { r[0] = 1 } // converges at the right step 32 r[1] = 0; if ll_is_monotone(scores, N) == 1 { r[1] = 1 } // sound search: no regression 33 r[2] = 0; if ll_is_lossless(scores[N-1], LL_LOSSLESS_FLOOR) == 1 { r[2] = 1 } // final is lossless 34 r[3] = 0; if ll_is_lossless(scores[0], LL_LOSSLESS_FLOOR) == 0 { r[3] = 1 } // base was NOT 35 r[4] = 0; if ll_distortion_removed(scores, N) >= 300 { r[4] = 1 } // language closed a big gap 36 var pass: i64 = 0; var j: i64 = 0 37 while j < 5 { pass = pass + r[j]; j = j + 1 } 38 lt_puts("----\n passed " as *u8); lt_num(pass); lt_puts("/5\n" as *u8) 39 if pass == 5 { lt_puts(" MODELED: the system REFINES the conditioning language until generation is lossless -- net-new, on demand, measured.\n" as *u8); sys_exit(0); return 0 } 40 lt_puts(" FAIL\n" as *u8); sys_exit(1); return 1 41}