NeurIPS 2026Coming to NeurIPS?Explore papers, orals & directions

Metric Learning for Session-Based Recommendations

Bartlomiej Twardowski, Pawel Zawistowski, Szymon Zaborowski · DOI

Introduction

Traditional session-based recommendation (SBR) systems have increasingly relied on complex neural architectures like RNNs and GNNs. This paper introduces Session-based Metric Learning (SML), a framework that simplifies the problem by treating recommendation as a distance-matching task in a shared embedding space. By learning a metric where sessions and items are co-located, SML matches or exceeds the performance of state-of-the-art models using significantly simpler architectures.

The Challenge of Session-Based Recommendation

In many e-commerce and media platforms, user history is often unavailable due to privacy or lack of authentication. Recommendation must rely solely on the current "session"—a short sequence of interactions. While deep learning has dominated this field, classical neighborhood-based methods (e.g., KNN) often remain surprisingly competitive. SML aims to bridge this gap by combining the representational power of neural networks with the efficiency of metric-based retrieval.

Methodology: Learning a Common Space

The core of SML is the projection of both sessions and items into a unified embedding space. The relevance of an item $i$ to a session $s$ is determined by the distance between their respective embeddings, $\phi(s)$ and $\omega(i)$.

Key Architectural Components

  • Modular Encoders: The framework is agnostic to the specific encoder. The authors evaluated simple Max-Pooling, CNNs (TextCNN, Caser), and RNNs (GRU, LSTM).
  • Metric Loss Functions: Instead of standard cross-entropy, SML utilizes Triplet Loss—which enforces a margin between positive and negative items—and NCAS (Neighborhood Component Analysis with Smoothing), a ranking-focused loss that improves generalization.
  • Sampling Strategies: To handle large item catalogs, the model employs balanced positive-negative sampling and a "swapping" technique to better explore item-item relationships.

Experimental Setup and Datasets

The SML approach was evaluated across four diverse datasets, ranging from public benchmarks to proprietary e-commerce data. These datasets exhibit significant variance in session length and item repetition rates, as detailed in the statistics below.

Table 1: Experimental dataset statistics before and after preprocessing.
Distribution of session lengths (events) and item repetition rates across the four datasets.

The datasets include:

  1. Retail Rocket (RR/5): A public e-commerce dataset.
  2. RSC15/64: A standard benchmark from the 2015 RecSys Challenge.
  3. SI-T & SI-D: Proprietary e-commerce datasets from distinct product categories.

Key Insights and Results

The experimental results demonstrate that SML is highly competitive with established baselines like VSKNN and GRU4Rec+.

  • Performance: On the SI-T dataset, SML-TextCNN-Triplet achieved a top Recall@20 of 0.7463. On RSC15/64, SML-RNN-NCAS led with a Recall@20 of 0.5248.
  • Simplicity and Efficiency: A major finding was that deep, complex architectures are often unnecessary; simple max-pooling or basic CNNs frequently matched the performance of more complex models. Furthermore, because the final recommendation is a nearest-neighbor search, SML is highly suitable for production environments using optimized vector search engines like Faiss.
  • Reduced Popularity Bias: SML models tend to recommend a broader spectrum of items. In proprietary tests, SML surfaced nearly twice as many unique items as the VSKNN baseline, suggesting better discovery of niche products.

Conclusion and Future Directions

SML provides a robust, efficient framework for session-based recommendations by leveraging the geometry of a shared metric space. While the current model focuses on item sequences, future work could incorporate additional context such as "dwell time" or cross-session user data to further enhance recommendation quality. Despite the computational overhead of triplet preparation, the gains in retrieval efficiency and coverage make SML a compelling alternative to standard sequence-to-item prediction models.

Summary updated

BibTeX
@inproceedings{twardowski2021metric,
  author = {Bartlomiej Twardowski and Pawel Zawistowski and Szymon Zaborowski},
  title = {{Metric Learning for Session-Based Recommendations}},
  booktitle = {ECIR},
  year = {2021},
  doi = {10.1007/978-3-030-72113-8\_43},
}
Figure