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[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.5.tar.gz (75.8 kB 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.5-cp312-cp312-manylinux_2_34_x86_64.whl (4.1 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.34+ x86-64

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

Uploaded CPython 3.12macOS 11.0+ ARM64

arrowspace-0.24.5-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.5.tar.gz.

File metadata

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

File hashes

Hashes for arrowspace-0.24.5.tar.gz
Algorithm Hash digest
SHA256 74204fc47b136bd36332c9b701c3811129acb2da2f9453daa2ae8a8bc6842872
MD5 c9eecc94d78e45986db6f6238d77804d
BLAKE2b-256 f36c83627437d08f57d19049eb7ec73d4764895fe82dd08d643eb45cefadc49b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for arrowspace-0.24.5-cp312-cp312-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 433afdf02ba4b390398ab621b5637afe2a1875e68cc3fd48f3006bb606d26032
MD5 318ae9baca9aec10993a1faa8d400c09
BLAKE2b-256 fc8b7f44bd8a80302a429a276241b8760be59228fc4a278c89aad92678875d4f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for arrowspace-0.24.5-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 01567da385f3494ee9494222244106d75c3792ec5e0f6093bfa097e7f4a84ff0
MD5 fa68e7911f6faeb481a037a6cb547e28
BLAKE2b-256 7fd6f51f98d5cf3a87c42635c2bf76d37607dc3d18f912546a5c168783aca0b3

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for arrowspace-0.24.5-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 7f673c79d2cafd9cb2fec7578c89980e41ea85deda42c0eb17d3284eaf5e619a
MD5 aa70a0ee2f1dfc9e12373f3cc96ac463
BLAKE2b-256 ff1bb10453b32a36c8c1f6ec0581d63a170847d05e1c99d867c069b5452af4c1

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for arrowspace-0.24.5-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 6b50b49ddadc3886b7bcfe3f878b26b687d363652bf2ad21083300ad240895e8
MD5 8e5431fe410bf9e2b6976a66bcc9acbe
BLAKE2b-256 de502afcdf0f3dbf3d7ff141f6ba76c6e5d0ae3f7cdbb5608244747310fd370f

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for arrowspace-0.24.5-cp312-cp312-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 f467085e1bcdb7f7d24ee9423ed441d5393e185ac849f08d88a8be78b1cb54e4
MD5 15af9d999df10df840f7814d8cb401d7
BLAKE2b-256 e5ed3735d46ca43acd9292d76289d0aab02ab7f4665c87d2e55781cb80257b28

See more details on using hashes here.

Provenance

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