usearch 0.19.3 → 0.21.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/prerelease.yml +27 -0
- package/Cargo.toml +1 -1
- package/README.md +21 -2
- package/c/test.c +238 -126
- package/conanfile.py +1 -1
- package/cpp/CMakeLists.txt +6 -2
- package/cpp/bench.cpp +41 -4
- package/cpp/test.cpp +12 -12
- package/docs/benchmarks.md +14 -12
- package/include/usearch/index.hpp +603 -100
- package/include/usearch/index_punned_dense.hpp +68 -10
- package/include/usearch/index_punned_helpers.hpp +30 -3
- package/package.json +1 -1
- package/python/lib.cpp +57 -5
- package/python/scripts/join.py +151 -0
- package/python/scripts/test.py +19 -0
- package/python/usearch/eval.py +11 -3
- package/python/usearch/index.py +119 -10
- package/python/usearch/join.py +0 -98
package/cpp/test.cpp
CHANGED
|
@@ -9,8 +9,6 @@
|
|
|
9
9
|
using namespace unum::usearch;
|
|
10
10
|
using namespace unum;
|
|
11
11
|
|
|
12
|
-
using point_id_t = std::int64_t;
|
|
13
|
-
|
|
14
12
|
void expect(bool must_be_true) {
|
|
15
13
|
if (!must_be_true)
|
|
16
14
|
throw std::runtime_error("Failed!");
|
|
@@ -22,6 +20,7 @@ template <typename scalar_at, typename index_at> void test3d(index_at&& index) {
|
|
|
22
20
|
using view_t = span_gt<scalar_t const>;
|
|
23
21
|
using index_t = typename std::remove_reference<index_at>::type;
|
|
24
22
|
using distance_t = typename index_t::distance_t;
|
|
23
|
+
using label_t = typename index_t::label_t;
|
|
25
24
|
|
|
26
25
|
scalar_t vec[3] = {10, 20, 15};
|
|
27
26
|
scalar_t vec_a[3] = {15, 16, 17};
|
|
@@ -31,7 +30,7 @@ template <typename scalar_at, typename index_at> void test3d(index_at&& index) {
|
|
|
31
30
|
index.add(42, view_t{&vec[0], 3ul});
|
|
32
31
|
|
|
33
32
|
// Default approximate search
|
|
34
|
-
|
|
33
|
+
label_t matched_labels[10] = {0};
|
|
35
34
|
distance_t matched_distances[10] = {0};
|
|
36
35
|
std::size_t matched_count = index.search(view_t{&vec[0], 3ul}, 5).dump_to(matched_labels, matched_distances);
|
|
37
36
|
|
|
@@ -52,7 +51,7 @@ template <typename scalar_at, typename index_at> void test3d(index_at&& index) {
|
|
|
52
51
|
// Validate scans
|
|
53
52
|
std::size_t count = 0;
|
|
54
53
|
for (auto member : index) {
|
|
55
|
-
|
|
54
|
+
label_t id = member.label;
|
|
56
55
|
expect(id >= 42 && id <= 44);
|
|
57
56
|
count++;
|
|
58
57
|
}
|
|
@@ -146,11 +145,12 @@ int main(int, char**) {
|
|
|
146
145
|
// static_assert(!std::is_same<index_gt<pearson_correlation_gt<>>::value_type, std::true_type>());
|
|
147
146
|
// static_assert(!std::is_same<index_gt<haversine_gt<>>::value_type, std::true_type>());
|
|
148
147
|
|
|
149
|
-
|
|
150
|
-
test3d<float>(index_gt<
|
|
148
|
+
using big_point_id_t = std::int64_t;
|
|
149
|
+
test3d<float>(index_gt<cos_gt<float>, big_point_id_t, std::uint32_t>{});
|
|
150
|
+
test3d<float>(index_gt<l2sq_gt<float>, big_point_id_t, std::uint32_t>{});
|
|
151
151
|
|
|
152
|
-
test3d<double>(index_gt<cos_gt<double>,
|
|
153
|
-
test3d<double>(index_gt<l2sq_gt<double>,
|
|
152
|
+
test3d<double>(index_gt<cos_gt<double>, big_point_id_t, std::uint32_t>{});
|
|
153
|
+
test3d<double>(index_gt<l2sq_gt<double>, big_point_id_t, std::uint32_t>{});
|
|
154
154
|
|
|
155
155
|
test3d<float>(punned_small_t::make(3, metric_kind_t::cos_k));
|
|
156
156
|
test3d<float>(punned_small_t::make(3, metric_kind_t::l2sq_k));
|
|
@@ -161,11 +161,11 @@ int main(int, char**) {
|
|
|
161
161
|
test3d_punned<float>(punned_small_t::make(3, metric_kind_t::cos_k));
|
|
162
162
|
test3d_punned<float>(punned_small_t::make(3, metric_kind_t::l2sq_k));
|
|
163
163
|
|
|
164
|
-
test_sets(index_gt<jaccard_gt<std::int32_t, float>,
|
|
165
|
-
test_sets(index_gt<jaccard_gt<std::int64_t, float>,
|
|
164
|
+
test_sets(index_gt<jaccard_gt<std::int32_t, float>, big_point_id_t, std::uint32_t>{});
|
|
165
|
+
test_sets(index_gt<jaccard_gt<std::int64_t, float>, big_point_id_t, std::uint32_t>{});
|
|
166
166
|
|
|
167
|
-
test_sets_moved<index_gt<jaccard_gt<std::int32_t, float>,
|
|
168
|
-
test_sets_moved<index_gt<jaccard_gt<std::int64_t, float>,
|
|
167
|
+
test_sets_moved<index_gt<jaccard_gt<std::int32_t, float>, big_point_id_t, std::uint32_t>>();
|
|
168
|
+
test_sets_moved<index_gt<jaccard_gt<std::int64_t, float>, big_point_id_t, std::uint32_t>>();
|
|
169
169
|
|
|
170
170
|
return 0;
|
|
171
171
|
}
|
package/docs/benchmarks.md
CHANGED
|
@@ -117,21 +117,23 @@ OPTIONS
|
|
|
117
117
|
BigANN benchmark is a good starting point, if you are searching for large collections of high-dimensional vectors.
|
|
118
118
|
Those often come with precomputed ground-truth neighbors, which is handy for recall evaluation.
|
|
119
119
|
|
|
120
|
-
| Dataset
|
|
121
|
-
|
|
|
122
|
-
| [Unum UForm
|
|
123
|
-
| [
|
|
124
|
-
|
|
|
125
|
-
|
|
|
126
|
-
| [Microsoft
|
|
127
|
-
| [
|
|
128
|
-
| [Yandex
|
|
129
|
-
|
|
|
130
|
-
|
|
|
120
|
+
| Dataset | Scalar Type | Dimensions | Metric | Size |
|
|
121
|
+
| :----------------------------------------- | :---------: | :--------: | :----: | :-------: |
|
|
122
|
+
| [Unum UForm Creative Captions][unum-cc-3m] | float32 | 256 | IP | 3 GB |
|
|
123
|
+
| [Unum UForm Wiki][unum-wiki-1m] | float32 | 256 | IP | 1 GB |
|
|
124
|
+
| [Yandex Text-to-Image Sample][unum-t2i] | float32 | 200 | Cos | 1 GB |
|
|
125
|
+
| | | | | |
|
|
126
|
+
| [Microsoft SPACEV][spacev] | int8 | 100 | L2 | 93 GB |
|
|
127
|
+
| [Microsoft Turing-ANNS][turing] | float32 | 100 | L2 | 373 GB |
|
|
128
|
+
| [Yandex Deep1B][deep] | float32 | 96 | L2 | 358 GB |
|
|
129
|
+
| [Yandex Text-to-Image][t2i] | float32 | 200 | Cos | 750 GB |
|
|
130
|
+
| | | | | |
|
|
131
|
+
| [ViT-L/12 LAION][laion] | float32 | 2048 | Cos | 2 - 10 TB |
|
|
131
132
|
|
|
132
133
|
Luckily, smaller samples of those datasets are available.
|
|
133
134
|
|
|
134
|
-
[unum-
|
|
135
|
+
[unum-cc-3m]: https://huggingface.co/datasets/unum-cloud/ann-cc-3m
|
|
136
|
+
[unum-wiki-1m]: https://huggingface.co/datasets/unum-cloud/ann-wiki-1m
|
|
135
137
|
[unum-t2i]: https://huggingface.co/datasets/unum-cloud/ann-t2i-1m
|
|
136
138
|
[spacev]: https://github.com/microsoft/SPTAG/tree/main/datasets/SPACEV1B
|
|
137
139
|
[turing]: https://learning2hash.github.io/publications/microsoftturinganns1B/
|