MCPcopy Create free account
hub / github.com/antirez/llama.cpp-deepseek-v4-flash / common_init_result

Method common_init_result

common/common.cpp:1144–1242  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1142};
1143
1144common_init_result::common_init_result(common_params & params) :
1145 pimpl(new impl{}) {
1146 auto mparams = common_model_params_to_llama(params);
1147 auto cparams = common_context_params_to_llama(params);
1148
1149 if (params.fit_params) {
1150 LOG_INF("%s: fitting params to device memory, for bugs during this step try to reproduce them with -fit off, or provide --verbose logs if the bug only occurs with -fit on\n", __func__);
1151 common_fit_params(params.model.path.c_str(), &mparams, &cparams,
1152 params.tensor_split,
1153 params.tensor_buft_overrides.data(),
1154 params.fit_params_target.data(),
1155 params.fit_params_min_ctx,
1156 params.verbosity >= 4 ? GGML_LOG_LEVEL_DEBUG : GGML_LOG_LEVEL_ERROR);
1157 }
1158
1159 llama_model * model = llama_model_load_from_file(params.model.path.c_str(), mparams);
1160 if (model == NULL) {
1161 return;
1162 }
1163
1164 pimpl->model.reset(model);
1165
1166 const llama_vocab * vocab = llama_model_get_vocab(model);
1167
1168 // load and optionally apply lora adapters
1169 for (auto & la : params.lora_adapters) {
1170 llama_adapter_lora_ptr lora;
1171 lora.reset(llama_adapter_lora_init(model, la.path.c_str()));
1172 if (lora == nullptr) {
1173 LOG_ERR("%s: failed to load lora adapter '%s'\n", __func__, la.path.c_str());
1174 pimpl->model.reset(model);
1175 return;
1176 }
1177
1178 char buf[1024];
1179 la.ptr = lora.get();
1180 llama_adapter_meta_val_str(la.ptr, "adapter.lora.task_name", buf, sizeof(buf));
1181 la.task_name = buf;
1182 llama_adapter_meta_val_str(la.ptr, "adapter.lora.prompt_prefix", buf, sizeof(buf));
1183 la.prompt_prefix = buf;
1184 pimpl->lora.emplace_back(std::move(lora)); // copy to list of loaded adapters
1185 }
1186
1187 // updates params.sampling
1188 // TODO: fix naming
1189 common_init_sampler_from_model(model, params.sampling);
1190
1191 if (params.sampling.ignore_eos && llama_vocab_eos(vocab) == LLAMA_TOKEN_NULL) {
1192 LOG_WRN("%s: warning: vocab does not have an EOS token, ignoring --ignore-eos\n", __func__);
1193 params.sampling.ignore_eos = false;
1194 }
1195
1196 // initialize once
1197 for (llama_token i = 0; i < llama_vocab_n_tokens(vocab); i++) {
1198 if (llama_vocab_is_eog(vocab, i)) {
1199 LOG_INF("%s: added %s logit bias = %f\n", __func__, common_token_to_piece(vocab, i).c_str(), -INFINITY);
1200 params.sampling.logit_bias_eog.push_back({i, -INFINITY});
1201 }

Callers

nothing calls this directly

Calls 15

common_fit_paramsFunction · 0.85
llama_model_get_vocabFunction · 0.85
llama_adapter_lora_initFunction · 0.85
llama_vocab_eosFunction · 0.85
llama_vocab_n_tokensFunction · 0.85
llama_vocab_is_eogFunction · 0.85
common_token_to_pieceFunction · 0.85

Tested by

no test coverage detected