Skip to main content

ReRanker

ReRanker for hybrid retrieval.

For end-to-end text query service, check qtext.

Ranking

  • rank(query: str, docs: list[str])
  • rank(docs: list[Record])
    • time decay with expressions
    • title n-gram with bm25
    • content n-gram with bm25
    • document boost with expressions
    • title embedding with content embedding
    • title keywords with content keywords
    • combination of the above features

Services

You can start all the service with the following command:

docker compose -f serving/compose.yaml up -d

Installation

pip install reranker

Usage

If you need the cross-encoder model service, you can start the server with the following command:

docker compose -f serving/compose.yaml up -d encoder

If you need the semantic highlight service, you can start the server with the following command:

docker compose -f serving/compose.yaml up -d colbert
from datetime import datetime, timedelta
from reranker import ReRanker, CrossEncoderClient, TimeDecayRanker


reranker = ReRanker(
    steps=[
        CrossEncoderClient(
            model_name="cross-encoder/ms-marco-MiniLM-L-6-v2",
            addr="http://localhost:8000",
        ),
        TimeDecayRanker(decay_rate=0.5),
    ]
)

reranker.rank(
    query="What is the capital of France?",
    docs=[
        "Paris is the capital of France.",
        "The Eiffel Tower is in Paris.",
        "The Louvre is in Paris.",
    ],
)
reranker.rank(
    query=Record(
        text="What is the capital of France?",
        timestamp=datetime.now(),
    ),
    docs=[
        Record(
            text="Paris is the capital of France.",
            timestamp=datetime.now() - timedelta(days=1),
        ),
        Record(
            text="The Eiffel Tower is in Paris.",
            timestamp=datetime.now() - timedelta(days=2),
        ),
        Record(
            text="The Louvre is in Paris.",
            timestamp=datetime.now() - timedelta(days=3),
        ),
    ]
)

Metadata

Release files for reranker 0.2.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for reranker 0.2.3
File Size Uploaded
reranker-0.2.3.tar.gz 15.7 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for reranker 0.2.3
File Interpreter ABI Platform
reranker-0.2.3-py3-none-any.whl Python 3 none any Details

Total release size: 25.5 kB

Release files / reranker-0.2.3.tar.gz

Download URL reranker-0.2.3.tar.gz
Size 15.7 kB
Tags Source
SHA-256 checksum
How to use checksums
5e1ea0932d336b3181a6ecb4f511c1ed4bd5c907396b348fee7f28e0fee84da9
BLAKE2b-256 checksum
How to use checksums
21f4f58cda799752c0cecdcc6918d14117e13f2270c83351dd123a5bd13f1049
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/5.0.0 CPython/3.12.2

Release files / reranker-0.2.3-py3-none-any.whl

Download URL reranker-0.2.3-py3-none-any.whl
Size 9.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
86165605ef6a52b8de0f68dec80f3ca379b017f278215ad3aa1e5a9ac022f8e3
BLAKE2b-256 checksum
How to use checksums
88cd8291fe526e2776ab4dda2477d6d100ee3a02edcdb3f9b6f0d8a0419036c4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/5.0.0 CPython/3.12.2

Release history Release notifications | RSS feed

This release

0.2.3 This release

2 release files

0.2.2

2 release files

0.2.1

2 release files

0.2.0

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page