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. This is experimental software meant for research at current state.

This is the starting repository for arrowspace, it is made public as a showcase for the Python interface, to collect feedback and make public some results of the tests run. To run needs the arrowspace-rs Rust module in a sibling directory.

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
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.22.0.tar.gz (25.3 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.22.0-cp312-cp312-manylinux_2_34_x86_64.whl (764.1 kB view details)

Uploaded CPython 3.12manylinux: glibc 2.34+ x86-64

arrowspace-0.22.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (901.8 kB view details)

Uploaded CPython 3.12manylinux: glibc 2.17+ x86-64

arrowspace-0.22.0-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (851.0 kB view details)

Uploaded CPython 3.12manylinux: glibc 2.17+ ARM64

arrowspace-0.22.0-cp312-cp312-macosx_11_0_arm64.whl (770.7 kB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

arrowspace-0.22.0-cp312-cp312-macosx_10_12_x86_64.whl (803.6 kB view details)

Uploaded CPython 3.12macOS 10.12+ x86-64

File details

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

File metadata

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

File hashes

Hashes for arrowspace-0.22.0.tar.gz
Algorithm Hash digest
SHA256 356215a70213044a92f2c5f3152be3e9719b4636ceb923bf92d22a70c4bc79e7
MD5 e3fecd66989670dc74a61cdd393f5f14
BLAKE2b-256 053bccb95d19519e893c15b382d4f8f75d9fdd3a54acd7ff7c75919dc3b817bd

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for arrowspace-0.22.0-cp312-cp312-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 d36be0ed07a24587bd10494f7997f6555faf7ecb4fc470e36d4ef4ff01713d1f
MD5 8cc633928a712dec67312d9c5edb1575
BLAKE2b-256 b014f93ae8b274123770a2414025775b78e7daee15a0be8ee8bbc2eff88e5e50

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for arrowspace-0.22.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 a64b19b67e6bceb268cd9b0a976d10699c6209489978626f24aab4baad2d7eb3
MD5 828865816566a4096d97e96af03c3475
BLAKE2b-256 47d93e37b6a31bd5fa7289acc8688e2d7f8d08f788b0dc1ff6244bc2fa12aa5a

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for arrowspace-0.22.0-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 71ca3f5f4c059aec131906df967834817bec67c57ae21b475710c770826cae49
MD5 cf40c660e8ed630d48a9d0e81010bbf5
BLAKE2b-256 74a9887f2cbffee56827fa0bbfda732bc7bdd765755f200522c92078d43cf5f4

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for arrowspace-0.22.0-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 a2038690195f90112ac2f2301c77ebcbc5e418d5354e7d767e59b5b75bbf590e
MD5 74bd36e8159bd443c1de3d33f2b31d3e
BLAKE2b-256 2e248732c32f2cbfff67780c2d486f711375376c8ad8a62a4213dd347d32c513

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for arrowspace-0.22.0-cp312-cp312-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 70335d942b576c28183d0190af6bcf707bac62e7b5189b4ac098fedbcb562660
MD5 1ca4c9b54125dc0d3841412d047944e6
BLAKE2b-256 fc69c7f6127ce486f93655f9453f103339451d5dcf8c23499acc965ab71f6bf1

See more details on using hashes here.

Provenance

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