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 .base import ModelBase ,TextModel ,gguf 4 5 6@ ModelBase . register ( "OrionForCausalLM" ) 7@ ModelBase . example ( "OrionStarAI/Orion-14B-Base" ) 8class OrionModel (TextModel ): 9model_arch = gguf .MODEL_ARCH .ORION 10 11def set_vocab (self ): 12self ._set_vocab_sentencepiece () 13 14def set_gguf_parameters (self ): 15head_count = self .hparams ["num_attention_heads" ] 16head_count_kv = self .hparams .get ("num_key_value_heads" ,head_count ) 17 18ctx_length = 0 19if "max_sequence_length" in self .hparams : 20ctx_length = self .hparams ["max_sequence_length" ] 21elif "max_position_embeddings" in self .hparams : 22ctx_length = self .hparams ["max_position_embeddings" ] 23elif "model_max_length" in self .hparams : 24ctx_length = self .hparams ["model_max_length" ] 25else : 26raise ValueError ("gguf: can not find ctx length parameter." ) 27 28self .gguf_writer .add_file_type (self .ftype ) 29self .gguf_writer .add_tensor_data_layout ("Meta AI original pth" ) 30self .gguf_writer .add_context_length (ctx_length ) 31self .gguf_writer .add_embedding_length (self .hparams ["hidden_size" ]) 32self .gguf_writer .add_block_count (self .block_count ) 33self .gguf_writer .add_feed_forward_length (self .hparams ["intermediate_size" ]) 34self .gguf_writer .add_head_count (head_count ) 35self .gguf_writer .add_head_count_kv (head_count_kv ) 36# note: config provides rms norm but it is actually layer norm 37# ref: https://huggingface.co/OrionStarAI/Orion-14B-Chat/blob/276a17221ce42beb45f66fac657a41540e71f4f5/modeling_orion.py#L570-L571 38self .gguf_writer .add_layer_norm_eps (self .hparams ["rms_norm_eps" ])