Skip to content

Commit

Permalink
add algo descartes(01AI) (#490)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
xiaoming-01ai authored Mar 19, 2024
1 parent 708c67f commit 0f6ad75
Show file tree
Hide file tree
Showing 5 changed files with 70 additions and 0 deletions.
1 change: 1 addition & 0 deletions .github/workflows/benchmarks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ jobs:
- balltree
- bruteforce
- ckdtree
- descartes
- diskann
- dolphinnpy
- elasticsearch
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ Evaluated
* [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)
* [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)
* [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)
* [Descartes(01AI)](https://github.com/xiaoming-01ai/descartes)

Data sets
=========
Expand Down
9 changes: 9 additions & 0 deletions ann_benchmarks/algorithms/descartes/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
FROM ann-benchmarks

RUN apt update
RUN apt install -y git cmake g++ python3 python3-setuptools python3-pip libblas-dev liblapack-dev
RUN pip3 install wheel pybind11==2.5.0

WORKDIR /home/app
RUN git clone https://github.com/xiaoming-01ai/descartes.git
RUN pip3 install descartes/descartes-*-linux_x86_64.whl
19 changes: 19 additions & 0 deletions ann_benchmarks/algorithms/descartes/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
float:
any:
- base_args: ['@metric']
constructor: fng
disabled: false
docker_tag: ann-benchmarks-descartes
module: ann_benchmarks.algorithms.descartes
name: descartes(01AI)
run_groups:
FNG:
args:
M: [32, 64, 96, 128]
L: [128, 256, 320, 384, 448]
S: [1, 2, 3]
query_args:
[
[0, 1, 2, 3],
[10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 150, 200, 250, 300, 350, 400, 500, 600]
]
40 changes: 40 additions & 0 deletions ann_benchmarks/algorithms/descartes/module.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import py01ai
import numpy as np
from ..base.module import BaseANN
import logging

class fng(BaseANN):
def __init__(self, metric, method_param):
self.metric = {"angular": "angular", "euclidean": "square_l2"}[metric]
self.method_param = method_param
self.name = "01ai (%s)" % (self.method_param)

def fit(self, X):
self.index = py01ai.FNGIndex(metric=self.metric, dimension=len(X[0]))
self.index.init(count=len(X),
m=self.method_param["M"],
s=self.method_param["S"],
l=self.method_param["L"])
try:
self.index.add_vector(input=np.asarray(X))
except Exception as e:
print(str(e))

def set_query_arguments(self, ex, ef):
self.search_ef = ef
self.search_ex = ex
self.index.set_query_param(ef=ef, ex=ex)

def query(self, v, n):
return self.index.search(query=v, topk=n)

def freeIndex(self):
del self.index

def __str__(self):
m = self.method_param['M']
s = self.method_param['S']
l = self.method_param['L']
ef = self.search_ef
ex = self.search_ex
return "01ai(M=%s S=%s L=%s EF=%s EX=%s)" % (m, s, l, ef, ex)

0 comments on commit 0f6ad75

Please sign in to comment.