One-layer PyTorch transformer groks trigonometry circuit

pub.towardsai.net10 min read

An author trained a one-layer transformer on modular addition in PyTorch and analyzed the model's weights to observe grokking firsthand. The investigation revealed that the network builds a trigonometric cosine circuit long before test accuracy climbs to 100%, while weight decay gradually strips away the initial memorized solution. Open article →