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
138 139 140 141 142 143 144 145 146 147 148 149 150 151 |
|
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 128 129 130 131 132 133 134 135 |
|
mindnlp.peft.config.PeftConfigMixin.__dict__
property
¶
Method 'dict' in the class 'PeftConfigMixin' returns a dictionary representation of the object using the 'asdict' function.
PARAMETER | DESCRIPTION |
---|---|
self |
The instance of the class. This parameter represents the object for which the dictionary representation is generated.
|
RETURNS | DESCRIPTION |
---|---|
None. The method does not return any value explicitly, as the dictionary representation is retrieved internally. |
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
116 117 118 119 120 121 122 123 124 125 126 127 128 |
|
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
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 |
|
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
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 |
|
mindnlp.peft.config.PeftConfigMixin.to_dict()
¶
to dict
Source code in mindnlp/peft/config.py
53 54 55 |
|
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 hidd-en embedding dimension of the base transformer model.
TYPE:
|
num_transformer_submodules |
The number of transformer subcells 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
155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 |
|
mindnlp.peft.config.PromptLearningConfig.is_prompt_learning
property
¶
Utility method to check if the configuration is for prompt learning.