FaissSearcher
- class lightning_ir.retrieve.faiss.faiss_searcher.FaissSearcher(index_dir: Path | str, search_config: FaissSearchConfig, module: BiEncoderModule, use_gpu: bool = False)[source]
Bases:
ApproximateSearcherFAISS-based searcher for approximate nearest neighbor retrieval in the Lightning IR framework.
- __init__(index_dir: Path | str, search_config: FaissSearchConfig, module: BiEncoderModule, use_gpu: bool = False) None[source]
Initialize the FaissSearcher.
- Parameters:
index_dir (Path | str) – Directory containing the FAISS index files.
search_config (FaissSearchConfig) – Configuration for the FAISS searcher.
module (BiEncoderModule) – The bi-encoder module used for embeddings.
use_gpu (bool) – Whether to use GPU for FAISS operations. Defaults to False.
Methods
__init__(index_dir, search_config, module[, ...])Initialize the FaissSearcher.
- 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]]]