Skip to content
module

P-Tuning

4 members
lucid.peft.tuners.p_tuning

lucid.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.

Paper

Liu, Xiao, et al. "GPT Understands, Too." [arXiv:2103.10385](https://arxiv.org/abs/2103.10385), 2021.

Overview

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