---
title: "Shopify’s generative discovery model"
description: "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."
url: "https://swe.quest/articles/shopify-s-generative-discovery-model-99e5ac502d9a8c68"
canonical: "https://shopify.engineering/generative-discovery"
source: "Shopify Engineering"
published: "2026-11-11"
difficulty: "hard"
kind: "Case study"
reading_minutes: 12
tags: ["recommendation-systems","search","llms","inference","model-training"]
---

# Shopify’s generative discovery model

A post on [Shopify Engineering](https://swe.quest/sources/shopify.md), published 2026-11-11, 12 min read, Case study. Original: [https://shopify.engineering/generative-discovery](https://shopify.engineering/generative-discovery)

## Summary

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.

Written by swe.quest, not by the author.

**Difficulty:** Hard: written for specialists in the field

## Topics

- [Recommendations & ranking](https://swe.quest/tags/recommendation-systems.md) (AI & ML)
- [Search](https://swe.quest/tags/search.md) (Backend & APIs)
- [LLMs](https://swe.quest/tags/llms.md) (AI & ML)
- [Inference & serving](https://swe.quest/tags/inference.md) (AI & ML)
- [Model training](https://swe.quest/tags/model-training.md) (AI & ML)

## Prerequisites

- LLM fine-tuning ([easy posts on LLMs](https://swe.quest/tags/llms.md?difficulty=easy))
- retrieval and ranking metrics ([easy posts on Recommendations & ranking](https://swe.quest/tags/recommendation-systems.md?difficulty=easy))
- vector quantization ([easy posts on Inference & serving](https://swe.quest/tags/inference.md?difficulty=easy))
- constrained decoding

## Keywords

semantic IDs, RQ-KMeans, LFM2-2.6B, TensorRT-LLM, STATIC, multi-token prediction, OneDCG@10, Shop app

## Related posts

- [The generative recommender behind Shopify's commerce engine](https://swe.quest/articles/the-generative-recommender-behind-shopify-s-commerce-engine-f5ed1bac0cf956d4.md): Shopify Engineering · 2026-02-25 · Hard · 8 min read · Recommendations & ranking, Model training, Machine learning, E-commerce
  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.
- [From Scoring to Spelling: Rebuilding Ads Retrieval at Instacart](https://swe.quest/articles/from-scoring-to-spelling-rebuilding-ads-retrieval-at-instacart-1eba18ee15c15a7e.md): Instacart Tech · 2026-06-02 · Hard · 13 min read · Recommendations & ranking, Ads, Inference & serving, ML platforms
  Instacart 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.
- [GenRecs Tokenization: Transforming Ads Recommendation at Meta with Stable Model Vocabulary](https://swe.quest/articles/genrecs-tokenization-transforming-ads-recommendation-at-meta-with-stable-model-e3f3b6ea2626a2c2.md): Meta Engineering · 2026-10-19 · Hard · 6 min read · Recommendations & ranking, Ads, LLMs, Machine learning
  Meta's ads recommender replaces per-item IDs with GenRecs Tokenization, a stable semantic vocabulary.
- [Semantic IDs: Product Understanding at Scale](https://swe.quest/articles/semantic-ids-product-understanding-at-scale-cd44ffa781feba70.md): Instacart Tech · 2026-06-02 · Hard · 10 min read · Recommendations & ranking, Machine learning, Model training, E-commerce, Evaluation
  Instacart 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).
- [Our Early Journey to Transform Instacart’s Discovery Recommendations with LLMs](https://swe.quest/articles/our-early-journey-to-transform-instacart-s-discovery-recommendations-with-llms-2b1f0ff7e32d37b4.md): Instacart Tech · 2026-02-26 · Medium · 14 min read · Recommendations & ranking, LLMs, RAG & retrieval, Evaluation, E-commerce
  Instacart rebuilt its Shopping Hub discovery recommendations around a top-down, cascaded LLM pipeline.

Browse: [Latest posts](https://swe.quest/index.md) · [Topics](https://swe.quest/tags.md) · [Sources](https://swe.quest/sources.md) · [Topic map](https://swe.quest/map.md) · [Site guide (llms.txt)](https://swe.quest/llms.txt)
