Compute the embedding distance between the prediction and reference.
This logs the embedding distance to LangSmith and returns a _Matcher instance
for making assertions on the distance value.
By default, this uses the OpenAI API for computing embeddings.
Example:
expect.embedding_distance(
prediction="hello",
reference="hi",
).to_be_less_than(1.0)The predicted string to compare.
The reference string to compare against.
Optional configuration for the embedding distance evaluator.
Supported options:
encoder: A custom encoder function to encode the list of input
strings to embeddings.
Defaults to the OpenAI API.
metric: The distance metric to use for comparison.
Supported values: 'cosine', 'euclidean', 'manhattan',
'chebyshev', 'hamming'.