HackerTube
HomeLongsLikedHistoryWatch laterCategoriesPlaylistsSettings

Let's build GPT: from scratch, in code, spelled out.

Andrej Karpathy14 HN recommenders · recommended in 8 months, 2023-2025
YouTube
8.2M views · 3 years ago · tutorial · evergreen

Andrej Karpathy builds a GPT from scratch in code, following Attention Is All You Need and GPT-2/3, in about two hours using PyTorch. He connects it to ChatGPT and assumes familiarity with his earlier makemore videos.

It is the go-to recommendation for learning how transformers and LLMs actually work, praised for its clarity and Karpathy's teaching.

LLMs & generative AIMachine learning & deep learning#gpt#transformer#pytorch#nanogpt#attention#fromscratch

20 comments from Hacker News

@zerd2025 · in “SmolGPT: A minimal PyTorch implementation for training a small LLM from scratch”

The one you linked to is based on Karpathy's tutorial: ▶ this video , except changing to train on tinystories in stead of Shakespeare. smolGPT also looks inspired by nanoGPT, also from Karpathy: link

CitesView on HN
@yreg2024 · in “A ChatGPT clone, in 3000 bytes of C, backed by GPT-2 (2023)”

Attention is all you need and GPT-2 were well known at that point. Many might doubt whether this approach leads to "general" intelligence – depends on the definition. BTW, Karpathy has a nice video tutorial about building an LLM: ▶ this video

RecommendsView on HN
@atum472024 · in “Building LLMs from the Ground Up: A 3-Hour Coding Workshop”

Excuse my ignorance, is this different from Andrej Karpathy ▶ this video Anyway I will watch it tonight before bed. Thank you for sharing.

CitesView on HN
@jiggawatts2024 · in “AI's $600B Question”

That's... my point. You're agreeing with me. Siri and Alexa are bad . Very, very bad. They pretend to understand spoken English, but they don't , because they're just a huge set of hard-coded rules written out one-at-a-time by enormous numbers of very expensive developers. This is the 1990s approach to AI: Fuzzy logic, heuristics, solvers, dynamic programming, etc... That approach has been thoroughly blown out of the water by Transformers, which does all of that and much more with a thousand lines of code that can be banged out in a couple of hours by one guy while talking in a YouTube video: ▶ this video Transformers will revolutionise this entire space, and more that don't even exist yet as a market. Take for example humanoid robots: Boston Dynamics has had the hardware working well enough for a decade, but not the software . You can't walk up to one of their robots, point at something, and tell the robot to complete a task. It can't understand what it is seeing, and can't understand English instructions. Programming that in with traditional AI methods would take man-millenia of effort, and might never work well enough . If we could speed up GPT-4o (the one with vision) to just 10x or 50x its current speed, with some light fine-tuning it could control a humanoid robot right now with a level of understanding comparable to C3P0 from Star Wars!

CitesView on HN
@villedespommes2024 · in “Implementing a ChatGPT-like LLM from scratch, step by step”

+1, Andrey is an amazing educator! I'd also recommend his ▶ this video and checking out his github repos. MinGPT, for example, implements a small gpt model that's compatible with HF API, whereas more modern nanoGPT shows how to use newer features such as flash attention. The quality of every video, every blog post is just so high.

Strongly recommendsView on HN
@solomatov2024 · in “Ask HN: Is it feasible to train my own LLM?”

Yes, it's doable. Your model won't be as large and as performant as a real large scale model, but you could train something. You could watch this for a start: ▶ this video

RecommendsView on HN
@samspenc2023 · in “Andrej Karpathy: Intro to Large Language Models [Video]”

I initially thought this was his older video, but I see this video was published just an hour ago (from the time of this comment). I was thinking of this other video he had published early this year: "Let's build GPT: from scratch, in code, spelled out" ▶ this video Karpathy is generally well-reputed as a good tutor, especially for complex topics in AI / ML.

RecommendsView on HN
@petemir2023 · in “Attention is Turing complete [pdf]”

There was this comment a couple of weeks ago ( link ). Perhaps also episode 7 of Karpathy’s “Neural Networks: From Zero to Hero” course ( ▶ this video )

CitesView on HN
@FranklinMaillot2023 · in “Ask HN: Can someone ELI5 Transformers and the “Attention is all we need” paper”

