Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/aienux/blob/main/native/kernel/x86/model/reference_probe.c # aienux Aienux, the AienOS kernel: boot, scheduling, IPC and capability boundaries. Pre-alpha; host, emulator and physical evidence are labelled separately. Brought by drakestapleton Sign in to star 0 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `main` Branches Tags History `aienux / native / kernel / x86 / model / reference_probe.c` 27 lines ยท 1084 bytes Raw Blame History 1 /* Independent upstream C reference, qualification only. Not linked into kernel. */ 2 #define main upstream_main 3 #include CK_LLAMA_REFERENCE 4 #undef main 5 int main(int argc, char **argv) { 6 if (argc < 4) return 2; 7 Transformer t; build_transformer(&t, argv[1]); 8 unsigned count = strtoul(argv[2], NULL, 10), nt = argc > 4 ? argc - 4 : 1; 9 int token = argc > 4 ? atoi(argv[4]) : 1; 10 float *logits = NULL; 11 printf("REFERENCE_MODEL ids="); 12 unsigned generated = 0; 13 for (unsigned pos = 0; pos < count + nt - 1; pos++) { 14 logits = forward(&t, token, pos); 15 token = 0; 16 for (int i = 1; i < t.config.vocab_size; i++) if (logits[i] > logits[token]) token = i; 17 if (pos + 1 < nt) token = atoi(argv[5 + pos]); 18 else { 19 if (token == 1) break; 20 printf("%s%d", generated++ ? "," : "", token); 21 } 22 } 23 puts(""); 24 FILE *f = fopen(argv[3], "wb"); 25 if (!logits || !f || fwrite(logits, 4, t.config.vocab_size, f) != (size_t)t.config.vocab_size || fclose(f)) return 2; 26 free_transformer(&t); return 0; 27 }