GPT-2 Source Code Notes, Part 2: Sampling and Generation (sample.py)
Sampling in GPT-2 is almost minimalistic. Here we look directly at top-k, temperature, and the single-token autoregressive loop that drove early generation behavior.