Those Computerphile videos[0] by Rob Miles helped me understand transformers. He specifically references the "Attention is all you need" paper. And for a deeper dive, Andrej Kharpaty has this hands-on video[1] where he builds a transformer from scratch. You can check-out his other videos on NLP as well they are all excellent. [0] link , link [1] ▶ this video

RecommendsView on HN
@Alpi2023 · in “Introducing "Implement DNS in a Weekend"”

I love all the series about writing your own X in 100 lines of code. It gives you the understanding of technology and removes a lot of unnecessary details. The great examples of this are 'A from-scratch tour of Bitcoin in Python' link and 'Let's build GPT: from scratch, in code, spelled out' ▶ this video from Andrej Karpathy I wonder if anybody tried to collect all such projects together and built his own 'Internet in just 100 lines of code'

RecommendsView on HN
@wesammikhail2023 · in “Google DeepMind CEO Says Some Form of AGI Possible in a Few Years”

Andrej Karpathy, the director of AI at tesla, published an AMAZING video about how the current models are built which I think everyone in the tech space should watch. It is intuitive, easy to follow and quite frankly the best video I have seen on the topic. Here is the link: ▶ this video If you conclude, after watching this, that this is all intelligence is - namely cascading optimization and data structure problems chained in a row, then you and a fair number of people here wont ever find common ground. That is not to say that you're wrong, it just seems as if there is a missing component here that we haven't yet discovered.

Strongly recommendsView on HN
@erwincoumans2023 · in “Transformers from Scratch”

Andrej Karpathy's 2 hour video and code is really good to understand the details of Transformers: "Let's build GPT: from scratch, in code, spelled out." ▶ this video

RecommendsView on HN
@Izkata2023 · in “A Completely Non-Technical Explanation of Deep Learning”

