MCPcopy Create free account
hub / github.com/Tiiny-AI/PowerInfer / llama_model_chat_template

Function llama_model_chat_template

smallthinker/src/llama-model.cpp:14288–14305  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

14286}
14287
14288const char * llama_model_chat_template(const llama_model * model, const char * name) {
14289 const auto key = name ? LLM_KV(model->arch, name)(LLM_KV_TOKENIZER_CHAT_TEMPLATE_N)
14290 : LLM_KV(model->arch)(LLM_KV_TOKENIZER_CHAT_TEMPLATE);
14291 const auto & it = model->gguf_kv.find(key);
14292 if (it == model->gguf_kv.end()) {
14293 // one-off fix for very popular models (so we are not flooded with issues)
14294 // do not extend this list unless absolutely necessary
14295 // Mistral-Small-2503 does not have built-in chat template
14296 llama_vocab_pre_type pre_type = model->vocab.get_pre_type();
14297 if (pre_type == LLAMA_VOCAB_PRE_TYPE_TEKKEN && model->layers.size() == 40) {
14298 return "mistral-v7-tekken";
14299 }
14300
14301 return nullptr;
14302 }
14303
14304 return it->second.c_str();
14305}
14306
14307uint64_t llama_model_n_params(const llama_model * model) {
14308 return model->n_elements();

Callers 4

mtmd_cli_contextMethod · 0.85
get_tts_versionFunction · 0.85
mainFunction · 0.85

Calls 6

findMethod · 0.80
get_pre_typeMethod · 0.80
LLM_KVClass · 0.70
endMethod · 0.45
sizeMethod · 0.45
c_strMethod · 0.45

Tested by

no test coverage detected