Skip to content
data

PromptLearningConfig

extendsPeftConfig
PromptLearningConfig(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)

The fields of a method that learns an input rather than a weight.

Prompt tuning, prefix tuning and p-tuning put learned vectors in front of the input — as extra token embeddings, or as extra keys and values of every attention layer. The sizes they need are the base model's, so everything but num_virtual_tokens can be left None and is read off the model's config when the adapter is built.

Parameters

task_typeTaskType or str= None
The task the adapter is for (metadata; see TaskType).
peft_typePeftType or str= None
The method; filled in by the subclass when omitted, refused when it names another.
auto_mappingdict of str to str= None
The class of the base model, {"base_model_class": name, "parent_library": module} — what AutoPeftModel* rebuilds the base with. PeftModel.save_pretrained writes it.
peft_versionstr= None
The library version that wrote the adapter file (metadata). Left None it is not written; a file that carries one keeps it.
base_model_name_or_pathstr= None
Name of the model the adapter was trained on (metadata).
revisionstr= None
Revision of that model (metadata).
inference_modebool= False
Freeze the adapter too, for inference.
num_virtual_tokensint= None
How many learned positions go in front of the input; required by the time the adapter is built.
token_dimint= None
The model's hidden size.
num_transformer_submodulesint= None
1 for an encoder-only or decoder-only model, 2 for an encoder-decoder one; 2 for task_type="SEQ_2_SEQ_LM" and 1 otherwise when omitted.
num_attention_headsint= None
The model's head count.
num_layersint= None
The model's layer count.
modules_to_savelist of str= None
Modules of the model trained in full beside the prompt (a classification head).

Used by 20

… 8 more