Brunobkr/llama.cpp_AlgMor24_github
ΩFFFΣLLIa • llama.cpp • AlgMor24 ██████╗ ███████╗███████╗███████╗██╗ ██╗ ██╗ █████╗ ██╔═══██╗██╔════╝██╔════╝██╔════╝██║ ██║ ██║██╔══██╗ ██║ ██║█████╗ █████╗ █████╗ ██║ ██║ ██║███████║ ██║ ██║██╔══╝ ██╔══╝ ██╔══╝ ██║ ██║ ██║██╔══██║ ╚██████╔╝██║ ██║ ███████╗███████╗███████╗██║██║ ██║ ╚═════╝ ╚═╝ ╚═╝ ╚══════╝╚══════╝╚══════╝╚═╝╚═╝ ╚═╝ High-Performance LLM / VLM Inference & Autonomous Agentic Ecosystem… See the full description on the dataset page: https://huggingface.co/datasets/Brunobkr/llama.cpp_AlgMor24_github.
03.1k
1from __future__ import annotations2 3from typing import Callable, Iterable, TYPE_CHECKING4 5if TYPE_CHECKING:6 from torch import Tensor7 8from .base import MmprojModel, ModelBase, gguf9 10 11@ModelBase.register("DotsOCRForCausalLM")12class DotsOCRVisionModel(MmprojModel):13 def __init__(self, *args, **kwargs):14 super().__init__(*args, **kwargs)15 assert self.hparams_vision is not None16 self.hparams_vision["image_size"] = 0 # dynamic resolution17 18 def set_gguf_parameters(self):19 super().set_gguf_parameters()20 self.gguf_writer.add_clip_projector_type(gguf.VisionProjectorType.DOTSOCR)21 self.gguf_writer.add_vision_min_pixels(self.preprocessor_config["min_pixels"])22 self.gguf_writer.add_vision_max_pixels(self.preprocessor_config["max_pixels"])23 self.gguf_writer.add_vision_attention_layernorm_eps(self.find_vparam(["rms_norm_eps"]))24 self.gguf_writer.add_vision_projector_scale_factor(self.find_vparam(["spatial_merge_size"]))25 self.gguf_writer.add_vision_use_silu(True)26 27 @classmethod28 def filter_tensors(cls, item: tuple[str, Callable[[], Tensor]]) -> tuple[str, Callable[[], Tensor]] | None:29 name, gen = item30 31 if not name.startswith("vision_tower."):32 return None33 34 if "vision_tower.blocks." in name and ".mlp." in name:35 # note: to avoid naming conflicts in tensor_mapping.py, we need to handle FFN renaming here36 # x = F.silu(self.fc1(x)) * self.fc3(x)37 # x = self.fc2(x)38 # fc1 -> gate, fc2 -> down, fc3 -> up39 # mapping original names to Qwen2.5 naming scheme40 name = name.replace("vision_tower.blocks.", "visual.blocks.")41 name = name.replace(".fc1", ".gate_proj")42 name = name.replace(".fc2", ".down_proj")43 name = name.replace(".fc3", ".up_proj")44 45 return super().filter_tensors((name, gen))46 47 def modify_tensors(self, data_torch: Tensor, name: str, bid: int | None) -> Iterable[tuple[str, Tensor]]:48 yield from super().modify_tensors(data_torch, name, bid)49 