char-fork/llama.cpp
git clone https://git.t4t.associates/char-fork/llama.cpp
fa88ae936
char/aliceai-t5-moe
1from __future__import annotations 2 3from typing import Callable ,TYPE_CHECKING 4 5if TYPE_CHECKING : 6from torch import Tensor 7 8from .base import MmprojModel ,ModelBase ,gguf 9 10from .llama import LlamaModel 11 12 13@ ModelBase . register ( "CogVLMForCausalLM" ) 14@ ModelBase . example ( "THUDM/cogvlm2-llama3-chat-19B" , "THUDM/cogvlm-chat-hf" ) 15class CogVLMVisionModel (MmprojModel ): 16 17def set_gguf_parameters (self ): 18super ().set_gguf_parameters () 19self .gguf_writer .add_vision_attention_layernorm_eps (self .hparams .get ("layer_norm_eps" ,1e-6 )) 20self .gguf_writer .add_clip_projector_type (gguf .VisionProjectorType .COGVLM ) 21 22@classmethod 23def filter_tensors (cls ,item :tuple [str ,Callable [[],Tensor ]])-> tuple [str ,Callable [[],Tensor ]]| None : 24name ,gen = item 25 26if not name .startswith ("model.vision." ): 27return None 28 29return super ().filter_tensors (item ) 30 31 32@ ModelBase . register ( "CogVLMForCausalLM" ) 33@ ModelBase . example ( "THUDM/cogvlm2-llama3-chat-19B" , "THUDM/cogvlm-chat-hf" ) 34class CogVLMModel (LlamaModel ): 35model_arch = gguf .MODEL_ARCH .COGVLM