Skip to main content

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_*.py only require the core install. All tests numbered test_1 and above require at minimum arrowspace[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) ]

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

arrowspace-0.26.3.tar.gz (17.6 MB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

arrowspace-0.26.3-cp313-cp313-macosx_11_0_arm64.whl (4.9 MB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

arrowspace-0.26.3-cp312-cp312-macosx_10_12_x86_64.whl (5.1 MB view details)

Uploaded CPython 3.12macOS 10.12+ x86-64

File details

Details for the file arrowspace-0.26.3.tar.gz.

File metadata

  • Download URL: arrowspace-0.26.3.tar.gz
  • Upload date:
  • Size: 17.6 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.12.1 {"installer":{"name":"uv","version":"0.12.1","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}

File hashes

Hashes for arrowspace-0.26.3.tar.gz
Algorithm Hash digest
SHA256 259f1745f3623570733ff59436e9e3a6f61fbca1cdb166011958c2cf73b02eb8
MD5 766e9ef1fb09570268ada15fd8e58f69
BLAKE2b-256 c87288c8a86db41b747b025e82eb19c62e0da65360a2bf131deec98c6216f8ff

See more details on using hashes here.

File details

Details for the file arrowspace-0.26.3-cp313-cp313-macosx_11_0_arm64.whl.

File metadata

  • Download URL: arrowspace-0.26.3-cp313-cp313-macosx_11_0_arm64.whl
  • Upload date:
  • Size: 4.9 MB
  • Tags: CPython 3.13, macOS 11.0+ ARM64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.12.1 {"installer":{"name":"uv","version":"0.12.1","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}

File hashes

Hashes for arrowspace-0.26.3-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 02849044167db02ea209305e8d6b1eee54eb952985a1f9a1108e35bda6e6a7f1
MD5 fa0c7811c0aecef780d580ef7c3f54bd
BLAKE2b-256 b75edcb1cf7375fc28c51e1bacaa39a44ea127b33abf94790760eb0fc5b9ad7b

See more details on using hashes here.

File details

Details for the file arrowspace-0.26.3-cp312-cp312-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for arrowspace-0.26.3-cp312-cp312-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 1fb77d2f449c2fe16d53158d1e7ad87c8fc51a673e8c35be54cf9eb60271fcd1
MD5 547fa836326c33c4a874187d5708df79
BLAKE2b-256 ab5ead88cb55759894cc9309ade295fef235312babb0de04256676b04dfcd168

See more details on using hashes here.

Provenance

The following attestation bundles were made for arrowspace-0.26.3-cp312-cp312-macosx_10_12_x86_64.whl:

Publisher: python-publish.yml on tuned-org-uk/pyarrowspace

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page