code wiki / (root) / nx_qwen_extract.nx

nx_qwen_extract.nx

buildroot/runtime/nx_qwen_extract.nx

6558 B135 linesdepth 10pulls 21 transitivereach 2 importersview sourcekind librarytopic qwen
docsdependenciesstructsconstsfunctions

about

nx_qwen_extract.nx -- R5: the pretrained sovereign Qwen as the RESEARCHER'S EXTRACTION stage (importable by nx_qabench). qwx_load() boots the model ONCE (like rd_load); qwx_extract(g, para, pred) reads paragraph `para`'s sentences + the question (qabench g[] slots) and greedy-generates an answer IN-PROCESS (nsv_generate, no HTTP), writing the first-line answer into pred (db_setpred convention: <=250 chars + NUL). Opt-in: qabench calls these only in qwen-reader mode. PROVEN standalone: nx_qwen_reader_bench_gate measured Qwen-as-reader >> mechanical 251. Sovereign: nx_nofloat_serve_core. ⚠tk_bpe_encode overflows g_nsv_ids past 192 tok BEFORE its length check -> the QWX_MAXPROMPT char guard is MANDATORY (SIGSEGV otherwise). license_tier: ORIGINAL

dependencies 2 imports · 2 importers

nx_syscalls.nx nx_nofloat_serve_core.nx nx_qwen_extract.nx nx_qabench.nx nx_qwen_extract_gate.nx

imports: nx_syscalls.nxnx_nofloat_serve_core.nx

imported by: nx_qabench.nxnx_qwen_extract_gate.nx

structs

none

consts

11const QWX_MODEL: *u8 = "/home/elderwesto/nx_stage/nx_real_model.gguf"
12const QWX_CTXCAP: i64 = 500 // s0-window context cap; 253(1-shot)+500+140(Q+cues)=893 < MAXPROMPT. ⚠2-shot@380 was REVERTED: measured on-protocol SQuAD 427 < 1-shot@500 510 (surface benefit null under multi-alias; 380 clips real retrieved paras). See arc memory.
13const QWX_MAXPROMPT: i64 = 900 // hard char guard at the PROVEN-SAFE band: 900/2.5-worst-bpe = 360 tok + 16 gen = 376 < NSV_MAXT=384 (1000 allowed ~400 tok worst-case = g_nsv_ids overflow risk)
14const QWX_MAXNEW: i64 = 16
15const QWX_MODE: i64 = 0 // 0 = i32 lossless (faithful default; i8 also verified working at NSV_MAXT=384)

functions

26func qwx_load() -> i64
54func qwx_ready() -> i64 { return g_qwx_ready }
56func qwx_cat(dst: *u8, off: i64, s: *u8, n: i64, cap: i64) -> i64
called by 1: qwx_extract
62func qwx_cats(dst: *u8, off: i64, s: *u8, cap: i64) -> i64
called by 1: qwx_extract
72func qwx_extract(g: *i64, s0: i64, pred: *u8) -> i64