Skip to main content

Argument parsing with structured class.

Project description

ReRanker

ReRanker for hybrid retrieval.

Installation

pip install reranker

Usage

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

Ranking

  • rank(query: str, docs: list[str])
    • cross-encoder model
    • cohere model
    • diversity
  • 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

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.0.tar.gz (12.8 kB view details)

Uploaded Source

Built Distribution

reranker-0.2.0-py3-none-any.whl (9.5 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: reranker-0.2.0.tar.gz
  • Upload date:
  • Size: 12.8 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.0.tar.gz
Algorithm Hash digest
SHA256 9f726ee0216e50ba5400e24ac401deaf8690c56ef5a2433e08d8834f00fd5471
MD5 752623bd13ca501029cbe3b2bb285576
BLAKE2b-256 d2db6f7108ade9b458435ff7a3b4c4c555deb961e9b154f6c9bd86c1cf7b0bda

See more details on using hashes here.

File details

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

File metadata

  • Download URL: reranker-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 9.5 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.0-py3-none-any.whl
Algorithm Hash digest
SHA256 f46b5943bfe165f9b39aa88b9b6f2b636da46a27cc38a2383af4ea19948a630d
MD5 1b2865fc265ddcbf931bf97eec31db1e
BLAKE2b-256 081790e4d8e7be2cd6bab4f044ccd5008cee5fb29dabfed04e07f04f6365d17e

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