Speaker Notes

[1hr Talk] Intro to Large Language Models

Large language models function as lossy compressed internet representations governed by predictable scaling laws, and are evolving from fast next-word predictors into tool-using reasoning agents.

Andrej Karpathy · 59:48 · YouTube ↗

Talk · solo speaker  Intermediate · concepts and scaling mechanics

Highlights

7 clips · 8 min of 60 min
    • An open-weights model requires only a parameter file and a small execution script
    • The 70B model uses 140GB for float16 weights
    • A minimal C implementation of about 500 lines can run the model locally
    • Training Llama 2 70B requires processing roughly 10 terabytes of text
    • The process uses around 6000 GPUs for 12 days at an estimated cost of $2 million
    • Parameters function as a lossy compressed zip file of internet data
    • Assistant models are created by swapping pre-training data for curated Q&A pairs
    • Pre-training focuses on text volume and knowledge, while fine-tuning prioritizes quality and formatting
    • Human-created conversation data teaches the model to respond helpfully to user queries
    • Model accuracy is a smooth, predictable function of parameter count and training data size
    • Scaling trends show no signs of topping out with larger compute
    • Algorithmic progress is a bonus, but bigger compute reliably guarantees better results
    • Next-word prediction accuracy is a smooth function of parameter count and training data size.
    • Algorithmic breakthroughs are optional; adding more compute and data reliably guarantees better results.
    • Downstream task evaluations tightly correlate with improvements in raw prediction accuracy.
    • Models dynamically invoke external utilities like web search, calculators, and Python interpreters.
    • Problem-solving shifts from purely internal parameter memory to coordinating software infrastructure.
    • Current LLMs operate entirely on fast, instinctive System 1 next-word chunking without deliberative loops.
    • True System 2 reasoning requires converting elapsed compute time into higher accuracy via search trees.
    • Enabling models to pause, reflect, and deliberate remains an open research frontier.
    • Retrieved web pages can contain hidden instructions that hijack the language model's control flow.
    • LLMs struggle to structurally isolate trusted user prompts from untrusted data fetched from external sources.

Questions this video answers

8 · every answer cites the moment it was said
01 What files make up a deployable large language model? 3 sources · 0:24

An LLM consists of a parameter file containing neural network weights and a run code file to execute them. For instance, Llama 2 70B uses a 140-gigabyte parameter file stored as float16 numbers and about 500 lines of C code. This self-contained package runs locally on hardware like a MacBook without internet connectivity.

02 How do you train a base language model from scratch? 3 sources · 5:00

Training a base model involves compressing roughly 10 terabytes of internet text using a large GPU cluster. For Llama 2 70B, this required around 6,000 GPUs running for 12 days at an estimated cost of $2 million. This process acts as a lossy compression of the internet, capturing a gestalt of the training data rather than an exact copy.

03 When should I use fine-tuning instead of pre-training? 3 sources · 16:12

Fine-tuning swaps the massive, low-quality internet text dataset of pre-training for a smaller, high-quality set of about 100,000 Q&A conversations created via human labeling instructions. While pre-training builds world knowledge, fine-tuning aligns the model to act as a helpful assistant that answers queries directly. This second stage is significantly cheaper, taking days rather than months.

04 How do scaling laws dictate large language model performance? 3 sources · 25:57

Scaling laws show that next-word prediction accuracy is a smooth, predictable function dependent on parameter count and training text volume. Because these trends do not top out, increasing compute and data guarantees better models without requiring algorithmic breakthroughs. This reliability drives massive industry investments in larger GPU clusters and datasets.

05 How do language models utilize tools during complex problem solving? 2 sources · 28:16

Rather than relying solely on internal weights, modern models recognize when to delegate tasks to external software infrastructure. They emit special tokens to invoke tools like web browsers, calculators, and python code interpreters for math and visualization. This integration closely mirrors how humans leverage external computing resources to solve complex problems.

06 What distinguishes System 2 thinking from current LLM capabilities? 2 sources · 36:28

