hacker tutorialscourse catalogue

Courses / Course 03 · Ml

Build a neural network, then a GPT

You end up withAn autograd engine you wrote, a GPT you trained from scratch with a tokenizer you wrote, and a from-scratch inference loop for a modern open-weights architecture. Enough to read a model's source and know what every line does.

  • 30 sources
  • 290 HN threads
  • 26,668 points
  • 2013–2026
  • 4–6 months part-time

Data pulled 2026-11-08 · time estimates are editorial

Why build one when you already talk to one every day? Because the agent that writes your code is one of these. After this track, “context window”, “temperature”, “tokens” and “fine-tuning” are things you’ve implemented, not words you’ve heard. Hacker News has voted these tutorials up since 2013, and more than half the stories in this track’s pool are from 2023 or later. Every step below shows its HN score and quotes what HN said.

What this track won’t do for you, in HN’s words:

HN libraryofbabel, 2025 · comment

“Although in retrospect knowing how a transformer works wasn’t very useful at all in my day job applying LLMs, except as a sort of deep background for reassurance that I had some idea of how the big black box producing the tokens was put together, and to give me the mathematical basis for things like context size limitations etc.”

You’ll understand the machine. That isn’t the same as predicting what a frontier model will do.

How to read the receipts.

  • Points are summed across every HN submission of the same URL. For multi-part works on one site (Nielsen’s book, Giles Thomas’s series), that includes parts submitted on their own.
  • “Submitted N×” means HN rediscovered it N times.
  • Quotes come from the highest-ranked top-level comments in those threads, and a quote is sometimes a criticism. Quotes keep the commenter’s spelling.
  • Steps are ordered for learning, not by points.
  • Times are our estimates, not the authors’. They assume evenings and weekends, and a reader who programs comfortably in Python.
  • Hardware. Stages 1–3 run on a laptop. Stages 4–5 are much faster with a GPU; each step says what it needs.

Optional on-ramp: Neural networks (3blue1brown.com) · 3Blue1Brown (Grant Sanderson)

825 points, submitted 18× (2017–2025) · Free · video · ~2 evenings

The visual intuition for what a network, a gradient and backpropagation are, before you write any code. The series has since grown chapters on transformers and attention.

HN kharms, 2017 · thread

“In my opinion this author produces the best math videos on youtube.”

Stage 11 eveningA neural network by hand

1.

An Introduction to Neural Networks (victorzhou.com) · Victor Zhou

628 points, submitted 8× (2019–2021) · Free · Python + NumPy · ~1 evening

A two-layer network with the gradients worked out by hand and trained with plain stochastic gradient descent. It’s small enough to finish in one sitting, and it makes Stage 2 less abstract.

HN amasad, 2019 · thread

“I see so many implementations of NeuralNets from Scratch on Repl.it (I’m a co-founder) but this is one of the simplest and clearest one.”

HN’s caveat (about the field as much as the post): “Why are deep learning researchers allergic to meaningful variable names?” (gambler, 2019 · comment)

Stage 26–10 weeksNeural Networks: Zero to Hero

The core of the track: Andrej Karpathy’s video series, where you write every piece yourself, in order. https://karpathy.ai/zero-to-hero.html · 1,450 points for the series page, submitted 7× (2023–2026) · Free · Python, then PyTorch

HN cube2222, 2026, who had tried “books, coursera courses (yeah, that one), a university class, the fastai course” first · thread

“This series of videos was by far the best, most “intuition building”, highest signal-to-noise ratio, and least “annoying” content to get through.”

HN lukebechtel, 2023 · thread

“I have taken several masters-level courses in Machine Learning — and even with those credentials, I cannot recommend enough Andrej’s youtube series, “Neural Networks: Zero to Hero”.”

A note on the receipts: HN voted for the series as a whole and for the GPT video. The early episodes scored little on their own: micrograd 171 points, makemore 50. The step order below is the series order, not HN’s.

2.

Building micrograd (youtube.com)

171 points, submitted 8× · ~1 week

You write a scalar autograd engine and a tiny neural-net library on top of it: backpropagation from first principles, in about 150 lines.

HN 7373737373, 2023 · comment

“This was the first time I actually grokked backpropagation, just the first video alone is more lucid and valuable than any other resource about machine learning I had seen before…”

3.

makemore (five videos) (github.com)

50 points, submitted 10× · ~3–4 weeks

A character-level language model, rebuilt five times: bigram counts, an MLP, activations and batch norm, “Backprop Ninja” (you derive every gradient by hand and check it against PyTorch), and a WaveNet-style model.

HN Buttons840, 2023 · comment

“The “Backprop Ninja” video was hard work, you manually calculate the gradients and then compare your calculations against PyTorch.”

4.

Let’s build GPT: from scratch, in code, spelled out (youtube.com)

1,112 points, submitted 2× (2023–2024) · ~1–2 weeks

Self-attention, multi-head attention, residual connections and layer norm, building a decoder-only transformer trained on Shakespeare.

HN diego898, 2023 · thread

