Skip to content

In development. Expect rough edges and changes. The source code is not public yet.

Shopify Engineering 5 min read Case study easyNovice

Building world-class product search at Shopify: Where C++ excellence meets ML innovation

Shopify's product search runs ML ranking models (transformers, neural rankers, CatBoost/LightGBM) at native C++ speed through RankFlow, a Python-like ranking DSL, and TurboDSL, its execution engine. Data scientists write and deploy ranking modules in minutes without C++ expertise, while the runtime provides type safety, compile-time validation, vectorized execution and predictable latency. The team first shipped a simple engine (SimScorerDSL) that compiles DSL to C++ in about four weeks, then built TurboDSL behind the same syntax for a 48% speedup in ranking feature computation. Every PR gets an automated per-component latency analysis with significance testing at ±2% tolerance.

Assumes: search ranking basicsgradient boosted trees

Related posts

  • How Shopify improved consumer search intent with real-time ML

    Shopify Engineering mediumAdept

    Shopify generates about 2,500 text and image embeddings per second (216M/day) in near real time with Google Cloud Dataflow and Apache Beam's RunInference on T4 GPUs, feeding Storefront Semantic Search and a BigQuery warehouse. Cutting Dataflow's per-process worker harness threads from 12 to 4 reduced memory use about 2.6x, from roughly 104GB to 40GB, without hurting GPU-bound throughput. That let the team drop high-memory machines and save 14% in cost. Sharing one model across processes and forcing a single SDK container both hurt throughput too much. Bursty input produced bundles of one element, so in-bundle batching rarely formed real batches, but stateful cross-bundle batching added unacceptable shuffle latency; per-process model copies still keep the GPU saturated.

  • Leveraging multimodal LLMs for Shopify’s global catalogue: Recap of expo talk at ICLR 2025

    Shopify Engineering mediumAdept

    Shopify's Global Catalogue uses fine-tuned open-source vision LLMs (LLaVA 1.5 7B, then LLaMA 3.2 11B, now Qwen2VL 7B) to classify, extract attributes from, standardize and match billions of merchant product listings. The system has four layers: streaming product data with change data capture, multi-task product understanding, graph-based product matching (LSH and embedding candidates, discriminator edge pruning, connected components) and canonical record reconciliation. Training each model to predict a randomly selected subset of fields kept it generalizable and cut median latency from 2s to 500ms and GPU usage by 40%. LLM-agent annotation with an LLM arbitrator, instruction-following eval metrics and active learning driven by low token probabilities support 40M inferences a day on Triton with FP8 quantization.

  • The generative recommender behind Shopify's commerce engine

    Shopify Engineering hardMaster

    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.

  • Shopify’s generative discovery model

    Shopify Engineering hardMaster

    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.

  • Cross-store product clustering across millions of stores

    Shopify Engineering hardMaster

    Shopify groups listings of the same product across millions of stores under a global Universal Product Identifier using a three-stage pipeline: embedding-based approximate nearest-neighbor retrieval to find candidate pairs, tiered pair scorers, and graph clustering. The scorers trade cost for precision. L1 is a GBDT on cheap pair features run over trillions of pairs, L2 is a fine-tuned multilingual E5 cross-encoder over both listings' text, and L3 is an image-aware reranker for selected pairs. All three are trained on LLM-judge labels validated against human annotations. To scale clustering, the graph is split into size-bounded components with a parallelized, score-ordered bounded union-find whose budget is degree-weighted. Within each component, hierarchical agglomerative clustering uses a learned GBDT merge rule built on support, coverage, cohesion and contradiction features, tuned for precision first and trained iteratively on its own policy's decisions.

The quest for software engineering knowledge.

Look:
Layout: