Skip to main content

Lightweight hybrid reranker with baked-in model artifact.

Project description

small-hybrid-reranker

small-hybrid-reranker is a lightweight reranker package with a baked-in trained model.

It reranks a list of passages for a query using a hybrid feature stack:

  • static embeddings (cnmoro/static-nomic-384-pten-v2)
  • lexical overlap and token interaction sketches
  • BM25 and dense retrieval priors
  • listwise LightGBM ranker

The model artifact is included in the package, so there is no separate checkpoint download.

Model In This Release

  • Version 0.2.1 packages a model retrained with cnmoro/static-nomic-384-pten-v2.
  • Training used the SciFact train split in this repository with strict BM25 top-100 candidates and LightGBM LambdaRank over hybrid features.
  • In-split training metric from the full training run:
    • ndcg@10: 0.90908
    • recall@10: 0.90766

Inference remains lightweight and CPU-friendly: the API is still a single HybridReranker().rerank(query, passages) call.

Install

pip install small-hybrid-reranker

Quickstart

from small_hybrid_reranker import HybridReranker

reranker = HybridReranker()

query = "What is the speed of light?"
passages = [
    "The speed of light in a vacuum is about 299,792 km/s.",
    "Earth orbits the Sun in about 365 days.",
    "Newton described laws of motion.",
]

ranked = reranker.rerank(query, passages)
print(ranked[0])
# {'passage': 'The speed of light in a vacuum is about 299,792 km/s.', 'score': 100.0}

API

HybridReranker(model_path: str | None = None)

  • model_path=None: uses baked-in model inside package.
  • model_path="...joblib": load your own compatible artifact.

rerank(query: str, passages: list[str], top_k: int | None = None) -> list[dict]

Returns:

[
  {"passage": "...", "score": 82.31},
  {"passage": "...", "score": 40.87},
]

Scores are floats in [0, 100] and sorted descending.

Notes

  • This package is optimized for reranking a provided candidate list.
  • It is not a full retrieval system by itself.

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

small_hybrid_reranker-0.2.1.tar.gz (11.8 MB view details)

Uploaded Source

Built Distribution

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

small_hybrid_reranker-0.2.1-py3-none-any.whl (11.8 MB view details)

Uploaded Python 3

File details

Details for the file small_hybrid_reranker-0.2.1.tar.gz.

File metadata

  • Download URL: small_hybrid_reranker-0.2.1.tar.gz
  • Upload date:
  • Size: 11.8 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.15

File hashes

Hashes for small_hybrid_reranker-0.2.1.tar.gz
Algorithm Hash digest
SHA256 c9e1f22222756e27b8b61804fd48b04822f844d14e507426e2498ce73a925767
MD5 d882ca098d8caf8403e0b193790f7445
BLAKE2b-256 e3731dce9fcbcb3039363a90689f0c5be1cd233920765ab9d2d53356dde10b6b

See more details on using hashes here.

File details

Details for the file small_hybrid_reranker-0.2.1-py3-none-any.whl.

File metadata

File hashes

Hashes for small_hybrid_reranker-0.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 2e6a82461ce4d876da12266cfad4983d49fd837bb5add98ac297faa734e53111
MD5 61df2bdd30a4ca743ef6c0ea2682803e
BLAKE2b-256 c1897a22c1ad91feade53a32106a485c0fb266d644031aa89abbff2eef292155

See more details on using hashes here.

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