janus.metrics.similarity#

Functions#

similarity_score(target, reference[, model_name, ...])

Computes the similarity score of two strings

Module Contents#

janus.metrics.similarity.similarity_score(target, reference, model_name='text-embedding-3-small', distance_metric='cosine', **kwargs)#

Computes the similarity score of two strings

Parameters:
  • target (str) – The target string.

  • reference (str) – The reference string.

  • model_name (typing_extensions.Annotated[str, typer.Option('-e', '--embedding-model', help='Name of embedding model to use.')]) – The name of the embedding model to use.

  • distance_metric (typing_extensions.Annotated[str, typer.Option('-d', '--distance-metric', click_type=click.Choice([e.value for e in list(EmbeddingDistance)]), help='Distance metric to use.')]) – The distance metric to use. Can be one of: - cosine - euclidean - manhattan - chebyshev - hamming

Returns:

The similarity score of the two strings.

Return type:

float