Skip to content

Expose top_k / min_p / presence_penalty / frequency_penalty sampling options - #156

Open
Saiska wants to merge 1 commit into
DustinHendrickson:mainfrom
Saiska:pr/sampling-params
Open

Expose top_k / min_p / presence_penalty / frequency_penalty sampling options#156
Saiska wants to merge 1 commit into
DustinHendrickson:mainfrom
Saiska:pr/sampling-params

Conversation

@Saiska

@Saiska Saiska commented May 31, 2026

Copy link
Copy Markdown

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

Key Type Ollama option Default (= unset)
OllamaChat.TopK int top_k 0
OllamaChat.MinP float min_p 0.0
OllamaChat.PresencePenalty float presence_penalty 0.0
OllamaChat.FrequencyPenalty float frequency_penalty 0.0

Implementation

Follows the existing conditional-options pattern in mod-ollama-chat_api.cpp — each param is added to the request options object only when set (top_k > 0; the floats != 0.0f), exactly like the existing num_predict / temperature / top_p / repeat_penalty handling. The four globals are loaded in the same config function as the existing sampling params, so .ollama reload covers 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.

…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>
@Saiska

Saiska commented Jun 1, 2026

Copy link
Copy Markdown
Author

My bad, i rewrote the history on the fork forgetting it would affect the prs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant