← Looped Weight-Space Programming · Maze demo
Looped weight-space programming · demo

Run the hand-written transformer

This page runs the Tower of Hanoi transformer from the post, in your browser. It loads the transformer's real weights, … of them, and only … aren't zero. Then it runs them with one generic loop: look up each token, run the same transformer block again and again, and read off the next move. The loop knows nothing about the puzzle. A separate checker on this page replays every move.

Moves
0
Mistakes
0
Tokens it reads
0
Transformer time
0.0 s
What the transformer wrote after each loop, for the latest move

The move is read after the last loop. With 4 or 8 loops, every move stays exactly the same.

Pick a number of disks and press Run.
moves = []

What happens when you press Run

  1. The puzzle becomes tokens: the number of disks, where each disk starts, where it should end, and a separator.
  2. For every new token, the transformer looks it up in its embedding table, runs the same transformer block a few times, and reads off a score for each possible next token. The highest score is the next move.
  3. That move is added to the input, and the loop goes again, until the transformer writes its end token.
  4. Separately, a small checker replays each move on the pegs: the disk must be on top of its peg and may never land on a smaller one.

Each step reads every earlier token, so bigger puzzles take longer. Up to 13 disks finishes in about a second. 15 disks, 32,767 moves, takes several seconds on a laptop.

The whole runner: the loop that runs the transformer

  

The same loop in Python, and the weights of all the hand-written transformers, are in weights/. This page uses hanoi_model.js, the same numbers as the Hanoi weights file there.