Felipe97/llama-cpp-compiled
01.1k
1from __future__ import annotations2 3from typing import Callable, TYPE_CHECKING4 5if TYPE_CHECKING:6 from torch import Tensor7 8from .base import ModelBase, gguf9 10from .llama import LlamaModel11from .qwenvl import Qwen2VLVisionModel12 13 14@ModelBase.register("Sarashina2VisionForCausalLM")15@ModelBase.example("sbintuitions/sarashina2.2-vision-3b")16class Sarashina2VLTextModel(LlamaModel):17 model_arch = gguf.MODEL_ARCH.LLAMA18 19 @classmethod20 def filter_tensors(cls, item: tuple[str, Callable[[], Tensor]]) -> tuple[str, Callable[[], Tensor]] | None:21 name, gen = item22 if name.startswith("llm."):23 name = name.replace("llm.", "", 1)24 elif name.startswith("norm."):25 return None26 return super().filter_tensors((name, gen))27 28 29@ModelBase.register("Sarashina2VisionForCausalLM")30@ModelBase.example("sbintuitions/sarashina2.2-vision-3b")31class Sarashina2VLVisionModel(Qwen2VLVisionModel):32 def __init__(self, *args, **kwargs):33 super().__init__(*args, **kwargs)34 self.global_config['model_type'] = "qwen2_vl"35 