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.