Build with AI

How do you build your own language model, and which path fits your goal and budget?

Published · By Robert Scales, with AI tools · 5 min read

Short answer

Building your own model can mean anything from a free laptop exercise to a run costing hundreds of thousands of dollars, so choose by goal. To learn, train from scratch with nanochat; to get something useful for a task, fine-tune an open-weight model; pretrain a serious model only if you need control over its data, its language or its licence.

"My own language model" is a phrase that hides very different projects. A student watching a toy learn spelling, a company teaching an open model its ticket format, and a university training a multilingual model on a national supercomputer are all building their own model. They differ by a factor of about a million in cost.

This page is the map for this series. It shows the levels, the stages every from-scratch model goes through, and the tools for each. A language model, or LLM (large language model), is a program that predicts the next piece of text. Pretraining teaches it that skill from raw text, starting from random numbers. Fine-tuning continues training on an existing model, usually with examples of the behavior you want.

The six levels

Dollar amounts are US dollars. The rented figures use prices read on November 2, 2026; the cost article shows the arithmetic.

LevelWhat you doExampleMachineAboutYou end up with
1Train a character-level toynanoGPT's ShakespeareLaptop$0Shakespeare-shaped nonsense and real intuition
2Run the whole pipeline, tinynanochat runs/runcpu.shFast laptop, about 40 min$0A weak chat model that may know the capital of France
3Fine-tune an open modelLoRA or QLoRA adapterFree notebook or gaming GPU$0 to $20A model useful for one narrow task
4Pretrain to GPT-2 gradenanochat runs/speedrun.sh8 H100 GPUs, about 2 h$64A chat model that writes fluently and invents freely
5Pretrain a capable small modelSmolLM3 (3 billion parameters)384 H100 GPUs, 24 days$880,000 at list priceA competitive open model
6Train at the frontierNational or lab-scale runsThousands of GPUsMillions and upA leading model, plus a research team to feed

Level 3 sits below level 4 on purpose: fine-tuning is cheaper and gives more practical results, while levels 1, 2 and 4 teach how models work. Most people should do level 1 or 2 for understanding and level 3 for use. Levels 1 and 3 already have step-by-step guides here: a tiny model from scratch and fine-tuning a small model.

The stages of a from-scratch model

The nanochat project by the researcher Andrej Karpathy is a useful reference because one short script runs all of these, in order:

  1. Collect and clean text. The speedrun needs about 150 files holding some 250 million characters each. See how to prepare a dataset.
  2. Train a tokenizer, the piece that cuts text into numbered tokens. See how to build one.
  3. Pretrain the model on those tokens. This stage uses most of the money.
  4. Fine-tune for chat, so that it answers instead of merely continuing your sentence.
  5. Evaluate it against numbers that mean something. See how to test your model.
  6. Publish, if you wish, with a licence that matches what you trained on. See publishing and licensing.

The rented-GPU walkthrough goes through stages 1 to 5 with commands.

Which tool does what

ToolUse it forWhy
PyTorchEverything underneathThe library most of these projects are written in
nanochatLearning the full pipeline, levels 2 and 4Readable code, one size setting (--depth), MIT licence
Hugging Face datasets, tokenizers, HubData, tokenizers, sharingCommon formats that other tools understand
Hugging Face TRL and PEFTFine-tuning from PythonDirect control, covered in our LoRA guide
UnslothFine-tuning on one modest GPULower memory needs, free notebooks, desktop app
AxolotlRepeatable fine-tuning, more GPUsA YAML file describes the run, and scales to several GPUs

With Axolotl, a first run is two commands, assuming it is installed. The file names the model, the data and the method:

axolotl fetch examples
axolotl train examples/llama-3/lora-1b.yml

A worked plan

Say you work for a Quebec organization and want an assistant that sorts French-language requests into your categories. A sensible order:

  1. Spend an afternoon on level 1 so that loss, tokens and overfitting stop being abstract.
  2. Write 300 French examples of the sorting task and test a plain prompt on them. That score is your baseline.
  3. If the prompt falls short, fine-tune a small open model that handles French (level 3), and compare on the same examples.
  4. Skip levels 4 and 5. A GPT-2-grade model trained for $64 will not sort your requests reliably, and $880,000 buys nothing that the fine-tune needs.

Try it: Write down in one sentence why you want your own model, then find your level in the table. If your sentence contains "understand", start at level 1. If it contains a task from your job, start at level 3 with 20 examples.

Where should you stop climbing?

Stop at the first level that delivers your goal, and be honest about which goal it is. If you wanted to understand models, you are done when you can explain why your loss curve flattened. Level 2 can get you there for free, and level 4 adds the experience of paying for compute and seeing a chat model appear from nothing.

If you wanted a tool, stop as soon as a measured test says it beats the prompt-only baseline. Going further costs more without necessarily helping. Many tasks never need more than a prompt, as the guide to choosing between prompts, documents and fine-tuning explains.

Levels 5 and 6 are a different kind of decision, closer to funding a research project than to a weekend build. They make sense when control is the point: a dataset whose licences you can defend, a language the big models serve badly, or a country that wants its own. The comparison with fine-tuning and RAG walks through those cases, and the cost breakdown helps you check whether your budget matches.

Sources

  1. nanochat README, speedrun script, CPU script and leaderboard notes — Andrej Karpathy (GitHub)
  2. SmolLM3: smol, multilingual, long-context reasoner — Hugging Face, July 8, 2025
  3. Quickstart — Axolotl, November 2, 2026

From the Guide to Artificial Intelligence, by Robert Scales, published by Holistic Hybrid Inc. Share and adapt it under CC BY-NC-SA 4.0: credit the guide, link to https://guidetoartificialintelligence.com/en/learn/build-own-llm-roadmap/, no commercial use without permission, and keep the same licence.

Get the free Guide to Artificial Intelligence

Sign up for the newsletter and receive the free guide: what changed in AI, one lesson, one prompt to try. Unsubscribe in one click.

How we handle your address

Back to top

Display

Your choices are saved in this browser only. No data is sent.

Text size
100%
Colours
Reading
More settings
Accessibility statement

Get the app

Add the guide to your home screen. It opens like an app, and the pages you have read stay available offline.

Read without a connection: download the articles

iPhone and iPad (Safari, Chrome, Edge)

  1. Tap the Share button (the square with an arrow). In Chrome and Edge, it is in the address bar or the menu.
  2. Choose “Add to Home Screen”.
  3. Tap “Add”.

Android (Chrome, Edge, Samsung Internet, Firefox)

  1. Open the browser menu (⋮ or ☰).
  2. Choose “Install app” or “Add to Home screen”.
  3. Confirm with “Install”.

Computer (Chrome, Edge)

  1. Click the install icon at the right end of the address bar, or open the browser menu (⋮ or …).
  2. In Chrome, choose “Cast, save and share”, then “Install page as app”. In Edge, choose “Apps”, then “Install this site as an app”.
  3. Click “Install”.

Mac (Safari)

  1. Open the File menu.
  2. Choose “Add to Dock”.
  3. Click “Add”.

Firefox on a computer can’t install a site as an app. Use Chrome, Edge or Safari instead.