新开源项目 Hora, 一个基于 Rust 🦀 的高速近似最近邻搜索 (ANN)算法库 🚀 ,欢迎围观与参与 (≧∇≦)ノ

2021-08-07 16:55:46 +08:00
 aljun

Hora 是一个近似最近邻搜索算法 (wiki) 库

Hora 完全基于 Rust🦀 实现,事实证明,Rust 确实非常非常快,完全可以媲美 C++ ,且Hora使用 SIMD进行了加速,速度非常快⚡️⚡️⚡️,具体速度可以参考下面的 benchmark.

Hora ,日语为 「ほら」,读法像 [hōlə] ,意思是 Wow, You see! , Look at that! 。 这个名字的灵感来自日本著名歌曲 「小さな恋のうた」

github: https://github.com/hora-search/hora

主页: https://horasearch.com/

Python 库: https://github.com/hora-search/horapy

Javascript 库: https://github.com/hora-search/hora-wasm

Hora 定位上是Rust实现的 ANN 算法库,希望能基于 Rust 本身的优势,能够提供多个安全的语言库,且能部署在任何地方。目前已经能在Linux, macOSWindows以及WebAssembly部署,未来还会支持AndroidIOS以及 嵌入式设备


Demo

这是 Hora 的在线演示(可以在这里找到它,强烈推荐试试速度!! https://horasearch.com/)

👩 Face-Match [online demo], have a try!

🍷 Dream wine comments search [online demo], have a try!

benchmark

Hora 非常快,bench (与 Faiss 和 Annoy 相比)

Usage

安装极为简单: Rust

[dependencies]
hora = "0.1.1"

Python

$ pip install horapy

Javascript (WebAssembly)

$ npm i horajs

Building from source

$ git clone https://github.com/hora-search/hora
$ cargo build

使用上 API 也非常简单:

Python example [more info]

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 {} \nhas neighbors: {}".format(
    target, index, index.search(samples[target], 10)))  # search

我们很欢迎任何参与,欢迎任何贡献,包括文档和测试。 我们使用 GitHub 问题来跟踪 Issue 和 bug,你可以在 github 上进行 Pull Requests 、Issue

最后如果觉得这个项目做的还不错,或者比较感兴趣,或者你们想用的,欢迎在 github 上 star 或者给我们提 issue

github: https://github.com/hora-search/hora

Python 库: https://github.com/hora-search/horapy

Javascript 库: https://github.com/hora-search/hora-wasm

2846 次点击
所在节点    程序员
30 条回复
messense
2021-08-08 12:13:49 +08:00
@aljun 好嘞,也可以先提一下 issue
timpaik
2021-08-08 13:16:11 +08:00
aljun
2021-08-08 13:31:15 +08:00
@timpaik 感谢🙏
honkki
2021-08-08 15:35:05 +08:00
rust🦀 针不戳
aljun
2021-08-08 15:43:50 +08:00
@honkki 其实还是不少坑,比如 Rust 现在的 SIMD 支持就不能算很完善,所以严格来说我 bench 实在 SIMD + nightly ( llvm12 )开启的情况下,才比 Faiss ( openmp + BLAS )有更快的水平(具体速度可以参考上面的 benchmark 图)
zzl22100048
2021-09-13 16:39:02 +08:00
index 怎么做持久化呢
aljun
2021-09-15 00:34:19 +08:00
@zzl22100048 我看你貌似提了个 issue,应该已经找到了对吧
zzl22100048
2021-09-15 08:32:34 +08:00
@aljun 找到了持久化的方法。
build 索引的时候没有进度条,100 多万的 200 维向量花了 8 个小时才构建完,有没有什么加速的方法
aljun
2021-09-20 17:01:48 +08:00
@zzl22100048 好的,感谢建议,我们会完善这块的建设
rpman
2022-06-09 21:47:03 +08:00
原来作者居然混 v2 ,惊了
想知道 ANN 里有没有适合 online 场景 (vector db 存在一定的 CRUD)

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/794292

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX