Skip to main content

Efficient interpolation-based ranking on CPUs

Project description

Fast-Forward Indexes

This is the implementation of Fast-Forward indexes.

Important: As this library is still in its early stages, the API is subject to change!

Installation

Install the package via pip:

pip install fast-forward-indexes

Getting Started

Using a Fast-Forward index is as simple as providing a TREC run with retrieval scores:

from pathlib import Path
from fast_forward import OnDiskIndex, Mode, Ranking
from fast_forward.encoder import TCTColBERTQueryEncoder

# choose a pre-trained query encoder
encoder = TCTColBERTQueryEncoder("castorini/tct_colbert-msmarco")

# load an index on disk
ff_index = OnDiskIndex.load(Path("/path/to/index.h5"), encoder, Mode.MAXP)

# load a run (TREC format) and attach all required queries
first_stage_ranking = (
    Ranking.from_file(Path("/path/to/input/run.tsv"))
    .attach_queries(
        {
            "q1": "query 1",
            "q2": "query 2",
            # ...
            "qn": "query n",
        }
    )
    .cut(5000)
)

# compute the corresponding semantic scores
out = ff_index(first_stage_ranking)

# interpolate scores and create a new TREC runfile
first_stage_ranking.interpolate(out, 0.1).save(Path("/path/to/output/run.tsv"))

Documentation

A more detailed documentation is available here.

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

fast_forward_indexes-0.2.1.tar.gz (24.6 kB view details)

Uploaded Source

Built Distribution

fast_forward_indexes-0.2.1-py3-none-any.whl (25.6 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: fast_forward_indexes-0.2.1.tar.gz
  • Upload date:
  • Size: 24.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/5.1.0 CPython/3.12.5

File hashes

Hashes for fast_forward_indexes-0.2.1.tar.gz
Algorithm Hash digest
SHA256 f3693b10af6ab4d4523eff765bde864800f43cb5b38274d2476498f30e5699c0
MD5 cbb38a4d95e9870ba2a9471c0db0226b
BLAKE2b-256 9f47b6820132718bd2352b68a4cc8c49d11a55a6d8e3e3e28b5738b7044e90a2

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for fast_forward_indexes-0.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 c63823b9d7109a30ed6ef13b530ba97b08c06472e2003d690bd725c05226a1fa
MD5 9b35ab451d4dab87f91163d35352b28b
BLAKE2b-256 22fe7cc01fd8742cccbfad3645ffcf86d918d288dd53e11a08d9db42ceb0b247

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