> ## Documentation Index
> Fetch the complete documentation index at: https://docs.mira-app.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Rule Evals

> Deterministic evals that check output against strings, regexes, keywords, schemas, and length constraints.

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-type           | Passes when…                                              |
| ------------------ | --------------------------------------------------------- |
| `keyword_contains` | Output contains all specified keywords (case-insensitive) |
| `keyword_excludes` | Output contains none of the forbidden keywords            |
| `regex`            | Output matches the JavaScript regular expression          |
| `json_schema`      | Output is valid JSON matching the given JSON Schema       |
| `length_min`       | Output character count ≥ minimum                          |
| `length_max`       | Output character count ≤ maximum                          |
| `custom_js`        | Custom 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

<Steps>
  <Step title="Open the Eval Studio">Click the Flask icon in the sidebar.</Step>
  <Step title="Click New">Click **+ New** in the left eval list panel.</Step>
  <Step title="Select the type">Click the **Rule** type card.</Step>

  <Step title="Choose a rule sub-type">
    Select the sub-type (e.g. `keyword_contains`, `regex`) and fill in the required fields.
  </Step>

  <Step title="Enter test input and test output">
    Use the inline test runner to verify the rule against a sample response before activating.
  </Step>

  <Step title="Save and activate">
    Click **Save**. Once a test passes, click **Activate** to start auto-evaluating live responses.
  </Step>
</Steps>

## Scoring

| Result              | Condition                    |
| ------------------- | ---------------------------- |
| ✅ Pass (score: 1.0) | Rule condition satisfied     |
| ❌ Fail (score: 0.0) | Rule condition not satisfied |

Pass/fail is binary — no partial credit.

## Regex examples

| Pattern             | Matches                                  |
| ------------------- | ---------------------------------------- |
| `\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" |

<Note>
  Edit this page — [Open a pull
  request](https://github.com/satyendra2013/mira-app/edit/main/docs/eval-framework/exact-match.mdx)
</Note>
