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.


sample_size: amount of objects to select.


Reset accumulated state if any

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

Sample objects and labels to calculate metrics

  • dataset – Sized object, like list, tuple,, etc. to sample

  • metric – metric instance to compute final labels representation

  • model – model to encode objects


Tensor, Tensor – metrics labels and computed distance matrix


Learn more about Qdrant vector search project and ecosystem

Discover Qdrant

Similarity Learning

Explore practical problem solving with Similarity Learning

Learn Similarity Learning


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

Join Community