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=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.4.0.tar.gz (31.8 kB view details)

Uploaded Source

Built Distribution

fast_forward_indexes-0.4.0-py3-none-any.whl (32.7 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: fast_forward_indexes-0.4.0.tar.gz
  • Upload date:
  • Size: 31.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/5.1.1 CPython/3.12.7

File hashes

Hashes for fast_forward_indexes-0.4.0.tar.gz
Algorithm Hash digest
SHA256 e4dc24ea2961d0ea6ff5cea7085fe991e098ff547c3044fb03babe8f6778f401
MD5 5b29d5c37f31708ffb7a89ee3e0591bb
BLAKE2b-256 ac6d60f7290491a6348c2905f61d3323def5ca9d5b749655d49e96ff64ce9fb4

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for fast_forward_indexes-0.4.0-py3-none-any.whl
Algorithm Hash digest
SHA256 b005a6b208a70b4723fec1c3a6cd4bd28d8d1c2d7cd6a63b8d7e297c8b358969
MD5 a77ba5061cf9de2f47e94a2bab0b0848
BLAKE2b-256 5765e0ad04b6a8a8f561366a1a017fa416e6bcd05c1159a620d40b64a1dc8d45

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