“Andrej’s entire series is by far one of the most useful resources I’ve found. Even as an instructor of these topics myself I learn something new about the material and about how to teach it!”

5.

Let’s build the GPT Tokenizer (youtube.com)

722 points, submitted 3× (2024–2025) · ~1 week

You write byte-pair encoding (the minbpe repo) and learn why tokenization explains so many odd LLM behaviours, from spelling to arithmetic.

HN mrtksn, 2024 · thread

“No metaphors trying explain “complex” ideas, making them scary and seem overly complex. Instead, hands on implementations with analogy explainers where you can actually understand the ideas and see how simple it is.”

Alternatives HN votes for:

  • Practical Deep Learning for Coders · fast.ai (Jeremy Howard) · https://course.fast.ai/ · 2,640 points, submitted 28× (2016–2024) · Free · Python + PyTorch. The opposite order: top-down, using working models first. Part 2 rebuilds Stable Diffusion from the foundations. “I feel I can now read an arbitrary paper, frown a lot, and eventually understand what it’s talking about…” (mattyyeung, 2023 · comment). The caveat: “This is very much a full time university level course… You will need to reserve 10 hours per week for the homework - at least.” (ttul, 2023 · comment)
  • Neural Networks and Deep Learning · Michael Nielsen · http://neuralnetworksanddeeplearning.com/ · 2,217 points across 40 submissions of its chapters (2013–2026) · Free · Python. The book version of Stages 1–2 (pre-transformer). “This is the best neural network tutorial out there.” (billconan, 2015 · thread)

Stage 32–3 weeksSee the transformer from every angle

6.

A GPT in 60 Lines of NumPy (jaykmody.com) · Jay Mody

1,563 points, submitted 1× (2023) · Free · Python + NumPy · ~1 week

GPT-2’s forward pass in plain NumPy, loading OpenAI’s real weights. After step 4 it’s a check: if you can read all 60 lines, you understand the architecture.

HN simonw, 2023 · thread

“This article is an absolutely fantastic introduction to GPT models - I think the clearest I’ve seen anywhere, at least for the first section that talks about generating text and sampling.”

Read alongside (pick one or two, not all):

Stage 46–10 weeksTrain a real one

7.

Build a Large Language Model (From Scratch) (github.com) · Sebastian Raschka

1,217 points, submitted 21× (2023–2026) · Paid book (Manning); code and notebooks free on GitHub · PyTorch · ~4–6 weeks

The book-length version of Stages 2–3 done properly. It covers data loading, attention, a GPT model, pretraining, loading GPT-2 weights, then fine-tuning for classification and for following instructions. The README says the main chapters run on a conventional laptop.

Free companion: Writing an LLM from scratch · Giles Thomas · https://www.gilesthomas.com/llm-from-scratch · 1,741 points across 32 submissions of its parts (2025–2026). It’s one engineer’s long, honest log of working through Raschka’s book, ending with a base model trained from scratch on an RTX 3090. “I hadn’t thought that an RTX 3090 would be capable of generating a sort-of decent small LLM from scratch in a reasonable time, but he shows how in detail.” (RagnarD, 2025 · thread)

8.

nanoGPT (github.com) · Andrej Karpathy

1,657 points, submitted 6× (2023–2025) · Free · PyTorch · ~2–3 weeks

