Meta fair introduces e-means, a clustering algorithm outperforming k-means with significantly fewer iterations
Researchers at Meta FAIR have unveiled e-means, a new clustering algorithm designed as a drop-in replacement for Lloyd's k-means. This method achieves the same loss as Lloyd's k-means after 25 epochs using only between 1.4 and 2.6 epochs. The implementation is available in FAISS version 1.16.0 under faiss.contrib.e_means, targeting the often slow offline clustering step in vector indexing and data pipelines.
e-means operates as a mini-batch k-means variant, updating cluster centroids using exponential moving averages. Testing revealed significant performance gains: a single e-means step processing 512 points took only 0.001 seconds, compared to 0.176 seconds for one Lloyd step touching 100,000 points. Furthermore, e-means demonstrated superior stability, remaining stuck on 0% of starts in a 5-blob toy example, whereas Lloyd got stuck on 46%.
Additional findings highlight e-means' robustness. When dealing with large cluster counts, such as 16,384 on the DEEP dataset, e-means' revival mechanism prevented 0.3% of clusters from dying, contrasting with 26.3% dying when revival was disabled. The authors also noted that plain gradient descent performed worse than EMA, ending 1.6% (DEEP) and 0.4% (SIFT) above EMA in its best configuration.