Shopify Engineering Team: Why Search and Recommendation Share a Single Generative Model
Shopify details the architectural decisions behind its shared generative discovery model: encoding billions of products into three-token sequences using semantic IDs, jointly training search and recommendation to mutually enhance each other, and deploying a 2.6B parameter model in production within millisecond-level latency budgets.
In industrial systems, search and recommendation typically follow separate pipelines: search handles explicit queries, while recommendation relies on implicit behavioral signals. The Shopify engineering team proposes a more fundamental observation—that both share the same set of inputs and objectives. A search query provides an explicit signal of intent, whereas recommendation infers intent from browsing and purchasing behavior; yet both require product knowledge and buyer context to identify relevant items. This common foundation makes joint training a natural choice rather than an engineering compromise.
To serve both search and recommendation with a single language model, a shared product vocabulary is essential first. Shopify’s catalog contains billions of products; the raw numeric product ID itself carries no product information, and treating every product as an independent output would create a vocabulary of billions of entries, resulting in extremely sparse training samples. Their solution is the semantic ID: first, an embedding model encodes product content into vector representations, then RQ-KMeans converts these embeddings into discrete three-token sequence codes, with each codebook level containing 8,192 entries. The key effect is that related products share encoding prefixes—for example, products starting with [6001] cover various vests and gilets, while [6001, 5561] further narrows down to padded gilets in different colors. This means that training data for one product can update the shared representation of its neighbors, providing a learning pathway for products with sparse interactions.
Does joint training truly benefit both tasks? Shopify provided ablation experiments to answer this. Removing search data caused recommendation Recall@50 to drop from a baseline of 21.0 to 20.9; removing recommendation data caused search OneDCG@10 to drop from 28.8 to 28.5, and search purchase Recall@10 to drop from 33.4 to 32.6. Both directions showed declines, indicating that shared training indeed produced cross-task gains. The team also found that while supervised fine-tuning teaches the model to reproduce historical samples, accurately predicting the next token does not fully equate to retrieval quality—multiple products can satisfy the same intent, yet training samples only record one observed purchase or click. To address this, they introduced reinforcement learning, using an LLM relevance judge to provide reward signals, which yielded an additional 1.5-point lift in OneDCG@10 for the search task.