---
title: "Clustering billions of products for agentic commerce with Catalog API"
description: "Shopify's Catalog groups billions of merchant product listings under Universal Product Identifiers (UPIs) using a precision-first pipeline."
url: "https://swe.quest/articles/clustering-billions-of-products-for-agentic-commerce-with-catalog-api-20619778c8b2f613"
canonical: "https://shopify.engineering/catalog-clustering"
source: "Shopify Engineering"
published: "2026-06-17"
difficulty: "medium"
kind: "Case study"
reading_minutes: 13
tags: ["llms","ecommerce","vector-search","algorithms","evals"]
---

# Clustering billions of products for agentic commerce with Catalog API

A post on [Shopify Engineering](https://swe.quest/sources/shopify.md), published 2026-06-17, 13 min read, Case study. Original: [https://shopify.engineering/catalog-clustering](https://shopify.engineering/catalog-clustering)

## Summary

Shopify's Catalog groups billions of merchant product listings under Universal Product Identifiers (UPIs) using a precision-first pipeline. It sets a hard precision threshold and maximizes recall under it, because a wrong merge is worse for buyers than a missed variant. A singleton detector parses Liquid theme code and resolves most shops deterministically. The remaining catalogs are pre-chunked with HNSW/FAISS nearest-neighbor graphs and sparse UPGMA average linkage (distance threshold 0.25, max 200 products per chunk). A two-stage LLM pipeline then extracts brand and model strings using a 'core value proposition' test, and a second critique pass flags outliers in each proposed cluster. Dynamically generated strict JSON schemas, with one required property per product ID, guarantee every product is labeled without skips or malformed output.

Written by swe.quest, not by the author.

**Difficulty:** Medium: assumes a working developer; shows how it is built or done

## Topics

- [LLMs](https://swe.quest/tags/llms.md) (AI & ML)
- [E-commerce](https://swe.quest/tags/ecommerce.md) (Domains)
- [Vector search](https://swe.quest/tags/vector-search.md) (Data & databases)
- [Algorithms](https://swe.quest/tags/algorithms.md) (Architecture & design)
- [Evaluation](https://swe.quest/tags/evals.md) (AI & ML)

## Prerequisites

- LLM prompting ([easy posts on LLMs](https://swe.quest/tags/llms.md?difficulty=easy))
- embeddings and cosine similarity ([easy posts on RAG & retrieval](https://swe.quest/tags/rag.md?difficulty=easy))
- hierarchical clustering
- precision and recall

## Keywords

Shopify Catalog API, Universal Product Identifier, FAISS, HNSW, UPGMA, OpenAI Structured Outputs, Liquid

## Related posts

- [Cross-store product clustering across millions of stores](https://swe.quest/articles/cross-store-product-clustering-across-millions-of-stores-c9b1fdcfbed466c6.md): Shopify Engineering · 2026-10-20 · Hard · 13 min read · Machine learning, E-commerce, Vector search, Algorithms, LLMs
  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.
- [Beyond classification: How AI agents are evolving Shopify's product taxonomy at scale](https://swe.quest/articles/beyond-classification-how-ai-agents-are-evolving-shopify-s-product-taxonomy-at-4a4993e179b43e33.md): Shopify Engineering · 2025-10-09 · Easy · 10 min read · AI agents, LLMs, E-commerce, Evaluation
  Shopify maintains its 10,000+ category, 2,000+ attribute product taxonomy with a multi-agent LLM system.
- [Evolution of Product Classification at Shopify: From Categories to Comprehensive Product Understanding](https://swe.quest/articles/evolution-of-product-classification-at-shopify-from-categories-to-comprehensive-f7af0d3e764e6a0d.md): Shopify Engineering · 2025-05-08 · Medium · 8 min read · Inference & serving, Machine learning, E-commerce, LLMs, ML platforms
  Shopify's product classification evolved from a 2018 TF-IDF logistic regression model through a 2020 multi-modal classifier to a Vision Language Model system built on the Shopify Product Taxonomy, which covers over 10,000 categories and 1,000+ attributes.
- [Leveraging multimodal LLMs for Shopify’s global catalogue: Recap of expo talk at ICLR 2025](https://swe.quest/articles/leveraging-multimodal-llms-for-shopify-s-global-catalogue-recap-of-expo-talk-at-5a595806db6311fb.md): Shopify Engineering · 2025-07-16 · Medium · 11 min read · LLMs, E-commerce, Model training, Inference & serving, Evaluation
  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.
- [Understanding Etsy’s Vast Inventory with LLMs](https://swe.quest/articles/understanding-etsy-s-vast-inventory-with-llms-1fa28367e98029f1.md): Etsy Code as Craft · 2025-10-13 · Medium · 7 min read · LLMs, Evaluation, E-commerce, Search, Data pipelines
  Etsy extracts structured product attributes such as color, material and dimensions from unstructured listing titles, descriptions and photos using LLMs.

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)
