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.9.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.9-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.9-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.9-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.9-cp312-cp312-macosx_11_0_arm64.whl (4.1 MB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

arrowspace-0.24.9-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.9.tar.gz.

File metadata

  • Download URL: arrowspace-0.24.9.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.9.tar.gz
Algorithm Hash digest
SHA256 ffeed87d51b924a9c0cd5245df05efd22e8926f4d6798efba98173c616ff522d
MD5 74a6c131fb89edfe7d9ea2cb674c85d5
BLAKE2b-256 5c5ceeb28175d43cc9385bf39c22d05f8ecedcd5420b0067ff8be9dc07261828

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for arrowspace-0.24.9-cp312-cp312-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 23a5247ec32b39eee964fe71de3e8a363a0682ebee00991d6f96026d26a143c3
MD5 6e60515ee2a5744b69ce65082552fb4b
BLAKE2b-256 ee7f58ce163a5d40c3b2e6b33aada2c6f1b900340c0bf55ceac810ce335e3e4a

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for arrowspace-0.24.9-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 1e56e6c098c62324d112751b29781c0fc6c2dd31392bbbfa582f7b0d331e7100
MD5 e8618a33215eceb4c3b5724b7a5e472e
BLAKE2b-256 773d8f794093ba7a9659fc36230b273ea2150b2c1c7e56e5c10b9d5cf1ef2c9c

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for arrowspace-0.24.9-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 1366d36a2ef5a435e2660b9ea4ca1ed9be4e3b913f51e7bef79583d1cd941eba
MD5 25534a253112e2e7b3067c5e630141da
BLAKE2b-256 3755730f1f9fb2edb2b85a9ae64d2e96cbcd4d82c0449aa72d94b4336d911a50

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for arrowspace-0.24.9-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 c4f5a8be457c0862e472bf802556dfa1a87a132c9157b21aebe4387292a49c0a
MD5 69c5a41e21ebc410ef6874cdfd6a1b13
BLAKE2b-256 f008ae45f0835b8631c8613e89970cdd9e18b334f085cb5ad1aa72793f4bb5cd

See more details on using hashes here.

Provenance

The following attestation bundles were made for arrowspace-0.24.9-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.9-cp312-cp312-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for arrowspace-0.24.9-cp312-cp312-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 c32943617dfffcb0979ab3bb4c26ef27c13f0154aa57e82d87d7f0db0bb1bee0
MD5 546799edec9757d6a573da4a5973a9e9
BLAKE2b-256 4788a314c2a26469497739c6d03068730e0ad2e6be37182f4af464ff7e079c96

See more details on using hashes here.

Provenance

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