Table of Contents

Class TokenSampling

Namespace
LMKit.TextGeneration.Sampling
Assembly
LM-Kit.NET.dll

Handles the sampling strategy used during text completion.

public abstract class TokenSampling
Inheritance
TokenSampling
Derived
Inherited Members

Examples

The following example shows how to assign different sampling strategies to a conversation:

using LMKit.Model;
using LMKit.TextGeneration;
using LMKit.TextGeneration.Sampling;

LM model = LM.LoadFromModelID("gemma3:4b");
var chat = new MultiTurnConversation(model);

// Use random sampling with custom temperature.
chat.SamplingMode = new RandomSampling { Temperature = 0.7f };

// Switch to greedy decoding for deterministic output.
chat.SamplingMode = new GreedyDecoding();

// Use Mirostat v2 for perplexity-controlled generation.
chat.SamplingMode = new Mirostat2Sampling { TargetEntropy = 5.0f };

Methods

Clone()

Creates a deep copy of the current TokenSampling instance.

Share