Skip to content

A lightweight, header-only C++20 library for highly optimized numeric top-k selection

License

Notifications You must be signed in to change notification settings

qieqieplus/fast_topk

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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.

About

A lightweight, header-only C++20 library for highly optimized numeric top-k selection

Resources

License

Stars

Watchers

Forks

Releases

No releases published