@@ -417,19 +417,6 @@ void llama_model::load_arch(llama_model_loader & ml) {
417417 }
418418}
419419
420- struct LLM_KV_MATCH_WITHOUT_ARCH {
421- const LLM_KV kv_arch = LLM_KV(LLM_ARCH_UNKNOWN);
422- const std::string kv_arch_prefix = llm_arch_name(LLM_ARCH_UNKNOWN);
423-
424- bool operator()(const llm_kv & kv, const std::string & kv_name) const
425- {
426- std::string kv_match = kv_arch(kv);
427- auto kv_arch_pos = kv_match.find(kv_arch_prefix);
428-
429- return kv_name.find(kv_match.substr(kv_arch_pos == std::string::npos ? 0 : kv_arch_pos + kv_arch_prefix.size())) != std::string::npos;
430- }
431- };
432-
433420void llama_model::load_hparams(llama_model_loader & ml) {
434421 const gguf_context * ctx = ml.meta.get();
435422
@@ -439,13 +426,12 @@ void llama_model::load_hparams(llama_model_loader & ml) {
439426 gguf_type type = gguf_get_kv_type(ctx, i);
440427
441428 if (type == GGUF_TYPE_ARRAY) {
442- if (LLM_KV_MATCH_WITHOUT_ARCH( )(LLM_KV_CLASSIFIER_OUTPUT_LABELS, name) ) {
429+ if (LLM_KV(arch )(LLM_KV_CLASSIFIER_OUTPUT_LABELS) == name) {
443430 const size_t n_items = gguf_get_arr_n(ctx, i);
444431
445432 for (size_t j = 0; j < n_items; j++) {
446- const std::string name_i = format("%s.%zu", name, j);
447433 const std::string value = gguf_get_arr_str(ctx, i, j);
448- gguf_kv.emplace(name_i, value);
434+ classifier_labels.emplace_back( value);
449435 }
450436 }
451437 } else {
@@ -13620,12 +13606,9 @@ uint32_t llama_model_n_cls_out(const struct llama_model * model) {
1362013606 return model->hparams.n_cls_out;
1362113607}
1362213608
13623- const char * llama_model_get_classifier_label_by_index(const struct llama_model * model, uint32_t i) {
13624- const std::string key = format("%s.%u", LLM_KV(model->arch)(LLM_KV_CLASSIFIER_OUTPUT_LABELS).c_str(), i);
13625- const auto & it = model->gguf_kv.find(key);
13626-
13627- if (it != model->gguf_kv.end()) {
13628- return it->second.c_str();
13609+ const char * llama_model_cls_label(const struct llama_model * model, uint32_t i) {
13610+ if (i < model->classifier_labels.size()) {
13611+ return model->classifier_labels[i].c_str();
1362913612 }
1363013613
1363113614 return nullptr;
0 commit comments