Skip to content

Latest commit

 

History

History
30 lines (20 loc) · 1.66 KB

README.md

File metadata and controls

30 lines (20 loc) · 1.66 KB

Fast Top-K

License C++20 Header-Only

A lightweight, header-only C++20 library for highly optimized numeric top-k selection, well-suited for vector database applications.

Overview

This fast top-k library adopts codes from Google Research's ScaNN (Scalable Nearest Neighbors) project.

It is refactored as a lean, header-only library with no external dependencies beyond the standard library. Makes it easy to integrate into various projects without the complexity of managing additional dependencies like Bazel, Abseil or TensorFlow, which ScaNN might utilize.

Getting Started

Check test or benchmark as examples.

Performance

Benchmarks

  • CPU: Intel Core i9-9880H @ 2.30GHz
  • Compiler: Apple clang version 16.0.0
  • Sources: fast topk and faiss
  • Other methods, such as torch.topk and std::nth_element, were also benchmarked but showed significantly worse results.

Future Plans

  • GPU accelerated implementation with radix k-th selection.

Acknowledgements

This library benefits from the excellent work done by the Google Research's ScaNN (Scalable Nearest Neighbors) project.