LoRAAdapter#
- class LoRAAdapter(model, rank: int = 8, alpha: float = 16.0, dropout: float = 0.0, target_modules=('attn.qkv', 'attn.proj'), trainable_keywords=())[source]#
Bases:
ModuleFreeze a built model and LoRA-tune its attention blocks.
- Parameters:
model – config of the inner model to build and adapt.
rank – LoRA rank for every injected adapter.
alpha – LoRA scaling numerator (effective scale = alpha / rank).
dropout – dropout applied to the LoRA branch input.
target_modules – a Linear module is adapted if its dotted name equals or ends with “.<entry>” (anchored on a path-component boundary). Default targets PT-v3 attention projections (”…block.attn.qkv/proj”); the anchoring means it will NOT match a decoder’s “self_attn.proj”.
trainable_keywords – parameters whose dotted name contains any of these substrings stay trainable (e.g. the task head). Everything else in the base model is frozen. Empty => only LoRA params train.