Active Corpus Selection for Training Subgraph Retrievers Using OOD Queries

Pritish Chakraborty, Aditya Singh, Indradyumna Roy, Lokesh Nagalapatti, Himanshu Dutta, Arun Iyer, Yashoteja Prabhu, Gaurav Sinha, Manik Varma, Soumen Chakrabarti, Abir DeNeurIPS 2026

TL;DR

Finding a small query graph hidden inside a massive database of larger graphs is computationally brutal (NP-complete, to be exact), so modern systems rely on fast neural networks to approximate the search. However, when the types of queries shift—say, moving from generic molecules to specialized drug candidates—retraining these models normally requires running expensive exact solvers all over again. ACROSS solves this by building a single, clever, reusable index that hunts down just enough training examples to adapt to any new query distribution on a strict computational budget.

What Problem Does This Paper Address?

Subgraph retrieval is the backbone of tasks like chemical search, code search, and protein motif discovery: given a query graph $G_q$, find all corpus graphs $G_c$ that contain it. Because exact subgraph matching is NP-complete, scanning a 100,000-graph database with a combinatorial solver is out of the question. Instead, Neural Subgraph Retrievers (NSRs) map graphs into vector space and rank them using fast, asymmetric similarity scores.

Here is the catch: NSRs are brittle. Train one on generic, publicly available queries (the "base" distribution), and its accuracy plummets when deployed on a private, specialized domain (out-of-distribution, or OOD, queries). Retraining on the new domain requires ground-truth labels, which means firing up that slow combinatorial solver again. And even if you try to smartly pick which graphs to label using an embedding index, you hit a chicken-and-egg problem: as your model adapts to the new queries, its embeddings shift, forcing you to constantly—and expensively—rebuild the index for the entire corpus.

Methods

The authors introduce ACROSS, an active corpus selection framework that gets the most out of a tiny solver budget ($B$ exact checks per query) while building the corpus index only once.

Figure 1: Overview of ACROSS. Top: An NSR model is trained on the base workload Qbase, following which graph embeddings are obtained for base queries and the corpus. Next, fϕ is trained on these embeddings in a distribution-shift-tolerant manner, using adversarial training. These robust fϕ outputs are then indexed offline via random hyperplane LSH, yielding dimh tables. Bottom: For each new query distribution, the index is used to retrieve corpus candidates for budgeted solver labeling. The solver budget is spent on positives, while negatives are randomly sampled and blindly labeled. These positives and negatives are used to supervise a specialized NSR model.

Standard NSRs use a shared Graph Neural Network (GNN) and an asymmetric "hinge" distance (penalizing query features not covered by the corpus graph). ACROSS introduces four key innovations on top of this:

  1. 100% Positive-Focused Budgeting: Instead of looking for uncertain boundary cases, ACROSS spends its entire solver budget $B$ hunting for likely positives (true subgraphs). Meanwhile, it randomly grabs a separate batch of graphs from the corpus and blindly labels them all as negatives for free.
  2. Decoupling via Linearization: Assuming a specialized GNN's parameters $\theta$ won't stray too far from the base model's parameters $\bar{\theta}$, the authors apply a first-order Taylor expansion around $\bar{\theta}$. This mathematical sleight of hand pushes all evolving parameter updates onto the query vector, leaving the corpus representations completely static and precomputable.
  3. Making Hinges Indexable: Standard Approximate Nearest Neighbor (ANN) indices like Locality Sensitive Hashing (LSH) work on dot products or cosine similarity, not asymmetric hinge functions ($\max(0, x)$). ACROSS applies a randomized hyperplane feature map that transforms the hinge-of-dot-products into pure dot products with high probability.
  4. Adversarial Jitter & Noisy Retrieval: To ensure the static index survives distribution shifts, a lightweight transformation network $f_\phi$ is trained by adversarially perturbing the GNN parameters $\theta$ inside a small radius around $\bar{\theta}$—simulating future OOD shifts without needing OOD data. Finally, during retrieval, Gaussian noise is added to the similarity scores before picking the top-$B$ candidates for the VF2 exact solver.

Datasets

The authors repurpose four real-world molecular graph benchmarks from TUDataset: PTC-FR, PTC-FM, PTC-MR, and COX2. While prior fully supervised graph retrieval papers typically used tiny corpora of ~800 graphs, this work scales the retrieval corpus up to 100,000 graphs alongside 500 queries. To simulate harsh OOD shifts, they place the densest ~1/3 of queries into the base workload ($\mathcal{Q}_{\text{base}}$) and cluster the remaining, sparser queries by structural features into four distinct OOD vertical distributions ($\mathcal{Q}_1 \dots \mathcal{Q}_4$).