2-hour video posted a month or two ago in a comment here: "Let's build GPT: from scratch, in code, spelled out." ▶ this video (I haven't gotten around to watching it yet)

CitesView on HN
@pankajdoharey2023 · in “What Are Transformer Models and How Do They Work?”

I agree that Karpathy's YouTube video is an excellent resource for understanding Transformers from scratch. It provides a hands-on experience that can be particularly helpful for those who want to implement the models themselves. Here's the link to the video titled "Let's build GPT: from scratch, in code, spelled out": ▶ this video Additionally, for more comprehensive resources on Transformers, you may find these resources useful: * The Illustrated Transformer by Jay Alammar: link * MIT 6.S191: Recurrent Neural Networks, Transformers, and Attention: link * Karpathy's course, Deep Learning and Generative Models (Lecture 6 covers Transformers): link ... These resources cover different aspects of Transformers and can help you grasp the underlying concepts and mechanisms better.

RecommendsView on HN
@bfg_damien2023 · in “Ask HN: How to Learn LLM Fundamentals”

Here are a few resources that might help get you started: 1. A thread explaining the internal working of transformers: link 2. Paper by DeepMind which provides pseudo-code for important algorithms for Transformer models: link 3. Another thread specifically on large language models: link Once again these are not courses per se, but do provide intuitive explanations for how transformers work. There is also the nanoGPT series of videos by Karpathy on youtube. First video here: ▶ this video

RecommendsView on HN
@qazpot2023 · in “Flow-Based Programming, a way for AI and humans to develop together”

I think you are taking a very major assumption that LLMs are deterministic infact they are exactly opposite. They are probabilistic systems. - They do not transpile Rough English to Deterministic English. Infact they do not do any transpiling at all. - LLMs learn the probabilities of words in the dataset for all contexts from that dataset (context is a ordered set of words). This is called training. - Once training is done, LLMs can generate text given a prompt and the probabilities that it has learned. The analogy of LLMs being auto-complete on steroids is very apt. - Whether the text generated by LLMs is factual or not is purely coincidental. I would highly recommend watching and working though the code (if possible) of NanoGPT by Andrej Karpathy. ▶ this video A lot of things which seem like magic about LLMs will get demystified. Now one can argue that LLMs are showing human like reasoning/intelligence/sentience as an emergent behavior. This is hard to argue against because all these terms are extremely hard to define. IMO, the only emergent behavior that LLMs are showing is the output they generate looks like it might have been generated by a human which should not be surprising given that LLMs like ChatGPT has trained on a large amount of human written text available on internet.

RecommendsView on HN
@durdn2023 · in “GPT in 60 Lines of NumPy”

Very impressive. Recently I watched this really amazing lecture on building GPT from scratch from Karpathy, I was blown away: ▶ this video

Strongly recommendsView on HN
@sebastianconcpt2023 · in “Training NanoGPT on My Journal”

I remember Andrej mentioning in [1] that is a challenging part, what materials/lectures/papers have you found or what ideas on what to do about that so far for that? [1] ▶ this video

CitesView on HN
@yonz2023 · in “The Transformer Family”

Great compilation, would be great to see Vision Transformer (ViT) included. Andrej Karpathy's GPT video is a must have companion for this ▶ this video I was going nuts trying to grok Key, Query,Position and Value until Andrej broke it down for me.

Strongly recommendsView on HN
@amrb2023 · in “Deep Learning Tuning Playbook”

I recommend this video on the subject. "Let's build GPT: from scratch, in code, spelled out." ▶ this video

RecommendsView on HN
Deep Dive into LLMs like ChatGPT3:31:24

Deep Dive into LLMs like ChatGPT

Andrej Karpathy
10.2M views • 1 year ago
Transformers, the tech behind LLMs | Deep Learning Chapter 527:14

Transformers, the tech behind LLMs | Deep Learning Chapter 5

3Blue1Brown
11.6M views • 2 years ago
The spelled-out intro to language modeling: building makemore1:57:45

The spelled-out intro to language modeling: building makemore

Andrej Karpathy
1.3M views • 4 years ago
Large Language Models from scratch8:25

Large Language Models from scratch

Graphics in 5 Minutes
375K views • 4 years ago
Let's build the GPT Tokenizer2:13:35

Let's build the GPT Tokenizer

Andrej Karpathy
1.3M views • 2 years ago
State of GPT | BRK216HFS42:40

State of GPT | BRK216HFS

Microsoft Developer
785K views • 3 years ago
[1hr Talk] Intro to Large Language Models59:48

[1hr Talk] Intro to Large Language Models

Andrej Karpathy
4.3M views • 2 years ago
LSTM is dead. Long Live Transformers!28:48

LSTM is dead. Long Live Transformers!

Seattle Applied Deep Learning
540K views • 6 years ago
A Hackers' Guide to Language Models1:31:13

A Hackers' Guide to Language Models

Jeremy Howard
580K views • 3 years ago
AI Language Models & Transformers - Computerphile20:39

AI Language Models & Transformers - Computerphile

Computerphile
354K views • 7 years ago
The Inside Story of ChatGPT’s Astonishing Potential | Greg Brockman | TED30:10

The Inside Story of ChatGPT’s Astonishing Potential | Greg Brockman | TED

TED
1.9M views • 3 years ago
GPT3: An Even Bigger Language Model - Computerphile25:57

GPT3: An Even Bigger Language Model - Computerphile

Computerphile
446K views • 6 years ago
Sparks of AGI: early experiments with GPT-448:32

Sparks of AGI: early experiments with GPT-4

Sebastien Bubeck
1.8M views • 3 years ago
The spelled-out intro to neural networks and backpropagation: building micrograd2:25:52

The spelled-out intro to neural networks and backpropagation: building micrograd

Andrej Karpathy
4.4M views • 4 years ago
Attention Is All You Need27:07

Attention Is All You Need

Yannic Kilcher
814K views • 8 years ago
CS480/680 Lecture 19: Attention and Transformer Networks1:22:38

CS480/680 Lecture 19: Attention and Transformer Networks

Pascal Poupart
374K views • 7 years ago
GitHub Copilot CRUSHES Leetcode Interview Questions! 😳9:20

GitHub Copilot CRUSHES Leetcode Interview Questions! 😳

DevOps Directive
266K views • 5 years ago
Attention in transformers, step-by-step | Deep Learning Chapter 626:10

Attention in transformers, step-by-step | Deep Learning Chapter 6

3Blue1Brown
4.8M views • 2 years ago
OpenAI Codex Live Demo29:43

OpenAI Codex Live Demo

OpenAI
913K views • 5 years ago
Building the Software 2 0 Stack (Andrej Karpathy)17:55

Building the Software 2 0 Stack (Andrej Karpathy)

Databricks
73K views • 8 years ago