Amazon's library for when your label space is absurdly large
PECOS finds the 10–100 relevant items from 100 million candidates without melting your servers.

What it does PECOS is Amazon’s framework for extreme multi-label ranking and classification — problems where the output space is comically large (think 100 million labels). It trains hierarchical models that recursively narrow down candidates, then ranks the survivors. The core C++ inference path is built for real-time serving, and there’s a Transformer-based variant (XR-Transformer) that fine-tunes Hugging Face models for the same task.
The interesting bit The hierarchy trick is the whole game: instead of scoring every label, PECOS builds a label tree and learns linear models that traverse from root to promising leaf clusters. It’s old-school divide-and-conquer dressed up for modern scale. The ANN module (HNSW with SIMD optimizations) is a nice bonus for dense/sparse retrieval, though it’s presented as a supporting player rather than the main event.
Key highlights
- X-Linear: recursive linear models with C++ inference, handles 100MM output space
- XR-Transformer: SotA on public XMC benchmarks, plugs into Hugging Face ecosystem
- HNSW ANN search with SIMD-optimized distance computation for sparse and dense features
- Thread-safe parallel graph construction and inference searchers
- Apache 2.0 licensed, pip-installable as
libpecos
Caveats
- Platform support is narrow: Ubuntu 20.04/22.04 and Amazon Linux 2 only
- The “general-purpose framework” claim is aspirational — the README examples and papers are almost entirely XMC/text classification flavored
Verdict Worth a look if you’re serving extreme multi-label models at scale and need the C++ speedup. Skip it if your label space is merely large (thousands, not millions) — you probably don’t need the complexity.