Matchers
Matchers
Overview of all 5 LLM assertion matchers
LLMAssert provides 5 assertion matchers. All return { pass: boolean, score: number | null, reasoning: string } and support .not negation.
| Matcher | What it checks | Score meaning |
|---|---|---|
toBeGroundedIn | Every claim is supported by the context | 1.0 = fully grounded, 0.0 = fabricated |
toBeFreeOfPII | No personally identifiable information | 1.0 = no PII, 0.0 = definite PII |
toMatchTone | Matches a described tone/sentiment | 1.0 = perfect match, 0.0 = opposite tone |
toBeFormatCompliant | Conforms to a described structure | 1.0 = fully compliant, 0.0 = wrong structure |
toSemanticMatch | Semantically similar to reference text | 1.0 = identical meaning, 0.0 = unrelated |
Common patterns
All matchers accept an optional threshold override:
await expect(response).toBeGroundedIn(context, { threshold: 0.9 });All matchers support .not negation:
await expect(creativeResponse).not.toBeGroundedIn(context);A null score means the evaluation was inconclusive (judge unavailable) — the test passes rather than producing a false failure.
Default threshold
All matchers use 0.7 as the default threshold. Scores at or above the threshold pass.
Threshold sources (highest priority first):
- Inline —
{ threshold: 0.9 }passed to the matcher - Remote — configured per-assertion-type in the dashboard
- Default — 0.7
See Thresholds for detailed guidance on choosing values per matcher.