Shopify’s generative discovery model
Shopify 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.
Related posts
- The generative recommender behind Shopify's commerce engine
Shopify Engineering hardMasterShopify 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.
- 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.
- 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.
- Semantic IDs: Product Understanding at Scale
Instacart Tech hardMasterInstacart compresses product text embeddings into 4-level semantic IDs using a residual vector quantizer (RQ-VAE), so products with related meaning share code prefixes across taxonomy branches (e.g., Italian cheeses, olives and tapenades under 6_19). A contrastive regularizer (λ=0.01) uses catalog-tree distance as supervision, with hierarchical batch sampling, which helps cold-start products that lack engagement data. Two embedding flavors serve different needs: ESCI for precise substitution and search, and Gemini-extracted attributes embedded with Gemma for broader discovery. Intrinsic evaluation (similarity-depth correlation of 0.69–0.84, LLM cluster scoring, taxonomy alignment) showed failures from sparse product text and exposed mislabeled catalog items. Generative retrieval over the ~2,000-token code vocabulary delivered +34% add-to-carts on carousels.
- Our Early Journey to Transform Instacart’s Discovery Recommendations with LLMs
Instacart Tech mediumAdeptInstacart rebuilt its Shopping Hub discovery recommendations around a top-down, cascaded LLM pipeline. It first generates personalized page themes, then taxonomy-grounded retrieval keywords, then applies quality and diversity filtering, and finally hands off to existing product and pagewise ranking services. Keyword generation uses a teacher-student fine-tuned open-weight model (Llama/Qwen with LoRA ablations). It also uses RAG that prunes a 300,000-term keyword corpus to about 100 nearest neighbors per theme, which cut generation costs 15–20%. Quality is enforced through embedding-based deduplication, LLM-as-a-judge evaluators calibrated with human-in-the-loop data, and a fine-tuned cross encoder for theme-product relevance at scale.