🚨BREAKING: This github has entire blueprint for building ChatGPT from scratch and put it on GitHub for free.
It's called LLMs-from-scratch and it walks you through building a GPT model in PyTorch line by line.
No black boxes. No hand-waving. Every single piece of the architecture explained and coded.
Here's why this changes everything for AI builders: ↓
Most people using ChatGPT every day have zero idea how it actually works under the hood.
Attention mechanisms. Tokenization. Pretraining. Finetuning. RLHF.
They're all magic words until you build one yourself.
This repo fixes that.
What you'll build, chapter by chapter:
→ Ch 2: Working with text data + BPE tokenizer from scratch
→ Ch 3: Coding multi-head attention from zero
→ Ch 4: Full GPT model implementation in PyTorch
→ Ch 5: Pretraining on unlabeled data
→ Ch 6: Finetuning for text classification
→ Ch 7: Instruction finetuning (how ChatGPT-style behavior actually works)
The bonus material alone is worth it:
→ Llama 3.2 from scratch
→ Qwen3 (Dense + MoE) from scratch
→ Gemma 3 from scratch
→ KV Cache implementation
→ Grouped-Query Attention
→ Mixture-of-Experts (MoE)
→ Direct Preference Optimization (DPO) from scratch
→ RLHF with GRPO from scratch
This isn't a beginner tutorial. It's a full AI engineering curriculum.
Prerequisites are minimal:
→ Solid Python skills
→ Basic PyTorch familiarity (Appendix A covers this if you're new)
→ Runs on a regular laptop, no GPU required
A 17-hour companion video course also exists where the author codes through every single chapter live.
Why this matters more than ever:
Every AI engineer talks about transformers, attention, and pretraining.
Maybe 1% have actually built any of it.
The engineers who understand what's happening inside the model are the ones building the next generation of AI products.
Everyone else is just using wrappers.
85.2K stars. 12.9K forks.
One of the most saved AI repos on GitHub.
100% Opensource.
github.com/rasbt/LLMs-fro…
As always, Thank you for reading this.
If you enjoyed this post:
1. Follow me @hasantoxr for more of these
2. RT the tweet below to share this thread with your audience
Share this Scrolly Tale with your friends.
A Scrolly Tale is a new way to read Twitter threads with a more visually immersive experience.
Discover more beautiful Scrolly Tales like this.
