Introduction
Recommendation systems predominantly utilize two-tower architectures, which evaluate user-item rankings through the inner product of their respective embeddings. However, a key limitation of two-tower models is that they learn a pair-agnostic representation of users and items. In contrast, pair-wise representations scale poorly due to their quadratic complexity or are too restrictive on the candidate pairs to rank.
To address these issues, Context-based Graph Neural Networks (ContextGNNs) introduce a novel deep learning architecture for link prediction in recommendation systems. By using a personalized fusion mechanism to balance local context with global exploration, ContextGNN bridges the gap between efficient two-tower models and precise pair-wise Graph Neural Networks (GNNs), outperforming state-of-the-art baselines by an average of 20% across diverse real-world tasks.
The Problem: Efficiency vs. Precision
Most modern recommendation systems rely on the two-tower architecture: one neural network (tower) embeds the user, another embeds the item, and their similarity is calculated via an inner product. While highly scalable, this approach is "pair-agnostic"—the user’s representation doesn't change based on which item is being evaluated. This makes it difficult to capture fine-grained dependencies, such as a user’s specific history with a particular brand or category.
Conversely, pair-wise models (like NBFNet) are "pair-aware," but they suffer from a "locality trap." They are excellent at predicting interactions within a user's immediate neighborhood (familiar items) but scale poorly and struggle to recommend "exploratory" items—new products a user hasn't interacted with yet. There is a fundamental trade-off: pair-wise context is needed for precision in familiar territory, but two-tower efficiency is required for broad exploration.
Methods: The ContextGNN Architecture
ContextGNN is a single-stage GNN-based system designed to fuse these two worlds effectively.
- Pair-wise Component: For items within a user’s local $k$-hop subgraph, the model generates user-specific item representations. It uses an "indicator" on the seed user node to let the GNN differentiate between the user and others in the neighborhood.
- Two-Tower Component: For "distant" items outside the local subgraph, the model falls back to a novel two-tower approach. Crucially, it uses shallow item embeddings instead of a full GNN on the item side. This avoids "oversmoothing" (where all items start looking the same) and allows the model to scale to millions of negative samples during training.
- Personalized Fusion: Because users exhibit different behaviors—some are "explorers" while others are "repeaters"—ContextGNN uses a Multi-Layer Perceptron (MLP) to predict a user-specific fusion score. This score dynamically adjusts the weight between the pair-wise (local) and two-tower (global) predictions for each individual user to create a final ranking.
- Efficiency via Shared Backbones: Both the pair-wise and two-tower components share the same GNN backbone. The system only needs a single GNN forward pass per user to generate both types of recommendations, making it significantly faster than traditional two-tower GNNs that must process users and items separately.
Datasets and The Locality Gap
The authors introduce a "Locality Score" metric to quantify the fraction of ground-truth items that fall within a user's $k$-hop neighborhood. This provides a mathematical way to characterize different recommendation datasets.
The model was evaluated on several diverse benchmarks, including the RelBench suite (rel-amazon, rel-hm, rel-stack, rel-trial), Amazon-Book, and the IJCAI Contest dataset.
A key insight from this evaluation is The Locality Gap: in many datasets, the majority of ground-truth items are actually "exploratory" (falling outside a 3-hop neighborhood). This explains why previous pair-wise GNNs, despite their complexity, often underperform in real-world scenarios where users frequently interact with novel items.
Key Results and Insights
- Superior Performance: ContextGNN improved Mean Average Precision (MAP) by 20% on average over NBFNet (the best pair-wise baseline) and by a staggering 344% over the best two-tower baseline.
- Adaptability: On datasets with very low locality (mostly exploratory items, such as
rel-trial), ContextGNN achieved a nearly 100% improvement by successfully combining orthogonal signals from both of its components. - Scalability: During training, ContextGNN can handle up to 1 million negative samples on a single commodity GPU, whereas standard GNN baselines often run out of memory (OOM) at much lower counts.
- Shallow is Better (Sometimes): On the item side of the tower, shallow embeddings often capture signals like popularity and seasonal trends more effectively than deep GNNs, which can struggle with the extreme density of popular item connections.
Limitations and Future Work
While ContextGNN represents a significant step forward, it has a few limitations. The use of shallow item embeddings makes the base model "transductive," meaning it struggles with entirely new items not seen during training. For "inductive" settings (like marketplaces with high turnover), a deep neural network fallback is suggested but requires further exploration. Additionally, while the model handles new users well via the GNN, the "exploratory" side of the recommendation still relies heavily on historical item popularity for cold-start users. Future work may also explore more lightweight GNN backbones or self-supervised learning techniques to further boost performance and efficiency.
Summary updated