PlaidIndexConfig

class lightning_ir.retrieve.plaid.plaid_indexer.PlaidIndexConfig(num_centroids: int, num_train_embeddings: int | None = None, k_means_iters: int = 4, n_bits: int = 2, seed: int = 42)[source]

Bases: IndexConfig

Configuration class for Plaid indexers in the Lightning IR framework.

__init__(num_centroids: int, num_train_embeddings: int | None = None, k_means_iters: int = 4, n_bits: int = 2, seed: int = 42) None[source]

Initialize the PlaidIndexConfig.

Parameters:
  • num_centroids (int) – Number of centroids for the Plaid index.

  • num_train_embeddings (int | None) – Number of embeddings to use for training the index. If None, it will be set later. Defaults to None.

  • k_means_iters (int) – Number of iterations for k-means clustering. Defaults to 4.

  • n_bits (int) – Number of bits for the residual codec. Defaults to 2.

  • seed (int) – Random seed for reproducibility. Defaults to 42.

Methods

__init__(num_centroids[, ...])

Initialize the PlaidIndexConfig.

Attributes

SUPPORTED_MODELS

classmethod from_pretrained(index_dir: Path | str) IndexConfig

Load the index configuration from a directory.

Parameters:

index_dir (Path | str) – Path to the directory containing the index configuration.

Returns:

An instance of the index configuration class.

Return type:

IndexConfig

Raises:

ValueError – If the index type in the configuration does not match the expected class name.

indexer_class

alias of PlaidIndexer

save(index_dir: Path) None

Save the index configuration to a directory.

Parameters:

index_dir (Path) – The directory to save the index configuration.

to_dict() dict

Convert the index configuration to a dictionary.

Returns:

A dictionary representation of the index configuration.

Return type:

dict