From b06f3dfd9198b849828059defc23cbf9e6b39590 Mon Sep 17 00:00:00 2001 From: ebolam Date: Sun, 19 May 2024 10:56:46 -0400 Subject: [PATCH] Fix for transformers moving GenerationMixin.sample to GenerationMixin._sample --- modeling/inference_model.py | 6 +++--- modeling/inference_models/hf_torch.py | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/modeling/inference_model.py b/modeling/inference_model.py index 1af066755..441335cc4 100644 --- a/modeling/inference_model.py +++ b/modeling/inference_model.py @@ -46,8 +46,8 @@ def __enter__(self): ) if use_core_manipulations.sample: - use_core_manipulations.old_sample = transformers.GenerationMixin.sample - transformers.GenerationMixin.sample = use_core_manipulations.sample + use_core_manipulations.old_sample = transformers.GenerationMixin._sample + transformers.GenerationMixin._sample = use_core_manipulations.sample if use_core_manipulations.get_stopping_criteria: use_core_manipulations.old_get_stopping_criteria = ( @@ -69,7 +69,7 @@ def __exit__(self, exc_type, exc_value, exc_traceback): ), "Patch leak: THE MONKEYS HAVE ESCAPED" if use_core_manipulations.old_sample: - transformers.GenerationMixin.sample = use_core_manipulations.old_sample + transformers.GenerationMixin._sample = use_core_manipulations.old_sample else: assert ( not use_core_manipulations.sample diff --git a/modeling/inference_models/hf_torch.py b/modeling/inference_models/hf_torch.py index fcdd9fb9f..37eaf1058 100644 --- a/modeling/inference_models/hf_torch.py +++ b/modeling/inference_models/hf_torch.py @@ -266,7 +266,7 @@ def new_sample(self, *args, **kwargs): kwargs.setdefault("pad_token_id", 2) return new_sample.old_sample(self, *args, **kwargs) - new_sample.old_sample = transformers.GenerationMixin.sample + new_sample.old_sample = transformers.GenerationMixin._sample use_core_manipulations.sample = new_sample # PEFT Loading. This MUST be done after all save_pretrained calls are