Table of Contents

Class RandomSampling

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

Handles random sampling strategy (also known as temperature-based sampling).

public sealed class RandomSampling : TokenSampling
Inheritance
RandomSampling
Inherited Members

Properties

DynamicTemperatureRange

Specifies the dynamic temperature strategy's intensity for decoding processes.
This property accepts a floating-point value ranging from 0 to 1, where 0 completely turns off dynamic temperature adjustments, and 1 applies the maximum intensity of temperature coefficient adjustments for dynamic decoding strategies.

LocallyTypical

Specifies diversity through Locally Typical sampling method.
Use a floating-point value within the range [0 , 1].
Use 1 to disable this sampler.

MinP

Specifies diversity through MinP sampling method.
All tokens with a probability percentage exceeding the MinP threshold are taken into consideration.
Use a floating-point value within the range [0 , 1].
Use 0 to disable MinP sampling.

SamplersSequence

Specifies an enumeration for RandomSamplers that outlines a customizable sequence of sampler algorithms.
This enumeration facilitates the dynamic arrangement of various sampling strategies, enabling precise control over the random sampling process.

Seed

Specifies the seed used for random number generation.
If set, the seed ensures reproducibility of the sampling process by controlling the randomness in token generation.
When not set (null), the model's behavior is non-deterministic as it relies on a system-generated random seed.
Use an unsigned integer (uint) value to define the seed for reproducibility, or leave it null for standard random behavior.

Temperature

Specifies output randomness level.
Lowering the temperature leads to fewer random completions.
As the temperature approaches zero, the model becomes more deterministic and repetitive.
Use a floating-point value within the range [0 (more deterministic), 1 (more random)].

TopK

Specifies the vocabulary size considered during completion (or text generation).
Use an integer value within the range [1, 1000].

TopP

Specifies diversity through nucleus sampling method.
The TopP algorithm computes the cumulative probability distribution and cuts off as soon as that distribution exceeds the value of TopP.
For example, a value of 0.8 implies that 80% of all likelihood-weighted options are considered.
This sampling strategy aims to strike a balance between diversity and quality, taking into account both the probability of tokens and the quantity of tokens to be sampled.
Use a floating-point value within the range [0 (more conservative), 1 (more diverse)].
Use 1 to disable TopP sampling.