---
title: GenerationOptions.SamplingMode
framework: foundationmodels
role: symbol
role_heading: Structure
path: foundationmodels/generationoptions/samplingmode-swift.struct
---

# GenerationOptions.SamplingMode

A type that defines how values are sampled from a probability distribution.

## Declaration

```swift
struct SamplingMode
```

## Overview

Overview A model builds its response to a prompt in a loop. At each iteration in the loop the model produces a probability distribution for all the tokens in its vocabulary. The sampling mode controls how a token is selected from that distribution.

## Topics

### Sampling modes

- [greedy](foundationmodels/generationoptions/samplingmode-swift.struct/greedy.md)
- [random(probabilityThreshold:seed:)](foundationmodels/generationoptions/samplingmode-swift.struct/random(probabilitythreshold:seed:).md)
- [random(top:seed:)](foundationmodels/generationoptions/samplingmode-swift.struct/random(top:seed:).md)

### Getting the kind of sampling

- [kind](foundationmodels/generationoptions/samplingmode-swift.struct/kind-swift.property.md)
- [GenerationOptions.SamplingMode.Kind](foundationmodels/generationoptions/samplingmode-swift.struct/kind-swift.enum.md)

## Relationships

### Conforms To

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

## See Also

### Configuring options

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