Build an LLM from scratch

Why your tiny LLM ≠ ChatGPT

List compute, data, and post-training gaps honestly

45 min8/8 in module

Learning objectives

  • List compute, data, and post-training gaps honestly
  • Write limits that a hiring manager would respect
  • Close Milestone 3 with portfolio polish

Credibility is knowing scale

You built a mini-LLM. It tokenizes text, runs a transformer forward pass, trains on next-token loss, and generates samples. That puts you ahead of engineers who only call APIs — you have felt shape errors, decoding knobs, and val loss curves firsthand.

The worst portfolio move is presenting that checkpoint as "my GPT." The best move is pairing the demo with an honest limits write-up that names exactly what separates your system from ChatGPT-class products. Hiring managers respect builders who know scale; they distrust vague hype.

This lesson closes the language-modeling milestone. Polish the repo, publish samples, and write limits that would survive a senior engineer's follow-up questions.

Callout — limits are not apologies: They are evidence you understand the stack. "My model has ~2M parameters trained on 2MB of text; GPT-4-class systems use orders of magnitude more data, compute, and post-training" is a strength statement.

Gap 1: Compute

Rough orders of magnitude (illustrative, not exact vendor numbers):

Resource Your tiny GPT Frontier chat model
Parameters 1M–20M 100B–1T+ (incl. MoE active params)
Training hardware CPU / 1 GPU, hours–days Thousands of GPUs, weeks–months
Training cost $0–$50 $10M–$100M+ cited for large pretrains
Inference Single-thread generate Batched KV-cache, speculative decoding, global CDN

Your model may train overnight on a laptop. GPT-class pretrain is a datacenter project with custom networking, checkpoint sharding, and failure recovery. You cannot close this gap by tuning hyperparameters — only by scaling budget and infrastructure.

What you did learn: the compute shape of one forward/backward step, memory scaling with block_size², and why serving is a different engineering problem from training.

Gap 2: Data

Your corpus is megabytes — maybe a novel's worth. Frontier pretraining uses trillions of tokens filtered from web-scale crawl, plus books, code, multilingual sources, and deduplication pipelines that are products unto themselves.

Data quality effects:

  • Coverage: Your model knows your corpus vocabulary; it does not know 2024 news, niche APIs, or medical guidelines unless they were in training text.
  • Contamination & bias: Small curated corpora have strong stylistic bias (Shakespeare sounds Shakespearean). Web-scale data has different bias profiles — neither is neutral.
  • Memorization vs generalization: Tiny models memorize; large models still memorize but also generalize patterns across domains.

Honest line for interviews: "I trained on [X tokens from Y source]; frontier models differ primarily in data diversity and cleaning at scale, not in the loss function."

Gap 3: Post-training

Your checkpoint stopped after pretrain (or early instruct mimicry if you experimented). ChatGPT-class assistants add:

  • SFT on millions of instruction examples
  • Preference optimization on human or AI rankers
  • Tool training (search, code execution, function schemas)
  • Safety layers — refusal behavior, moderation classifiers, red-teaming iterations

Post-training does not inject encyclopedic knowledge from nowhere — it steers style, format, and policy on top of the base model. A 5M-parameter base cannot be post-trained into a code copilot that knows every API.

Gap 4: Architecture and product wrapper

Beyond raw LM training:

  • Context length — 128 tokens vs 128k+ with RoPE scaling, sliding attention, etc.
  • Multimodality — vision, audio encoders fused with text
  • System orchestration — agents, memory, retrieval, caching, rate limits
  • Evaluation — MMLU, HumanEval, LMSYS arena; continuous regression suites

Your portfolio demo is python sample.py. Production is vLLM + load balancers + eval gates + incident response when the model drifts.

Writing limits a hiring manager respects

Bad limits bullet: "It is not as smart as GPT."

