import{s as Fe,n as He,o as Le}from"../chunks/scheduler.9cda857a.js";import{S as _e,i as Ue,e as a,s as n,c as r,h as ke,a as o,d as i,b as s,f as Se,g as f,j as m,k as Ce,l as Ze,m as l,n as p,t as u,o as g,p as h}from"../chunks/index.f47f3121.js";import{C as Je}from"../chunks/CopyLLMTxtMenu.676ed699.js";import{C as ue}from"../chunks/CodeBlock.24d62f98.js";import{H as A,E as Pe}from"../chunks/MermaidChart.svelte_svelte_type_style_lang.64d112fc.js";function je(ge){let c,E,G,I,d,V,$,q,w,he='SetFit is an efficient and prompt-free framework for few-shot fine-tuning of <a href="https://sbert.net/" rel="nofollow">Sentence Transformers</a>. It achieves high accuracy with little labeled data - for instance, with only 8 labeled examples per class on the Customer Reviews sentiment dataset, SetFit is competitive with fine-tuning RoBERTa Large on the full training set of 3k examples 🤯!',z,y,ce="Compared to other few-shot learning methods, SetFit has several unique features:",X,b,de='<li>🗣 <strong>No prompts or verbalizers:</strong> Current techniques for few-shot fine-tuning require handcrafted prompts or verbalizers to convert examples into a format suitable for the underlying language model. SetFit dispenses with prompts altogether by generating rich embeddings directly from text examples.</li> <li>🏎 <strong>Fast to train:</strong> SetFit doesn’t require large-scale models like <a href="https://huggingface.co/bigscience/T0" rel="nofollow">T0</a> or GPT-3 to achieve high accuracy. As a result, it is typically an order of magnitude (or more) faster to train and run inference with.</li> <li>🌎 <strong>Multilingual support</strong>: SetFit can be used with any <a href="https://huggingface.co/models?library=sentence-transformers&amp;sort=downloads" rel="nofollow">Sentence Transformer</a> on the Hub, which means you can classify text in multiple languages by simply fine-tuning a multilingual checkpoint.</li>',Y,v,R,x,$e='You can find SetFit models by filtering at the left of the <a href="https://huggingface.co/models?library=setfit" rel="nofollow">models page</a>.',N,M,we="All models on the Hub come with these useful features:",Q,T,ye="<li>An automatically generated model card with a brief description.</li> <li>An interactive widget you can use to play with the model directly in the browser.</li> <li>An Inference API that allows you to make inference requests.</li>",O,S,D,C,be='To get started, you can follow the <a href="https://huggingface.co/docs/setfit/installation" rel="nofollow">SetFit installation guide</a>. You can also use the following one-line install through pip:',K,F,ee,H,te,L,ve="All <code>setfit</code> models can easily be loaded from the Hub.",ie,_,le,U,xe='Once loaded, you can use <a href="https://huggingface.co/docs/setfit/reference/main#setfit.SetFitModel.predict" rel="nofollow"><code>SetFitModel.predict</code></a> to perform inference.',ne,k,se,Z,ae,J,Me="If you want to load a specific SetFit model, you can click <code>Use in SetFit</code> and you will be given a working snippet!",oe,P,re,j,Te='<li><a href="https://huggingface.co/models?library=setfit" rel="nofollow">All SetFit models available on the Hub</a></li> <li>SetFit <a href="https://github.com/huggingface/setfit" rel="nofollow">repository</a></li> <li>SetFit <a href="https://huggingface.co/docs/setfit" rel="nofollow">docs</a></li> <li>SetFit <a href="https://arxiv.org/abs/2209.11055" rel="nofollow">paper</a></li>',fe,B,me,W,pe;return d=new Je({props:{containerStyle:"float: right; margin-left: 10px; display: inline-flex; position: relative; z-index: 10;"}}),$=new A({props:{title:"Using SetFit with Hugging Face",local:"using-setfit-with-hugging-face",headingTag:"h1"}}),v=new A({props:{title:"Exploring SetFit on the Hub",local:"exploring-setfit-on-the-hub",headingTag:"h2"}}),S=new A({props:{title:"Installation",local:"installation",headingTag:"h2"}}),F=new ue({props:{code:"cGlwJTIwaW5zdGFsbCUyMC1VJTIwc2V0Zml0",highlighted:'pip <span class="hljs-keyword">install</span> -U setfit',wrap:!1}}),H=new A({props:{title:"Using existing models",local:"using-existing-models",headingTag:"h2"}}),_=new ue({props:{code:"ZnJvbSUyMHNldGZpdCUyMGltcG9ydCUyMFNldEZpdE1vZGVsJTBBJTBBbW9kZWwlMjAlM0QlMjBTZXRGaXRNb2RlbC5mcm9tX3ByZXRyYWluZWQoJTIydG9tYWFyc2VuJTJGc2V0Zml0LXBhcmFwaHJhc2UtbXBuZXQtYmFzZS12Mi1zc3QyLTgtc2hvdCUyMik=",highlighted:`<span class="hljs-keyword">from</span> setfit <span class="hljs-keyword">import</span> SetFitModel

model = SetFitModel.from_pretrained(<span class="hljs-string">&quot;tomaarsen/setfit-paraphrase-mpnet-base-v2-sst2-8-shot&quot;</span>)`,wrap:!1}}),k=new ue({props:{code:"bW9kZWwucHJlZGljdCglMjJBbWVsaWElMjBFYXJoYXJ0JTIwZmxldyUyMGhlciUyMHNpbmdsZSUyMGVuZ2luZSUyMExvY2toZWVkJTIwVmVnYSUyMDVCJTIwYWNyb3NzJTIwdGhlJTIwQXRsYW50aWMlMjB0byUyMFBhcmlzLiUyMik=",highlighted:'model.predict(<span class="hljs-string">&quot;Amelia Earhart flew her single engine Lockheed Vega 5B across the Atlantic to Paris.&quot;</span>)',wrap:!1}}),Z=new ue({props:{code:"JTVCJ3Bvc2l0aXZlJyUyQyUyMCduZWdhdGl2ZSclNUQ=",highlighted:'[<span class="hljs-string">&#x27;positive&#x27;</span>, <span class="hljs-string">&#x27;negative&#x27;</span>]',wrap:!1}}),P=new A({props:{title:"Additional resources",local:"additional-resources",headingTag:"h2"}}),B=new Pe({props:{source:"https://github.com/huggingface/hub-docs/blob/main/docs/hub/setfit.md"}}),{c(){c=a("meta"),E=n(),G=a("p"),I=n(),r(d.$$.fragment),V=n(),r($.$$.fragment),q=n(),w=a("p"),w.innerHTML=he,z=n(),y=a("p"),y.textContent=ce,X=n(),b=a("ul"),b.innerHTML=de,Y=n(),r(v.$$.fragment),R=n(),x=a("p"),x.innerHTML=$e,N=n(),M=a("p"),M.textContent=we,Q=n(),T=a("ol"),T.innerHTML=ye,O=n(),r(S.$$.fragment),D=n(),C=a("p"),C.innerHTML=be,K=n(),r(F.$$.fragment),ee=n(),r(H.$$.fragment),te=n(),L=a("p"),L.innerHTML=ve,ie=n(),r(_.$$.fragment),le=n(),U=a("p"),U.innerHTML=xe,ne=n(),r(k.$$.fragment),se=n(),r(Z.$$.fragment),ae=n(),J=a("p"),J.innerHTML=Me,oe=n(),r(P.$$.fragment),re=n(),j=a("ul"),j.innerHTML=Te,fe=n(),r(B.$$.fragment),me=n(),W=a("p"),this.h()},l(e){const t=ke("svelte-u9bgzb",document.head);c=o(t,"META",{name:!0,content:!0}),t.forEach(i),E=s(e),G=o(e,"P",{}),Se(G).forEach(i),I=s(e),f(d.$$.fragment,e),V=s(e),f($.$$.fragment,e),q=s(e),w=o(e,"P",{"data-svelte-h":!0}),m(w)!=="svelte-1mkza03"&&(w.innerHTML=he),z=s(e),y=o(e,"P",{"data-svelte-h":!0}),m(y)!=="svelte-shg4rg"&&(y.textContent=ce),X=s(e),b=o(e,"UL",{"data-svelte-h":!0}),m(b)!=="svelte-txtyih"&&(b.innerHTML=de),Y=s(e),f(v.$$.fragment,e),R=s(e),x=o(e,"P",{"data-svelte-h":!0}),m(x)!=="svelte-e3slj1"&&(x.innerHTML=$e),N=s(e),M=o(e,"P",{"data-svelte-h":!0}),m(M)!=="svelte-qgdcoc"&&(M.textContent=we),Q=s(e),T=o(e,"OL",{"data-svelte-h":!0}),m(T)!=="svelte-15umf4s"&&(T.innerHTML=ye),O=s(e),f(S.$$.fragment,e),D=s(e),C=o(e,"P",{"data-svelte-h":!0}),m(C)!=="svelte-rjmin4"&&(C.innerHTML=be),K=s(e),f(F.$$.fragment,e),ee=s(e),f(H.$$.fragment,e),te=s(e),L=o(e,"P",{"data-svelte-h":!0}),m(L)!=="svelte-1txywkm"&&(L.innerHTML=ve),ie=s(e),f(_.$$.fragment,e),le=s(e),U=o(e,"P",{"data-svelte-h":!0}),m(U)!=="svelte-18vgghq"&&(U.innerHTML=xe),ne=s(e),f(k.$$.fragment,e),se=s(e),f(Z.$$.fragment,e),ae=s(e),J=o(e,"P",{"data-svelte-h":!0}),m(J)!=="svelte-1hzt40x"&&(J.innerHTML=Me),oe=s(e),f(P.$$.fragment,e),re=s(e),j=o(e,"UL",{"data-svelte-h":!0}),m(j)!=="svelte-b2vxdn"&&(j.innerHTML=Te),fe=s(e),f(B.$$.fragment,e),me=s(e),W=o(e,"P",{}),Se(W).forEach(i),this.h()},h(){Ce(c,"name","hf:doc:metadata"),Ce(c,"content",Be)},m(e,t){Ze(document.head,c),l(e,E,t),l(e,G,t),l(e,I,t),p(d,e,t),l(e,V,t),p($,e,t),l(e,q,t),l(e,w,t),l(e,z,t),l(e,y,t),l(e,X,t),l(e,b,t),l(e,Y,t),p(v,e,t),l(e,R,t),l(e,x,t),l(e,N,t),l(e,M,t),l(e,Q,t),l(e,T,t),l(e,O,t),p(S,e,t),l(e,D,t),l(e,C,t),l(e,K,t),p(F,e,t),l(e,ee,t),p(H,e,t),l(e,te,t),l(e,L,t),l(e,ie,t),p(_,e,t),l(e,le,t),l(e,U,t),l(e,ne,t),p(k,e,t),l(e,se,t),p(Z,e,t),l(e,ae,t),l(e,J,t),l(e,oe,t),p(P,e,t),l(e,re,t),l(e,j,t),l(e,fe,t),p(B,e,t),l(e,me,t),l(e,W,t),pe=!0},p:He,i(e){pe||(u(d.$$.fragment,e),u($.$$.fragment,e),u(v.$$.fragment,e),u(S.$$.fragment,e),u(F.$$.fragment,e),u(H.$$.fragment,e),u(_.$$.fragment,e),u(k.$$.fragment,e),u(Z.$$.fragment,e),u(P.$$.fragment,e),u(B.$$.fragment,e),pe=!0)},o(e){g(d.$$.fragment,e),g($.$$.fragment,e),g(v.$$.fragment,e),g(S.$$.fragment,e),g(F.$$.fragment,e),g(H.$$.fragment,e),g(_.$$.fragment,e),g(k.$$.fragment,e),g(Z.$$.fragment,e),g(P.$$.fragment,e),g(B.$$.fragment,e),pe=!1},d(e){e&&(i(E),i(G),i(I),i(V),i(q),i(w),i(z),i(y),i(X),i(b),i(Y),i(R),i(x),i(N),i(M),i(Q),i(T),i(O),i(D),i(C),i(K),i(ee),i(te),i(L),i(ie),i(le),i(U),i(ne),i(se),i(ae),i(J),i(oe),i(re),i(j),i(fe),i(me),i(W)),i(c),h(d,e),h($,e),h(v,e),h(S,e),h(F,e),h(H,e),h(_,e),h(k,e),h(Z,e),h(P,e),h(B,e)}}}const Be='{"title":"Using SetFit with Hugging Face","local":"using-setfit-with-hugging-face","sections":[{"title":"Exploring SetFit on the Hub","local":"exploring-setfit-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 Ge(ge){return Le(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class qe extends _e{constructor(c){super(),Ue(this,c,Ge,je,Fe,{})}}export{qe as component};
