data
PromptTuningConfig
extends
PromptLearningConfigPromptTuningConfig(task_type: TaskType | str | None = None, peft_type: PeftType | str | None = None, auto_mapping: dict[str, str] | None = None, peft_version: str | None = None, base_model_name_or_path: str | None = None, revision: str | None = None, inference_mode: bool = False, num_virtual_tokens: int | None = None, token_dim: int | None = None, num_transformer_submodules: int | None = None, num_attention_heads: int | None = None, num_layers: int | None = None, modules_to_save: list[str] | None = None, prompt_tuning_init: PromptTuningInit | str = PromptTuningInit.RANDOM, prompt_tuning_init_text: str | None = None, tokenizer_name_or_path: str | None = None, tokenizer_kwargs: dict[str, object] | None = None)How lucid.peft.get_peft_model adapts a model with prompt tuning.
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.
Field names, their order, defaults and adapter_config.json are the reference adapter
library's.
Parameters
As in
lucid.peft.PeftConfig.As in
lucid.peft.PeftConfig.As in
lucid.peft.PeftConfig.As in
lucid.peft.PeftConfig.As in
lucid.peft.PeftConfig.As in
lucid.peft.PeftConfig.As in
lucid.peft.PeftConfig.num_ virtual_ tokensint | None= NoneAs in
lucid.peft.PromptLearningConfig.token_ dimint | None= NoneAs in
lucid.peft.PromptLearningConfig.num_ transformer_ submodulesint | None= NoneAs in
lucid.peft.PromptLearningConfig.num_ attention_ headsint | None= NoneAs in
lucid.peft.PromptLearningConfig.num_ layersint | None= NoneAs in
lucid.peft.PromptLearningConfig.modules_ to_ saveint | None= NoneAs in
lucid.peft.PromptLearningConfig."RANDOM" keeps the embedding table's initialisation; "SAMPLE_VOCAB"
starts from the embeddings of random vocabulary tokens; "TEXT"
starts from those of prompt_tuning_init_text's tokens (cut or
repeated to num_virtual_tokens).prompt_ tuning_ init_ textstr= NoneThe text
"TEXT" starts from; required then.tokenizer_ name_ or_ pathstr= NoneNames the tokenizer that turns that text into ids; required for
"TEXT".tokenizer_ kwargsdict= NoneKeyword arguments for loading that tokenizer; only with
"TEXT".Raises
TypeErrorA field holds a value of the wrong type.
ValueError"TEXT" without its text or tokenizer, or tokenizer_kwargs without "TEXT".Examples
>>> from lucid.peft import PromptTuningConfig
>>> config = PromptTuningConfig(num_virtual_tokens=8, task_type="CAUSAL_LM")
>>> config.peft_type, config.prompt_tuning_init
(<PeftType.PROMPT_TUNING: 'PROMPT_TUNING'>, <PromptTuningInit.RANDOM: 'RANDOM'>)
>>> PromptTuningConfig.from_dict(config.to_dict()) == config
True