<!--
{
  "availability" : [
    "iOS: 26.0.0 -",
    "iPadOS: 26.0.0 -",
    "macCatalyst: 26.0.0 -",
    "macOS: 26.0.0 -",
    "visionOS: 26.0.0 -",
    "watchOS: 27.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "FoundationModels",
  "identifier" : "/documentation/FoundationModels/GenerationOptions/samplingMode-swift.property",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Property",
  "symbol" : {
    "kind" : "Instance Property",
    "modules" : [
      "Foundation Models",
      "FoundationModels"
    ],
    "preciseIdentifier" : "s:16FoundationModels17GenerationOptionsV12samplingModeAC08SamplingF0VSgvp"
  },
  "title" : "samplingMode"
}
-->

# samplingMode

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

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

## 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` to `nil` lets the system choose a
> reasonable default on your behalf.

---

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)