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

Uploaded Source

Built Distribution

fast_forward_indexes-0.4.1-py3-none-any.whl (32.8 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: fast_forward_indexes-0.4.1.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.1.tar.gz
Algorithm Hash digest
SHA256 a212e81ee6a7a96badf6d6d78bd149d060f14c7c582580f39dee522dffbb0c35
MD5 68653f29254a1e39bec1855b1e318500
BLAKE2b-256 c2c25099b5efb2c6dc53eebd6e356f8315b0c4f5fa7fb19317b7377885ae8028

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for fast_forward_indexes-0.4.1-py3-none-any.whl
Algorithm Hash digest
SHA256 cf15754386548a8d4dc1933bb9d3a8af58f29b9291c54d1a02e0c93b55220730
MD5 849c0d69d94062b3139d48fa366ee7a5
BLAKE2b-256 8ddbda800b9d3429d7a6424a8cdbd37fd46755ece34b3b9d444720e09c51f323

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