Skip to main content

Module model_sampling

Module model_sampling 

Source
Expand description

The sampler defaults a model carries in its own GGUF metadata.

Inputs come from the raw GGUF key/value map that gglib-gguf copies verbatim into crate::domain::Model::metadata — the same pattern as crate::domain::estimate_kv_elems_per_token and crate::domain::kv_memory_is_partial, and this module sits beside them for that reason.

§Why gglib has to know about these

llama.cpp PR #17120 (merged 2025-11-25, and in the pinned build) added common_init_sampler_from_model, which overwrites params.sampling from the model’s own general.sampling.* keys for every field no CLI flag set — and GET /props renders default_generation_settings from that same struct.

So /props answers “what will this server with this model default to”, not “what does this build default to”. Since ADR 0003 gglib passes no sampler flags at all, model metadata always wins where it is present.

gglib_proxy::props’s baseline check compares /props against a table measured for the pinned build. Without this module it reports a model’s own recommendation as drift — “this build’s default has moved, ADR 0003’s deferral is re-opened” — which is a false alarm on the one instrument whose whole value is being worth believing when it fires.

§Five keys of twelve

llama.cpp reads twelve general.sampling.* keys. Only five name a parameter gglib has a floor opinion about, and those are the only ones modelled here — the same rule SlotParams states about /props’s 42 fields: naming the rest would invent an obligation to keep up with them.

  gglib field        GGUF key
  temperature        general.sampling.temp
  top_p              general.sampling.top_p
  top_k              general.sampling.top_k
  min_p              general.sampling.min_p
  repeat_penalty     general.sampling.penalty_repeat

  presence_penalty   (none)
  dry_multiplier     (none)

The asymmetry at the bottom is worth stating rather than leaving to be rediscovered: presence_penalty and dry_multiplier have no GGUF key at all, so they stay attributable to the build whatever a model ships. A baseline check therefore cannot go fully blind on a model’s account.

The other seven keys — sequence, xtc_probability, xtc_threshold, penalty_last_n, mirostat, mirostat_tau, mirostat_eta — move sampling with nothing in gglib watching, because gglib has no floor for them to contradict.

§Not architecture-prefixed

Unlike its two siblings, which look up {arch}.{suffix} and fall back to the bare suffix. general.sampling.* is a general.* key like general.architecture: there is one spelling and a prefixed fallback would match keys that do not exist.

Structs§

ModelSamplingDefaults
The sampler defaults one model declares.

Enums§

ModelSamplingDefault
What one model’s GGUF says about one sampler field.
SamplingOverride
What gglib is doing with one field’s published recommendation.

Constants§

FLOAT_EPSILON 🔒
Tolerance for comparing a published value against a resolved one.
MODEL_SAMPLING_KEYS
gglib’s wire name for a sampler field, paired with the GGUF key that can move it.