Skip to main content

KEO logo: a ninja cat above three clusters of dots, next to the letters K, E, O

KEO

A reproducible benchmark of k-means, e-means and o-means on data neither method was evaluated on.

What KEO stands for. KEO is named after Keo, the ninja cat from the Ninja Hattori cartoon series, and it spells out the three clustering algorithms the framework compares: K-means, E-means and O-means. In the logo, the masked ninja cat stands over three clusters of points, each with its centroid ringed, and the letters K, E and O use one colour per algorithm, the same colours as every figure.

KEO compares three large-scale clustering algorithms under one protocol, one set of metrics and one result store, and tests whether the headline claims of the e-means and o-means papers hold outside the datasets they were developed on.

Algorithm Summary Source
K k-means (Lloyd) Full-batch alternation of exact assignment and centroid mean update. Lloyd (1982)
E e-means Mini-batch k-means with exponential-moving-average updates, a cosine step schedule, scaling laws for batch size and step size, and dead-cluster revival. Reported to match Lloyd in a fraction of the epochs. Bessa et al., Meta FAIR, 2026
O o-means e-means with a two-level inverted-file index built over the centroids, so each point is compared with a small subset of them instead of all k. Bajaj, Nupur, Garg, 2026

Contents

Research question

Do the reported gains of e-means (matching k-means quality in roughly 1.4–2.6 epochs) and o-means (further reducing assignment cost as k grows) hold on a dataset that was not used to design or tune them, and under what conditions do they break down?

Dataset

GloVe-100: 1,183,514 word vectors in 100 dimensions, with 10,000 provided query vectors, taken from ANN-Benchmarks (glove-100-angular). It appears in neither paper's list of evaluation datasets (checked against those two papers only). Vectors are L2-normalised by default. The download is checksum-verified (SHA-256).

Installation

Requires Python 3.10 or newer (developed and tested on 3.12).

pip install keo

To work on the code, clone the repository and use uv:

git clone https://github.com/rajveer43/keo.git
cd keo
uv sync

Quick start

keo download glove100     # ~460 MB, checksum-verified
keo smoke                 # end-to-end run on a small subset, about 10 seconds
keo figures smoke         # figures in results/smoke/figures/
keo adapters              # which official implementations can run on this machine

From a source checkout, prefix commands with uv run and run the tests with uv run pytest.

Where files go: in a source checkout, data/ and results/ sit next to the code. After pip install, datasets are cached in ~/.cache/keo/data and results are written to ./results in the directory you run from. Set KEO_DATA_DIR, KEO_RESULTS_DIR or KEO_CONFIGS_DIR to override.

Run a configured experiment, or preview it first:

keo run <name-or-path.yaml> --dry-run
keo run <name-or-path.yaml>
keo status <name>
keo figures <name> --theme both

Each result cell is stored under a content hash of its configuration, so an interrupted run resumes where it stopped and completed cells are never recomputed.

Method

Two implementations, never mixed. Every algorithm exists twice:

  • reference: our own PyTorch (CPU) implementation, written from the papers.
  • official: the authors' released code (Faiss contrib/e_means and related adapters), run in an isolated worker process.

Each result row records which one produced it. Quality is compared across both; wall-clock time is compared only within one implementation.

Metrics.

  • MSE: mean squared L2 distance to the assigned centroid, computed with exact assignment in float64, on both training and held-out points.
  • Relative MSE (the gap): error relative to k-means run for 25 iterations from the same starting centroids and seed.
  • Cluster health: dead clusters (fewer than 10 points), empty clusters, and the Faiss imbalance factor.
  • Cost: counted distance computations, split into assignment and index maintenance, reported both as actually performed and as the nominal cell arithmetic. This is hardware independent.
  • Wall-clock fit time, within one implementation only.

e-means recipe. recipe="official" (default) uses the constants shipped in the official code; recipe="paper" uses the values in the paper text. The two differ slightly. All headline results use official.

Figures. Six figures are generated from the stored result rows, each with a CSV of exactly the plotted numbers and a light and dark variant. Headlines are computed from the data rather than written by hand. See docs/FIGURES.md.

Project status

Phase Scope State
0–2 Specification, data pipeline, metrics, k-means Complete
3–4 e-means and o-means reference implementations Complete
5 Adapters for the official implementations Complete
6 Result store, resumable runner, figures Complete
7 Main run on the full grid Not started
8 Analysis and report (keo analyze, keo report) Not started; commands are stubs
9 Ablations, scaling-law transfer, secondary track Not started
10 Hardening and packaging Not started

