Look inside a transformer while it thinks
Transformers are the architecture behind ChatGPT, Claude and Gemini. We trained a small one, about 100,000 parameters, to sort lists of numbers. Watch where it looks before it writes each number.
Try this
- Press Sort it and watch it write the list in order, one number at a time.
- Click any output number to see which inputs it was looking at when it chose it.
- Switch between the four attention heads. Each one learned a different job.
- Change the input to include repeats, like three 5s. Does it keep count?
The idea behind it
A transformer writes one token at a time. Before each one, its attention heads decide which earlier tokens matter most, and the bright cells show that choice. Nobody programmed a sorting rule: the model learned it from examples, and it sorted all 5,000 test lists it had never seen. Large language models work the same way, with billions of parameters instead of 100,000 and words instead of numbers.