---
title: samplingMode
framework: foundationmodels
role: symbol
role_heading: Instance Property
path: foundationmodels/generationoptions/samplingmode-swift.property
---

# samplingMode

A sampling strategy for how the model picks tokens when generating a response.

## Declaration

```swift
@backDeployed(before: iOS 27.0, macOS 27.0, visionOS 27.0)
var samplingMode: GenerationOptions.SamplingMode? { get set }
```

## Discussion

Discussion When you execute a prompt on a model, the model produces a probability for every token in its vocabulary. The sampling strategy controls how the model narrows down the list of tokens to consider during that process. A strategy that picks the single most likely token yields a predictable response every time, but other strategies offer results that often sound more natural to a person. note: Leaving the sampling nil lets the system choose a a reasonable default on your behalf.

## See Also

### Configuring options

- [temperature](foundationmodels/generationoptions/temperature.md)
- [sampling](foundationmodels/generationoptions/sampling.md)
- [GenerationOptions.SamplingMode](foundationmodels/generationoptions/samplingmode-swift.struct.md)
- [toolCallingMode](foundationmodels/generationoptions/toolcallingmode-swift.property.md)
- [GenerationOptions.ToolCallingMode](foundationmodels/generationoptions/toolcallingmode-swift.struct.md)
- [maximumResponseTokens](foundationmodels/generationoptions/maximumresponsetokens.md)