The test suite has 179 tests, all passing. The smoke experiment (26 cells) runs cleanly end to end.

Implementation agreement. On GloVe subsets, our e-means matches the official implementation within about 0.2% on held-out error. The remainder is most likely remainder-batch handling (see assumptions A2 and A52 in docs/ASSUMPTIONS.md); this has not been isolated.

No benchmark results are claimed yet. Numbers visible in results/smoke/ come from two repeats at k = 512 and exist to verify the pipeline, not to answer the research question.

Limitations

  • o-means is partly reconstructed. Its paper is unreleased, so our version is built from the project page and every unspecified detail is a recorded assumption. Conclusions about o-means describe this reconstruction.
  • No GPU in the reference environment. Wall-clock claims from the papers concern GPU execution and cannot be tested on the development machine (Apple M4, CPU only). Quality and operation counts can be.
  • CPU time is not representative for o-means. Index maintenance is cheap on a GPU and relatively costly on a CPU, so CPU wall-clock should not be read as a verdict on the method.
  • One dataset so far. Findings are about GloVe-100 and will not necessarily transfer.
  • Dataset novelty is a bounded claim. GloVe-100 was checked against the two papers' dataset lists, not against all prior work.

License

Code is released under the MIT License. The GloVe vectors are not redistributed; they are downloaded from ANN-Benchmarks and remain under their own terms.

Documentation

File Contents
docs/SPEC.md Algorithms, formulas and experimental protocol, tied to the source papers
docs/ASSUMPTIONS.md Register of every point where the papers were silent, and the decision taken
docs/FIGURES.md What each figure answers, how it is built, and the palette validation record
docs/MASTER_PROMPT.md The original build brief (archived; has since diverged)

docs/ is excluded from version control (see .gitignore) and is kept locally.

Repository layout

configs/         Dataset and experiment definitions (YAML)
src/keo/
  algos/         k-means, e-means, o-means, scaling laws, revival, IVF cells; adapters/ for official code
  bench/         Experiment schema, resumable runner, result store, provenance
  metrics/       MSE, gap, cluster health, operation counting
  analysis/      Figure generation
  data/          Download, verification, preparation
tests/           Unit tests and per-phase gate tests
results/         Run outputs (smoke, exploratory)
docs/            Specification, assumptions, figure guide (local only)

References

  • e-means: Bessa et al., e-means: outperforming k-means (in one-tenth the epochs). arXiv:2611.09501 · project page · code in Faiss contrib/e_means
  • o-means: Bajaj, Nupur, Garg, o-means: index the centroids, don't scan them. Project page, November 2026; paper not yet released.
  • Flash-KMeans (GPU k-means baseline): arXiv:2603.09229
  • Faiss: Douze et al., The Faiss library. arXiv:2401.08281
  • VQ-VAE (origin of the moving-average update): van den Oord et al. arXiv:1711.00937
  • ANN-Benchmarks: Aumüller et al. arXiv:1807.05614 · GloVe: Pennington et al. nlp.stanford.edu/projects/glove · VIBE: arXiv:2505.17810
  • Classics: Lloyd (1982); Arthur and Vassilvitskii, k-means++ (2007); Sculley, Web-scale k-means clustering (2010)

Metadata

Release files for keo 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for keo 0.1.0
File Size Uploaded Provenance Actions
keo-0.1.0.tar.gz 82.6 kB Without provenance Details for keo-0.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for keo 0.1.0
File Interpreter ABI Platform Actions
keo-0.1.0-py3-none-any.whl Python 3 none any Details for keo-0.1.0-py3-none-any.whl

Total release size: 155.4 kB

Release files / keo-0.1.0.tar.gz

Download URL keo-0.1.0.tar.gz
Size 82.6 kB
Tags Source
SHA-256 checksum
How to use checksums
a02022bf264dabcedae417dd50f832b0acfb55b2b26cccd1e0a8c46a432af392
BLAKE2b-256 checksum
How to use checksums
2f9e6163c6844cd93ac7b97820bd9d043b83873c8f6774d18311b9141f63cb0a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.13.8 {"installer":{"name":"uv","version":"0.13.8","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / keo-0.1.0-py3-none-any.whl

Download URL keo-0.1.0-py3-none-any.whl
Size 72.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
82ac56b828fc50712ad8971130f191ac35ab2898f223d68b96f58320bed1919c
BLAKE2b-256 checksum
How to use checksums
c1452970dec2b98b539967bf7c89603edc323d9cb071fbf6a34bf4266e66301e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.13.8 {"installer":{"name":"uv","version":"0.13.8","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Security for keo 0.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page