If you run k-means clustering at any meaningful scale, e-means is worth a close look. The method replaces the standard Lloyd's algorithm with mini-batch updates driven by exponential moving averages (EMA), and it reaches a better final loss in roughly 1.2 to 3 epochs — work that Lloyd's typically needs 25 epochs to accomplish. On GPU, that translates to a 10–45× wall-clock reduction against Flash-KMeans; on CPU, 8–15× against Faiss. Critically, it doesn't trade quality for speed: e-means achieves both lower loss and faster convergence simultaneously.
The core insight is that Lloyd's algorithm — the dominant approach since the 1950s — is essentially full-batch optimization applied to one of the few ML problems where that was still considered standard practice. Mini-batch k-means methods have existed since MacQueen's 1967 update rule, but that rule accumulates statistics across the entire training history, meaning early (often poor) centroid assignments continue to influence the final result. E-means instead applies an exponential moving average: each cluster's sum and count decay at rate α, so recent assignments dominate and stale history fades. This is the same update used in VQ-VAE codebook learning, but the authors found it is also highly effective on static datasets when paired with the right supporting components.
A key practical advantage is zero hyperparameter tuning. The batch size B and initial step size α₀ are derived automatically from scaling laws fitted to n (dataset size), k (number of clusters), and T (number of epochs). The fitted laws generalize well to held-out datasets and unseen scales, with median regret under 0.2% versus an exhaustive grid search. Lloyd's algorithm is actually a degenerate special case of e-means — set batch size to the full dataset and α=1 — but the hyperparameter study shows that corner of the search space produces substantially worse results than the diagonal band of optimal (B, α) pairs.

E-means also handles a persistent pain point in mini-batch clustering: dead clusters. When a centroid loses all assigned points, it wastes codebook capacity — increasingly costly as large codebooks become common in modern architectures. Rather than resampling random batch points (the approach used in EnCodec), e-means revives dead clusters by splitting an existing large cluster proportionally by size. On a 1-million-vector DEEP benchmark with k=16,384, this reduces dead clusters from 2,343 (14.3% of the codebook, EnCodec strategy) to just 47 (0.3%), with a corresponding improvement in test MSE.
The local-minima behavior is also meaningfully better. Across toy datasets with deliberately tricky cluster geometries, Lloyd's gets permanently stuck in pathological configurations on 15–46% of random initializations. E-means, starting from identical positions, escapes those traps in early epochs — the stochasticity of mini-batch updates acts as implicit exploration that full-batch methods structurally cannot provide. Additional components round out the method: a cosine-scheduled decay on α, an improved initialization strategy, and a finalization stage that computes each cluster's exact mean over the last epoch for negligible extra cost.
For builders, the practical entry points are clear: anywhere you currently run k-means — vector quantization, embedding compression, codebook training for audio or image models, large-scale data clustering — e-means is a candidate replacement. The auto-scaling laws mean you don't need to re-tune when problem dimensions change. GPU kernels fuse the nearest-centroid assignment step to convert the epoch savings into matching wall-clock gains. The project page at e-means.github.io includes the full algorithmic details and benchmark methodology.
