Fix paligemma: must subtract image tokens from prompt length

PiperOrigin-RevId: 865905454
This commit is contained in:
Jan Wassenberg 2026-02-05 05:59:14 -08:00 committed by Copybara-Service
parent 60eed010ba
commit 2751a194be
1 changed files with 1 additions and 1 deletions

View File

@ -200,7 +200,7 @@ void ReplGemma(const GemmaArgs& args, const Gemma& gemma, KVCache& kv_cache,
config.wrapping, abs_pos, prompt_string,
image_tokens.Rows());
runtime_config.image_tokens = &image_tokens;
prompt_size = prompt.size();
prompt_size = prompt.size() - image_tokens.Rows();
if (config.wrapping == PromptWrapping::PALIGEMMA) {
// The end of the prefix for prefix-LM style attention in Paligemma.
// See Figure 2 of https://arxiv.org/abs/2407.07726.