sampler: read suppress_tokens

generation_config.json's suppress_tokens (Gemma 4: the end-of-image and
end-of-audio markers, ids 258883 and 258882) are never sampled. The ids
reach the sampler as SamplingParams::suppress_tokens and leave the row
the way a grammar's mask does. A container carries them already, as the
space-separated generation.suppress_tokens.
This commit is contained in:
keptn42 committed 2026-11-04 07:21:07 +01:00
1 parent c1c05e9029
commit a72686b7e7
6 files changed
+83 -2

No files matched your search

+4
View File
@@ -682,6 +682,10 @@ struct SamplingParams {
* duplicates ignored. Empty (the default) is off: the ban is then bit-identical to the
* no-whitelist form. */
std::vector<int32_t> ngram_whitelist;
/* Token ids this request never samples (generation_config.json's suppress_tokens: Gemma 4's
* end-of-image and end-of-audio markers). Global ids, duplicates ignored; empty is off. The
* sampler takes them out of the row as it does a grammar's mask. */
std::vector<int32_t> suppress_tokens;
};
/* Raw logits at chosen vocabulary ids at the prompt's last position, for a caller that answers