nx_nofloat_scale_research_fetch.nx source
↩ module page · 88 lines · 6317 B
1// nx_nofloat_scale_research_fetch.nx -- SOVEREIGN researcher: GROUND the "how do we AFFORDABLY + EFFICIENTLY
2// land a real working no-float transformer LM (CAP-AI-FRONTIER)" roadmap in REAL fetched facts (Rule 4:
3// roadmaps need VERIFIED facts, never assumptions). The no-float MECHANISM ladder is complete (train→generate→
4// sample→generalize→prose→in-context-copy→induction); what remains is SCALE/DATA/COMPUTE -- so this fetches the
5// literature on the CHEAPEST high-leverage moves: compute-optimal scaling, tiny-but-capable models, integer/
6// ternary LLMs (our exact no-float axis), and efficiency techniques.
7//
8// Mirrors nx_ng_research_fetch: sovereign TLS-1.3 (nx_https_fetch_follow) + Mozilla CA store, idempotent
9// skip-if-have, saves each source to knowledge/fetched/nfs_*.raw so the corpus COMPOUNDS + can be grepped to
10// CITE (>=2-source / no-hearsay). 100% sovereign (own TLS, nx_cc->nxasm, no curl/wget/gcc). expect_exit: 0
11import "nx_syscalls.nx"
12import "nx_x509_trust_store.nx"
13import "nx_trust_store_load_from_certdata.nx"
14import "nx_https_fetch_follow.nx"
15const K_MAGIC_4194304: i64 = 4194304
16const K_MAGIC_8388608: i64 = 8388608
17
18func df_puts(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } sys_write(1, s, n); return 0 }
19func df_putn(v: i64) -> i64 {
20 if v == 0 { sys_write(1, "0" as *u8, 1); return 0 }
21 var m: i64 = v
22 if m < 0 { sys_write(1, "-" as *u8, 1); m = 0 - m }
23 let d: *u8 = sys_mmap(24); var k: i64 = 0
24 while m > 0 { d[k] = (48 + (m % 10)) as u8; m = m / 10; k = k + 1 }
25 var j: i64 = k - 1
26 while j >= 0 { sys_write(1, ((d as i64)+j) as *u8, 1); j = j - 1 }
27 return 0
28}
29func have_file(path: *u8) -> i64 { let fd: i64 = sys_openat_rd(path); if fd < 0 { return 0 } sys_close(fd); return 1 }
30func fetch_save(url: *u8, opath: *u8, store: *TrustStore, out: *u8, cap: i64) -> i64 {
31 if have_file(opath) == 1 { df_puts(opath); df_puts(" [have-skip]\n"); return 1 }
32 let status: *i64 = sys_mmap(8) as *i64
33 let n: i64 = nx_https_fetch_follow(url, store, out, cap, 6, status)
34 df_puts(url); df_puts(" status="); df_putn(status[0]); df_puts(" bytes="); df_putn(n)
35 if n <= 0 { df_puts(" FETCH-FAIL\n"); return 0 }
36 var gz: i64 = 0
37 if n >= 2 { if out[0] == 0x1f as u8 { if out[1] == 0x8b as u8 { gz = 1 } } }
38 if gz == 1 { df_puts(" [GZIP-skip]\n"); return 0 }
39 let fd: i64 = sys_openat_wr(opath, 0x1a4)
40 if fd < 0 { df_puts(" SAVE-FAIL\n"); return 0 }
41 sys_write(fd, out, n); sys_close(fd)
42 df_puts(" SAVED\n")
43 return 1
44}
45
46func main() -> i64 {
47 let r: i64 = nx_trust_store_load_from_certdata("data/mozilla_certdata.txt" as *u8, 512, K_MAGIC_4194304)
48 if r <= 0 { df_puts("NFS: certdata load failed\n"); return 1 }
49 let store: *TrustStore = r as *TrustStore
50 df_puts("CA roots="); df_putn(trust_store_count(store)); df_puts("\n")
51 let cap: i64 = K_MAGIC_8388608
52 let out: *u8 = sys_mmap(cap)
53 var ok: i64 = 0
54
55 df_puts("== COMPUTE-OPTIMAL SCALING (spend compute right; data:param ratio = the affordability lever) ==\n")
56 ok = ok + fetch_save("https://en.wikipedia.org/wiki/Neural_scaling_law" as *u8, "knowledge/fetched/nfs_scaling_law.raw" as *u8, store, out, cap)
57 ok = ok + fetch_save("https://arxiv.org/abs/2203.15556" as *u8, "knowledge/fetched/nfs_chinchilla.raw" as *u8, store, out, cap)
58 ok = ok + fetch_save("https://arxiv.org/abs/2001.08361" as *u8, "knowledge/fetched/nfs_kaplan.raw" as *u8, store, out, cap)
59
60 df_puts("== TINY-BUT-CAPABLE (small models CAN be coherent on the RIGHT data = the cheapest path to land) ==\n")
61 ok = ok + fetch_save("https://arxiv.org/abs/2305.07759" as *u8, "knowledge/fetched/nfs_tinystories.raw" as *u8, store, out, cap)
62 ok = ok + fetch_save("https://arxiv.org/abs/2306.11644" as *u8, "knowledge/fetched/nfs_phi_textbooks.raw" as *u8, store, out, cap)
63 ok = ok + fetch_save("https://en.wikipedia.org/wiki/Large_language_model" as *u8, "knowledge/fetched/nfs_llm.raw" as *u8, store, out, cap)
64
65 df_puts("== INTEGER / TERNARY LLMs (our EXACT no-float axis -- the literature that matches our substrate) ==\n")
66 ok = ok + fetch_save("https://arxiv.org/abs/2402.17764" as *u8, "knowledge/fetched/nfs_bitnet158.raw" as *u8, store, out, cap)
67 ok = ok + fetch_save("https://arxiv.org/abs/2310.11453" as *u8, "knowledge/fetched/nfs_bitnet.raw" as *u8, store, out, cap)
68 ok = ok + fetch_save("https://arxiv.org/abs/1712.05877" as *u8, "knowledge/fetched/nfs_intquant.raw" as *u8, store, out, cap)
69 ok = ok + fetch_save("https://en.wikipedia.org/wiki/Quantization_(signal_processing)" as *u8, "knowledge/fetched/nfs_quantization.raw" as *u8, store, out, cap)
70
71 df_puts("== EFFICIENCY TECHNIQUES (get more from less compute) ==\n")
72 ok = ok + fetch_save("https://en.wikipedia.org/wiki/Knowledge_distillation" as *u8, "knowledge/fetched/nfs_distillation.raw" as *u8, store, out, cap)
73 ok = ok + fetch_save("https://arxiv.org/abs/1503.02531" as *u8, "knowledge/fetched/nfs_hinton_distill.raw" as *u8, store, out, cap)
74 ok = ok + fetch_save("https://arxiv.org/abs/2106.09685" as *u8, "knowledge/fetched/nfs_lora.raw" as *u8, store, out, cap)
75 ok = ok + fetch_save("https://en.wikipedia.org/wiki/Transfer_learning" as *u8, "knowledge/fetched/nfs_transfer.raw" as *u8, store, out, cap)
76
77 df_puts("== DATA / TOKENIZATION (efficient use of a small corpus) ==\n")
78 ok = ok + fetch_save("https://en.wikipedia.org/wiki/Byte_pair_encoding" as *u8, "knowledge/fetched/nfs_bpe.raw" as *u8, store, out, cap)
79 ok = ok + fetch_save("https://en.wikipedia.org/wiki/Language_model" as *u8, "knowledge/fetched/nfs_langmodel.raw" as *u8, store, out, cap)
80
81 df_puts("== OPTIMIZERS / FOUNDATIONS (what we already have, for grounding the recipe) ==\n")
82 ok = ok + fetch_save("https://arxiv.org/abs/1412.6980" as *u8, "knowledge/fetched/nfs_adam.raw" as *u8, store, out, cap)
83 ok = ok + fetch_save("https://en.wikipedia.org/wiki/Transformer_(deep_learning_architecture)" as *u8, "knowledge/fetched/nfs_transformer.raw" as *u8, store, out, cap)
84 ok = ok + fetch_save("https://en.wikipedia.org/wiki/Perplexity" as *u8, "knowledge/fetched/nfs_perplexity.raw" as *u8, store, out, cap)
85
86 df_puts("NFS READABLE SOURCES SAVED: "); df_putn(ok); df_puts(" / 19\n")
87 return 0
88}