---
title: "init(_:samples:targetCount:sessionProvider:samplingStrategy:validator:)"
framework: evaluations
role: symbol
role_heading: Initializer
path: "evaluations/samplegenerator/init(_:samples:targetcount:sessionprovider:samplingstrategy:validator:)-8t01x"
---

# init(_:samples:targetCount:sessionProvider:samplingStrategy:validator:)

Creates a generator for sample values with a generable-expected value type.

## Declaration

```swift
init<T>(_ prompt: Prompt, samples: [SampleType], targetCount: Int, sessionProvider: (@Sendable () -> LanguageModelSession)? = nil, samplingStrategy: SampleGenerator<SampleType>.SamplingStrategy? = .random(), validator: (nonisolated(nonsending) @Sendable (SampleType) async throws -> Bool)? = nil) where SampleType == ModelSample<T>, T : Generable, T : Decodable, T : Encodable, T : Sendable
```

## Parameters

- `prompt`: The prompt the generator sends to the language model session.
- `samples`: The initial set of evaluation samples that provide context.
- `targetCount`: The total number of samples in the resulting dataset.
- `sessionProvider`: A closure that creates a new language model session.
- `samplingStrategy`: The strategy for selecting example samples.
- `validator`: An optional closure that decides whether a generated sample is valid.
