hora wasm
1.0.0
[首頁] [文件] [範例] [Hora]
以WebAssembly方式對Hora Approximate Nearest Neighbor Search
進行 Javascript 競價。
表現出色⚡️
多索引支持
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 的簡單實作)可靠性
Rust
編譯器保護所有程式碼Rust
為所有語言庫(例如Python lib
管理的內存多距離支援?
Dot Product Distance
Euclidean Distance
Manhattan Distance
Cosine Similarity
有成效
作者aws t2.medium (CPU: Intel(R) Xeon(R) CPU E5-2686 v4 @ 2.30GHz)
更多信息
npm i horajs
import * as horajs from "horajs" ;
const demo = ( ) => {
const dimension = 50 ;
var bf_idx = horajs . BruteForceIndexUsize . new ( dimension ) ;
// var hnsw_idx = horajs.HNSWIndexUsize.new(dimension, 1000000, 32, 64, 20, 500, 16, false);
for ( var i = 0 ; i < 1000 ; i ++ ) {
var feature = [ ] ;
for ( var j = 0 ; j < dimension ; j ++ ) {
feature . push ( Math . random ( ) ) ;
}
bf_idx . add ( feature , i ) ; // add point
}
bf_idx . build ( "euclidean" ) ; // build index
var feature = [ ] ;
for ( var j = 0 ; j < dimension ; j ++ ) {
feature . push ( Math . random ( ) ) ;
}
console . log ( "bf result" , bf_idx . search ( feature , 10 ) ) ; //bf result Uint32Array(10) [704, 113, 358, 835, 408, 379, 117, 414, 808, 826]
}
( async ( ) => {
await horajs . default ( ) ;
await horajs . init_env ( ) ;
demo ( ) ;
} ) ( ) ;
整個儲存庫均遵循 Apache 許可證。