Class LiteRtRepetitionPenaltyOptions
- Namespace
- LiteRtLmSharp
- Assembly
- LiteRtLmSharp.dll
Repetition penalties for one send's decode, in the two industry conventions the native runtime implements: a multiplicative HuggingFace-style RepetitionPenalty and subtractive OpenAI-style PresencePenalty/FrequencyPenalty. All penalties look at the generated output window of the current send only (not the prompt, not prior turns). Set on RepetitionPenalties. Requires native LiteRT-LM v0.15.0+.
public sealed record LiteRtRepetitionPenaltyOptions : IEquatable<LiteRtRepetitionPenaltyOptions>
- Inheritance
-
LiteRtRepetitionPenaltyOptions
- Implements
- Inherited Members
Remarks
Maps to the C API litert_lm_repetition_penalty_config_* builder; the defaults
below are the native defaults, so a partially configured record is faithful.
Properties
FrequencyPenalty
Subtractive frequency penalty (OpenAI style): subtracted from a token's logit scaled by how many times the token appeared in the window. Positive discourages repetition, negative rewards it. Default 0 = off.
public float FrequencyPenalty { get; init; }
Property Value
Exceptions
- ArgumentOutOfRangeException
The value is NaN or infinite.
PresencePenalty
Subtractive presence penalty (OpenAI style): subtracted once from a token's logit if the token appeared anywhere in the window. Positive discourages repetition, negative rewards it. Default 0 = off.
public float PresencePenalty { get; init; }
Property Value
Exceptions
- ArgumentOutOfRangeException
The value is NaN or infinite.
RepetitionPenalty
Multiplicative repetition penalty (HuggingFace style): positive logits of tokens already seen in the window are divided by this value, negative ones multiplied. 1.0 (default) = off; must be >= 1.0 (the native layer clamps lower values to 1.0 at execution time — the binding rejects them up front instead).
public float RepetitionPenalty { get; init; }
Property Value
Exceptions
- ArgumentOutOfRangeException
The value is NaN or below 1.0.
WindowSize
How many of the most recent generated tokens the penalties consider. 0 (default) = the whole generation history of the send.
public int WindowSize { get; init; }
Property Value
Exceptions
- ArgumentOutOfRangeException
The value is negative.