P-Tuning
4 memberslucid.peft.tuners.p_tuninglucid.peft.tuners.p_tuning — p-tuning: virtual tokens produced by an MLP or LSTM.
P-tuning (Liu et al., 2021, arXiv:2103.10385 — "GPT Understands, Too") puts num_virtual_tokens
learned embeddings in front of the input like prompt tuning, but produces them through an encoder,
an MLP or a bidirectional LSTM followed by one, so the tokens depend on each other. The encoder is
only used while training: the file stores the prompt it produced. Pick it over prompt tuning when
independent token embeddings train poorly.
The prompt is applied by hooks on the model's own call. Here: PromptEncoder (what is learned)
and PromptEncoderModel (the tuner). PromptEncoderConfig and
PromptEncoderReparameterizationType are here too and exported from lucid.peft.
Liu, Xiao, et al. "GPT Understands, Too." [arXiv:2103.10385](https://arxiv.org/abs/2103.10385), 2021.
P-tuning (Liu et al., 2021, arXiv:2103.10385) puts num_virtual_tokens
learned embeddings in front of the input like prompt tuning, but produces
them through an encoder — an MLP, or a bidirectional LSTM followed by one —
so the tokens depend on each other. The encoder is only used while
training: the file stores the prompt it produced.
Classes
PromptEncoderConfigHow lucid.peft.get_peft_model adapts a model with p-tuning.
PromptEncoderReparameterizationTypeWhat turns the virtual tokens' embeddings into the prompt: an MLP or an LSTM.
PromptEncoder10 methodsThe prompt of p-tuning: virtual-token embeddings through an MLP, or a bidirectional LSTM and an MLP.
PromptEncoderModel11 methodsThe tuner of p-tuning: a PromptEncoder per adapter, whose prompt goes in front of the input.