Measures the cosine of the angle between two embedding vectors to evaluate semantic similarity based on orientation, not magnitude.
output
(str): The generated text to be evaluated.expectedOutput
(str): The reference or ground truth text.Result
(float): A distance score between 0 and 1.0
: The vectors have the same orientation (perfectly similar).1
: The vectors are orthogonal (no similarity).A · B
is the dot product of the vectors and ||A||
is the vector’s magnitude.
distance = 1 - cosine_similarity
. Lower scores (closer to 0) indicate higher similarity