Shortcuts

quaterion.eval.group.group_metric module

class GroupMetric(distance_metric_name: Distance = Distance.COSINE)[source]

Bases: BaseMetric

Base class for group metrics

Parameters:

distance_metric_name – name of a distance metric to calculate distance or similarity matrices. Available names could be found in Distance.

Provides default implementations for distance and interaction matrices calculation. Accumulates embeddings and groups in an accumulator.

compute(embeddings: Tensor, groups: Tensor) Tensor[source]

Compute metric value

Parameters:
  • embeddings – embeddings to calculate metrics on

  • groups – groups to calculate labels

Returns:

torch.Tensor - computed metric

evaluate() Tensor[source]

Perform metric computation with accumulated state

static prepare_labels(groups: Tensor)[source]

Compute metric labels based on samples groups

Parameters:

groups – groups to distinguish similar and dissimilar objects

Returns:

target – torch.Tensor - labels to be used during metric computation

raw_compute(distance_matrix: Tensor, labels: Tensor) Tensor[source]

Perform metric computation on ready distance_matrix and labels

This method does not make any data and labels preparation. It is assumed that distance_matrix has already been calculated, required changes such masking distance from an element to itself have already been applied and corresponding labels have been prepared.

Parameters:
  • distance_matrix – distance matrix ready to metric computation

  • labels – labels ready to metric computation with the same shape as distance_matrix. Possible values are in {0, 1}.

Returns:

torch.Tensor - calculated metric value

reset()[source]

Reset accumulated embeddings, groups

update(embeddings: Tensor, groups: LongTensor, device=None) None[source]

Process and accumulate batch

Parameters:
  • embeddings – embeddings to accumulate

  • groups – groups to distinguish similar and dissimilar objects.

  • device – device to store calculated embeddings and groups on.

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