Expose top_k / min_p / presence_penalty / frequency_penalty sampling options - #156
Open
Saiska wants to merge 1 commit into
Open
Expose top_k / min_p / presence_penalty / frequency_penalty sampling options#156Saiska wants to merge 1 commit into
Saiska wants to merge 1 commit into
Conversation
…options Four Ollama sampling params via config: OllamaChat.TopK (uint32_t), OllamaChat.MinP, OllamaChat.PresencePenalty, OllamaChat.FrequencyPenalty (all float). Each defaults to 0 / 0.0 = unset (not sent to Ollama), so behavior is unchanged unless an operator sets a non-zero value. Follows the existing conditional-options pattern used for Temperature, TopP, and RepeatPenalty. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Author
|
My bad, i rewrote the history on the fork forgetting it would affect the prs. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Exposes four additional Ollama sampling parameters through config so operators can tune response diversity and reduce repetition:
top_k,min_p,presence_penalty,frequency_penalty.All four default to unset (not sent in the request), so the model's defaults apply and behavior is unchanged unless an operator opts in.
Config
OllamaChat.TopKtop_k0OllamaChat.MinPmin_p0.0OllamaChat.PresencePenaltypresence_penalty0.0OllamaChat.FrequencyPenaltyfrequency_penalty0.0Implementation
Follows the existing conditional-options pattern in
mod-ollama-chat_api.cpp— each param is added to the requestoptionsobject only when set (top_k > 0; the floats!= 0.0f), exactly like the existingnum_predict/temperature/top_p/repeat_penaltyhandling. The four globals are loaded in the same config function as the existing sampling params, so.ollama reloadcovers them.Files:
mod-ollama-chat_config.{h,cpp},mod-ollama-chat_api.cpp,conf/mod_ollama_chat.conf.dist,README.md.Testing
Built (MSVC, Release) against the AzerothCore Playerbot branch; clean server boot with no errors. With all four at their defaults, none are sent (request payload unchanged); with non-default values set (e.g.
TopK=40,MinP=0.05,FrequencyPenalty=0.4), replies generate normally with the options applied.🤖 Generated with Claude Code
Resubmitted from #153 (auto-closed for a structural merge conflict from divergent fork history). Rebased onto current
main; this branch is a single focused commit that merges cleanly.