Rules catalog
Similarity
Similarity rule for guardrails
The similarity
rule is used to measure the semantic similarity between a content and a reference text or set of texts.
Parameters:
- type:
similarity
(specifies the rule type) - value: A string or array of strings containing the reference text(s) to compare against
- expected: Usually set to
pass
to ensure the content is sufficiently similar to the reference - threshold: A number between 0 and 1 representing the minimum similarity score required (e.g., 0.8 for 80% similarity)