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
Similarity ranking for Retrieval-Augmented Generation
✨ 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
📦 Installation
You can install SymRank with 'uv' or alternatively using 'pip'.
Recommended (with uv):
uv pip install symrank
Using pip:
pip install symrank
🧪 Usage
Basic Example
import symrank as sr
query = [0.1, 0.2, 0.3, 0.4] # or np.array([...], dtype=np.float32)
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.compare(query, candidates, top_k=2, vector_size=4)
print(results)
Output
[{'id': 'doc_1', 'score': 0.9987}, {'id': 'doc_3', 'score': 0.8912}]
🧩 API: compare(...)
compare(
query_vector, # List[float] or np.ndarray
candidate_vectors, # List[Tuple[str, List[float] or np.ndarray]]
method="cosine", # Currently only "cosine" is supported
top_k=5, # Number of top results to return
vector_size=1536, # Embedding dimension (default: OpenAI's)
batch_size=None, # Optional: split into batches for large sets
)
'compare(...)' Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
query_vector |
List[float] or np.ndarray | required | Vector to search with |
candidate_vectors |
List[Tuple[str, List[float] or np.ndarray]] | required | (id, vector) pairs to compare against |
method |
str | "cosine" | Similarity method (E.g. "cosine") |
top_k |
int | 5 | Number of results to return |
vector_size |
int | 1536 | Dimensionality of all vectors |
batch_size |
int or None | None | Optional batch size to reduce memory use |
Returns
List of dictionaries with id and score (cosine 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
Built Distributions
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file symrank-0.1.0.tar.gz.
File metadata
- Download URL: symrank-0.1.0.tar.gz
- Upload date:
- Size: 15.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ee831b17e5d5eeb0d1a558058338f9b0bb6aa68a0efe02fbe5c4f1d6f6ba14fb
|
|
| MD5 |
7a0a4e73e4aced64000a0bef29b9e3fe
|
|
| BLAKE2b-256 |
b585c671762d66eaf0f7a9b8b6430b734ceeec0296ebfea0b44ade94b9ebf53e
|
Provenance
The following attestation bundles were made for symrank-0.1.0.tar.gz:
Publisher:
CI.yml on analyticsinmotion/symrank
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
symrank-0.1.0.tar.gz -
Subject digest:
ee831b17e5d5eeb0d1a558058338f9b0bb6aa68a0efe02fbe5c4f1d6f6ba14fb - Sigstore transparency entry: 218753125
- Sigstore integration time:
-
Permalink:
analyticsinmotion/symrank@c90765827ff2d22a2d13b4a918636f4b7cd69c3e -
Branch / Tag:
refs/heads/main - Owner: https://github.com/analyticsinmotion
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
CI.yml@c90765827ff2d22a2d13b4a918636f4b7cd69c3e -
Trigger Event:
workflow_dispatch
-
Statement type:
File details
Details for the file symrank-0.1.0-cp314-cp314-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.
File metadata
- Download URL: symrank-0.1.0-cp314-cp314-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 297.3 kB
- Tags: CPython 3.14, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
772ab56a64e27927576f75a9b2a927022746d911ae3ee4a9e6eee67564921343
|
|
| MD5 |
919ec00f9af2ad24fb0a0d2ca286a6f8
|
|
| BLAKE2b-256 |
2fa0e36dbf4b1808ca7b504455d9dbfa1ad35276d8f424330335d52ea86761cd
|
Provenance
The following attestation bundles were made for symrank-0.1.0-cp314-cp314-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:
Publisher:
CI.yml on analyticsinmotion/symrank
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
symrank-0.1.0-cp314-cp314-manylinux2014_x86_64.manylinux_2_17_x86_64.whl -
Subject digest:
772ab56a64e27927576f75a9b2a927022746d911ae3ee4a9e6eee67564921343 - Sigstore transparency entry: 218753130
- Sigstore integration time:
-
Permalink:
analyticsinmotion/symrank@c90765827ff2d22a2d13b4a918636f4b7cd69c3e -
Branch / Tag:
refs/heads/main - Owner: https://github.com/analyticsinmotion
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
CI.yml@c90765827ff2d22a2d13b4a918636f4b7cd69c3e -
Trigger Event:
workflow_dispatch
-
Statement type:
File details
Details for the file symrank-0.1.0-cp313-cp313-win_amd64.whl.
File metadata
- Download URL: symrank-0.1.0-cp313-cp313-win_amd64.whl
- Upload date:
- Size: 169.6 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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3bd82f2540844478fe7bfedbc2526c315dc709bb336f931055a614cf7e20dd05
|
|
| MD5 |
90a9b6bb2bcbadf4483c05cef99a956f
|
|
| BLAKE2b-256 |
c167e80aff586262008c96110571d5b5f5b6e45308eb9f3dfe4db8c158a46924
|
Provenance
The following attestation bundles were made for symrank-0.1.0-cp313-cp313-win_amd64.whl:
Publisher:
CI.yml on analyticsinmotion/symrank
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
symrank-0.1.0-cp313-cp313-win_amd64.whl -
Subject digest:
3bd82f2540844478fe7bfedbc2526c315dc709bb336f931055a614cf7e20dd05 - Sigstore transparency entry: 218753142
- Sigstore integration time:
-
Permalink:
analyticsinmotion/symrank@c90765827ff2d22a2d13b4a918636f4b7cd69c3e -
Branch / Tag:
refs/heads/main - Owner: https://github.com/analyticsinmotion
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
CI.yml@c90765827ff2d22a2d13b4a918636f4b7cd69c3e -
Trigger Event:
workflow_dispatch
-
Statement type:
File details
Details for the file symrank-0.1.0-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.
File metadata
- Download URL: symrank-0.1.0-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 297.4 kB
- Tags: CPython 3.13, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b1ab5c7f7344c54af15f99baff7fc8b531cf0b1667a4ed3c16818fd882e828cb
|
|
| MD5 |
03e0d1c2f73507c61080982821fae792
|
|
| BLAKE2b-256 |
1b58ce0293b69dc85b666f0a931d89342607f3b255359dbe39cf0b62033559ea
|
Provenance
The following attestation bundles were made for symrank-0.1.0-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:
Publisher:
CI.yml on analyticsinmotion/symrank
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
symrank-0.1.0-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.whl -
Subject digest:
b1ab5c7f7344c54af15f99baff7fc8b531cf0b1667a4ed3c16818fd882e828cb - Sigstore transparency entry: 218753134
- Sigstore integration time:
-
Permalink:
analyticsinmotion/symrank@c90765827ff2d22a2d13b4a918636f4b7cd69c3e -
Branch / Tag:
refs/heads/main - Owner: https://github.com/analyticsinmotion
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
CI.yml@c90765827ff2d22a2d13b4a918636f4b7cd69c3e -
Trigger Event:
workflow_dispatch
-
Statement type:
File details
Details for the file symrank-0.1.0-cp313-cp313-macosx_11_0_arm64.whl.
File metadata
- Download URL: symrank-0.1.0-cp313-cp313-macosx_11_0_arm64.whl
- Upload date:
- Size: 256.1 kB
- Tags: CPython 3.13, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d37afb11e94b3f5076355d07cc76337aed51b03e195bbb1cdc39b35d4f381add
|
|
| MD5 |
38449722b449b44b40f2954ec2a24cee
|
|
| BLAKE2b-256 |
b4c490911d477ed14aabc8430abed4372000a6dd920416438cf70eba307d546c
|
Provenance
The following attestation bundles were made for symrank-0.1.0-cp313-cp313-macosx_11_0_arm64.whl:
Publisher:
CI.yml on analyticsinmotion/symrank
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
symrank-0.1.0-cp313-cp313-macosx_11_0_arm64.whl -
Subject digest:
d37afb11e94b3f5076355d07cc76337aed51b03e195bbb1cdc39b35d4f381add - Sigstore transparency entry: 218753139
- Sigstore integration time:
-
Permalink:
analyticsinmotion/symrank@c90765827ff2d22a2d13b4a918636f4b7cd69c3e -
Branch / Tag:
refs/heads/main - Owner: https://github.com/analyticsinmotion
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
CI.yml@c90765827ff2d22a2d13b4a918636f4b7cd69c3e -
Trigger Event:
workflow_dispatch
-
Statement type: