DeepBase: Deep Inspection of Neural Networks

Thibault Sellam, Kevin Lin, Ian Yiran Huang, Michelle Yang, Carl Vondrick, Eugene Wu

Abstract

Although deep learning models perform remarkably well across a range of tasks such as language translation and object recognition, it remains unclear what high-level logic, if any, they follow. Understanding this logic may lead to more transparency, better model design, and faster experimentation. Recent machine learning research has leveraged statistical methods to identify hidden units that behave similarly to human-understandable logic, but those analyses require considerable manual effort. Our insight is that many of those studies follow a common analysis pattern, which we term Deep Neural Inspection (DNI). There is opportunity to provide a declarative abstraction to easily express, execute, and optimize them. This paper describes DeepBase, a system to inspect neural network behaviors through a unified interface. We model logic with user-provided hypothesis functions that annotate the data with high-level labels. DeepBase lets users quickly identify individual or groups of units that have strong statistical dependencies with desired hypotheses. We discuss how DeepBase can express existing analyses, propose a set of simple and effective optimizations to speed up a standard Python implementation by up to 72x, and reproduce recent studies from the NLP literature.

Introduction

Deep learning models are notoriously difficult to interpret. To understand them, researchers often perform "Deep Neural Inspection" (DNI)—writing custom scripts to see if internal hidden units (neurons) activate in response to specific high-level "hypotheses" (e.g., "Does this neuron fire only when it sees a noun?"). Currently, this process is inefficient; it requires thousands of lines of one-off, unoptimized code that is slow to run and hard to reuse. There is no unified system to manage the massive amount of data generated by neuron activations across different models and datasets.

Figure 1: Comparison of lines of code required for various neural network inspection methods. Existing research often requires thousands of lines of code, a complexity DeepBase aims to reduce.

DeepBase addresses this by treating model inspection as a data management problem, providing a declarative, high-performance framework for DNI. It allows researchers to easily test if specific neurons have "learned" human-understandable concepts, achieving significant speedups over traditional ad-hoc scripts.

System Architecture and Methods

The core of DeepBase is a declarative API that separates what to inspect from how to execute it. The system architecture is designed to handle the scale of modern neural networks efficiently.

Figure 2: The DeepBase system architecture, showing the flow from datasets and hypotheses through behavior extractors to the final inspection results.

The system consists of several key components:

  • Hypothesis Functions: User-provided logic (Python functions, Finite State Machines, or Parse Trees) that label input data with high-level concepts.
  • Affinity Measures: Statistical tools (like Pearson correlation or Logistic Regression) used to quantify the relationship between a neuron's behavior and a hypothesis.
  • System Optimizations: To achieve high performance, DeepBase employs several optimizations. Model Merging combines multiple probes into a single computation graph on the GPU. Early Stopping halts data processing once affinity scores converge, leveraging the fact that DNI is essentially a statistical estimation. Additionally, Streaming & Caching extracts activations on-the-fly to save memory and reuses hypothesis results.

Evaluation and Key Insights

DeepBase was evaluated across three distinct domains: Synthetic SQL (using a PCFG), Neural Machine Translation (OpenNMT on WMT15), and Computer Vision (using the Broden dataset).

Several key insights emerged from this work:

  • Interpretability as a Query Problem: Most interpretability research follows a common pattern that can be abstracted into a system similar to a database.
  • Statistical Convergence: Statistical measures often converge very early, allowing for massive speedups through early stopping without looking at every activation in a massive corpus.
  • Architecture as a Prior: Even untrained models exhibit some "logic" (like detecting textures), but high-level semantic concepts only emerge after training.

Results

DeepBase demonstrates significant performance gains, running up to 72x faster than standard Python baselines and up to 419x faster than in-database implementations for certain measures. It handles models with tens of thousands of hidden units by avoiding the cubic cost bottlenecks of naive inspection.

In the Computer Vision benchmark, DeepBase scores were strongly correlated with specialized tools like NetDissect, proving that a general-purpose declarative system can match the accuracy of niche solutions. Furthermore, the system successfully reproduced complex NLP research findings, confirming that NMT models learn low-level features in early layers and high-level syntax in deeper layers.

Conclusion and Future Work

DeepBase transforms the "black box" of neural networks into a more transparent environment by providing a scalable, declarative framework for inspection. While hypothesis engineering still requires manual effort, the system significantly lowers the barrier to entry for model auditing. Future work includes extending the system to Transformer architectures and building libraries of off-the-shelf hypotheses for various domains.

Summary updated

Abstract

Although deep learning models perform remarkably well across a range of tasks such as language translation and object recognition, it remains unclear what high-level logic, if any, they follow. Understanding this logic may lead to more transparency, better model design, and faster experimentation. Recent machine learning research has leveraged statistical methods to identify hidden units that behave (e.g., activate) similarly to human understandable logic, but those analyses require considerable manual effort. Our insight is that many of those studies follow a common analysis pattern, which we term Deep Neural Inspection. There is opportunity to provide a declarative abstraction to easily express, execute, and optimize them. This paper describes DeepBase, a system to inspect neural network behaviors through a unified interface. We model logic with user-provided hypothesis functions that annotate the data with high-level labels (e.g., part-of-speech tags, image captions). DeepBase lets users quickly identify individual or groups of units that have strong statistical dependencies with desired hypotheses. We discuss how DeepBase can express existing analyses, propose a set of simple and effective optimizations to speed up a standard Python implementation by up to 72x, and reproduce recent studies from the NLP literature.
BibTeX
@inproceedings{sellam2019deepbase,
  author = {Thibault Sellam and Kevin Lin and Ian Yiran Huang and Michelle Yang and Carl Vondrick and Eugene Wu},
  title = {{DeepBase: Deep Inspection of Neural Networks}},
  booktitle = {SIGMOD},
  year = {2019},
  url = {https://openreview.net/forum?id=wzXvZfw4BJ},
}
Figure