MCPcopy Create free account
hub / github.com/bigcode-project/starcoder / LoadBestPeftModelCallback

Class LoadBestPeftModelCallback

finetune/finetune.py:35–48  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

33
34
35class LoadBestPeftModelCallback(TrainerCallback):
36 def on_train_end(
37 self,
38 args: TrainingArguments,
39 state: TrainerState,
40 control: TrainerControl,
41 **kwargs,
42 ):
43 print(f"Loading best peft model from {state.best_model_checkpoint} (score: {state.best_metric}).")
44 best_model_path = os.path.join(state.best_model_checkpoint, "adapter_model.bin")
45 adapters_weights = torch.load(best_model_path)
46 model = kwargs["model"]
47 set_peft_model_state_dict(model, adapters_weights)
48 return control
49
50
51def get_args():

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected