<!--
{
  "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/ModelSample",
  "metadataVersion" : "0.1.0",
  "role" : "Structure",
  "symbol" : {
    "kind" : "Structure",
    "modules" : [
      "Evaluations"
    ],
    "preciseIdentifier" : "s:11Evaluations11ModelSampleV"
  },
  "title" : "ModelSample"
}
-->

# ModelSample

A general-purpose language model evaluation sample.

```
struct ModelSample<ExpectedValue> where ExpectedValue : Decodable, ExpectedValue : Encodable, ExpectedValue : Sendable
```

## Overview

Accepts string-based prompts and instructions. For multimodal prompts,
create a custom [`ModelSampleProtocol`](/documentation/Evaluations/ModelSampleProtocol) conformance or use the
[`init(input:expected:expectations:)`](/documentation/Evaluations/ModelSample/init(input:expected:expectations:)) initializer with a prebuilt
[`ModelSampleInput`](/documentation/Evaluations/ModelSampleInput).

```swift
let sample = ModelSample(prompt: "The capital of France is...", expected: "Paris.")
```

## Topics

### Creating a sample

[`init(prompt:expected:instructions:generationSchema:expectations:)`](/documentation/Evaluations/ModelSample/init(prompt:expected:instructions:generationSchema:expectations:)-7daed)

Creates a model sample with string-based prompt and instructions.

[`init(prompt:expected:instructions:generationSchema:expectations:)`](/documentation/Evaluations/ModelSample/init(prompt:expected:instructions:generationSchema:expectations:)-8mni)

Creates a model sample with a FoundationModels prompt.

[`init(input:expected:expectations:)`](/documentation/Evaluations/ModelSample/init(input:expected:expectations:))

Creates a model sample with a prebuilt input.

### Specifying the query

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

The user’s prompt for this sample.

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

A text representation of the prompt, synthesized from its segments.

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

Optional instructions providing context to the model for this sample.

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

A text representation of the instructions, synthesized from their segments.

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

The bundled language model input (prompt, instructions, schema).

### Specifying expected output

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

The expected output for comparison.

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

The expected output value and evaluation expectations.

### Specifying tool expectations

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

The expected pattern of tool calls for this sample.

### Configuring generation

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

The output schema for the model’s response.

### Bundled input and output

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

The data a language model receives for evaluation.

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

The expected output value and evaluation expectations for a sample.

### Protocols

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

A type that defines language model evaluation samples with prompt, instructions, and expectations.

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

A type that defines evaluation samples.

## Relationships

### Conforms To

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

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

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

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

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

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

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

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

---

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)