diff --git a/unsloth/tokenizer_utils.py b/unsloth/tokenizer_utils.py index f2b0da8600..3b336664d0 100644 --- a/unsloth/tokenizer_utils.py +++ b/unsloth/tokenizer_utils.py @@ -1059,8 +1059,11 @@ for trainer_name in ("SFTTrainer", "DPOTrainer", "KTOTrainer"): if trainer_text is None: continue try: exec(trainer_text, globals()) - except: - raise RuntimeError(f"Unsloth: Please file a bug report! Error patching {trainer_name}") + except Exception as error: + raise RuntimeError( + f"Unsloth: Please file a bug report! Error patching {trainer_name}. Error:\n"\ + f"{str(error)}", + ) exec(f"trl.trainer.{trainer_name} = Unsloth{trainer_name}", globals()) pass