A commerce engine that reads the whole journey

A Shopify buyer’s behavior is not a single action but a stream of events—searches, product views, add-to-carts, favorites, and purchases—spanning storefronts and the Shop app over months. The sequence itself carries meaning: order, timing, and the gaps between actions all matter. A useful recommendation model must read that full sequence and predict what comes next, not just summarize it.

Shopify’s scale makes this demanding. During BFCM 2025, the platform observed 2.2 trillion edge requests, and more than 81 million consumers made purchases from Shopify-powered brands. That volume is both the raw material for training and the constraint on serving latency.

Framing recommendations as next-token prediction

The core task is straightforward to state: given a buyer journey, recommend the next products—or, in some contexts, the next ads. Treating it as next-step prediction over sequences puts the problem in the domain where generative modeling excels. Rather than engineering features for every possible context signal, Shopify trained an autoregressive model with a causal mask to predict the next product token from raw event sequences. That approach lets the model discover patterns that would be difficult to specify by hand, including intention shifts, long-range preferences, and seasonal behavior.

Early work built on HSTU, a generative recommender architecture for sequential recommendation, which showed promising scaling behavior where validation loss improved as model capacity grew. As the project matured, development focused on three dimensions: enriching data with more user activity sources across the Shop app and storefronts; model changes including new time encoding and improved negative sampling; and compute optimizations with custom CUDA kernels to fit training and serving within memory and latency budgets.

What moved quality in production

Improvements came not from a single change but from reinforcing techniques, all derived from one principle: commerce is context. Three techniques stood out.

Encoding time as a first-class signal

Browsing history in June and the same history in December should not lead to the same recommendations. In commerce, when an event happened matters, and the current session’s timestamp often matters more because it anchors what is relevant at that moment.

Time is meaning

The solution was to encode timestamps directly inside attention, using a RoPE-inspired rotary encoding for absolute time combined with a relative attention bias to represent time gaps and recency. The design also allows the current session timestamp to be incorporated at inference time, letting the model handle seasonality without manual rules. With time encoded this way, the system behaves less like a generic sequence predictor and more like a commerce model aware that context shifts.

Negative sampling as a scaling lever

With a catalog of millions of products, training a next-item model over that output space requires approximation. Sampled softmax is the practical choice, but its behavior depends entirely on the quality of the negatives shown to the model. If negatives are trivial, the model learns weak representations; if they are informative, it can separate similar products more sharply and retrieval quality improves.

Negative sampling

Two sampling strategies proved effective:

  1. Shared negatives expand the negative pool across the batch, increasing coverage without the memory explosion of per-example negatives.
  2. Positive-aware hard negatives address a subtle danger: uniform sampling of negatives may treat potential true positives as negatives, misleading contrastive learning. Useful near-miss negatives must be chosen carefully to avoid false negatives—items the user simply never saw.

Negative sampling became one of the strongest levers available, but it only worked because system efficiency was treated as part of the modeling problem. Scaling negatives raises memory use and forces close attention to GPU utilization.

Optimizing for incremental recall

A production recommender is an ensemble: multiple retrieval models generate candidates, rankers reorder, and aggregation layers handle deduplication and business constraints. A single model can look excellent offline yet add little if it mostly rediscores the same items other models already surface.

Incremental recall

To contribute real value, the generative recommender needed to find true positives that other models missed. That objective changed the training strategy. A boosting-inspired approach increases training pressure on regions where the ensemble is weak and can treat other models’ predictions as hard negatives. The point is not novelty for its own sake but broader, useful coverage that makes the ensemble stronger overall.

Training speed as a competitive advantage

Long sequences, time-aware attention, and large negative pools make training expensive. Naive implementations slow iteration cycles and cap scalability. Shopify focused on pipeline optimization, reaching up to 7.3x faster training relative to a baseline for the target workloads.

Speed

That speedup directly translates into faster hypothesis testing. Faster training allows more aggressive exploration of model capacity, batch size, and context length—and makes it feasible to evaluate ideas that would otherwise be too costly. At Shopify’s scale, iteration velocity is itself a competitive factor.

Production results

Offline gains translated to online outcomes in A/B tests of an August model version. Shop orders increased 0.94% relative, high quality click-through rate (defined as clicks leading to actions closer to buying, such as favoriting, adding to cart, or purchasing) rose 5% relative, and conversion rate increased 0.71% relative. Final served product recall at 2 also improved 4.8% relative, evidence that offline retrieval quality can predict online success when evaluation is carefully aligned.

Stats

Moving beyond product IDs

One visible limitation of generative recommenders is their dependence on very large embedding tables over a huge product ID space. Modeling products independently becomes a bottleneck when trying to incorporate richer signals like text queries or assistant interactions while keeping serving costs predictable.

An ongoing direction is moving from product ID space to token space with semantic IDs: learning representations that express products and other entities as sequences of tokens from a much smaller vocabulary. The next step would be training a model that works over both semantic ID tokens and text tokens, integrating additional context sources and reducing reliance on massive product ID embeddings. That could enable more flexible behaviors, including prompt-driven task adaptation, while staying grounded in Shopify’s commerce context.

The foundational approach, as Shopify defines it, is not a single model release. It is a method that treats buyer journeys as sequences, time as context, negative sampling as a scaling lever, and system-level benefit as the objective. Those pieces together produce a recommender that is accurate offline, impactful online, and able to keep improving as data, models, and infrastructure evolve. The work was presented at NeurIPS 2025.