Shortcuts

quaterion.eval.samplers.base_sampler module

class BaseSampler(sample_size=-1, device: device | str | None = None, log_progress: bool = True)[source]

Bases: object

Sample part of embeddings and targets to perform metric calculation on a part of the data

Sampler allows reducing amount of time and resources to calculate a distance matrix. Instead of calculation of squared matrix with shape (num_embeddings, num_embeddings), it selects embeddings and computes matrix of a rectangle shape.

Args:

sample_size: amount of objects to select.

reset()[source]

Reset accumulated state if any

sample(dataset: Sized, metric: BaseMetric, model: SimilarityModel) Tuple[Tensor, Tensor][source]

Sample objects and labels to calculate metrics

Parameters:
  • dataset – Sized object, like list, tuple, torch.utils.data.Dataset, etc. to sample

  • metric – metric instance to compute final labels representation

  • model – model to encode objects

Returns:

Tensor, Tensor – metrics labels and computed distance matrix

Qdrant

Learn more about Qdrant vector search project and ecosystem

Discover Qdrant

Similarity Learning

Explore practical problem solving with Similarity Learning

Learn Similarity Learning

Community

Find people dealing with similar problems and get answers to your questions

Join Community