# `Nous.Eval.Scorer`
[🔗](https://github.com/nyo16/nous/blob/v0.21.1/lib/nous/eval/scorer.ex#L1)

Behaviour for eval scorers.

A scorer turns one sample (`Nous.Eval.ScoreInput`) into one or more
`Nous.Eval.Score`s, a skip, or an error:

  * `{:ok, score | [score]}` - a verdict
  * `{:skip, reason}` - the scorer does not apply to this sample; excluded
    from its metrics. A required scorer may only skip when declared
    `skippable: true`, otherwise the skip is an `:invalid_config` error
  * `{:error, %Nous.Eval.ScorerError{}}` - the instrument failed

`init/1` runs once per eval run and validates options; unknown options
are an error. Scorers run under a supervisor with a time limit: a raise
or timeout becomes a `Nous.Eval.ScorerError` and never discards another
scorer's result.

`describe/1` (optional) returns the configuration that identifies the
scorer in the run fingerprint (for an LLM judge: model, prompt hash,
scale). `kind/0` (optional, default `:deterministic`) marks scorers that
call a model as `:model_graded`. `option_keys/0` (optional) lists the
options a dataset file (YAML/JSONL) may set; a scorer without it cannot be
configured from a file. `init/1` must accept the string forms of its
enum-valued options (`"superset"` for `:superset`), because file values
are never turned into atoms.

`content/0` (optional, default `:required`) declares whether the scorer
reads content - the agent's input or output, messages, tool arguments or
results, error text - or only the trace skeleton (ids, timings, tokens,
cost, tool names and outcomes, guard verdicts). `Nous.Eval.Online` refuses
to start a scorer that reads content under `redact: :drop_content`, where
it would score empty values.

## Referencing scorers from dataset files

YAML and JSONL name scorers by string, resolved with `resolve/2` through
a fixed table of built-ins plus the application's own table:

    config :nous, :eval_scorers, %{"house_style" => MyApp.Eval.HouseStyle}

An unknown name or option is an error; nothing in a file becomes an atom.

# `result`

```elixir
@type result() ::
  {:ok, Nous.Eval.Score.t() | [Nous.Eval.Score.t()]}
  | {:skip, String.t()}
  | {:error, Nous.Eval.ScorerError.t()}
```

# `content`
*optional* 

```elixir
@callback content() :: :required | :none
```

# `describe`
*optional* 

```elixir
@callback describe(config :: term()) :: map()
```

# `id`

```elixir
@callback id() :: String.t()
```

# `init`

```elixir
@callback init(opts :: keyword()) :: {:ok, config :: term()} | {:error, term()}
```

# `kind`
*optional* 

```elixir
@callback kind() :: :deterministic | :model_graded
```

# `option_keys`
*optional* 

```elixir
@callback option_keys() :: [atom()]
```

# `score`

```elixir
@callback score(Nous.Eval.ScoreInput.t(), config :: term()) :: result()
```

# `resolve`

```elixir
@spec resolve(String.t(), map()) ::
  {:ok, Nous.Eval.Scorer.Spec.t()} | {:error, String.t()}
```

Resolves a scorer named in a dataset file into a `Spec`.

`name` is looked up in the built-in table, then in
`config :nous, :eval_scorers`. `opts` is the string-keyed map from the
file: `"required"`, `"weight"` and `"skippable"` set the composition,
every other key must be one of the scorer's `c:option_keys/0`. Option
values are passed through unchanged; the scorer's `c:init/1` validates
them.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
