Back to Blog
Published:
Last Updated:
Fresh Content
Production LLMOps & EvaluationChapter 30

What is nanochat? Andrej Karpathy's full-stack LLM, explained

4 min read
963 words
high priority
Ali Ahmed

Ali Ahmed

AI Solutions Engineer, Cognilium AI

The exposed movement of a mechanical clock

TL;DR

nanochat is Andrej Karpathy's minimal end-to-end ChatGPT clone: tokenizer, pretraining, fine-tuning, inference and a web UI in one small codebase you can read.

nanochat is a complete, minimal implementation of a ChatGPT-style model, written by Andrej Karpathy and released as open source in October 2025. One repository takes you from raw text to a chat interface you can talk to: tokenizer, pretraining, fine-tuning, inference, and a small web UI.

The point is not the model it produces. A model trained this way is not competitive with anything you would pay for. The point is that the entire pipeline fits in one codebase small enough to read end to end, which is a different and rarer thing.

For engineers deciding whether it is worth their weekend. 7 minute read.

What is actually in the repository?

StageWhat it does
TokenizerTrains a byte-pair encoding tokenizer from scratch, implemented in Rust for speed
PretrainingTrains a transformer on a large web-text corpus
MidtrainingAdapts the base model toward conversation and structured formats
Supervised fine-tuningTrains on instruction and chat data
Reinforcement learningOptional, and the least essential stage for most readers
InferenceA serving engine with KV caching
Web UIA ChatGPT-like interface to talk to what you trained

That list is the reason the project exists. Most educational LLM code stops after pretraining, which is the half that is well explained everywhere and the half that produces nothing you can use.

Who made it, and why does that matter?

Andrej Karpathy: founding member of OpenAI, former director of AI at Tesla, and author of the teaching material a large share of working ML engineers learned from. nanoGPT, his earlier project, is one of the most forked educational repositories in the field.

That matters here for a practical reason rather than a reputational one. Code written to be read is different from code written to work, and very little published LLM training code is written to be read. The pedagogical intent is the feature.

How is nanochat different from nanoGPT?

nanoGPTnanochat
ScopePretraining onlyThe whole pipeline, tokenizer to chat UI
What you get at the endA base model that continues textSomething you can hold a conversation with
TokenizerUses an existing oneTrains its own
ServingNot includedIncluded, with a web interface

nanoGPT answers "how is a transformer trained". nanochat answers "how does a trained transformer become a product you can open in a browser", and that second question is where most people's understanding actually stops.

What hardware does nanochat need?

This is the question most people arrive with, and the honest answer has two halves.

The published target is a single 8xH100 node. Karpathy describes a speedrun costing roughly $100 and taking around four hours on that hardware, which is a rented machine for an afternoon rather than a purchase.

It is not a laptop project. You can read every line on a laptop, and you can run the inference stage against a small model, but the pretraining stage assumes serious GPUs. Anyone planning to work through it should budget for rented compute rather than expect it to run locally.

Both figures above are the author's, from the project's own announcement. We have not reproduced them, and you should treat any cost quoted for a training run as a function of the hardware market on the day it was measured.

What is it good for, and what is it not?

Good for: understanding the shape of the whole pipeline; seeing where each stage's data comes from; having a reference implementation small enough to modify and observe. If you have ever been unsure what "midtraining" means in practice, the answer is fifty lines here rather than a paper.

Not good for: producing a model to put in front of users. The result is a demonstration. Judged as a product it is worse than every free API you could call instead, and it is not trying to be otherwise.

The value is the readable pipeline, not the weights that fall out of the end of it.

Why would an engineering team care?

Because the failure modes in production retrieval and agent systems are usually not in the model. They are in the boundaries between stages, and this is the smallest artefact that shows every boundary at once: what the tokenizer decided, what pretraining saw, what fine-tuning changed, what inference does with a KV cache.

A team that has read one full pipeline end to end argues about the right things afterwards. That is worth an afternoon of rented GPUs whether or not you ever train anything again.

Share this article

The work behind this series

Evaluation harnesses, judges, retries and circuit breakers — how we keep an agent system honest once real traffic arrives.

Ali Ahmed

Ali Ahmed

AI Solutions Engineer, Cognilium AI

Ali Ahmed is an AI Solutions Engineer at Cognilium AI.

Applied AI AgentsAgentic SystemsRetrieval-Augmented Generation (RAG)LLM Product Engineering
In short

Key takeaways

  • nanochat is Andrej Karpathy's open-source, end-to-end implementation of a ChatGPT-style model, released October 2025.
  • It covers the whole pipeline: tokenizer, pretraining, midtraining, supervised fine-tuning, optional reinforcement learning, inference and a web UI.
  • The difference from nanoGPT is scope. nanoGPT stops after pretraining; nanochat goes to something you can talk to.
  • The published speedrun target is roughly $100 and about four hours on an 8xH100 node, per the author. It is not a laptop project.
  • The output is a demonstration, not a product. Any hosted model you can call is better at being a model.
  • The value is that the pipeline is small enough to read, which is rare in published training code.
What goes wrong

Common mistakes to avoid

  • Expecting a usable assistant. The result demonstrates the pipeline. It does not compete with a hosted model and is not meant to.
  • Planning to run pretraining locally. Reading the code needs a laptop. Training needs rented GPUs.
  • Treating the cost figure as fixed. It is a function of GPU pricing on the day, and it moves.
  • Skipping to the fine-tuning stage. The stages that explain the most are the tokenizer and the data handling, and they are the ones people skim.
  • Reading it as a production reference. It is deliberately minimal. Things you need in production, such as evaluation harnesses and observability, are correctly absent.

Frequently Asked Questions

Find answers to common questions about the topics covered in this article.

Still have questions?

Get in touch with our team for personalized assistance.

Contact Us

Still have a question this did not answer?

The person who wrote this article answers these. Describe your setup and what you are stuck on — you will get a straight answer, including where we think the approach is wrong.