Adaption Prompt
3 memberslucid.peft.tuners.adaption_promptlucid.peft.tuners.adaption_prompt — adaption prompts (LLaMA-Adapter): learned prompts the top attention layers attend to.
LLaMA-Adapter (Zhang et al., 2023, arXiv:2303.16199) freezes a decoder language model and gives
each of its top attention layers adapter_len learned prompt vectors. The layer's
queries attend to keys and values that the layer's own projections make of the prompt, and the
result is added to the layer's output through a gate that starts at zero:
. The adapted model therefore
starts as the base, and the first gradients move the gate before the prompt matters. Pick it to
steer a decoder with a few thousand parameters when the weights should stay untouched; unlike
prompt tuning it acts inside the layers, and unlike LoRA it cannot be folded into the weights.
It needs the attention's keys and values and its queries, which a module does not return, so each
supported family is one strategy: the zoo's gpt and gpt2 decoders (fused c_attn
projection). Any other model type raises ValueError naming the supported ones. AdaptionPromptConfig
and AdaptionPromptModel are here and exported from lucid.peft; AdaptedAttention is the
layer. Importing the package registers the method under PeftType.ADAPTION_PROMPT.
Zhang, Renrui, et al. "LLaMA-Adapter: Efficient Fine-tuning of Language Models with Zero-init Attention." [arXiv:2303.16199](https://arxiv.org/abs/2303.16199), 2023.
LLaMA-Adapter (Zhang et al., 2023, arXiv:2303.16199) freezes the model and gives each of the
top adapter_layers attention layers adapter_len learned prompt vectors. The layer's
queries attend to keys and values projected from the prompt, and that attention output is
added to the layer's own, scaled by a gate that starts at zero, so the adapted model starts as
the base.
Classes
AdaptionPromptConfig9 methodsHow lucid.peft.get_peft_model adapts a decoder with adaption prompts (LLaMA-Adapter).
AdaptedAttention18 methodsAn attention module that also attends to learned prompts: .
AdaptionPromptModel16 methodsA model whose top attention layers also attend to learned prompts, and the tools to take them out again.