The smallest serious GPT training code: reproduce GPT-2 (124M) on OpenWebText, or fine-tune on your own text. The companion video Let’s reproduce GPT-2 (124M) (https://www.youtube.com/watch?v=l8pRSuU81PU; 9 points, a weak HN signal) builds it from an empty file.

Alternative: minGPT (Karpathy) · https://github.com/karpathy/minGPT · 597 points, submitted 2×. It’s nanoGPT’s older, more educational sibling.

Optional, for systems people: llm.c · Karpathy · https://github.com/karpathy/llm.c · 1,923 points, submitted 8× (2024–2025) · Free · C/CUDA. GPT-2 training in plain C and CUDA, with no PyTorch. “Kind of amazing that something that can be expressed in ~1000 lines of code has completely turned the world on its head.” (osigurdson, 2024 · thread)

Stage 53–5 weeksModern architectures and fast inference

9.

llama3 from scratch (github.com) · naklecha

1,041 points, submitted 1× (2024) · Free · PyTorch (tensor by tensor) · ~1 week

Loads Meta’s real Llama 3 weights and runs them one matrix multiplication at a time: RoPE, grouped-query attention, SwiGLU, RMSNorm. It’s what changed between GPT-2 and a 2024 open-weights model.

HN miki123211, 2024 · thread

“If you like this, it’s also worth looking at llama2.c[1], an implementation of the Llama 2 architecture in about 1000 lines of plain, dependency-free C, tokenizer and all.”

Alternative: Llama from scratch, or how to implement a paper without crying · Brian Kitano · https://blog.briankitano.com/llama-from-scratch/ · 672 points, submitted 2×. It’s as much about method as about Llama. “‘Use .shape religiously. assert and plt.imshow are your friends.’ Thank you.” (bravura, 2023). HN found a bug: “There is a bug : While in SwiGLU beta is a learnable parameter, in the reference paper the feed forward network set beta as a constant” (GistNoesis, 2023 · comment).

10.

Fast LLM Inference From Scratch (andrewkchan.dev) · Andrew Chan

344 points, submitted 1× (2024) · Free · C++/CUDA · ~2–3 weeks · needs an NVIDIA GPU

An inference engine written without libraries, then optimised step by step: why decoding is memory-bandwidth bound, KV caches, and kernel by kernel speed-ups.

Read first (one evening): Making Deep Learning Go Brrrr From First Principles · Horace He · https://horace.io/brrr_intro.html · 368 points, submitted 8× (2022–2026). Compute, memory bandwidth and overhead: the three things that decide how fast a model runs. “This post is a classic!” (ollin, 2026 · thread)

On a Mac instead: tiny-llm · Alex Chi Z · https://github.com/skyzh/tiny-llm · 299 points, submitted 2×. A course in LLM serving on Apple Silicon with MLX.

Optional capstone: Stanford CS336, Language Modeling from Scratch

https://cs336.stanford.edu/ · 571 points, submitted 3× (2025–2026) · Free lectures (YouTube) and public assignments; GPU time costs money · ~3–6 months

Percy Liang and Tatsunori Hashimoto’s course, with minimal scaffolding. You build a tokenizer, a transformer and an optimiser, then write a FlashAttention2 kernel in Triton, fit scaling laws, filter Common Crawl into training data, and do alignment. It’s the whole stack, at research depth.

HN fg137, 2026 · thread

“Despite having a decent foundation in deep learning, it took me several months to finish it using bits of my after-work hours and weekends.”

The theory shelf (read alongside, not in sequence)

Book HN signal Cost Read it during
Understanding Deep Learning · Simon Prince · https://udlbook.github.io/udlbook/ 433 points over 9 submissions Free PDF; print is paid Stages 2–4
Dive into Deep Learning · Zhang, Lipton, Li, Smola · https://d2l.ai/ 1,028 points over 26 submissions Free online; print (Cambridge UP) is paid Stages 2–4
HN martingoodson, 2023, in the Understanding Deep Learning thread · comment

“The field is bifurcating into two different skill sets: ML engineer and ML scientist (or researcher).”

Before you train on real data

A Recipe for Training Neural Networks (karpathy.github.io) · Andrej Karpathy

424 points, submitted 7× (2019–2025) · Free · 30 minutes

How neural-net training fails silently, and the habits that catch it.

HN cs702, 2019 · thread

“This blog post is full of the kind of real-world knowledge and how-to details that are not taught in books and often take endless hours to learn the hard way.”

HN 6gvONxR4sf7o, 2019 · comment

“Just look at your damned data to sanity check it and understand what’s going on.”

Editorial backlog

Checked against HN on 2026-11-08 (candidates_receipts.json), not used:

  • Neural Networks from Scratch in Python (nnfs.io, Kinsley & Kukieła): 6 points over 2 submissions, and a paid book.
  • Stanford CS231n (vision): 458 points over 27 submissions. It’s a computer-vision course, so it’s off this track’s endpoint. It’s a candidate for a future vision track.
  • Deep Learning (Goodfellow, Bengio, Courville; deeplearningbook.org): 80 points over 8 submissions. Famous, but HN’s story signal is weak; it’s probably cited through comments rather than submitted.

Not yet checked: Hugging Face’s courses, Stanford CS224N, Karpathy’s Intro to Large Language Models talk, Sebastian Raschka’s newer Reasoning LLMs from scratch.

Method

  • Candidates came from the 160 ML-tagged stories in the 4,140-story pull, plus an ML topic pull with 32 terms: 286 candidates in all (phase1-stories/data/ml_candidates.json). Bare “transformer”, “tokenizer” and “LLM” were avoided as news noise.
  • YouTube resources were matched by video ID, and GitHub ones by repository path.
  • Two filters removed off-topic stories from the same domains: CS336’s “AI Agent Guidelines” page (503 points) and the separate Dive into Deep Learning Compiler book (142 points).
  • Selection. 33 resources had receipts pulled; 30 are used here, chosen by hand for followability and sequence. Points were then totalled across every submission of each URL.
  • Quotes come from the top five top-level comments of the two best-scoring threads per resource, in HN’s ranked order via the Firebase API. Some quotes are trimmed with ”…”; links go to the full comment or thread. Every ID and quote is checked with phase1-stories/scripts/check_track.py.
  • Costs were checked on 2026-11-08 for the mixed resources: Raschka (the repository README), CS336 (the course page) and Dive into Deep Learning (its site). The others are free web pages, videos or repositories. Time estimates are editorial, not measured.
  • Drift. This is the fastest-moving track. Expect to re-check it every few months, not yearly.
  • Data: tracks/ml/receipts.json (resources used) and candidates_receipts.json (all 33 checked).