char-fork/llama.cpp

git clone https://git.t4t.associates/char-fork/llama.cpp

Xuan-Son Nguyenconvert: add @ModelBase.example (#27208)fa88ae936

char/aliceai-t5-moe
1.0 KiB34 linesraw
1from __future__ import annotations
2
3from typing import Callable, TYPE_CHECKING
4
5if TYPE_CHECKING:
6    from torch import Tensor
7
8from .base import ModelBase, gguf
9
10from .llama import LlamaModel
11from .qwenvl import Qwen2VLVisionModel
12
13
14@ModelBase.register("Sarashina2VisionForCausalLM")
15@ModelBase.example("sbintuitions/sarashina2.2-vision-3b")
16class Sarashina2VLTextModel(LlamaModel):
17    model_arch = gguf.MODEL_ARCH.LLAMA
18
19    @classmethod
20    def filter_tensors(cls, item: tuple[str, Callable[[], Tensor]]) -> tuple[str, Callable[[], Tensor]] | None:
21        name, gen = item
22        if name.startswith("llm."):
23            name = name.replace("llm.", "", 1)
24        elif name.startswith("norm."):
25            return None
26        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"