<!--
{
  "availability" : [
    "iOS: 27.0.0 -",
    "iPadOS: 27.0.0 -",
    "macOS: 27.0.0 -",
    "visionOS: 27.0.0 -",
    "watchOS: 27.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "Swift",
  "identifier" : "/documentation/Swift/Array/makeSamples(_:targetCount:sessionProvider:validator:)-5j7t0",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "Swift"
    ],
    "preciseIdentifier" : "s:Sa11EvaluationsE11makeSamples_11targetCount15sessionProvider9validatorQr16FoundationModels6PromptV_SiAF20LanguageModelSessionCyYbcSgSbAA0M6SampleVyqd__GYaYbKYCcSgtANRszAF9GenerableRd__SeRd__SERd__s8SendableRd__lF"
  },
  "title" : "makeSamples(_:targetCount:sessionProvider:validator:)"
}
-->

# makeSamples(_:targetCount:sessionProvider:validator:)

Generates synthetic data based on this dataset and returns a stream of new samples.

```
func makeSamples<T>(_ prompt: Prompt, targetCount: Int, sessionProvider: (@Sendable () -> LanguageModelSession)? = nil, validator: (nonisolated(nonsending) @Sendable (ModelSample<T>) async throws -> Bool)? = nil) -> some AsyncSequence<ModelSample<T>, any Error> where Element == ModelSample<T>, T : Generable, T : Decodable, T : Encodable, T : Sendable
```

## Parameters

`prompt`

The prompt the generator sends to the language model session.

`targetCount`

The desired total number of samples, counting both the initial dataset and newly generated ones.

`sessionProvider`

A closure that creates a new language model session, or `nil` to use the default.

`validator`

A closure that decides whether a generated sample is valid, or `nil` to accept all samples.

## Return Value

An async throwing stream of newly generated samples.

## Discussion

For more control over generation, create a `SampleGenerator` directly.

---

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)