Skip to content

Commit 0f6ad75

Browse files
add algo descartes(01AI) (#490)
* add algo descartes(01AI) * Remove the link to Descartes and add it back after the product is released in the future. * add link to descartes * Using the GitHub:https://github.com/xiaoming-01ai/descartes.git
1 parent 708c67f commit 0f6ad75

File tree

5 files changed

+70
-0
lines changed

5 files changed

+70
-0
lines changed

.github/workflows/benchmarks.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ jobs:
3333
- balltree
3434
- bruteforce
3535
- ckdtree
36+
- descartes
3637
- diskann
3738
- dolphinnpy
3839
- elasticsearch

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ Evaluated
4646
* [pgvector](https://github.com/pgvector/pgvector) ![https://img.shields.io/github/stars/pgvector/pgvector?style=social](https://img.shields.io/github/stars/pgvector/pgvector?style=social)
4747
* [RediSearch](https://github.com/redisearch/redisearch) ![https://img.shields.io/github/stars/redisearch/redisearch?style=social](https://img.shields.io/github/stars/redisearch/redisearch?style=social)
4848
* [pg_embedding](https://github.com/neondatabase/pg_embedding) ![https://img.shields.io/github/stars/pg_embedding/pg_embedding?style=social](https://img.shields.io/github/stars/neondatabase/pg_embedding?style=social)
49+
* [Descartes(01AI)](https://github.com/xiaoming-01ai/descartes)
4950

5051
Data sets
5152
=========
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
FROM ann-benchmarks
2+
3+
RUN apt update
4+
RUN apt install -y git cmake g++ python3 python3-setuptools python3-pip libblas-dev liblapack-dev
5+
RUN pip3 install wheel pybind11==2.5.0
6+
7+
WORKDIR /home/app
8+
RUN git clone https://github.com/xiaoming-01ai/descartes.git
9+
RUN pip3 install descartes/descartes-*-linux_x86_64.whl
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
float:
2+
any:
3+
- base_args: ['@metric']
4+
constructor: fng
5+
disabled: false
6+
docker_tag: ann-benchmarks-descartes
7+
module: ann_benchmarks.algorithms.descartes
8+
name: descartes(01AI)
9+
run_groups:
10+
FNG:
11+
args:
12+
M: [32, 64, 96, 128]
13+
L: [128, 256, 320, 384, 448]
14+
S: [1, 2, 3]
15+
query_args:
16+
[
17+
[0, 1, 2, 3],
18+
[10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 150, 200, 250, 300, 350, 400, 500, 600]
19+
]
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
import py01ai
2+
import numpy as np
3+
from ..base.module import BaseANN
4+
import logging
5+
6+
class fng(BaseANN):
7+
def __init__(self, metric, method_param):
8+
self.metric = {"angular": "angular", "euclidean": "square_l2"}[metric]
9+
self.method_param = method_param
10+
self.name = "01ai (%s)" % (self.method_param)
11+
12+
def fit(self, X):
13+
self.index = py01ai.FNGIndex(metric=self.metric, dimension=len(X[0]))
14+
self.index.init(count=len(X),
15+
m=self.method_param["M"],
16+
s=self.method_param["S"],
17+
l=self.method_param["L"])
18+
try:
19+
self.index.add_vector(input=np.asarray(X))
20+
except Exception as e:
21+
print(str(e))
22+
23+
def set_query_arguments(self, ex, ef):
24+
self.search_ef = ef
25+
self.search_ex = ex
26+
self.index.set_query_param(ef=ef, ex=ex)
27+
28+
def query(self, v, n):
29+
return self.index.search(query=v, topk=n)
30+
31+
def freeIndex(self):
32+
del self.index
33+
34+
def __str__(self):
35+
m = self.method_param['M']
36+
s = self.method_param['S']
37+
l = self.method_param['L']
38+
ef = self.search_ef
39+
ex = self.search_ex
40+
return "01ai(M=%s S=%s L=%s EF=%s EX=%s)" % (m, s, l, ef, ex)

0 commit comments

Comments
 (0)