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

Uploaded Source

Built Distribution

fast_forward_indexes-0.3.0-py3-none-any.whl (30.6 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: fast_forward_indexes-0.3.0.tar.gz
  • Upload date:
  • Size: 29.5 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.3.0.tar.gz
Algorithm Hash digest
SHA256 c161d6659c78800c61dec230413d8f04053785e67a64dd3d179a415a43df47b5
MD5 f52f18a2b655d5b8ff71b711cf83c2a3
BLAKE2b-256 d4c63dbccb329720969ad71883d602c4d0a4f0471b5e9f759d8c8f0dfa0d810b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for fast_forward_indexes-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 ca597e1f1c4ccb5d13c453b2ee1405028294d0841ae633aa4b716d610aa27619
MD5 54b4a05c30ffb147194a5abe2cffe271
BLAKE2b-256 0015d8a4364b20b389786bdc0bb93416df8669e131ea6047a041cce475fb5639

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