Skip to main content

Python bindings for ArrowSpace (Rust) providing graph-based similarity search, signal graphs, and spectral methods for vector data.

Project description

pyarrowspace

Python bindings for arrowspace-rs.

arrowspace is a database for vectors 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

From PyPi:

pip install arrowspace

or any other way of installing a Python library.

If you have cargo installed, to compile the libraries involved (from crates.io):

pip install maturin[patchelf]
maturin develop

Tests

Simple test:

python tests/test_0.py

Test with public QA dataset:

python tests/test_1_quora_questions.py

There are other tests but they require downloadin a dataset separately or fine-tuning the embeddings on a given dataset. Give it a try and let me know!

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.24.10.tar.gz (30.0 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.24.10-cp312-cp312-manylinux_2_34_x86_64.whl (4.2 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.34+ x86-64

arrowspace-0.24.10-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (4.8 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.17+ x86-64

arrowspace-0.24.10-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (4.5 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.17+ ARM64

arrowspace-0.24.10-cp312-cp312-macosx_11_0_arm64.whl (4.1 MB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

arrowspace-0.24.10-cp312-cp312-macosx_10_12_x86_64.whl (4.4 MB view details)

Uploaded CPython 3.12macOS 10.12+ x86-64

File details

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

File metadata

  • Download URL: arrowspace-0.24.10.tar.gz
  • Upload date:
  • Size: 30.0 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: maturin/1.9.4

File hashes

Hashes for arrowspace-0.24.10.tar.gz
Algorithm Hash digest
SHA256 ed6a010014f56d291d4d581c8e6f99a5e0e68f945fa51f136a4c941ccf35ce16
MD5 3a0b71fd4a6a2690f4ef1f55c088c7ce
BLAKE2b-256 6153d07aea9a8e02ad38ecf753133b4293b0a75c5a864109b04aab113ad2baf4

See more details on using hashes here.

File details

Details for the file arrowspace-0.24.10-cp312-cp312-manylinux_2_34_x86_64.whl.

File metadata

File hashes

Hashes for arrowspace-0.24.10-cp312-cp312-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 c52f934dfa6646a63fa0154dd94b4785e29a9cd8f6520a4fe2e34e616a8cd5fc
MD5 fa42349ff7cf9bfe7bfe5ada20db3745
BLAKE2b-256 d52ccf2f05b01f0b79248632390a456359de65df4e4c5398e1af3c823ca5f099

See more details on using hashes here.

File details

Details for the file arrowspace-0.24.10-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for arrowspace-0.24.10-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 6b7923de02daee57bc3f94ba47eec1b7ceb591fc1394774b5605b0288ae88763
MD5 5f8ad291a13ccc532c6b70a270d7a1ec
BLAKE2b-256 2de7761adefefb212fc234edb03af1dea36885c6f000a9a549096d80ec36efc9

See more details on using hashes here.

Provenance

The following attestation bundles were made for arrowspace-0.24.10-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_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.

File details

Details for the file arrowspace-0.24.10-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for arrowspace-0.24.10-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 d576f1da934a1cc76b24ed5788f118455bf3cff28c58678fcd2d22399237ab1e
MD5 90953d7173a2f6f30a90cd5e9b569644
BLAKE2b-256 aeb4b22b51d2532657f2dddc3a38147f4c41a3d22c27dedb5bbe7c3b16d3d211

See more details on using hashes here.

Provenance

The following attestation bundles were made for arrowspace-0.24.10-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.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.

File details

Details for the file arrowspace-0.24.10-cp312-cp312-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for arrowspace-0.24.10-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 31817c020e30f88276d48ed770f25d95a845090c556166a46aa7ed919ddf3d94
MD5 5ee57c10a48c97ae5aabc34063ae9e8a
BLAKE2b-256 a6119e6f89aee6c2bf588b71efa0de2a7c90cf3e4b7cb5e1a8e4b4e63c41add6

See more details on using hashes here.

Provenance

The following attestation bundles were made for arrowspace-0.24.10-cp312-cp312-macosx_11_0_arm64.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.

File details

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

File metadata

File hashes

Hashes for arrowspace-0.24.10-cp312-cp312-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 3b8757317d03283701c7b0f02a57f2d2137d3f74fc380810995bb56d5d285f0b
MD5 a6b7fdabba93795c3883c83a8b69c59d
BLAKE2b-256 f439fbf64571767718d7d0ecde3c0732e1bdf9b5a07fb88c01df5f2d3abe4958

See more details on using hashes here.

Provenance

The following attestation bundles were made for arrowspace-0.24.10-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