From 168c14fd4c800a6530d3d4433a707e9b8a1d43cf Mon Sep 17 00:00:00 2001 From: vfbd Date: Sun, 24 Jul 2022 00:35:58 -0400 Subject: [PATCH] Better way to copy mkultra methods --- prompt_tuner.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/prompt_tuner.py b/prompt_tuner.py index 99320861..1ce3e210 100644 --- a/prompt_tuner.py +++ b/prompt_tuner.py @@ -78,8 +78,10 @@ class UniversalPromptTuningMixin: Embedding.__call__ = old_embedding_call for k in dir(GPTPromptTuningMixin): - if not hasattr(UniversalPromptTuningMixin, k): - setattr(UniversalPromptTuningMixin, k, getattr(GPTPromptTuningMixin, k)) + v = getattr(GPTPromptTuningMixin, k) + _v = getattr(UniversalPromptTuningMixin, k, None) + if _v is None or (_v is getattr(object, k, None) and callable(_v) and not isinstance(_v, type)): + setattr(UniversalPromptTuningMixin, k, v) class AutoPromptTuningLM(UniversalPromptTuningMixin, transformers.AutoModelForCausalLM):