---
title: Loader
framework: evaluations
role: symbol
role_heading: Protocol
path: evaluations/loader
---

# Loader

A protocol for types that supply a dataset for evaluation.

## Declaration

```swift
protocol Loader<Sample> : Sendable
```

## Overview

Overview Use one of the built-in concrete types — ArrayLoader, JSONLoader, or StreamLoader — or implement this protocol directly for custom data sources. var dataset: any Loader<ModelSample<String>> {     ArrayLoader(samples: [         ModelSample(prompt: "One plus one is...", expected: "Two."),         ModelSample(prompt: "Swift is...", expected: "A powerful language."),     ]) } var dataset: any Loader<ModelSample<String>> {     JSONLoader(url: Bundle.main.url(forResource: "prompts", withExtension: "jsonl")!) } var dataset: any Loader<ModelSample<String>> {     StreamLoader(stream: AsyncThrowingStream<ModelSample<String>, Error> { continuation in         Task {             let prompts = ["One plus one is...", "Swift is..."]             for prompt in prompts {                 continuation.yield(ModelSample(prompt: prompt, expected: ""))             }             continuation.finish()         }     }) }

## Topics

### Loaders

- [ArrayLoader](evaluations/arrayloader.md)
- [JSONLoader](evaluations/jsonloader.md)
- [StreamLoader](evaluations/streamloader.md)

### Associated Types

- [Sample](evaluations/loader/sample.md)

### Instance Properties

- [stream](evaluations/loader/stream.md)

## Relationships

### Inherits From

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

### Conforming Types

- [ArrayLoader](evaluations/arrayloader.md)
- [JSONLoader](evaluations/jsonloader.md)
- [StreamLoader](evaluations/streamloader.md)

## See Also

### Datasets

- [Generating synthetic datasets](evaluations/generating-synthetic-evaluation-datasets.md)
- [Designing datasets to test your feature](evaluations/designing-evaluation-datasets.md)
- [ModelSample](evaluations/modelsample.md)
- [SampleGenerator](evaluations/samplegenerator.md)
