Neural Architecture Retrieval

Xiaohuan Pei, Yanxi Li, Minjing Dong, Chang Xu

With the explosion of deep learning research, thousands of neural architectures are now open-sourced on platforms like HuggingFace and PyTorch Hub. However, researchers lack a streamlined way to automatically "situate" a new design. When proposing a new model, it is increasingly difficult to answer: Is this architecture truly novel? What existing models are most similar to my design?

Standard Information Retrieval (IR) works well for text, but neural networks are represented as complex computational graphs. Applying standard Graph Neural Networks (GNNs) to this problem faces two major hurdles:

  1. Extreme Scale Variance: Graphs range from tiny (like LeNet-5) to massive (like ViT-L), making direct comparison computationally heavy and noisy.
  2. Structural Motifs: Neural networks are inherently modular. For example, ResNet-50 and ResNet-101 are globally different but share identical "bottleneck" blocks. Standard GNNs often fail to capture these repeated structural patterns (motifs) that define an architecture's core "DNA."

To address this, researchers have introduced Neural Architecture Retrieval (NAR), a new task aimed at finding similar neural network designs within a massive database of existing models.

Overview of the Neural Architecture Retrieval framework.

Methodology

To enable efficient, hierarchy-aware search that significantly outperforms standard graph neural networks, the authors propose a two-stage framework to learn accurate graph representations for retrieval.

1. Motif Discovery and Macro Graph Construction

Instead of treating the network as one giant, flat graph of operations, the system identifies recurring sub-structures.

  • Motif Sampling: The framework uses an iterative neighbor-encoding strategy (similar to Weisfeiler-Lehman labeling) to identify frequent subsequences of operations.
  • Macro Graph: The original graph is then "shrunk" by replacing discovered motifs with single nodes. This reduces the overall graph size and forces the model to focus on the high-level "macro" connectivity of the architecture.
The motif discovery process extracting subgraphs from the input computational graph.

2. Multi-Level Contrastive Learning

To train the encoder effectively on these macro graphs, the authors use two levels of self-supervised learning:

  • Motif-level: The model learns to embed motifs by comparing a motif's structure against its local "context" (its immediate neighbors in the full graph). A motif gains its "meaning" from where it sits in the network, and this contrastive task successfully captures that positional importance.
  • Graph-level: The model uses a contrastive loss to ensure that architectures from the same "family" (e.g., different versions of ResNets or Transformers) are clustered together in the embedding space, while different families are pushed apart.

Datasets

To facilitate this new task, the researchers introduced two significant datasets:

  • Real-World Dataset: 12,517 unique neural architectures crawled from public repositories, covering tasks from image classification to speech recognition.
  • NAS Dataset: 30,000 synthesized architectures generated using the DARTS (Differentiable Architecture Search) space to test the model's ability to handle fine-grained structural variations.

Key Results and Insights

The proposed method was evaluated using standard retrieval metrics: Mean Reciprocal Rank (MRR), Mean Average Precision (MAP), and Normalized Discounted Cumulative Gain (NDCG).

  • Superiority over Baselines: On real-world data, the method outperformed standard GCN and GAT baselines significantly. Most notably, NDCG@20 increased by 13% compared to the best baseline.
  • Clean Clustering: Qualitative t-SNE visualizations demonstrated that the model creates highly distinct clusters for different model families (e.g., separating Attention-based models from CNNs), whereas standard GNNs produced messy, overlapping clusters.
  • The Importance of Hierarchy: The most important insight from the study is that explicitly modeling motifs as nodes in a macro graph effectively "compresses" the search space without losing structural meaning. Ablation studies proved that using "Motif Number" to split graphs was far more effective than random splitting, confirming that motifs are the natural "units" of neural architectures.
  • Transferability: Pre-training on synthetic Neural Architecture Search (NAS) data actually helps the model perform better on real-world human-designed architectures, suggesting that structural patterns are universal across both domains.

Limitations and Future Work

While highly effective, the framework does have limitations. The initial discovery of motifs across 12k+ graphs requires a pre-processing step that could become computationally intensive as the database grows to millions of models. Furthermore, the current approach focuses entirely on static computational graphs, meaning it does not explicitly account for dynamic behaviors (like conditional branching during inference) or the specific weight values of trained models.

Looking forward, the authors suggest that NAR could be integrated into automated machine learning (AutoML) pipelines. By retrieving high-performing architectures similar to a user's initial query, NAR could help "warm-start" architecture searches, saving massive amounts of compute.

Summary updated

BibTeX
@inproceedings{pei2024neural,
  author = {Xiaohuan Pei and Yanxi Li and Minjing Dong and Chang Xu},
  title = {{Neural Architecture Retrieval}},
  booktitle = {International Conference on Learning Representations},
  year = {2024},
  url = {https://openreview.net/forum?id=1JtTPYBKqt},
}
Figure