import{s as Je,n as $e,o as Ue}from"../chunks/scheduler.d6170356.js";import{S as je,i as Ie,g as i,s as n,r as p,A as Ze,h as o,f as l,c as a,j as ye,u as r,x as u,k as pe,y as ke,a as s,v as d,d as m,t as c,w as f}from"../chunks/index.fcd4cc08.js";import{C as re}from"../chunks/CodeBlock.db16bf50.js";import{H,E as ve}from"../chunks/getInferenceSnippets.0f6acb26.js";function Ge(ue){let h,x,B,R,w,N,T,de='🤗 <a href="https://huggingface.co/docs/peft/index" rel="nofollow">Parameter-Efficient Fine-Tuning (PEFT)</a> is a library for efficiently adapting pre-trained language models to various downstream applications without fine-tuning all the model’s parameters.',X,b,Q,y,me='You can find PEFT models by filtering at the left of the <a href="https://huggingface.co/models?library=peft&amp;sort=trending" rel="nofollow">models page</a>.',Y,J,P,$,ce=`To get started, you can check out the <a href="https://huggingface.co/docs/peft/quicktour" rel="nofollow">Quick Tour in the PEFT docs</a>. To install, follow the <a href="https://huggingface.co/docs/peft/install" rel="nofollow">PEFT installation guide</a>.
You can also use the following one-line install through pip:`,L,U,S,j,A,I,fe="All PEFT models can be loaded from the Hub. To use a PEFT model you also need to load the base model that was fine-tuned, as shown below. Every fine-tuned model has the base model in its model card.",z,Z,q,k,he="Once loaded, you can pass your inputs to the tokenizer to prepare them, and call <code>model.generate()</code> in regular <code>transformers</code> fashion.",K,v,D,G,ge="It outputs the following:",O,E,ee,W,Me="If you want to load a specific PEFT model, you can click <code>Use in PEFT</code> in the model card and you will be given a working snippet!",te,g,we='<img class="block dark:hidden" src="https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/hub/peft_repo_light_new.png"/> <img class="hidden dark:block" src="https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/hub/peft_repo.png"/>',le,M,Te='<img class="block dark:hidden" src="https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/hub/peft_snippet_light.png"/> <img class="hidden dark:block" src="https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/hub/peft_snippet.png"/>',se,C,ne,_,be='<li>PEFT <a href="https://github.com/huggingface/peft" rel="nofollow">repository</a></li> <li>PEFT <a href="https://huggingface.co/docs/peft/index" rel="nofollow">docs</a></li> <li>PEFT <a href="https://huggingface.co/models?library=peft&amp;sort=trending" rel="nofollow">models</a></li>',ae,F,ie,V,oe;return w=new H({props:{title:"Using PEFT at Hugging Face",local:"using-peft-at-hugging-face",headingTag:"h1"}}),b=new H({props:{title:"Exploring PEFT on the Hub",local:"exploring-peft-on-the-hub",headingTag:"h2"}}),J=new H({props:{title:"Installation",local:"installation",headingTag:"h2"}}),U=new re({props:{code:"JTI0JTIwcGlwJTIwaW5zdGFsbCUyMHBlZnQ=",highlighted:'$ pip <span class="hljs-keyword">install</span> peft',wrap:!1}}),j=new H({props:{title:"Using existing models",local:"using-existing-models",headingTag:"h2"}}),Z=new re({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMEF1dG9Nb2RlbEZvckNhdXNhbExNJTJDJTIwQXV0b1Rva2VuaXplciUwQWZyb20lMjBwZWZ0JTIwaW1wb3J0JTIwUGVmdE1vZGVsJTJDJTIwUGVmdENvbmZpZyUwQSUwQWJhc2VfbW9kZWwlMjAlM0QlMjAlMjJtaXN0cmFsYWklMkZNaXN0cmFsLTdCLXYwLjElMjIlMEFhZGFwdGVyX21vZGVsJTIwJTNEJTIwJTIyZGZ1cm1hbiUyRk1pc3RyYWwtN0ItSW5zdHJ1Y3QtdjAuMiUyMiUwQSUwQW1vZGVsJTIwJTNEJTIwQXV0b01vZGVsRm9yQ2F1c2FsTE0uZnJvbV9wcmV0cmFpbmVkKGJhc2VfbW9kZWwpJTBBbW9kZWwlMjAlM0QlMjBQZWZ0TW9kZWwuZnJvbV9wcmV0cmFpbmVkKG1vZGVsJTJDJTIwYWRhcHRlcl9tb2RlbCklMEF0b2tlbml6ZXIlMjAlM0QlMjBBdXRvVG9rZW5pemVyLmZyb21fcHJldHJhaW5lZChiYXNlX21vZGVsKSUwQSUwQW1vZGVsJTIwJTNEJTIwbW9kZWwudG8oJTIyY3VkYSUyMiklMEFtb2RlbC5ldmFsKCk=",highlighted:`<span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoModelForCausalLM, AutoTokenizer
<span class="hljs-keyword">from</span> peft <span class="hljs-keyword">import</span> PeftModel, PeftConfig

base_model = <span class="hljs-string">&quot;mistralai/Mistral-7B-v0.1&quot;</span>
adapter_model = <span class="hljs-string">&quot;dfurman/Mistral-7B-Instruct-v0.2&quot;</span>

model = AutoModelForCausalLM.from_pretrained(base_model)
model = PeftModel.from_pretrained(model, adapter_model)
tokenizer = AutoTokenizer.from_pretrained(base_model)

model = model.to(<span class="hljs-string">&quot;cuda&quot;</span>)
model.<span class="hljs-built_in">eval</span>()`,wrap:!1}}),v=new re({props:{code:"aW5wdXRzJTIwJTNEJTIwdG9rZW5pemVyKCUyMlRlbGwlMjBtZSUyMHRoZSUyMHJlY2lwZSUyMGZvciUyMGNob2NvbGF0ZSUyMGNoaXAlMjBjb29raWUlMjIlMkMlMjByZXR1cm5fdGVuc29ycyUzRCUyMnB0JTIyKSUwQSUwQXdpdGglMjB0b3JjaC5ub19ncmFkKCklM0ElMEElMjAlMjAlMjAlMjBvdXRwdXRzJTIwJTNEJTIwbW9kZWwuZ2VuZXJhdGUoaW5wdXRfaWRzJTNEaW5wdXRzJTVCJTIyaW5wdXRfaWRzJTIyJTVELnRvKCUyMmN1ZGElMjIpJTJDJTIwbWF4X25ld190b2tlbnMlM0QxMCklMEElMjAlMjAlMjAlMjBwcmludCh0b2tlbml6ZXIuYmF0Y2hfZGVjb2RlKG91dHB1dHMuZGV0YWNoKCkuY3B1KCkubnVtcHkoKSUyQyUyMHNraXBfc3BlY2lhbF90b2tlbnMlM0RUcnVlKSU1QjAlNUQp",highlighted:`inputs = tokenizer(<span class="hljs-string">&quot;Tell me the recipe for chocolate chip cookie&quot;</span>, return_tensors=<span class="hljs-string">&quot;pt&quot;</span>)

<span class="hljs-keyword">with</span> torch.no_grad():
    outputs = model.generate(input_ids=inputs[<span class="hljs-string">&quot;input_ids&quot;</span>].to(<span class="hljs-string">&quot;cuda&quot;</span>), max_new_tokens=<span class="hljs-number">10</span>)
    <span class="hljs-built_in">print</span>(tokenizer.batch_decode(outputs.detach().cpu().numpy(), skip_special_tokens=<span class="hljs-literal">True</span>)[<span class="hljs-number">0</span>])`,wrap:!1}}),E=new re({props:{code:"VGVsbCUyMG1lJTIwdGhlJTIwcmVjaXBlJTIwZm9yJTIwY2hvY29sYXRlJTIwY2hpcCUyMGNvb2tpZSUyMGRvdWdoLiUwQSUwQTEuJTIwUHJlaGVhdCUyMG92ZW4lMjB0byUyMDM3NSUyMGRlZ3JlZXMlMjBGJTIwKDE5MCUyMGRlZ3JlZXMlMjBDKS4lMEEyLiUyMEluJTIwYSUyMGxhcmdlJTIwYm93bCUyQyUyMGNyZWFtJTIwdG9nZXRoZXIlMjAxJTJGMiUyMGN1cCUyMCgxJTIwc3RpY2spJTIwb2YlMjBidXR0ZXIlMjBvciUyMG1hcmdhcmluZSUyQyUyMDElMkYyJTIwY3VwJTIwZ3JhbnVsYXRlZCUyMHN1Z2FyJTJDJTIwYW5kJTIwMSUyRjIlMjBjdXAlMjBwYWNrZWQlMjBicm93biUyMHN1Z2FyLiUwQTMuJTIwQmVhdCUyMGluJTIwMSUyMGVnZyUyMGFuZCUyMDElMjB0ZWFzcG9vbiUyMHZhbmlsbGElMjBleHRyYWN0LiUwQTQuJTIwTWl4JTIwaW4lMjAxJTIwMSUyRjQlMjBjdXBzJTIwYWxsLXB1cnBvc2UlMjBmbG91ci4lMEE1LiUyMFN0aXIlMjBpbiUyMDElMkYyJTIwdGVhc3Bvb24lMjBiYWtpbmclMjBzb2RhJTIwYW5kJTIwMSUyRjIlMjB0ZWFzcG9vbiUyMHNhbHQuJTBBNi4lMjBGb2xkJTIwaW4lMjAzJTJGNCUyMGN1cCUyMHNlbWlzd2VldCUyMGNob2NvbGF0ZSUyMGNoaXBzLiUwQTcuJTIwRHJvcCUyMGJ5",highlighted:`Tell me the recipe for chocolate chip cookie dough.

1. Preheat oven to 375 degrees F (190 degrees C).
2. In a large bowl, cream together 1/2 cup (1 stick) of butter or margarine, 1/2 cup granulated sugar, and 1/2 cup packed brown sugar.
3. Beat in 1 egg and 1 teaspoon vanilla extract.
4. Mix in 1 1/4 cups all-purpose flour.
5. Stir in 1/2 teaspoon baking soda and 1/2 teaspoon salt.
6. Fold in 3/4 cup semisweet chocolate chips.
7. Drop by`,wrap:!1}}),C=new H({props:{title:"Additional resources",local:"additional-resources",headingTag:"h2"}}),F=new ve({props:{source:"https://github.com/huggingface/hub-docs/blob/main/docs/hub/peft.md"}}),{c(){h=i("meta"),x=n(),B=i("p"),R=n(),p(w.$$.fragment),N=n(),T=i("p"),T.innerHTML=de,X=n(),p(b.$$.fragment),Q=n(),y=i("p"),y.innerHTML=me,Y=n(),p(J.$$.fragment),P=n(),$=i("p"),$.innerHTML=ce,L=n(),p(U.$$.fragment),S=n(),p(j.$$.fragment),A=n(),I=i("p"),I.textContent=fe,z=n(),p(Z.$$.fragment),q=n(),k=i("p"),k.innerHTML=he,K=n(),p(v.$$.fragment),D=n(),G=i("p"),G.textContent=ge,O=n(),p(E.$$.fragment),ee=n(),W=i("p"),W.innerHTML=Me,te=n(),g=i("div"),g.innerHTML=we,le=n(),M=i("div"),M.innerHTML=Te,se=n(),p(C.$$.fragment),ne=n(),_=i("ul"),_.innerHTML=be,ae=n(),p(F.$$.fragment),ie=n(),V=i("p"),this.h()},l(e){const t=Ze("svelte-u9bgzb",document.head);h=o(t,"META",{name:!0,content:!0}),t.forEach(l),x=a(e),B=o(e,"P",{}),ye(B).forEach(l),R=a(e),r(w.$$.fragment,e),N=a(e),T=o(e,"P",{"data-svelte-h":!0}),u(T)!=="svelte-1pze80r"&&(T.innerHTML=de),X=a(e),r(b.$$.fragment,e),Q=a(e),y=o(e,"P",{"data-svelte-h":!0}),u(y)!=="svelte-515lb5"&&(y.innerHTML=me),Y=a(e),r(J.$$.fragment,e),P=a(e),$=o(e,"P",{"data-svelte-h":!0}),u($)!=="svelte-11jm9nl"&&($.innerHTML=ce),L=a(e),r(U.$$.fragment,e),S=a(e),r(j.$$.fragment,e),A=a(e),I=o(e,"P",{"data-svelte-h":!0}),u(I)!=="svelte-1qqfp2y"&&(I.textContent=fe),z=a(e),r(Z.$$.fragment,e),q=a(e),k=o(e,"P",{"data-svelte-h":!0}),u(k)!=="svelte-1ohlhfq"&&(k.innerHTML=he),K=a(e),r(v.$$.fragment,e),D=a(e),G=o(e,"P",{"data-svelte-h":!0}),u(G)!=="svelte-7whdhn"&&(G.textContent=ge),O=a(e),r(E.$$.fragment,e),ee=a(e),W=o(e,"P",{"data-svelte-h":!0}),u(W)!=="svelte-gbpq7c"&&(W.innerHTML=Me),te=a(e),g=o(e,"DIV",{class:!0,"data-svelte-h":!0}),u(g)!=="svelte-1ulotkq"&&(g.innerHTML=we),le=a(e),M=o(e,"DIV",{class:!0,"data-svelte-h":!0}),u(M)!=="svelte-ai6chf"&&(M.innerHTML=Te),se=a(e),r(C.$$.fragment,e),ne=a(e),_=o(e,"UL",{"data-svelte-h":!0}),u(_)!=="svelte-z8ea3s"&&(_.innerHTML=be),ae=a(e),r(F.$$.fragment,e),ie=a(e),V=o(e,"P",{}),ye(V).forEach(l),this.h()},h(){pe(h,"name","hf:doc:metadata"),pe(h,"content",Ee),pe(g,"class","flex justify-center"),pe(M,"class","flex justify-center")},m(e,t){ke(document.head,h),s(e,x,t),s(e,B,t),s(e,R,t),d(w,e,t),s(e,N,t),s(e,T,t),s(e,X,t),d(b,e,t),s(e,Q,t),s(e,y,t),s(e,Y,t),d(J,e,t),s(e,P,t),s(e,$,t),s(e,L,t),d(U,e,t),s(e,S,t),d(j,e,t),s(e,A,t),s(e,I,t),s(e,z,t),d(Z,e,t),s(e,q,t),s(e,k,t),s(e,K,t),d(v,e,t),s(e,D,t),s(e,G,t),s(e,O,t),d(E,e,t),s(e,ee,t),s(e,W,t),s(e,te,t),s(e,g,t),s(e,le,t),s(e,M,t),s(e,se,t),d(C,e,t),s(e,ne,t),s(e,_,t),s(e,ae,t),d(F,e,t),s(e,ie,t),s(e,V,t),oe=!0},p:$e,i(e){oe||(m(w.$$.fragment,e),m(b.$$.fragment,e),m(J.$$.fragment,e),m(U.$$.fragment,e),m(j.$$.fragment,e),m(Z.$$.fragment,e),m(v.$$.fragment,e),m(E.$$.fragment,e),m(C.$$.fragment,e),m(F.$$.fragment,e),oe=!0)},o(e){c(w.$$.fragment,e),c(b.$$.fragment,e),c(J.$$.fragment,e),c(U.$$.fragment,e),c(j.$$.fragment,e),c(Z.$$.fragment,e),c(v.$$.fragment,e),c(E.$$.fragment,e),c(C.$$.fragment,e),c(F.$$.fragment,e),oe=!1},d(e){e&&(l(x),l(B),l(R),l(N),l(T),l(X),l(Q),l(y),l(Y),l(P),l($),l(L),l(S),l(A),l(I),l(z),l(q),l(k),l(K),l(D),l(G),l(O),l(ee),l(W),l(te),l(g),l(le),l(M),l(se),l(ne),l(_),l(ae),l(ie),l(V)),l(h),f(w,e),f(b,e),f(J,e),f(U,e),f(j,e),f(Z,e),f(v,e),f(E,e),f(C,e),f(F,e)}}}const Ee='{"title":"Using PEFT at Hugging Face","local":"using-peft-at-hugging-face","sections":[{"title":"Exploring PEFT on the Hub","local":"exploring-peft-on-the-hub","sections":[],"depth":2},{"title":"Installation","local":"installation","sections":[],"depth":2},{"title":"Using existing models","local":"using-existing-models","sections":[],"depth":2},{"title":"Additional resources","local":"additional-resources","sections":[],"depth":2}],"depth":1}';function We(ue){return Ue(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class Ve extends je{constructor(h){super(),Ie(this,h,We,Ge,Je,{})}}export{Ve as component};
