LLM validators support transforms. Transforms are applied to the content before sending to the LLM for evaluation.
prompt!
Validates whether a natural-language statement about the output is true based on the actual text.
The prompt validator asks an LLM to check if your statement is supported by the actual output. It focuses on factual consistency rather than exact wording.
Examples
Examples
Writing Effective Statements
Good statements:Negating prompt!
Use thenegate field to assert that a statement is not true:
rubric!
Grades the output against a structured rubric — a list of criteria, each judged by its own isolated LLM call with its own context window. Per-dimension judging grades more reliably than one judge scoring everything at once, and each criterion returnspass / fail / unknown with a reason (unknown is the judge’s escape hatch when the text gives no way to verify — it counts as not passing).
When the rubric fails, the eval report lists every failing criterion with the judge’s reason — you see exactly which requirement broke, not a single opaque fail.
Full form with weighted criteria:
Use
rubric! instead of several prompt! statements when the requirements form one quality bar: you get per-criterion verdicts, weights, a partial-credit threshold, and one aggregate score. The same rubric can also gate an agent at runtime via timbal.guardrails.LLMJudge(rubric=...), which feeds failing criteria back to the agent for revision.semantic!
Uses an LLM to check if the actual value semantically matches the expected description.
The semantic validator sends the actual value and your description to an LLM, which determines if they match semantically.
If your check can be phrased as a verifiable statement, prefer
prompt!. Use semantic! when you’re matching the output against a description of its overall meaning, tone, or style rather than asserting a specific fact about it.Examples
Examples
not_semantic!
Checks that the content does NOT semantically match the description. This is the negated form ofsemantic!.
Examples
Examples
language!
Checks that the content is written in a specific language.Examples
Examples
Common Language Codes
not_language!
Checks that the content is NOT written in a specific language. This is the negated form oflanguage!.
Examples
Examples
LLM vs Exact Matching
Use LLM validation (prompt!, semantic!) when:
- Output wording can vary but meaning must be consistent
- Testing for tone, style, or completeness
- Validating summaries or explanations
eq!, contains!) when:
- Specific words or phrases must appear
- Validating structured data
- Checking for exact values
Common Patterns
Multi-Language Support Testing
Behavioral Checks
Tone and Style Validation
Completeness Checks
Error Message Quality
Using Transforms
Transforms normalize content before LLM evaluation:Combining with Other Validators
Choosing Models
LLM validators use Timbal agents under the hood. By default they useopenai/gpt-5.4-nano, but you can override the model per-validator in YAML.
Agent – the model field here is passed directly through to the underlying agent used for the validator, subject to the provider’s structured-output limitations.
Cost Considerations
LLM validators make API calls to language models, which incur costs. To optimize:- Use structural validators first: Check
not_null!,contains!, etc. before LLM validation - Be specific in statements: Reduces need for retries
- Group LLM checks: One detailed statement vs. multiple simple ones
- Use for critical paths: Reserve LLM validation for important behavioral checks