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

Method load_model

examples/server/server.cpp:539–577  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

537 }
538
539 bool load_model(const gpt_params &params_)
540 {
541 params = params_;
542 if (!params.mmproj.empty()) {
543 multimodal = true;
544 LOG_TEE("Multi Modal Mode Enabled");
545 clp_ctx = clip_model_load(params.mmproj.c_str(), /*verbosity=*/ 1);
546 if(clp_ctx == nullptr) {
547 LOG_ERROR("unable to load clip model", {{"model", params.mmproj}});
548 return false;
549 }
550
551 if (params.n_ctx < 2048) { // request larger context for the image embedding
552 params.n_ctx = 2048;
553 }
554 }
555
556 std::tie(model, ctx) = llama_init_from_gpt_params(params);
557 if (model == nullptr)
558 {
559 LOG_ERROR("unable to load model", {{"model", params.model}});
560 return false;
561 }
562
563 if (multimodal) {
564 const int n_embd_clip = clip_n_mmproj_embd(clp_ctx);
565 const int n_embd_llm = llama_n_embd(model);
566 if (n_embd_clip != n_embd_llm) {
567 LOG_TEE("%s: embedding dim of the multimodal projector (%d) is not equal to that of LLaMA (%d). Make sure that you use the correct mmproj file.\n", __func__, n_embd_clip, n_embd_llm);
568 llama_free(ctx);
569 llama_free_model(model);
570 return false;
571 }
572 }
573
574 n_ctx = llama_n_ctx(ctx);
575
576 return true;
577 }
578
579 void initialize() {
580 id_gen = 0;

Callers 1

mainFunction · 0.45

Calls 9

clip_model_loadFunction · 0.85
clip_n_mmproj_embdFunction · 0.50
llama_n_embdFunction · 0.50
llama_freeFunction · 0.50
llama_free_modelFunction · 0.50
llama_n_ctxFunction · 0.50
emptyMethod · 0.45
c_strMethod · 0.45

Tested by

no test coverage detected