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.
embedding_distance(
self,
prediction: str,
reference: str,
*,
config: Optional[EmbeddingConfig] = None
) -> _MatcherExample:
expect.embedding_distance(
prediction="hello",
reference="hi",
).to_be_less_than(1.0)| Name | Type | Description |
|---|---|---|
prediction* | str | The predicted string to compare. |
reference* | str | The reference string to compare against. |
config | Optional[EmbeddingConfig] | Default: NoneOptional configuration for the embedding distance evaluator. Supported options:
|