pyarrowspace
Python bindings for arrowspace-rs.
arrowspace is a graph-based analytics library for vector spaces, supported by a graph representation and a key-value store. The main use-cases targeted are: AI search capabilities as advanced vector similarity, graph characterisation analysis and search, indexing of high-dimensional vectors. Design principles described in this article.
For labs and tests please see tests/
Installation
Core library
The core library ships as a compiled Rust extension. It only requires numpy, pyarrow, pandas, and scikit-learn:
pip install arrowspace
Optional extras
Additional capabilities are available as optional extras:
| Extra | Packages included | Use case |
|---|---|---|
embeddings |
datasets, sentence-transformers, transformers[torch]<5.0, tsdae |
Generating embeddings from text via HuggingFace models; required for test_1_quora_questions.py and all tests above |
benchmarks |
beir, nltk |
Running BEIR/MS-MARCO benchmark suites and NLP preprocessing |
viz |
matplotlib, seaborn, tqdm |
Plotting results and progress bars in test scripts |
full |
all of the above | Full development and research environment |
Install with one or more extras:
# Required to run test_1_quora_questions.py and above
pip install arrowspace[embeddings]
# Benchmarking + visualisation
pip install arrowspace[benchmarks,viz]
# Everything (for running the full test suite)
pip install arrowspace[full]
Note:
tests/test_0_*.pyonly require the core install. All tests numberedtest_1and above require at minimumarrowspace[embeddings].
Build from source
If you have Cargo installed, you can compile and install locally using maturin:
pip install maturin[patchelf]
# quick development build
maturin develop
# optimised release build (recommended for large datasets)
maturin develop --release
Tests
test_0_*.py scripts only require the core install:
python tests/test_0_0.py
test_1 and above require the embeddings extra (pip install arrowspace[embeddings]):
python tests/test_1_quora_questions.py
Higher-numbered tests (test_3 and above) additionally require benchmarks and viz:
pip install arrowspace[full]
python tests/test_3_beir.py
Some tests require downloading a dataset separately or fine-tuning embeddings on a given dataset.
Simplest Example
from arrowspace import ArrowSpaceBuilder
import numpy as np
items: np.array = np.array(
[[0.1, 0.2, 0.3], [0.0, 0.5, 0.1], [0.9, 0.1, 0.0]],
dtype = np.float64
)
graph_params: dict = {
"eps": 1.0,
"k": 6,
"topk": 3,
"p": 2.0,
"sigma": 1.0,
}
# Create an ArrowSpace instance, returning the computed
# signal graph and lambdas
aspace, gl = ArrowSpaceBuilder().build(graph_params, items)
# Search comparable items
# defaults: k = nitems, alpha = 0.9, beta = 0.1
query: np.array = np.array(
[0.05, 0.2, 0.25],
dtype = np.float64
)
tau: float = 1.0
hits: list = aspace.search(query, gl, tau)
# Search returns a list of `(index, score`) tuples, where
# expected value from the code above show the first index
# having the top score, i.e., being nearest.
print(hits)
# [ (0, 0.989743318610787), (1, 0.7565344158360029), (2, 0.22151940739207396) ]
Metadata
Release files for arrowspace 0.28.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| arrowspace-0.28.1.tar.gz | 18.7 MB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| arrowspace-0.28.1-cp314-cp314-macosx_11_0_arm64.whl | CPython 3.14 | CPython 3.14 | macOS 11.0+ ARM64 | Details |
Total release size: 21.9 MB
Release files / arrowspace-0.28.1.tar.gz
| Download URL | arrowspace-0.28.1.tar.gz |
|---|---|
| Size | 18.7 MB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
93abaa21b2a701236812fa5bfd2e99eb2a688c58d208f6d627071c9be9e199ff
|
|
BLAKE2b-256 checksum How to use checksums |
b29bb48e7cee33ef72a40a0a6a056518e4af04e5c97697e425b17a6c2f789eae
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.12.9 {"installer":{"name":"uv","version":"0.12.9","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
|
Release files / arrowspace-0.28.1-cp314-cp314-macosx_11_0_arm64.whl
| Download URL | arrowspace-0.28.1-cp314-cp314-macosx_11_0_arm64.whl |
|---|---|
| Size | 3.3 MB |
| Tags | CPython 3.14 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
392ac5c6b1011bf08ea0630476b1542c37b6e1b7e2e56f4db016ecd0ec17b89c
|
|
BLAKE2b-256 checksum How to use checksums |
67638f3111f14b28d7042bf77016de005423db4703725ddb3421424f6c9af049
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.12.9 {"installer":{"name":"uv","version":"0.12.9","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
|