MCPcopy Create free account
hub / github.com/abetlen/llama-cpp-python / _load_lora_adapters

Method _load_lora_adapters

examples/server/server.py:11769–11789  ·  view source on GitHub ↗
(self, loras: List["Model.LoraAdapter"])

Source from the content-addressed store, hash-verified

11767 return self.n_ctx
11768
11769 def _load_lora_adapters(self, loras: List["Model.LoraAdapter"]) -> None:
11770 for lora in loras:
11771 adapter = llama_cpp.llama_adapter_lora_init(
11772 self.llama_model,
11773 lora.path.encode("utf-8"),
11774 )
11775 if adapter is None:
11776 raise RuntimeError(f"failed to load LoRA adapter: {lora.path}")
11777 self._lora_adapters.append(adapter)
11778
11779 if not self._lora_adapters:
11780 return
11781
11782 adapter_array_type = llama_cpp.llama_adapter_lora_p_ctypes * len(
11783 self._lora_adapters
11784 )
11785 scale_array_type = ctypes.c_float * len(self._lora_adapters)
11786 self._lora_adapter_array = adapter_array_type(*self._lora_adapters)
11787 self._lora_scales_array = scale_array_type(
11788 *(float(lora.scale) for lora in loras)
11789 )
11790
11791 def _apply_lora_adapters(self, ctx: Any, context_name: str) -> None:
11792 if not self._lora_adapters:

Callers 1

__init__Method · 0.95

Calls 2

appendMethod · 0.80
encodeMethod · 0.45

Tested by

no test coverage detected