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

# whileai.simulations.verify

> Verifiable rewards: programmatic checks a judge cannot game.

Verifiable rewards: programmatic checks a judge cannot game.

3 public names. `import whileai.simulations as wai`, then `wai.name`.

| Name                    | What it does                                                              |
| ----------------------- | ------------------------------------------------------------------------- |
| [`Verifier`](#verifier) | Base class.                                                               |
| [`verifier`](#verifier) | Decorator: turn `fn(candidate, reference, row) -> score` into a Verifier. |
| [`verify`](#verify)     | Verifiers: programmatic, verifiable rewards (RLHF book ch.                |

## package

### verify

Module `whileai.simulations.verify`.

Verifiers: programmatic, verifiable rewards (RLHF book ch. 7, 13).

A verifier is a checker, not a judge: it reads a rollout and decides pass,
fail, or a partial score in \[0, 1], with no model call. Every verifier
honors the judge contract (`callable(row) -> {"reward", "reason"}`), so it
drops into `data.grade(judge=v)`, `evaluate`, `optimize` and a gated
`push` exactly where an LLM judge would go.

import whileai.simulations as wai
from whileai.simulations.verify import MathEqual, All, Regex

v = All(\[MathEqual(), Regex(r"\</think>")])       # right answer, and it closed its reasoning
scored = data.grade(judge=v)                     # verifier IS the reward
rows, \_ = wai.optimize(scored, mode="rl")        # GRPO data with a verifiable reward

The gold answer is read from the row's `privileged.reference` (never
exported to training rows), with flat fields (`answer`, `target`, ...)
as a fallback. Point any verifier at a different column with `field=`.

## base

Verifiers: rewards that are programs, not judges.

### Verifier

```python  theme={null}
Verifier(field: str | None = None, name: str | None = None)
```

Base class. Subclasses implement `check(candidate, reference, row)`
and return a float in \[0, 1] (or a bool), or a `(score, reason)` pair.

Instances are callables honoring the judge contract, and carry `name`
and `kind` so the scored row's `ScorerRef` records what graded it.

### verifier

```python  theme={null}
verifier(fn: Callable[[str, Any, dict], Any]) -> FunctionVerifier
```

Decorator: turn `fn(candidate, reference, row) -> score` into a Verifier.
