Skip to main content
QUICK REVIEW

[Paper Review] The Clock and the Pizza: Two Stories in Mechanistic Explanation of Neural Networks

Ziqian Zhong, Ziming Liu|arXiv (Cornell University)|Jun 30, 2023
Neural Networks and ApplicationsComputer Science11 citations
TL;DR

The paper shows that neural networks trained on modular addition can discover multiple algorithmic strategies (Clock, Pizza, and more) depending on architecture and hyperparameters, revealing algorithmic phase transitions in neural networks' mechanistic solutions.

ABSTRACT

Do neural networks, trained on well-understood algorithmic tasks, reliably rediscover known algorithms for solving those tasks? Several recent studies, on tasks ranging from group arithmetic to in-context linear regression, have suggested that the answer is yes. Using modular addition as a prototypical problem, we show that algorithm discovery in neural networks is sometimes more complex. Small changes to model hyperparameters and initializations can induce the discovery of qualitatively different algorithms from a fixed training set, and even parallel implementations of multiple such algorithms. Some networks trained to perform modular addition implement a familiar Clock algorithm; others implement a previously undescribed, less intuitive, but comprehensible procedure which we term the Pizza algorithm, or a variety of even more complex procedures. Our results show that even simple learning problems can admit a surprising diversity of solutions, motivating the development of new tools for characterizing the behavior of neural networks across their algorithmic phase space.

Motivation & Objective

  • Motivate how neural networks discover algorithms for algorithmic tasks beyond a single canonical solution.
  • Show that Clock and Pizza algorithms can both emerge in similar architectures under different hyperparameters.
  • Demonstrate that networks can ensemble multiple algorithm variants in parallel for robustness.
  • Introduce metrics to distinguish these algorithms and quantify phase transitions in the algorithmic space.

Proposed method

  • Train one-layer transformers with and without attention on modular addition modulo p (p=59).
  • Characterize learned embeddings as circles in PCA-projected space to identify Clock behavior.
  • Define and compute gradient symmetricity and distance irrelevance as metrics to distinguish Clock vs Pizza.
  • Introduce circle isolation to analyze embedded representations under reduced subspaces.
  • Vary architecture and a new attention-rate parameter to map algorithmic phase transitions between Clock and Pizza.
Figure 1: Illustration of the Clock and the Pizza Algorithm.
Figure 1: Illustration of the Clock and the Pizza Algorithm.

Experimental results

Research questions

  • RQ1Can neural networks trained on modular addition rediscover familiar algorithms like Clock, or do alternative strategies arise under different conditions?
  • RQ2What mechanisms (embeddings, gradients) distinguish Clock from Pizza in practice?
  • RQ3How do architecture (with/without attention) and hyperparameters influence which algorithm is learned?
  • RQ4Do networks ensemble multiple algorithmic strategies, and how can this be detected and analyzed?

Key findings

  • Clock and Pizza are both viable solutions for modular addition in similar networks.
  • Networks without attention (Clock-leaning) exhibit gradient symmetry and a distance-independent logit pattern, indicating Pizza-like behavior.
  • Pizza algorithm relies on averaging embeddings and an absolute value operation, leading to logit patterns dependent on a-b.
  • Clock algorithm uses circular embeddings and absence of dependence on a-b; Pizza shows dependence on a-b and an extra |cos((a-b)/2)| factor in logits.
  • There are sharp algorithmic phase transitions between Clock and Pizza governed by model width and attention strength, with ensembling revealing robustness across inputs.
Figure 2: Gradients on first six principal components of input embeddings. $(a,b,c)$ in the title stands for taking gradients on the output logit $c$ for input $(a,b)$ . x and y axes represent the gradients for embeddings of the first and the second token. The dashed line $y=x$ signals a symmetric g
Figure 2: Gradients on first six principal components of input embeddings. $(a,b,c)$ in the title stands for taking gradients on the output logit $c$ for input $(a,b)$ . x and y axes represent the gradients for embeddings of the first and the second token. The dashed line $y=x$ signals a symmetric g

Read this paper

Open the full text in the Nubint reader and ask about any passage as you read.

Read this paper on Nubint

This review was generated by AI from the original paper. Please check the paper before citing it.