hnswlib 0.6.2 → 0.8.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: fc8a40172623a3439b17c8b1854017c845bf4dc23f4e1714e9427e4b6b701c9b
4
- data.tar.gz: 95fa48d791f000bf48809e7067efaba9a654ab0dd517c626f689c66af3668d0e
3
+ metadata.gz: b5b9bb4199b5f8632fe95367083d304c47588d32c7a278cf962fff2a21a1bcda
4
+ data.tar.gz: be1988b82ab3dee3fcb0926746b20db29f9dfe7c50598c0bd096245454cf6d4f
5
5
  SHA512:
6
- metadata.gz: 07c449031cc7afbf80803ae15c8094589a146b59b1852ea72e88fcd39067def572bbdd58277e3a85c47c537e8dc6eef645f9f404a2b874e4e217b559adc38054
7
- data.tar.gz: 4b71a7f4fe0ffb3c15124e32c9c8fbba9eb6f82e6f0b95f5d91dd35c6b10be8aeba25d7313eabeaa5078b051b3410195415843ecd600b58ec1b0b36532b7ae1d
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 item vector that will be indexed.
52
- t = Hnswlib::HnswIndex.new(n_features: f, max_item: 1000)
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.add_item(i, v)
57
+ t.add_point(v, i)
57
58
  end
58
59
 
59
- t.save('test.ann')
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
- u = Hnswlib::HnswIndex.new(n_features: f, max_item: 1000)
62
- u.load('test.ann')
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
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * hnswlib.rb is a Ruby binding for the Hnswlib.
3
3
  *
4
- * Copyright (c) 2021-2022 Atsushi Tatsuma
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);