---
title: Evaluator
framework: evaluations
role: symbol
role_heading: Structure
path: evaluations/evaluator
---

# Evaluator

A closure-based evaluator.

## Declaration

```swift
struct Evaluator<Input> where Input : SampleProtocol, Input.ExpectedValue : Decodable, Input.ExpectedValue : Encodable, Input.ExpectedValue : Sendable
```

## Mentioned in

Designing specific, measurable criteria in an evaluation suite

## Overview

Overview Use Evaluator to create inline evaluators without defining a custom type. The closure receives the input sample and the ModelSubject, providing access to both .value and .transcript. Evaluator { sample, subject in     let metric = Metric("TitleMatch")     guard let expected = sample.expected else { return metric.ignore() }     return subject.value == expected ? metric.passing() : metric.failing() }

## Topics

### Initializers

- [init(_:)](evaluations/evaluator/init(_:).md)

## Relationships

### Conforms To

- [EvaluatorProtocol](evaluations/evaluatorprotocol.md)
- [Sendable](swift/sendable.md)
- [SendableMetatype](swift/sendablemetatype.md)

## See Also

### Metrics and evaluators

- [Designing specific, measurable criteria in an evaluation suite](evaluations/designing-evaluation-criteria.md)
- [Metric](evaluations/metric.md)
- [MetricsAggregator](evaluations/metricsaggregator.md)
