Skip to content
module

Prompt Tuning

4 members
lucid.peft.tuners.prompt_tuning

lucid.peft.tuners.prompt_tuning — prompt tuning: learned embeddings in front of the input.

Prompt tuning (Lester et al., 2021, arXiv:2104.08691) freezes the model and learns num_virtual_tokens embedding vectors that are put in front of the input embeddings. The only trained parameters are num_virtual_tokens * token_dim numbers, so a task is a file of that size. The prompt starts from text, from sampled vocabulary rows or at random (PromptTuningInit). Pick it for the smallest per-task files on a large model; it adds no layer, and trains one prompt at a time.

The prompt is applied by hooks on the model's own call. Here: PromptEmbedding (what is learned) and PromptTuningModel (the tuner). PromptTuningConfig and PromptTuningInit are here too and exported from lucid.peft.

Paper

Lester, Brian, et al. "The Power of Scale for Parameter-Efficient Prompt Tuning." [arXiv:2104.08691](https://arxiv.org/abs/2104.08691), 2021.

Overview

Prompt tuning (Lester et al., 2021, arXiv:2104.08691) freezes the model and learns num_virtual_tokens embedding vectors that are put in front of the input embeddings: the only trained parameters are num_virtual_tokens * token_dim numbers, and a task is a file of that size. An encoder-decoder model gets them in front of the encoder's input.

Classes