All models

GPT-2

The Transformer language model that learned tasks zero-shot from millions of web pages.

Language · 539 operations Checked

100%

Showing the top corner; full diagram not loaded yetShowing a small copy; full diagram not loaded yetLarge diagram, not loaded yet

Open SVG

Loading diagram (40 KB)

Open in a new tab

Click or tap a spot to read it up close. Scroll or drag inside the diagram to move through it. Zoom with + and − or Ctrl and scroll. Press 0 for the whole graph. Swipe inside the diagram to move through it. Use + and − to zoom.

At a glance

Family
GPT-2
Parameters
124.4M
Operations
539
Framework
PyTorch
Recurrent
No
License
Apache-2.0
Checked
Passed: the trace was replayed operation by operation and matched the model's own output for this input.

Files

The diagram is a drawing of a TorchLens trace of the source code. It contains no code or weights.

Details
Stable ID
m5228
Graph hash
c56e199a5e208cad0931d15259ceff85ecf8ecd7166e5c2f6917b7eb454a838c
Skeleton hash
e1fac6750f0b4c6bfce9e0617c66dc9fe5b1b1aa14cf589483a12d48ba759c77
Architecture hash
6103f10fbd5df688500bde0554b01e00867bdb6b133aec55993bfb796fdd366b
Diagram SHA-256
019130cf04e7b5a7cd6f93195aeceab9961caf5a4139258eabfdf2095eba0d42
TorchLens version
2.36.0
Renderer
graphviz 2.43.0+pyvips 3.2.0+libvips 8.18.7+render-opts@06c1f0d3
Check
Forward pass replayed in PyTorch

How this diagram was made

transformers.AutoModel.from_config()

What it is

About this model's family

GPT-2 is the Transformer language model behind the paper Language Models are Unsupervised Multitask Learners, whose claim is that a language model begins to learn tasks like question answering, translation and summarization with no explicit supervision. Its training set, WebText, was built by scraping all outbound links from Reddit that received at least 3 karma, giving slightly over 8 million documents and 40 GB of text after cleaning. The member traced here is the base gpt2 configuration from the transformers library, which corresponds to the paper's smallest size: 12 layers with a model width of 768, about 117M parameters.

The architecture largely follows the OpenAI GPT model with a few modifications. Layer normalization moves to the input of each sub-block, like a pre-activation residual network, and an extra layer normalization is added after the final self-attention block. Residual layer weights are scaled at initialization by 1/√N, where N is the number of residual layers, to account for accumulation on the residual path with depth. The vocabulary grows to 50,257 tokens using a byte-level version of byte pair encoding, and the context size doubles from 512 to 1024 tokens.

The paper trained four sizes with log-uniformly spaced parameter counts, 117M, 345M, 762M and 1542M, and the largest is the one it names GPT-2. That 1.5B parameter model reaches state of the art on 7 of 8 tested language modeling datasets zero-shot, yet still underfits WebText. Conditioned on a document plus questions, its answers reach 55 F1 on CoQA, matching or exceeding 3 of 4 baselines without using the 127,000+ training examples. Capacity matters: performance improves in a log-linear fashion across tasks as the model grows.

Key idea. Showing that a large Transformer language model trained only on web text learns downstream tasks zero-shot, with performance scaling log-linearly in model capacity.

  • GPT-2
  • gpt2
  • GPT
  • OpenAI
  • language model
  • WebText
  • zero-shot
  • text generation
  • Radford
  • CodeGen

AI-written summary, checked automatically against its sources; not reviewed by a person. Corrections welcome.