BuildTube Preview About
Back to the feed

nanochat: Train a small GPT-2 level chatbot and talk to it

Added · Updated

Train your own small chatbot from scratch on a GPU server, then chat with it in the terminal.

For people who want to learn how language models are trained.

What it does

nanochat is an open-source harness from the karpathy repository for training language models. It covers tokenization, pretraining, finetuning, evaluation and inference. One setting, --depth, sets the number of layers, and the other training settings are calculated automatically.

How to use it

Rent an 8XH100 GPU machine from a GPU cloud provider, install the dependencies with uv, and run the speedrun script with bash. It takes about 1.5 hours. Then activate the virtual environment and chat with the model in the terminal.

Common use cases

  • Run the speedrun script on an 8XH100 node, and you get a GPT-2 grade model that you can chat with in your terminal.
  • Ask the trained model why the sky is blue, and you see a short answer that may contain mistakes.
  • Change the single --depth number, and you get a model with a different layer count while its other settings are worked out automatically.

Can I use this?

Needs a GPU server you rent or own

Requirements It runs on a GPU machine you rent or own. Install with uv, using the GPU option for CUDA or the CPU option for CPU-only or MPS. Licensed under MIT.

Caveat Cost and leaderboard figures in the source come from the author's runs on 8XH100 nodes at $3 per GPU hour, so your provider's price may differ.

Worth knowing The speedrun model is described as being like talking to a kindergartener, and it can hallucinate. Hardware such as xpu or mps is not fully exercised by the author.

Why it's here

Not trending this week

Last seen on the GitHub trending list on 3 November 2026. It stays on BuildTube so you can still find it.

  • 60,370 people have starred it on GitHub.

Numbers checked on 8 November 2026; not refreshed since.

Behind it

View setup guide

BuildTube has not run or verified this project. Everything above is written from what the creator published.

Made this?

Quick questions

What is nanochat?
nanochat is an open-source harness from the karpathy repository for training language models.
What can I use nanochat for?
Run the speedrun script on an 8XH100 node, and you get a GPT-2 grade model that you can chat with in your terminal. Ask the trained model why the sky is blue, and you see a short answer that may contain mistakes. Change the single --depth number, and you get a model with a different layer count while its other settings are worked out automatically.
Can I run nanochat on my computer?
Not on a typical laptop. The documented setup is an 8XH100 GPU node you rent or own; a single GPU works but takes about 8 times longer. Install with uv.
What do I need to use nanochat?
An 8XH100 GPU node is the documented setup; a single GPU also works but takes 8 times longer. GPUs with under 80GB need a smaller --device-batch-size. Dependencies install with uv.
What license does nanochat use?
Licensed under MIT.

More from this week

Explore by topic

Post this

A ready-made picture of this card for X, LinkedIn or a group chat. Link to this page alongside it.

Share image for nanochatDownload share image

For makers

Made this? Show it’s on BuildTube — add the badge to your README or embed the card on your site.

Featured on BuildTube

README badge (Markdown)

[![Featured on BuildTube](https://buildtube.app/badge/gh-karpathy-nanochat.svg)](https://buildtube.app/p/gh-karpathy-nanochat/)

Embed card (HTML)

<iframe src="https://buildtube.app/embed/gh-karpathy-nanochat/" width="560" height="240" style="border:0;max-width:100%" loading="lazy" title="nanochat on BuildTube"></iframe>

Back to the feed