<!--
{
  "availability" : [
    "Xcode: 27.0.0 -",
    "iOS: 27.0.0 -",
    "iPadOS: 27.0.0 -",
    "macCatalyst: 27.0.0 -",
    "macOS: 27.0.0 -",
    "visionOS: 27.0.0 -",
    "watchOS: 27.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "Evaluations",
  "identifier" : "/documentation/Evaluations/SampleProtocol",
  "metadataVersion" : "0.1.0",
  "role" : "Protocol",
  "symbol" : {
    "kind" : "Protocol",
    "modules" : [
      "Evaluations"
    ],
    "preciseIdentifier" : "s:11Evaluations14SampleProtocolP"
  },
  "title" : "SampleProtocol"
}
-->

# SampleProtocol

A type that defines evaluation samples.

```
protocol SampleProtocol : Decodable, Encodable, Sendable
```

## Overview

```swift
struct MySample: SampleProtocol {
    var input: String
    var expected: String?
}
```

Conform to this protocol to define input samples for your evaluation datasets.
Each sample has an input that’s displayed in the DataFrame “Input” column, and an
optional expected value for comparison.

For language model evaluations, use [`ModelSampleProtocol`](/documentation/Evaluations/ModelSampleProtocol) which extends this
protocol with language-model-specific properties: prompt, instructions, and expectations.

```swift
let samples = [
    ModelSample(prompt: "Classify: I love this!", expected: "positive"),
]
```

## Topics

### Associated Types

[`associatedtype ExpectedValue`](/documentation/Evaluations/SampleProtocol/ExpectedValue)

The type of the expected output value.

[`associatedtype Input : CustomStringConvertible`](/documentation/Evaluations/SampleProtocol/Input-swift.associatedtype)

The type of the input data.

### Instance Properties

[`var expected: Self.ExpectedValue?`](/documentation/Evaluations/SampleProtocol/expected)

The expected output for comparison.

[`var input: Self.Input`](/documentation/Evaluations/SampleProtocol/input-swift.property)

The input data for this sample, shown in the “Input” DataFrame column.

## Relationships

### Inherits From

[`SendableMetatype`](/documentation/Swift/SendableMetatype)

[`Sendable`](/documentation/Swift/Sendable)

[`Decodable`](/documentation/Swift/Decodable)

[`Encodable`](/documentation/Swift/Encodable)

### Conforming Types

[`ModelSample`](/documentation/Evaluations/ModelSample)

### Inherited By

[`ModelSampleProtocol`](/documentation/Evaluations/ModelSampleProtocol)

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)