usearch 0.13.0 → 0.15.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.
- package/.github/workflows/release.yml +62 -7
- package/.github/workflows/update_version.sh +6 -1
- package/.vscode/launch.json +21 -22
- package/.vscode/settings.json +7 -1
- package/CITATION.cff +4 -4
- package/CMakeLists.txt +1 -1
- package/Cargo.toml +1 -1
- package/Package.swift +0 -1
- package/README.md +100 -27
- package/binding.gyp +0 -1
- package/build.gradle +1 -1
- package/build.rs +3 -3
- package/c/lib.cpp +32 -9
- package/c/usearch.h +67 -36
- package/conanfile.py +1 -1
- package/{src → cpp}/bench.cpp +52 -36
- package/{src → cpp}/test.cpp +17 -7
- package/docs/benchmarks.md +33 -10
- package/docs/c/index.rst +11 -0
- package/docs/c/reference.rst +7 -0
- package/docs/compilation.md +24 -8
- package/docs/conf.dox +6 -6
- package/docs/conf.py +3 -1
- package/docs/cpp/index.rst +11 -0
- package/docs/cpp/reference.rst +7 -0
- package/docs/index.rst +10 -0
- package/docs/java/index.rst +11 -0
- package/docs/java/reference.rst +7 -0
- package/docs/javascript/index.rst +11 -0
- package/docs/javascript/reference.rst +9 -0
- package/docs/python/index.rst +11 -0
- package/docs/python/reference.rst +35 -0
- package/golang/lib.go +1 -1
- package/include/usearch/{usearch.hpp → index.hpp} +152 -148
- package/include/usearch/index_punned_dense.hpp +633 -0
- package/include/usearch/index_punned_helpers.hpp +528 -0
- package/java/cloud/unum/usearch/cloud_unum_usearch_Index.cpp +8 -7
- package/javascript/lib.cpp +26 -50
- package/javascript/usearch.js +117 -2
- package/objc/USearchObjective.mm +145 -49
- package/objc/include/USearchObjective.h +106 -30
- package/package.json +2 -2
- package/python/lib.cpp +178 -320
- package/python/scripts/bench.ipynb +170 -0
- package/python/scripts/bench.py +102 -185
- package/python/scripts/index_faiss.py +100 -0
- package/python/scripts/test.py +57 -34
- package/python/usearch/eval.py +353 -0
- package/python/usearch/index.py +138 -117
- package/python/usearch/io.py +7 -2
- package/python/usearch/join.py +100 -0
- package/python/usearch/numba.py +101 -0
- package/rust/lib.cpp +27 -14
- package/rust/lib.hpp +4 -10
- package/rust/lib.rs +50 -17
- package/setup.py +12 -2
- package/simsimd/include/simsimd/simsimd.h +32 -3
- package/swift/Index+Sugar.swift +55 -29
- package/swift/Test.swift +1 -1
- package/wolfram/lib.cpp +4 -4
- package/python/scripts/bench_params.py +0 -161
- package/python/usearch/synthetic.py +0 -32
- package/src/punned.hpp +0 -887
- /package/{src → cpp}/CMakeLists.txt +0 -0
package/javascript/usearch.js
CHANGED
|
@@ -1,3 +1,118 @@
|
|
|
1
|
-
const
|
|
1
|
+
const usearch_native = require('bindings')('usearch');
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
class Index {
|
|
4
|
+
/**
|
|
5
|
+
* Creates an instance of Index.
|
|
6
|
+
* @date 6/7/2023 - 7:32:29 AM
|
|
7
|
+
*
|
|
8
|
+
* @constructor
|
|
9
|
+
* @param {...{}} args
|
|
10
|
+
*/
|
|
11
|
+
constructor(...args) {
|
|
12
|
+
this.native = new usearch_native.Index(...args)
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Description placeholder
|
|
17
|
+
* @date 6/7/2023 - 7:32:28 AM
|
|
18
|
+
*
|
|
19
|
+
* @param {...{}} args
|
|
20
|
+
* @returns {*}
|
|
21
|
+
*/
|
|
22
|
+
dimensions(...args) {
|
|
23
|
+
return this.native.dimensions(...args)
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Description placeholder
|
|
28
|
+
* @date 6/7/2023 - 7:32:28 AM
|
|
29
|
+
*
|
|
30
|
+
* @param {...{}} args
|
|
31
|
+
* @returns {*}
|
|
32
|
+
*/
|
|
33
|
+
size(...args) {
|
|
34
|
+
return this.native.size(...args)
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Description placeholder
|
|
39
|
+
* @date 6/7/2023 - 7:32:28 AM
|
|
40
|
+
*
|
|
41
|
+
* @param {...{}} args
|
|
42
|
+
* @returns {*}
|
|
43
|
+
*/
|
|
44
|
+
capacity(...args) {
|
|
45
|
+
return this.native.capacity(...args)
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Description placeholder
|
|
50
|
+
* @date 6/7/2023 - 7:32:28 AM
|
|
51
|
+
*
|
|
52
|
+
* @param {...{}} args
|
|
53
|
+
* @returns {*}
|
|
54
|
+
*/
|
|
55
|
+
connectivity(...args) {
|
|
56
|
+
return this.native.connectivity(...args)
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* Description placeholder
|
|
61
|
+
* @date 6/7/2023 - 7:32:28 AM
|
|
62
|
+
*
|
|
63
|
+
* @param {...{}} args
|
|
64
|
+
* @returns {*}
|
|
65
|
+
*/
|
|
66
|
+
save(...args) {
|
|
67
|
+
return this.native.save(...args)
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* Description placeholder
|
|
72
|
+
* @date 6/7/2023 - 7:32:27 AM
|
|
73
|
+
*
|
|
74
|
+
* @param {...{}} args
|
|
75
|
+
* @returns {*}
|
|
76
|
+
*/
|
|
77
|
+
load(...args) {
|
|
78
|
+
return this.native.load(...args)
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* Description placeholder
|
|
83
|
+
* @date 6/7/2023 - 7:32:27 AM
|
|
84
|
+
*
|
|
85
|
+
* @param {...{}} args
|
|
86
|
+
* @returns {*}
|
|
87
|
+
*/
|
|
88
|
+
view(...args) {
|
|
89
|
+
return this.native.view(...args)
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* Description placeholder
|
|
94
|
+
* @date 6/7/2023 - 7:32:27 AM
|
|
95
|
+
*
|
|
96
|
+
* @param {...{}} args
|
|
97
|
+
* @returns {*}
|
|
98
|
+
*/
|
|
99
|
+
add(...args) {
|
|
100
|
+
return this.native.add(...args)
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* Description placeholder
|
|
105
|
+
* @date 6/7/2023 - 7:32:27 AM
|
|
106
|
+
*
|
|
107
|
+
* @param {...{}} args
|
|
108
|
+
* @returns {*}
|
|
109
|
+
*/
|
|
110
|
+
search(...args) {
|
|
111
|
+
return this.native.search(...args)
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
|
|
116
|
+
module.exports = {
|
|
117
|
+
Index: Index
|
|
118
|
+
};
|
package/objc/USearchObjective.mm
CHANGED
|
@@ -2,17 +2,73 @@
|
|
|
2
2
|
|
|
3
3
|
#pragma clang diagnostic push
|
|
4
4
|
#pragma clang diagnostic ignored "-Wdocumentation"
|
|
5
|
-
#import
|
|
5
|
+
#import <usearch/index_punned_dense.hpp>
|
|
6
6
|
#pragma clang diagnostic pop
|
|
7
7
|
|
|
8
8
|
using namespace unum::usearch;
|
|
9
9
|
using namespace unum;
|
|
10
10
|
|
|
11
11
|
using distance_t = punned_distance_t;
|
|
12
|
-
using punned_t =
|
|
12
|
+
using punned_t = index_punned_dense_gt<UInt32>;
|
|
13
|
+
using add_result_t = punned_t::add_result_t;
|
|
14
|
+
using search_result_t = punned_t::search_result_t;
|
|
15
|
+
using serialization_result_t = punned_t::serialization_result_t;
|
|
13
16
|
using shared_index_t = std::shared_ptr<punned_t>;
|
|
14
17
|
|
|
15
|
-
|
|
18
|
+
metric_kind_t to_native_metric(USearchMetric m) {
|
|
19
|
+
switch (m) {
|
|
20
|
+
case USearchMetricIP:
|
|
21
|
+
return metric_kind_t::ip_k;
|
|
22
|
+
|
|
23
|
+
case USearchMetricCos:
|
|
24
|
+
return metric_kind_t::cos_k;
|
|
25
|
+
|
|
26
|
+
case USearchMetricL2sq:
|
|
27
|
+
return metric_kind_t::l2sq_k;
|
|
28
|
+
|
|
29
|
+
case USearchMetricHamming:
|
|
30
|
+
return metric_kind_t::hamming_k;
|
|
31
|
+
|
|
32
|
+
case USearchMetricHaversine:
|
|
33
|
+
return metric_kind_t::haversine_k;
|
|
34
|
+
|
|
35
|
+
case USearchMetricJaccard:
|
|
36
|
+
return metric_kind_t::jaccard_k;
|
|
37
|
+
|
|
38
|
+
case USearchMetricPearson:
|
|
39
|
+
return metric_kind_t::pearson_k;
|
|
40
|
+
|
|
41
|
+
case USearchMetricSorensen:
|
|
42
|
+
return metric_kind_t::sorensen_k;
|
|
43
|
+
|
|
44
|
+
case USearchMetricTanimoto:
|
|
45
|
+
return metric_kind_t::tanimoto_k;
|
|
46
|
+
|
|
47
|
+
default:
|
|
48
|
+
return metric_kind_t::unknown_k;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
scalar_kind_t to_native_scalar(USearchScalar m) {
|
|
53
|
+
switch (m) {
|
|
54
|
+
case USearchScalarF8:
|
|
55
|
+
return scalar_kind_t::f8_k;
|
|
56
|
+
|
|
57
|
+
case USearchScalarF16:
|
|
58
|
+
return scalar_kind_t::f16_k;
|
|
59
|
+
|
|
60
|
+
case USearchScalarF32:
|
|
61
|
+
return scalar_kind_t::f32_k;
|
|
62
|
+
|
|
63
|
+
case USearchScalarF64:
|
|
64
|
+
return scalar_kind_t::f64_k;
|
|
65
|
+
|
|
66
|
+
default:
|
|
67
|
+
return scalar_kind_t::unknown_k;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
@interface USearchIndex ()
|
|
16
72
|
|
|
17
73
|
@property (readonly) shared_index_t native;
|
|
18
74
|
|
|
@@ -20,7 +76,7 @@ using shared_index_t = std::shared_ptr<punned_t>;
|
|
|
20
76
|
|
|
21
77
|
@end
|
|
22
78
|
|
|
23
|
-
@implementation
|
|
79
|
+
@implementation USearchIndex
|
|
24
80
|
|
|
25
81
|
- (instancetype)initWithIndex:(shared_index_t)native {
|
|
26
82
|
self = [super init];
|
|
@@ -48,79 +104,101 @@ using shared_index_t = std::shared_ptr<punned_t>;
|
|
|
48
104
|
return static_cast<UInt32>(_native->capacity());
|
|
49
105
|
}
|
|
50
106
|
|
|
51
|
-
- (UInt32)
|
|
52
|
-
return static_cast<UInt32>(_native->
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
- (UInt32)expansion_search {
|
|
56
|
-
return static_cast<UInt32>(_native->config().expansion_search);
|
|
107
|
+
- (UInt32)expansionAdd {
|
|
108
|
+
return static_cast<UInt32>(_native->expansion_add());
|
|
57
109
|
}
|
|
58
110
|
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
index_config_t config;
|
|
62
|
-
|
|
63
|
-
config.connectivity = static_cast<std::size_t>(connectivity);
|
|
64
|
-
shared_index_t ptr = std::make_shared<punned_t>(punned_t::ip(dims, accuracy_t::f32_k, config));
|
|
65
|
-
return [[Index alloc] initWithIndex:ptr];
|
|
111
|
+
- (UInt32)expansionSearch {
|
|
112
|
+
return static_cast<UInt32>(_native->expansion_search());
|
|
66
113
|
}
|
|
67
114
|
|
|
68
|
-
+ (instancetype)
|
|
115
|
+
+ (instancetype)make:(USearchMetric)metric dimensions:(UInt32)dimensions connectivity:(UInt32)connectivity quantization:(USearchScalar)quantization {
|
|
69
116
|
std::size_t dims = static_cast<std::size_t>(dimensions);
|
|
70
117
|
index_config_t config;
|
|
71
118
|
|
|
72
119
|
config.connectivity = static_cast<std::size_t>(connectivity);
|
|
73
|
-
shared_index_t ptr = std::make_shared<punned_t>(punned_t::
|
|
74
|
-
return [[
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
+ (instancetype)indexHaversine:(UInt32)connectivity {
|
|
78
|
-
index_config_t config;
|
|
79
|
-
|
|
80
|
-
config.connectivity = static_cast<std::size_t>(connectivity);
|
|
81
|
-
shared_index_t ptr = std::make_shared<punned_t>(punned_t::haversine(accuracy_t::f32_k, config));
|
|
82
|
-
return [[Index alloc] initWithIndex:ptr];
|
|
120
|
+
shared_index_t ptr = std::make_shared<punned_t>(punned_t::make(dims, to_native_metric(metric), config, to_native_scalar(quantization)));
|
|
121
|
+
return [[USearchIndex alloc] initWithIndex:ptr];
|
|
83
122
|
}
|
|
84
123
|
|
|
85
124
|
- (void)addSingle:(UInt32)label
|
|
86
125
|
vector:(Float32 const *_Nonnull)vector {
|
|
87
|
-
_native->add(label, vector);
|
|
126
|
+
add_result_t result = _native->add(label, vector);
|
|
127
|
+
|
|
128
|
+
if (!result) {
|
|
129
|
+
@throw [NSException exceptionWithName:@"Can't add to index"
|
|
130
|
+
reason:[NSString stringWithUTF8String:result.error.what()]
|
|
131
|
+
userInfo:nil];
|
|
132
|
+
}
|
|
88
133
|
}
|
|
89
134
|
|
|
90
135
|
- (UInt32)searchSingle:(Float32 const *_Nonnull)vector
|
|
91
136
|
count:(UInt32)wanted
|
|
92
137
|
labels:(UInt32 *_Nullable)labels
|
|
93
138
|
distances:(Float32 *_Nullable)distances {
|
|
94
|
-
|
|
139
|
+
search_result_t result = _native->search(vector, static_cast<std::size_t>(wanted));
|
|
140
|
+
|
|
141
|
+
if (!result) {
|
|
142
|
+
@throw [NSException exceptionWithName:@"Can't find in index"
|
|
143
|
+
reason:[NSString stringWithUTF8String:result.error.what()]
|
|
144
|
+
userInfo:nil];
|
|
145
|
+
}
|
|
95
146
|
|
|
147
|
+
std::size_t found = result.dump_to(labels, distances);
|
|
96
148
|
return static_cast<UInt32>(found);
|
|
97
149
|
}
|
|
98
150
|
|
|
99
|
-
- (void)
|
|
100
|
-
|
|
101
|
-
_native->add(label, (f64_t const *)vector);
|
|
151
|
+
- (void)addDouble:(UInt32)label
|
|
152
|
+
vector:(Float64 const *_Nonnull)vector {
|
|
153
|
+
add_result_t result = _native->add(label, (f64_t const *)vector);
|
|
154
|
+
|
|
155
|
+
if (!result) {
|
|
156
|
+
@throw [NSException exceptionWithName:@"Can't add to index"
|
|
157
|
+
reason:[NSString stringWithUTF8String:result.error.what()]
|
|
158
|
+
userInfo:nil];
|
|
159
|
+
}
|
|
102
160
|
}
|
|
103
161
|
|
|
104
|
-
- (UInt32)
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
162
|
+
- (UInt32)searchDouble:(Float64 const *_Nonnull)vector
|
|
163
|
+
count:(UInt32)wanted
|
|
164
|
+
labels:(UInt32 *_Nullable)labels
|
|
165
|
+
distances:(Float32 *_Nullable)distances {
|
|
166
|
+
search_result_t result = _native->search((f64_t const *)vector, static_cast<std::size_t>(wanted));
|
|
167
|
+
|
|
168
|
+
if (!result) {
|
|
169
|
+
@throw [NSException exceptionWithName:@"Can't find in index"
|
|
170
|
+
reason:[NSString stringWithUTF8String:result.error.what()]
|
|
171
|
+
userInfo:nil];
|
|
172
|
+
}
|
|
109
173
|
|
|
174
|
+
std::size_t found = result.dump_to(labels, distances);
|
|
110
175
|
return static_cast<UInt32>(found);
|
|
111
176
|
}
|
|
112
177
|
|
|
113
|
-
- (void)
|
|
114
|
-
|
|
115
|
-
_native->add(label, (
|
|
178
|
+
- (void)addHalf:(UInt32)label
|
|
179
|
+
vector:(void const *_Nonnull)vector {
|
|
180
|
+
add_result_t result = _native->add(label, (f16_t const *)vector);
|
|
181
|
+
|
|
182
|
+
if (!result) {
|
|
183
|
+
@throw [NSException exceptionWithName:@"Can't add to index"
|
|
184
|
+
reason:[NSString stringWithUTF8String:result.error.what()]
|
|
185
|
+
userInfo:nil];
|
|
186
|
+
}
|
|
116
187
|
}
|
|
117
188
|
|
|
118
|
-
- (UInt32)
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
189
|
+
- (UInt32)searchHalf:(void const *_Nonnull)vector
|
|
190
|
+
count:(UInt32)wanted
|
|
191
|
+
labels:(UInt32 *_Nullable)labels
|
|
192
|
+
distances:(Float32 *_Nullable)distances {
|
|
193
|
+
search_result_t result = _native->search((f16_t const *)vector, static_cast<std::size_t>(wanted));
|
|
123
194
|
|
|
195
|
+
if (!result) {
|
|
196
|
+
@throw [NSException exceptionWithName:@"Can't find in index"
|
|
197
|
+
reason:[NSString stringWithUTF8String:result.error.what()]
|
|
198
|
+
userInfo:nil];
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
std::size_t found = result.dump_to(labels, distances);
|
|
124
202
|
return static_cast<UInt32>(found);
|
|
125
203
|
}
|
|
126
204
|
|
|
@@ -137,7 +215,13 @@ using shared_index_t = std::shared_ptr<punned_t>;
|
|
|
137
215
|
userInfo:nil];
|
|
138
216
|
}
|
|
139
217
|
|
|
140
|
-
_native->save(path_c);
|
|
218
|
+
serialization_result_t result = _native->save(path_c);
|
|
219
|
+
|
|
220
|
+
if (!result) {
|
|
221
|
+
@throw [NSException exceptionWithName:@"Can't save to disk"
|
|
222
|
+
reason:[NSString stringWithUTF8String:result.error.what()]
|
|
223
|
+
userInfo:nil];
|
|
224
|
+
}
|
|
141
225
|
}
|
|
142
226
|
|
|
143
227
|
- (void)load:(NSString *)path {
|
|
@@ -149,7 +233,13 @@ using shared_index_t = std::shared_ptr<punned_t>;
|
|
|
149
233
|
userInfo:nil];
|
|
150
234
|
}
|
|
151
235
|
|
|
152
|
-
_native->load(path_c);
|
|
236
|
+
serialization_result_t result = _native->load(path_c);
|
|
237
|
+
|
|
238
|
+
if (!result) {
|
|
239
|
+
@throw [NSException exceptionWithName:@"Can't load from disk"
|
|
240
|
+
reason:[NSString stringWithUTF8String:result.error.what()]
|
|
241
|
+
userInfo:nil];
|
|
242
|
+
}
|
|
153
243
|
}
|
|
154
244
|
|
|
155
245
|
- (void)view:(NSString *)path {
|
|
@@ -161,7 +251,13 @@ using shared_index_t = std::shared_ptr<punned_t>;
|
|
|
161
251
|
userInfo:nil];
|
|
162
252
|
}
|
|
163
253
|
|
|
164
|
-
_native->view(path_c);
|
|
254
|
+
serialization_result_t result = _native->view(path_c);
|
|
255
|
+
|
|
256
|
+
if (!result) {
|
|
257
|
+
@throw [NSException exceptionWithName:@"Can't view from disk"
|
|
258
|
+
reason:[NSString stringWithUTF8String:result.error.what()]
|
|
259
|
+
userInfo:nil];
|
|
260
|
+
}
|
|
165
261
|
}
|
|
166
262
|
|
|
167
263
|
@end
|
|
@@ -4,19 +4,36 @@
|
|
|
4
4
|
|
|
5
5
|
NS_ASSUME_NONNULL_BEGIN
|
|
6
6
|
|
|
7
|
-
typedef NS_ENUM(NSUInteger,
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
7
|
+
typedef NS_ENUM(NSUInteger, USearchScalar) {
|
|
8
|
+
USearchScalarF32,
|
|
9
|
+
USearchScalarF16,
|
|
10
|
+
USearchScalarF64,
|
|
11
|
+
USearchScalarF8,
|
|
12
|
+
USearchScalarB1
|
|
11
13
|
};
|
|
12
14
|
|
|
15
|
+
typedef NS_ENUM(NSUInteger, USearchMetric) {
|
|
16
|
+
USearchMetricUnknown,
|
|
17
|
+
USearchMetricIP,
|
|
18
|
+
USearchMetricCos,
|
|
19
|
+
USearchMetricL2sq,
|
|
20
|
+
USearchMetricPearson,
|
|
21
|
+
USearchMetricHaversine,
|
|
22
|
+
USearchMetricJaccard,
|
|
23
|
+
USearchMetricHamming,
|
|
24
|
+
USearchMetricTanimoto,
|
|
25
|
+
USearchMetricSorensen
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
typedef UInt32 USearchLabel;
|
|
29
|
+
|
|
13
30
|
API_AVAILABLE(ios(13.0), macos(10.15), tvos(13.0), watchos(6.0))
|
|
14
|
-
@interface
|
|
31
|
+
@interface USearchIndex : NSObject
|
|
15
32
|
|
|
16
33
|
@property (readonly) UInt32 dimensions;
|
|
17
34
|
@property (readonly) UInt32 connectivity;
|
|
18
|
-
@property (readonly) UInt32
|
|
19
|
-
@property (readonly) UInt32
|
|
35
|
+
@property (readonly) UInt32 expansionAdd;
|
|
36
|
+
@property (readonly) UInt32 expansionSearch;
|
|
20
37
|
|
|
21
38
|
@property (readonly) UInt32 length;
|
|
22
39
|
@property (readonly) UInt32 capacity;
|
|
@@ -24,37 +41,96 @@ API_AVAILABLE(ios(13.0), macos(10.15), tvos(13.0), watchos(6.0))
|
|
|
24
41
|
|
|
25
42
|
- (instancetype)init NS_UNAVAILABLE;
|
|
26
43
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
44
|
+
/**
|
|
45
|
+
* @brief Initializes a new index.
|
|
46
|
+
* @param metric The distance function to compare the dis-similarity of vectors.
|
|
47
|
+
* @param dimensions The number of dimensions planned for this index.
|
|
48
|
+
* @param connectivity Number of connections per node in the proximity graph.
|
|
49
|
+
* Higher connectivity improves accuracy, increases memory usage, and reduces construction speed.
|
|
50
|
+
* @param quantization Accuracy of internal vector representations. Lower accuracy means higher speed.
|
|
51
|
+
*/
|
|
52
|
+
+ (instancetype)make:(USearchMetric)metric dimensions:(UInt32)dimensions connectivity:(UInt32)connectivity quantization:(USearchScalar)quantization NS_SWIFT_NAME(make(metric:dimensions:connectivity:quantization:));
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* @brief Adds a labeled vector to the index.
|
|
56
|
+
* @param vector Single-precision vector.
|
|
57
|
+
*/
|
|
58
|
+
- (void)addSingle:(USearchLabel)label
|
|
32
59
|
vector:(Float32 const *_Nonnull)vector NS_SWIFT_NAME(addSingle(label:vector:));
|
|
33
60
|
|
|
61
|
+
/**
|
|
62
|
+
* @brief Approximate nearest neighbors search.
|
|
63
|
+
* @param vector Single-precision query vector.
|
|
64
|
+
* @param count Upper limit on the number of matches to retrieve.
|
|
65
|
+
* @param labels Optional output buffer for labels of approximate neighbors.
|
|
66
|
+
* @param distances Optional output buffer for (increasing) distances to approximate neighbors.
|
|
67
|
+
* @return Number of matches exported to `labels` and `distances`.
|
|
68
|
+
*/
|
|
34
69
|
- (UInt32)searchSingle:(Float32 const *_Nonnull)vector
|
|
35
70
|
count:(UInt32)count
|
|
36
|
-
labels:(
|
|
71
|
+
labels:(USearchLabel *_Nullable)labels
|
|
37
72
|
distances:(Float32 *_Nullable)distances NS_SWIFT_NAME(searchSingle(vector:count:labels:distances:));
|
|
38
73
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
74
|
+
/**
|
|
75
|
+
* @brief Adds a labeled vector to the index.
|
|
76
|
+
* @param vector Double-precision vector.
|
|
77
|
+
*/
|
|
78
|
+
- (void)addDouble:(UInt32)label
|
|
79
|
+
vector:(Float64 const *_Nonnull)vector NS_SWIFT_NAME(addDouble(label:vector:));
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* @brief Approximate nearest neighbors search.
|
|
83
|
+
* @param vector Double-precision query vector.
|
|
84
|
+
* @param count Upper limit on the number of matches to retrieve.
|
|
85
|
+
* @param labels Optional output buffer for labels of approximate neighbors.
|
|
86
|
+
* @param distances Optional output buffer for (increasing) distances to approximate neighbors.
|
|
87
|
+
* @return Number of matches exported to `labels` and `distances`.
|
|
88
|
+
*/
|
|
89
|
+
- (UInt32)searchDouble:(Float64 const *_Nonnull)vector
|
|
90
|
+
count:(UInt32)count
|
|
91
|
+
labels:(USearchLabel *_Nullable)labels
|
|
92
|
+
distances:(Float32 *_Nullable)distances NS_SWIFT_NAME(searchDouble(vector:count:labels:distances:));
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* @brief Adds a labeled vector to the index.
|
|
96
|
+
* @param vector Half-precision vector.
|
|
97
|
+
*/
|
|
98
|
+
- (void)addHalf:(UInt32)label
|
|
99
|
+
vector:(void const *_Nonnull)vector NS_SWIFT_NAME(addHalf(label:vector:));
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* @brief Approximate nearest neighbors search.
|
|
103
|
+
* @param vector Half-precision query vector.
|
|
104
|
+
* @param count Upper limit on the number of matches to retrieve.
|
|
105
|
+
* @param labels Optional output buffer for labels of approximate neighbors.
|
|
106
|
+
* @param distances Optional output buffer for (increasing) distances to approximate neighbors.
|
|
107
|
+
* @return Number of matches exported to `labels` and `distances`.
|
|
108
|
+
*/
|
|
109
|
+
- (UInt32)searchHalf:(void const *_Nonnull)vector
|
|
110
|
+
count:(UInt32)count
|
|
111
|
+
labels:(USearchLabel *_Nullable)labels
|
|
112
|
+
distances:(Float32 *_Nullable)distances NS_SWIFT_NAME(searchHalf(vector:count:labels:distances:));
|
|
113
|
+
|
|
114
|
+
/**
|
|
115
|
+
* @brief Saves pre-constructed index to disk.
|
|
116
|
+
*/
|
|
117
|
+
- (void)save:(NSString *)path NS_SWIFT_NAME(save(path:));
|
|
118
|
+
|
|
119
|
+
/**
|
|
120
|
+
* @brief Loads a pre-constructed index from index.
|
|
121
|
+
*/
|
|
56
122
|
- (void)load:(NSString *)path NS_SWIFT_NAME(load(path:));
|
|
123
|
+
|
|
124
|
+
/**
|
|
125
|
+
* @brief Views a pre-constructed index from disk without loading it into RAM.
|
|
126
|
+
* Allows working with larger-than memory indexes and saving scarce
|
|
127
|
+
* memory on device in read-only workloads.
|
|
128
|
+
*/
|
|
57
129
|
- (void)view:(NSString *)path NS_SWIFT_NAME(view(path:));
|
|
130
|
+
|
|
131
|
+
/**
|
|
132
|
+
* @brief Removes all the data from index, while preserving the settings.
|
|
133
|
+
*/
|
|
58
134
|
- (void)clear NS_SWIFT_NAME(clear());
|
|
59
135
|
|
|
60
136
|
@end
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "usearch",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.15.0",
|
|
4
4
|
"description": "Smaller & Faster Single-File Vector Search Engine from Unum",
|
|
5
5
|
"author": "Ashot Vardanian",
|
|
6
6
|
"license": "Apache 2.0",
|
|
@@ -24,6 +24,6 @@
|
|
|
24
24
|
"@semantic-release/exec": "^6.0.3",
|
|
25
25
|
"@semantic-release/git": "^10.0.1",
|
|
26
26
|
"conventional-changelog-eslint": "^3.0.9",
|
|
27
|
-
"semantic-release": "^21.0.
|
|
27
|
+
"semantic-release": "^21.0.5"
|
|
28
28
|
}
|
|
29
29
|
}
|