Class LiteRtSamplerParams
- Namespace
- LiteRtLmSharp
- Assembly
- LiteRtLmSharp.dll
Sampler parameters for a conversation. Construct one and set it on Sampler. A constructed instance sends all fields to the engine — replacing any sampler parameters the model file itself carries — so set the ones you care about and leave the rest at their defaults. The defaults below (TopP, 40, 0.95, 1.0, seed 0) are the same values Google's official bindings fill in for unset fields, so a partial configuration behaves identically across the LiteRT-LM ecosystem.
public sealed record LiteRtSamplerParams : IEquatable<LiteRtSamplerParams>
- Inheritance
-
LiteRtSamplerParams
- Implements
- Inherited Members
Properties
Seed
Random seed for sampling. Default 0 — the same default as the engine and Google's
official bindings — which makes sampling deterministic: the same conversation state and
prompt reproduce the same reply. Pass a different value (e.g. Random.Shared.Next()) for
output that varies between runs.
public int Seed { get; init; }
Property Value
Strategy
The sampling strategy. Default TopP (the value the official bindings use). With Unspecified no sampler parameters are sent at all — the engine's own default applies and the fields below are ignored.
public LiteRtSamplerType Strategy { get; init; }
Property Value
Temperature
Sampling temperature: higher is more random, 0 is greedy/argmax. Must be a non-negative number. Default 1.0.
public float Temperature { get; init; }
Property Value
Exceptions
- ArgumentOutOfRangeException
The value is NaN or negative.
TopK
Top-k cutoff: how many of the highest-probability tokens to consider. Must be positive. Default 40.
public int TopK { get; init; }
Property Value
Exceptions
- ArgumentOutOfRangeException
The value is zero or negative.
TopP
Nucleus (top-p) probability mass, in the range [0, 1]. Default 0.95.
public float TopP { get; init; }
Property Value
Exceptions
- ArgumentOutOfRangeException
The value is NaN or outside [0, 1].