Current language models operate purely on System 1 thinking, which relies on fast, instinctive, next-word generation without deep reasoning. In contrast, System 2 thinking involves slower, conscious problem-solving and exploring trees of possibilities over time to increase accuracy. Researchers are actively working on how to give models this capability to trade compute time for better answers.

07 Why is general self-improvement difficult for language models compared to games like Go? 2 sources · 38:49

While systems like AlphaGo achieved superhuman performance through self-play, applying this to general language models is extremely difficult. Games have clear, fast, and inexpensive reward functions that automatically determine if a move wins or loses. Language tasks are much more open-ended and generally lack a fast, reliable reward criterion to guide automatic self-improvement.

08 How do prompt injection and jailbreak attacks compromise large language models? 2 sources · 45:59

Large language models face security vulnerabilities such as jailbreaks and prompt injection attacks that hijack their behavior. Attackers use roleplay, encoded text, adversarial suffixes, or hidden instructions within retrieved data to bypass safety guardrails. These exploits mirror traditional security challenges, creating a continuous cat-and-mouse game for model developers.

Section-by-section summary

11 parts

Large language models consist of parameters and execution code

An open-weights model like Llama 2 70B is essentially just two files on disk: a parameter file holding float16 weights and a lightweight execution script. This self-contained package allows models to run locally on consumer hardware without internet access.

Training compresses massive internet text using GPU clusters

Obtaining model parameters requires a massive training process that compresses roughly ten terabytes of internet text. Using thousands of specialized GPUs over several days, this lossy compression builds a statistical representation of human knowledge.

Next word prediction drives the acquisition of world knowledge

Neural networks are fundamentally trained to predict the next token in a sequence. This simple objective forces the network to implicitly internalize vast amounts of factual knowledge and semantic structure about the world.

Transformers operate as inscrutable empirical artifacts

Although the mathematical architecture of transformer networks is fully understood, the exact collaboration of billions of parameters remains opaque. Consequently, these models are treated as empirical artifacts whose behavior must be rigorously evaluated.

Fine-tuning transforms raw models into helpful assistants

Base models trained on internet text merely dream documents rather than answering questions. By swapping the training corpus for curated high-quality Q&A pairs, fine-tuning aligns the model to act as a responsive assistant.

Scaling laws drive predictable performance gains

Model accuracy on next word prediction follows smooth scaling laws determined strictly by parameter count and training data size. This predictability fuels massive industry investments because larger compute clusters reliably yield better models.

Models act as orchestrators via tool use

Modern LLMs do not rely solely on internal weights for complex tasks like math or data analysis. Instead, they dynamically emit tokens to invoke external tools such as web browsers, Python interpreters, and image generators.

Multimodality expands input and output modalities

Language models increasingly process and generate multiple data types natively, moving beyond text to handle audio and images. Features like speech-to-speech interfaces and sketching website mockups into working code demonstrate this shift.

System 2 thinking and self-improvement are future frontiers

Current LLMs operate purely via fast System 1 next-word prediction without deliberative reasoning loops. Future research aims to introduce slower System 2 verification trees and reinforcement learning self-improvement analogous to AlphaGo.

LLMs function as operating system kernels

An LLM is best conceptualized not as a simple chatbot, but as an OS kernel managing resources like memory, context windows, and computational tools. This architecture mirrors traditional OS abstractions including process management and virtual memory paging.

Prompt injection and jailbreaks threaten LLM security

New computing paradigms introduce novel attack surfaces like roleplay jailbreaks, universal adversarial suffixes, and indirect prompt injections via untrusted web pages. These vectors allow malicious actors to bypass safety filters or exfiltrate private user data.

0:00 / 59:48
k play/pause · f fullscreen · m mute
n next · p previous clip · t highlights/full
< > slower/faster · / search what was said
  • Llama 23× · first 0:54

    An open weights large language model series released by meta ai.

  • Reinforcement Learning from Human Feedback1× · first 22:10

    An optional third fine-tuning stage using comparison labels to gain performance.

  • Scaling laws1× · first 25:47

    Predictable mathematical relationships governing model performance based on parameters and training data volume.

  • Retrieval augmented generation2× · first 41:32

    A technique where models reference external uploaded files or data chunks to generate contextual responses.