Table of Contents

Enum RandomSampling.RandomSamplers

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

The stages available to the RandomSampling chain, each shaping the candidate distribution in a different way. The order they run in is set through SamplersSequence, and a stage does nothing while its parameter sits at its neutral value.

public enum RandomSampling.RandomSamplers

Fields

TopK = 0

Selects the top K predictions.

TailFree = 1

Reduces the influence of tail-end predictions.

LocallyTypical = 2

Focuses on selections that are typical within a local context.

TopP = 3

Selects predictions that cumulatively reach a probability threshold.

MinP = 4

Filters out predictions below a certain probability threshold.

Temperature = 5

Adjusts the probability distribution based on a temperature parameter to control the randomness of selection.

TopA = 6

Filters against a threshold that scales with the SQUARE of the best prediction's probability, so a confident distribution is cut hard and an uncertain one is barely touched.

EpsilonCutoff = 7

Filters out predictions below an absolute probability floor, regardless of how the best prediction scored.

EtaCutoff = 8

Filters against a floor that adapts to the distribution's own entropy, truncating a confident prediction harder than an uncertain one.

TopNSigma = 9

Keeps predictions within a number of standard deviations of the best score, a cut that stays stable as temperature changes.

ExcludeTopChoices = 10

Occasionally removes the MOST predictable predictions, leaving a still-likely alternative, to break out of cliches without losing coherence.

Quadratic = 11

Compresses the head of the distribution with a quadratic curve instead of rescaling everything uniformly the way temperature does, giving variety among good choices without admitting bad ones.

Examples

The following example shows how to customize the sampler execution order:

using LMKit.TextGeneration.Sampling;

var sampling = new RandomSampling
{
    Temperature = 0.7f,
    // Apply temperature scaling first, then filter by TopK and TopP.
    SamplersSequence = new[]
    {
        RandomSampling.RandomSamplers.Temperature,
        RandomSampling.RandomSamplers.TopK,
        RandomSampling.RandomSamplers.TopP
    }
};
Share