usearch 0.2.4 → 0.4.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.
@@ -0,0 +1,90 @@
1
+ name: Report a bug
2
+ description: Something doesn't work as expected?
3
+ title: "Bug: "
4
+ labels: ["bug", "invalid"]
5
+ assignees:
6
+ - octocat
7
+ body:
8
+ - type: markdown
9
+ attributes:
10
+ value: |
11
+ Thanks for taking the time to fill out this bug report!
12
+ If you have a small question, it may be faster to ask the maintainers on [Discord](https://discord.gg/4mxGrenbNt).
13
+ - type: textarea
14
+ id: what
15
+ attributes:
16
+ label: Describe the bug
17
+ placeholder: A short description of what the bug is.
18
+ validations:
19
+ required: true
20
+ - type: textarea
21
+ id: steps
22
+ attributes:
23
+ label: Steps to reproduce
24
+ placeholder: Detail the steps taken to reproduce the behavior.
25
+ validations:
26
+ required: true
27
+ - type: textarea
28
+ id: expected
29
+ attributes:
30
+ label: Expected behavior
31
+ placeholder: A clear and concise description of what you expected to happen.
32
+ validations:
33
+ required: true
34
+ - type: input
35
+ id: version
36
+ attributes:
37
+ label: USearch version
38
+ placeholder: v0.4.X
39
+ validations:
40
+ required: true
41
+ - type: input
42
+ id: os
43
+ attributes:
44
+ label: Operating System
45
+ placeholder: Ubuntu 22.04
46
+ validations:
47
+ required: true
48
+ - type: dropdown
49
+ id: hardware
50
+ attributes:
51
+ label: Hardware architecture
52
+ options:
53
+ - x86
54
+ - Arm
55
+ validations:
56
+ required: true
57
+ - type: dropdown
58
+ id: frontend
59
+ attributes:
60
+ label: Which interface are you using?
61
+ options:
62
+ - C++ implementation
63
+ - Python bindings
64
+ - Other bindings
65
+ validations:
66
+ required: true
67
+ - type: input
68
+ id: contact
69
+ attributes:
70
+ label: Contact Details
71
+ description: How can we get in touch with you if we need more info?
72
+ placeholder: email@example.com
73
+ validations:
74
+ required: false
75
+ - type: checkboxes
76
+ id: duplicate
77
+ attributes:
78
+ label: Is there an existing issue for this?
79
+ description: Please search [our issues](https://github.com/unum-cloud/usearch/issues) to see if this bug already exists.
80
+ options:
81
+ - label: I have searched the existing issues
82
+ required: true
83
+ - type: checkboxes
84
+ id: terms
85
+ attributes:
86
+ label: Code of Conduct
87
+ description: By submitting this issue, you agree to follow our [Code of Conduct](https://github.com/unum-cloud/usearch/blob/main/CODE_OF_CONDUCT.md)
88
+ options:
89
+ - label: I agree to follow this project's Code of Conduct
90
+ required: true
@@ -0,0 +1,5 @@
1
+ blank_issues_enabled: false
2
+ contact_links:
3
+ - name: 💬 Ask on Discord
4
+ url: https://discord.gg/A6wxt6dS9j
5
+ about: Real-time communication with maintainers, contributors, and broader community
@@ -0,0 +1,64 @@
1
+ name: Request a feature
2
+ description: Something we haven't implemented yet?
3
+ title: "Feature: "
4
+ labels: ["enhancement"]
5
+ assignees:
6
+ - octocat
7
+ body:
8
+ - type: markdown
9
+ attributes:
10
+ value: |
11
+ Thanks for taking the time to fill out this feature request!
12
+ We have already scheduled a few features for our [next milestone](https://github.com/unum-cloud/usearch/milestones).
13
+ Still, if it is something we have yet to think about, we will happily extend our [roadmap](https://github.com/orgs/unum-cloud/projects/2).
14
+ It is also worth noting that choosing between speed and functionality, we generally prefer the former.
15
+ So in some cases, it makes more sense to build something on top of USearch rather than patch it 🤗
16
+ - type: textarea
17
+ id: what
18
+ attributes:
19
+ label: Describe what you are looking for
20
+ placeholder: A short description of what the feature would look like, ideally with code examples.
21
+ validations:
22
+ required: true
23
+ - type: checkboxes
24
+ id: check
25
+ attributes:
26
+ label: Can you contribute to the implementation?
27
+ options:
28
+ - label: I can contribute
29
+ - type: dropdown
30
+ id: interface
31
+ attributes:
32
+ label: Is your feature request specific to a certain interface?
33
+ options:
34
+ - It applies to everything
35
+ - C++ implementation
36
+ - Python bindings
37
+ - Other bindings
38
+ - Other
39
+ validations:
40
+ required: true
41
+ - type: input
42
+ id: contact
43
+ attributes:
44
+ label: Contact Details
45
+ description: How can we get in touch with you if we need more info?
46
+ placeholder: email@example.com
47
+ validations:
48
+ required: false
49
+ - type: checkboxes
50
+ id: duplicate
51
+ attributes:
52
+ label: Is there an existing issue for this?
53
+ description: Please search [our issues](https://github.com/unum-cloud/usearch/issues) to see if this bug already exists.
54
+ options:
55
+ - label: I have searched the existing issues
56
+ required: true
57
+ - type: checkboxes
58
+ id: terms
59
+ attributes:
60
+ label: Code of Conduct
61
+ description: By submitting this issue, you agree to follow our [Code of Conduct](https://github.com/unum-cloud/usearch/blob/main/CODE_OF_CONDUCT.md)
62
+ options:
63
+ - label: I agree to follow this project's Code of Conduct
64
+ required: true
@@ -86,9 +86,9 @@ jobs:
86
86
  - name: Publish to PyPi
87
87
  uses: pypa/gh-action-pypi-publish@release/v1
88
88
  with:
89
- packages_dir: ./dist/artifact
89
+ packages-dir: ./dist/artifact
90
90
  verbose: true
91
- print_hash: true
91
+ print-hash: true
92
92
 
93
93
  publish_javascript:
94
94
  name: Publish JavaScript
@@ -143,7 +143,7 @@ jobs:
143
143
  java-version: '11'
144
144
  distribution: 'adopt'
145
145
  - name: Setup Gradle
146
- uses: gradle/gradle-build-action@v2
146
+ uses: gradle/gradle-build-action@v2.4.2
147
147
  - name: Execute Gradle build
148
148
  run: gradle clean build
149
149
  - name: Publish package
@@ -171,7 +171,8 @@ jobs:
171
171
  name: github-pages
172
172
  url: ${{ steps.deployment.outputs.page_url }}
173
173
  runs-on: ubuntu-22.04
174
- needs: publish_python
174
+ if: ${{ always() }}
175
+ needs: [publish_python, publish_javascript, publish_rust, publish_java, publish_swift]
175
176
  steps:
176
177
  - name: Checkout
177
178
  uses: actions/checkout@v3
@@ -98,11 +98,13 @@
98
98
  "filesystem": "cpp",
99
99
  "__availability": "cpp",
100
100
  "version": "cpp",
101
- "future": "cpp"
101
+ "future": "cpp",
102
+ "__verbose_abort": "cpp"
102
103
  },
103
104
  "cSpell.words": [
104
105
  "astype",
105
106
  "BLAS",
107
+ "cflags",
106
108
  "downcasted",
107
109
  "Downcasting",
108
110
  "dtype",
@@ -113,6 +115,7 @@
113
115
  "jaccard",
114
116
  "longlong",
115
117
  "memmap",
118
+ "Napi",
116
119
  "ndim",
117
120
  "Numba",
118
121
  "preprocess",
@@ -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.
@@ -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
@@ -1,6 +1,6 @@
1
1
  [package]
2
2
  name = "usearch"
3
- version = "0.2.4"
3
+ version = "0.4.0"
4
4
  authors = ["Ashot Vardanian <1983160+ashvardanian@users.noreply.github.com>"]
5
5
  description = "Smaller & Faster Single-File Vector Search Engine from Unum"
6
6
  edition = "2021"
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
- ![USearch: Vector Search Approaches](assets/usearch-approaches-white.png)
95
+ ![USearch: Vector Search Approaches](https://github.com/unum-cloud/usearch/blob/main/assets/usearch-approaches-white.png?raw=true)
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
- ![USearch uint40_t support](assets/usearch-neighbor-types.png)
109
+ ![USearch uint40_t support](https://github.com/unum-cloud/usearch/blob/main/assets/usearch-neighbor-types.png?raw=true)
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.
@@ -205,7 +205,7 @@ The following distances are pre-packaged:
205
205
  - `pearson_correlation_gt<scalar_t>` for "Pearson" correlation between probability distributions.
206
206
  - `haversine_gt<scalar_t>` for "Haversine" or "Great Circle" distance between coordinates.
207
207
 
208
- #### Bring your Threads
208
+ #### Multi-Threading
209
209
 
210
210
  Most AI, HPC, or Big Data packages use some form of a thread pool.
211
211
  Instead of spawning additional threads within USearch, we focus on the thread safety of `add()` function, simplifying resource management.
@@ -213,7 +213,7 @@ Instead of spawning additional threads within USearch, we focus on the thread sa
213
213
  ```cpp
214
214
  #pragma omp parallel for
215
215
  for (std::size_t i = 0; i < n; ++i)
216
- native.add(label, span_t{vector, dims}, omp_get_thread_num());
216
+ native.add(label, span_t{vector, dims}, add_config_t { .thread = omp_get_thread_num() });
217
217
  ```
218
218
 
219
219
  During initialization, we allocate enough temporary memory for all the cores on the machine.
@@ -383,6 +383,14 @@ let results = index.search(&first, 10).unwrap();
383
383
  assert_eq!(results.count, 2);
384
384
  ```
385
385
 
386
+ #### Multi-Threading
387
+
388
+ ```rust
389
+ assert!(index.add_in_thread(42, &first, 0).is_ok());
390
+ assert!(index.add_in_thread(43, &second, 0).is_ok());
391
+ let results = index.search_in_thread(&first, 10, 0).unwrap();
392
+ ```
393
+
386
394
  Being a systems-programming language, Rust has better control over memory management and concurrency but lacks function overloading.
387
395
  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
396
 
package/VERSION CHANGED
@@ -1 +1 @@
1
- 0.2.4
1
+ 0.4.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!": ["-fno-exceptions", "-Wunknown-pragmas"],
19
- "cflags_cc!": ["-fno-exceptions", "-Wunknown-pragmas"],
20
- "conditions": [
21
- ["OS==\"mac\"", {
22
- "xcode_settings": {
23
- "GCC_ENABLE_CPP_EXCEPTIONS": "YES"
24
- }
25
- }]
26
- ]
18
+ "cflags": ["-fexceptions", "-Wunknown-pragmas", "-std=c99"],
19
+ "cflags_cc": ["-fexceptions", "-Wunknown-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("-Wunknown-pragmas")
5
6
  .include("include")
6
7
  .include("rust")
7
8
  .include("src")
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.2.4'
7
+ version = '0.4.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'
@@ -0,0 +1,5 @@
1
+ ========================
2
+ Benchmarks
3
+ ========================
4
+
5
+ .. mdinclude:: benchmarks.md
@@ -0,0 +1,5 @@
1
+ ========================
2
+ Compilation
3
+ ========================
4
+
5
+ .. mdinclude:: compilation.md