import{S as Wr,i as jr,s as Br,e as o,k as d,w as u,t as n,M as Rr,c as r,d as t,m as f,a as s,x as c,h as i,b as m,N as Ar,G as a,g as p,y as b,q as y,o as w,B as v,v as Pr}from"../chunks/vendor-hf-doc-builder.js";import{T as Cr}from"../chunks/Tip-hf-doc-builder.js";import{I as ie}from"../chunks/IconCopyLink-hf-doc-builder.js";import{C as Z}from"../chunks/CodeBlock-hf-doc-builder.js";import{D as Gr}from"../chunks/DocNotebookDropdown-hf-doc-builder.js";function Vr(Ne){let h,j,M,k,U,_,B,C,F,$,J;return{c(){h=o("p"),j=n("You can load a PEFT adapter with either an "),M=o("code"),k=n("AutoModelFor"),U=n(" class or the base model class like "),_=o("code"),B=n("OPTForCausalLM"),C=n(" or "),F=o("code"),$=n("LlamaForCausalLM"),J=n(".")},l(W){h=r(W,"P",{});var T=s(h);j=i(T,"You can load a PEFT adapter with either an "),M=r(T,"CODE",{});var R=s(M);k=i(R,"AutoModelFor"),R.forEach(t),U=i(T," class or the base model class like "),_=r(T,"CODE",{});var Xe=s(_);B=i(Xe,"OPTForCausalLM"),Xe.forEach(t),C=i(T," or "),F=r(T,"CODE",{});var Qe=s(F);$=i(Qe,"LlamaForCausalLM"),Qe.forEach(t),J=i(T,"."),T.forEach(t)},m(W,T){p(W,h,T),a(h,j),a(h,M),a(M,k),a(h,U),a(h,_),a(_,B),a(h,C),a(h,F),a(F,$),a(h,J)},d(W){W&&t(h)}}}function Ir(Ne){let h,j,M,k,U,_,B,C;return{c(){h=o("p"),j=n("If you aren\u2019t familiar with fine-tuning a model with "),M=o("a"),k=n("Trainer"),U=n(", take a look at the "),_=o("a"),B=n("Fine-tune a pretrained model"),C=n(" tutorial."),this.h()},l(F){h=r(F,"P",{});var $=s(h);j=i($,"If you aren\u2019t familiar with fine-tuning a model with "),M=r($,"A",{href:!0});var J=s(M);k=i(J,"Trainer"),J.forEach(t),U=i($,", take a look at the "),_=r($,"A",{href:!0});var W=s(_);B=i(W,"Fine-tune a pretrained model"),W.forEach(t),C=i($," tutorial."),$.forEach(t),this.h()},h(){m(M,"href","/docs/transformers/main/en/main_classes/trainer#transformers.Trainer"),m(_,"href","training")},m(F,$){p(F,h,$),a(h,j),a(h,M),a(M,k),a(h,U),a(h,_),a(_,B),a(h,C)},d(F){F&&t(h)}}}function Nr(Ne){let h,j,M,k,U,_,B,C,F,$,J,W,T,R,Xe,Qe,Vt,Le,za,It,G,nt,Eo,qa,He,Da,Nt,x,Oa,pe,Ka,el,Xt,V,S,it,de,tl,pt,al,Qt,xe,ll,Lt,fe,Ht,Se,ol,xt,me,St,I,Y,dt,he,rl,ft,sl,Yt,Ye,nl,zt,A,mt,ue,il,pl,ht,ce,dl,fl,ut,be,ml,qt,z,hl,ye,ul,cl,Dt,N,q,ct,we,bl,bt,yl,Ot,P,wl,yt,vl,Ml,wt,_l,El,Kt,D,vt,Tl,$l,ve,kl,ze,gl,Fl,ea,Me,ta,O,aa,K,Jl,Mt,Zl,Ul,la,_e,oa,X,ee,_t,Ee,Cl,Et,Wl,ra,E,jl,Tt,Bl,Rl,$t,Al,Pl,qe,Gl,Vl,kt,Il,Nl,gt,Xl,Ql,De,Ll,Hl,Ft,xl,Sl,sa,Te,na,Q,te,Jt,$e,Yl,Zt,zl,ia,ae,ql,Ut,Dl,Ol,pa,ke,da,Oe,Kl,fa,ge,ma,le,eo,Ct,to,ao,ha,Fe,ua,L,oe,Wt,Je,lo,jt,oo,ca,Ke,ro,ba,Ze,ya,et,so,wa,Ue,va,H,re,Bt,Ce,no,Rt,io,Ma,se,po,tt,fo,mo,_a,ne,Ea,at,We,ho,At,uo,co,Ta,je,$a,Be,Pt,bo,ka,Re,ga,Ae,Pe,yo,lt,wo,vo,Fa,Ge,Ja,ot,Mo,Za,Ve,Ua;return _=new ie({}),J=new Gr({props:{classNames:"absolute z-10 right-0 top-0",options:[{label:"Mixed",value:"https://colab.research.google.com/github/huggingface/notebooks/blob/main/transformers_doc/en/peft.ipynb"},{label:"PyTorch",value:"https://colab.research.google.com/github/huggingface/notebooks/blob/main/transformers_doc/en/pytorch/peft.ipynb"},{label:"TensorFlow",value:"https://colab.research.google.com/github/huggingface/notebooks/blob/main/transformers_doc/en/tensorflow/peft.ipynb"},{label:"Mixed",value:"https://studiolab.sagemaker.aws/import/github/huggingface/notebooks/blob/main/transformers_doc/en/peft.ipynb"},{label:"PyTorch",value:"https://studiolab.sagemaker.aws/import/github/huggingface/notebooks/blob/main/transformers_doc/en/pytorch/peft.ipynb"},{label:"TensorFlow",value:"https://studiolab.sagemaker.aws/import/github/huggingface/notebooks/blob/main/transformers_doc/en/tensorflow/peft.ipynb"}]}}),de=new ie({}),fe=new Z({props:{code:"cGlwJTIwaW5zdGFsbCUyMHBlZnQ=",highlighted:"pip install peft"}}),me=new Z({props:{code:"cGlwJTIwaW5zdGFsbCUyMGdpdCUyQmh0dHBzJTNBJTJGJTJGZ2l0aHViLmNvbSUyRmh1Z2dpbmdmYWNlJTJGcGVmdC5naXQ=",highlighted:"pip install git+https://github.com/huggingface/peft.git"}}),he=new ie({}),we=new ie({}),Me=new Z({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMEF1dG9Nb2RlbEZvckNhdXNhbExNJTJDJTIwQXV0b1Rva2VuaXplciUwQSUwQXBlZnRfbW9kZWxfaWQlMjAlM0QlMjAlMjJ5YmVsa2FkYSUyRm9wdC0zNTBtLWxvcmElMjIlMEFtb2RlbCUyMCUzRCUyMEF1dG9Nb2RlbEZvckNhdXNhbExNLmZyb21fcHJldHJhaW5lZChwZWZ0X21vZGVsX2lkKQ==",highlighted:`<span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoModelForCausalLM, AutoTokenizer

peft_model_id = <span class="hljs-string">&quot;ybelkada/opt-350m-lora&quot;</span>
model = AutoModelForCausalLM.from_pretrained(peft_model_id)`}}),O=new Cr({props:{$$slots:{default:[Vr]},$$scope:{ctx:Ne}}}),_e=new Z({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMEF1dG9Nb2RlbEZvckNhdXNhbExNJTJDJTIwQXV0b1Rva2VuaXplciUwQSUwQW1vZGVsX2lkJTIwJTNEJTIwJTIyZmFjZWJvb2slMkZvcHQtMzUwbSUyMiUwQXBlZnRfbW9kZWxfaWQlMjAlM0QlMjAlMjJ5YmVsa2FkYSUyRm9wdC0zNTBtLWxvcmElMjIlMEElMEFtb2RlbCUyMCUzRCUyMEF1dG9Nb2RlbEZvckNhdXNhbExNLmZyb21fcHJldHJhaW5lZChtb2RlbF9pZCklMEFtb2RlbC5sb2FkX2FkYXB0ZXIocGVmdF9tb2RlbF9pZCk=",highlighted:`<span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoModelForCausalLM, AutoTokenizer

model_id = <span class="hljs-string">&quot;facebook/opt-350m&quot;</span>
peft_model_id = <span class="hljs-string">&quot;ybelkada/opt-350m-lora&quot;</span>

model = AutoModelForCausalLM.from_pretrained(model_id)
model.load_adapter(peft_model_id)`}}),Ee=new ie({}),Te=new Z({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMEF1dG9Nb2RlbEZvckNhdXNhbExNJTJDJTIwQXV0b1Rva2VuaXplciUwQSUwQXBlZnRfbW9kZWxfaWQlMjAlM0QlMjAlMjJ5YmVsa2FkYSUyRm9wdC0zNTBtLWxvcmElMjIlMEFtb2RlbCUyMCUzRCUyMEF1dG9Nb2RlbEZvckNhdXNhbExNLmZyb21fcHJldHJhaW5lZChwZWZ0X21vZGVsX2lkJTJDJTIwZGV2aWNlX21hcCUzRCUyMmF1dG8lMjIlMkMlMjBsb2FkX2luXzhiaXQlM0RUcnVlKQ==",highlighted:`<span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoModelForCausalLM, AutoTokenizer

peft_model_id = <span class="hljs-string">&quot;ybelkada/opt-350m-lora&quot;</span>
model = AutoModelForCausalLM.from_pretrained(peft_model_id, device_map=<span class="hljs-string">&quot;auto&quot;</span>, load_in_8bit=<span class="hljs-literal">True</span>)`}}),$e=new ie({}),ke=new Z({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMEF1dG9Nb2RlbEZvckNhdXNhbExNJTJDJTIwT1BURm9yQ2F1c2FsTE0lMkMlMjBBdXRvVG9rZW5pemVyJTBBZnJvbSUyMHBlZnQlMjBpbXBvcnQlMjBQZWZ0Q29uZmlnJTBBJTBBbW9kZWxfaWQlMjAlM0QlMjAlMjJmYWNlYm9vayUyRm9wdC0zNTBtJTIyJTBBbW9kZWwlMjAlM0QlMjBBdXRvTW9kZWxGb3JDYXVzYWxMTS5mcm9tX3ByZXRyYWluZWQobW9kZWxfaWQpJTBBJTBBbG9yYV9jb25maWclMjAlM0QlMjBMb3JhQ29uZmlnKCUwQSUyMCUyMCUyMCUyMHRhcmdldF9tb2R1bGVzJTNEJTVCJTIycV9wcm9qJTIyJTJDJTIwJTIya19wcm9qJTIyJTVEJTJDJTBBJTIwJTIwJTIwJTIwaW5pdF9sb3JhX3dlaWdodHMlM0RGYWxzZSUwQSklMEElMEFtb2RlbC5hZGRfYWRhcHRlcihsb3JhX2NvbmZpZyUyQyUyMGFkYXB0ZXJfbmFtZSUzRCUyMmFkYXB0ZXJfMSUyMik=",highlighted:`<span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoModelForCausalLM, OPTForCausalLM, AutoTokenizer
<span class="hljs-keyword">from</span> peft <span class="hljs-keyword">import</span> PeftConfig

model_id = <span class="hljs-string">&quot;facebook/opt-350m&quot;</span>
model = AutoModelForCausalLM.from_pretrained(model_id)

lora_config = LoraConfig(
    target_modules=[<span class="hljs-string">&quot;q_proj&quot;</span>, <span class="hljs-string">&quot;k_proj&quot;</span>],
    init_lora_weights=<span class="hljs-literal">False</span>
)

model.add_adapter(lora_config, adapter_name=<span class="hljs-string">&quot;adapter_1&quot;</span>)`}}),ge=new Z({props:{code:"JTIzJTIwYXR0YWNoJTIwbmV3JTIwYWRhcHRlciUyMHdpdGglMjBzYW1lJTIwY29uZmlnJTBBbW9kZWwuYWRkX2FkYXB0ZXIobG9yYV9jb25maWclMkMlMjBhZGFwdGVyX25hbWUlM0QlMjJhZGFwdGVyXzIlMjIp",highlighted:`<span class="hljs-comment"># attach new adapter with same config</span>
model.add_adapter(lora_config, adapter_name=<span class="hljs-string">&quot;adapter_2&quot;</span>)`}}),Fe=new Z({props:{code:"JTIzJTIwdXNlJTIwYWRhcHRlcl8xJTBBbW9kZWwuc2V0X2FkYXB0ZXIoJTIyYWRhcHRlcl8xJTIyKSUwQW91dHB1dCUyMCUzRCUyMG1vZGVsLmdlbmVyYXRlKCoqaW5wdXRzKSUwQXByaW50KHRva2VuaXplci5kZWNvZGUob3V0cHV0X2Rpc2FibGVkJTVCMCU1RCUyQyUyMHNraXBfc3BlY2lhbF90b2tlbnMlM0RUcnVlKSklMEElMEElMjMlMjB1c2UlMjBhZGFwdGVyXzIlMEFtb2RlbC5zZXRfYWRhcHRlciglMjJhZGFwdGVyXzIlMjIpJTBBb3V0cHV0X2VuYWJsZWQlMjAlM0QlMjBtb2RlbC5nZW5lcmF0ZSgqKmlucHV0cyklMEFwcmludCh0b2tlbml6ZXIuZGVjb2RlKG91dHB1dF9lbmFibGVkJTVCMCU1RCUyQyUyMHNraXBfc3BlY2lhbF90b2tlbnMlM0RUcnVlKSk=",highlighted:`<span class="hljs-comment"># use adapter_1</span>
model.set_adapter(<span class="hljs-string">&quot;adapter_1&quot;</span>)
output = model.generate(**inputs)
<span class="hljs-built_in">print</span>(tokenizer.decode(output_disabled[<span class="hljs-number">0</span>], skip_special_tokens=<span class="hljs-literal">True</span>))

<span class="hljs-comment"># use adapter_2</span>
model.set_adapter(<span class="hljs-string">&quot;adapter_2&quot;</span>)
output_enabled = model.generate(**inputs)
<span class="hljs-built_in">print</span>(tokenizer.decode(output_enabled[<span class="hljs-number">0</span>], skip_special_tokens=<span class="hljs-literal">True</span>))`}}),Je=new ie({}),Ze=new Z({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMEF1dG9Nb2RlbEZvckNhdXNhbExNJTJDJTIwT1BURm9yQ2F1c2FsTE0lMkMlMjBBdXRvVG9rZW5pemVyJTBBZnJvbSUyMHBlZnQlMjBpbXBvcnQlMjBQZWZ0Q29uZmlnJTBBJTBBbW9kZWxfaWQlMjAlM0QlMjAlMjJmYWNlYm9vayUyRm9wdC0zNTBtJTIyJTBBYWRhcHRlcl9tb2RlbF9pZCUyMCUzRCUyMCUyMnliZWxrYWRhJTJGb3B0LTM1MG0tbG9yYSUyMiUwQXRva2VuaXplciUyMCUzRCUyMEF1dG9Ub2tlbml6ZXIuZnJvbV9wcmV0cmFpbmVkKG1vZGVsX2lkKSUwQXRleHQlMjAlM0QlMjAlMjJIZWxsbyUyMiUwQWlucHV0cyUyMCUzRCUyMHRva2VuaXplcih0ZXh0JTJDJTIwcmV0dXJuX3RlbnNvcnMlM0QlMjJwdCUyMiklMEElMEFtb2RlbCUyMCUzRCUyMEF1dG9Nb2RlbEZvckNhdXNhbExNLmZyb21fcHJldHJhaW5lZChtb2RlbF9pZCklMEFwZWZ0X2NvbmZpZyUyMCUzRCUyMFBlZnRDb25maWcuZnJvbV9wcmV0cmFpbmVkKGFkYXB0ZXJfbW9kZWxfaWQpJTBBJTBBJTIzJTIwdG8lMjBpbml0aWF0ZSUyMHdpdGglMjByYW5kb20lMjB3ZWlnaHRzJTBBcGVmdF9jb25maWcuaW5pdF9sb3JhX3dlaWdodHMlMjAlM0QlMjBGYWxzZSUwQSUwQW1vZGVsLmFkZF9hZGFwdGVyKHBlZnRfY29uZmlnKSUwQW1vZGVsLmVuYWJsZV9hZGFwdGVycygpJTBBb3V0cHV0JTIwJTNEJTIwbW9kZWwuZ2VuZXJhdGUoKippbnB1dHMp",highlighted:`<span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoModelForCausalLM, OPTForCausalLM, AutoTokenizer
<span class="hljs-keyword">from</span> peft <span class="hljs-keyword">import</span> PeftConfig

model_id = <span class="hljs-string">&quot;facebook/opt-350m&quot;</span>
adapter_model_id = <span class="hljs-string">&quot;ybelkada/opt-350m-lora&quot;</span>
tokenizer = AutoTokenizer.from_pretrained(model_id)
text = <span class="hljs-string">&quot;Hello&quot;</span>
inputs = tokenizer(text, return_tensors=<span class="hljs-string">&quot;pt&quot;</span>)

model = AutoModelForCausalLM.from_pretrained(model_id)
peft_config = PeftConfig.from_pretrained(adapter_model_id)

<span class="hljs-comment"># to initiate with random weights</span>
peft_config.init_lora_weights = <span class="hljs-literal">False</span>

model.add_adapter(peft_config)
model.enable_adapters()
output = model.generate(**inputs)`}}),Ue=new Z({props:{code:"bW9kZWwuZGlzYWJsZV9hZGFwdGVycygpJTBBb3V0cHV0JTIwJTNEJTIwbW9kZWwuZ2VuZXJhdGUoKippbnB1dHMp",highlighted:`model.disable_adapters()
output = model.generate(**inputs)`}}),Ce=new ie({}),ne=new Cr({props:{$$slots:{default:[Ir]},$$scope:{ctx:Ne}}}),je=new Z({props:{code:"ZnJvbSUyMHBlZnQlMjBpbXBvcnQlMjBMb3JhQ29uZmlnJTBBJTBBcGVmdF9jb25maWclMjAlM0QlMjBMb3JhQ29uZmlnKCUwQSUyMCUyMCUyMCUyMGxvcmFfYWxwaGElM0QxNiUyQyUwQSUyMCUyMCUyMCUyMGxvcmFfZHJvcG91dCUzRDAuMSUyQyUwQSUyMCUyMCUyMCUyMHIlM0Q2NCUyQyUwQSUyMCUyMCUyMCUyMGJpYXMlM0QlMjJub25lJTIyJTJDJTBBJTIwJTIwJTIwJTIwdGFza190eXBlJTNEJTIyQ0FVU0FMX0xNJTIyJTJDJTBBKQ==",highlighted:`<span class="hljs-keyword">from</span> peft <span class="hljs-keyword">import</span> LoraConfig

peft_config = LoraConfig(
    lora_alpha=<span class="hljs-number">16</span>,
    lora_dropout=<span class="hljs-number">0.1</span>,
    r=<span class="hljs-number">64</span>,
    bias=<span class="hljs-string">&quot;none&quot;</span>,
    task_type=<span class="hljs-string">&quot;CAUSAL_LM&quot;</span>,
)`}}),Re=new Z({props:{code:"bW9kZWwuYWRkX2FkYXB0ZXIocGVmdF9jb25maWcp",highlighted:"model.add_adapter(peft_config)"}}),Ge=new Z({props:{code:"dHJhaW5lciUyMCUzRCUyMFRyYWluZXIobW9kZWwlM0Rtb2RlbCUyQyUyMC4uLiklMEF0cmFpbmVyLnRyYWluKCk=",highlighted:`trainer = Trainer(model=model, ...)
trainer.train()`}}),Ve=new Z({props:{code:"bW9kZWwuc2F2ZV9wcmV0cmFpbmVkKHNhdmVfZGlyKSUwQW1vZGVsJTIwJTNEJTIwQXV0b01vZGVsRm9yQ2F1c2FsTE0uZnJvbV9wcmV0cmFpbmVkKHNhdmVfZGlyKQ==",highlighted:`model.save_pretrained(save_dir)
model = AutoModelForCausalLM.from_pretrained(save_dir)`}}),{c(){h=o("meta"),j=d(),M=o("h1"),k=o("a"),U=o("span"),u(_.$$.fragment),B=d(),C=o("span"),F=n("Load adapters with \u{1F917} PEFT"),$=d(),u(J.$$.fragment),W=d(),T=o("p"),R=o("a"),Xe=n("Parameter-Efficient Fine Tuning (PEFT)"),Qe=n(" methods freeze the pretrained model parameters during fine-tuning and add a small number of trainable parameters (the adapters) on top of it. The adapters are trained to learn task-specific information. This approach has been shown to be very memory-efficient with lower compute usage while producing results comparable to a fully fine-tuned model."),Vt=d(),Le=o("p"),za=n("Adapters trained with PEFT are also usually an order of magnitude smaller than the full model, making it convenient to share, store, and load them."),It=d(),G=o("div"),nt=o("img"),qa=d(),He=o("figcaption"),Da=n("The adapter weights for a OPTForCausalLM model stored on the Hub are only ~6MB compared to the full size of the model weights, which can be ~700MB."),Nt=d(),x=o("p"),Oa=n("If you\u2019re interested in learning more about the \u{1F917} PEFT library, check out the "),pe=o("a"),Ka=n("documentation"),el=n("."),Xt=d(),V=o("h2"),S=o("a"),it=o("span"),u(de.$$.fragment),tl=d(),pt=o("span"),al=n("Setup"),Qt=d(),xe=o("p"),ll=n("Get started by installing \u{1F917} PEFT:"),Lt=d(),u(fe.$$.fragment),Ht=d(),Se=o("p"),ol=n("If you want to try out the brand new features, you might be interested in installing the library from source:"),xt=d(),u(me.$$.fragment),St=d(),I=o("h2"),Y=o("a"),dt=o("span"),u(he.$$.fragment),rl=d(),ft=o("span"),sl=n("Supported PEFT models"),Yt=d(),Ye=o("p"),nl=n("\u{1F917} Transformers natively supports some PEFT methods, meaning you can load adapter weights stored locally or on the Hub and easily run or train them with a few lines of code. The following methods are supported:"),zt=d(),A=o("ul"),mt=o("li"),ue=o("a"),il=n("Low Rank Adapters"),pl=d(),ht=o("li"),ce=o("a"),dl=n("IA3"),fl=d(),ut=o("li"),be=o("a"),ml=n("AdaLoRA"),qt=d(),z=o("p"),hl=n("If you want to use other PEFT methods, such as prompt learning or prompt tuning, or about the \u{1F917} PEFT library in general, please refer to the "),ye=o("a"),ul=n("documentation"),cl=n("."),Dt=d(),N=o("h2"),q=o("a"),ct=o("span"),u(we.$$.fragment),bl=d(),bt=o("span"),yl=n("Load a PEFT adapter"),Ot=d(),P=o("p"),wl=n("To load and use a PEFT adapter model from \u{1F917} Transformers, make sure the Hub repository or local directory contains an "),yt=o("code"),vl=n("adapter_config.json"),Ml=n(" file and the adapter weights, as shown in the example image above. Then you can load the PEFT adapter model using the "),wt=o("code"),_l=n("AutoModelFor"),El=n(" class. For example, to load a PEFT adapter model for causal language modeling:"),Kt=d(),D=o("ol"),vt=o("li"),Tl=n("specify the PEFT model id"),$l=d(),ve=o("li"),kl=n("pass it to the "),ze=o("a"),gl=n("AutoModelForCausalLM"),Fl=n(" class"),ea=d(),u(Me.$$.fragment),ta=d(),u(O.$$.fragment),aa=d(),K=o("p"),Jl=n("You can also load a PEFT adapter by calling the "),Mt=o("code"),Zl=n("load_adapter"),Ul=n(" method:"),la=d(),u(_e.$$.fragment),oa=d(),X=o("h2"),ee=o("a"),_t=o("span"),u(Ee.$$.fragment),Cl=d(),Et=o("span"),Wl=n("Load in 8bit or 4bit"),ra=d(),E=o("p"),jl=n("The "),Tt=o("code"),Bl=n("bitsandbytes"),Rl=n(" integration supports 8bit and 4bit precision data types, which are useful for loading large models because it saves memory (see the "),$t=o("code"),Al=n("bitsandbytes"),Pl=n(" integration "),qe=o("a"),Gl=n("guide"),Vl=n(" to learn more). Add the "),kt=o("code"),Il=n("load_in_8bit"),Nl=n(" or "),gt=o("code"),Xl=n("load_in_4bit"),Ql=n(" parameters to "),De=o("a"),Ll=n("from_pretrained()"),Hl=n(" and set "),Ft=o("code"),xl=n('device_map="auto"'),Sl=n(" to effectively distribute the model to your hardware:"),sa=d(),u(Te.$$.fragment),na=d(),Q=o("h2"),te=o("a"),Jt=o("span"),u($e.$$.fragment),Yl=d(),Zt=o("span"),zl=n("Add a new adapter"),ia=d(),ae=o("p"),ql=n("You can use "),Ut=o("code"),Dl=n("~peft.PeftModel.add_adapter"),Ol=n(" to add a new adapter to a model with an existing adapter as long as the new adapter is the same type as the current one. For example, if you have an existing LoRA adapter attached to a model:"),pa=d(),u(ke.$$.fragment),da=d(),Oe=o("p"),Kl=n("To add a new adapter:"),fa=d(),u(ge.$$.fragment),ma=d(),le=o("p"),eo=n("Now you can use "),Ct=o("code"),to=n("~peft.PeftModel.set_adapter"),ao=n(" to set which adapter to use:"),ha=d(),u(Fe.$$.fragment),ua=d(),L=o("h2"),oe=o("a"),Wt=o("span"),u(Je.$$.fragment),lo=d(),jt=o("span"),oo=n("Enable and disable adapters"),ca=d(),Ke=o("p"),ro=n("Once you\u2019ve added an adapter to a model, you can enable or disable the adapter module. To enable the adapter module:"),ba=d(),u(Ze.$$.fragment),ya=d(),et=o("p"),so=n("To disable the adapter module:"),wa=d(),u(Ue.$$.fragment),va=d(),H=o("h2"),re=o("a"),Bt=o("span"),u(Ce.$$.fragment),no=d(),Rt=o("span"),io=n("Train a PEFT adapter"),Ma=d(),se=o("p"),po=n("PEFT adapters are supported by the "),tt=o("a"),fo=n("Trainer"),mo=n(" class so that you can train an adapter for your specific use case. It only requires adding a few more lines of code. For example, to train a LoRA adapter:"),_a=d(),u(ne.$$.fragment),Ea=d(),at=o("ol"),We=o("li"),ho=n("Define your adapter configuration with the task type and hyperparameters (see "),At=o("code"),uo=n("~peft.LoraConfig"),co=n(" for more details about what the hyperparameters do)."),Ta=d(),u(je.$$.fragment),$a=d(),Be=o("ol"),Pt=o("li"),bo=n("Add adapter to the model."),ka=d(),u(Re.$$.fragment),ga=d(),Ae=o("ol"),Pe=o("li"),yo=n("Now you can pass the model to "),lt=o("a"),wo=n("Trainer"),vo=n("!"),Fa=d(),u(Ge.$$.fragment),Ja=d(),ot=o("p"),Mo=n("To save your trained adapter and load it back:"),Za=d(),u(Ve.$$.fragment),this.h()},l(e){const l=Rr('[data-svelte="svelte-1phssyn"]',document.head);h=r(l,"META",{name:!0,content:!0}),l.forEach(t),j=f(e),M=r(e,"H1",{class:!0});var Ie=s(M);k=r(Ie,"A",{id:!0,class:!0,href:!0});var Gt=s(k);U=r(Gt,"SPAN",{});var To=s(U);c(_.$$.fragment,To),To.forEach(t),Gt.forEach(t),B=f(Ie),C=r(Ie,"SPAN",{});var $o=s(C);F=i($o,"Load adapters with \u{1F917} PEFT"),$o.forEach(t),Ie.forEach(t),$=f(e),c(J.$$.fragment,e),W=f(e),T=r(e,"P",{});var _o=s(T);R=r(_o,"A",{href:!0,rel:!0});var ko=s(R);Xe=i(ko,"Parameter-Efficient Fine Tuning (PEFT)"),ko.forEach(t),Qe=i(_o," methods freeze the pretrained model parameters during fine-tuning and add a small number of trainable parameters (the adapters) on top of it. The adapters are trained to learn task-specific information. This approach has been shown to be very memory-efficient with lower compute usage while producing results comparable to a fully fine-tuned model."),_o.forEach(t),Vt=f(e),Le=r(e,"P",{});var go=s(Le);za=i(go,"Adapters trained with PEFT are also usually an order of magnitude smaller than the full model, making it convenient to share, store, and load them."),go.forEach(t),It=f(e),G=r(e,"DIV",{class:!0});var Ca=s(G);nt=r(Ca,"IMG",{src:!0}),qa=f(Ca),He=r(Ca,"FIGCAPTION",{class:!0});var Fo=s(He);Da=i(Fo,"The adapter weights for a OPTForCausalLM model stored on the Hub are only ~6MB compared to the full size of the model weights, which can be ~700MB."),Fo.forEach(t),Ca.forEach(t),Nt=f(e),x=r(e,"P",{});var Wa=s(x);Oa=i(Wa,"If you\u2019re interested in learning more about the \u{1F917} PEFT library, check out the "),pe=r(Wa,"A",{href:!0,rel:!0});var Jo=s(pe);Ka=i(Jo,"documentation"),Jo.forEach(t),el=i(Wa,"."),Wa.forEach(t),Xt=f(e),V=r(e,"H2",{class:!0});var ja=s(V);S=r(ja,"A",{id:!0,class:!0,href:!0});var Zo=s(S);it=r(Zo,"SPAN",{});var Uo=s(it);c(de.$$.fragment,Uo),Uo.forEach(t),Zo.forEach(t),tl=f(ja),pt=r(ja,"SPAN",{});var Co=s(pt);al=i(Co,"Setup"),Co.forEach(t),ja.forEach(t),Qt=f(e),xe=r(e,"P",{});var Wo=s(xe);ll=i(Wo,"Get started by installing \u{1F917} PEFT:"),Wo.forEach(t),Lt=f(e),c(fe.$$.fragment,e),Ht=f(e),Se=r(e,"P",{});var jo=s(Se);ol=i(jo,"If you want to try out the brand new features, you might be interested in installing the library from source:"),jo.forEach(t),xt=f(e),c(me.$$.fragment,e),St=f(e),I=r(e,"H2",{class:!0});var Ba=s(I);Y=r(Ba,"A",{id:!0,class:!0,href:!0});var Bo=s(Y);dt=r(Bo,"SPAN",{});var Ro=s(dt);c(he.$$.fragment,Ro),Ro.forEach(t),Bo.forEach(t),rl=f(Ba),ft=r(Ba,"SPAN",{});var Ao=s(ft);sl=i(Ao,"Supported PEFT models"),Ao.forEach(t),Ba.forEach(t),Yt=f(e),Ye=r(e,"P",{});var Po=s(Ye);nl=i(Po,"\u{1F917} Transformers natively supports some PEFT methods, meaning you can load adapter weights stored locally or on the Hub and easily run or train them with a few lines of code. The following methods are supported:"),Po.forEach(t),zt=f(e),A=r(e,"UL",{});var rt=s(A);mt=r(rt,"LI",{});var Go=s(mt);ue=r(Go,"A",{href:!0,rel:!0});var Vo=s(ue);il=i(Vo,"Low Rank Adapters"),Vo.forEach(t),Go.forEach(t),pl=f(rt),ht=r(rt,"LI",{});var Io=s(ht);ce=r(Io,"A",{href:!0,rel:!0});var No=s(ce);dl=i(No,"IA3"),No.forEach(t),Io.forEach(t),fl=f(rt),ut=r(rt,"LI",{});var Xo=s(ut);be=r(Xo,"A",{href:!0,rel:!0});var Qo=s(be);ml=i(Qo,"AdaLoRA"),Qo.forEach(t),Xo.forEach(t),rt.forEach(t),qt=f(e),z=r(e,"P",{});var Ra=s(z);hl=i(Ra,"If you want to use other PEFT methods, such as prompt learning or prompt tuning, or about the \u{1F917} PEFT library in general, please refer to the "),ye=r(Ra,"A",{href:!0,rel:!0});var Lo=s(ye);ul=i(Lo,"documentation"),Lo.forEach(t),cl=i(Ra,"."),Ra.forEach(t),Dt=f(e),N=r(e,"H2",{class:!0});var Aa=s(N);q=r(Aa,"A",{id:!0,class:!0,href:!0});var Ho=s(q);ct=r(Ho,"SPAN",{});var xo=s(ct);c(we.$$.fragment,xo),xo.forEach(t),Ho.forEach(t),bl=f(Aa),bt=r(Aa,"SPAN",{});var So=s(bt);yl=i(So,"Load a PEFT adapter"),So.forEach(t),Aa.forEach(t),Ot=f(e),P=r(e,"P",{});var st=s(P);wl=i(st,"To load and use a PEFT adapter model from \u{1F917} Transformers, make sure the Hub repository or local directory contains an "),yt=r(st,"CODE",{});var Yo=s(yt);vl=i(Yo,"adapter_config.json"),Yo.forEach(t),Ml=i(st," file and the adapter weights, as shown in the example image above. Then you can load the PEFT adapter model using the "),wt=r(st,"CODE",{});var zo=s(wt);_l=i(zo,"AutoModelFor"),zo.forEach(t),El=i(st," class. For example, to load a PEFT adapter model for causal language modeling:"),st.forEach(t),Kt=f(e),D=r(e,"OL",{});var Pa=s(D);vt=r(Pa,"LI",{});var qo=s(vt);Tl=i(qo,"specify the PEFT model id"),qo.forEach(t),$l=f(Pa),ve=r(Pa,"LI",{});var Ga=s(ve);kl=i(Ga,"pass it to the "),ze=r(Ga,"A",{href:!0});var Do=s(ze);gl=i(Do,"AutoModelForCausalLM"),Do.forEach(t),Fl=i(Ga," class"),Ga.forEach(t),Pa.forEach(t),ea=f(e),c(Me.$$.fragment,e),ta=f(e),c(O.$$.fragment,e),aa=f(e),K=r(e,"P",{});var Va=s(K);Jl=i(Va,"You can also load a PEFT adapter by calling the "),Mt=r(Va,"CODE",{});var Oo=s(Mt);Zl=i(Oo,"load_adapter"),Oo.forEach(t),Ul=i(Va," method:"),Va.forEach(t),la=f(e),c(_e.$$.fragment,e),oa=f(e),X=r(e,"H2",{class:!0});var Ia=s(X);ee=r(Ia,"A",{id:!0,class:!0,href:!0});var Ko=s(ee);_t=r(Ko,"SPAN",{});var er=s(_t);c(Ee.$$.fragment,er),er.forEach(t),Ko.forEach(t),Cl=f(Ia),Et=r(Ia,"SPAN",{});var tr=s(Et);Wl=i(tr,"Load in 8bit or 4bit"),tr.forEach(t),Ia.forEach(t),ra=f(e),E=r(e,"P",{});var g=s(E);jl=i(g,"The "),Tt=r(g,"CODE",{});var ar=s(Tt);Bl=i(ar,"bitsandbytes"),ar.forEach(t),Rl=i(g," integration supports 8bit and 4bit precision data types, which are useful for loading large models because it saves memory (see the "),$t=r(g,"CODE",{});var lr=s($t);Al=i(lr,"bitsandbytes"),lr.forEach(t),Pl=i(g," integration "),qe=r(g,"A",{href:!0});var or=s(qe);Gl=i(or,"guide"),or.forEach(t),Vl=i(g," to learn more). Add the "),kt=r(g,"CODE",{});var rr=s(kt);Il=i(rr,"load_in_8bit"),rr.forEach(t),Nl=i(g," or "),gt=r(g,"CODE",{});var sr=s(gt);Xl=i(sr,"load_in_4bit"),sr.forEach(t),Ql=i(g," parameters to "),De=r(g,"A",{href:!0});var nr=s(De);Ll=i(nr,"from_pretrained()"),nr.forEach(t),Hl=i(g," and set "),Ft=r(g,"CODE",{});var ir=s(Ft);xl=i(ir,'device_map="auto"'),ir.forEach(t),Sl=i(g," to effectively distribute the model to your hardware:"),g.forEach(t),sa=f(e),c(Te.$$.fragment,e),na=f(e),Q=r(e,"H2",{class:!0});var Na=s(Q);te=r(Na,"A",{id:!0,class:!0,href:!0});var pr=s(te);Jt=r(pr,"SPAN",{});var dr=s(Jt);c($e.$$.fragment,dr),dr.forEach(t),pr.forEach(t),Yl=f(Na),Zt=r(Na,"SPAN",{});var fr=s(Zt);zl=i(fr,"Add a new adapter"),fr.forEach(t),Na.forEach(t),ia=f(e),ae=r(e,"P",{});var Xa=s(ae);ql=i(Xa,"You can use "),Ut=r(Xa,"CODE",{});var mr=s(Ut);Dl=i(mr,"~peft.PeftModel.add_adapter"),mr.forEach(t),Ol=i(Xa," to add a new adapter to a model with an existing adapter as long as the new adapter is the same type as the current one. For example, if you have an existing LoRA adapter attached to a model:"),Xa.forEach(t),pa=f(e),c(ke.$$.fragment,e),da=f(e),Oe=r(e,"P",{});var hr=s(Oe);Kl=i(hr,"To add a new adapter:"),hr.forEach(t),fa=f(e),c(ge.$$.fragment,e),ma=f(e),le=r(e,"P",{});var Qa=s(le);eo=i(Qa,"Now you can use "),Ct=r(Qa,"CODE",{});var ur=s(Ct);to=i(ur,"~peft.PeftModel.set_adapter"),ur.forEach(t),ao=i(Qa," to set which adapter to use:"),Qa.forEach(t),ha=f(e),c(Fe.$$.fragment,e),ua=f(e),L=r(e,"H2",{class:!0});var La=s(L);oe=r(La,"A",{id:!0,class:!0,href:!0});var cr=s(oe);Wt=r(cr,"SPAN",{});var br=s(Wt);c(Je.$$.fragment,br),br.forEach(t),cr.forEach(t),lo=f(La),jt=r(La,"SPAN",{});var yr=s(jt);oo=i(yr,"Enable and disable adapters"),yr.forEach(t),La.forEach(t),ca=f(e),Ke=r(e,"P",{});var wr=s(Ke);ro=i(wr,"Once you\u2019ve added an adapter to a model, you can enable or disable the adapter module. To enable the adapter module:"),wr.forEach(t),ba=f(e),c(Ze.$$.fragment,e),ya=f(e),et=r(e,"P",{});var vr=s(et);so=i(vr,"To disable the adapter module:"),vr.forEach(t),wa=f(e),c(Ue.$$.fragment,e),va=f(e),H=r(e,"H2",{class:!0});var Ha=s(H);re=r(Ha,"A",{id:!0,class:!0,href:!0});var Mr=s(re);Bt=r(Mr,"SPAN",{});var _r=s(Bt);c(Ce.$$.fragment,_r),_r.forEach(t),Mr.forEach(t),no=f(Ha),Rt=r(Ha,"SPAN",{});var Er=s(Rt);io=i(Er,"Train a PEFT adapter"),Er.forEach(t),Ha.forEach(t),Ma=f(e),se=r(e,"P",{});var xa=s(se);po=i(xa,"PEFT adapters are supported by the "),tt=r(xa,"A",{href:!0});var Tr=s(tt);fo=i(Tr,"Trainer"),Tr.forEach(t),mo=i(xa," class so that you can train an adapter for your specific use case. It only requires adding a few more lines of code. For example, to train a LoRA adapter:"),xa.forEach(t),_a=f(e),c(ne.$$.fragment,e),Ea=f(e),at=r(e,"OL",{});var $r=s(at);We=r($r,"LI",{});var Sa=s(We);ho=i(Sa,"Define your adapter configuration with the task type and hyperparameters (see "),At=r(Sa,"CODE",{});var kr=s(At);uo=i(kr,"~peft.LoraConfig"),kr.forEach(t),co=i(Sa," for more details about what the hyperparameters do)."),Sa.forEach(t),$r.forEach(t),Ta=f(e),c(je.$$.fragment,e),$a=f(e),Be=r(e,"OL",{start:!0});var gr=s(Be);Pt=r(gr,"LI",{});var Fr=s(Pt);bo=i(Fr,"Add adapter to the model."),Fr.forEach(t),gr.forEach(t),ka=f(e),c(Re.$$.fragment,e),ga=f(e),Ae=r(e,"OL",{start:!0});var Jr=s(Ae);Pe=r(Jr,"LI",{});var Ya=s(Pe);yo=i(Ya,"Now you can pass the model to "),lt=r(Ya,"A",{href:!0});var Zr=s(lt);wo=i(Zr,"Trainer"),Zr.forEach(t),vo=i(Ya,"!"),Ya.forEach(t),Jr.forEach(t),Fa=f(e),c(Ge.$$.fragment,e),Ja=f(e),ot=r(e,"P",{});var Ur=s(ot);Mo=i(Ur,"To save your trained adapter and load it back:"),Ur.forEach(t),Za=f(e),c(Ve.$$.fragment,e),this.h()},h(){m(h,"name","hf:doc:metadata"),m(h,"content",JSON.stringify(Xr)),m(k,"id","load-adapters-with-peft"),m(k,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),m(k,"href","#load-adapters-with-peft"),m(M,"class","relative group"),m(R,"href","https://huggingface.co/blog/peft"),m(R,"rel","nofollow"),Ar(nt.src,Eo="https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/peft/PEFT-hub-screenshot.png")||m(nt,"src",Eo),m(He,"class","text-center"),m(G,"class","flex flex-col justify-center"),m(pe,"href","https://huggingface.co/docs/peft/index"),m(pe,"rel","nofollow"),m(S,"id","setup"),m(S,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),m(S,"href","#setup"),m(V,"class","relative group"),m(Y,"id","supported-peft-models"),m(Y,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),m(Y,"href","#supported-peft-models"),m(I,"class","relative group"),m(ue,"href","https://huggingface.co/docs/peft/conceptual_guides/lora"),m(ue,"rel","nofollow"),m(ce,"href","https://huggingface.co/docs/peft/conceptual_guides/ia3"),m(ce,"rel","nofollow"),m(be,"href","https://arxiv.org/abs/2303.10512"),m(be,"rel","nofollow"),m(ye,"href","https://huggingface.co/docs/peft/index"),m(ye,"rel","nofollow"),m(q,"id","load-a-peft-adapter"),m(q,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),m(q,"href","#load-a-peft-adapter"),m(N,"class","relative group"),m(ze,"href","/docs/transformers/main/en/model_doc/auto#transformers.AutoModelForCausalLM"),m(ee,"id","load-in-8bit-or-4bit"),m(ee,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),m(ee,"href","#load-in-8bit-or-4bit"),m(X,"class","relative group"),m(qe,"href","./quantization#bitsandbytes-integration"),m(De,"href","/docs/transformers/main/en/main_classes/model#transformers.PreTrainedModel.from_pretrained"),m(te,"id","add-a-new-adapter"),m(te,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),m(te,"href","#add-a-new-adapter"),m(Q,"class","relative group"),m(oe,"id","enable-and-disable-adapters"),m(oe,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),m(oe,"href","#enable-and-disable-adapters"),m(L,"class","relative group"),m(re,"id","train-a-peft-adapter"),m(re,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),m(re,"href","#train-a-peft-adapter"),m(H,"class","relative group"),m(tt,"href","/docs/transformers/main/en/main_classes/trainer#transformers.Trainer"),m(Be,"start","2"),m(lt,"href","/docs/transformers/main/en/main_classes/trainer#transformers.Trainer"),m(Ae,"start","3")},m(e,l){a(document.head,h),p(e,j,l),p(e,M,l),a(M,k),a(k,U),b(_,U,null),a(M,B),a(M,C),a(C,F),p(e,$,l),b(J,e,l),p(e,W,l),p(e,T,l),a(T,R),a(R,Xe),a(T,Qe),p(e,Vt,l),p(e,Le,l),a(Le,za),p(e,It,l),p(e,G,l),a(G,nt),a(G,qa),a(G,He),a(He,Da),p(e,Nt,l),p(e,x,l),a(x,Oa),a(x,pe),a(pe,Ka),a(x,el),p(e,Xt,l),p(e,V,l),a(V,S),a(S,it),b(de,it,null),a(V,tl),a(V,pt),a(pt,al),p(e,Qt,l),p(e,xe,l),a(xe,ll),p(e,Lt,l),b(fe,e,l),p(e,Ht,l),p(e,Se,l),a(Se,ol),p(e,xt,l),b(me,e,l),p(e,St,l),p(e,I,l),a(I,Y),a(Y,dt),b(he,dt,null),a(I,rl),a(I,ft),a(ft,sl),p(e,Yt,l),p(e,Ye,l),a(Ye,nl),p(e,zt,l),p(e,A,l),a(A,mt),a(mt,ue),a(ue,il),a(A,pl),a(A,ht),a(ht,ce),a(ce,dl),a(A,fl),a(A,ut),a(ut,be),a(be,ml),p(e,qt,l),p(e,z,l),a(z,hl),a(z,ye),a(ye,ul),a(z,cl),p(e,Dt,l),p(e,N,l),a(N,q),a(q,ct),b(we,ct,null),a(N,bl),a(N,bt),a(bt,yl),p(e,Ot,l),p(e,P,l),a(P,wl),a(P,yt),a(yt,vl),a(P,Ml),a(P,wt),a(wt,_l),a(P,El),p(e,Kt,l),p(e,D,l),a(D,vt),a(vt,Tl),a(D,$l),a(D,ve),a(ve,kl),a(ve,ze),a(ze,gl),a(ve,Fl),p(e,ea,l),b(Me,e,l),p(e,ta,l),b(O,e,l),p(e,aa,l),p(e,K,l),a(K,Jl),a(K,Mt),a(Mt,Zl),a(K,Ul),p(e,la,l),b(_e,e,l),p(e,oa,l),p(e,X,l),a(X,ee),a(ee,_t),b(Ee,_t,null),a(X,Cl),a(X,Et),a(Et,Wl),p(e,ra,l),p(e,E,l),a(E,jl),a(E,Tt),a(Tt,Bl),a(E,Rl),a(E,$t),a($t,Al),a(E,Pl),a(E,qe),a(qe,Gl),a(E,Vl),a(E,kt),a(kt,Il),a(E,Nl),a(E,gt),a(gt,Xl),a(E,Ql),a(E,De),a(De,Ll),a(E,Hl),a(E,Ft),a(Ft,xl),a(E,Sl),p(e,sa,l),b(Te,e,l),p(e,na,l),p(e,Q,l),a(Q,te),a(te,Jt),b($e,Jt,null),a(Q,Yl),a(Q,Zt),a(Zt,zl),p(e,ia,l),p(e,ae,l),a(ae,ql),a(ae,Ut),a(Ut,Dl),a(ae,Ol),p(e,pa,l),b(ke,e,l),p(e,da,l),p(e,Oe,l),a(Oe,Kl),p(e,fa,l),b(ge,e,l),p(e,ma,l),p(e,le,l),a(le,eo),a(le,Ct),a(Ct,to),a(le,ao),p(e,ha,l),b(Fe,e,l),p(e,ua,l),p(e,L,l),a(L,oe),a(oe,Wt),b(Je,Wt,null),a(L,lo),a(L,jt),a(jt,oo),p(e,ca,l),p(e,Ke,l),a(Ke,ro),p(e,ba,l),b(Ze,e,l),p(e,ya,l),p(e,et,l),a(et,so),p(e,wa,l),b(Ue,e,l),p(e,va,l),p(e,H,l),a(H,re),a(re,Bt),b(Ce,Bt,null),a(H,no),a(H,Rt),a(Rt,io),p(e,Ma,l),p(e,se,l),a(se,po),a(se,tt),a(tt,fo),a(se,mo),p(e,_a,l),b(ne,e,l),p(e,Ea,l),p(e,at,l),a(at,We),a(We,ho),a(We,At),a(At,uo),a(We,co),p(e,Ta,l),b(je,e,l),p(e,$a,l),p(e,Be,l),a(Be,Pt),a(Pt,bo),p(e,ka,l),b(Re,e,l),p(e,ga,l),p(e,Ae,l),a(Ae,Pe),a(Pe,yo),a(Pe,lt),a(lt,wo),a(Pe,vo),p(e,Fa,l),b(Ge,e,l),p(e,Ja,l),p(e,ot,l),a(ot,Mo),p(e,Za,l),b(Ve,e,l),Ua=!0},p(e,[l]){const Ie={};l&2&&(Ie.$$scope={dirty:l,ctx:e}),O.$set(Ie);const Gt={};l&2&&(Gt.$$scope={dirty:l,ctx:e}),ne.$set(Gt)},i(e){Ua||(y(_.$$.fragment,e),y(J.$$.fragment,e),y(de.$$.fragment,e),y(fe.$$.fragment,e),y(me.$$.fragment,e),y(he.$$.fragment,e),y(we.$$.fragment,e),y(Me.$$.fragment,e),y(O.$$.fragment,e),y(_e.$$.fragment,e),y(Ee.$$.fragment,e),y(Te.$$.fragment,e),y($e.$$.fragment,e),y(ke.$$.fragment,e),y(ge.$$.fragment,e),y(Fe.$$.fragment,e),y(Je.$$.fragment,e),y(Ze.$$.fragment,e),y(Ue.$$.fragment,e),y(Ce.$$.fragment,e),y(ne.$$.fragment,e),y(je.$$.fragment,e),y(Re.$$.fragment,e),y(Ge.$$.fragment,e),y(Ve.$$.fragment,e),Ua=!0)},o(e){w(_.$$.fragment,e),w(J.$$.fragment,e),w(de.$$.fragment,e),w(fe.$$.fragment,e),w(me.$$.fragment,e),w(he.$$.fragment,e),w(we.$$.fragment,e),w(Me.$$.fragment,e),w(O.$$.fragment,e),w(_e.$$.fragment,e),w(Ee.$$.fragment,e),w(Te.$$.fragment,e),w($e.$$.fragment,e),w(ke.$$.fragment,e),w(ge.$$.fragment,e),w(Fe.$$.fragment,e),w(Je.$$.fragment,e),w(Ze.$$.fragment,e),w(Ue.$$.fragment,e),w(Ce.$$.fragment,e),w(ne.$$.fragment,e),w(je.$$.fragment,e),w(Re.$$.fragment,e),w(Ge.$$.fragment,e),w(Ve.$$.fragment,e),Ua=!1},d(e){t(h),e&&t(j),e&&t(M),v(_),e&&t($),v(J,e),e&&t(W),e&&t(T),e&&t(Vt),e&&t(Le),e&&t(It),e&&t(G),e&&t(Nt),e&&t(x),e&&t(Xt),e&&t(V),v(de),e&&t(Qt),e&&t(xe),e&&t(Lt),v(fe,e),e&&t(Ht),e&&t(Se),e&&t(xt),v(me,e),e&&t(St),e&&t(I),v(he),e&&t(Yt),e&&t(Ye),e&&t(zt),e&&t(A),e&&t(qt),e&&t(z),e&&t(Dt),e&&t(N),v(we),e&&t(Ot),e&&t(P),e&&t(Kt),e&&t(D),e&&t(ea),v(Me,e),e&&t(ta),v(O,e),e&&t(aa),e&&t(K),e&&t(la),v(_e,e),e&&t(oa),e&&t(X),v(Ee),e&&t(ra),e&&t(E),e&&t(sa),v(Te,e),e&&t(na),e&&t(Q),v($e),e&&t(ia),e&&t(ae),e&&t(pa),v(ke,e),e&&t(da),e&&t(Oe),e&&t(fa),v(ge,e),e&&t(ma),e&&t(le),e&&t(ha),v(Fe,e),e&&t(ua),e&&t(L),v(Je),e&&t(ca),e&&t(Ke),e&&t(ba),v(Ze,e),e&&t(ya),e&&t(et),e&&t(wa),v(Ue,e),e&&t(va),e&&t(H),v(Ce),e&&t(Ma),e&&t(se),e&&t(_a),v(ne,e),e&&t(Ea),e&&t(at),e&&t(Ta),v(je,e),e&&t($a),e&&t(Be),e&&t(ka),v(Re,e),e&&t(ga),e&&t(Ae),e&&t(Fa),v(Ge,e),e&&t(Ja),e&&t(ot),e&&t(Za),v(Ve,e)}}}const Xr={local:"load-adapters-with-peft",sections:[{local:"setup",title:"Setup"},{local:"supported-peft-models",title:"Supported PEFT models"},{local:"load-a-peft-adapter",title:"Load a PEFT adapter"},{local:"load-in-8bit-or-4bit",title:"Load in 8bit or 4bit"},{local:"add-a-new-adapter",title:"Add a new adapter"},{local:"enable-and-disable-adapters",title:"Enable and disable adapters"},{local:"train-a-peft-adapter",title:"Train a PEFT adapter"}],title:"Load adapters with \u{1F917} PEFT"};function Qr(Ne){return Pr(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class zr extends Wr{constructor(h){super();jr(this,h,Qr,Nr,Br,{})}}export{zr as default,Xr as metadata};
