Skip to content

Commit 3c79dd9

Browse files
authored
[docs] PEFT adapter API (#6499)
follow up
1 parent 9d76791 commit 3c79dd9

File tree

2 files changed

+13
-15
lines changed

2 files changed

+13
-15
lines changed

docs/source/en/api/loaders/peft.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,14 @@ specific language governing permissions and limitations under the License.
1212

1313
# PEFT
1414

15-
Diffusers supports working with adapters (such as [LoRA](../../using-diffusers/loading_adapters)) via the [`peft` library](https://huggingface.co/docs/peft/index). We provide a `PeftAdapterMixin` class to handle this for modeling classes in Diffusers (such as [`UNet2DConditionModel`]).
15+
Diffusers supports loading adapters such as [LoRA](../../using-diffusers/loading_adapters) with the [PEFT](https://huggingface.co/docs/peft/index) library with the [`~loaders.peft.PeftAdapterMixin`] class. This allows modeling classes in Diffusers like [`UNet2DConditionModel`] to load an adapter.
1616

1717
<Tip>
1818

19-
Refer to [this doc](../../tutorials/using_peft_for_inference.md) to get an overview of how to work with `peft` in Diffusers for inference.
19+
Refer to the [Inference with PEFT](../../tutorials/using_peft_for_inference.md) tutorial for an overview of how to use PEFT in Diffusers for inference.
2020

2121
</Tip>
2222

2323
## PeftAdapterMixin
2424

25-
[[autodoc]] loaders.peft.PeftAdapterMixin
25+
[[autodoc]] loaders.peft.PeftAdapterMixin

src/diffusers/loaders/peft.py

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,13 @@
2020
class PeftAdapterMixin:
2121
"""
2222
A class containing all functions for loading and using adapters weights that are supported in PEFT library. For
23-
more details about adapters and injecting them on a transformer-based model, check out the documentation of PEFT
24-
library: https://huggingface.co/docs/peft/index.
23+
more details about adapters and injecting them in a transformer-based model, check out the PEFT [documentation](https://huggingface.co/docs/peft/index).
2524
26-
27-
With this mixin, if the correct PEFT version is installed, it is possible to:
25+
Install the latest version of PEFT, and use this mixin to:
2826
2927
- Attach new adapters in the model.
30-
- Attach multiple adapters and iteratively activate / deactivate them.
31-
- Activate / deactivate all adapters from the model.
28+
- Attach multiple adapters and iteratively activate/deactivate them.
29+
- Activate/deactivate all adapters from the model.
3230
- Get a list of the active adapters.
3331
"""
3432

@@ -77,11 +75,11 @@ def set_adapter(self, adapter_name: Union[str, List[str]]) -> None:
7775
Sets a specific adapter by forcing the model to only use that adapter and disables the other adapters.
7876
7977
If you are not familiar with adapters and PEFT methods, we invite you to read more about them on the PEFT
80-
official documentation: https://huggingface.co/docs/peft
78+
[documentation](https://huggingface.co/docs/peft).
8179
8280
Args:
8381
adapter_name (Union[str, List[str]])):
84-
The list of adapters to set or the adapter name in case of single adapter.
82+
The list of adapters to set or the adapter name in the case of a single adapter.
8583
"""
8684
check_peft_version(min_version=MIN_PEFT_VERSION)
8785

@@ -126,7 +124,7 @@ def disable_adapters(self) -> None:
126124
Disable all adapters attached to the model and fallback to inference with the base model only.
127125
128126
If you are not familiar with adapters and PEFT methods, we invite you to read more about them on the PEFT
129-
official documentation: https://huggingface.co/docs/peft
127+
[documentation](https://huggingface.co/docs/peft).
130128
"""
131129
check_peft_version(min_version=MIN_PEFT_VERSION)
132130

@@ -145,11 +143,11 @@ def disable_adapters(self) -> None:
145143

146144
def enable_adapters(self) -> None:
147145
"""
148-
Enable adapters that are attached to the model. The model will use `self.active_adapters()` to retrieve the
146+
Enable adapters that are attached to the model. The model uses `self.active_adapters()` to retrieve the
149147
list of adapters to enable.
150148
151149
If you are not familiar with adapters and PEFT methods, we invite you to read more about them on the PEFT
152-
official documentation: https://huggingface.co/docs/peft
150+
[documentation](https://huggingface.co/docs/peft).
153151
"""
154152
check_peft_version(min_version=MIN_PEFT_VERSION)
155153

@@ -171,7 +169,7 @@ def active_adapters(self) -> List[str]:
171169
Gets the current list of active adapters of the model.
172170
173171
If you are not familiar with adapters and PEFT methods, we invite you to read more about them on the PEFT
174-
official documentation: https://huggingface.co/docs/peft
172+
[documentation](https://huggingface.co/docs/peft).
175173
"""
176174
check_peft_version(min_version=MIN_PEFT_VERSION)
177175

0 commit comments

Comments
 (0)