How Shopify improved consumer search intent with real-time ML
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.
Related posts
- Building world-class product search at Shopify: Where C++ excellence meets ML innovation
Shopify Engineering easyNoviceShopify'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.
- Introducing the Hugging Face Embedding Container for Amazon SageMaker
Hugging Face mediumAdeptThe Hugging Face Embedding Container for Amazon SageMaker, built on Text Embedding Inference (TEI), is now generally available for deploying open embedding models such as Snowflake Arctic Embed and BGE. TEI uses token-based dynamic batching, Flash Attention and Candle, and ships separate CPU and GPU images. A walkthrough with the sagemaker Python SDK covers retrieving the image URI, deploying snowflake-arctic-embed-m-v1.5 and load testing it. In the test, embedding ~1M tokens took about 841s (~5 req/s, 2s latency) on a ~$150/month CPU instance versus about 30s (~130 req/s, 4ms latency) on an ml.g5.xlarge A10G GPU at $1.408/hour. The recommendation is GPUs for bulk embedding and CPUs for low-cost endpoints.
- Boost your throughput with dynamic batching
Modal mediumAdept
Modal added a `@modal.batched()` decorator that groups incoming requests into batches flushed when either `max_batch_size` is reached or `wait_ms` elapses, avoiding the unbounded waits of fixed-size batching. Batching helps GPU inference because model weights (over 6 GB for Whisper large v3) must be moved from memory to compute units per pass, and inference is usually memory-bandwidth bound. On an A10G, batching Whisper with a max batch size of 64 raised throughput from about 1.2 to 3.3 requests per second per container, cutting inference cost by roughly 65%. The function only needs to accept and return lists.
- Leveraging multimodal LLMs for Shopify’s global catalogue: Recap of expo talk at ICLR 2025
Shopify Engineering mediumAdeptShopify'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.
- Benchmarking Text Generation Inference
Hugging Face mediumAdeptText Generation Inference ships a benchmarking tool that profiles LLM serving across batch sizes, plotting throughput against latency separately for prefill and decode so deployments can be tuned for a workload such as RAG or chat. Using a duplicable Hugging Face Space bundling TGI with JupyterLab, the walkthrough shows how to read the charts. Vertical regions mean added batch size buys throughput at no latency cost. Horizontal regions mean the server is compute bound: in the example, decode latency stayed flat near 5.3s up to batch 32, while prefill beyond 32 doubled TTFT with no throughput gain. The recommended loop is to benchmark on hardware matching production, adjust TGI launch settings, and repeat, checking real user token patterns in TGI logs.