diff --git a/LLama.KernelMemory/LlamaSharpTextGenerator.cs b/LLama.KernelMemory/LlamaSharpTextGenerator.cs index 02be0b34..adfc8931 100644 --- a/LLama.KernelMemory/LlamaSharpTextGenerator.cs +++ b/LLama.KernelMemory/LlamaSharpTextGenerator.cs @@ -92,8 +92,8 @@ private static InferenceParams OptionsToParams(TextGenerationOptions options, In SamplingPipeline = new DefaultSamplingPipeline() { Temperature = (float)options.Temperature, - AlphaFrequency = (float)options.FrequencyPenalty, - AlphaPresence = (float)options.PresencePenalty, + FrequencyPenalty = (float)options.FrequencyPenalty, + PresencePenalty = (float)options.PresencePenalty, TopP = (float)options.NucleusSampling, } }; @@ -107,8 +107,8 @@ private static InferenceParams OptionsToParams(TextGenerationOptions options, In SamplingPipeline = new DefaultSamplingPipeline() { Temperature = (float)options.Temperature, - AlphaFrequency = (float)options.FrequencyPenalty, - AlphaPresence = (float)options.PresencePenalty, + FrequencyPenalty = (float)options.FrequencyPenalty, + PresencePenalty = (float)options.PresencePenalty, TopP = (float)options.NucleusSampling, } }; diff --git a/LLama.SemanticKernel/ExtensionMethods.cs b/LLama.SemanticKernel/ExtensionMethods.cs index 0439533d..ba1b7447 100644 --- a/LLama.SemanticKernel/ExtensionMethods.cs +++ b/LLama.SemanticKernel/ExtensionMethods.cs @@ -53,8 +53,8 @@ internal static LLama.Common.InferenceParams ToLLamaSharpInferenceParams(this LL { Temperature = (float)requestSettings.Temperature, TopP = (float)requestSettings.TopP, - AlphaPresence = (float)requestSettings.PresencePenalty, - AlphaFrequency = (float)requestSettings.FrequencyPenalty, + PresencePenalty = (float)requestSettings.PresencePenalty, + FrequencyPenalty = (float)requestSettings.FrequencyPenalty, } }; } diff --git a/LLama/Extensions/LLamaExecutorExtensions.cs b/LLama/Extensions/LLamaExecutorExtensions.cs index 4a83b966..19c8d33d 100644 --- a/LLama/Extensions/LLamaExecutorExtensions.cs +++ b/LLama/Extensions/LLamaExecutorExtensions.cs @@ -142,9 +142,9 @@ private string CreatePrompt(IList messages) MaxTokens = options?.MaxOutputTokens ?? 256, // arbitrary upper limit SamplingPipeline = new DefaultSamplingPipeline() { - AlphaFrequency = options?.AdditionalProperties?.TryGetValue(nameof(DefaultSamplingPipeline.AlphaFrequency), out float af) is true ? af : s_defaultPipeline.AlphaFrequency, - AlphaPresence = options?.AdditionalProperties?.TryGetValue(nameof(DefaultSamplingPipeline.AlphaPresence), out float ap) is true ? ap : s_defaultPipeline.AlphaPresence, - PenalizeEOS = options?.AdditionalProperties?.TryGetValue(nameof(DefaultSamplingPipeline.PenalizeEOS), out bool eos) is true ? eos : s_defaultPipeline.PenalizeEOS, + FrequencyPenalty = options?.AdditionalProperties?.TryGetValue(nameof(DefaultSamplingPipeline.FrequencyPenalty), out float af) is true ? af : s_defaultPipeline.FrequencyPenalty, + PresencePenalty = options?.AdditionalProperties?.TryGetValue(nameof(DefaultSamplingPipeline.PresencePenalty), out float ap) is true ? ap : s_defaultPipeline.PresencePenalty, + PreventEOS = options?.AdditionalProperties?.TryGetValue(nameof(DefaultSamplingPipeline.PreventEOS), out bool eos) is true ? eos : s_defaultPipeline.PreventEOS, PenalizeNewline = options?.AdditionalProperties?.TryGetValue(nameof(DefaultSamplingPipeline.PenalizeNewline), out bool pnl) is true ? pnl : s_defaultPipeline.PenalizeNewline, RepeatPenalty = options?.AdditionalProperties?.TryGetValue(nameof(DefaultSamplingPipeline.RepeatPenalty), out float rp) is true ? rp : s_defaultPipeline.RepeatPenalty, RepeatPenaltyCount = options?.AdditionalProperties?.TryGetValue(nameof(DefaultSamplingPipeline.RepeatPenaltyCount), out int rpc) is true ? rpc : s_defaultPipeline.RepeatPenaltyCount, diff --git a/LLama/Sampling/DefaultSamplingPipeline.cs b/LLama/Sampling/DefaultSamplingPipeline.cs index 7f1e5e40..fdbbcb23 100644 --- a/LLama/Sampling/DefaultSamplingPipeline.cs +++ b/LLama/Sampling/DefaultSamplingPipeline.cs @@ -25,15 +25,15 @@ public sealed class DefaultSamplingPipeline /// Number between -2.0 and 2.0. Positive values penalize new tokens based on their existing frequency in the text /// so far, decreasing the model's likelihood to repeat the same line verbatim. /// - public float AlphaFrequency + public float FrequencyPenalty { get => _alphaFreq; init { if (value < -2) - throw new ArgumentOutOfRangeException(nameof(value), "AlphaFrequency must be greater than -2"); + throw new ArgumentOutOfRangeException(nameof(value), $"{nameof(FrequencyPenalty)} must be greater than -2"); if (value > 2) - throw new ArgumentOutOfRangeException(nameof(value), "AlphaFrequency must be less than 2"); + throw new ArgumentOutOfRangeException(nameof(value), $"{nameof(FrequencyPenalty)} must be less than 2"); _alphaFreq = value; } } @@ -44,15 +44,15 @@ public float AlphaFrequency /// Number between -2.0 and 2.0. Positive values penalize new tokens based on whether they appear in the /// text so far, increasing the model's likelihood to talk about new topics. /// - public float AlphaPresence + public float PresencePenalty { get => _alphaPresence; init { if (value < -2) - throw new ArgumentOutOfRangeException(nameof(value), "AlphaFrequency must be greater than -2"); + throw new ArgumentOutOfRangeException(nameof(value), $"{nameof(PresencePenalty)} must be greater than -2"); if (value > 2) - throw new ArgumentOutOfRangeException(nameof(value), "AlphaFrequency must be less than 2"); + throw new ArgumentOutOfRangeException(nameof(value), $"{nameof(PresencePenalty)} must be less than 2"); _alphaPresence = value; } } @@ -69,9 +69,9 @@ public float AlphaPresence public bool PenalizeNewline { get; init; } = false; /// - /// Whether the EOS token should be protected from being modified by penalty + /// Whether the EOS token should be suppressed. Setting this to 'true' prevents EOS from being sampled /// - public bool PenalizeEOS { get; init; } = false; + public bool PreventEOS { get; init; } = false; /// /// Temperature to apply (higher temperature is more "creative") @@ -147,8 +147,8 @@ protected override SafeLLamaSamplerChainHandle CreateChain(SafeLLamaContextHandl context.VocabCount, context.ModelHandle.Tokens.EOS, context.ModelHandle.Tokens.Newline ?? 0, RepeatPenaltyCount, RepeatPenalty, - AlphaFrequency, AlphaPresence, - PenalizeNewline, PenalizeEOS + FrequencyPenalty, PresencePenalty, + PenalizeNewline, PreventEOS ); chain.AddTopK(TopK);