muend.
LLM fundamentals · Built from scratch

neuron-to-gpt

A learning journal that starts at one neuron and ends at a trained character-level GPT, with the architecture's gains measured stage by stage.

PublicPyTorchA100-trained31 tests
Scope8 weeks, one runnable directory each
Model6 blocks · 8 heads · width 256 · context 256
Parameters4,833,345 English · 4,860,534 Turkish
Training5,000 updates · BF16 · NVIDIA A100 · ≈7.3 min per model
Validation NLL1.4723 Shakespeare · 1.6239 Turkish
Tests31, incl. exact checkpoint continuation
Why

Know the machine you evaluate

Evaluating language models for a living without ever having built one leaves a gap. This journal closes it the slow way: a neuron, a loss, a gradient, then an autograd engine written with nothing but the standard library, and only then PyTorch.

From week three each new layer is rebuilt by hand before the framework version is trusted: the bigram counts before the neural bigram, manual backpropagation before backward(), a custom BatchNorm before LayerNorm, causal averaging before attention. The Week 8 model was written before the finished reference was consulted.

Fig. 01

Eight weeks, then a measured comparison

The six-stage comparison holds the corpus, split, seed and iteration budget fixed and adds one idea at a time. Each step improved in this run; the repository says plainly that improvement is not guaranteed for every configuration.

Fig. 01 / Path and measured stages
ONE NEURON → CHARACTER-LEVEL GPT 8 WEEKS · 31 TESTS · PUBLIC 01 / EIGHT WEEKS, ONE DEPENDENCY CHAIN EACH LAYER IS REBUILT BEFORE IT IS USED W1 · NEURON LOSS · GRADIENT W2 · AUTOGRAD VALUE · BACKWARD() W3 · BIGRAM COUNTS · NLL W4 · MLP LM EMBED · BATCHNORM W5 · BACKPROP DERIVED BY HAND W6 · HIERARCHY WAVENET-STYLE W7 · ATTENTION CAUSAL · ONE HEAD W8 · GPT BLOCKS · A100 WEEKS 1–2 · STANDARD LIBRARY ONLY WEEKS 3–8 · PYTORCH 02 / SIX-STAGE COMPARISON — VALIDATION NLL, LOWER IS BETTER SAME CORPUS · SEED · 4,000 ITERATIONS ON CPU BIGRAM 2.4942 4,225 PARAMS SINGLE HEAD 2.3457 22,721 PARAMS MULTI-HEAD 2.1314 26,881 PARAMS + FEEDFORWARD 1.9422 59,969 PARAMS + RESIDUAL PATHS 1.8846 59,969 PARAMS + PRE-LAYERNORM 1.8673 60,353 PARAMS BAR LENGTH = NLL ABOVE 1.40 NATS PER CHARACTER · PARAMETER COUNTS RISE, SO THIS IS NOT PARAMETER-MATCHED 03 / SCALED MODEL WIDTH, DEPTH, CONTEXT AND BUDGET CHANGE TOGETHER: NOT AN ABLATION 6 BLOCKS · 8 HEADS · WIDTH 256 · CONTEXT 256 · 4,833,345 PARAMETERS 5,000 UPDATES ON AN A100 · VALIDATION NLL 1.4723 SHAKESPEARE · 1.6239 TURKISH
Results

What the trained models reached

Architecture gain−0.627

Nats per character from bigram to the completed block, at a fixed CPU budget.

Shakespeare1.4723

Final validation NLL after 5,000 updates; best sampled checkpoint 1.4657 at step 4,500.

Turkish corpus1.6239

A 1.9M-character Nâzım Hikmet collection with a 118-character vocabulary. Not a ranking against English.

Live inferenceGradio

An optional panel loads the trained checkpoints and generates text next to the recorded evidence.

The Turkish corpus was prepared from three user-selected PDFs with layout-aware extraction and OCR recovery of 243 pages. Raw texts, PDFs and checkpoints stay out of Git; only metrics, loss histories, plots and samples are published.

Sample

What 4.8 million parameters can and cannot do

An unedited excerpt generated by the Shakespeare model, not a quotation:

KING RICHARD II: Shall I, be made to be exceeding?
QUEEN ELIZABETH: My hard will I be?

The model has learned speaker labels, line structure and plausible vocabulary. It has not learned meaning. A low character loss does not guarantee coherent writing, and the repository states that next to the samples.

Limitations

Educational scale, and stated as such. The larger runs change width, depth, context, training budget and precision together, so they are not an ablation; the six-stage CPU table is the controlled comparison, and it is not parameter-matched. The reported GPU losses were validated for internal consistency against the returned histories, not re-evaluated independently. The sequence follows Andrej Karpathy's lecture series.

Open to collaboration

Build spatial systems that hold up.

© 2026 Muhammed Enes Duran Static site · no trackers
Technical diagram