import{s as Ae,n as Pe,o as Oe}from"../chunks/scheduler.78382b47.js";import{S as He,i as Re,e as i,s as o,c as M,h as Ue,a as l,d as n,b as r,f as le,g as A,j as d,k as se,l as p,m as a,n as P,t as O,o as H,p as R}from"../chunks/index.6dd35eb6.js";import{C as ze,H as he,E as Ee}from"../chunks/MermaidChart.svelte_svelte_type_style_lang.fed9dfe4.js";import{D as Me}from"../chunks/Docstring.32e826ec.js";function Ie(ue){let f,B,F,j,h,S,u,W,g,ge='<a href="https://huggingface.co/papers/2503.18225" rel="nofollow">DeLoRA</a> is a parameter-efficient fine-tuning technique that implicitly maintains a Frobenius boundary with respect to the pretrained weights by normalizing and scaling learnable low-rank matrices. This effectively decouples the learning of directions (BA term) and magnitude (boundary term) of the weight updates, avoiding catastrophic shifts in the adapted weights and enhancing robustness to hyperparameter choices.',Q,_,_e="Note:",V,b,be="<li>use a learning rate 10-100x larger than for standard LoRA variants (typical values from 1e-3/1e-2/..)</li> <li>ensure the initial boundary parameter lambda is not too small (typical values around 10/15/..). Setting different lambdas to different layers is possible</li>",G,v,ve="DeLoRA currently has the following constraints:",K,x,xe="<li>Only nn.Linear layers are supported.</li> <li>Quantized layers are not supported.</li>",J,y,ye="If these constraints don’t work for your use case, consider other methods instead.",X,w,we="The abstract from the paper is:",Y,D,De="<p>Parameter-Efficient FineTuning (PEFT) methods have recently gained significant popularity thanks to the widespread availability of large-scale pretrained models. These methods allow for quick adaptation to downstream tasks with minimal computational cost. However, popular finetuning methods such as LoRA exhibit limited robustness when it comes to hyperparameter choices or extended training regimes, preventing optimal out-of-the-box performance. In contrast, bounded approaches, such as ETHER, provide greater robustness but are limited to extremely low-rank adaptations and fixed-strength transformations, reducing their adaptation expressive power. In this work, we propose Decoupled Low-rank Adaptation (DeLoRA), a novel finetuning method that normalizes and scales learnable low-rank matrices. By bounding the distance of the transformation, DeLoRA effectively decouples the angular learning from the adaptation strength, enhancing robustness without compromising performance. Through evaluations on subject-driven image generation, natural language understanding, and instruction tuning, we show that DeLoRA matches or surpasses performance of competing PEFT methods, while exhibiting stronger robustness.</p>",Z,T,ee,c,$,de,U,Te='This is the configuration class to store the configuration of a <a href="/docs/peft/main/en/package_reference/delora#peft.DeloraModel">DeloraModel</a>.',te,L,ne,s,C,pe,z,$e="Creates DeLoRA model from a pretrained transformers model.",me,E,Le=`The method is described in detail in <a href="https://huggingface.co/papers/2503.18225" rel="nofollow">DeLoRA: Decoupled Low-rank
Adaptation</a>.`,fe,I,Ce="<strong>Attributes</strong>:",ce,N,ke='<li><strong>model</strong> (<a href="https://huggingface.co/docs/transformers/main/en/main_classes/model#transformers.PreTrainedModel" rel="nofollow">PreTrainedModel</a>) — The model to be adapted.</li> <li><strong>peft_config</strong> (<a href="/docs/peft/main/en/package_reference/delora#peft.DeloraConfig">DeloraConfig</a>): The configuration of the DeLoRA model.</li>',ae,k,oe,q,re;return h=new ze({props:{containerStyle:"float: right; margin-left: 10px; display: inline-flex; position: relative; z-index: 10;"}}),u=new he({props:{title:"DeLoRA: Decoupled Low-rank Adaptation",local:"delora-decoupled-low-rank-adaptation",headingTag:"h1"}}),T=new he({props:{title:"DeloraConfig",local:"peft.DeloraConfig",headingTag:"h2"}}),$=new Me({props:{name:"class peft.DeloraConfig",anchor:"peft.DeloraConfig",parameters:[{name:"task_type",val:": Optional[Union[str, TaskType]] = None"},{name:"peft_type",val:": Optional[Union[str, PeftType]] = None"},{name:"auto_mapping",val:": Optional[dict] = None"},{name:"peft_version",val:": Optional[str] = None"},{name:"base_model_name_or_path",val:": Optional[str] = None"},{name:"revision",val:": Optional[str] = None"},{name:"inference_mode",val:": bool = False"},{name:"r",val:": int = 8"},{name:"delora_lambda",val:": int = 15"},{name:"module_dropout",val:": float = 0.0"},{name:"target_modules",val:": Optional[Union[list[str], str]] = None"},{name:"exclude_modules",val:": Optional[Union[list[str], str]] = None"},{name:"bias",val:": Literal['none', 'all', 'delora_only'] = 'none'"},{name:"init_weights",val:": bool = True"},{name:"layers_to_transform",val:": Optional[Union[list[int], int]] = None"},{name:"layers_pattern",val:": Optional[Union[list[str], str]] = None"},{name:"rank_pattern",val:": Optional[dict] = <factory>"},{name:"lambda_pattern",val:": Optional[dict] = <factory>"},{name:"modules_to_save",val:": Optional[list[str]] = None"}],parametersDescription:[{anchor:"peft.DeloraConfig.r",description:`<strong>r</strong> (<code>int</code>) &#x2014;
The rank of the DeLoRA adapter.`,name:"r"},{anchor:"peft.DeloraConfig.delora_lambda",description:`<strong>delora_lambda</strong> (<code>int</code>) &#x2014;
The initial value of the boundary of the DeLoRA adapter. This variable sets an upper bound to the Frobenius
norm of the weight change, avoiding the finetuned model to deviate too much from the original model.`,name:"delora_lambda"},{anchor:"peft.DeloraConfig.module_dropout",description:`<strong>module_dropout</strong> (<code>float</code>) &#x2014;
The dropout probability for disabling DeLoRA modules during training.`,name:"module_dropout"},{anchor:"peft.DeloraConfig.target_modules",description:`<strong>target_modules</strong> (<code>Optional[Union[List[str], str]]</code>) &#x2014;
The names of the modules to apply the adapter to. If this is specified, only the modules with the specified
names will be replaced. When passing a string, a regex match will be performed. When passing a list of
strings, either an exact match will be performed or it is checked if the name of the module ends with any
of the passed strings. If this is specified as &#x2018;all-linear&#x2019;, then all linear/Conv1D modules are chosen,
excluding the output layer. If this is not specified, modules will be chosen according to the model
architecture. If the architecture is not known, an error will be raised &#x2014; in this case, you should specify
the target modules manually.`,name:"target_modules"},{anchor:"peft.DeloraConfig.exclude_modules",description:`<strong>exclude_modules</strong> (<code>Optional[Union[List[str], str]]</code>) &#x2014;
The names of the modules to not apply the adapter. When passing a string, a regex match will be performed.
When passing a list of strings, either an exact match will be performed or it is checked if the name of the
module ends with any of the passed strings.`,name:"exclude_modules"},{anchor:"peft.DeloraConfig.bias",description:`<strong>bias</strong> (<code>str</code>) &#x2014;
Bias type for DeLoRA. Can be &#x2018;none&#x2019;, &#x2018;all&#x2019; or &#x2018;delora_only&#x2019;. If &#x2018;all&#x2019; or &#x2018;delora_only&#x2019;, the corresponding
biases will be updated during training. Be aware that this means that, even when disabling the adapters,
the model will not produce the same output as the base model would have without adaptation.`,name:"bias"},{anchor:"peft.DeloraConfig.init_weights",description:`<strong>init_weights</strong> (<code>bool</code>) &#x2014;
Whether to perform initialization of adapter weights. If <code>True</code> (default): A is initialized with kaiming
uniform initialization, while B is initialized with zeros. If <code>False</code>: A and B are both initialized with
kaiming uniform, immediately contributing a non-zero delta. This is generally discouraged for normal use.`,name:"init_weights"},{anchor:"peft.DeloraConfig.layers_to_transform",description:`<strong>layers_to_transform</strong> (<code>Union[List[int], int]</code>) &#x2014;
The layer indices to transform. If a list of ints is passed, it will apply the adapter to the layer indices
that are specified in this list. If a single integer is passed, it will apply the transformations on the
layer at this index.`,name:"layers_to_transform"},{anchor:"peft.DeloraConfig.layers_pattern",description:`<strong>layers_pattern</strong> (<code>Optional[Union[List[str], str]]</code>) &#x2014;
The layer pattern name, used only if <code>layers_to_transform</code> is different from <code>None</code>. This should target the
<code>nn.ModuleList</code> of the model, which is often called <code>&apos;layers&apos;</code> or <code>&apos;h&apos;</code>.`,name:"layers_pattern"},{anchor:"peft.DeloraConfig.rank_pattern",description:`<strong>rank_pattern</strong> (<code>dict</code>) &#x2014;
The mapping from layer names or regexp expression to ranks which are different from the default rank
specified by <code>r</code>. For example, <code>{&apos;^model.decoder.layers.0.encoder_attn.k_proj&apos;: 16}</code>.`,name:"rank_pattern"},{anchor:"peft.DeloraConfig.lambda_pattern",description:`<strong>lambda_pattern</strong> (<code>dict</code>) &#x2014;
The mapping from layer names or regexp expression to lambdas which are different from the default lambda
specified by <code>delora_lambda</code>. For example, <code>{&apos;^model.decoder.layers.0.encoder_attn.k_proj&apos;: 16}</code>.`,name:"lambda_pattern"},{anchor:"peft.DeloraConfig.modules_to_save",description:`<strong>modules_to_save</strong> (<code>Optional[List[str]]</code>) &#x2014;
List of modules apart from adapter layers to be set as trainable and saved in the final checkpoint.`,name:"modules_to_save"}],source:"https://github.com/huggingface/peft/blob/main/src/peft/tuners/delora/config.py#L24"}}),L=new he({props:{title:"DeloraModel",local:"peft.DeloraModel",headingTag:"h2"}}),C=new Me({props:{name:"class peft.DeloraModel",anchor:"peft.DeloraModel",parameters:[{name:"model",val:""},{name:"peft_config",val:": Union[PeftConfig, dict[str, PeftConfig]]"},{name:"adapter_name",val:": str"},{name:"low_cpu_mem_usage",val:": bool = False"},{name:"state_dict",val:": Optional[dict[str, torch.Tensor]] = None"}],parametersDescription:[{anchor:"peft.DeloraModel.model",description:"<strong>model</strong> (<code>torch.nn.Module</code>) &#x2014; The model to be adapted.",name:"model"},{anchor:"peft.DeloraModel.config",description:'<strong>config</strong> (<a href="/docs/peft/main/en/package_reference/delora#peft.DeloraConfig">DeloraConfig</a>) &#x2014; The configuration of the DeLoRA model.',name:"config"},{anchor:"peft.DeloraModel.adapter_name",description:"<strong>adapter_name</strong> (<code>str</code>) &#x2014; The name of the adapter, defaults to <code>&quot;default&quot;</code>.",name:"adapter_name"}],source:"https://github.com/huggingface/peft/blob/main/src/peft/tuners/delora/model.py#L28",returnDescription:`<script context="module">export const metadata = 'undefined';<\/script>


<p>The DeLoRA model.</p>
`,returnType:`<script context="module">export const metadata = 'undefined';<\/script>


<p><code>torch.nn.Module</code></p>
`}}),k=new Ee({props:{source:"https://github.com/huggingface/peft/blob/main/docs/source/package_reference/delora.md"}}),{c(){f=i("meta"),B=o(),F=i("p"),j=o(),M(h.$$.fragment),S=o(),M(u.$$.fragment),W=o(),g=i("p"),g.innerHTML=ge,Q=o(),_=i("p"),_.textContent=_e,V=o(),b=i("ul"),b.innerHTML=be,G=o(),v=i("p"),v.textContent=ve,K=o(),x=i("ul"),x.innerHTML=xe,J=o(),y=i("p"),y.textContent=ye,X=o(),w=i("p"),w.textContent=we,Y=o(),D=i("blockquote"),D.innerHTML=De,Z=o(),M(T.$$.fragment),ee=o(),c=i("div"),M($.$$.fragment),de=o(),U=i("p"),U.innerHTML=Te,te=o(),M(L.$$.fragment),ne=o(),s=i("div"),M(C.$$.fragment),pe=o(),z=i("p"),z.textContent=$e,me=o(),E=i("p"),E.innerHTML=Le,fe=o(),I=i("p"),I.innerHTML=Ce,ce=o(),N=i("ul"),N.innerHTML=ke,ae=o(),M(k.$$.fragment),oe=o(),q=i("p"),this.h()},l(e){const t=Ue("svelte-u9bgzb",document.head);f=l(t,"META",{name:!0,content:!0}),t.forEach(n),B=r(e),F=l(e,"P",{}),le(F).forEach(n),j=r(e),A(h.$$.fragment,e),S=r(e),A(u.$$.fragment,e),W=r(e),g=l(e,"P",{"data-svelte-h":!0}),d(g)!=="svelte-rq4tub"&&(g.innerHTML=ge),Q=r(e),_=l(e,"P",{"data-svelte-h":!0}),d(_)!=="svelte-fovr4a"&&(_.textContent=_e),V=r(e),b=l(e,"UL",{"data-svelte-h":!0}),d(b)!=="svelte-4fhcab"&&(b.innerHTML=be),G=r(e),v=l(e,"P",{"data-svelte-h":!0}),d(v)!=="svelte-ty8fmt"&&(v.textContent=ve),K=r(e),x=l(e,"UL",{"data-svelte-h":!0}),d(x)!=="svelte-1gsh2i7"&&(x.innerHTML=xe),J=r(e),y=l(e,"P",{"data-svelte-h":!0}),d(y)!=="svelte-hr8j55"&&(y.textContent=ye),X=r(e),w=l(e,"P",{"data-svelte-h":!0}),d(w)!=="svelte-1cwsb16"&&(w.textContent=we),Y=r(e),D=l(e,"BLOCKQUOTE",{"data-svelte-h":!0}),d(D)!=="svelte-vz5lfp"&&(D.innerHTML=De),Z=r(e),A(T.$$.fragment,e),ee=r(e),c=l(e,"DIV",{class:!0});var ie=le(c);A($.$$.fragment,ie),de=r(ie),U=l(ie,"P",{"data-svelte-h":!0}),d(U)!=="svelte-nfasi6"&&(U.innerHTML=Te),ie.forEach(n),te=r(e),A(L.$$.fragment,e),ne=r(e),s=l(e,"DIV",{class:!0});var m=le(s);A(C.$$.fragment,m),pe=r(m),z=l(m,"P",{"data-svelte-h":!0}),d(z)!=="svelte-h15d97"&&(z.textContent=$e),me=r(m),E=l(m,"P",{"data-svelte-h":!0}),d(E)!=="svelte-1o5zo2t"&&(E.innerHTML=Le),fe=r(m),I=l(m,"P",{"data-svelte-h":!0}),d(I)!=="svelte-1xx6nm4"&&(I.innerHTML=Ce),ce=r(m),N=l(m,"UL",{"data-svelte-h":!0}),d(N)!=="svelte-bbw3q"&&(N.innerHTML=ke),m.forEach(n),ae=r(e),A(k.$$.fragment,e),oe=r(e),q=l(e,"P",{}),le(q).forEach(n),this.h()},h(){se(f,"name","hf:doc:metadata"),se(f,"content",Ne),se(c,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),se(s,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8")},m(e,t){p(document.head,f),a(e,B,t),a(e,F,t),a(e,j,t),P(h,e,t),a(e,S,t),P(u,e,t),a(e,W,t),a(e,g,t),a(e,Q,t),a(e,_,t),a(e,V,t),a(e,b,t),a(e,G,t),a(e,v,t),a(e,K,t),a(e,x,t),a(e,J,t),a(e,y,t),a(e,X,t),a(e,w,t),a(e,Y,t),a(e,D,t),a(e,Z,t),P(T,e,t),a(e,ee,t),a(e,c,t),P($,c,null),p(c,de),p(c,U),a(e,te,t),P(L,e,t),a(e,ne,t),a(e,s,t),P(C,s,null),p(s,pe),p(s,z),p(s,me),p(s,E),p(s,fe),p(s,I),p(s,ce),p(s,N),a(e,ae,t),P(k,e,t),a(e,oe,t),a(e,q,t),re=!0},p:Pe,i(e){re||(O(h.$$.fragment,e),O(u.$$.fragment,e),O(T.$$.fragment,e),O($.$$.fragment,e),O(L.$$.fragment,e),O(C.$$.fragment,e),O(k.$$.fragment,e),re=!0)},o(e){H(h.$$.fragment,e),H(u.$$.fragment,e),H(T.$$.fragment,e),H($.$$.fragment,e),H(L.$$.fragment,e),H(C.$$.fragment,e),H(k.$$.fragment,e),re=!1},d(e){e&&(n(B),n(F),n(j),n(S),n(W),n(g),n(Q),n(_),n(V),n(b),n(G),n(v),n(K),n(x),n(J),n(y),n(X),n(w),n(Y),n(D),n(Z),n(ee),n(c),n(te),n(ne),n(s),n(ae),n(oe),n(q)),n(f),R(h,e),R(u,e),R(T,e),R($),R(L,e),R(C),R(k,e)}}}const Ne='{"title":"DeLoRA: Decoupled Low-rank Adaptation","local":"delora-decoupled-low-rank-adaptation","sections":[{"title":"DeloraConfig","local":"peft.DeloraConfig","sections":[],"depth":2},{"title":"DeloraModel","local":"peft.DeloraModel","sections":[],"depth":2}],"depth":1}';function Fe(ue){return Oe(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class We extends He{constructor(f){super(),Re(this,f,Fe,Ie,Ae,{})}}export{We as component};
