How it works
e-means (Bessa et al., Meta FAIR, 2026) trains k-means on mini-batches, keeping a moving average of each cluster's statistics, and beats Lloyd's algorithm in a tenth of the passes. h-means keeps its update, its laws for batch and step size, and its revival of dead clusters, and changes two things.
A hierarchical warm start. Half a pass of e-means with k/16 coarse centroids, then each coarse cluster is split into children in proportion to its share of the loss, and the children are placed by two local Lloyd iterations. It costs about a tenth of a pass.
Hartigan's move rule instead of the nearest centroid. A point moves from cluster a to b only if Na/(Na−1)·d²(x,a) > Nb/(Nb+1)·d²(x,b): the exact change of the k-means objective for that one move. Written as one matrix product in d+2 dimensions, it costs the same as a nearest-centroid search. The size factors matter when clusters are small, which is where h-means gains most.
With both switched off, the code is a faithful e-means and matches the official faiss implementation within seed noise. It installs with pip and follows the scikit-learn API.
Results
Training loss of h-means at 5 passes against the better of e-means's two batch laws at 5 passes, on the same number of distance computations, mean of 5 seeds. Negative means h-means is better.
| Points per cluster | h-means vs best e-means |
|---|---|
| 7 to 9 | −4.4% to −6.7% |
| 14 to 20 | −1.6% to −3.2% |
| 30 to 80 | −0.03% to −0.9% |
| 122 and 152 | −2.2%, −0.2% |
| 240 to 480 | tie (±0.03%) |
The datasets are SIFT, GloVe, NYTimes, Fashion-MNIST, Deep (10M rows) and Gaussian mixtures. h-means is below the best e-means on all 16 configurations and every seed, with 3 to 10 times less variation between seeds. At 15 points per cluster or fewer, 3 passes of h-means already reach e-means's 5-pass loss.
Limits
The clear wins are a small-cluster effect: above about 200 points per cluster it ties e-means, and that is the range e-means targets for vector-search indexes. Gains on held-out data are about a fifth of the training gains. The rule that splits the passes between the two modes was set on the same grid the results come from, and the final recipe was picked after seeing three on that grid; only the 10M-row and k-sweep runs came after. Everything ran on one machine (Apple M3 Ultra), and on small problems the untuned code is 2 to 5 times slower than e-means in seconds, though not in operations. The report has every table, ablation and limit.