Show HN: Andrej Karpathy's microgpt.py to C99 microgpt.c – 4,600x faster
Source: Hacker News
MicroGPT-C
A zero-dependency, pure C99 implementation of a GPT-style character-level language model.
The algorithm faithfully matches Andrej Karpathy’s microgpt.py — same architecture, same training loop, same sampling — but compiles to native code with optional compiler‑driven SIMD auto‑vectorisation for dramatically faster training and inference.
Train a GPT in 20 ms. Generate names in microseconds. No Python. No PyTorch. No GPU.
What Is This?
MicroGPT‑C is a minimal, readable implementation of a GPT (Generative Pre‑trained Transformer) — the same family of models behind ChatGPT, but stripped down to its essential algorithm. It trains a tiny character‑level language model that learns to generate realistic human names from scratch.
The goal is education and experimentation: understand how attention, softmax, Adam optimiser, and back‑propagation work at the lowest level, without any framework abstractions.
Audience & Value
| Audience | Value |
|---|---|
| Students & educators | Study attention, softmax, Adam, and back‑prop in readable C — no framework magic |
| Embedded / edge engineers | Entire model fits in **), Enjector Software Ltd. |