import{s as Q,n as V,o as z}from"../chunks/scheduler.4cd3e004.js";import{S as D,i as O,e as n,s,c as W,h as K,a as d,d as a,b as o,f as N,g as I,j as y,k as q,l as ee,m as l,n as k,t as B,o as F,p as E}from"../chunks/index.b664cb2d.js";import{C as te}from"../chunks/CodeBlock.8601e34e.js";import{H as S,E as ae}from"../chunks/MermaidChart.svelte_svelte_type_style_lang.179b63f8.js";function le(C){let i,w,_,g,p,x,r,G='Normally, it isn’t possible to mix different adapter types in 🤗 PEFT. You can create a PEFT model with two different LoRA adapters (which can have different config options), but it is not possible to combine a LoRA and LoHa adapter. With <a href="/docs/peft/main/en/package_reference/peft_model#peft.PeftMixedModel">PeftMixedModel</a> however, this works as long as the adapter types are compatible. The main purpose of allowing mixed adapter types is to combine trained adapters for inference. While it is possible to train a mixed adapter model, this has not been tested and is not recommended.',J,f,U='To load different adapter types into a PEFT model, use <a href="/docs/peft/main/en/package_reference/peft_model#peft.PeftMixedModel">PeftMixedModel</a> instead of <a href="/docs/peft/main/en/package_reference/peft_model#peft.PeftModel">PeftModel</a>:',$,m,Z,c,Y='The <a href="/docs/peft/main/en/package_reference/peft_model#peft.PeftMixedModel.set_adapter">set_adapter()</a> method is necessary to activate both adapters, otherwise only the first adapter would be active. You can keep adding more adapters by calling <a href="/docs/peft/main/en/package_reference/peft_model#peft.PeftModel.add_adapter">add_adapter()</a> repeatedly.',v,h,A='<a href="/docs/peft/main/en/package_reference/peft_model#peft.PeftMixedModel">PeftMixedModel</a> does not support saving and loading mixed adapters. The adapters should already be trained, and loading the model requires a script to be run each time.',L,u,j,M,X='<li>Not all adapter types can be combined. See <a href="https://github.com/huggingface/peft/blob/1c1c7fdaa6e6abaa53939b865dee1eded82ad032/src/peft/tuners/mixed/model.py#L35" rel="nofollow"><code>peft.tuners.mixed.COMPATIBLE_TUNER_TYPES</code></a> for a list of compatible types. An error will be raised if you try to combine incompatible adapter types.</li> <li>It is possible to mix multiple adapters of the same type which can be useful for combining adapters with very different configs.</li> <li>If you want to combine a lot of different adapters, the most performant way to do it is to consecutively add the same adapter types. For example, add LoRA1, LoRA2, LoHa1, LoHa2 in this order, instead of LoRA1, LoHa1, LoRA2, and LoHa2. While the order can affect the output, there is no inherently <em>best</em> order, so it is best to choose the fastest one.</li>',P,b,R,T,H;return p=new S({props:{title:"Mixed adapter types",local:"mixed-adapter-types",headingTag:"h1"}}),m=new te({props:{code:"ZnJvbSUyMHBlZnQlMjBpbXBvcnQlMjBQZWZ0TWl4ZWRNb2RlbCUwQSUwQWJhc2VfbW9kZWwlMjAlM0QlMjAuLi4lMjAlMjAlMjMlMjBsb2FkJTIwdGhlJTIwYmFzZSUyMG1vZGVsJTJDJTIwZS5nLiUyMGZyb20lMjB0cmFuc2Zvcm1lcnMlMEElMjMlMjBsb2FkJTIwZmlyc3QlMjBhZGFwdGVyJTJDJTIwd2hpY2glMjB3aWxsJTIwYmUlMjBjYWxsZWQlMjAlMjJkZWZhdWx0JTIyJTBBcGVmdF9tb2RlbCUyMCUzRCUyMFBlZnRNaXhlZE1vZGVsLmZyb21fcHJldHJhaW5lZChiYXNlX21vZGVsJTJDJTIwJTNDcGF0aF90b19hZGFwdGVyMSUzRSklMEFwZWZ0X21vZGVsLmxvYWRfYWRhcHRlciglM0NwYXRoX3RvX2FkYXB0ZXIyJTNFJTJDJTIwYWRhcHRlcl9uYW1lJTNEJTIyb3RoZXIlMjIpJTBBcGVmdF9tb2RlbC5zZXRfYWRhcHRlciglNUIlMjJkZWZhdWx0JTIyJTJDJTIwJTIyb3RoZXIlMjIlNUQp",highlighted:`<span class="hljs-keyword">from</span> peft <span class="hljs-keyword">import</span> PeftMixedModel

base_model = ...  <span class="hljs-comment"># load the base model, e.g. from transformers</span>
<span class="hljs-comment"># load first adapter, which will be called &quot;default&quot;</span>
peft_model = PeftMixedModel.from_pretrained(base_model, &lt;path_to_adapter1&gt;)
peft_model.load_adapter(&lt;path_to_adapter2&gt;, adapter_name=<span class="hljs-string">&quot;other&quot;</span>)
peft_model.set_adapter([<span class="hljs-string">&quot;default&quot;</span>, <span class="hljs-string">&quot;other&quot;</span>])`,wrap:!1}}),u=new S({props:{title:"Tips",local:"tips",headingTag:"h2"}}),b=new ae({props:{source:"https://github.com/huggingface/peft/blob/main/docs/source/developer_guides/mixed_models.md"}}),{c(){i=n("meta"),w=s(),_=n("p"),g=s(),W(p.$$.fragment),x=s(),r=n("p"),r.innerHTML=G,J=s(),f=n("p"),f.innerHTML=U,$=s(),W(m.$$.fragment),Z=s(),c=n("p"),c.innerHTML=Y,v=s(),h=n("p"),h.innerHTML=A,L=s(),W(u.$$.fragment),j=s(),M=n("ul"),M.innerHTML=X,P=s(),W(b.$$.fragment),R=s(),T=n("p"),this.h()},l(e){const t=K("svelte-u9bgzb",document.head);i=d(t,"META",{name:!0,content:!0}),t.forEach(a),w=o(e),_=d(e,"P",{}),N(_).forEach(a),g=o(e),I(p.$$.fragment,e),x=o(e),r=d(e,"P",{"data-svelte-h":!0}),y(r)!=="svelte-123yn85"&&(r.innerHTML=G),J=o(e),f=d(e,"P",{"data-svelte-h":!0}),y(f)!=="svelte-prqfoh"&&(f.innerHTML=U),$=o(e),I(m.$$.fragment,e),Z=o(e),c=d(e,"P",{"data-svelte-h":!0}),y(c)!=="svelte-zr8d6f"&&(c.innerHTML=Y),v=o(e),h=d(e,"P",{"data-svelte-h":!0}),y(h)!=="svelte-4gvw5x"&&(h.innerHTML=A),L=o(e),I(u.$$.fragment,e),j=o(e),M=d(e,"UL",{"data-svelte-h":!0}),y(M)!=="svelte-ruw7am"&&(M.innerHTML=X),P=o(e),I(b.$$.fragment,e),R=o(e),T=d(e,"P",{}),N(T).forEach(a),this.h()},h(){q(i,"name","hf:doc:metadata"),q(i,"content",se)},m(e,t){ee(document.head,i),l(e,w,t),l(e,_,t),l(e,g,t),k(p,e,t),l(e,x,t),l(e,r,t),l(e,J,t),l(e,f,t),l(e,$,t),k(m,e,t),l(e,Z,t),l(e,c,t),l(e,v,t),l(e,h,t),l(e,L,t),k(u,e,t),l(e,j,t),l(e,M,t),l(e,P,t),k(b,e,t),l(e,R,t),l(e,T,t),H=!0},p:V,i(e){H||(B(p.$$.fragment,e),B(m.$$.fragment,e),B(u.$$.fragment,e),B(b.$$.fragment,e),H=!0)},o(e){F(p.$$.fragment,e),F(m.$$.fragment,e),F(u.$$.fragment,e),F(b.$$.fragment,e),H=!1},d(e){e&&(a(w),a(_),a(g),a(x),a(r),a(J),a(f),a($),a(Z),a(c),a(v),a(h),a(L),a(j),a(M),a(P),a(R),a(T)),a(i),E(p,e),E(m,e),E(u,e),E(b,e)}}}const se='{"title":"Mixed adapter types","local":"mixed-adapter-types","sections":[{"title":"Tips","local":"tips","sections":[],"depth":2}],"depth":1}';function oe(C){return z(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class re extends D{constructor(i){super(),O(this,i,oe,le,Q,{})}}export{re as component};
