SeismicSearcher

class lightning_ir.retrieve.seismic.seismic_searcher.SeismicSearcher(index_dir: Path | str, search_config: SeismicSearchConfig, module: BiEncoderModule, use_gpu: bool = False)[source]

Bases: ApproximateSearcher

Seismic Searcher for efficient retrieval using Seismic indexing.

__init__(index_dir: Path | str, search_config: SeismicSearchConfig, module: BiEncoderModule, use_gpu: bool = False) None[source]

Initialize the SeismicSearcher.

Parameters:
  • index_dir (Path | str) – Directory where the Seismic index is stored.

  • search_config (SeismicSearchConfig) – Configuration for the Seismic searcher.

  • module (BiEncoderModule) – The BiEncoder module used for searching.

  • use_gpu (bool) – Whether to use GPU for searching. Defaults to False.

Raises:

ImportError – If the seismic package is not available.

Methods

__init__(index_dir, search_config, module[, ...])

Initialize the SeismicSearcher.

search(output: BiEncoderOutput) Tuple[PackedTensor, List[List[str]]]

Search for documents based on the output of the bi-encoder model.

Parameters:

output (BiEncoderOutput) – The output from the bi-encoder model containing query and document embeddings.

Returns:

The top-k scores and corresponding document IDs.

Return type:

Tuple[PackedTensor, List[List[str]]]

to_gpu() None

Move the searcher to the GPU if available.