Automatic Discovery of Visual Circuits

Achyuta Rajaram, Neil Chowdhury, Antonio Torralba, Jacob Andreas, Sarah SchwettmannarXiv 2024 · DOI

Abstract

Mechanistic interpretability seeks to understand deep neural networks as collections of human-interpretable "circuits" rather than opaque black boxes. While previous efforts relied on labor-intensive manual inspection, we introduce Cross-Layer Attribution (CLA), an automated framework for identifying functional subgraphs within vision models. By analyzing functional connectivity—how neurons influence one another during inference—CLA uncovers the underlying logic of visual recognition. Our results demonstrate that CLA can recover known circuits, reveal the compositional nature of visual representations, and enable surgical model editing to mitigate adversarial vulnerabilities.

The Challenge of Mechanistic Interpretability

Understanding how a vision model recognizes a "car" or a "dog" requires more than just identifying individual feature detectors; it requires mapping the connections between them. Until now, discovering these "visual circuits" was a grueling, manual process. Researchers had to visualize neurons and inspect weight magnitudes to hypothesize connectivity, a method that fails to scale to modern architectures. Furthermore, structural connectivity (high weights) does not always imply functional relevance for a specific task. There is a critical need for automated methods that identify circuits based on actual model behavior.

Methodology: Cross-Layer Attribution (CLA)

The core innovation of this work is Cross-Layer Attribution (CLA). Unlike static weight analysis, CLA identifies circuits by measuring functional connectivity—the degree to which one neuron's activation influences a downstream neuron for a specific input class.

Visualization of an automatically discovered visual circuit across layers 4b, 4c, and 4d, showing functional connectivity between neuron clusters.

The CLA process involves three primary steps:

  1. Attribution Matrix Calculation: For a target concept, the algorithm computes an attribution score for every pair of neurons in successive layers. This score is defined as the product of a neuron's activation and the gradient of the downstream neuron with respect to that activation.
  2. Iterative Refinement: The algorithm "sweeps" through layers to select a subset of $k$ neurons per layer that maximize total attribution to the previously selected neurons.
  3. Circuit Validation: To ensure these subgraphs are causal, researchers use pruning techniques. By zeroing out activations or edges within a discovered circuit, they can verify if the specific concept is "deleted" from the model's output without affecting general performance.

Experimental Setup and Datasets

The researchers validated CLA using several benchmarks:

  • ImageNet: Used to recover established circuits (such as the "car circuit" in InceptionV1) and sample images for concept identification.
  • CatFish Dataset: A novel synthetic dataset featuring composite images (e.g., a "tabby cat" paired with "pajamas"). This dataset allows for testing the hypothesis that complex circuits are composed of simpler, modular sub-circuits.
  • Traffic Light Dataset: A benchmark for CLIP consisting of real traffic lights and adversarial images with misleading text overlays (e.g., a red light labeled "green").
Examples from the CatFish dataset, used to study how models compose individual visual concepts into complex representations.

Key Findings: Modularity and Compositionality

A major insight from this study is that functional connectivity is superior to structural connectivity for circuit discovery. CLA successfully automated the recovery of the InceptionV1 car circuit, which previously required months of manual effort.

Furthermore, experiments with the CatFish dataset confirmed that vision models learn in a hierarchical and modular fashion. The circuit for a composite class like "tabby-pajama" was found to be essentially the union of the individual "tabby" and "pajama" circuits. This modularity suggests that models build complex understanding from simpler, reusable components.

Results: Causal Interventions and Adversarial Robustness

The precision of CLA allows for highly targeted "surgical" interventions. The researchers demonstrated two key applications:

  • Causal Impact: Pruning CLA-discovered circuits resulted in a significantly sharper drop in target-class accuracy compared to pruning random neurons or those selected via weight magnitude alone.
  • Adversarial Defense: In CLIP, the researchers identified a specific "text circuit" responsible for processing typographic overlays. By pruning just 6% of the edges in a single layer, they increased CLIP’s accuracy on adversarial "red light/green text" images from 3% to 87%, while maintaining standard performance on clean images.

Conclusion and Future Directions

While CLA represents a significant leap toward automated interpretability, it currently relies on a fixed number of neurons ($k$) per layer. Future research will focus on allowing the algorithm to automatically determine the optimal width of each layer in a circuit. Extending CLA to even larger architectures, such as Diffusion models and Large Language Models (LLMs), remains a promising frontier for understanding the "brains" of modern AI.

Summary updated

BibTeX
@misc{rajaram2024automatic,
  author = {Achyuta Rajaram and Neil Chowdhury and Antonio Torralba and Jacob Andreas and Sarah Schwettmann},
  title = {{Automatic Discovery of Visual Circuits}},
  year = {2024},
  eprint = {2404.14349},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2404.14349},
}
Figure