From 7c369a69e7e4f8cd2734bee18eeec3c38972a7b3 Mon Sep 17 00:00:00 2001 From: Prince Shakya Date: Sun, 24 May 2026 04:20:19 +0530 Subject: [PATCH] fix: add missing f-prefix in _normalize_token() error message The error message was a plain string, causing {token!r} to be printed literally instead of interpolating the actual token value. This makes debugging stop_tokens / forbidden_tokens misconfigurations impossible. Fixes #658 --- gemma/gm/text/_sampler.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gemma/gm/text/_sampler.py b/gemma/gm/text/_sampler.py index 5b8ae163..710e321d 100644 --- a/gemma/gm/text/_sampler.py +++ b/gemma/gm/text/_sampler.py @@ -577,7 +577,7 @@ def _normalize_token(tokenizer, token: str | int) -> int: token_id = tokenizer.encode(token) if len(token_id) != 1: raise ValueError( - 'Invalid token: {token!r}. `stop_token`s and `forbidden_token`s must' + f'Invalid token: {token!r}. `stop_token`s and `forbidden_token`s must' ' map to single token ids in the vocab.' ) (token_id,) = token_id