GPT-3 and In-Context Learning
GPT-3 (Generative Pre-trained Transformer 3) is a 175-billion-parameter autoregressive language model released by OpenAI in 2020 that demonstrated a striking new capability called in-context learning: the ability to perform tasks it was never explicitly trained on, simply by reading a few examples in the input prompt. It matters because it shifted how practitioners think about AI — from "train a model per task" to "prompt a single model for any task." The counterintuitive fact: GPT-3's weights are never updated during in-context learning; all the "learning" happens inside a single forward pass through the network.
Before GPT-3, adapting a model to a new task meant fine-tuning — updating millions of weights with labeled data. GPT-3 showed that a large enough model, trained to predict the next word on vast text, implicitly learns how to learn from examples baked into the prompt itself. You hand it a few input-output pairs as plain text, and it figures out the pattern and applies it to a new input — no gradient updates, no retraining, no data pipeline. The "aha moment" is this: the prompt is the program, and the model is the interpreter.
How It Works
Autoregressive Language Modeling
GPT-3 is trained on one objective: predict the next token given all previous tokens. During pretraining on hundreds of billions of tokens of internet text, the model learns an enormous compressed representation of language, facts, reasoning patterns, and task formats.
Explanation: The model assigns a probability to every possible next token, conditioned on the entire sequence of tokens that came before it.
- token_t — the token we are predicting at position t
- token₁ … token_{t-1} — all preceding tokens in the context window
- P(·|·) — a conditional probability distribution produced by the softmax output layer
The Prompt as a Conditional Distribution
When you prepend examples to a query, you are simply concatenating them into the context. The model then predicts the next token of your query as if continuing a document it has seen many times in analogous form.
Explanation: The probability of the correct answer increases when relevant examples are present in the context, because the model has seen this prompt-completion pattern structure repeatedly during pretraining.
- example₁ … example_k — the k few-shot demonstrations in the prompt
- query — the new input you want the model to answer
- answer — the token sequence the model generates greedily or by sampling
In-Context Learning Regimes
GPT-3 introduced three distinct prompting regimes:
| Regime | Examples in Prompt | Weight Update? |
|---|---|---|
| Zero-shot | 0 | No |
| One-shot | 1 | No |
| Few-shot | 2–100+ | No |
Here is a minimal Python snippet showing how these look in practice using the OpenAI API pattern: ```python import openai
# Zero-shot: just describe the task zero_shot_prompt = "Translate English to French.\nEnglish: cheese\nFrench:"
# Few-shot: show examples before the query few_shot_prompt = """Translate English to French. English: sea French: mer English: sky French: ciel English: cheese French:""" response = openai.chat.completions.create( model="gpt-3.5-turbo", messages=[{"role": "user", "content": few_shot_prompt}], max_tokens=5, temperature=0.0, ) print(response.choices[0].message.content) # → fromage ```
Scaling Laws and Emergence
GPT-3's in-context learning ability is closely tied to model scale. Researchers found a clean power-law relationship between model size, training compute, and loss:
Explanation: As the number of model parameters N grows, the test loss L follows a predictable power-law decrease — larger models reliably get better, all else equal.
- L(N) — cross-entropy loss at parameter count N
- N_c — a fitted constant representing a critical scale
- αN — the scaling exponent (empirically ~0.076 for parameters alone)
- This is the Chinchilla / Kaplan scaling law family
The crucial implication: certain capabilities, including reliable few-shot arithmetic and multi-step reasoning, appear discontinuously above a threshold size. Below ~7B parameters, few-shot performance on many benchmarks is near random; above it, performance jumps. This is called emergent behavior. ```python import numpy as np import matplotlib matplotlib.use("Agg") import matplotlib.pyplot as plt
# Simulate a scaling curve params = np.logspace(8, 11, 100) # 100M to 100B parameters alpha = 0.076 Nc = 1e13 loss = (Nc / params) ** alpha plt.figure(figsize=(6, 3)) plt.loglog(params, loss) plt.xlabel("Parameters (N)") plt.ylabel("Loss L(N)") plt.title("Scaling Law: Loss vs. Model Size") plt.tight_layout() plt.savefig("scaling_law.png", dpi=120) ```
Tom Brown was a research scientist at OpenAI who led the team that designed and trained GPT-3, co-authoring the landmark 2020 paper "Language Models are Few-Shot Learners" with over 30 collaborators. His central contribution was framing the in-context learning evaluation methodology — defining zero-shot, one-shot, and few-shot precisely and systematically benchmarking all three across dozens of NLP tasks. Surprisingly, Brown has noted in interviews that the team was genuinely uncertain whether 175B parameters would produce qualitatively different behavior, or just a quantitatively better version of GPT-2.
Alec Radford at OpenAI developed GPT-1 and GPT-2, establishing the pretrain-then-adapt paradigm that GPT-3 scaled dramatically. His 2019 GPT-2 paper "Language Models are Unsupervised Multitask Learners" was the conceptual seed of in-context learning: it showed that a language model trained only on next-token prediction implicitly learned to translate, summarize, and answer questions. Radford later became a key contributor to CLIP and Whisper, two multimodal systems that extend the same "scale up a simple objective" philosophy.
Intuition
Imagine hiring an extremely well-read consultant who has read essentially all of the internet. You don't retrain them — they already know everything they know. Instead, you walk them into a meeting and hand them a sheet of paper that says: > "We're doing Spanish translations today. Here are two examples: Hello → Hola, Goodbye → Adiós. Now translate: Cat → ?" The consultant doesn't need a training course. They recognize the pattern immediately from the sheet and from years of reading bilingual documents. That sheet of paper is your prompt. The consultant's brain is the frozen GPT-3 weights. The meeting room conversation is a single forward pass. The more examples you give (few-shot), the less ambiguous the task becomes. The key insight is that GPT-3 saw millions of analogous documents during pretraining — instruction manuals, Q&A forums, code tutorials — and learned the structure of task-solving itself, not just facts. When you show it examples, you are essentially tuning a radio dial to the right frequency within that vast learned space, not installing new hardware.
Historical Development
Origins · 1 minhow this was discovered
Why It Matters
Prerequisites
What This Leads To
See Also
Transformer Architecture · RLHF and InstructGPT · Prompt Engineering · Scaling Laws · Chain-of-Thought Prompting