micm_nlp.models.xpe.save_load¶
XPE-aware save/load helpers.
These replace peft.utils.save_and_load.get_peft_model_state_dict and
set_peft_model_state_dict while an XPE model saves or loads (the PeftModel
subclasses swap them in). Their bodies started as copies of peft 0.14’s; the XPE
differences:
The prompt encoder’s weights are read from and written to the encoder itself, as
prompt_encoder.<param>. Stock PEFT reduces a prompt encoder to oneprompt_embeddingstensor, and since peft 0.17 a CAUSAL_LM encoder’s parts are never wrapped bymodules_to_saveeither. The keys are the ones peft 0.14-era adapters were saved under, so those still load; a missing encoder weight raises.The
PEFT_TYPE_TO_PREFIX_MAPPINGbranch is skipped for prompt learning: since peft 0.15 XPE is in that mapping asxpe_, and inserting the adapter name after that prefix would corrupt thexpe_embedding/xpe_headkeys.Everything else –
save_embedding_layers,modules_to_savefor the rest of the model (a SEQ_CLS classifier) – follows upstream.
Functions¶
|
See module docstring. Mirrors upstream except the prompt-learning collapse. |
|
See module docstring. Mirrors upstream except it skips the destructive |
Module Contents¶
- micm_nlp.models.xpe.save_load.xpe_get_peft_model_state_dict(model, state_dict=None, adapter_name='default', unwrap_compiled=False, save_embedding_layers='auto')¶
See module docstring. Mirrors upstream except the prompt-learning collapse.
- micm_nlp.models.xpe.save_load.xpe_set_peft_model_state_dict(model, peft_model_state_dict, adapter_name='default', ignore_mismatched_sizes: bool = False, low_cpu_mem_usage: bool = False)¶
See module docstring. Mirrors upstream except it skips the destructive
prompt_embeddingssingle-tensor load and instead does a non-strictprompt_encoder.load_state_dictso XPE’s multi-component state loads.