Skip to main content

High-performance cosine similarity ranking for Retrieval-Augmented Generation (RAG) pipelines, vector search, and information retrieval, with a Python interface powered by a Rust backend.

Project description

logo-symrank

Similarity ranking for Retrieval-Augmented Generation

Meta       uv  Ruff  Powered by Rust  Analytics in Motion

✨ What is SymRank?

SymRank is a blazing-fast Python library for top-k cosine similarity ranking, designed for vector search, retrieval-augmented generation (RAG), and embedding-based matching.

Built with a Rust + SIMD backend, it offers the speed of native code with the ease of Python.


🚀 Why SymRank?

⚡ Fast: SIMD-accelerated cosine scoring with adaptive parallelism

🧠 Smart: Automatically selects serial or parallel mode based on workload

🔢 Top-K optimized: Efficient inlined heap selection (no full sort overhead)

🐍 Pythonic: Easy-to-use Python API

🦀 Powered by Rust: Safe, high-performance core engine

📉 Memory Efficient: Supports batching for speed and to reduce memory footprint


📦 Installation

You can install SymRank with 'uv' or alternatively using 'pip'.

Recommended (with uv):

uv pip install symrank

Alternatively (using pip):

pip install symrank

🧪 Usage

Basic Example (using python lists)

import symrank as sr

query = [0.1, 0.2, 0.3, 0.4]  
candidates = [
    ("doc_1", [0.1, 0.2, 0.3, 0.5]),
    ("doc_2", [0.9, 0.1, 0.2, 0.1]),
    ("doc_3", [0.0, 0.0, 0.0, 1.0]),
]

results = sr.cosine_similarity(query, candidates, k=2)
print(results)

Output

[{'id': 'doc_1', 'score': 0.9939991235733032}, {'id': 'doc_3', 'score': 0.7302967309951782}]

Basic Example (using numpy arrays)

import symrank as sr
import numpy as np

query = np.array([0.1, 0.2, 0.3, 0.4], dtype=np.float32)
candidates = [
    ("doc_1", np.array([0.1, 0.2, 0.3, 0.5], dtype=np.float32)),
    ("doc_2", np.array([0.9, 0.1, 0.2, 0.1], dtype=np.float32)),
    ("doc_3", np.array([0.0, 0.0, 0.0, 1.0], dtype=np.float32)),
]

results = sr.cosine_similarity(query, candidates, k=2)
print(results)

Output

[{'id': 'doc_1', 'score': 0.9939991235733032}, {'id': 'doc_3', 'score': 0.7302967309951782}]

🧩 API: cosine_similarity(...)

cosine_similarity(
    query_vector,              # List[float] or np.ndarray
    candidate_vectors,         # List[Tuple[str, List[float] or np.ndarray]]
    k=5,                       # Number of top results to return
    batch_size=None            # Optional: set for memory-efficient batching
)

'cosine_similarity(...)' Parameters

Parameter Type Default Description
query_vector list[float] or np.ndarray required The query vector you want to compare against the candidate vectors.
candidate_vectors list[tuple[str, list[float] or np.ndarray]] required List of (id, vector) pairs. Each vector can be a list or NumPy array.
k int 5 Number of top results to return, sorted by descending similarity.
batch_size int or None None Optional batch size to reduce memory usage. If None, uses SIMD directly.

Returns

List of dictionaries with id and score (cosine similarity), sorted by descending similarity:

[{"id": "doc_42", "score": 0.8763}, {"id": "doc_17", "score": 0.8451}, ...]

📄 License

This project is licensed under the Apache License 2.0.

Project details


Download files

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

Source Distribution

symrank-0.1.5.tar.gz (15.7 kB view details)

Uploaded Source

Built Distributions

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

symrank-0.1.5-cp313-cp313-win_amd64.whl (164.3 kB view details)

Uploaded CPython 3.13Windows x86-64

symrank-0.1.5-cp313-cp313-manylinux_2_34_x86_64.whl (290.3 kB view details)

Uploaded CPython 3.13manylinux: glibc 2.34+ x86-64

