You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This is the configuration class that extends peft.LoraConfig with a few defaults.
47
47
@@ -63,71 +63,92 @@ class LoraConfig(_LoraConfig):
63
63
default=None,
64
64
metadata={
65
65
"help": (
66
-
"List of module names or regex expression of the module names to replace with LoRA."
66
+
"List of module names or regex expression of the module names to replace with LoRA."
67
67
"For example, ['q', 'v'] or '.*decoder.*(SelfAttention|EncDecAttention).*(q|v)$'. "
68
68
"This can also be a wildcard 'all-linear' which matches all linear/Conv1D "
69
69
"(if the model is a PreTrainedModel, the output layer excluded). "
70
-
"If not specified, modules will be chosen according to the model architecture, If the architecture is "
71
-
"not known, an error will be raised -- in this case, you should specify the target modules manually. "
72
-
"To avoid targeting any modules (because you want to apply `target_parameters`), set "
73
-
"`target_modules=[]`."
70
+
"If not specified, modules will be chosen according to the model architecture, "
71
+
"If the architecture is not known, an error will be raised -- "
72
+
"in this case, you should specify the target modules manually. "
73
+
"To avoid targeting any modules (because you want to apply `target_parameters`) "
74
+
", set `target_modules=[]`."
74
75
),
75
76
},
76
77
)
77
-
exclude_modules: List[str]|None=field(
78
+
exclude_modules: Optional[List[str]]=field(
78
79
default=None,
79
80
metadata={
80
-
"help": "List of module names or regex expression of the module names to exclude from Lora."
81
+
"help": (
82
+
"List of module names or regex expression of the module names to exclude from Lora."
83
+
)
81
84
},
82
85
)
83
-
init_lora_weights: (bool)=field(
86
+
init_lora_weights: bool=field(
84
87
default=True,
85
88
metadata={
86
89
"help": (
87
90
"How to initialize the weights of the LoRA layers. "
88
-
"Passing True (default) results in the default initialization from the reference implementation from "
89
-
"Microsoft, with the LoRA B weight being set to 0. This means that without further training, the LoRA "
90
-
"adapter will be a no-op. "
91
-
"Setting the initialization to False leads to random initialization of LoRA A and B, meaning that LoRA "
92
-
"is not a no-op before training; this setting is intended for debugging purposes. "
91
+
"Passing True (default) results in the default initialization from "
92
+
"the reference implementation from "
93
+
"Microsoft, with the LoRA B weight being set to 0. "
94
+
"This means that without further training, "
95
+
"the LoRA adapter will be a no-op. "
96
+
"Setting the initialization to False leads to random initialization of "
97
+
"LoRA A and B, meaning that LoRA is not a no-op before training; "
98
+
"this setting is intended for debugging purposes."
93
99
),
94
100
},
95
101
)
96
102
layers_to_transform: Optional[list[int]] =field(
97
103
default=None,
98
104
metadata={
99
-
"help": "The layer indexes to transform, is this argument is specified, PEFT will transform only the layers indexes that are specified inside this list. If a single integer is passed, PEFT will transform only the layer at this index. "
100
-
"This only works when target_modules is a list of str."
105
+
"help": (
106
+
"The layer indexes to transform, is this argument is specified, "
107
+
"PEFT will transform only the layers indexes that are specified inside this list. "
108
+
"If a single integer is passed, PEFT will transform only the layer at this index. "
109
+
"This only works when target_modules is a list of str."
110
+
)
101
111
},
102
112
)
103
113
layers_pattern: Optional[list[str]] =field(
104
114
default=None,
105
115
metadata={
106
-
"help": "The layer pattern name, used only if `layers_to_transform` is different to None and if the layer pattern is not in the common layers pattern."
107
-
"This only works when target_modules is a list of str. This should target the `nn.ModuleList` of the "
108
-
"model, which is often called `'layers'` or `'h'`."
116
+
"help": (
117
+
"The layer pattern name, used only if `layers_to_transform` is different to None "
118
+
"and if the layer pattern is not in the common layers pattern. "
119
+
"This only works when target_modules is a list of str. "
120
+
"This should target the `nn.ModuleList` of the "
121
+
"model, which is often called `'layers'` or `'h'`."
0 commit comments