Better way to copy mkultra methods

This commit is contained in:
vfbd 2022-07-24 00:35:58 -04:00
parent 289248ef40
commit 168c14fd4c
1 changed files with 4 additions and 2 deletions

View File

@ -78,8 +78,10 @@ class UniversalPromptTuningMixin:
Embedding.__call__ = old_embedding_call Embedding.__call__ = old_embedding_call
for k in dir(GPTPromptTuningMixin): for k in dir(GPTPromptTuningMixin):
if not hasattr(UniversalPromptTuningMixin, k): v = getattr(GPTPromptTuningMixin, k)
setattr(UniversalPromptTuningMixin, k, 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): class AutoPromptTuningLM(UniversalPromptTuningMixin, transformers.AutoModelForCausalLM):