PEFT documentation

LyCORIS

You are viewing main version, which requires installation from source. If you'd like regular pip install, checkout the latest stable version (v0.21.0).
Hugging Face's logo
Join the Hugging Face community

and get access to the augmented documentation experience

to get started

LyCORIS

LyCORIS(Lora beYond Conventional methods, Other Rank adaptation Implementations for Stable diffusion)是类似于 LoRA 的矩阵分解适配器,用于修改 UNet 的交叉注意力层。LoHa 和 LoKr 方法继承自此处的 Lycoris 类。

LycorisConfig

类 peft.tuners.lycoris_utils.LycorisConfig

< >

( task_type: Optional[Union[str, TaskType]] = Nonepeft_type: Optional[Union[str, PeftType]] = Noneauto_mapping: Optional[dict] = Nonepeft_version: Optional[str] = Nonebase_model_name_or_path: Optional[str] = Nonerevision: Optional[str] = Noneinference_mode: bool = Falserank_pattern: Optional[dict] = <factory>alpha_pattern: Optional[dict] = <factory> )

LyCORIS 类似适配器的基础配置

LycorisLayer

类 peft.tuners.lycoris_utils.LycorisLayer

< >

( base_layer: nn.Module )

类似适配器的 LyCORIS 基础层

合并

< >

( safe_merge: bool = Falseadapter_names: Optional[list[str]] = None )

参数

  • safe_merge (bool, 可选) — 如果为 True,合并操作将在原始权重的副本上执行,并在合并权重之前检查是否存在 NaN。如果您想检查合并操作是否会产生 NaN,这将非常有用。默认为 False。
  • adapter_names (List[str], 可选) — 需要合并的适配器名称列表。如果为 None,则合并所有处于活动状态的适配器。 默认值为 None。

将活动适配器的权重合并到基础权重中

unmerge

< >

( )

此方法会从基础权重中取消合并所有已合并的适配器层。

LycorisTuner

类 peft.tuners.lycoris_utils.LycorisTuner

< >

( modelpeft_config: Union[PeftConfig, dict[str, PeftConfig]]adapter_name: strlow_cpu_mem_usage: bool = Falsestate_dict: Optional[dict[str, torch.Tensor]] = None )

参数

  • model (torch.nn.Module) — 要适配的模型。
  • config (LoraConfig) — Lora 模型的配置。
  • adapter_name (str) — 适配器的名称,默认为 "default"。
  • low_cpu_mem_usage (bool, optional, defaults to False) — 在 meta 设备上创建空的适配器权重。有助于加快加载过程。

类似 LyCORIS 适配器的基础调优器

Update on GitHub