The generative recommender behind Shopify's commerce engine
Shopify built a foundational generative recommender on HSTU that treats buyer journeys as raw event sequences and trains an autoregressive, causally masked model to predict the next product. The quality gains came from three ideas. Timestamps are encoded directly in attention through RoPE-style rotary encoding plus relative time bias, including the current session time. Negative sampling is scaled with shared and positive-aware hard negatives under sampled softmax. A boosting-inspired objective rewards recall that the rest of the retrieval ensemble misses. Optimized CUDA kernels gave up to 7.3x training speedup, and online A/B tests showed +0.94% Shop orders, +5% high-quality CTR and +0.71% conversion. Next steps explore semantic IDs to replace huge product-ID embedding tables.
Related posts
- Shopify’s generative discovery model
Shopify Engineering hardMasterShopify trained a single generative model, adapted from an open-weight LLM, that emits semantic-ID tokens to generate product candidates for both personalized search and recommendation across a catalog of billions. Products are tokenized with RQ-KMeans into three-token semantic IDs (three 8,192-entry codebooks). Training combines joint continued pretraining, upsampling of first-purchase discovery events, RL with an LLM relevance judge (+1.5 OneDCG@10) and multi-teacher distillation from task experts. For serving, LFM2-2.6B was chosen for its 25.5 ms p95, GPU trie-constrained decoding via STATIC cut constraint overhead from 50 ms to about 1 ms, and multi-token prediction replaces autoregressive decoding. In production the model lifted home-feed orders by 7.95% and search OneDCG@10 by 2.1 points.
- GenRecs Tokenization: Transforming Ads Recommendation at Meta with Stable Model Vocabulary
Meta Engineering hardMasterMeta's ads recommender replaces per-item IDs with GenRecs Tokenization, a stable semantic vocabulary. Each ad, product or page is encoded with pre-trained multimodal models, decomposed into subspaces (e.g. residual decomposition) and quantized against learned codebooks into short token sequences, so similar items share tokens. This lets new and tail items inherit what the model learned about related items, enabling cold-start generalization and cross-campaign transfer. Paired with GEM and the Adaptive Ranking Model it delivered a +0.35% conversion lift. Across eight tokenizer versions, intrinsic metrics (cluster purity, distribution balance, codebook utilization) correlated with downstream CTR accuracy, so the tokenizer can be iterated without full model retraining.
- From Scoring to Spelling: Rebuilding Ads Retrieval at Instacart
Instacart Tech hardMasterInstacart replaced its BERT-based ads retrieval model, which scored every atomic product ID in a fixed vocabulary, with a generative model that autoregressively decodes Semantic IDs (RQ-VAE codeword sequences) via beam search. The goal was to fix vocabulary bottlenecks, cold-start bias toward popular items, and incoherent candidate sets. Prompts combine a retailer-type token, user history SIDs and cart SIDs. SIDs shrink embedding parameters 125x and give new products coverage from day one, while beam width and temperature act as dials between precision and diversity. Serving moved from Python on CPU to a Go service on TensorRT-LLM and Triton. Mean latency dropped 10–17% despite roughly twice the candidates, and A/B tests showed +5% CTR and +34% add-to-carts.
- Advancing Generative Recommendation Inference: our collaboration with NVIDIA on TensorRT LLM
Spotify Engineering hardMasterSpotify consolidated its LLM-based generative recommendation inference onto TensorRT LLM, working with NVIDIA to add the features it had been splitting across engines. vLLM handled beam search for semantic-ID candidate generation, but its beam search runs outside the core GPU engine and recomputes partially filled KV blocks. SGLang supplied multi-item candidate scoring, and personalization came from soft tokens that project existing user embeddings into the LLM's embedding space. The upstream additions were multi-sequence beam search, out-of-tree models for a custom Qwen3 soft-token plugin, embedding injection and multi-item scoring, which cut costs on Qwen3 1.7B by up to 54% for beam search and 7% for scoring.
- Meta’s Generative Ads Model (GEM): The Central Brain Accelerating Ads Recommendation AI Innovation
Meta Engineering hardMasterGEM is Meta's LLM-scale foundation model for ads recommendation, trained on thousands of GPUs and used as a teacher to improve hundreds of downstream vertical ranking models; it lifted ad conversions 5% on Instagram and 3% on Facebook Feed. The architecture handles non-sequence features with an extended Wukong design (stackable factorization machines), long user-behavior sequences with a pyramid-parallel structure, and cross-feature learning with InterFormer, plus multi-domain learning across surfaces, for 4x the efficiency of earlier ranking models. Knowledge reaches downstream models through direct and hierarchical transfer that combines distillation with a Student Adapter for stale supervision, representation learning and parameter sharing, which Meta reports as 2x as effective as standard distillation. A rebuilt training stack (HSDP for dense layers, 2D sharding of embedding tables, jagged-sequence kernels, FP8 activations, SM-free NCCLX collectives, compile caching) delivered 23x effective FLOPs with 1.43x MFU on 16x more GPUs.