提出可保证质量的聚类方法,让大模型推理成本降50倍
Efficient Clustering with Provable Guardrails for LLM Inference at Scale

- 先用Mini-batch K-Means分组,再贪心选代表点
- 在3800万用户上使推理延迟和成本降低50倍
- 支持每样本质量控制,适合超大规模生产部署
将基于大模型的应用扩展至数百万用户时,推理成本和延迟成为瓶颈。一种自然解法是聚类输入,仅对聚类中心调用大模型,其余样本复用其输出——但前提是每个样本与中心足够接近。现有聚类方法无法在大规模下同时保证组内相似性最低值、类别属性精确匹配和可扩展性。本文提出两阶段算法:先用小批量K-Means生成初始聚类,再在每组内贪心选择代表点(等价于嵌入空间中alpha-ball上的集覆盖问题的Johnson-Chvatal启发式)。该方法通过构造确保相似性和属性约束完全满足,时间复杂度为$O(nd + n^2 d/K)$,空间复杂度为$O(nd + n^2/K^2)$,当K与n成比例增长时呈线性。在内部及公开数据集上对比常见聚类方法,本方法不仅提供逐样本质量保障,且运行速度提升10-1000倍,可处理大多数方法无法应对的数据规模。在3800万用户的个性化推荐系统中部署后,下游成本和延迟下降50倍,同时保持个性化效果,成功推动产品上线。
原文摘要 · Abstract (English)
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 + n^2 d/K)$ time and $O(nd + n^2/K^2)$ memory for $n$ samples, feature dimension $d$, and $K$ initial clusters -- linear in $n$ when $K$ grows proportionally with $n$. 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.
Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。