modal.build
def build(
_warn_parentheses_missing=None, *, force: bool = False, timeout: int = 86400
) -> Callable[[Union[Callable[[Any], Any], _PartialFunction]], _PartialFunction]:
Decorator for methods that should execute at build time to create a new layer
in a modal.Image
.
See the lifeycle function guide for more information.
Usage
@app.cls(gpu="A10G")
class AlpacaLoRAModel:
@build()
def download_models(self):
model = LlamaForCausalLM.from_pretrained(
base_model,
)
PeftModel.from_pretrained(model, lora_weights)
LlamaTokenizer.from_pretrained(base_model)