The generative recommender behind Shopify's commerce engine

Yang Liu, Ali Khanafer25 Feb 2026

Problem

Shopify recommends products, and in some contexts ads, to buyers whose journeys run across storefronts and the Shop app: searches, views, add-to-carts, favorites and purchases over months. Order, timing and gaps carry the intent, and a summary of the history throws that away. The catalog has millions of products and the system sees billions of events, so a sequence model must also fit memory and latency budgets.

Example from the article: a buyer searches for t-shirts, views a few and buys one. More t-shirts is a fair next recommendation in June, but the same history should not give the same answer in December.

Solution in brief

Frame recommendation as next-product prediction over raw event sequences and train an autoregressive model (built on HSTU) with a causal mask. Three changes raised quality most: time encoded inside attention, large and carefully chosen negatives for sampled softmax, and a boosting-inspired objective that targets what the existing retrieval ensemble misses. Optimized CUDA kernels make training and serving fit the budgets.

Questions this case answers
  • How to predict the next item from long raw event sequences when the item catalog has millions of entries and serving latency is bounded
  • How to make a sequence model use event time and seasonality instead of order alone
  • How to add a retrieval model to an ensemble so that it finds positives the other models miss
  • How to recommend the next product from raw buyer event sequences without heavy feature engineering?

Tools and methods

  • HSTU — generative sequential recommender used as the starting point, with rotary time encoding and relative attention bias
  • Sampled softmax with shared and positive-aware hard negatives — trains over millions of products
  • Boosting-inspired training — targets the part of the space where the ensemble is weak
  • Custom CUDA kernels — keep training and serving within budgets
Continue reading — it's free

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