Skip to content

bmel:jaccardSimilarity

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

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

Description

Returns the Jaccard similarity between two strings, computed as |intersection(tokens(a), tokens(b))| / |union(tokens(a), tokens(b))|. Result in [0, 1]. Useful for measuring token-level overlap between a prompt and a response, or between two generated outputs — a lightweight alternative to embedding similarity.

Arguments

Parameter Type Required Description
a bmel:string First string.
b bmel:string Second string.

Example

bmel:jaccardSimilarity({chat:Request Payload}.$.prompt, {chat:Response Payload}.$.content)

Back to BMEL Reference