Skip to main content
A Rule eval passes if the engine’s output satisfies a deterministic rule. No additional LLM calls are required — rule evals are the fastest and most cost-effective type.

Rule sub-types

Sub-typePasses when…
keyword_containsOutput contains all specified keywords (case-insensitive)
keyword_excludesOutput contains none of the forbidden keywords
regexOutput matches the JavaScript regular expression
json_schemaOutput is valid JSON matching the given JSON Schema
length_minOutput character count ≥ minimum
length_maxOutput character count ≤ maximum
custom_jsCustom JavaScript function returns true

When to use

  • The correct answer has a known, fixed form (e.g. a number, a named entity, a required phrase)
  • You need zero-cost, high-speed evaluation with no second LLM call
  • Compliance checks — ensure a required phrase is always present, or a forbidden phrase is never present
  • Output format validation — ensure the engine returns valid JSON matching your schema

Configuring a rule eval

1

Open the Eval Studio

Click the Flask icon in the sidebar.
2

Click New

Click + New in the left eval list panel.
3

Select the type

Click the Rule type card.
4

Choose a rule sub-type

Select the sub-type (e.g. keyword_contains, regex) and fill in the required fields.
5

Enter test input and test output

Use the inline test runner to verify the rule against a sample response before activating.
6

Save and activate

Click Save. Once a test passes, click Activate to start auto-evaluating live responses.

Scoring

ResultCondition
✅ Pass (score: 1.0)Rule condition satisfied
❌ Fail (score: 0.0)Rule condition not satisfied
Pass/fail is binary — no partial credit.

Regex examples

PatternMatches
\d{4}-\d{2}-\d{2}Any ISO date like 2024-03-15
GPT-4[o|turbo]?GPT-4, GPT-4o, GPT-4turbo
(?i)conclusion”Conclusion”, “CONCLUSION”, “conclusion”
Edit this page — Open a pull request