diff --git a/unsloth/tokenizer_utils.py b/unsloth/tokenizer_utils.py index c35d990d00..e2ba5fab7e 100644 --- a/unsloth/tokenizer_utils.py +++ b/unsloth/tokenizer_utils.py @@ -952,8 +952,9 @@ def patch_sft_trainer_tokenizer(): check_text = "\n".join(" "*where + x for x in check_text) if replacer is None: + # .*? matches first match. .+? matches final match. replacer = re.findall( - f"def {function_name}\(.+?\).+?\:\n", + f"def {function_name}\(.*?\).*?\:\n", function, flags = re.MULTILINE | re.DOTALL, )