AI-powered validators for semantic matching and language detection
LLM validators use AI models to evaluate content that can’t be easily checked with exact matching. They’re ideal for validating natural language outputs where wording may vary but meaning should be consistent.
LLM validators support transforms. Transforms are applied to the content before sending to the LLM for evaluation.
Uses an LLM to check if the actual value semantically matches the expected description.
Copy
output: semantic!: "A polite greeting that welcomes the user"
Parameter
Type
Description
value
string
Natural language description of expected content
The semantic validator sends the actual value and your description to an LLM, which determines if they match semantically.
Examples
Copy
# Time response validationoutput: semantic!: "a time response mentioning Madrid"# Error handlingoutput: semantic!: "An apologetic message explaining the service is unavailable"# Product descriptionoutput: semantic!: "A detailed product description including price and availability"# Professional toneoutput: semantic!: "A professional response suitable for a business context"
Be specific about what you expect. Vague descriptions lead to inconsistent results.
Good prompts:
Copy
# Specific and measurablesemantic!: "A response that includes at least 3 product recommendations with prices"semantic!: "An error message that mentions the specific field that failed validation"semantic!: "A summary that covers the main points: budget, timeline, and deliverables"
Avoid:
Copy
# Too vaguesemantic!: "A good response"semantic!: "Something helpful"semantic!: "The right answer"
Output wording can vary but meaning must be consistent
Testing for tone, style, or completeness
Validating summaries or explanations
Use exact matching (eq!, contains!) when:
Specific words or phrases must appear
Validating structured data
Checking for exact values
Copy
# Use semantic for flexible contentoutput: semantic!: "Confirms the order was placed successfully"# Use contains for required termsoutput: contains!: "Order #"# Combine both approachesoutput: contains!: "confirmed" semantic!: "A professional confirmation with order details"
Checks that the content does NOT semantically match the description. This is the negated form of semantic!.
Copy
output: not_semantic!: "An error message or apology"
Parameter
Type
Description
value
string
Natural language description that must NOT match
Examples
Copy
# Ensure response is not an erroroutput: not_semantic!: "An error message or failure notification"# Ensure not rude or dismissiveoutput: not_semantic!: "A rude, dismissive, or unhelpful response"# Ensure not off-topicoutput: not_semantic!: "A response about unrelated topics"
Validates whether a natural-language statement about the output is factually true based on the actual text.
Copy
output: prompt!: "The response clearly explains the refund process"
Parameter
Type
Description
value
string
A statement or claim that should be true in 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
Copy
# Check that a specific question was askedoutput: prompt!: "The agent asked the customer about their budget"# Check that a key action was takenoutput: prompt!: "The assistant confirmed the shipping address before placing the order"# Check that required information is presentoutput: prompt!: "The message includes the expected delivery date"
- name: professional_tone runnable: agent.py::agent params: prompt: "I want a refund" output: semantic!: "A professional, empathetic response that acknowledges the request and explains the refund process"- name: casual_tone runnable: agent.py::agent params: prompt: "Hey what's up" output: semantic!: "A casual, friendly greeting that matches the user's informal tone"
output: semantic!: | A comprehensive response that includes: - Acknowledgment of the user's question - Direct answer to the question - Additional context or helpful information - Offer for follow-up assistance
- name: helpful_error_message runnable: agent.py::agent params: prompt: "Buy product XYZ123" output: semantic!: | An error message that: - Clearly states the product was not found - Suggests possible alternatives or corrections - Offers help finding the right product
Transforms normalize content before LLM evaluation:
Copy
# Normalize whitespace before semantic checkoutput: semantic!: value: "A professional greeting" transform: [trim, collapse_whitespace]# Lowercase before language detectionoutput: language!: value: "en" transform: lowercase
LLM validators use Timbal agents under the hood. By default they use openai/gpt-4.1-nano, but you can override the model per-validator in YAML.
Copy
output: # Use a larger OpenAI model for semantic checks semantic!: value: "A helpful, on-topic answer" model: "openai/gpt-5.2" # Use an Anthropic model for language + semantics language!: value: "es" model: "anthropic/claude-sonnet-4-6" # Use a Gemini model for prompt-based factual checks prompt!: value: "The assistant clearly explains the refund process" model: "google/gemini-2.0-flash"
LLM validators rely on structured output. For Anthropic, structured-output support is currently in beta and only available on a limited set of models (for example: Claude Sonnet 4.5/4.6, Claude Opus 4.5/4.6, Claude Haiku 4.5). Make sure you pick one of these Anthropic variants when you set the model field.
You can otherwise pick any model supported by Timbal’s 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.