MCPcopy Create free account
hub / github.com/Pints-AI/1.5-Pints / add_model_prefix

Function add_model_prefix

lit_gpt/utils.py:552–560  ·  view source on GitHub ↗

Adds the 'model.' prefix in-place, if it does not already exist.

(state_dict: Dict[str, torch.Tensor])

Source from the content-addressed store, hash-verified

550
551
552def add_model_prefix(state_dict: Dict[str, torch.Tensor]) -> None:
553 """
554 Adds the 'model.' prefix in-place, if it does not already exist.
555 """
556 keys = list(state_dict.keys())
557 for key in keys:
558 if not key.startswith('model.'):
559 new_key = 'model.' + key
560 state_dict[new_key] = state_dict.pop(key)
561
562
563def load_weights(

Callers 1

load_weightsFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected