Shopify2023-10-18Explainer
The generative recommender behind Shopify's commerce engine
Summary
Shopify describes a foundational generative recommender that predicts next products, and in some contexts ads, from buyer event sequences spanning searches, views, add-to-carts, favorites, and purchases. The system uses an autoregressive model with causal masking, time-aware attention combining RoPE-inspired rotary encoding with relative attention bias, and sampled softmax with shared and positive-aware hard negatives. Built on HSTU, it combines richer activity data, ensemble-focused training for incremental recall, and optimized CUDA kernels; the full training pipeline reached up to 7.3x the speed of a baseline implementation. In an online test of an August model version, relative shop orders rose 0.94%, high-quality click-through rate rose 5%, conversion rate rose 0.71%, and final served product recall at 2 rose 4.8%.
Context
Shopify needed recommendations that could interpret complete buyer journeys, including event order, timing, and gaps, across millions of products and billions of events. The system also had to meet real-time production latency and memory constraints while contributing incremental value to an ensemble of retrieval models rather than duplicating their candidates.
Approach / What changed
The recommender treats recommendation as next-step prediction over raw event sequences using an autoregressive, causally masked model. Shopify combined enriched activity data, HSTU-based architecture, timestamp encodings, relative attention bias, sampled softmax, shared negatives, positive-aware hard negatives, and boosting-inspired training against ensemble weaknesses. Optimized CUDA kernels supported training and serving within resource budgets.
Takeaways
Time is encoded directly through a RoPE-inspired rotary encoding and relative attention bias, allowing the model to represent absolute time, time gaps, recency, and the current session timestamp.
Shared negatives expand the sampled softmax pool across a batch, while positive-aware hard negatives avoid treating potential true positives as negatives and focus learning on informative near misses.
An August online model test reported relative lifts of 0.94% in shop orders, 5% in high-quality click-through rate, 0.71% in conversion rate, and 4.8% in final served product recall at 2.
Source and freshness
- Source
- shopify.engineering
- Published
- Added to Yomu
- Last updated
Summaries are generated from the original by a language model. Check the original before relying on it.
Keep reading
Related reading
The Good Stuff
Paid picks we use ourselves. Links carry a referral code — a subscription through one earns us a commission at no extra cost to you.
The best engineering reads, once a week
One useful email. Unsubscribe anytime.