From f55e85e28a218875bc989a5567ffe0ae66c7458e Mon Sep 17 00:00:00 2001 From: oobabooga <112222186+oobabooga@users.noreply.github.com> Date: Tue, 6 Jun 2023 19:42:40 -0300 Subject: [PATCH] Fix multimodal with model loaded through AutoGPTQ --- extensions/multimodal/pipelines/llava/llava.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/extensions/multimodal/pipelines/llava/llava.py b/extensions/multimodal/pipelines/llava/llava.py index 16f0e06f..eca2be50 100644 --- a/extensions/multimodal/pipelines/llava/llava.py +++ b/extensions/multimodal/pipelines/llava/llava.py @@ -56,7 +56,12 @@ class LLaVA_v0_Pipeline(AbstractMultimodalPipeline): @staticmethod def embed_tokens(input_ids: torch.Tensor) -> torch.Tensor: - return shared.model.model.embed_tokens(input_ids).to(shared.model.device, dtype=shared.model.dtype) + if hasattr(shared.model.model, 'embed_tokens'): + func = shared.model.model.embed_tokens + else: + func = shared.model.model.model.embed_tokens # AutoGPTQ case + + return func(input_ids).to(shared.model.device, dtype=shared.model.dtype) @staticmethod def placeholder_embeddings() -> torch.Tensor: