Andrej Karpathy recently dropped a 3-hour masterclass on how ChatGPT really works. It's one of the best lectures I've seen on LLMs. Here are my key takeaways π§΅
1/ The Training Pipeline LLMs are built through a multi-stage process, with two major stages: 1. Pre-training (learning from internet data) 2. Post-training (learning from human examples)
2/ Pre-training (Building a Base Model) Step 1: Data Collection β The first step in training an LLM is downloading and processing the internet. β companies like OpenAI, Google, and Anthropic gather massive amounts of publicly available text from sources like Wikipedia, Common
3/ Step 2: Tokenization LLMs donβt process raw text directly. Instead, they convert raw texts into a sequence of tokens It uses byte-pair encoding to create efficient token representations
4/ Step 3: Training the Neural Network The model is then trained using next-word prediction: it takes a sequence of tokens as input and predicts the most likely next token. Training involves: β Random initialization - gradually improving predictions by adjusting weights. β
5/ Step 4: Inference Once trained, the model can generate text by predicting tokens step by step Text Generation Process β Autoregressive Prediction: The model generates text one token at a time. β Probability-Based Sampling: Multiple valid outputs exist, so responses may
6/ Post-training After pre-training, the model is still just an "Internet text generator." It can generate plausible-sounding text, but itβs not yet an 'assistant.' To make it useful, it goes through post-training
7/ Post-training techniques: β Supervised fine-tuning: Human labelers provide curated examples of high-quality responses. β Reinforcement Learning with Human Feedback (RLHF): Models are fine-tuned using human preferences to align responses with user expectations. β Safety
8/ Limitations of LLMs: β Hallucinations β They make up plausible-sounding but false information. β Context Limits β GPT models can βrememberβ only a certain number of tokens at once. β Biases β If training data has biases, the model will reflect them. β Lack of True
9/ How to get better responses from LLMs β Be specific β Vague questions lead to vague answers. β Use role-playing β βAct as an AI expert and explain X.β β Provide examples β Show the structure you want. β Break down complex queries β Step-by-step instructions work best. β
10/ What's next for LLMs β Longer memory β Some models can process 100K+ tokens at once. β Cheaper, faster models β Smaller, more efficient LLMs are emerging. β Multimodal AI β LLMs that understand text, images, and video. β Better safety & alignment β Reducing bias & halluci
11/ If youβre curious to learn more, I highly recommend watching the full video. @karpathy does an excellent job breaking down how LLMs like ChatGPT works
12/ Want a visual summary? Karpathy shared the exact file he created. 1. Download this file: 2. Visit Excalidraw .com 3. Import the file & explore the full lecture visually!
That's a wrap β¨ Hope you enjoyed it If you found this thread valuable: 1. Follow @0xmetaschool for more 2. Retweet the first tweet so more people can see it




