Using graph neural networks to recommend related products

Srinivas Virinchi, Anoop Saladi, Abhirup Mondal11 Oct 2022

Problem

An e-commerce team wants to show related products next to a query product. The relation is asymmetric: a case suits a phone buyer, but a phone does not suit a case buyer. Popular graph neural network (GNN) models have no straightforward way to encode this direction. Purchase logs are also biased, because what customers buy reflects what they were shown, and new products have no purchases at all.

Example from the article: recommending a phone case to someone buying a new phone, but not a phone to someone buying a case.

Solution in brief

Give every product two embeddings, one as the source of a recommendation and one as the target, built from different sides of the directed co-purchase edges. Train with a loss that rewards outbound co-purchase edges and penalizes the reverse direction. Add co-view edges between similar products to offset selection bias, and feed catalog metadata as node features so new products get embeddings too.

Questions this case answers
  • How to learn item-to-item recommendations from directed co-occurrence data where the relation is asymmetric and the logged data reflects what the system exposed
  • How to produce item-to-item recommendations for new items that have metadata but no interaction history
  • How to recommend related products when the relation is one-directional, like phone to case but not case to phone?
  • How to correct co-purchase recommendations for selection bias caused by what customers were shown?

Tools and methods

  • Directed product graph — nodes are products with metadata features; co-purchase edges may be one-way, co-view edges are bidirectional.
  • Dual-embedding GNN (DAEMON) — source and target embeddings aggregated from different neighbors.
  • Contrastive asymmetric loss with negative sampling — pulls connected products together and enforces direction.
  • FAISS — nearest-neighbor lookup of the query's source embedding among target embeddings.
  • PyTorch — model training.
Continue reading — it's free

Google or a one-time email code. No password.