import{s as rt,o as pt,n as ft}from"../chunks/scheduler.c3dfb84c.js";import{S as dt,i as ct,e as m,s as a,c as p,h as $t,a as u,d as l,b as n,f as ot,g as f,j as g,k as mt,l as ht,m as s,n as d,t as c,o as $,p as h}from"../chunks/index.47c20be5.js";import{T as gt}from"../chunks/Tip.34d6f74f.js";import{C as bt,H as K,E as Mt}from"../chunks/MermaidChart.svelte_svelte_type_style_lang.423d8c15.js";import{C as ut}from"../chunks/CodeBlock.6375aab7.js";function Tt(W){let i,b="Unless each instance must be assigned multiple outputs, you frequently do not need to specify a multi target strategy.";return{c(){i=m("p"),i.textContent=b},l(o){i=u(o,"P",{"data-svelte-h":!0}),g(i)!=="svelte-oj451i"&&(i.textContent=b)},m(o,F){s(o,i,F)},p:ft,d(o){o&&l(i)}}}function wt(W){let i,b,o,F,M,G,T,U,w,Y="SetFit supports multilabel classification, allowing multiple labels to be assigned to each instance.",q,r,z,y,tt="This guide will show you how to train and use multilabel SetFit models.",E,J,R,C,et="SetFit will initialise a multilabel classification head from <code>sklearn</code> - the following options are available for <code>multi_target_strategy</code>:",V,_,lt='<li><code>&quot;one-vs-rest&quot;</code>: uses a <a href="https://scikit-learn.org/stable/modules/generated/sklearn.multiclass.OneVsRestClassifier.html" rel="nofollow"><code>OneVsRestClassifier</code></a> head.</li> <li><code>&quot;multi-output&quot;</code>: uses a <a href="https://scikit-learn.org/stable/modules/generated/sklearn.multioutput.MultiOutputClassifier.html" rel="nofollow"><code>MultiOutputClassifier</code></a> head.</li> <li><code>&quot;classifier-chain&quot;</code>: uses a <a href="https://scikit-learn.org/stable/modules/generated/sklearn.multioutput.ClassifierChain.html" rel="nofollow"><code>ClassifierChain</code></a> head.</li>',X,B,st='See the <a href="https://scikit-learn.org/stable/modules/multiclass.html#multiclass-classification" rel="nofollow">scikit-learn documentation for multiclass and multioutput classification</a> for more details.',A,k,L,x,it="Using the default LogisticRegression head, we can apply multi target strategies like so:",P,j,Q,Z,at="With a differentiable head it looks like so:",H,I,N,v,O,S,D;return M=new bt({props:{containerStyle:"float: right; margin-left: 10px; display: inline-flex; position: relative; z-index: 10;"}}),T=new K({props:{title:"Multilabel Text Classification",local:"multilabel-text-classification",headingTag:"h1"}}),r=new gt({props:{$$slots:{default:[Tt]},$$scope:{ctx:W}}}),J=new K({props:{title:"Multilabel strategies",local:"multilabel-strategies",headingTag:"h2"}}),k=new K({props:{title:"Initializing SetFit models with multilabel strategies",local:"initializing-setfit-models-with-multilabel-strategies",headingTag:"h2"}}),j=new ut({props:{code:"ZnJvbSUyMHNldGZpdCUyMGltcG9ydCUyMFNldEZpdE1vZGVsJTBBJTBBbW9kZWwlMjAlM0QlMjBTZXRGaXRNb2RlbC5mcm9tX3ByZXRyYWluZWQoJTBBJTIwJTIwJTIwJTIwbW9kZWxfaWQlMkMlMjAlMjMlMjBlLmcuJTIwJTIyQkFBSSUyRmJnZS1zbWFsbC1lbi12MS41JTIyJTBBJTIwJTIwJTIwJTIwbXVsdGlfdGFyZ2V0X3N0cmF0ZWd5JTNEJTIybXVsdGktb3V0cHV0JTIyJTJDJTBBKQ==",highlighted:`<span class="hljs-keyword">from</span> setfit <span class="hljs-keyword">import</span> SetFitModel

model = SetFitModel.from_pretrained(
    model_id, <span class="hljs-comment"># e.g. &quot;BAAI/bge-small-en-v1.5&quot;</span>
    multi_target_strategy=<span class="hljs-string">&quot;multi-output&quot;</span>,
)`,wrap:!1}}),I=new ut({props:{code:"ZnJvbSUyMHNldGZpdCUyMGltcG9ydCUyMFNldEZpdE1vZGVsJTBBJTBBbW9kZWwlMjAlM0QlMjBTZXRGaXRNb2RlbC5mcm9tX3ByZXRyYWluZWQoJTBBJTIwJTIwJTIwJTIwbW9kZWxfaWQlMkMlMjAlMjMlMjBlLmcuJTIwJTIyQkFBSSUyRmJnZS1zbWFsbC1lbi12MS41JTIyJTBBJTIwJTIwJTIwJTIwbXVsdGlfdGFyZ2V0X3N0cmF0ZWd5JTNEJTIyb25lLXZzLXJlc3QlMjIlMEElMjAlMjAlMjAlMjB1c2VfZGlmZmVyZW50aWFibGVfaGVhZCUzRFRydWUlMkMlMEElMjAlMjAlMjAlMjBoZWFkX3BhcmFtcyUzRCU3QiUyMm91dF9mZWF0dXJlcyUyMiUzQSUyMG51bV9jbGFzc2VzJTdEJTJDJTBBKQ==",highlighted:`<span class="hljs-keyword">from</span> setfit <span class="hljs-keyword">import</span> SetFitModel

model = SetFitModel.from_pretrained(
    model_id, <span class="hljs-comment"># e.g. &quot;BAAI/bge-small-en-v1.5&quot;</span>
    multi_target_strategy=<span class="hljs-string">&quot;one-vs-rest&quot;</span>
    use_differentiable_head=<span class="hljs-literal">True</span>,
    head_params={<span class="hljs-string">&quot;out_features&quot;</span>: num_classes},
)`,wrap:!1}}),v=new Mt({props:{source:"https://github.com/huggingface/setfit/blob/main/docs/source/en/how_to/multilabel.mdx"}}),{c(){i=m("meta"),b=a(),o=m("p"),F=a(),p(M.$$.fragment),G=a(),p(T.$$.fragment),U=a(),w=m("p"),w.textContent=Y,q=a(),p(r.$$.fragment),z=a(),y=m("p"),y.textContent=tt,E=a(),p(J.$$.fragment),R=a(),C=m("p"),C.innerHTML=et,V=a(),_=m("ul"),_.innerHTML=lt,X=a(),B=m("p"),B.innerHTML=st,A=a(),p(k.$$.fragment),L=a(),x=m("p"),x.textContent=it,P=a(),p(j.$$.fragment),Q=a(),Z=m("p"),Z.textContent=at,H=a(),p(I.$$.fragment),N=a(),p(v.$$.fragment),O=a(),S=m("p"),this.h()},l(t){const e=$t("svelte-u9bgzb",document.head);i=u(e,"META",{name:!0,content:!0}),e.forEach(l),b=n(t),o=u(t,"P",{}),ot(o).forEach(l),F=n(t),f(M.$$.fragment,t),G=n(t),f(T.$$.fragment,t),U=n(t),w=u(t,"P",{"data-svelte-h":!0}),g(w)!=="svelte-1suhalr"&&(w.textContent=Y),q=n(t),f(r.$$.fragment,t),z=n(t),y=u(t,"P",{"data-svelte-h":!0}),g(y)!=="svelte-13p5ezl"&&(y.textContent=tt),E=n(t),f(J.$$.fragment,t),R=n(t),C=u(t,"P",{"data-svelte-h":!0}),g(C)!=="svelte-zhilh4"&&(C.innerHTML=et),V=n(t),_=u(t,"UL",{"data-svelte-h":!0}),g(_)!=="svelte-h2knuu"&&(_.innerHTML=lt),X=n(t),B=u(t,"P",{"data-svelte-h":!0}),g(B)!=="svelte-1cgmuwl"&&(B.innerHTML=st),A=n(t),f(k.$$.fragment,t),L=n(t),x=u(t,"P",{"data-svelte-h":!0}),g(x)!=="svelte-59k6ip"&&(x.textContent=it),P=n(t),f(j.$$.fragment,t),Q=n(t),Z=u(t,"P",{"data-svelte-h":!0}),g(Z)!=="svelte-8iwzib"&&(Z.textContent=at),H=n(t),f(I.$$.fragment,t),N=n(t),f(v.$$.fragment,t),O=n(t),S=u(t,"P",{}),ot(S).forEach(l),this.h()},h(){mt(i,"name","hf:doc:metadata"),mt(i,"content",yt)},m(t,e){ht(document.head,i),s(t,b,e),s(t,o,e),s(t,F,e),d(M,t,e),s(t,G,e),d(T,t,e),s(t,U,e),s(t,w,e),s(t,q,e),d(r,t,e),s(t,z,e),s(t,y,e),s(t,E,e),d(J,t,e),s(t,R,e),s(t,C,e),s(t,V,e),s(t,_,e),s(t,X,e),s(t,B,e),s(t,A,e),d(k,t,e),s(t,L,e),s(t,x,e),s(t,P,e),d(j,t,e),s(t,Q,e),s(t,Z,e),s(t,H,e),d(I,t,e),s(t,N,e),d(v,t,e),s(t,O,e),s(t,S,e),D=!0},p(t,[e]){const nt={};e&2&&(nt.$$scope={dirty:e,ctx:t}),r.$set(nt)},i(t){D||(c(M.$$.fragment,t),c(T.$$.fragment,t),c(r.$$.fragment,t),c(J.$$.fragment,t),c(k.$$.fragment,t),c(j.$$.fragment,t),c(I.$$.fragment,t),c(v.$$.fragment,t),D=!0)},o(t){$(M.$$.fragment,t),$(T.$$.fragment,t),$(r.$$.fragment,t),$(J.$$.fragment,t),$(k.$$.fragment,t),$(j.$$.fragment,t),$(I.$$.fragment,t),$(v.$$.fragment,t),D=!1},d(t){t&&(l(b),l(o),l(F),l(G),l(U),l(w),l(q),l(z),l(y),l(E),l(R),l(C),l(V),l(_),l(X),l(B),l(A),l(L),l(x),l(P),l(Q),l(Z),l(H),l(N),l(O),l(S)),l(i),h(M,t),h(T,t),h(r,t),h(J,t),h(k,t),h(j,t),h(I,t),h(v,t)}}}const yt='{"title":"Multilabel Text Classification","local":"multilabel-text-classification","sections":[{"title":"Multilabel strategies","local":"multilabel-strategies","sections":[],"depth":2},{"title":"Initializing SetFit models with multilabel strategies","local":"initializing-setfit-models-with-multilabel-strategies","sections":[],"depth":2}],"depth":1}';function Jt(W){return pt(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class jt extends dt{constructor(i){super(),ct(this,i,Jt,wt,rt,{})}}export{jt as component};
