Skip to content
1 min read · 99 words

Function: normalizeScore()

ts
function normalizeScore(
  raw: number,
  metric: DistanceMetric,
  kind: ScoreKind,
): number;

Defined in: src/batteries/vector/helpers.ts:24

Normalize a backend's raw score into a [0, 1] similarity where higher is closer, accounting for the distance metric and whether the raw value is a similarity or a distance.

Parameters

ParameterTypeDescription
rawnumberThe backend's raw score.
metricDistanceMetricThe distance metric the score was computed under.
kindScoreKindWhether raw is a similarity or a distance.

Returns

number

The normalized similarity in [0, 1].