Skip to content

bmel:levenshteinDistance

Category: LLM & AI Observability · Returns: bmel:integer

bmel:levenshteinDistance(a: bmel:string, b: bmel:string)

Description

Returns the Levenshtein edit distance between two strings: the minimum number of single-character insertions, deletions, or substitutions required to transform a into b. Useful for detecting hallucinations by comparing LLM output against a known ground-truth string, or for measuring output stability across repeated calls.

Arguments

Parameter Type Required Description
a bmel:string Source string.
b bmel:string Target string.

Example

bmel:levenshteinDistance({eval:Response Payload}.$.answer, "expected answer")

Back to BMEL Reference