SamplingParams class final

Sampling parameters for a session, as the caller asked for them.

A null field is unset. An engine resolves each unset field on its own, in this order:

  1. what the model file ships, when the engine can read it (a native .litertlm bundle's sampler, an ONNX model's genai_config.json);
  2. the model family's published defaults, SamplingParams.forModelType;
  3. SamplingParams.fallback.

resolve implements that order for engines that pick the values in Dart. ONNX leaves unset fields to its config and takes only a top-k from the family; built-in AI sends its OS defaults' stand-in, temperature 0.8 and top-k 1.

Annotations

Constructors

SamplingParams({double? temperature, int? topK, double? topP, int? randomSeed})
const

Properties

hashCode → int
The hash code for this object.
no setteroverride
isEmpty → bool
True when the caller set nothing.
no setter
isGreedy → bool
Greedy decoding, the same for every engine: a top-k of 1 or a temperature of 0.
no setter
needsSamplingTopK → bool
True when this asks for sampling, a temperature above 0 or a top-p with no temperature of 0, but sets no top-k: a top-k of 1 from the model or its family would then silently turn it into greedy decoding.
no setter
randomSeed → int?
final
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited
temperature → double?
final
topK → int?
final
topP → double?
final

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
orElse(SamplingParams other) → SamplingParams
This, with every unset field taken from other.
toString() → String
A string representation of this object.
override
validate() → void
Throws an ArgumentError for a set value no engine can sample with.

Operators

operator ==(Object other) → bool
The equality operator.
override

Static Methods

forModelType(ModelType modelType, {bool thinking = false}) → SamplingParams
The defaults the family's publisher recommends, from each model's generation_config.json or model card. thinking picks between the two sets the Qwen families publish.
resolve(SamplingParams explicit, {required ModelType modelType, bool thinking = false, SamplingParams modelDefaults = const SamplingParams()}) → ResolvedSampling
explicit, then modelDefaults, then forModelType, then fallback.

Constants

fallback → const SamplingParams
Used for whatever neither the caller, the model file nor the family set.