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)
  • 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.

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.1.0.tar.gz (3.3 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.1.0-py3-none-any.whl (3.4 MB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for small_hybrid_reranker-0.1.0.tar.gz
Algorithm Hash digest
SHA256 89a668c253415d6560bf68026687cf59bd48af3173cc7bf47584f6b73255e48b
MD5 4de8f28a1305fc9714254166988ee0b2
BLAKE2b-256 4d536de2463e753acaebdc0dbb32d2c100d825c7740e545c58ca37122e193ba5

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for small_hybrid_reranker-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 2b7661e04dbeb3f764a70f6025ccf39672c6be01b2dff6b831c7e36fd76bbec7
MD5 e89241be71d8eacf6d913da579163d3d
BLAKE2b-256 95216b23d3f49f758d0b36868f205a0de6c907965ed7d34f0329a1af40ecbeb0

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