Skip to content

Commit

Permalink
Silence Gemma tokenizer warning after first try
Browse files Browse the repository at this point in the history
  • Loading branch information
ProbablyFaiz committed Jul 11, 2024
1 parent afb320d commit facd5cf
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions rl/llm/engines.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,12 +67,13 @@ def _apply_chat_template(tokenizer, messages):
if isinstance(messages, list) and messages and messages[0]["role"] == "system":
messages[0]["role"] = "user"
messages.insert(1, {"role": "assistant", "content": ""})
LOGGER.warning(
"You passed a system message to a Gemma-2 tokenizer, and it "
"doesn't support those. I'll try to fix it by changing the "
"role to 'user' and adding an empty assistant message, but "
"there's no guarantee this will work."
)
if not _WARNED_GEMMA:
LOGGER.warning(
"You passed a system message to a Gemma-2 tokenizer, and it "
"doesn't support those. I'll try to fix it by changing the "
"role to 'user' and adding an empty assistant message, but "
"there's no guarantee this will work."
)
global _WARNED_GEMMA
_WARNED_GEMMA = True
return tokenizer.apply_chat_template(
Expand Down

0 comments on commit facd5cf

Please sign in to comment.