horapy
1.0.0
[首頁] [文件] [範例] [Hora]
用於Hora Approximate Nearest Neighbor Search
的 Python 綁定
表現出色⚡️
多索引支持
Hierarchical Navigable Small World Graph Index(HNSWIndex)
(詳細)Satellite System Graph (SSGIndex)
(詳細)Product Quantization Inverted File(PQIVFIndex)
(詳細)Random Projection Tree(RPTIndex)
(LSH,WIP)BruteForce (BruteForceIndex)
(使用 SIMD 的簡單實作)便攜的
no_std
(WIP,部分)Windows
、 Linux
和OS X
IOS
和Android
(WI)BLAS
可靠性
Rust
編譯器保護所有程式碼Rust
管理的記憶體多距離支援?
Dot Product Distance
Euclidean Distance
Manhattan Distance
Cosine Similarity
有成效
作者aws t2.medium (CPU: Intel(R) Xeon(R) CPU E5-2686 v4 @ 2.30GHz)
更多信息
pip install horapy
import numpy as np
from horapy import HNSWIndex
dimension = 50
n = 1000
# init index instance
index = HNSWIndex ( dimension , "usize" )
samples = np . float32 ( np . random . rand ( n , dimension ))
for i in range ( 0 , len ( samples )):
# add node
index . add ( np . float32 ( samples [ i ]), i )
index . build ( "euclidean" ) # build index
target = np . random . randint ( 0 , n )
# 410 in Hora ANNIndex <HNSWIndexUsize> (dimension: 50, dtype: usize, max_item: 1000000, n_neigh: 32, n_neigh0: 64, ef_build: 20, ef_search: 500, has_deletion: False)
# has neighbors: [410, 736, 65, 36, 631, 83, 111, 254, 990, 161]
print ( "{} in {} n has neighbors: {}" . format (
target , index , index . search ( samples [ target ], 10 ))) # search
整個儲存庫均遵循 Apache 許可證。