Skip to content

Commit fb0aaab

Browse files
authored
Merge pull request #1 from yurymalkov/develop
Merge develop
2 parents b1198ce + c77a871 commit fb0aaab

17 files changed

+1864
-1457
lines changed

CMakeLists.txt

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,13 @@ include_directories("${PROJECT_BINARY_DIR}")
55

66

77

8-
project(hello_world)
9-
108
set(SOURCE_EXE main.cpp)
119

12-
set(SOURCE_LIB1 sift_test.cpp)
13-
set(SOURCE_LIB2 sift_1b.cpp)
10+
set(SOURCE_LIB sift_1b.cpp)
11+
12+
add_library(sift_test STATIC ${SOURCE_LIB})
1413

15-
add_library(sift_test STATIC ${SOURCE_LIB1} ${SOURCE_LIB2})
1614

17-
add_executable(main ${SOURCE_EXE})
15+
add_executable(main ${SOURCE_EXE})
1816
SET( CMAKE_CXX_FLAGS "-Ofast -lrt -DNDEBUG -std=c++11 -DHAVE_CXX0X -openmp -march=native -fpic -w -fopenmp -ftree-vectorize -ftree-vectorizer-verbose=0" )
1917
target_link_libraries(main sift_test)

L2space.h

Lines changed: 0 additions & 233 deletions
This file was deleted.

README.md

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
# Hnsw - Approximate nearest neighbor search
22
Hnsw paper code for the 200M SIFT experiment.
33

4+
NEW: Added simple python bindings with incremental construction(reusing some nmslib code, only L2 is now supported)
5+
6+
7+
####Test reproduction steps:
48
To download and extract the bigann dataset:
59
```bash
610
python3 download_bigann.py
@@ -18,6 +22,37 @@ To run the test on 200M SIFT subset:
1822

1923
The size of the bigann subset (in millions) is controlled by the variable **subset_size_milllions** hardcoded in **sift_1b.cpp**.
2024

25+
26+
#### Python bindings example
27+
```python
28+
import hnswlib
29+
import numpy as np
30+
31+
dim = 128
32+
num_elements = 10000
33+
34+
data=np.float32(np.random.random((num_elements,dim)))
35+
data_labels=np.arange(num_elements)
36+
37+
p = hnswlib.Index(space='l2', dim=dim) #Only l2 is supported currently
38+
p.init_index(max_elements=10000, ef_construction=200, M=16)
39+
40+
# Element insertion be called several times:
41+
int_labels = p.add_items(data, data_labels)
42+
43+
44+
p.set_ef(50)
45+
# Query dataset, k - number of closest elements
46+
# Return numpy arrays
47+
labels, distances = p.knn_query(data, k=1)
48+
49+
```
50+
To compile run:
51+
```bash
52+
cd python_bindings
53+
python3 setup.py install
54+
```
55+
2156
The repo contrains some parts of the Non-Metric Space Library's code https://github.com/searchivarius/nmslib
2257

2358
References:

brutoforce.h

Lines changed: 0 additions & 63 deletions
This file was deleted.

0 commit comments

Comments
 (0)