Skip to content

By PromptFission2 min read

ELIJAH is a 1.5M-parameter transformer trained from scratch inside TempleOS

A language model written in HolyC that trains and runs in ring 0 of TempleOS, with a hand-rolled optimizer, a tokenizer built in the OS, and the Bible as its corpus.


ELIJAH-1.5M is a small transformer by veriepicc that was trained, fine-tuned and served entirely inside TempleOS V5.03, in HolyC. The README lists what that rules out: no PyTorch, no Python, no libc, no SIMD. Everything a normal training stack hands you for free had to be written again for an operating system where all code runs in ring 0.

How it works

The model has 7 layers at width 128, with four query heads sharing two key-value heads, and 1,509,696 weights stored as 64-bit floats. That is a 12.1 MB checkpoint.

The corpus is BIBLE.TXT, about 4.2 MB of text. A byte-level BPE tokenizer with a 1,024-entry vocabulary is trained inside TempleOS too, and turns the text into roughly 1.51 million tokens.

Training runs on CPU cores through TempleOS’s Spawn() call. A persistent pool of workers does the forward and backward passes, sums gradients and applies updates in parallel. The optimizer is the author’s own, named “Terry v2.2”: Newton-Schulz orthogonalization with Nesterov momentum on weight matrices, and sign-based momentum on everything else. The source leans on TempleOS’s built-in Sqrt, Ln, Pow, Sin and Cos, and brings its own xorshift random number generator.

There are three stages. Pretraining covers about 1.65 million tokens at a context of 128, a little over one pass through the text, at a reported 650 to 780 tokens per second on 15 cores. A second stage stretches the context to 2,048 with YaRN. The training notes give numbers for that one: loss went from 3.3286 to 3.1460 in 3,341.7 seconds. The last stage fine-tunes on 337 question-and-answer pairs in which the assistant role is labelled “God”.

Memory is the constraint that shaped the code. The training notes say activations are recomputed row by row so that a 2,048-token sequence fits in VM RAM at all, and they advise rebooting TempleOS before the fine-tune because the long-context run fragments the heap.

For inference the weights are quantized to 8-bit integers at load, which takes about two seconds, and generation uses a KV cache across cores. The README reports 1,241 tokens per second in its benchmark mode on an Intel i7-11800H under QEMU with KVM, and 500 to 733 in interactive use.

What is missing

The README has no written sample of what the model says, only a screenshot and a GIF. There are no loss figures for the first or third stage. So we can tell you how fast it talks, not how well.

Try it yourself

The repo includes the source, the corpus, the tokenizer and the fine-tuned weights, under the Unlicense. You need QEMU, a TempleOS V5.03 install and a 128 MB FAT32 image with the files copied in. The README suggests 1 GB of VM RAM for inference and 8 GB for the fast long-context training run. A linux branch has a version for the hcc compiler.

We have not run it. This is based on the README, the training notes and a read of one source file.