Key Insights and Ideas

  • Classical active learning fails under extreme imbalance: Textbook active learning tells you to label examples near the decision boundary where the model is most uncertain. In graph retrieval, positives are needles in a haystack. Near the boundary, negatives still vastly outnumber positives, so querying "uncertain" points wastes your solver budget confirming negatives. The authors mathematically prove (Theorem 1) that spending 100% of the solver budget on positives while blindly guessing "negative" on random samples maximizes valid contrastive training pairs.
  • Simulating data shift via weight shift: Generating synthetic OOD graphs to robustify an index would require running the exact solver to label them. Realizing that different query distributions ultimately just manifest as shifted GNN weights, ACROSS perturbs the weights instead of the graphs—getting OOD robustness at zero labeling cost.
  • Determinism breeds overfitting: If you strictly send the top-$B$ highest-scoring candidates to the solver, you only ever harvest "easy" positives, starving the downstream GNN of hard examples. Injecting Gaussian noise ($\sigma = 1$) during reranking broadens the net to match the true positive distribution.

Key Results

Using a strict budget of $B = 40$ solver calls per OOD query, ACROSS consistently beats six baselines (including Random, k-Center Greedy, Weisfeiler–Leman kernels, raw GNN distances, and Infomax) in Mean Average Precision (MAP) across all datasets:

  • Retrieval Accuracy: Averaged across $\mathcal{Q}_1$ and $\mathcal{Q}_2$, ACROSS reaches 0.207 MAP on PTC-FR (vs. 0.183 best baseline), 0.252 on PTC-FM (vs. 0.239), 0.231 on PTC-MR (vs. 0.206), and 0.213 on COX2 (vs. 0.183).
  • Adversarial vs. Random Weight Jitter: Adversarial parameter perturbation consistently beats random sampling perturbations (e.g., 0.252 vs. 0.227 MAP on PTC-FM), as gradient-based worst-case search explores the parameter ball much more efficiently.
  • Ablations: Skipping the base NSR training drops PTC-FM MAP from 0.252 down to 0.100, and skipping the adversarial $f_\phi$ network drops it to 0.201, confirming every stage pulls its weight.

Limitations and Future Work

ACROSS relies on a first-order Taylor expansion, which leans on the assumption that the optimal GNN parameters for a new vertical sit reasonably close to the base model's parameters $\bar{\theta}$. For extreme shifts, the authors suggest exploring higher-order Taylor expansions. Additionally, ACROSS currently assigns a rigid, uniform budget $B$ to every incoming OOD query; dynamically allocating the solver budget across harder or easier queries is highlighted as a promising next step.

Summary updated

Abstract

Neural subgraph retrieval (NSR) models degrade under query distribution shifts, and retraining for each new distribution requires collecting fresh ground-truth labels, each of which entails an NP-hard subgraph-matching instance across a large corpus—making repeated label collection computationally prohibitive. We introduce ACROSS, an active corpus selection framework that, under a fixed solver budget, selects a small corpus subset per out-of-distribution query whose labels suffice for effective NSR training. We prove that allocating the entire budget to retrieving positives is optimal given extreme class imbalance. To enable efficient positive retrieval across arbitrary query distributions, we linearize corpus embeddings around a base model, apply randomized projections to eliminate hinge nonlinearities, and train distribution-shift-tolerant representations via adversarial parameter perturbation. The resulting corpus index is built once and reused across all distributions. Experiments on four molecular graph datasets show ACROSS consistently outperforms six baselines in downstream retrieval accuracy.
BibTeX
@inproceedings{chakraborty2026active,
  author = {Pritish Chakraborty and Aditya Singh and Indradyumna Roy and Lokesh Nagalapatti and Himanshu Dutta and Arun Iyer and Yashoteja Prabhu and Gaurav Sinha and Manik Varma and Soumen Chakrabarti and Abir De},
  title = {{Active Corpus Selection for Training Subgraph Retrievers Using OOD Queries}},
  booktitle = {Advances in Neural Information Processing Systems},
  year = {2026},
  url = {https://openreview.net/forum?id=MbIpE61lGH},
}
Figure