config
mindnlp.peft.config
¶
configs
mindnlp.peft.config.PeftConfig
dataclass
¶
Bases: PeftConfigMixin
This is the base configuration class to store the configuration of a [PeftModel].
| PARAMETER | DESCRIPTION |
|---|---|
peft_type |
The type of Peft method to use.
TYPE:
|
task_type |
The type of task to perform.
TYPE:
|
inference_mode |
Whether to use the Peft model in inference mode.
TYPE:
|
Source code in mindnlp/peft/config.py
130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 | |
mindnlp.peft.config.PeftConfigMixin
dataclass
¶
This is the base configuration class for PEFT adapter models.
It contains all the methods that are common to all PEFT adapter models.
The method save_pretrained will save the configuration of your adapter model in a directory.
The method from_pretrained will load the configuration of your adapter model from a directory.
| PARAMETER | DESCRIPTION |
|---|---|
peft_type |
The type of Peft method to use.
TYPE:
|
Source code in mindnlp/peft/config.py
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 | |
mindnlp.peft.config.PeftConfigMixin.is_prompt_learning
property
¶
Utility method to check if the configuration is for prompt learning.
mindnlp.peft.config.PeftConfigMixin.from_json_file(path_json_file, **kwargs)
classmethod
¶
Loads a configuration file from a json file.
| PARAMETER | DESCRIPTION |
|---|---|
path_json_file |
The path to the json file.
TYPE:
|
Source code in mindnlp/peft/config.py
107 108 109 110 111 112 113 114 115 116 117 118 119 | |
mindnlp.peft.config.PeftConfigMixin.from_pretrained(pretrained_model_name_or_path, subfolder=None, **kwargs)
classmethod
¶
This method loads the configuration of your adapter model from a directory.
| PARAMETER | DESCRIPTION |
|---|---|
pretrained_model_name_or_path |
The directory or the Hub repository id where the configuration is saved.
TYPE:
|
kwargs |
Additional keyword arguments passed along to the child class initialization.
TYPE:
|
Source code in mindnlp/peft/config.py
75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 | |
mindnlp.peft.config.PeftConfigMixin.save_pretrained(save_directory, **kwargs)
¶
This method saves the configuration of your adapter model in a directory.
| PARAMETER | DESCRIPTION |
|---|---|
save_directory |
The directory where the configuration will be saved.
TYPE:
|
kwargs |
Additional keyword arguments passed along to the
[
TYPE:
|
Source code in mindnlp/peft/config.py
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 | |
mindnlp.peft.config.PeftConfigMixin.to_dict()
¶
to dict
Source code in mindnlp/peft/config.py
42 43 44 | |
mindnlp.peft.config.PromptLearningConfig
dataclass
¶
Bases: PeftConfig
This is the base configuration class to store the configuration of [PrefixTuning], [PromptEncoder], or
[PromptTuning].
| PARAMETER | DESCRIPTION |
|---|---|
num_virtual_tokens |
The number of virtual tokens to use.
TYPE:
|
token_dim |
The hidden embedding dimension of the base transformer model.
TYPE:
|
num_transformer_submodules |
The number of transformer submodules in the base transformer model.
TYPE:
|
num_attention_heads |
The number of attention heads in the base transformer model.
TYPE:
|
num_layers |
The number of layers in the base transformer model.
TYPE:
|
Source code in mindnlp/peft/config.py
148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 | |
mindnlp.peft.config.PromptLearningConfig.is_prompt_learning
property
¶
Utility method to check if the configuration is for prompt learning.