Variational Inference for Category Recommendation in E-Commerce platforms

Ramasubramanian Balasubramanian, Venugopal Mani, Abhinav Mathur, Sushant Kumar, Kannan AchanarXiv 2021

This paper, authored by researchers at Walmart Global Tech, presents a novel approach to category recommendation in e-commerce by combining graph-based semantic initialization with variational inference to capture temporal purchase patterns.

TL;DR

The authors propose a hybrid recommendation framework that uses Metapath2Vec to initialize latent factors from a heterogeneous interaction graph and then refines them using Variational Inference (VI) on both transactional and temporal affinity data. This approach significantly outperforms standard baselines like BPR and Metapath2Vec, particularly in grocery settings where repeat purchase behavior is a strong signal.

What Problem Does This Paper Address?

In large-scale e-commerce, recommending specific items is often difficult due to extreme data sparsity—most users only interact with a tiny fraction of the catalog. Category recommendation serves as a "less granular" but vital alternative that helps users discover new groups of items and helps the platform manage traffic flow.

The authors identify two key structures often treated separately in literature:

  1. Graphical Structure: The semantic relationships between users, baskets, and categories (e.g., "users who buy coffee often buy filters").
  2. Temporal Structure: The "when" of a purchase. In domains like grocery, users exhibit strong repeat purchase patterns (e.g., buying paper towels every few months).

Existing graph-based models (like Metapath2Vec) excel at the former but often ignore the latter. Conversely, collaborative filtering models that focus on temporal signals often struggle with cold-start issues or lack deep semantic understanding.

Methods

The proposed system operates in two main stages:

1. Semantic Initialization via Metapath2Vec

The authors first construct a heterogeneous graph consisting of Users, Baskets, and Categories. They use the Metapath2Vec algorithm, employing a specific metapath schema (User-Basket-Category-Basket-User), to generate initial embeddings. This ensures that the starting point for the optimization process already contains rich semantic information about how categories relate to one another and to users.

2. Variational Inference (VI) Optimization

The core of the model is a probabilistic framework that treats two matrices as observed data:

  • Matrix T: A binary transaction matrix (did the user buy from this category?).
  • Matrix A: A continuous temporal affinity matrix, where entries are weighted by an exponential decay based on the time elapsed since the last purchase.

The authors model $T$ with a Bernoulli distribution and $A$ with a Normal distribution. Because calculating the true posterior is computationally intractable, they use Variational Inference to maximize the Evidence Lower Bound (ELBO). This process "fine-tunes" the initial graph embeddings to better account for the temporal repeat-purchase signals.

Datasets

The model was evaluated on two large-scale datasets:

  • Instacart Orders Dataset: A public dataset of 3 million orders from 200,000 users. The authors used k-means clustering on Word2Vec embeddings of product names to define 11,000 categories.
  • Private e-Commerce Dataset: Six months of grocery transaction data from a major retailer, involving 180,000 users and 3,100 human-curated categories. This dataset provided a denser interaction matrix and more accurate ground-truth labels.

Key Insights and Ideas

  • Initialization Matters: Instead of random initialization or domain-expert heuristics, using graph embeddings (Metapath2Vec) provides a "warm start" that leads to faster and better convergence in the VI stage.
  • Temporal Decay as a Signal: By weighting purchases by how recently they occurred, the model captures the "rhythm" of shopping, which is particularly effective for grocery items that are consumed and replenished.
  • Semantic Separation: The VI process doesn't just improve accuracy; it improves the quality of the embedding space. The authors found that while graph models cluster similar items, the addition of temporal signals helps distinguish between sub-families with different purchase frequencies (e.g., coffee powder vs. coffee accessories).

Key Results

The hybrid VI model consistently outperformed baselines across all metrics (NDCG, Hit Rate, MRR, MAP, and LAUC).

  • Instacart: The model achieved a 20-30% lift in NDCG@5 over the best baselines (BPR and M2V). The Hit Rate increased by roughly 30-60%, indicating a much higher quality recommendation pool.
  • Private Dataset: The results were even more pronounced, with a 40% lift in NDCG@5 compared to the closest baseline.
Table 2: Comparison of evaluation metrics on the private e-Commerce dataset

Qualitatively, the model showed superior ability to separate product families. As seen in Figure 1, the VI model (represented by 'x' marks) clearly separates "Coffee powders" from "Coffee accessories," whereas the base Metapath2Vec model (dots) keeps them tightly clustered. The authors attribute this to the temporal signal: people buy coffee powder much more frequently than they buy decanters or grinders.

Figure 1: Embeddings corresponding to the following product families (and product categories): Coffee accessories (Decanters, Filters, Grinders, Perco- lators, Drippers, Pods), and Coffee powders (Whole Bean, Instant Coffee, Ground Coffee)

Limitations and Future Work

  • Initialization Strategies: While Metapath2Vec worked well, the authors suggest exploring other graph-based initialization strategies to capture even deeper semantics.
  • Cold-Start: Although category recommendation helps with item-level cold-start, the model still requires a minimum threshold of user transactions to make informed predictions.
  • Domain Knowledge: Future iterations could incorporate explicit domain knowledge (like product hierarchies) directly into the probabilistic distributions rather than relying solely on implicit signals.

Summary updated

BibTeX
@misc{balasubramanian2021variational,
  author = {Ramasubramanian Balasubramanian and Venugopal Mani and Abhinav Mathur and Sushant Kumar and Kannan Achan},
  title = {{Variational Inference for Category Recommendation in E-Commerce platforms}},
  year = {2021},
  eprint = {2104.07748},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2104.07748},
}
Figure