Skip to content

Commit b943d1d

Browse files
committed
Updated names and comments for some sampling params
1 parent 77bfb56 commit b943d1d

File tree

4 files changed

+19
-19
lines changed

4 files changed

+19
-19
lines changed

LLama.KernelMemory/LlamaSharpTextGenerator.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -92,8 +92,8 @@ private static InferenceParams OptionsToParams(TextGenerationOptions options, In
9292
SamplingPipeline = new DefaultSamplingPipeline()
9393
{
9494
Temperature = (float)options.Temperature,
95-
AlphaFrequency = (float)options.FrequencyPenalty,
96-
AlphaPresence = (float)options.PresencePenalty,
95+
FrequencyPenalty = (float)options.FrequencyPenalty,
96+
PresencePenalty = (float)options.PresencePenalty,
9797
TopP = (float)options.NucleusSampling,
9898
}
9999
};
@@ -107,8 +107,8 @@ private static InferenceParams OptionsToParams(TextGenerationOptions options, In
107107
SamplingPipeline = new DefaultSamplingPipeline()
108108
{
109109
Temperature = (float)options.Temperature,
110-
AlphaFrequency = (float)options.FrequencyPenalty,
111-
AlphaPresence = (float)options.PresencePenalty,
110+
FrequencyPenalty = (float)options.FrequencyPenalty,
111+
PresencePenalty = (float)options.PresencePenalty,
112112
TopP = (float)options.NucleusSampling,
113113
}
114114
};

LLama.SemanticKernel/ExtensionMethods.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,8 @@ internal static LLama.Common.InferenceParams ToLLamaSharpInferenceParams(this LL
5353
{
5454
Temperature = (float)requestSettings.Temperature,
5555
TopP = (float)requestSettings.TopP,
56-
AlphaPresence = (float)requestSettings.PresencePenalty,
57-
AlphaFrequency = (float)requestSettings.FrequencyPenalty,
56+
PresencePenalty = (float)requestSettings.PresencePenalty,
57+
FrequencyPenalty = (float)requestSettings.FrequencyPenalty,
5858
}
5959
};
6060
}