Good limits bullet: "2.4M-param decoder-only GPT trained on ~1MB tiny Shakespeare; val loss 1.9 vs ~4.4 untrained baseline; generates locally coherent Shakespeare-like phrases but no instruction following, no factual QA, no tool use. No SFT or preference stage — continuation only."

Structure your write-up:

  1. What it does — concrete capabilities with examples.
  2. What it does not do — instruction following, math, long context, multilingual, etc.
  3. Scale table — params, tokens, hardware, training time (your numbers).
  4. What you would do next — realistic roadmap (more data, SFT on 1k pairs, LoRA on open weights), not fantasy "scale to GPT-4."

Tone: confident about learning; precise about boundaries.

Milestone 3 portfolio polish

Before marking the module done, verify the portfolio story:

m3/
  tokenizer/     ← lesson 3.1
  bigram/          ← 3.2
  mlp_lm/          ← 3.3
  attention/       ← 3.4
  mini_llm/        ← 3.5 centerpiece
  sampling/        ← 3.6 ablation
  lifecycle/       ← 3.7 diagram
  LIMITS.md        ← this lesson

README at module root should link each artifact, show one best sample, val loss plot thumbnail, and the limits summary. A reviewer should grok the arc in 3 minutes.

Checklist for polish:

  • All scripts run from documented commands
  • No hardcoded absolute paths
  • Requirements pinned
  • Samples committed with decoding params
  • One screenshot or GIF optional but effective

Callout — interview story in 30 seconds: "I built the full LM stack from BPE through causal transformer training and decoding ablations. Here is a sample and here is exactly how it differs from production ChatGPT in compute, data, and alignment."

Engineering problem (staff framing)

Honest limits: scale, data, post-train, tools, evals. Credibility = knowing what you built vs what remains.

Diagram — Gap map

flowchart TD
  Tiny[Your tiny LM] --> Gap1[Data + params]
  Gap1 --> Gap2[Post-train]
  Gap2 --> Gap3[Tools/RAG/product]
  Gap3 --> Prod[Chat product]

Precise definitions & mental model

Scaling gaps, alignment gaps, system gaps (RAG/tools/moderation).

Tradeoffs — when to use what

Claiming parity vs documenting deltas — only the latter is hireable.

Failure modes (interview + on-call)

Demo cherry-picks; hiding tokenizer/context limits; no failure corpus.

Production & OSS practices

Write LIMITS.md with quantitative deltas (params, tokens trained, eval scores).

Deep dive (FAANG / OSS bar)

Push «tiny-llm-vs-chatgpt-limits» past tutorial depth: write the interface contract (inputs/outputs/invariants), list three measurable metrics, and name two degrade modes if the happy path fails. Add a short threat note: what an attacker or noisy tool result could do, and which layer catches it (schema, policy, HITL, or eval gate).

flowchart LR
  Contract[Interface contract] --> Metrics
  Metrics --> Degrade[Degrade modes]
  Degrade --> Threat[Threat + control]

Micro-project: Honest limits write-up

In m3/LIMITS.md (or m3/limits/WRITEUP.md):

  1. Capabilities — 3 bullets with evidence (loss numbers, sample quotes).
  2. Non-capabilities — 5+ bullets tied to scale (not vague "bad at reasoning").
  3. Comparison table — your model vs ChatGPT-class on: params, train tokens, compute, post-training, context, inference stack.
  4. Roadmap — 3 realistic next steps if you had 10× time vs 10,000× budget.
  5. One paragraph — what you learned that API-only usage would not teach.

Keep it to 400–800 words — dense and specific. Avoid marketing language.

Optional: record a 2-minute Loom walking through sample generation and one limits bullet — strong portfolio addition.

Checklist

  • LIMITS.md with capabilities, non-capabilities, and comparison table
  • Real numbers from your training run (not placeholders)
  • Module README links all milestone artifacts
  • mini_llm samples and sampling ablation referenced
  • Milestone 3 marked portfolio-ready
Project checklist0/3 done

ShipAI delivery model is: