nanoGPT

nanoGPT is a plain PyTorch repository written to train and fine-tuning medium-sized GPT models; it contains about 300 lines of training cycles and 300 lines of model definition, OpenAI can load GPT-2 weights. train.py reproduces the GPT-2 (124M) model on OpenWebText. As of November 2025, the author declared the repository old and deprecated, suggesting a nanochat instead.

NA

karpathy · AI / LLM / RAG

STARS64.3K
FORKS11.0K
COMMITS210
CONTRIBUTORS37
VERSION—
UPDATED11 mo ago
PythonGPT EğitimiResearchKarpathyMIT

Common commercial products in this category: ChatGPT, Claude, Gemini

What can it do?
  • Based on Shakespeare data, you quickly train a character-based little GPT model.
  • You use GPT-2 weights supplied by OpenAI by uploading them to the model
  • You do fine-tuning (finetune) over pre-trained checkpoints
User reviews
  • • NeutralHacker News

    karpathy/build-nanogpt: Video + code lecture on building nanoGPT from scratch

    “H1: build nanoGPT Title: Video+code lecture on building nanoGPT from scratch Please don't do things to make titles stand out (..) Otherwise please use the original title”

  • • NeutralGitHub Issue

    Training on M1 "MPS"

    “Most of the people do not have access to 8XA100 40GB systems. But a single M1 Max laptop with 64 GB memory could host the training. How difficult is it to port this code to "MPS" ?”

GitHub

Verified against README · Oct 26, 2026 · source

My note

Alternative pages

More in: AI / LLM / RAG