e-means: outperforming k-means (in one-tenth the epochs)
Abstract: Lloyd's k-means algorithm is a long-running standard for clustering, with applications in data analysis, retrieval, quantization and data curation. In this paper, we introduce an exponential moving average optimization procedure for k-means with mini-batch updates, powered by modern deep learning machinery and new insights. We also establish scaling laws on how decay rate and batch size impact final performance. This gives us a formulaic rule to fix them for multiple problem sizes and embedding datasets, without the need for any hyperparameter sweep. The resulting clustering algorithm, coined e-means, is much faster than Lloyd k-means and converges to lower losses, frequently even beating k-means++. On a wide array of embeddings datasets, it beats the loss of Lloyd k-means at 25 epochs in 1.4 to 2.6 epochs, which translates to 10-45x GPU wall-clock speedups compared to state-of-the-art k-means implementations. As an example, e-means partitions DINO10B, a dataset of 10 billion DINO embeddings, into 16 million clusters in only 2.5 epochs, reaching a loss below Lloyd's at 25 epochs.
Paper Prompts
Sign up for free to create and run prompts on this paper.
Explain it Like I'm 14
1. What is this paper about?
This paper introduces a new version of the -means clustering algorithm, called e-means.
Clustering means putting similar things into groups. For example, a music app might group songs with similar sounds, or a photo app might group images with similar visual features.
The usual -means algorithm can work well, but it may be slow when there are millions or billions of data points. The authors want to make clustering:
- much faster,
- just as accurate or more accurate,
- easier to use without lots of trial and error.
Their main claim is that e-means can reach better results in only about one-tenth of the training time needed by common versions of -means.
2. What questions are the researchers asking?
The paper mainly investigates these questions:
- Can -means be made faster without losing accuracy?
- Can a faster method find better groups than the standard algorithm?
- Can the method automatically choose its settings, such as the batch size, without users testing many different options?
- Does the method still work on extremely large datasets, including billions of data points?
The authors compare e-means with well-known methods such as:
- Lloyd’s -means, the traditional full-dataset method,
- mini-batch -means, which uses smaller pieces of data,
- -means++, which tries to choose better starting points,
- fast computer implementations designed for CPUs and GPUs.
3. How does the method work?
What normal -means does
Suppose we have many points representing things such as images or pieces of text. Each point is described by numbers. These numbers are called a vector.
The standard -means algorithm chooses group centers, called centroids. It then repeats two steps:
- Give each data point to the closest centroid.
- Move each centroid to the average position of the points assigned to it.
You can imagine placing several flags on a map. Each town joins the closest flag, and then each flag moves to the middle of its towns. This repeats until the flags stop moving much.
The problem is that standard -means usually examines the entire dataset again and again. This can be very expensive for huge datasets.
Mini-batches
Instead of looking at every point at once, e-means looks at a smaller group of points called a mini-batch.
This is like estimating the average opinion of an entire school by asking a smaller group of students. It is faster, but if the updates are handled badly, the estimates can become noisy or inaccurate.
Exponential moving averages
E-means uses an exponential moving average, or EMA, to update each centroid.
An EMA gives more weight to recent information while still remembering older information. For example, when tracking the average temperature, today’s temperature might matter more than the temperature from several weeks ago.
For e-means, each centroid is updated gradually using the points in the current mini-batch. The researchers also make the updates:
- larger at the beginning, so the centroids move quickly toward useful locations;
- smaller later, so the centroids become stable.
This is similar to learning to ride a bicycle: at first, you make large corrections, but once you are balanced, you make smaller corrections.
Fixing unused clusters
Sometimes a centroid receives no points. It then becomes a dead cluster and stops being useful.
E-means regularly checks for these dead clusters. When it finds one, it creates a new centroid by splitting a useful existing cluster. This gives the unused cluster another chance to become helpful.
Automatically choosing settings
Algorithms often have settings called hyperparameters. For e-means, important examples include:
- the mini-batch size,
- how quickly old information is forgotten,
- how many passes are made through the data.
The authors run many experiments and find scaling laws. These are formulas that predict good settings based on the size of the dataset and the number of clusters.
This means users generally do not need to test many settings manually.
Measuring quality
The researchers mainly use mean squared error, or MSE. In simple terms, this measures how far each data point is from the center of its assigned group.
A smaller MSE means that points are, on average, closer to their group centers. Therefore, lower MSE usually means better clustering.
They also test the algorithms on separate data that was not used during training. This checks whether the clusters work well for new data, not just the data used to create them.
4. What did the researchers find?
The experiments used many datasets, including:
- image features,
- text features,
- search and recommendation data,
- datasets ranging from about one million to ten billion vectors.
The main findings were as follows.
E-means was much faster
E-means often reached the quality of standard -means after only 1.4 to 2.6 passes through the data.
The comparison methods were allowed around 25 passes. This means e-means often needed far less work.
Compared with fast existing GPU implementations, e-means achieved speedups of approximately:
- 10 times in some experiments,
- up to about 45 times in the largest speed comparisons.
E-means usually produced better clusters
E-means did not only reach similar quality faster. It often reached a lower final error than standard Lloyd -means, including versions using -means++ starting points.
In every main dataset comparison described in the paper, e-means eventually produced better results than the standard approaches.
The method worked without manual tuning
The scaling laws were learned using one dataset and then tested on other datasets. They generally worked well on these new problems.
This is important because a method that is fast only after careful testing may be difficult for other researchers and companies to use. E-means aims to provide good settings automatically.
It worked at enormous scale
The authors tested e-means on a dataset containing 10 billion image embeddings and used it to create 16 million clusters.
At this size, comparing every data point with every possible cluster would be extremely expensive. The researchers therefore also used an approximate search method called IVF.
IVF divides centroids into smaller groups, or buckets. Instead of checking every centroid, each data point checks only the most promising buckets. This saves a large amount of computation.
5. Why are these results important?
Clustering is used in many technologies, including:
- image and video search,
- organizing large collections of documents,
- recommendation systems,
- data compression,
- computer vision,
- artificial intelligence systems,
- search indexes.
Modern AI systems often create huge numbers of vectors to represent images, text, or other information. Grouping these vectors can help computers search and store information more efficiently.
If clustering can be done 10 to 45 times faster, then researchers and companies could:
- process much larger datasets,
- reduce the cost of using GPUs,
- build search systems more quickly,
- update clusters more often,
- make large-scale AI applications more practical.
Conclusion
The paper presents e-means, a faster and more carefully designed version of mini-batch -means. It updates group centers using recent data, gradually reduces the size of its updates, revives unused clusters, and automatically chooses important settings using formulas learned from experiments.
The results suggest that e-means can produce clusters that are at least as good as those from standard -means—and often better—while using far less time and computing power.
In simple terms, the paper shows that computers may be able to organize enormous collections of data faster, more accurately, and with less manual setup. This could be especially useful as datasets continue to grow to billions or even trillions of data points.
Practical Applications
Immediate Applications
The paper’s results make e-means directly applicable wherever large-scale vector quantization, clustering, indexing, or compression is currently performed with Lloyd-style k-means.
- Large-scale vector clustering for search and recommendation systems (information retrieval, recommender systems, enterprise search)
- Potential workflow: embed data → train centroids with
e-means→ assign vectors to centroid lists → query only nearby lists. - Expected benefit: the reported 9.5–45.5× GPU wall-clock speedups can reduce index-building time and make more frequent re-indexing practical.
- Dependencies: embeddings should be reasonably compatible with squared Euclidean distance; sufficient GPU memory and an efficient assignment kernel are needed. Quality should be validated with recall or downstream retrieval metrics, not MSE alone.
- Potential workflow: embed data → train centroids with
- Construction of massive IVF indexes (search infrastructure, vector databases, cloud platforms)
- Potential products: faster offline index builders, automated centroid retraining services, and low-cost vector-search indexing pipelines.
- Dependencies: IVF introduces approximate assignment and may reduce recall or alter convergence; the number of probed buckets must be tuned for the target latency–recall tradeoff.
- Embedding compression and quantization (machine learning infrastructure, storage, edge AI)
- Potential workflow: train
e-meanscodebooks → map each vector to a centroid ID → store IDs, residuals, or quantized centroids. - Dependencies: compression quality depends on the number of clusters, embedding dimensionality, and whether residual quantization is added. The paper evaluates MSE, so downstream task degradation must be measured separately.
- Potential workflow: train
- Compression of neural-network intermediate representations (deep-learning systems, LLM serving)
- Potential tools: offline codebook training, cluster-based KV-cache storage, centroid-based attention pruning, and memory-aware inference runtimes.
- Dependencies: the paper does not directly evaluate language-model perplexity, generation quality, or latency. Additional experiments are required to establish acceptable distortion and to handle sequentially evolving distributions.
- Faster vector-quantized model training (generative modeling, audio, vision)
- Potential benefit: more active codebooks, fewer unused tokens, and faster codebook adaptation during training.
- Dependencies:
e-meansis designed for a fixed dataset, whereas many VQ models learn under a moving representation distribution. The update rule therefore needs validation in end-to-end backpropagation settings.
- Data curation and deduplication at embedding scale (content platforms, dataset management, AI governance)
- Potential workflow: embed records → cluster with
e-means→ inspect cluster sizes and representatives → select balanced or diverse subsets. - Dependencies: cluster interpretability is not guaranteed, and squared-distance clusters may not correspond to semantic categories. Human review or task-specific evaluation remains necessary.
- Potential workflow: embed records → cluster with
- Image segmentation and visual organization (computer vision, digital asset management)
- Dependencies: results depend heavily on the upstream feature extractor; clustering raw pixels or low-dimensional features may not produce useful semantic groups.
- Academic and industrial benchmarking of scalable clustering (research, HPC, software engineering)
- Dependencies: reported performance is hardware- and implementation-dependent, particularly on H100 GPUs, BF16/FP8/INT8 kernels, and highly parallel assignment operations. Independent reproduction on other accelerators is needed.
- Automatic hyperparameter selection for production clustering jobs (MLOps, data engineering)
- Dependencies: the laws were fitted primarily on high-dimensional embedding datasets and are less reliable for tiny, low-dimensional, or unusual datasets. A small validation run should be retained as a safeguard.
- Resource and energy savings in data centers (cloud computing, sustainability)
- Dependencies: the practical environmental benefit depends on whether faster clustering leads to reduced total workload or simply enables more frequent retraining. Full system-level energy measurements are not provided in the paper.
Long-Term Applications
The following uses are plausible extensions but require further research, broader validation, or integration with downstream systems.
- Real-time or continuously updated clustering under distribution shift (streaming analytics, fraud detection, IoT, monitoring)
- Potential products: continuously refreshed customer segments, online anomaly buckets, adaptive IoT state representations, and evolving document indexes.
- Dependencies: the paper targets a fixed dataset, so the decay schedule, revival policy, and finalization strategy must be redesigned for concept drift. Stability–adaptation tradeoffs and deletion policies also need to be studied.
- Healthcare cohort discovery and clinical representation clustering (healthcare, biomedical research)
- Dependencies: clinical clusters require validation for stability, bias, interpretability, and clinical usefulness. Privacy-preserving computation, regulatory compliance, and protection against demographic or institutional confounding are essential. The paper provides no medical validation.
- Financial segmentation and anomaly screening (finance, insurance, compliance)
- Dependencies: cluster assignments should not be treated as automated decisions without interpretability and fairness analysis. Nonstationary financial distributions may require adaptive rather than fixed-data training.
- Robotics and embodied AI memory compression (robotics, autonomous vehicles)
- Potential workflow: encode observations → cluster them into prototypes → retrieve nearby prototypes for planning, localization, or policy conditioning.
- Dependencies: robotics often requires metric properties beyond MSE, including temporal consistency, geometric validity, and safety guarantees. Approximate assignments could be problematic in safety-critical loops.
- Energy-system and industrial monitoring applications (energy, manufacturing, predictive maintenance)
- Dependencies: sensor streams are often low-dimensional, noisy, and nonstationary—the settings where the paper’s scaling laws are explicitly less established. Domain-specific distance metrics and drift-aware updates may be required.
- Large-scale semantic tokenizers and retrieval-augmented generation systems (LLMs, multimodal AI)
- Dependencies: semantic usefulness cannot be inferred from Euclidean MSE alone. Research must evaluate perplexity, factuality, recall, robustness, and sensitivity to rare concepts.
- Distributed and heterogeneous accelerator implementations (systems research, cloud infrastructure)
- Potential tools: a distributed
e-meansservice with automatic choice between exact and IVF assignment based on dataset size and cluster count. - Dependencies: synchronization of centroid statistics, load imbalance caused by uneven cluster populations, and communication costs may reduce the reported single-node speedups.
- Potential tools: a distributed
- Adaptive, data-aware scaling laws (automated machine learning, optimization research)
- Dependencies: the current laws omit dimensionality because its fitted exponent was unstable and were trained mainly on high-dimensional datasets. Robust out-of-distribution calibration is required.
- Hybrid clustering pipelines combining
e-means, coresets, and pruning (large-scale analytics, scientific computing)- Dependencies: interactions between approximation errors may compound. End-to-end evaluations should report not only MSE and GPU time but also retrieval recall, clustering stability, memory use, and total pipeline cost.
- Representative sampling for education, policy, and public-sector datasets (education, government, social science)
- Dependencies: automated grouping can encode social bias, obscure minority populations, or expose sensitive information. Governance frameworks, subgroup coverage metrics, and human oversight are required before operational deployment.
Glossary
- Ablation: An experiment that removes or changes one component of a method to measure its contribution. “Table~\ref{tab:recipe-ablation} ablates every component of the recipe”
- Approximate nearest-neighbor search (ANN): A search technique that finds near-neighbors efficiently without exhaustively checking every candidate. “which can be solved efficiently with approximate nearest-neighbor search”
- Assignment: The process of associating each data point with its nearest cluster centroid. “assigns each point to its nearest centroid”
- Backpropagation: A method for computing gradients through a neural network to update its parameters. “Some autoencoders alternatively use backpropagation on the centroids”
- Batch size: The number of data points processed in one mini-batch update. “ the number of points in a training batch”
- BF16: A 16-bit floating-point format commonly used for efficient deep-learning computation. “we use BF16, FP8, and INT8 for assignment”
- Centroid: A representative point, usually the mean of the data points assigned to a cluster. “The centroids themselves are never stored”
- Clustering: The division of data points into groups according to similarity. “This problem has applications in clustering”
- Codebook: A collection of representative vectors used to encode or quantize data. “codebook learning inside VQ-VAEs being an example”
- Concept drift: A change over time in the statistical distribution of incoming data. “where the incoming data may undergo concept drift”
- Convergence: The process by which an iterative optimization algorithm approaches a stable solution. “The optimization is guaranteed to converge to a local minimum”
- Cosine schedule: A schedule that varies a parameter according to a cosine-shaped function over training. “We anneal on a cosine schedule”
- Dead cluster: A cluster that no longer receives assigned points and is therefore unused. “a cluster can stop receiving points and remain unused, turning into a ``dead centroid''”
- Deduplication: The removal of duplicate data points or records. “with deduplication to avoid contamination”
- Decay rate: A parameter controlling how strongly previous values are retained in an exponential moving average. “The decay rate law.”
- Distance pruning: The elimination of distance calculations that cannot affect the final assignment. “distance-pruning methods, which reduce computation by skipping unnecessary distance calculations”
- Embedding: A numerical vector representation of an object, such as an image or text document. “a dataset of 10 billion DINO embeddings”
- Epoch: One complete pass through the training dataset. “one epoch being a single pass over all training points in random order”
- Exponential moving average (EMA): A weighted running average that gives greater or controlled weight to recent observations. “Our approach, e-means, applies a specialized optimization procedure based on exponential moving average (EMA) updates”
- FLOPs: Floating-point operations, used as a measure of computational work. “The FLOPs in e-means are comparable to Lloyd for each epoch”
- FP8: An 8-bit floating-point numerical format used for compact and efficient computation. “we use BF16, FP8, and INT8 for assignment”
- Held-out set: Data excluded from training and used to evaluate generalization. “For each dataset, we report the MSE on a held-out set.”
- Hyperparameter: A configuration value selected outside the model’s ordinary parameter updates. “e-means requires as little hyperparameter tuning as Lloyd”
- Hyperparameter sweep: A systematic evaluation of multiple hyperparameter settings. “requiring unlike them no hyperparameter sweep”
- Intrinsic dimensionality: The effective number of dimensions needed to describe the structure of data, which may be lower than its ambient dimension. “we don't know the local intrinsic dimensionality of the data”
- IVF index: An inverted-file index that partitions vectors into buckets to accelerate nearest-neighbor search. “we adopt an IVF index”
- K-means++: A centroid-initialization procedure that selects centers with probabilities favoring points far from existing centers. “While k-means++ and scalable k-means++”
- Local minimum: A solution that cannot be improved by small changes, although better solutions may exist elsewhere. “The optimization is guaranteed to converge to a local minimum”
- Mini-batch: A small subset of a dataset used for one optimization update. “updates the centroids from mini-batches rather than from the whole dataset”
- Mean squared error (MSE): The average of the squared distances between data points and their assigned centroids. “The Mean Squared Error (MSE)”
- Meta-centroid: A higher-level centroid used to organize or partition a collection of ordinary centroids. “the centroids are partitioned into buckets defined by meta-centroids”
- Nearest-neighbor search: The task of finding the closest vector or vectors to a query under a distance measure. “Assigning training vectors to their closest centroids is a nearest-neighbor search problem”
- Out-of-distribution (OOD): Referring to evaluation data or configurations drawn from a distribution different from that used for fitting. “OOD designates evaluation on randomly sampled configurations on other datasets”
- Quantization: The representation of continuous values using a limited set of discrete representative values. “with applications in data analysis, retrieval, quantization and data curation”
- Regret: The normalized performance gap between a method selected by a rule and the best available hyperparameter choice. “Regret is the normalized MSE difference between following a law and the best hyper-parameter”
- Scaling law: An empirically fitted relationship describing how an algorithmic quantity changes with problem characteristics. “We also establish scaling laws on how decay rate and batch size impact final performance.”
- Stochastic gradient descent: An optimization method that updates parameters using randomly selected subsets of data. “Both are stochastic gradient descent with a decreasing step”
- Test MSE: Mean squared error measured on data not used for fitting or training. “We report primarily test MSE”
- Throughput: The amount of data or computation processed per unit of time. “The batch size trades off quality against throughput.”
- Train MSE: Mean squared error measured on the data used for training. “The last-epoch mean improves the train MSE”
- Validation MSE: Mean squared error used to select or fit methods and hyperparameters before final testing. “We fit our scaling laws on the validation MSE”
- Vector quantization: The encoding of vectors by replacing them with nearby representatives from a finite codebook. “Many vector-quantized autoencoders maintain their centroid”
- Wall-clock time: The actual elapsed time required to perform a computation. “The wall-clock speedup at that number of epochs.”






