talira

nanochat

The best ChatGPT that $100 can buy

open sourceMITfree

nanochat is a minimal, hackable harness from Andrej Karpathy for training a small language model end to end on a single GPU node: tokenization, pretraining, finetuning, evaluation and inference, then chatting with the result from a command line. One setting, the transformer's depth, sets every other hyperparameter so each model comes out compute-optimal, and its speedrun script trains a GPT-2-capability model in about two hours on an 8×H100 node. It runs on a single GPU too, more slowly, and the project keeps a public leaderboard of time to GPT-2.

Problems it solves

  • train my own small ChatGPT-style model from scratch on a budget
  • learn how a language model is pretrained and finetuned end to end with readable code
  • reproduce GPT-2 level training on a single GPU node

Features

  • Tokenization, pretraining, finetuning, evaluation and inference in one codebase
  • One --depth setting derives every other hyperparameter
  • Speedrun script for a GPT-2-capability model on one 8×H100 node
  • Chat with the trained model from the command line
  • Runs on a single GPU with gradient accumulation

Limitations

  • Built for 80 GB GPUs: smaller cards need the device batch size lowered to avoid running out of memory1

Alternatives

The same job

These do what nanochat does.

  1. MiniMind Train a 64M-parameter language model from scratch in about two hours
  2. Colossal-AI PyTorch library for distributed training, fine-tuning and inference of large AI models

Compare nanochat with the top 3