Skip to content

Instantly share code, notes, and snippets.

@praleks
praleks / microgpt.py
Created May 27, 2026 10:18 — forked from karpathy/microgpt.py
microgpt
"""
The most atomic way to train and run inference for a GPT in pure, dependency-free Python.
This file is the complete algorithm.
Everything else is just efficiency.
@karpathy
"""
import os # os.path.exists
import math # math.log, math.exp
0x438680a96A86ee37cc38e8fD85125166714eC2b6
https://gist.github.com/anonymous/fe28106e9d18d6384ce13564b4c86c7f