mirror of
https://github.com/LostRuins/koboldcpp.git
synced 2026-05-17 04:09:19 +00:00
* move conversion code to a dedicated conversion directory and split the files akin to the src/models architecture --------- Co-authored-by: Sigbjørn Skjæret <sigbjorn.skjaeret@scala.com>
32 lines
958 B
Python
32 lines
958 B
Python
from __future__ import annotations
|
|
|
|
from typing import Callable, TYPE_CHECKING
|
|
|
|
if TYPE_CHECKING:
|
|
from torch import Tensor
|
|
|
|
from .base import ModelBase, gguf
|
|
|
|
from .llama import LlamaModel
|
|
from .qwenvl import Qwen2VLVisionModel
|
|
|
|
|
|
@ModelBase.register("Sarashina2VisionForCausalLM")
|
|
class Sarashina2VLTextModel(LlamaModel):
|
|
model_arch = gguf.MODEL_ARCH.LLAMA
|
|
|
|
@classmethod
|
|
def filter_tensors(cls, item: tuple[str, Callable[[], Tensor]]) -> tuple[str, Callable[[], Tensor]] | None:
|
|
name, gen = item
|
|
if name.startswith("llm."):
|
|
name = name.replace("llm.", "", 1)
|
|
elif name.startswith("norm."):
|
|
return None
|
|
return super().filter_tensors((name, gen))
|
|
|
|
|
|
@ModelBase.register("Sarashina2VisionForCausalLM")
|
|
class Sarashina2VLVisionModel(Qwen2VLVisionModel):
|
|
def __init__(self, *args, **kwargs):
|
|
super().__init__(*args, **kwargs)
|
|
self.global_config['model_type'] = "qwen2_vl"
|