import{S as _l,i as El,s as jl,e as n,k as c,w as m,t,M as xl,c as o,d as s,m as d,a as r,x as h,h as l,b as u,N as kl,G as a,g as p,y as g,q as v,o as $,B as _,v as wl}from"../chunks/vendor-hf-doc-builder.js";import{T as yl}from"../chunks/Tip-hf-doc-builder.js";import{I as oa}from"../chunks/IconCopyLink-hf-doc-builder.js";import{C as A}from"../chunks/CodeBlock-hf-doc-builder.js";function bl(ia){let f,H,E,w,M;return{c(){f=n("p"),H=t("Echa un vistazo a la documentaci\xF3n de "),E=n("code"),w=t("pipeline()"),M=t(" para obtener una lista completa de tareas admitidas.")},l(k){f=o(k,"P",{});var P=r(f);H=l(P,"Echa un vistazo a la documentaci\xF3n de "),E=o(P,"CODE",{});var U=r(E);w=l(U,"pipeline()"),U.forEach(s),M=l(P," para obtener una lista completa de tareas admitidas."),P.forEach(s)},m(k,P){p(k,f,P),a(f,H),a(f,E),a(E,w),a(f,M)},d(k){k&&s(f)}}}function ql(ia){let f,H,E,w,M,k,P,U,Za,ra,y,es,ze,as,ss,Z,ts,ls,Ce,ns,os,pa,z,ee,is,De,rs,ps,cs,Ae,ds,us,ae,fs,Me,ms,hs,ca,N,da,S,F,Se,se,gs,Oe,vs,ua,b,$s,Le,_s,Es,Te,js,xs,He,ks,ws,fa,ke,te,ys,Ue,bs,qs,ma,le,ha,ne,oe,Ps,Ne,zs,Cs,ga,ie,va,we,Ds,$a,re,_a,j,As,Fe,Ms,Ss,Ie,Os,Ls,Re,Ts,Hs,Je,Us,Ns,Ea,pe,ja,O,I,Ke,ce,Fs,We,Is,xa,x,Rs,Be,Js,Ks,de,Ws,Bs,Ge,Gs,Qs,Qe,Vs,Xs,ka,ue,wa,R,Ys,Ve,Zs,et,ya,fe,ba,J,at,Xe,st,tt,qa,me,Pa,L,K,Ye,he,lt,Ze,nt,za,W,ot,ea,it,rt,Ca,q,pt,ge,ct,dt,ve,ut,ft,aa,mt,ht,Da,$e,Aa,B,gt,sa,vt,$t,Ma,_e,Sa,T,G,ta,Ee,_t,la,Et,Oa,Q,jt,na,xt,kt,La,ye,wt,Ta,be,qe,yt,Ha,je,Ua;return k=new oa({}),N=new yl({props:{$$slots:{default:[bl]},$$scope:{ctx:ia}}}),se=new oa({}),le=new A({props:{code:`from transformers import pipeline

generator = pipeline(task="text-generation")`,highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> pipeline

<span class="hljs-meta">&gt;&gt;&gt; </span>generator = pipeline(task=<span class="hljs-string">&quot;text-generation&quot;</span>)`}}),ie=new A({props:{code:'generator("Three Rings for the Elven-kings under the sky, Seven for the Dwarf-lords in their halls of stone")',highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span>generator(<span class="hljs-string">&quot;Three Rings for the Elven-kings under the sky, Seven for the Dwarf-lords in their halls of stone&quot;</span>)
[{<span class="hljs-string">&#x27;generated_text&#x27;</span>: <span class="hljs-string">&#x27;Three Rings for the Elven-kings under the sky, Seven for the Dwarf-lords in their halls of stone, Seven for the Iron-priests at the door to the east, and thirteen for the Lord Kings at the end of the mountain&#x27;</span>}]`}}),re=new A({props:{code:`generator(
    [
        "Three Rings for the Elven-kings under the sky, Seven for the Dwarf-lords in their halls of stone",
        "Nine for Mortal Men, doomed to die, One for the Dark Lord on his dark throne",
    ]
)`,highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span>generator(
<span class="hljs-meta">... </span>    [
<span class="hljs-meta">... </span>        <span class="hljs-string">&quot;Three Rings for the Elven-kings under the sky, Seven for the Dwarf-lords in their halls of stone&quot;</span>,
<span class="hljs-meta">... </span>        <span class="hljs-string">&quot;Nine for Mortal Men, doomed to die, One for the Dark Lord on his dark throne&quot;</span>,
<span class="hljs-meta">... </span>    ]
<span class="hljs-meta">... </span>)`}}),pe=new A({props:{code:`generator(
    "Three Rings for the Elven-kings under the sky, Seven for the Dwarf-lords in their halls of stone",
    num_return_sequences=2,
)`,highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span>generator(
<span class="hljs-meta">... </span>    <span class="hljs-string">&quot;Three Rings for the Elven-kings under the sky, Seven for the Dwarf-lords in their halls of stone&quot;</span>,
<span class="hljs-meta">... </span>    num_return_sequences=<span class="hljs-number">2</span>,
<span class="hljs-meta">... </span>)`}}),ce=new oa({}),ue=new A({props:{code:`from transformers import AutoTokenizer, AutoModelForCausalLM

tokenizer = AutoTokenizer.from_pretrained("distilgpt2")
model = AutoModelForCausalLM.from_pretrained("distilgpt2")`,highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoTokenizer, AutoModelForCausalLM

<span class="hljs-meta">&gt;&gt;&gt; </span>tokenizer = AutoTokenizer.from_pretrained(<span class="hljs-string">&quot;distilgpt2&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>model = AutoModelForCausalLM.from_pretrained(<span class="hljs-string">&quot;distilgpt2&quot;</span>)`}}),fe=new A({props:{code:`from transformers import pipeline

generator = pipeline(task="text-generation", model=model, tokenizer=tokenizer)`,highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> pipeline

<span class="hljs-meta">&gt;&gt;&gt; </span>generator = pipeline(task=<span class="hljs-string">&quot;text-generation&quot;</span>, model=model, tokenizer=tokenizer)`}}),me=new A({props:{code:'generator("Three Rings for the Elven-kings under the sky, Seven for the Dwarf-lords in their halls of stone")',highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span>generator(<span class="hljs-string">&quot;Three Rings for the Elven-kings under the sky, Seven for the Dwarf-lords in their halls of stone&quot;</span>)
[{<span class="hljs-string">&#x27;generated_text&#x27;</span>: <span class="hljs-string">&#x27;Three Rings for the Elven-kings under the sky, Seven for the Dwarf-lords in their halls of stone, Seven for the Dragon-lords (for them to rule in a world ruled by their rulers, and all who live within the realm&#x27;</span>}]`}}),he=new oa({}),$e=new A({props:{code:`from transformers import pipeline

audio_classifier = pipeline(
    task="audio-classification", model="ehcalabres/wav2vec2-lg-xlsr-en-speech-emotion-recognition"
)`,highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> pipeline

<span class="hljs-meta">&gt;&gt;&gt; </span>audio_classifier = pipeline(
<span class="hljs-meta">... </span>    task=<span class="hljs-string">&quot;audio-classification&quot;</span>, model=<span class="hljs-string">&quot;ehcalabres/wav2vec2-lg-xlsr-en-speech-emotion-recognition&quot;</span>
<span class="hljs-meta">... </span>)`}}),_e=new A({props:{code:'audio_classifier("jfk_moon_speech.wav")',highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span>audio_classifier(<span class="hljs-string">&quot;jfk_moon_speech.wav&quot;</span>)
[{<span class="hljs-string">&#x27;label&#x27;</span>: <span class="hljs-string">&#x27;calm&#x27;</span>, <span class="hljs-string">&#x27;score&#x27;</span>: <span class="hljs-number">0.13856211304664612</span>},
 {<span class="hljs-string">&#x27;label&#x27;</span>: <span class="hljs-string">&#x27;disgust&#x27;</span>, <span class="hljs-string">&#x27;score&#x27;</span>: <span class="hljs-number">0.13148026168346405</span>},
 {<span class="hljs-string">&#x27;label&#x27;</span>: <span class="hljs-string">&#x27;happy&#x27;</span>, <span class="hljs-string">&#x27;score&#x27;</span>: <span class="hljs-number">0.12635163962841034</span>},
 {<span class="hljs-string">&#x27;label&#x27;</span>: <span class="hljs-string">&#x27;angry&#x27;</span>, <span class="hljs-string">&#x27;score&#x27;</span>: <span class="hljs-number">0.12439591437578201</span>},
 {<span class="hljs-string">&#x27;label&#x27;</span>: <span class="hljs-string">&#x27;fearful&#x27;</span>, <span class="hljs-string">&#x27;score&#x27;</span>: <span class="hljs-number">0.12404385954141617</span>}]`}}),Ee=new oa({}),je=new A({props:{code:`from transformers import pipeline

vision_classifier = pipeline(task="image-classification")
vision_classifier(
    images="https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/pipeline-cat-chonk.jpeg"
)`,highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> pipeline

<span class="hljs-meta">&gt;&gt;&gt; </span>vision_classifier = pipeline(task=<span class="hljs-string">&quot;image-classification&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>vision_classifier(
<span class="hljs-meta">... </span>    images=<span class="hljs-string">&quot;https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/pipeline-cat-chonk.jpeg&quot;</span>
<span class="hljs-meta">... </span>)
[{<span class="hljs-string">&#x27;label&#x27;</span>: <span class="hljs-string">&#x27;lynx, catamount&#x27;</span>, <span class="hljs-string">&#x27;score&#x27;</span>: <span class="hljs-number">0.4403027892112732</span>},
 {<span class="hljs-string">&#x27;label&#x27;</span>: <span class="hljs-string">&#x27;cougar, puma, catamount, mountain lion, painter, panther, Felis concolor&#x27;</span>,
  <span class="hljs-string">&#x27;score&#x27;</span>: <span class="hljs-number">0.03433405980467796</span>},
 {<span class="hljs-string">&#x27;label&#x27;</span>: <span class="hljs-string">&#x27;snow leopard, ounce, Panthera uncia&#x27;</span>,
  <span class="hljs-string">&#x27;score&#x27;</span>: <span class="hljs-number">0.032148055732250214</span>},
 {<span class="hljs-string">&#x27;label&#x27;</span>: <span class="hljs-string">&#x27;Egyptian cat&#x27;</span>, <span class="hljs-string">&#x27;score&#x27;</span>: <span class="hljs-number">0.02353910356760025</span>},
 {<span class="hljs-string">&#x27;label&#x27;</span>: <span class="hljs-string">&#x27;tiger cat&#x27;</span>, <span class="hljs-string">&#x27;score&#x27;</span>: <span class="hljs-number">0.023034192621707916</span>}]`}}),{c(){f=n("meta"),H=c(),E=n("h1"),w=n("a"),M=n("span"),m(k.$$.fragment),P=c(),U=n("span"),Za=t("Pipelines para inferencia"),ra=c(),y=n("p"),es=t("Un "),ze=n("code"),as=t("pipeline()"),ss=t(" simplifica el uso de cualquier modelo del "),Z=n("a"),ts=t("Model Hub"),ls=t(" para la inferencia en una variedad de tareas como la generaci\xF3n de texto, la segmentaci\xF3n de im\xE1genes y la clasificaci\xF3n de audio. Incluso si no tienes experiencia con una modalidad espec\xEDfica o no comprendes el c\xF3digo que alimenta los modelos, \xA1a\xFAn puedes usarlos con el "),Ce=n("code"),ns=t("pipeline()"),os=t("! Este tutorial te ense\xF1ar\xE1 a:"),pa=c(),z=n("ul"),ee=n("li"),is=t("Utilizar un "),De=n("code"),rs=t("pipeline()"),ps=t(" para inferencia."),cs=c(),Ae=n("li"),ds=t("Utilizar un tokenizador o modelo espec\xEDfico."),us=c(),ae=n("li"),fs=t("Utilizar un "),Me=n("code"),ms=t("pipeline()"),hs=t(" para tareas de audio y visi\xF3n."),ca=c(),m(N.$$.fragment),da=c(),S=n("h2"),F=n("a"),Se=n("span"),m(se.$$.fragment),gs=c(),Oe=n("span"),vs=t("Uso del pipeline"),ua=c(),b=n("p"),$s=t("Si bien cada tarea tiene un "),Le=n("code"),_s=t("pipeline()"),Es=t(" asociado, es m\xE1s sencillo usar la abstracci\xF3n general "),Te=n("code"),js=t("pipeline()"),xs=t(" que contiene todos los pipelines de tareas espec\xEDficas. El "),He=n("code"),ks=t("pipeline()"),ws=t(" carga autom\xE1ticamente un modelo predeterminado y un tokenizador con capacidad de inferencia para tu tarea."),fa=c(),ke=n("ol"),te=n("li"),ys=t("Comienza creando un "),Ue=n("code"),bs=t("pipeline()"),qs=t(" y espec\xEDfica una tarea de inferencia:"),ma=c(),m(le.$$.fragment),ha=c(),ne=n("ol"),oe=n("li"),Ps=t("Pasa tu texto de entrada al "),Ne=n("code"),zs=t("pipeline()"),Cs=t(":"),ga=c(),m(ie.$$.fragment),va=c(),we=n("p"),Ds=t("Si tienes m\xE1s de una entrada, p\xE1sala como una lista:"),$a=c(),m(re.$$.fragment),_a=c(),j=n("p"),As=t("Cualquier par\xE1metro adicional para tu tarea tambi\xE9n se puede incluir en el "),Fe=n("code"),Ms=t("pipeline()"),Ss=t(". La tarea "),Ie=n("code"),Os=t("text-generation"),Ls=t(" tiene un m\xE9todo "),Re=n("code"),Ts=t("generate()"),Hs=t(" con varios par\xE1metros para controlar la salida. Por ejemplo, si deseas generar m\xE1s de una salida, def\xEDnelo en el par\xE1metro "),Je=n("code"),Us=t("num_return_sequences"),Ns=t(":"),Ea=c(),m(pe.$$.fragment),ja=c(),O=n("h3"),I=n("a"),Ke=n("span"),m(ce.$$.fragment),Fs=c(),We=n("span"),Is=t("Selecciona un modelo y un tokenizador"),xa=c(),x=n("p"),Rs=t("El "),Be=n("code"),Js=t("pipeline()"),Ks=t(" acepta cualquier modelo del "),de=n("a"),Ws=t("Model Hub"),Bs=t(". Hay etiquetas en el Model Hub que te permiten filtrar por el modelo que te gustar\xEDa utilizar para tu tarea. Una vez que hayas elegido un modelo apropiado, c\xE1rgalo con la clase "),Ge=n("code"),Gs=t("AutoModelFor"),Qs=t(" y [`AutoTokenizer\u2019] correspondientes. Por ejemplo, carga la clase "),Qe=n("code"),Vs=t("AutoModelForCausalLM"),Xs=t(" para una tarea de modelado de lenguaje causal:"),ka=c(),m(ue.$$.fragment),wa=c(),R=n("p"),Ys=t("Crea un "),Ve=n("code"),Zs=t("pipeline()"),et=t(" para tu tarea y espec\xEDfica el modelo y el tokenizador que cargaste:"),ya=c(),m(fe.$$.fragment),ba=c(),J=n("p"),at=t("Pasa tu texto de entrada a "),Xe=n("code"),st=t("pipeline()"),tt=t(" para generar algo de texto:"),qa=c(),m(me.$$.fragment),Pa=c(),L=n("h2"),K=n("a"),Ye=n("span"),m(he.$$.fragment),lt=c(),Ze=n("span"),nt=t("Pipeline de audio"),za=c(),W=n("p"),ot=t("La flexibilidad de "),ea=n("code"),it=t("pipeline()"),rt=t(" significa que tambi\xE9n se puede extender a tareas de audio."),Ca=c(),q=n("p"),pt=t("Por ejemplo, clasifiquemos la emoci\xF3n de un breve fragmento del famoso discurso de John F. Kennedy "),ge=n("a"),ct=t("\u201CWe choose to go to the Moon\u201D"),dt=t(". Encuentra un modelo de "),ve=n("a"),ut=t("audio classification"),ft=t(" para reconocimiento de emociones en el Model Hub y c\xE1rgalo en el "),aa=n("code"),mt=t("pipeline()"),ht=t(":"),Da=c(),m($e.$$.fragment),Aa=c(),B=n("p"),gt=t("Pasa el archivo de audio al "),sa=n("code"),vt=t("pipeline()"),$t=t(":"),Ma=c(),m(_e.$$.fragment),Sa=c(),T=n("h2"),G=n("a"),ta=n("span"),m(Ee.$$.fragment),_t=c(),la=n("span"),Et=t("Pipeline de visi\xF3n"),Oa=c(),Q=n("p"),jt=t("Finalmente, utilizar un "),na=n("code"),xt=t("pipeline()"),kt=t(" para tareas de visi\xF3n es pr\xE1cticamente igual."),La=c(),ye=n("p"),wt=t("Espec\xEDfica tu tarea de visi\xF3n y pasa tu imagen al clasificador. La imagen puede ser un enlace o una ruta local a la imagen. Por ejemplo, \xBFqu\xE9 especie de gato se muestra a continuaci\xF3n?"),Ta=c(),be=n("p"),qe=n("img"),Ha=c(),m(je.$$.fragment),this.h()},l(e){const i=xl('[data-svelte="svelte-1phssyn"]',document.head);f=o(i,"META",{name:!0,content:!0}),i.forEach(s),H=d(e),E=o(e,"H1",{class:!0});var xe=r(E);w=o(xe,"A",{id:!0,class:!0,href:!0});var bt=r(w);M=o(bt,"SPAN",{});var qt=r(M);h(k.$$.fragment,qt),qt.forEach(s),bt.forEach(s),P=d(xe),U=o(xe,"SPAN",{});var Pt=r(U);Za=l(Pt,"Pipelines para inferencia"),Pt.forEach(s),xe.forEach(s),ra=d(e),y=o(e,"P",{});var V=r(y);es=l(V,"Un "),ze=o(V,"CODE",{});var zt=r(ze);as=l(zt,"pipeline()"),zt.forEach(s),ss=l(V," simplifica el uso de cualquier modelo del "),Z=o(V,"A",{href:!0,rel:!0});var Ct=r(Z);ts=l(Ct,"Model Hub"),Ct.forEach(s),ls=l(V," para la inferencia en una variedad de tareas como la generaci\xF3n de texto, la segmentaci\xF3n de im\xE1genes y la clasificaci\xF3n de audio. Incluso si no tienes experiencia con una modalidad espec\xEDfica o no comprendes el c\xF3digo que alimenta los modelos, \xA1a\xFAn puedes usarlos con el "),Ce=o(V,"CODE",{});var Dt=r(Ce);ns=l(Dt,"pipeline()"),Dt.forEach(s),os=l(V,"! Este tutorial te ense\xF1ar\xE1 a:"),V.forEach(s),pa=d(e),z=o(e,"UL",{});var Pe=r(z);ee=o(Pe,"LI",{});var Na=r(ee);is=l(Na,"Utilizar un "),De=o(Na,"CODE",{});var At=r(De);rs=l(At,"pipeline()"),At.forEach(s),ps=l(Na," para inferencia."),Na.forEach(s),cs=d(Pe),Ae=o(Pe,"LI",{});var Mt=r(Ae);ds=l(Mt,"Utilizar un tokenizador o modelo espec\xEDfico."),Mt.forEach(s),us=d(Pe),ae=o(Pe,"LI",{});var Fa=r(ae);fs=l(Fa,"Utilizar un "),Me=o(Fa,"CODE",{});var St=r(Me);ms=l(St,"pipeline()"),St.forEach(s),hs=l(Fa," para tareas de audio y visi\xF3n."),Fa.forEach(s),Pe.forEach(s),ca=d(e),h(N.$$.fragment,e),da=d(e),S=o(e,"H2",{class:!0});var Ia=r(S);F=o(Ia,"A",{id:!0,class:!0,href:!0});var Ot=r(F);Se=o(Ot,"SPAN",{});var Lt=r(Se);h(se.$$.fragment,Lt),Lt.forEach(s),Ot.forEach(s),gs=d(Ia),Oe=o(Ia,"SPAN",{});var Tt=r(Oe);vs=l(Tt,"Uso del pipeline"),Tt.forEach(s),Ia.forEach(s),ua=d(e),b=o(e,"P",{});var X=r(b);$s=l(X,"Si bien cada tarea tiene un "),Le=o(X,"CODE",{});var Ht=r(Le);_s=l(Ht,"pipeline()"),Ht.forEach(s),Es=l(X," asociado, es m\xE1s sencillo usar la abstracci\xF3n general "),Te=o(X,"CODE",{});var Ut=r(Te);js=l(Ut,"pipeline()"),Ut.forEach(s),xs=l(X," que contiene todos los pipelines de tareas espec\xEDficas. El "),He=o(X,"CODE",{});var Nt=r(He);ks=l(Nt,"pipeline()"),Nt.forEach(s),ws=l(X," carga autom\xE1ticamente un modelo predeterminado y un tokenizador con capacidad de inferencia para tu tarea."),X.forEach(s),fa=d(e),ke=o(e,"OL",{});var Ft=r(ke);te=o(Ft,"LI",{});var Ra=r(te);ys=l(Ra,"Comienza creando un "),Ue=o(Ra,"CODE",{});var It=r(Ue);bs=l(It,"pipeline()"),It.forEach(s),qs=l(Ra," y espec\xEDfica una tarea de inferencia:"),Ra.forEach(s),Ft.forEach(s),ma=d(e),h(le.$$.fragment,e),ha=d(e),ne=o(e,"OL",{start:!0});var Rt=r(ne);oe=o(Rt,"LI",{});var Ja=r(oe);Ps=l(Ja,"Pasa tu texto de entrada al "),Ne=o(Ja,"CODE",{});var Jt=r(Ne);zs=l(Jt,"pipeline()"),Jt.forEach(s),Cs=l(Ja,":"),Ja.forEach(s),Rt.forEach(s),ga=d(e),h(ie.$$.fragment,e),va=d(e),we=o(e,"P",{});var Kt=r(we);Ds=l(Kt,"Si tienes m\xE1s de una entrada, p\xE1sala como una lista:"),Kt.forEach(s),$a=d(e),h(re.$$.fragment,e),_a=d(e),j=o(e,"P",{});var C=r(j);As=l(C,"Cualquier par\xE1metro adicional para tu tarea tambi\xE9n se puede incluir en el "),Fe=o(C,"CODE",{});var Wt=r(Fe);Ms=l(Wt,"pipeline()"),Wt.forEach(s),Ss=l(C,". La tarea "),Ie=o(C,"CODE",{});var Bt=r(Ie);Os=l(Bt,"text-generation"),Bt.forEach(s),Ls=l(C," tiene un m\xE9todo "),Re=o(C,"CODE",{});var Gt=r(Re);Ts=l(Gt,"generate()"),Gt.forEach(s),Hs=l(C," con varios par\xE1metros para controlar la salida. Por ejemplo, si deseas generar m\xE1s de una salida, def\xEDnelo en el par\xE1metro "),Je=o(C,"CODE",{});var Qt=r(Je);Us=l(Qt,"num_return_sequences"),Qt.forEach(s),Ns=l(C,":"),C.forEach(s),Ea=d(e),h(pe.$$.fragment,e),ja=d(e),O=o(e,"H3",{class:!0});var Ka=r(O);I=o(Ka,"A",{id:!0,class:!0,href:!0});var Vt=r(I);Ke=o(Vt,"SPAN",{});var Xt=r(Ke);h(ce.$$.fragment,Xt),Xt.forEach(s),Vt.forEach(s),Fs=d(Ka),We=o(Ka,"SPAN",{});var Yt=r(We);Is=l(Yt,"Selecciona un modelo y un tokenizador"),Yt.forEach(s),Ka.forEach(s),xa=d(e),x=o(e,"P",{});var D=r(x);Rs=l(D,"El "),Be=o(D,"CODE",{});var Zt=r(Be);Js=l(Zt,"pipeline()"),Zt.forEach(s),Ks=l(D," acepta cualquier modelo del "),de=o(D,"A",{href:!0,rel:!0});var el=r(de);Ws=l(el,"Model Hub"),el.forEach(s),Bs=l(D,". Hay etiquetas en el Model Hub que te permiten filtrar por el modelo que te gustar\xEDa utilizar para tu tarea. Una vez que hayas elegido un modelo apropiado, c\xE1rgalo con la clase "),Ge=o(D,"CODE",{});var al=r(Ge);Gs=l(al,"AutoModelFor"),al.forEach(s),Qs=l(D," y [`AutoTokenizer\u2019] correspondientes. Por ejemplo, carga la clase "),Qe=o(D,"CODE",{});var sl=r(Qe);Vs=l(sl,"AutoModelForCausalLM"),sl.forEach(s),Xs=l(D," para una tarea de modelado de lenguaje causal:"),D.forEach(s),ka=d(e),h(ue.$$.fragment,e),wa=d(e),R=o(e,"P",{});var Wa=r(R);Ys=l(Wa,"Crea un "),Ve=o(Wa,"CODE",{});var tl=r(Ve);Zs=l(tl,"pipeline()"),tl.forEach(s),et=l(Wa," para tu tarea y espec\xEDfica el modelo y el tokenizador que cargaste:"),Wa.forEach(s),ya=d(e),h(fe.$$.fragment,e),ba=d(e),J=o(e,"P",{});var Ba=r(J);at=l(Ba,"Pasa tu texto de entrada a "),Xe=o(Ba,"CODE",{});var ll=r(Xe);st=l(ll,"pipeline()"),ll.forEach(s),tt=l(Ba," para generar algo de texto:"),Ba.forEach(s),qa=d(e),h(me.$$.fragment,e),Pa=d(e),L=o(e,"H2",{class:!0});var Ga=r(L);K=o(Ga,"A",{id:!0,class:!0,href:!0});var nl=r(K);Ye=o(nl,"SPAN",{});var ol=r(Ye);h(he.$$.fragment,ol),ol.forEach(s),nl.forEach(s),lt=d(Ga),Ze=o(Ga,"SPAN",{});var il=r(Ze);nt=l(il,"Pipeline de audio"),il.forEach(s),Ga.forEach(s),za=d(e),W=o(e,"P",{});var Qa=r(W);ot=l(Qa,"La flexibilidad de "),ea=o(Qa,"CODE",{});var rl=r(ea);it=l(rl,"pipeline()"),rl.forEach(s),rt=l(Qa," significa que tambi\xE9n se puede extender a tareas de audio."),Qa.forEach(s),Ca=d(e),q=o(e,"P",{});var Y=r(q);pt=l(Y,"Por ejemplo, clasifiquemos la emoci\xF3n de un breve fragmento del famoso discurso de John F. Kennedy "),ge=o(Y,"A",{href:!0,rel:!0});var pl=r(ge);ct=l(pl,"\u201CWe choose to go to the Moon\u201D"),pl.forEach(s),dt=l(Y,". Encuentra un modelo de "),ve=o(Y,"A",{href:!0,rel:!0});var cl=r(ve);ut=l(cl,"audio classification"),cl.forEach(s),ft=l(Y," para reconocimiento de emociones en el Model Hub y c\xE1rgalo en el "),aa=o(Y,"CODE",{});var dl=r(aa);mt=l(dl,"pipeline()"),dl.forEach(s),ht=l(Y,":"),Y.forEach(s),Da=d(e),h($e.$$.fragment,e),Aa=d(e),B=o(e,"P",{});var Va=r(B);gt=l(Va,"Pasa el archivo de audio al "),sa=o(Va,"CODE",{});var ul=r(sa);vt=l(ul,"pipeline()"),ul.forEach(s),$t=l(Va,":"),Va.forEach(s),Ma=d(e),h(_e.$$.fragment,e),Sa=d(e),T=o(e,"H2",{class:!0});var Xa=r(T);G=o(Xa,"A",{id:!0,class:!0,href:!0});var fl=r(G);ta=o(fl,"SPAN",{});var ml=r(ta);h(Ee.$$.fragment,ml),ml.forEach(s),fl.forEach(s),_t=d(Xa),la=o(Xa,"SPAN",{});var hl=r(la);Et=l(hl,"Pipeline de visi\xF3n"),hl.forEach(s),Xa.forEach(s),Oa=d(e),Q=o(e,"P",{});var Ya=r(Q);jt=l(Ya,"Finalmente, utilizar un "),na=o(Ya,"CODE",{});var gl=r(na);xt=l(gl,"pipeline()"),gl.forEach(s),kt=l(Ya," para tareas de visi\xF3n es pr\xE1cticamente igual."),Ya.forEach(s),La=d(e),ye=o(e,"P",{});var vl=r(ye);wt=l(vl,"Espec\xEDfica tu tarea de visi\xF3n y pasa tu imagen al clasificador. La imagen puede ser un enlace o una ruta local a la imagen. Por ejemplo, \xBFqu\xE9 especie de gato se muestra a continuaci\xF3n?"),vl.forEach(s),Ta=d(e),be=o(e,"P",{});var $l=r(be);qe=o($l,"IMG",{src:!0,alt:!0}),$l.forEach(s),Ha=d(e),h(je.$$.fragment,e),this.h()},h(){u(f,"name","hf:doc:metadata"),u(f,"content",JSON.stringify(Pl)),u(w,"id","pipelines-para-inferencia"),u(w,"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"),u(w,"href","#pipelines-para-inferencia"),u(E,"class","relative group"),u(Z,"href","https://huggingface.co/models"),u(Z,"rel","nofollow"),u(F,"id","uso-del-pipeline"),u(F,"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"),u(F,"href","#uso-del-pipeline"),u(S,"class","relative group"),u(ne,"start","2"),u(I,"id","selecciona-un-modelo-y-un-tokenizador"),u(I,"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"),u(I,"href","#selecciona-un-modelo-y-un-tokenizador"),u(O,"class","relative group"),u(de,"href","https://huggingface.co/models"),u(de,"rel","nofollow"),u(K,"id","pipeline-de-audio"),u(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"),u(K,"href","#pipeline-de-audio"),u(L,"class","relative group"),u(ge,"href","https://en.wikipedia.org/wiki/We_choose_to_go_to_the_Moon"),u(ge,"rel","nofollow"),u(ve,"href","https://huggingface.co/models?pipeline_tag=audio-classification"),u(ve,"rel","nofollow"),u(G,"id","pipeline-de-visin"),u(G,"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"),u(G,"href","#pipeline-de-visin"),u(T,"class","relative group"),kl(qe.src,yt="https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/pipeline-cat-chonk.jpeg")||u(qe,"src",yt),u(qe,"alt","pipeline-cat-chonk")},m(e,i){a(document.head,f),p(e,H,i),p(e,E,i),a(E,w),a(w,M),g(k,M,null),a(E,P),a(E,U),a(U,Za),p(e,ra,i),p(e,y,i),a(y,es),a(y,ze),a(ze,as),a(y,ss),a(y,Z),a(Z,ts),a(y,ls),a(y,Ce),a(Ce,ns),a(y,os),p(e,pa,i),p(e,z,i),a(z,ee),a(ee,is),a(ee,De),a(De,rs),a(ee,ps),a(z,cs),a(z,Ae),a(Ae,ds),a(z,us),a(z,ae),a(ae,fs),a(ae,Me),a(Me,ms),a(ae,hs),p(e,ca,i),g(N,e,i),p(e,da,i),p(e,S,i),a(S,F),a(F,Se),g(se,Se,null),a(S,gs),a(S,Oe),a(Oe,vs),p(e,ua,i),p(e,b,i),a(b,$s),a(b,Le),a(Le,_s),a(b,Es),a(b,Te),a(Te,js),a(b,xs),a(b,He),a(He,ks),a(b,ws),p(e,fa,i),p(e,ke,i),a(ke,te),a(te,ys),a(te,Ue),a(Ue,bs),a(te,qs),p(e,ma,i),g(le,e,i),p(e,ha,i),p(e,ne,i),a(ne,oe),a(oe,Ps),a(oe,Ne),a(Ne,zs),a(oe,Cs),p(e,ga,i),g(ie,e,i),p(e,va,i),p(e,we,i),a(we,Ds),p(e,$a,i),g(re,e,i),p(e,_a,i),p(e,j,i),a(j,As),a(j,Fe),a(Fe,Ms),a(j,Ss),a(j,Ie),a(Ie,Os),a(j,Ls),a(j,Re),a(Re,Ts),a(j,Hs),a(j,Je),a(Je,Us),a(j,Ns),p(e,Ea,i),g(pe,e,i),p(e,ja,i),p(e,O,i),a(O,I),a(I,Ke),g(ce,Ke,null),a(O,Fs),a(O,We),a(We,Is),p(e,xa,i),p(e,x,i),a(x,Rs),a(x,Be),a(Be,Js),a(x,Ks),a(x,de),a(de,Ws),a(x,Bs),a(x,Ge),a(Ge,Gs),a(x,Qs),a(x,Qe),a(Qe,Vs),a(x,Xs),p(e,ka,i),g(ue,e,i),p(e,wa,i),p(e,R,i),a(R,Ys),a(R,Ve),a(Ve,Zs),a(R,et),p(e,ya,i),g(fe,e,i),p(e,ba,i),p(e,J,i),a(J,at),a(J,Xe),a(Xe,st),a(J,tt),p(e,qa,i),g(me,e,i),p(e,Pa,i),p(e,L,i),a(L,K),a(K,Ye),g(he,Ye,null),a(L,lt),a(L,Ze),a(Ze,nt),p(e,za,i),p(e,W,i),a(W,ot),a(W,ea),a(ea,it),a(W,rt),p(e,Ca,i),p(e,q,i),a(q,pt),a(q,ge),a(ge,ct),a(q,dt),a(q,ve),a(ve,ut),a(q,ft),a(q,aa),a(aa,mt),a(q,ht),p(e,Da,i),g($e,e,i),p(e,Aa,i),p(e,B,i),a(B,gt),a(B,sa),a(sa,vt),a(B,$t),p(e,Ma,i),g(_e,e,i),p(e,Sa,i),p(e,T,i),a(T,G),a(G,ta),g(Ee,ta,null),a(T,_t),a(T,la),a(la,Et),p(e,Oa,i),p(e,Q,i),a(Q,jt),a(Q,na),a(na,xt),a(Q,kt),p(e,La,i),p(e,ye,i),a(ye,wt),p(e,Ta,i),p(e,be,i),a(be,qe),p(e,Ha,i),g(je,e,i),Ua=!0},p(e,[i]){const xe={};i&2&&(xe.$$scope={dirty:i,ctx:e}),N.$set(xe)},i(e){Ua||(v(k.$$.fragment,e),v(N.$$.fragment,e),v(se.$$.fragment,e),v(le.$$.fragment,e),v(ie.$$.fragment,e),v(re.$$.fragment,e),v(pe.$$.fragment,e),v(ce.$$.fragment,e),v(ue.$$.fragment,e),v(fe.$$.fragment,e),v(me.$$.fragment,e),v(he.$$.fragment,e),v($e.$$.fragment,e),v(_e.$$.fragment,e),v(Ee.$$.fragment,e),v(je.$$.fragment,e),Ua=!0)},o(e){$(k.$$.fragment,e),$(N.$$.fragment,e),$(se.$$.fragment,e),$(le.$$.fragment,e),$(ie.$$.fragment,e),$(re.$$.fragment,e),$(pe.$$.fragment,e),$(ce.$$.fragment,e),$(ue.$$.fragment,e),$(fe.$$.fragment,e),$(me.$$.fragment,e),$(he.$$.fragment,e),$($e.$$.fragment,e),$(_e.$$.fragment,e),$(Ee.$$.fragment,e),$(je.$$.fragment,e),Ua=!1},d(e){s(f),e&&s(H),e&&s(E),_(k),e&&s(ra),e&&s(y),e&&s(pa),e&&s(z),e&&s(ca),_(N,e),e&&s(da),e&&s(S),_(se),e&&s(ua),e&&s(b),e&&s(fa),e&&s(ke),e&&s(ma),_(le,e),e&&s(ha),e&&s(ne),e&&s(ga),_(ie,e),e&&s(va),e&&s(we),e&&s($a),_(re,e),e&&s(_a),e&&s(j),e&&s(Ea),_(pe,e),e&&s(ja),e&&s(O),_(ce),e&&s(xa),e&&s(x),e&&s(ka),_(ue,e),e&&s(wa),e&&s(R),e&&s(ya),_(fe,e),e&&s(ba),e&&s(J),e&&s(qa),_(me,e),e&&s(Pa),e&&s(L),_(he),e&&s(za),e&&s(W),e&&s(Ca),e&&s(q),e&&s(Da),_($e,e),e&&s(Aa),e&&s(B),e&&s(Ma),_(_e,e),e&&s(Sa),e&&s(T),_(Ee),e&&s(Oa),e&&s(Q),e&&s(La),e&&s(ye),e&&s(Ta),e&&s(be),e&&s(Ha),_(je,e)}}}const Pl={local:"pipelines-para-inferencia",sections:[{local:"uso-del-pipeline",sections:[{local:"selecciona-un-modelo-y-un-tokenizador",title:"Selecciona un modelo y un tokenizador"}],title:"Uso del pipeline"},{local:"pipeline-de-audio",title:"Pipeline de audio"},{local:"pipeline-de-visin",title:"Pipeline de visi\xF3n"}],title:"Pipelines para inferencia"};function zl(ia){return wl(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class Sl extends _l{constructor(f){super();El(this,f,zl,ql,jl,{})}}export{Sl as default,Pl as metadata};
