usearch 2.9.1 → 2.10.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/README.md +50 -52
- package/javascript/{types → dist/cjs}/usearch.d.ts +90 -115
- package/javascript/dist/cjs/usearch.js +531 -0
- package/javascript/dist/esm/usearch.d.ts +212 -0
- package/javascript/{usearch.js → dist/esm/usearch.js} +202 -153
- package/package.json +25 -23
- package/prebuilds/darwin-arm64+x64/usearch.node +0 -0
- package/prebuilds/linux-arm64/usearch.node +0 -0
- package/prebuilds/linux-x64/usearch.node +0 -0
- package/prebuilds/win32-ia32/usearch.node +0 -0
- package/prebuilds/win32-x64/usearch.node +0 -0
- package/.clang-format +0 -10
- package/.clang-tidy +0 -60
- package/.cmake-format.py +0 -19
- package/.dockerignore +0 -93
- package/.gitattributes +0 -9
- package/.github/ISSUE_TEMPLATE/bug_report.yml +0 -90
- package/.github/ISSUE_TEMPLATE/config.yml +0 -5
- package/.github/ISSUE_TEMPLATE/feature_request.yml +0 -64
- package/.github/workflows/Dockerfile.libs +0 -36
- package/.github/workflows/prerelease.yml +0 -331
- package/.github/workflows/release.yml +0 -722
- package/.github/workflows/update_version.sh +0 -15
- package/.gitmodules +0 -9
- package/.releaserc +0 -90
- package/CITATION.cff +0 -11
- package/CMakeLists.txt +0 -324
- package/CODE_OF_CONDUCT.md +0 -128
- package/CONTRIBUTING.md +0 -353
- package/Cargo.toml +0 -19
- package/Dockerfile +0 -16
- package/VERSION +0 -1
- package/assets/unum.png +0 -0
- package/assets/usearch-approaches-transparent.png +0 -0
- package/assets/usearch-approaches-white.png +0 -0
- package/assets/usearch-neighbor-types.png +0 -0
- package/binding.gyp +0 -87
- package/build.gradle +0 -204
- package/build.rs +0 -18
- package/c/CMakeLists.txt +0 -25
- package/c/README.md +0 -34
- package/c/lib.cpp +0 -358
- package/c/test.c +0 -374
- package/c/usearch.h +0 -311
- package/cmake/clipp.cmake +0 -7
- package/cmake/config.cmake.in +0 -15
- package/cmake/emscripten.cmake +0 -8
- package/cmake/jemalloc.cmake +0 -62
- package/cmake/pkg-config.pc.in +0 -4
- package/cmake/usearchConfigVersion.cmake.in +0 -20
- package/conanfile.py +0 -26
- package/cpp/CMakeLists.txt +0 -14
- package/cpp/README.md +0 -161
- package/cpp/bench.cpp +0 -618
- package/cpp/test.cpp +0 -323
- package/fp16/CMakeLists.txt +0 -176
- package/fp16/LICENSE +0 -11
- package/fp16/README.md +0 -20
- package/fp16/bench/alt-element.cc +0 -89
- package/fp16/bench/from-alt-array.cc +0 -175
- package/fp16/bench/from-ieee-array.cc +0 -399
- package/fp16/bench/ieee-element.cc +0 -272
- package/fp16/bench/to-alt-array.cc +0 -91
- package/fp16/bench/to-ieee-array.cc +0 -303
- package/fp16/cmake/DownloadGoogleBenchmark.cmake +0 -15
- package/fp16/cmake/DownloadGoogleTest.cmake +0 -15
- package/fp16/cmake/DownloadPSimd.cmake +0 -15
- package/fp16/configure.py +0 -65
- package/fp16/confu.yaml +0 -8
- package/fp16/include/fp16/__init__.py +0 -0
- package/fp16/include/fp16/avx.py +0 -50
- package/fp16/include/fp16/avx2.py +0 -53
- package/fp16/include/fp16/bitcasts.h +0 -92
- package/fp16/include/fp16/fp16.h +0 -451
- package/fp16/include/fp16/psimd.h +0 -131
- package/fp16/include/fp16.h +0 -11
- package/fp16/jni/Android.mk +0 -6
- package/fp16/jni/Application.mk +0 -4
- package/fp16/test/alt-from-fp32-value.cc +0 -498
- package/fp16/test/alt-to-fp32-bits.cc +0 -263
- package/fp16/test/alt-to-fp32-psimd.cc +0 -145
- package/fp16/test/alt-to-fp32-value.cc +0 -348
- package/fp16/test/alt-to-fp32x2-psimd.cc +0 -245
- package/fp16/test/bitcasts.cc +0 -56
- package/fp16/test/ieee-from-fp32-value.cc +0 -523
- package/fp16/test/ieee-to-fp32-bits.cc +0 -333
- package/fp16/test/ieee-to-fp32-psimd.cc +0 -312
- package/fp16/test/ieee-to-fp32-value.cc +0 -420
- package/fp16/test/ieee-to-fp32x2-psimd.cc +0 -541
- package/fp16/test/peachpy/alt-xmm-to-fp32-xmm-avx.cc +0 -96
- package/fp16/test/peachpy/alt-xmm-to-fp32-ymm-avx2.cc +0 -96
- package/fp16/test/peachpy/stubs.py +0 -38
- package/fp16/test/tables.cc +0 -530
- package/fp16/test/tables.h +0 -13
- package/fp16/third-party/THHalf.h +0 -92
- package/fp16/third-party/eigen-half.h +0 -170
- package/fp16/third-party/float16-compressor.h +0 -80
- package/fp16/third-party/half.hpp +0 -2916
- package/fp16/third-party/npy-halffloat.h +0 -328
- package/include/usearch/index.hpp +0 -3836
- package/include/usearch/index_dense.hpp +0 -2004
- package/include/usearch/index_plugins.hpp +0 -2203
- package/javascript/lib.cpp +0 -341
- package/javascript/types/usearch.d.ts.map +0 -1
- package/javascript/usearch.test.js +0 -74
- package/package-ci.json +0 -10
- package/pyproject.toml +0 -51
- package/setup.py +0 -201
- package/simsimd/.releaserc +0 -86
- package/simsimd/Cargo.lock +0 -708
- package/simsimd/Cargo.toml +0 -36
- package/simsimd/LICENSE +0 -201
- package/simsimd/README.md +0 -275
- package/simsimd/binding.gyp +0 -36
- package/simsimd/build.rs +0 -20
- package/simsimd/include/simsimd/binary.h +0 -201
- package/simsimd/include/simsimd/probability.h +0 -548
- package/simsimd/include/simsimd/simsimd.h +0 -456
- package/simsimd/include/simsimd/spatial.h +0 -1175
- package/simsimd/include/simsimd/types.h +0 -207
- package/simsimd/javascript/bench.js +0 -127
- package/simsimd/javascript/fallback.ts +0 -193
- package/simsimd/javascript/lib.c +0 -102
- package/simsimd/javascript/node-gyp-build.d.ts +0 -1
- package/simsimd/javascript/simsimd.ts +0 -124
- package/simsimd/javascript/test.mjs +0 -153
- package/simsimd/javascript/tsconfig-base.json +0 -25
- package/simsimd/javascript/tsconfig-cjs.json +0 -8
- package/simsimd/javascript/tsconfig-esm.json +0 -8
- package/simsimd/package-lock.json +0 -1688
- package/simsimd/package.json +0 -61
- package/simsimd/rust/benches/cosine.rs +0 -27
- package/simsimd/rust/benches/native.rs +0 -27
- package/simsimd/rust/benches/sqeuclidean.rs +0 -27
- package/simsimd/rust/lib.c +0 -68
- package/simsimd/rust/lib.rs +0 -232
- package/sqlite/README.md +0 -178
- package/sqlite/lib.cpp +0 -325
- package/stringzilla/CONTRIBUTING.md +0 -429
- package/stringzilla/Cargo.lock +0 -25
- package/stringzilla/Cargo.toml +0 -26
- package/stringzilla/LICENSE +0 -201
- package/stringzilla/README.md +0 -1281
- package/stringzilla/VERSION +0 -1
- package/stringzilla/assets/cover-strinzilla.jpeg +0 -0
- package/stringzilla/assets/meme-stringzilla-v2.jpeg +0 -0
- package/stringzilla/assets/meme-stringzilla-v3.jpeg +0 -0
- package/stringzilla/binding.gyp +0 -16
- package/stringzilla/build.rs +0 -14
- package/stringzilla/c/lib.c +0 -304
- package/stringzilla/cli/README.md +0 -48
- package/stringzilla/cli/split.py +0 -72
- package/stringzilla/cli/wc.py +0 -37
- package/stringzilla/include/stringzilla/experimental.h +0 -724
- package/stringzilla/include/stringzilla/module.modulemap +0 -9
- package/stringzilla/include/stringzilla/stringzilla.h +0 -5240
- package/stringzilla/include/stringzilla/stringzilla.hpp +0 -3830
- package/stringzilla/javascript/lib.c +0 -125
- package/stringzilla/javascript/stringzilla.js +0 -22
- package/stringzilla/package-ci.json +0 -10
- package/stringzilla/package.json +0 -32
- package/stringzilla/rust/lib.rs +0 -362
- package/stringzilla/swift/StringProtocol+StringZilla.swift +0 -280
- package/stringzilla/swift/Test.swift +0 -60
- package/tsconfig.json +0 -21
- package/wasmer.toml +0 -12
- package/winlibinstaller.bat +0 -42
- /package/{simsimd/javascript/dist-package-cjs.json → javascript/dist/cjs/package.json} +0 -0
- /package/{simsimd/javascript/dist-package-esm.json → javascript/dist/esm/package.json} +0 -0
|
@@ -0,0 +1,212 @@
|
|
|
1
|
+
type Vector = Float32Array | Float64Array | Int8Array;
|
|
2
|
+
type Matrix = Vector[];
|
|
3
|
+
type VectorOrMatrix = Vector | Matrix;
|
|
4
|
+
/**
|
|
5
|
+
* Enumeration representing the various metric kinds used to measure the distance between vectors in the index.
|
|
6
|
+
* @enum {string}
|
|
7
|
+
* @readonly
|
|
8
|
+
*/
|
|
9
|
+
export declare enum MetricKind {
|
|
10
|
+
Unknown = "unknown",
|
|
11
|
+
Cos = "cos",
|
|
12
|
+
IP = "ip",
|
|
13
|
+
L2sq = "l2sq",
|
|
14
|
+
Haversine = "haversine",
|
|
15
|
+
Divergence = "divergence",
|
|
16
|
+
Pearson = "pearson",
|
|
17
|
+
Jaccard = "jaccard",
|
|
18
|
+
Hamming = "hamming",
|
|
19
|
+
Tanimoto = "tanimoto",
|
|
20
|
+
Sorensen = "sorensen"
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Enumeration representing the various scalar kinds used to define the type of scalar values in vectors.
|
|
24
|
+
* @enum {string}
|
|
25
|
+
* @readonly
|
|
26
|
+
*/
|
|
27
|
+
export declare enum ScalarKind {
|
|
28
|
+
Unknown = "unknown",
|
|
29
|
+
F32 = "f32",
|
|
30
|
+
F64 = "f64",
|
|
31
|
+
F16 = "f16",
|
|
32
|
+
I8 = "i8",
|
|
33
|
+
B1 = "b1"
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Represents a set of search results.
|
|
37
|
+
*/
|
|
38
|
+
export declare class Matches {
|
|
39
|
+
keys: BigUint64Array;
|
|
40
|
+
distances: Float32Array;
|
|
41
|
+
/**
|
|
42
|
+
* Constructs a Matches object.
|
|
43
|
+
*
|
|
44
|
+
* @param {BigUint64Array} keys - The keys of the nearest neighbors found.
|
|
45
|
+
* @param {Float32Array} distances - The distances of the nearest neighbors found.
|
|
46
|
+
*/
|
|
47
|
+
constructor(keys: BigUint64Array, distances: Float32Array);
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Represents a set of batched search results.
|
|
51
|
+
*/
|
|
52
|
+
export declare class BatchMatches {
|
|
53
|
+
keys: BigUint64Array;
|
|
54
|
+
distances: Float32Array;
|
|
55
|
+
counts: BigUint64Array;
|
|
56
|
+
k: number;
|
|
57
|
+
/**
|
|
58
|
+
* Constructs a BatchMatches object.
|
|
59
|
+
*
|
|
60
|
+
* @param {BigUint64Array} keys - The keys of the nearest neighbors found in the batch.
|
|
61
|
+
* @param {Float32Array} distances - The distances of the nearest neighbors found in the batch.
|
|
62
|
+
* @param {BigUint64Array} counts - The number of neighbors found for each query in the batch.
|
|
63
|
+
* @param {number} k - The limit for search results per query in the batch.
|
|
64
|
+
*/
|
|
65
|
+
constructor(keys: BigUint64Array, distances: Float32Array, counts: BigUint64Array, k: number);
|
|
66
|
+
/**
|
|
67
|
+
* Retrieves a Matches object at the specified index in the batch.
|
|
68
|
+
*
|
|
69
|
+
* @param {number} i - The index at which to retrieve the Matches object.
|
|
70
|
+
* @returns {Matches} - A Matches object representing the search results at the specified index in the batch.
|
|
71
|
+
*/
|
|
72
|
+
get(i: number): Matches;
|
|
73
|
+
}
|
|
74
|
+
export interface IndexCongif {
|
|
75
|
+
dimensions: number;
|
|
76
|
+
metric: MetricKind;
|
|
77
|
+
quantization: ScalarKind;
|
|
78
|
+
connectivity: number;
|
|
79
|
+
expansion_add: number;
|
|
80
|
+
expansion_search: number;
|
|
81
|
+
multi: boolean;
|
|
82
|
+
}
|
|
83
|
+
export declare class Index {
|
|
84
|
+
#private;
|
|
85
|
+
/**
|
|
86
|
+
* Constructs a new index.
|
|
87
|
+
*
|
|
88
|
+
* @param {(number | {dimensions: number, metric: MetricKind = MetricKind.Cos, quantization: ScalarKind = ScalarKind.F32, connectivity: number = 0, expansion_add: number = 0, expansion_search: number = 0, multi: boolean = false})} dimensionsOrConfigs
|
|
89
|
+
* @param {MetricKind} [metric=MetricKind.Cos] - Optional, default is 'cos'.
|
|
90
|
+
* @param {ScalarKind} [quantization=ScalarKind.F32] - Optional, default is 'f32'.
|
|
91
|
+
* @param {number} [connectivity=0] - Optional, default is 0.
|
|
92
|
+
* @param {number} [expansion_add=0] - Optional, default is 0.
|
|
93
|
+
* @param {number} [expansion_search=0] - Optional, default is 0.
|
|
94
|
+
* @param {boolean} [multi=false] - Optional, default is false.
|
|
95
|
+
* @throws Will throw an error if any of the parameters are of incorrect type or invalid value.
|
|
96
|
+
*/
|
|
97
|
+
constructor(dimensionsOrConfigs: number | bigint | IndexCongif, metric?: MetricKind, quantization?: ScalarKind, connectivity?: number, expansion_add?: number, expansion_search?: number, multi?: boolean);
|
|
98
|
+
/**
|
|
99
|
+
* Add vectors to the index.
|
|
100
|
+
*
|
|
101
|
+
* This method accepts vectors and their corresponding keys for indexing.
|
|
102
|
+
* Each key should correspond to a vector. If a single key is provided,
|
|
103
|
+
* it is broadcasted to match the number of provided vectors.
|
|
104
|
+
*
|
|
105
|
+
* Vectors should be provided as a flat typed array representing a matrix
|
|
106
|
+
* where each row is a vector to be indexed. The matrix should have a size
|
|
107
|
+
* of n * d, where n is the number of vectors, and d is the dimensionality
|
|
108
|
+
* of the vectors.
|
|
109
|
+
*
|
|
110
|
+
* Keys should be provided as a BigInt or an array-like object of BigInts
|
|
111
|
+
* representing the unique identifier for each vector.
|
|
112
|
+
*
|
|
113
|
+
* @param {bigint|bigint[]|BigUint64Array} keys - Input identifiers for every vector.
|
|
114
|
+
* If a single key is provided, it is associated with all provided vectors.
|
|
115
|
+
* @param {Float32Array|Float64Array|Int8Array} vectors - Input matrix representing vectors,
|
|
116
|
+
* matrix of size n * d, where n is the number of vectors, and d is their dimensionality.
|
|
117
|
+
* @throws Will throw an error if the length of keys doesn't match the number of vectors
|
|
118
|
+
* or if it's not a single key.
|
|
119
|
+
*/
|
|
120
|
+
add(keys: bigint | bigint[] | BigUint64Array, vectors: Vector): void;
|
|
121
|
+
/**
|
|
122
|
+
* Perform a k-nearest neighbor search on the index.
|
|
123
|
+
*
|
|
124
|
+
* This method accepts a matrix of query vectors and returns the closest vectors
|
|
125
|
+
* from the index for each query. The method returns an object containing the keys,
|
|
126
|
+
* distances, and counts of the matches found.
|
|
127
|
+
*
|
|
128
|
+
* Vectors should be provided as a flat typed array representing a matrix where
|
|
129
|
+
* each row is a vector. The matrix should be of size n * d, where n is the
|
|
130
|
+
* number of query vectors, and d is their dimensionality.
|
|
131
|
+
*
|
|
132
|
+
* The parameter `k` specifies the number of nearest neighbors to return for each
|
|
133
|
+
* query vector. If there are not enough results for a query, the result array is
|
|
134
|
+
* padded with -1s.
|
|
135
|
+
*
|
|
136
|
+
* @param {Float32Array|Float64Array|Int8Array|Array<Array<number>>} vectors - Input matrix representing query vectors, can be a TypedArray or an array of TypedArray.
|
|
137
|
+
* @param {number} k - The number of nearest neighbors to search for each query vector.
|
|
138
|
+
* @return {Matches|BatchMatches} - Search results for one or more queries, containing keys, distances, and counts of the matches found.
|
|
139
|
+
* @throws Will throw an error if `k` is not a positive integer or if the size of the vectors is not a multiple of dimensions.
|
|
140
|
+
* @throws Will throw an error if `vectors` is not a valid input type (TypedArray or an array of TypedArray) or if its flattened size is not a multiple of dimensions.
|
|
141
|
+
*/
|
|
142
|
+
search(vectors: VectorOrMatrix, k: number): Matches | BatchMatches;
|
|
143
|
+
/**
|
|
144
|
+
* Verifies the presence of one or more keys in the index.
|
|
145
|
+
*
|
|
146
|
+
* This method accepts one or multiple keys as input and returns a boolean or
|
|
147
|
+
* an array of booleans indicating whether each key is present in the index.
|
|
148
|
+
*
|
|
149
|
+
* @param {bigint|bigint[]|BigUint64Array} keys - The identifier(s) of the vector(s) to be checked for presence in the index.
|
|
150
|
+
* @return {boolean|boolean[]} - Returns true if a single key is contained in the index, false otherwise. Returns an array of booleans corresponding to the presence of each key in the index when multiple keys are provided.
|
|
151
|
+
* @throws Will throw an error if keys are not integers.
|
|
152
|
+
*/
|
|
153
|
+
contains(keys: bigint | bigint[] | BigUint64Array): boolean | boolean[];
|
|
154
|
+
/**
|
|
155
|
+
* Counts the number of times keys shows up in the index.
|
|
156
|
+
*
|
|
157
|
+
* @param {bigint|bigint[]|BigUint64Array} keys - The identifier(s) of the vector(s) to be enumerated.
|
|
158
|
+
* @return {number|number[]} - Returns the number of vectors found when a single key is provided. Returns an array of big integers corresponding to the number of vectors found for each key when multiple keys are provided.
|
|
159
|
+
* @throws Will throw an error if keys are not integers.
|
|
160
|
+
*/
|
|
161
|
+
count(keys: bigint | bigint[] | BigUint64Array): number | number[];
|
|
162
|
+
/**
|
|
163
|
+
* Removes one or multiple vectors from the index.
|
|
164
|
+
*
|
|
165
|
+
* This method accepts one or multiple keys as input and removes the corresponding vectors from the index.
|
|
166
|
+
* It returns the number of vectors actually removed for each key provided.
|
|
167
|
+
*
|
|
168
|
+
* @param {bigint|bigint[]|BigUint64Array} keys - The identifier(s) of the vector(s) to be removed.
|
|
169
|
+
* @return {number|number[]} - Returns the number of vectors deleted when a single key is provided. Returns an array of big integers corresponding to the number of vectors deleted for each key when multiple keys are provided.
|
|
170
|
+
* @throws Will throw an error if keys are not integers.
|
|
171
|
+
*/
|
|
172
|
+
remove(keys: bigint | bigint[] | BigUint64Array): number | number[];
|
|
173
|
+
/**
|
|
174
|
+
* Returns the dimensionality of vectors.
|
|
175
|
+
* @return {number} The dimensionality of vectors.
|
|
176
|
+
*/
|
|
177
|
+
dimensions(): number;
|
|
178
|
+
/**
|
|
179
|
+
* Returns connectivity.
|
|
180
|
+
* @return {number} The connectivity of index.
|
|
181
|
+
*/
|
|
182
|
+
connectivity(): number;
|
|
183
|
+
/**
|
|
184
|
+
* Returns the number of vectors currently indexed.
|
|
185
|
+
* @return {number} The number of vectors currently indexed.
|
|
186
|
+
*/
|
|
187
|
+
size(): number;
|
|
188
|
+
/**
|
|
189
|
+
* Returns index capacity.
|
|
190
|
+
* @return {number} The capacity of index.
|
|
191
|
+
*/
|
|
192
|
+
capacity(): number;
|
|
193
|
+
/**
|
|
194
|
+
* Write index to a file.
|
|
195
|
+
* @param {string} path File path to write.
|
|
196
|
+
* @throws Will throw an error if `path` is not a string.
|
|
197
|
+
*/
|
|
198
|
+
save(path: string): void;
|
|
199
|
+
/**
|
|
200
|
+
* Load index from a file.
|
|
201
|
+
* @param {string} path File path to read.
|
|
202
|
+
* @throws Will throw an error if `path` is not a string.
|
|
203
|
+
*/
|
|
204
|
+
load(path: string): void;
|
|
205
|
+
/**
|
|
206
|
+
* View index from a file, without loading into RAM.
|
|
207
|
+
* @param {string} path File path to read.
|
|
208
|
+
* @throws Will throw an error if `path` is not a string.
|
|
209
|
+
*/
|
|
210
|
+
view(path: string): void;
|
|
211
|
+
}
|
|
212
|
+
export {};
|