Query-adaptive sparse/dense/KG reranker for RAG systems.
Project description
gardian-reranker
Query-adaptive sparse/dense/KG reranker for RAG systems.
Install
pip install .
After publishing to PyPI:
pip install gardian-reranker
What it returns
gardian-reranker returns:
- query-level adaptive branch weights: sparse/dense/kg
- ranked passages with final score
- per-passage branch contributions for explainable routing into the reader
Python API
from gardian_reranker import GardianReranker, Candidate, QueryFeatures
reranker = GardianReranker.from_checkpoint("gardian_best.pt", {
"sparse_dim": 3,
"dense_dim": 4,
"kg_dim": 6,
"branch_hidden": 256,
"controller_hidden": 256,
"query_feat_dim": 1024,
"n_qtypes": 7,
"dropout": 0.2
})
query_features = QueryFeatures(
query_emb=[0.0] * 1024,
qtype_onehot=[0, 0, 0, 0, 0, 0, 1],
kg_coverage=0.8
)
candidates = [
Candidate(
id="doc1",
text="Passage text",
sparse_feats=[0.1, 0.2, 0.3],
dense_feats=[0.4, 0.5, 0.6, 0.7],
kg_feats=[0.1, 0.2, 0.3, 0.1, 0.0, 0.4],
)
]
result = reranker.rerank(query_features, candidates)
print(result["query_weights"])
print(result["ranked"][0]["contrib"])
CLI
gardian-rerank \
--checkpoint results/gardian_best_hybrid.pt \
--config config.json \
--input input.json \
--output output.json
PyPI release (maintainers)
- Replace placeholder repository URLs in
pyproject.toml. - Configure Trusted Publishing for your PyPI project.
- Bump
versioninpyproject.toml. - Push a tag, e.g.
v0.1.1:
git tag v0.1.1
git push origin v0.1.1
The GitHub Action .github/workflows/publish-pypi.yml will build and publish automatically.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
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 gardian_reranker-0.1.0.tar.gz.
File metadata
- Download URL: gardian_reranker-0.1.0.tar.gz
- Upload date:
- Size: 6.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6a3e6a9b26a6e222b04915315c6b2fea075495ddc3a98237ae1c6ed0423941c4
|
|
| MD5 |
7851ef59a6e33d15c4bd792cf6b03654
|
|
| BLAKE2b-256 |
fe484a4e56d754eb8d3ac19ce69957b96ea8416682c3de9e5efc5fa01a0e67b1
|
File details
Details for the file gardian_reranker-0.1.0-py3-none-any.whl.
File metadata
- Download URL: gardian_reranker-0.1.0-py3-none-any.whl
- Upload date:
- Size: 7.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f457f0900872678c9d5f2dab786624a76ecbf8b09f5e5218a19e11aa9ce6e58f
|
|
| MD5 |
005679c006c3703d985d2312ca3e701c
|
|
| BLAKE2b-256 |
fac13852d27e37206c61a5c8feb05ccc8fcbc0f72e4d0c6d21a17a05469c23c8
|