hnswlib 0.6.2 → 0.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +28 -0
- data/README.md +14 -7
- data/ext/hnswlib/hnswlibext.cpp +1 -3
- data/ext/hnswlib/hnswlibext.hpp +326 -93
- data/ext/hnswlib/src/bruteforce.h +142 -131
- data/ext/hnswlib/src/hnswalg.h +1028 -964
- data/ext/hnswlib/src/hnswlib.h +74 -66
- data/ext/hnswlib/src/space_ip.h +299 -299
- data/ext/hnswlib/src/space_l2.h +268 -273
- data/ext/hnswlib/src/visited_list_pool.h +54 -55
- data/lib/hnswlib/version.rb +2 -2
- data/lib/hnswlib.rb +21 -18
- data/sig/hnswlib.rbs +9 -7
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b5b9bb4199b5f8632fe95367083d304c47588d32c7a278cf962fff2a21a1bcda
|
4
|
+
data.tar.gz: be1988b82ab3dee3fcb0926746b20db29f9dfe7c50598c0bd096245454cf6d4f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7633712aadef67f78daa1e1d6d8534cf4f3d9e9f301b204df59b4f14f46bc8ffc33952a54d0e5ea5a66b5976bd0d27b532c9c922115baf974816fe7986de5739
|
7
|
+
data.tar.gz: c2fde5d220d72920cfe23c7cfe8f9bdd01d6719ea6f3dba0eff07f76c6bf02cb498c9ea68ddae8c4236d94ea46ac0b2468bcf284be376a804580065754121937
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,31 @@
|
|
1
|
+
## [0.8.0] - 2023-03-14
|
2
|
+
|
3
|
+
**Breaking change:**
|
4
|
+
|
5
|
+
- Change to give a String to the space argument of the `initialize` method
|
6
|
+
in [HierarchicalNSW](https://yoshoku.github.io/hnswlib.rb/doc/Hnswlib/HierarchicalNSW.html) and [BruteforceSearch](https://yoshoku.github.io/hnswlib.rb/doc/Hnswlib/BruteforceSearch.html).
|
7
|
+
- Add `init_index` method to HierarchicalNSW and BruteforceSearch.
|
8
|
+
Along with this, some arguments of `initialize` method moved to `init_index` method.
|
9
|
+
```ruby
|
10
|
+
require 'hnswlib'
|
11
|
+
|
12
|
+
n_features = 3
|
13
|
+
max_elements = 10
|
14
|
+
|
15
|
+
hnsw = Hnswlib::HierarchicalNSW.new(space: 'l2', dim: n_features)
|
16
|
+
hnsw.init_index(max_elements: max_elements, m: 16, ef_construction: 200, random_seed: 42, allow_replace_deleted: false)
|
17
|
+
|
18
|
+
bf = Hnswlib::BruteforceSearch.new(space: 'l2', dim: n_features)
|
19
|
+
bf.init_index(max_elements: max_elements)
|
20
|
+
```
|
21
|
+
- Deprecate [HnswIndex](https://yoshoku.github.io/hnswlib.rb/doc/Hnswlib/HnswIndex.html) has interface similar to Annoy.
|
22
|
+
|
23
|
+
## [0.7.0] - 2023-03-04
|
24
|
+
|
25
|
+
- Update bundled hnswlib version to 0.7.0.
|
26
|
+
- Add support for replacing an element marked for deletion with a new element.
|
27
|
+
- Add support filtering function by label in search_knn method of BruteforeceSearch and HierarchicalNSW.
|
28
|
+
|
1
29
|
## [0.6.2] - 2022-06-25
|
2
30
|
|
3
31
|
- Refactor codes and configs with RuboCop and clang-format.
|
data/README.md
CHANGED
@@ -48,19 +48,26 @@ $ gem install hnswlib -- --with-cxxflags=-march=native
|
|
48
48
|
```ruby
|
49
49
|
require 'hnswlib'
|
50
50
|
|
51
|
-
f = 40 # length of
|
52
|
-
t = Hnswlib::
|
51
|
+
f = 40 # length of datum point vector that will be indexed.
|
52
|
+
t = Hnswlib::HierarchicalNSW.new(space: 'l2', dim: f)
|
53
|
+
t.init_index(max_elements: 1000)
|
53
54
|
|
54
55
|
1000.times do |i|
|
55
56
|
v = Array.new(f) { rand }
|
56
|
-
t.
|
57
|
+
t.add_point(v, i)
|
57
58
|
end
|
58
59
|
|
59
|
-
t.
|
60
|
+
t.save_index('test.ann')
|
61
|
+
```
|
62
|
+
|
63
|
+
```ruby
|
64
|
+
require 'hnswlib'
|
65
|
+
|
66
|
+
u = Hnswlib::HierarchicalNSW.new(space: 'l2', dim: f)
|
67
|
+
u.load_index('test.ann')
|
60
68
|
|
61
|
-
|
62
|
-
u.
|
63
|
-
p u.get_nns_by_item(0, 100) # will find the 100 nearest neighbors.
|
69
|
+
q = Array.new(f) { rand }
|
70
|
+
p u.search_knn(q, 100) # will find the 100 nearest neighbors.
|
64
71
|
```
|
65
72
|
|
66
73
|
## License
|
data/ext/hnswlib/hnswlibext.cpp
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
/**
|
2
2
|
* hnswlib.rb is a Ruby binding for the Hnswlib.
|
3
3
|
*
|
4
|
-
* Copyright (c) 2021-
|
4
|
+
* Copyright (c) 2021-2023 Atsushi Tatsuma
|
5
5
|
*
|
6
6
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
7
7
|
* you may not use this file except in compliance with the License.
|
@@ -18,8 +18,6 @@
|
|
18
18
|
|
19
19
|
#include "hnswlibext.hpp"
|
20
20
|
|
21
|
-
VALUE rb_mHnswlib;
|
22
|
-
|
23
21
|
extern "C" void Init_hnswlibext(void) {
|
24
22
|
rb_mHnswlib = rb_define_module("Hnswlib");
|
25
23
|
RbHnswlibL2Space::define_class(rb_mHnswlib);
|