Skip to main content

Argument parsing with structured class.

Project description

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

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),
        ),
    ]
)

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

reranker-0.2.2.tar.gz (15.2 kB view details)

Uploaded Source

Built Distribution

reranker-0.2.2-py3-none-any.whl (9.8 kB view details)

Uploaded Python 3

File details

Details for the file reranker-0.2.2.tar.gz.

File metadata

  • Download URL: reranker-0.2.2.tar.gz
  • Upload date:
  • Size: 15.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/4.0.2 CPython/3.11.8

File hashes

Hashes for reranker-0.2.2.tar.gz
Algorithm Hash digest
SHA256 4dc0c818daacff63555fc7a553ef949e3fef5098360ee1668f7bf235a8e66693
MD5 6bb118746431f6a8d4bfc82b2c9a7042
BLAKE2b-256 31ece213cb75ac3e354fb3f2cd228fc66f3d7038b2f28b0c0be64f1afd67cb0f

See more details on using hashes here.

File details

Details for the file reranker-0.2.2-py3-none-any.whl.

File metadata

  • Download URL: reranker-0.2.2-py3-none-any.whl
  • Upload date:
  • Size: 9.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/4.0.2 CPython/3.11.8

File hashes

Hashes for reranker-0.2.2-py3-none-any.whl
Algorithm Hash digest
SHA256 a34f9fbe7afc65708d85e4161f36824da441d959f2882e66124f46eb9fccd665
MD5 def5d55b466526f89740eb20c6a1343c
BLAKE2b-256 ca143421571f9c651df66d9cf778212ec21cba253d06c24be48da59c58e9dfc6

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page