symrank-0.1.5-cp313-cp313-macosx_11_0_arm64.whl (252.0 kB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

symrank-0.1.5-cp312-cp312-win_amd64.whl (164.4 kB view details)

Uploaded CPython 3.12Windows x86-64

symrank-0.1.5-cp312-cp312-manylinux_2_34_x86_64.whl (290.3 kB view details)

Uploaded CPython 3.12manylinux: glibc 2.34+ x86-64

symrank-0.1.5-cp312-cp312-macosx_11_0_arm64.whl (252.0 kB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

symrank-0.1.5-cp311-cp311-win_amd64.whl (163.8 kB view details)

Uploaded CPython 3.11Windows x86-64

symrank-0.1.5-cp311-cp311-manylinux_2_34_x86_64.whl (292.1 kB view details)

Uploaded CPython 3.11manylinux: glibc 2.34+ x86-64

symrank-0.1.5-cp311-cp311-macosx_11_0_arm64.whl (254.7 kB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

symrank-0.1.5-cp310-cp310-win_amd64.whl (163.9 kB view details)

Uploaded CPython 3.10Windows x86-64

symrank-0.1.5-cp310-cp310-manylinux_2_34_x86_64.whl (292.3 kB view details)

Uploaded CPython 3.10manylinux: glibc 2.34+ x86-64

symrank-0.1.5-cp310-cp310-macosx_11_0_arm64.whl (254.9 kB view details)

Uploaded CPython 3.10macOS 11.0+ ARM64

File details

Details for the file symrank-0.1.5.tar.gz.

File metadata

  • Download URL: symrank-0.1.5.tar.gz
  • Upload date:
  • Size: 15.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for symrank-0.1.5.tar.gz
Algorithm Hash digest
SHA256 1a548189e9d693f8f68505da9ca6aa87b097998ab6b114d1b26399ed5d211630
MD5 4e85b496204ab586dbb91c30aa961f62
BLAKE2b-256 f1df2c6bc51cff756649409b28ececd3884e1c3531db9e540aa142ec5afbdfd8

See more details on using hashes here.

Provenance

The following attestation bundles were made for symrank-0.1.5.tar.gz:

Publisher: CI.yml on analyticsinmotion/symrank

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

File details

Details for the file symrank-0.1.5-cp313-cp313-win_amd64.whl.

File metadata

  • Download URL: symrank-0.1.5-cp313-cp313-win_amd64.whl
  • Upload date:
  • Size: 164.3 kB
  • Tags: CPython 3.13, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for symrank-0.1.5-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 9b25c78e6bdd5da2972da96c85c48da4b6d794473e89fb6b78a38595c03ff582
MD5 bc8d28e88965b9a69bbb8958827e3b65
BLAKE2b-256 ce3851eb17c26231b73cfac41151db0efa7d7b4cf584123cd417417dad62760d

See more details on using hashes here.

Provenance

The following attestation bundles were made for symrank-0.1.5-cp313-cp313-win_amd64.whl:

Publisher: CI.yml on analyticsinmotion/symrank

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

File details

Details for the file symrank-0.1.5-cp313-cp313-manylinux_2_34_x86_64.whl.

File metadata

File hashes

Hashes for symrank-0.1.5-cp313-cp313-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 67ec82433f66a43f09081b4cb595db68185dd6201334dd6a7a9cbf8a8fcce29d
MD5 b94b31acafd085b95638cdf837ebef5c
BLAKE2b-256 58fddd34b027ccd966d8824f50859e285362c50a30ce0bd64eb220388880e9a7

See more details on using hashes here.

Provenance

The following attestation bundles were made for symrank-0.1.5-cp313-cp313-manylinux_2_34_x86_64.whl:

Publisher: CI.yml on analyticsinmotion/symrank

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

File details

Details for the file symrank-0.1.5-cp313-cp313-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for symrank-0.1.5-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 563a95ce38d617522d15bda0f765e952e99080038447206e8b05f9bf5a113f2e
MD5 9099a168e363643872ff9773f5294845
BLAKE2b-256 3cd38c0d56af05c74da52c9cf77fa7596d26d1bcff0666c22ae2d1fdbc74fb94

See more details on using hashes here.

Provenance

The following attestation bundles were made for symrank-0.1.5-cp313-cp313-macosx_11_0_arm64.whl:

Publisher: CI.yml on analyticsinmotion/symrank

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

File details

Details for the file symrank-0.1.5-cp312-cp312-win_amd64.whl.

File metadata

  • Download URL: symrank-0.1.5-cp312-cp312-win_amd64.whl
  • Upload date:
  • Size: 164.4 kB
  • Tags: CPython 3.12, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for symrank-0.1.5-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 407f4f990ff7ee7def9d9736468bf271361eed6e77697e3670cdcfa0ca7d533d
MD5 4be7cd3b96ef2be06f3ca8f5e96a9d59
BLAKE2b-256 c2b26e868bf8051f5f653b13a9978f5dd4e1b23db7e9cdb781b280fe157493f2

See more details on using hashes here.

Provenance

The following attestation bundles were made for symrank-0.1.5-cp312-cp312-win_amd64.whl:

Publisher: CI.yml on analyticsinmotion/symrank

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

File details

Details for the file symrank-0.1.5-cp312-cp312-manylinux_2_34_x86_64.whl.

File metadata

File hashes

Hashes for symrank-0.1.5-cp312-cp312-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 6dce0c1a4fb8adb73df1d3e97d04b57349bc08bc8ae16714d0d2d1b6b82a2092
MD5 a902b4153a03cabe1e4ea41b1e6ea112
BLAKE2b-256 81973ef4bc33f5dd3cb3b92a43167c12f98e8418dc383fc65d23f240bc4b06c2

See more details on using hashes here.

Provenance

The following attestation bundles were made for symrank-0.1.5-cp312-cp312-manylinux_2_34_x86_64.whl:

Publisher: CI.yml on analyticsinmotion/symrank

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

File details

Details for the file symrank-0.1.5-cp312-cp312-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for symrank-0.1.5-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 796a242db4a1ccc0f29e873c0a44efb05d68facea716de495a5b940301d52278
MD5 847bcbf84003d9a17102d9a033cf2f68
BLAKE2b-256 2ec6cfee4b4604f2979797cfa7e6c24eef49dd9a80333bee14e4169e2c8dd33d

See more details on using hashes here.

Provenance

The following attestation bundles were made for symrank-0.1.5-cp312-cp312-macosx_11_0_arm64.whl:

Publisher: CI.yml on analyticsinmotion/symrank

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

File details

Details for the file symrank-0.1.5-cp311-cp311-win_amd64.whl.

File metadata

  • Download URL: symrank-0.1.5-cp311-cp311-win_amd64.whl
  • Upload date:
  • Size: 163.8 kB
  • Tags: CPython 3.11, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for symrank-0.1.5-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 337a98d7023a3106a41fa28f442edb046251f43f940e9c118a9d1031aaf210fc
MD5 7bbdfaf73ef8b1899af62075edc5d9d7
BLAKE2b-256 36ceea1242d47f5c79feb33a46de1db0f1ffacc87bca83c1697bbab3b89d20a0

See more details on using hashes here.

Provenance

The following attestation bundles were made for symrank-0.1.5-cp311-cp311-win_amd64.whl:

Publisher: CI.yml on analyticsinmotion/symrank

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

File details

Details for the file symrank-0.1.5-cp311-cp311-manylinux_2_34_x86_64.whl.

File metadata

File hashes

Hashes for symrank-0.1.5-cp311-cp311-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 4adb74bd6096aa7c5add681b5a27a79273372ed36ff51f75a08c8ca8edf27c88
MD5 698a929201379ca591d798847977027a
BLAKE2b-256 55a49eb166b842c7a1209c7175c1321a88df91b419b6a6c04eb0e5e572ba2d90

See more details on using hashes here.

Provenance

The following attestation bundles were made for symrank-0.1.5-cp311-cp311-manylinux_2_34_x86_64.whl:

Publisher: CI.yml on analyticsinmotion/symrank

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

File details

Details for the file symrank-0.1.5-cp311-cp311-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for symrank-0.1.5-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 f2c0a747db6e9dda41612b8e2eff6af4fedb97c341ed7f7f18101e4d7aa01205
MD5 673f23966c08b837c511a61ce018b73b
BLAKE2b-256 5c520e3b356f7952922172ff4a99e0d9b8509f8c82c9c8b481468ecbff713b44

See more details on using hashes here.

Provenance

The following attestation bundles were made for symrank-0.1.5-cp311-cp311-macosx_11_0_arm64.whl:

Publisher: CI.yml on analyticsinmotion/symrank

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

File details

Details for the file symrank-0.1.5-cp310-cp310-win_amd64.whl.

File metadata

  • Download URL: symrank-0.1.5-cp310-cp310-win_amd64.whl
  • Upload date:
  • Size: 163.9 kB
  • Tags: CPython 3.10, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for symrank-0.1.5-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 d2a6b0ec23db7cd436e2ced2d8da209a1d2b29e54671af0f32f09c7a3702710a
MD5 1d87daf2af0b4cb7e6a1c36a497b3d3a
BLAKE2b-256 e54f793d1c85024ad00084ca07d13a79959c3abb9fd8d6feac107e5e9b9c2bf0

See more details on using hashes here.

Provenance

The following attestation bundles were made for symrank-0.1.5-cp310-cp310-win_amd64.whl:

Publisher: CI.yml on analyticsinmotion/symrank

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

File details

Details for the file symrank-0.1.5-cp310-cp310-manylinux_2_34_x86_64.whl.

File metadata

File hashes

Hashes for symrank-0.1.5-cp310-cp310-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 6046389a27231a864376bd375e45788d9934e231fa901963dd7cf80852628c67
MD5 f8ee410da0782f4311b06216829ce7b4
BLAKE2b-256 f5f69ec40dafd172a2d1188c9471a3d0167a37863e5a726f4a957c42fd3c16c6

See more details on using hashes here.

Provenance

The following attestation bundles were made for symrank-0.1.5-cp310-cp310-manylinux_2_34_x86_64.whl:

Publisher: CI.yml on analyticsinmotion/symrank

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

File details

Details for the file symrank-0.1.5-cp310-cp310-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for symrank-0.1.5-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 9a651a29e46475072e5070e37284bb27330dd34718c2046cc43f6e81798e6539
MD5 fde3a0b5a616c75b2210580f688c4844
BLAKE2b-256 9e34a5410d51a4f474acd7f80307167f5ad2511a97e77c2d7c623d91a35e220f

See more details on using hashes here.

Provenance

The following attestation bundles were made for symrank-0.1.5-cp310-cp310-macosx_11_0_arm64.whl:

Publisher: CI.yml on analyticsinmotion/symrank

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