cs.LGJul 22, 2026

Efficient Clustering with Provable Guardrails for LLM Inference at Scale

Authors: Longshaokan WangWai Tsang KeungPunit GhodasaraRoman WangAli DashtiFrancesc Moreno-Noguer

Organizations: Amazon

Abstract

Scaling LLM-based applications to millions of users is bottlenecked by the inference cost and latency of modern foundation models. A natural fix is to cluster the inputs and call the LLM only on cluster representatives, letting other members inherit the output -- but this is only safe if each member is measurably close to its representative. Existing clustering methods do not offer such per-sample quality control at scale: none jointly guarantee a minimal within-cluster similarity, exact matching of categorical attributes, and scalability to tens of millions of samples. We propose a two-stage algorithm that generates initial clusters with Mini-batch K-Means, then greedily selects representatives within each initial cluster -- a step equivalent to the Johnson-Chvatal heuristic for Set Cover over alpha-balls in embedding space. The algorithm enforces the similarity and attribute guardrails exactly by construction, and runs in O(nd+n2d/K)O(nd + n^2 d/K) time and O(nd+n2/K2)O(nd + n^2/K^2) memory for nn samples, feature dimension dd, and KK initial clusters -- linear in nn when KK grows proportionally with nn. We provide benchmarks against common clustering methods on internal and public datasets: our method not only delivers per-sample guardrails but also runs 10-1000x faster and scales to data sizes where most standard methods become intractable. Deployed on 38 million customers for a persona-based recommender, the clustering method cut downstream cost and latency by 50-fold while preserving personalization and unblocked the production launch.

Explore similar work

CardsList
  1. RAILS: Retrieval-Augmented Incremental LLM Clustering at Scale

    Sep 21, 2026Armin Oliya, Aleksandra Sawczuk, Radosław BiałobrzeskiReranking

  2. Cluster, Route, Escalate: Cascaded Framework for Cost-Aware LLM Serving

    Jun 25, 2026Yasmin Moslem, Magdalena Kacmajor, Vasudevan Nedumpozhimana +11Large Language Model ServingEscalation