usearch 0.2.4 → 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.
- package/.clang-tidy +60 -0
- package/.github/ISSUE_TEMPLATE/bug_report.yml +90 -0
- package/.github/ISSUE_TEMPLATE/config.yml +5 -0
- package/.github/ISSUE_TEMPLATE/feature_request.yml +64 -0
- package/.github/workflows/release.yml +47 -20
- package/.github/workflows/update_version.sh +1 -0
- package/.vscode/launch.json +22 -0
- package/.vscode/settings.json +9 -1
- package/.vscode/tasks.json +4 -4
- package/CITATION.cff +11 -0
- package/CMakeLists.txt +108 -95
- package/CODE_OF_CONDUCT.md +128 -0
- package/CONTRIBUTING.md +12 -0
- package/Cargo.toml +1 -1
- package/Dockerfile +14 -0
- package/README.md +21 -12
- package/VERSION +1 -1
- package/binding.gyp +13 -9
- package/build.rs +2 -1
- package/cmake/config.cmake.in +15 -0
- package/cmake/pkg-config.pc.in +4 -0
- package/cmake/usearchConfigVersion.cmake.in +20 -0
- package/conanfile.py +1 -1
- package/docs/{Benchmarking.md → benchmarks.md} +11 -2
- package/docs/benchmarks.rst +5 -0
- package/docs/{Compilation.md → compilation.md} +54 -27
- package/docs/compilation.rst +5 -0
- package/docs/conf.dox +2668 -0
- package/docs/index.rst +7 -0
- package/include/usearch/usearch.hpp +833 -439
- package/java/cloud/unum/usearch/cloud_unum_usearch_Index.cpp +17 -16
- package/javascript/lib.cpp +94 -20
- package/javascript/test.js +1 -1
- package/objc/USearchObjective.mm +47 -30
- package/objc/include/USearchObjective.h +18 -26
- package/package.json +1 -1
- package/pyproject.toml +3 -2
- package/python/lib.cpp +216 -130
- package/python/{bench.py → scripts/bench.py} +6 -1
- package/python/scripts/bench_params.py +112 -0
- package/python/{test.py → scripts/test.py} +32 -13
- package/python/usearch/client.py +100 -14
- package/python/usearch/server.py +104 -23
- package/rust/lib.cpp +20 -15
- package/rust/lib.hpp +5 -5
- package/rust/lib.rs +3 -3
- package/setup.py +7 -0
- package/src/CMakeLists.txt +107 -0
- package/src/bench.cpp +54 -19
- package/src/{advanced.hpp → punned.hpp} +235 -203
- package/src/test.cpp +62 -0
- package/swift/Index+Sugar.swift +1 -0
- package/swift/Test.swift +2 -1
- package/wolfram/lib.cpp +14 -14
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
# Contributor Covenant Code of Conduct
|
|
2
|
+
|
|
3
|
+
## Our Pledge
|
|
4
|
+
|
|
5
|
+
We as members, contributors, and leaders pledge to make participation in our
|
|
6
|
+
community a harassment-free experience for everyone, regardless of age, body
|
|
7
|
+
size, visible or invisible disability, ethnicity, sex characteristics, gender
|
|
8
|
+
identity and expression, level of experience, education, socio-economic status,
|
|
9
|
+
nationality, personal appearance, race, religion, or sexual identity
|
|
10
|
+
and orientation.
|
|
11
|
+
|
|
12
|
+
We pledge to act and interact in ways that contribute to an open, welcoming,
|
|
13
|
+
diverse, inclusive, and healthy community.
|
|
14
|
+
|
|
15
|
+
## Our Standards
|
|
16
|
+
|
|
17
|
+
Examples of behavior that contributes to a positive environment for our
|
|
18
|
+
community include:
|
|
19
|
+
|
|
20
|
+
* Demonstrating empathy and kindness toward other people
|
|
21
|
+
* Being respectful of differing opinions, viewpoints, and experiences
|
|
22
|
+
* Giving and gracefully accepting constructive feedback
|
|
23
|
+
* Accepting responsibility and apologizing to those affected by our mistakes,
|
|
24
|
+
and learning from the experience
|
|
25
|
+
* Focusing on what is best not just for us as individuals, but for the
|
|
26
|
+
overall community
|
|
27
|
+
|
|
28
|
+
Examples of unacceptable behavior include:
|
|
29
|
+
|
|
30
|
+
* The use of sexualized language or imagery, and sexual attention or
|
|
31
|
+
advances of any kind
|
|
32
|
+
* Trolling, insulting or derogatory comments, and personal or political attacks
|
|
33
|
+
* Public or private harassment
|
|
34
|
+
* Publishing others' private information, such as a physical or email
|
|
35
|
+
address, without their explicit permission
|
|
36
|
+
* Other conduct which could reasonably be considered inappropriate in a
|
|
37
|
+
professional setting
|
|
38
|
+
|
|
39
|
+
## Enforcement Responsibilities
|
|
40
|
+
|
|
41
|
+
Community leaders are responsible for clarifying and enforcing our standards of
|
|
42
|
+
acceptable behavior and will take appropriate and fair corrective action in
|
|
43
|
+
response to any behavior that they deem inappropriate, threatening, offensive,
|
|
44
|
+
or harmful.
|
|
45
|
+
|
|
46
|
+
Community leaders have the right and responsibility to remove, edit, or reject
|
|
47
|
+
comments, commits, code, wiki edits, issues, and other contributions that are
|
|
48
|
+
not aligned to this Code of Conduct, and will communicate reasons for moderation
|
|
49
|
+
decisions when appropriate.
|
|
50
|
+
|
|
51
|
+
## Scope
|
|
52
|
+
|
|
53
|
+
This Code of Conduct applies within all community spaces, and also applies when
|
|
54
|
+
an individual is officially representing the community in public spaces.
|
|
55
|
+
Examples of representing our community include using an official e-mail address,
|
|
56
|
+
posting via an official social media account, or acting as an appointed
|
|
57
|
+
representative at an online or offline event.
|
|
58
|
+
|
|
59
|
+
## Enforcement
|
|
60
|
+
|
|
61
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
|
62
|
+
reported to the community leaders responsible for enforcement at
|
|
63
|
+
info@unum.cloud.
|
|
64
|
+
All complaints will be reviewed and investigated promptly and fairly.
|
|
65
|
+
|
|
66
|
+
All community leaders are obligated to respect the privacy and security of the
|
|
67
|
+
reporter of any incident.
|
|
68
|
+
|
|
69
|
+
## Enforcement Guidelines
|
|
70
|
+
|
|
71
|
+
Community leaders will follow these Community Impact Guidelines in determining
|
|
72
|
+
the consequences for any action they deem in violation of this Code of Conduct:
|
|
73
|
+
|
|
74
|
+
### 1. Correction
|
|
75
|
+
|
|
76
|
+
**Community Impact**: Use of inappropriate language or other behavior deemed
|
|
77
|
+
unprofessional or unwelcome in the community.
|
|
78
|
+
|
|
79
|
+
**Consequence**: A private, written warning from community leaders, providing
|
|
80
|
+
clarity around the nature of the violation and an explanation of why the
|
|
81
|
+
behavior was inappropriate. A public apology may be requested.
|
|
82
|
+
|
|
83
|
+
### 2. Warning
|
|
84
|
+
|
|
85
|
+
**Community Impact**: A violation through a single incident or series
|
|
86
|
+
of actions.
|
|
87
|
+
|
|
88
|
+
**Consequence**: A warning with consequences for continued behavior. No
|
|
89
|
+
interaction with the people involved, including unsolicited interaction with
|
|
90
|
+
those enforcing the Code of Conduct, for a specified period of time. This
|
|
91
|
+
includes avoiding interactions in community spaces as well as external channels
|
|
92
|
+
like social media. Violating these terms may lead to a temporary or
|
|
93
|
+
permanent ban.
|
|
94
|
+
|
|
95
|
+
### 3. Temporary Ban
|
|
96
|
+
|
|
97
|
+
**Community Impact**: A serious violation of community standards, including
|
|
98
|
+
sustained inappropriate behavior.
|
|
99
|
+
|
|
100
|
+
**Consequence**: A temporary ban from any sort of interaction or public
|
|
101
|
+
communication with the community for a specified period of time. No public or
|
|
102
|
+
private interaction with the people involved, including unsolicited interaction
|
|
103
|
+
with those enforcing the Code of Conduct, is allowed during this period.
|
|
104
|
+
Violating these terms may lead to a permanent ban.
|
|
105
|
+
|
|
106
|
+
### 4. Permanent Ban
|
|
107
|
+
|
|
108
|
+
**Community Impact**: Demonstrating a pattern of violation of community
|
|
109
|
+
standards, including sustained inappropriate behavior, harassment of an
|
|
110
|
+
individual, or aggression toward or disparagement of classes of individuals.
|
|
111
|
+
|
|
112
|
+
**Consequence**: A permanent ban from any sort of public interaction within
|
|
113
|
+
the community.
|
|
114
|
+
|
|
115
|
+
## Attribution
|
|
116
|
+
|
|
117
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage],
|
|
118
|
+
version 2.0, available at
|
|
119
|
+
https://www.contributor-covenant.org/version/2/0/code_of_conduct.html.
|
|
120
|
+
|
|
121
|
+
Community Impact Guidelines were inspired by [Mozilla's code of conduct
|
|
122
|
+
enforcement ladder](https://github.com/mozilla/diversity).
|
|
123
|
+
|
|
124
|
+
[homepage]: https://www.contributor-covenant.org
|
|
125
|
+
|
|
126
|
+
For answers to common questions about this code of conduct, see the FAQ at
|
|
127
|
+
https://www.contributor-covenant.org/faq. Translations are available at
|
|
128
|
+
https://www.contributor-covenant.org/translations.
|
package/CONTRIBUTING.md
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
# Contribution Guide
|
|
2
|
+
|
|
3
|
+
Thank you for even opening this page!
|
|
4
|
+
It's always nice to have third-party contributors!
|
|
5
|
+
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
To keep the quality of the code high, we have a set of guidelines common to all Unum projects.
|
|
9
|
+
|
|
10
|
+
- Whats the procedure? [answered](https://github.com/unum-cloud/awesome/blob/main/Workflow.md#organizing-software-development)
|
|
11
|
+
- How to organize branches? [answered](https://github.com/unum-cloud/awesome/blob/main/Workflow.md#branches)
|
|
12
|
+
- How to style commits? [answered](https://github.com/unum-cloud/awesome/blob/main/Workflow.md#commits)
|
package/Cargo.toml
CHANGED
package/Dockerfile
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
# syntax=docker/dockerfile:1
|
|
2
|
+
|
|
3
|
+
FROM ubuntu:23.04
|
|
4
|
+
RUN apt-get update && \
|
|
5
|
+
apt-get install -y --no-install-recommends python3.11 python3-pip && \
|
|
6
|
+
apt-get clean && \
|
|
7
|
+
rm -rf /var/lib/apt/lists/*
|
|
8
|
+
RUN pip3 install --no-cache-dir --break-system-packages ucall usearch
|
|
9
|
+
|
|
10
|
+
WORKDIR /usearch
|
|
11
|
+
COPY python/usearch/server.py server.py
|
|
12
|
+
|
|
13
|
+
CMD ["python3", "./server.py"]
|
|
14
|
+
EXPOSE 8545
|
package/README.md
CHANGED
|
@@ -82,7 +82,7 @@ USearch is designed to be compact and broadly compatible without sacrificing per
|
|
|
82
82
|
> Jump to the [Performance Tuning][benchmarking] section to read about the effects of those hyper-parameters.
|
|
83
83
|
|
|
84
84
|
[sloc]: https://en.wikipedia.org/wiki/Source_lines_of_code
|
|
85
|
-
[benchmarking]: https://github.com/unum-cloud/usearch
|
|
85
|
+
[benchmarking]: https://github.com/unum-cloud/usearch/blob/main/docs/benchmarks.md
|
|
86
86
|
|
|
87
87
|
## User-Defined Functions
|
|
88
88
|
|
|
@@ -92,7 +92,7 @@ A good example would be the rare [Haversine][haversine] distance, used to comput
|
|
|
92
92
|
Another example would be designing a custom metric for **composite embeddings** concatenated from multiple AI models in real-world applications.
|
|
93
93
|
USearch supports that: [Python](#user-defined-functions-in-python) and [C++](#user-defined-functions-in-c) examples.
|
|
94
94
|
|
|
95
|
-

|
|
95
|
+

|
|
96
96
|
|
|
97
97
|
Unlike older approaches indexing high-dimensional spaces, like KD-Trees and Locality Sensitive Hashing, HNSW doesn't require vectors to be identical in length.
|
|
98
98
|
They only have to be comparable.
|
|
@@ -106,7 +106,7 @@ So you can apply it in [obscure][obscure] applications, like searching for simil
|
|
|
106
106
|
Training a quantization model and dimension-reduction is a common approach to accelerate vector search.
|
|
107
107
|
Those, however, are only sometimes reliable, can significantly affect the statistical properties of your data, and require regular adjustments if your distribution shifts.
|
|
108
108
|
|
|
109
|
-

|
|
109
|
+

|
|
110
110
|
|
|
111
111
|
Instead, we have focused on high-precision arithmetic over low-precision downcasted vectors.
|
|
112
112
|
The same index, and `add` and `search` operations will automatically down-cast or up-cast between `f32_t`, `f16_t`, `f64_t`, and `f8_t` representations, even if the hardware doesn't natively support it.
|
|
@@ -157,10 +157,11 @@ index_gt<cos_gt<float>> index;
|
|
|
157
157
|
float vec[3] = {0.1, 0.3, 0.2};
|
|
158
158
|
|
|
159
159
|
index.reserve(10);
|
|
160
|
-
index.add(/* label: */ 42, /* vector: */ {&vec, 3});
|
|
161
|
-
index.search(
|
|
162
|
-
|
|
163
|
-
|
|
160
|
+
index.add(/* label: */ 42, /* vector: */ {&vec[0], 3});
|
|
161
|
+
auto results = index.search(/* query: */ {&vec[0], 3}, 5 /* neighbors */);
|
|
162
|
+
|
|
163
|
+
for (std::size_t i = 0; i != results.size(); ++i)
|
|
164
|
+
results[i].member.label, results[i].member.vector, results[i].distance;
|
|
164
165
|
```
|
|
165
166
|
|
|
166
167
|
The `add` is thread-safe for concurrent index construction.
|
|
@@ -205,7 +206,7 @@ The following distances are pre-packaged:
|
|
|
205
206
|
- `pearson_correlation_gt<scalar_t>` for "Pearson" correlation between probability distributions.
|
|
206
207
|
- `haversine_gt<scalar_t>` for "Haversine" or "Great Circle" distance between coordinates.
|
|
207
208
|
|
|
208
|
-
####
|
|
209
|
+
#### Multi-Threading
|
|
209
210
|
|
|
210
211
|
Most AI, HPC, or Big Data packages use some form of a thread pool.
|
|
211
212
|
Instead of spawning additional threads within USearch, we focus on the thread safety of `add()` function, simplifying resource management.
|
|
@@ -213,7 +214,7 @@ Instead of spawning additional threads within USearch, we focus on the thread sa
|
|
|
213
214
|
```cpp
|
|
214
215
|
#pragma omp parallel for
|
|
215
216
|
for (std::size_t i = 0; i < n; ++i)
|
|
216
|
-
native.add(label, span_t{vector, dims}, omp_get_thread_num());
|
|
217
|
+
native.add(label, span_t{vector, dims}, add_config_t { .thread = omp_get_thread_num() });
|
|
217
218
|
```
|
|
218
219
|
|
|
219
220
|
During initialization, we allocate enough temporary memory for all the cores on the machine.
|
|
@@ -235,7 +236,7 @@ from usearch.index import Index
|
|
|
235
236
|
|
|
236
237
|
index = Index(
|
|
237
238
|
ndim=3, # Define the number of dimensions in input vectors
|
|
238
|
-
metric='cos', # Choose '
|
|
239
|
+
metric='cos', # Choose 'l2sq', 'haversine' or other metric, default = 'ip'
|
|
239
240
|
dtype='f32', # Quantize to 'f16' or 'f8' if needed, default = 'f32'
|
|
240
241
|
connectivity=16, # How frequent should the connections in the graph be, optional
|
|
241
242
|
expansion_add=128, # Control the recall of indexing, optional
|
|
@@ -383,6 +384,14 @@ let results = index.search(&first, 10).unwrap();
|
|
|
383
384
|
assert_eq!(results.count, 2);
|
|
384
385
|
```
|
|
385
386
|
|
|
387
|
+
#### Multi-Threading
|
|
388
|
+
|
|
389
|
+
```rust
|
|
390
|
+
assert!(index.add_in_thread(42, &first, 0).is_ok());
|
|
391
|
+
assert!(index.add_in_thread(43, &second, 0).is_ok());
|
|
392
|
+
let results = index.search_in_thread(&first, 10, 0).unwrap();
|
|
393
|
+
```
|
|
394
|
+
|
|
386
395
|
Being a systems-programming language, Rust has better control over memory management and concurrency but lacks function overloading.
|
|
387
396
|
Aside from the `add` and `search`, USearch Rust binding also provides `add_in_thread` and `search_in_thread`, which let users identify the calling thread to use underlying temporary memory more efficiently.
|
|
388
397
|
|
|
@@ -397,7 +406,7 @@ assert!(index.view("index.usearch").is_ok());
|
|
|
397
406
|
#### Metrics
|
|
398
407
|
|
|
399
408
|
```rust
|
|
400
|
-
assert!(
|
|
409
|
+
assert!(new_l2sq(3, &quant, 0, 0, 0).is_ok());
|
|
401
410
|
assert!(new_cos(3, &quant, 0, 0, 0).is_ok());
|
|
402
411
|
assert!(new_haversine(&quant, 0, 0, 0).is_ok());
|
|
403
412
|
```
|
|
@@ -436,7 +445,7 @@ https://github.com/unum-cloud/usearch
|
|
|
436
445
|
#### Quickstart
|
|
437
446
|
|
|
438
447
|
```swift
|
|
439
|
-
let index = Index.
|
|
448
|
+
let index = Index.l2sq(dimensions: 3, connectivity: 8)
|
|
440
449
|
let vectorA: [Float32] = [0.3, 0.5, 1.2]
|
|
441
450
|
let vectorB: [Float32] = [0.4, 0.2, 1.2]
|
|
442
451
|
index.add(label: 42, vector: vectorA[...])
|
package/VERSION
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
0.
|
|
1
|
+
0.8.0
|
package/binding.gyp
CHANGED
|
@@ -15,15 +15,19 @@
|
|
|
15
15
|
"dependencies": [
|
|
16
16
|
"<!(node -p \"require('node-addon-api').gyp\")"
|
|
17
17
|
],
|
|
18
|
-
"cflags
|
|
19
|
-
"cflags_cc
|
|
20
|
-
"
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
18
|
+
"cflags": ["-fexceptions", "-Wno-unknown-pragmas"],
|
|
19
|
+
"cflags_cc": ["-fexceptions", "-Wno-unknown-pragmas", "-std=c++11"],
|
|
20
|
+
"xcode_settings": {
|
|
21
|
+
"GCC_ENABLE_CPP_EXCEPTIONS": "YES",
|
|
22
|
+
"CLANG_CXX_LIBRARY": "libc++",
|
|
23
|
+
"MACOSX_DEPLOYMENT_TARGET": "10.15"
|
|
24
|
+
},
|
|
25
|
+
"msvs_settings": {
|
|
26
|
+
"VCCLCompilerTool": {
|
|
27
|
+
"ExceptionHandling": 1,
|
|
28
|
+
"AdditionalOptions": [ "-std:c++11" ]
|
|
29
|
+
}
|
|
30
|
+
}
|
|
27
31
|
}
|
|
28
32
|
]
|
|
29
33
|
}
|
package/build.rs
CHANGED
|
@@ -2,6 +2,7 @@ fn main() {
|
|
|
2
2
|
cxx_build::bridge("rust/lib.rs")
|
|
3
3
|
.file("rust/lib.cpp")
|
|
4
4
|
.flag_if_supported("-std=c++11")
|
|
5
|
+
.flag_if_supported("-Wno-unknown-pragmas")
|
|
5
6
|
.include("include")
|
|
6
7
|
.include("rust")
|
|
7
8
|
.include("src")
|
|
@@ -12,6 +13,6 @@ fn main() {
|
|
|
12
13
|
println!("cargo:rerun-if-changed=rust/lib.rs");
|
|
13
14
|
println!("cargo:rerun-if-changed=rust/lib.cpp");
|
|
14
15
|
println!("cargo:rerun-if-changed=rust/lib.hpp");
|
|
15
|
-
println!("cargo:rerun-if-changed=src/
|
|
16
|
+
println!("cargo:rerun-if-changed=src/punned.hpp");
|
|
16
17
|
println!("cargo:rerun-if-changed=include/usearch/usearch.hpp");
|
|
17
18
|
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
include(FindPackageHandleStandardArgs)
|
|
2
|
+
set(${CMAKE_FIND_PACKAGE_NAME}_CONFIG ${CMAKE_CURRENT_LIST_FILE})
|
|
3
|
+
find_package_handle_standard_args(@PROJECT_NAME@ CONFIG_MODE)
|
|
4
|
+
|
|
5
|
+
if(NOT TARGET @PROJECT_NAME@::@USEARCH_TARGET_NAME@)
|
|
6
|
+
include("${CMAKE_CURRENT_LIST_DIR}/@USEARCH_TARGETS_EXPORT_NAME@.cmake")
|
|
7
|
+
if((NOT TARGET @USEARCH_TARGET_NAME@) AND
|
|
8
|
+
(NOT @PROJECT_NAME@_FIND_VERSION OR
|
|
9
|
+
@PROJECT_NAME@_FIND_VERSION VERSION_LESS 3.2.0))
|
|
10
|
+
add_library(@USEARCH_TARGET_NAME@ INTERFACE IMPORTED)
|
|
11
|
+
set_target_properties(@USEARCH_TARGET_NAME@ PROPERTIES
|
|
12
|
+
INTERFACE_LINK_LIBRARIES @PROJECT_NAME@::@USEARCH_TARGET_NAME@
|
|
13
|
+
)
|
|
14
|
+
endif()
|
|
15
|
+
endif()
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
# This is essentially cmake's BasicConfigVersion-SameMajorVersion.cmake.in but
|
|
2
|
+
# without the 32/64-bit check. Since USearch is a header-only library, it doesn't
|
|
3
|
+
# matter if it was built on a different platform than what it is used on (see
|
|
4
|
+
# https://github.com/nlohmann/json/issues/1697).
|
|
5
|
+
set(PACKAGE_VERSION "@PROJECT_VERSION@")
|
|
6
|
+
|
|
7
|
+
if(PACKAGE_VERSION VERSION_LESS PACKAGE_FIND_VERSION)
|
|
8
|
+
set(PACKAGE_VERSION_COMPATIBLE FALSE)
|
|
9
|
+
else()
|
|
10
|
+
|
|
11
|
+
if(PACKAGE_FIND_VERSION_MAJOR STREQUAL "@PROJECT_VERSION_MAJOR@")
|
|
12
|
+
set(PACKAGE_VERSION_COMPATIBLE TRUE)
|
|
13
|
+
else()
|
|
14
|
+
set(PACKAGE_VERSION_COMPATIBLE FALSE)
|
|
15
|
+
endif()
|
|
16
|
+
|
|
17
|
+
if(PACKAGE_FIND_VERSION STREQUAL PACKAGE_VERSION)
|
|
18
|
+
set(PACKAGE_VERSION_EXACT TRUE)
|
|
19
|
+
endif()
|
|
20
|
+
endif()
|
package/conanfile.py
CHANGED
|
@@ -4,7 +4,7 @@ from conans import ConanFile
|
|
|
4
4
|
class USearchConan(ConanFile):
|
|
5
5
|
|
|
6
6
|
name = 'USearch'
|
|
7
|
-
version = '0.
|
|
7
|
+
version = '0.8.0'
|
|
8
8
|
license = 'Apache 2.0'
|
|
9
9
|
url = 'https://github.com/unum-cloud/usearch'
|
|
10
10
|
description = 'Smaller & Faster Single-File Vector Search Engine from Unum'
|
|
@@ -77,7 +77,7 @@ SYNOPSIS
|
|
|
77
77
|
./build_release/bench [--vectors <path>] [--queries <path>] [--neighbors <path>] [-b] [-j
|
|
78
78
|
<integer>] [-c <integer>] [--expansion-add <integer>]
|
|
79
79
|
[--expansion-search <integer>] [--native|--f16quant|--i8quant]
|
|
80
|
-
[--ip|--
|
|
80
|
+
[--ip|--l2sq|--cos|--haversine] [-h]
|
|
81
81
|
|
|
82
82
|
OPTIONS
|
|
83
83
|
--vectors <path>
|
|
@@ -106,7 +106,7 @@ OPTIONS
|
|
|
106
106
|
--f16quant Enable `f16_t` quantization
|
|
107
107
|
--i8quant Enable `int8_t` quantization
|
|
108
108
|
--ip Choose Inner Product metric
|
|
109
|
-
--
|
|
109
|
+
--l2sq Choose L2 Euclidean metric
|
|
110
110
|
--cos Choose Angular metric
|
|
111
111
|
--haversine Choose Haversine metric
|
|
112
112
|
-h, --help Print this help information on this tool and exit
|
|
@@ -170,6 +170,15 @@ mkdir -p datasets/deep_1B/ && \
|
|
|
170
170
|
|
|
171
171
|
## Profiling
|
|
172
172
|
|
|
173
|
+
Enabling Huge Pages:
|
|
174
|
+
|
|
175
|
+
```sh
|
|
176
|
+
sudo cat /proc/sys/vm/nr_hugepages
|
|
177
|
+
sudo sysctl -w vm.nr_hugepages=2048
|
|
178
|
+
sudo reboot
|
|
179
|
+
sudo cat /proc/sys/vm/nr_hugepages
|
|
180
|
+
```
|
|
181
|
+
|
|
173
182
|
With `perf`:
|
|
174
183
|
|
|
175
184
|
```sh
|
|
@@ -1,65 +1,86 @@
|
|
|
1
1
|
# Compiling USearch
|
|
2
2
|
|
|
3
|
-
## Build
|
|
4
|
-
|
|
5
3
|
Before building the first time, please pull submodules.
|
|
6
4
|
|
|
7
5
|
```sh
|
|
8
6
|
git submodule update --init --recursive
|
|
9
7
|
```
|
|
10
8
|
|
|
11
|
-
|
|
9
|
+
## C++
|
|
10
|
+
|
|
11
|
+
Linux:
|
|
12
12
|
|
|
13
13
|
```sh
|
|
14
14
|
cmake -B ./build_release \
|
|
15
15
|
-DCMAKE_CXX_COMPILER="g++-12" \
|
|
16
16
|
-DCMAKE_BUILD_TYPE=Release \
|
|
17
|
+
-DUSEARCH_USE_JEMALLOC=1 \
|
|
17
18
|
-DUSEARCH_USE_OPENMP=1 \
|
|
18
|
-
-
|
|
19
|
+
-DUSEARCH_USE_SIMSIMD=1 \
|
|
20
|
+
-DUSEARCH_BUILD_BENCHMARK=1 \
|
|
21
|
+
-DUSEARCH_BUILD_TEST=1 \
|
|
22
|
+
&& \
|
|
19
23
|
make -C ./build_release -j
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
MacOS:
|
|
27
|
+
|
|
28
|
+
```sh
|
|
29
|
+
brew install libomp llvm
|
|
30
|
+
cmake -B ./build_release \
|
|
31
|
+
-DCMAKE_C_COMPILER="/opt/homebrew/opt/llvm/bin/clang" \
|
|
32
|
+
-DCMAKE_CXX_COMPILER="/opt/homebrew/opt/llvm/bin/clang++" \
|
|
33
|
+
-DUSEARCH_USE_OPENMP=1 \
|
|
34
|
+
-DUSEARCH_USE_SIMSIMD=1 \
|
|
35
|
+
-DUSEARCH_BUILD_BENCHMARK=1 \
|
|
36
|
+
-DUSEARCH_BUILD_TEST=1 \
|
|
37
|
+
&& \
|
|
38
|
+
make -C ./build_release -j
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
Benchmarking:
|
|
20
42
|
|
|
21
|
-
|
|
43
|
+
```sh
|
|
22
44
|
./build_release/bench \
|
|
23
45
|
--vectors datasets/wiki_1M/base.1M.fbin \
|
|
24
46
|
--queries datasets/wiki_1M/query.public.100K.fbin \
|
|
25
47
|
--neighbors datasets/wiki_1M/groundtruth.public.100K.ibin
|
|
26
48
|
|
|
27
|
-
# Large benchmark on a 1TB dataset:
|
|
28
49
|
./build_release/bench \
|
|
29
50
|
--vectors datasets/t2i_1B/base.1B.fbin \
|
|
30
51
|
--queries datasets/t2i_1B/query.public.100K.fbin \
|
|
31
52
|
--neighbors datasets/t2i_1B/groundtruth.public.100K.ibin \
|
|
32
53
|
--output datasets/t2i_1B/index.usearch \
|
|
33
54
|
--cos
|
|
55
|
+
```
|
|
34
56
|
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
57
|
+
## Python
|
|
58
|
+
|
|
59
|
+
```sh
|
|
60
|
+
pip install -e .
|
|
61
|
+
pytest python/scripts/test.py
|
|
40
62
|
```
|
|
41
63
|
|
|
42
|
-
|
|
64
|
+
Benchmarking:
|
|
43
65
|
|
|
44
66
|
```sh
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
-DUSEARCH_USE_OPENMP=1 \
|
|
51
|
-
-B ./build_release && \
|
|
52
|
-
make -C ./build_release -j
|
|
67
|
+
pip install faiss-cpu
|
|
68
|
+
python python/scripts/bench.py \
|
|
69
|
+
--vectors datasets/wiki_1M/base.1M.fbin \
|
|
70
|
+
--queries datasets/wiki_1M/query.public.100K.fbin \
|
|
71
|
+
--neighbors datasets/wiki_1M/groundtruth.public.100K.ibin
|
|
53
72
|
```
|
|
54
73
|
|
|
55
|
-
|
|
74
|
+
> Optional parameters include `connectivity`, `expansion_add`, `expansion_search`.
|
|
75
|
+
|
|
76
|
+
Checking the effect of different embedding dimensions on construction speed:
|
|
56
77
|
|
|
57
78
|
```sh
|
|
58
|
-
|
|
59
|
-
|
|
79
|
+
python python/scripts/bench_params.py dimensions
|
|
80
|
+
python python/scripts/bench_params.py connectivity
|
|
60
81
|
```
|
|
61
82
|
|
|
62
|
-
|
|
83
|
+
## JavaScript
|
|
63
84
|
|
|
64
85
|
```sh
|
|
65
86
|
npm install
|
|
@@ -67,14 +88,14 @@ node javascript/test.js
|
|
|
67
88
|
npm publish
|
|
68
89
|
```
|
|
69
90
|
|
|
70
|
-
|
|
91
|
+
## Rust
|
|
71
92
|
|
|
72
93
|
```sh
|
|
73
94
|
cargo test -p usearch
|
|
74
95
|
cargo publish
|
|
75
96
|
```
|
|
76
97
|
|
|
77
|
-
|
|
98
|
+
## Java
|
|
78
99
|
|
|
79
100
|
```sh
|
|
80
101
|
gradle clean build
|
|
@@ -105,8 +126,14 @@ java -cp . -Djava.library.path=/Users/av/github/usearch/java/cloud/unum/usearch/
|
|
|
105
126
|
java -cp . -Djava.library.path=/Users/av/github/usearch/java cloud.unum.usearch.Index
|
|
106
127
|
```
|
|
107
128
|
|
|
108
|
-
|
|
129
|
+
## Wolfram
|
|
109
130
|
|
|
110
131
|
```sh
|
|
111
132
|
brew install --cask wolfram-engine
|
|
112
133
|
```
|
|
134
|
+
|
|
135
|
+
## Docker
|
|
136
|
+
|
|
137
|
+
```sh
|
|
138
|
+
docker build -t unum/usearch . && docker run unum/usearch
|
|
139
|
+
```
|