LLama/Extensions/LLamaExecutorExtensions.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -142,9 +142,9 @@ private string CreatePrompt(IList<ChatMessage> messages)
142142
MaxTokens = options?.MaxOutputTokens ?? 256, // arbitrary upper limit
143143
SamplingPipeline = new DefaultSamplingPipeline()
144144
{
145-
AlphaFrequency = options?.AdditionalProperties?.TryGetValue(nameof(DefaultSamplingPipeline.AlphaFrequency), out float af) is true ? af : s_defaultPipeline.AlphaFrequency,
146-
AlphaPresence = options?.AdditionalProperties?.TryGetValue(nameof(DefaultSamplingPipeline.AlphaPresence), out float ap) is true ? ap : s_defaultPipeline.AlphaPresence,
147-
PenalizeEOS = options?.AdditionalProperties?.TryGetValue(nameof(DefaultSamplingPipeline.PenalizeEOS), out bool eos) is true ? eos : s_defaultPipeline.PenalizeEOS,
145+
FrequencyPenalty = options?.AdditionalProperties?.TryGetValue(nameof(DefaultSamplingPipeline.FrequencyPenalty), out float af) is true ? af : s_defaultPipeline.FrequencyPenalty,
146+
PresencePenalty = options?.AdditionalProperties?.TryGetValue(nameof(DefaultSamplingPipeline.PresencePenalty), out float ap) is true ? ap : s_defaultPipeline.PresencePenalty,
147+
PreventEOS = options?.AdditionalProperties?.TryGetValue(nameof(DefaultSamplingPipeline.PreventEOS), out bool eos) is true ? eos : s_defaultPipeline.PreventEOS,
148148
PenalizeNewline = options?.AdditionalProperties?.TryGetValue(nameof(DefaultSamplingPipeline.PenalizeNewline), out bool pnl) is true ? pnl : s_defaultPipeline.PenalizeNewline,
149149
RepeatPenalty = options?.AdditionalProperties?.TryGetValue(nameof(DefaultSamplingPipeline.RepeatPenalty), out float rp) is true ? rp : s_defaultPipeline.RepeatPenalty,
150150
RepeatPenaltyCount = options?.AdditionalProperties?.TryGetValue(nameof(DefaultSamplingPipeline.RepeatPenaltyCount), out int rpc) is true ? rpc : s_defaultPipeline.RepeatPenaltyCount,

LLama/Sampling/DefaultSamplingPipeline.cs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -25,15 +25,15 @@ public sealed class DefaultSamplingPipeline
2525
/// Number between -2.0 and 2.0. Positive values penalize new tokens based on their existing frequency in the text
2626
/// so far, decreasing the model's likelihood to repeat the same line verbatim.
2727
/// </summary>
28-
public float AlphaFrequency
28+
public float FrequencyPenalty
2929
{
3030
get => _alphaFreq;
3131
init
3232
{
3333
if (value < -2)
34-
throw new ArgumentOutOfRangeException(nameof(value), "AlphaFrequency must be greater than -2");
34+
throw new ArgumentOutOfRangeException(nameof(value), $"{nameof(FrequencyPenalty)} must be greater than -2");
3535
if (value > 2)
36-
throw new ArgumentOutOfRangeException(nameof(value), "AlphaFrequency must be less than 2");
36+
throw new ArgumentOutOfRangeException(nameof(value), $"{nameof(FrequencyPenalty)} must be less than 2");
3737
_alphaFreq = value;
3838
}
3939
}
@@ -44,15 +44,15 @@ public float AlphaFrequency
4444
/// Number between -2.0 and 2.0. Positive values penalize new tokens based on whether they appear in the
4545
/// text so far, increasing the model's likelihood to talk about new topics.
4646
/// </summary>
47-
public float AlphaPresence
47+
public float PresencePenalty
4848
{
4949
get => _alphaPresence;
5050
init
5151
{
5252
if (value < -2)
53-
throw new ArgumentOutOfRangeException(nameof(value), "AlphaFrequency must be greater than -2");
53+
throw new ArgumentOutOfRangeException(nameof(value), $"{nameof(PresencePenalty)} must be greater than -2");
5454
if (value > 2)
55-
throw new ArgumentOutOfRangeException(nameof(value), "AlphaFrequency must be less than 2");
55+
throw new ArgumentOutOfRangeException(nameof(value), $"{nameof(PresencePenalty)} must be less than 2");
5656
_alphaPresence = value;
5757
}
5858
}
@@ -69,9 +69,9 @@ public float AlphaPresence
6969
public bool PenalizeNewline { get; init; } = false;
7070

7171
/// <summary>
72-
/// Whether the EOS token should be protected from being modified by penalty
72+
/// Whether the EOS token should be suppressed. Setting this to 'true' prevents EOS from being sampled
7373
/// </summary>
74-
public bool PenalizeEOS { get; init; } = false;
74+
public bool PreventEOS { get; init; } = false;
7575

7676
/// <summary>
7777
/// Temperature to apply (higher temperature is more "creative")
@@ -147,8 +147,8 @@ protected override SafeLLamaSamplerChainHandle CreateChain(SafeLLamaContextHandl
147147
context.VocabCount,
148148
context.ModelHandle.Tokens.EOS, context.ModelHandle.Tokens.Newline ?? 0,
149149
RepeatPenaltyCount, RepeatPenalty,
150-
AlphaFrequency, AlphaPresence,
151-
PenalizeNewline, PenalizeEOS
150+
FrequencyPenalty, PresencePenalty,
151+
PenalizeNewline, PreventEOS
152152
);
153153

154154
chain.AddTopK(TopK);

0 commit comments

Comments
 (0)