From 5d95a23273a14101eb58f27dd0dc7edff4b5426d Mon Sep 17 00:00:00 2001 From: Datta Nimmaturi Date: Mon, 2 Feb 2026 11:39:15 +0530 Subject: [PATCH] [fix] qwen3-guard tokenizer (#3959) * fix for qwen3-guard tokenizer * Better qwen3guard check * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> --- unsloth/tokenizer_utils.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/unsloth/tokenizer_utils.py b/unsloth/tokenizer_utils.py index 0136e3498e..087a9a7f8a 100644 --- a/unsloth/tokenizer_utils.py +++ b/unsloth/tokenizer_utils.py @@ -602,7 +602,10 @@ def load_correct_tokenizer( old_chat_template = getattr(tokenizer, "chat_template", None) # Ignore mistral type models since they don't have an add_generation_prompt - if "mistral" in str(getattr(tokenizer, "name_or_path", "")).lower(): + if any( + s in str(getattr(tokenizer, "name_or_path", "")).lower() + for s in ["mistral", "qwen3guard"] + ): chat_template = old_chat_template # Also check Llama-2 old style models