Build an LLMBeginnerLesson 366 min read

Which LLM can you actually build?

There are five honest tiers, separated by three or four orders of magnitude in cost. Pick yours before you write a line of code.

Lesson in motion

In 60 seconds

Which LLM can you actually build?

There are five honest tiers, separated by three or four orders of magnitude in cost. Pick yours before you write a line of code.

1/5
In simple words
You cannot build a jumbo jet in your garage. You can absolutely build a paper plane, then a model glider, then a real drone. Each one teaches you the next.
"Build an LLM" means five completely different projects. People waste months because they picked the wrong tier for their budget, then blamed the code.

Interactive · pick your tier

T1LoRA fine-tune an open model1 GPU, 16–48 GB · hours · $1–100The best value on the ladder. You learn data formatting, training loops, overfitting and evaluation discipline, and the output is a real product you can serve. Most teams should live here.

What each tier actually teaches you

TierYou learnYou do not learn
T0 · Prompt + RAGContext design, retrieval, evaluation, product senseAnything about how the model works inside
T1 · LoRA fine-tuneData formatting, training loops, overfitting, eval disciplinePretraining dynamics, distributed systems
T2 · Full fine-tune / continued pretrainingOptimiser behaviour, memory management, multi-GPU basicsFrontier-scale data engineering
T3 · Pretrain a small modelEverything. Tokenizers, architecture, data, scaling, infrastructureWhat breaks only at 1000+ GPUs
T4 · Frontier pretrainCluster reliability, data at trillions of tokens, months-long runsNothing — this is the deep end
Do this
The honest recommendation for almost everyone: do T3 once at tiny scale, then live at T0 and T1. Train a 10M-parameter model on a small text file for an afternoon. You will understand every later conversation about LLMs for the rest of your career, and it costs the price of a coffee.

The route this track takes

  1. 1

    Modules 37–42 · build one from nothing

    Tokenizer, embeddings, attention, transformer block, a complete tiny GPT, and a training loop that converges. Real code you can run on one GPU or a laptop.
  2. 2

    Modules 43–48 · make it real

    Data pipelines, scaling laws and compute budgets, distributed training, speed, modern architecture, long context.
  3. 3

    Modules 49–52 · make it useful

    Instruction tuning, preference optimisation, reasoning training, and LoRA — the path most people should take.
  4. 4

    Module 53 · ship it

    Evaluation, quantisation, serving, cost per token.

What you need before starting

  • Python and a little PyTorch. If you can write a for-loop and a class, you are fine.
  • Enough linear algebra to be comfortable with "a matrix multiply mixes information". No proofs required.
  • A GPU is helpful, not required, for Modules 37–42. Free notebook GPUs are enough for a tiny model.
  • Patience with silence. Training gives almost no feedback for long stretches. That is normal, and it is why Module 42 is mostly about instrumentation.
Watch out
One thing to settle now: you are not going to beat a frontier model. That is not the goal and it never was. The goal is to understand the machine you are securing, to own a small model that does one job cheaply, and to stop treating the whole thing as magic.

Watch and read more

Let's build GPT: from scratch, in codeAndrej Karpathy · 2 hr · video
The spelled-out intro to neural networksAndrej Karpathy · micrograd · video

Lab

An honest costing of the model you actually want.

~20 min

The problem

Pick a model you would genuinely like to have. Compute, using C ≈ 6ND: parameters, tokens, FLOPs, GPU-hours at 40% MFU, and cost. Then compute inference cost per million tokens at your expected volume. Decide which tier you are really in.
Starter codepython
N, D = 7e9, 15e12
C = 6 * N * D
gpu_hours = C / (400e12 * 0.40) / 3600
print(f"{C:.2e} FLOPs, {gpu_hours:,.0f} GPU-hours, ${gpu_hours*2:,.0f} at $2/hr")
print(f"inference: {2*N/1e9:.1f} GFLOPs per token")

You are done when

Hard questions

Try to answer before you reveal. If you can answer these, you understood the lesson.

Q1Your calculation says training costs $200k and API access costs $8k/year for the same quality. Name three reasons to train anyway.Reveal
Data that cannot leave your infrastructure; latency or throughput a shared API cannot meet; and a domain or language the API models handle poorly, where a small specialised model beats a large general one. A fourth, often decisive: the API's terms, pricing or availability can change under you, and some businesses cannot accept that dependency. If none of these apply, the API is the right answer and the calculation just told you so.

Please sign in to continue.

Questions people ask

Do I need a PhD?

No. The core transformer is about 200 lines of readable code. What separates practitioners is data judgement and evaluation discipline, both of which are learned by doing.

Should I use PyTorch or JAX?

PyTorch, unless you are joining a team that uses JAX. More tutorials, more code to read, more jobs. The concepts transfer completely.

Can I train something useful on one GPU?

A LoRA fine-tune of a 7B model, absolutely — that is a genuinely useful, shippable product on a single 24 GB card. Pretraining from scratch on one GPU tops out around 100M–500M parameters on a small dataset, which is educational rather than useful.

Is it cheaper to fine-tune or to prompt well?

Prompt well first, every time. Fine-tuning is worth it when you need a consistent format, a narrow domain, lower latency, or a smaller model doing a job a big one currently does. It is rarely the fix for "the model does not know my facts" — that is retrieval.

Lesson test

5 questions. Get 3 right (60%) to pass and complete this lesson.

Sign in with your phone number to take the test and save your progress