import{S as Ut,i as $t,s as wt,e as n,k as c,w as h,t as s,M as _t,c as o,d as l,m as d,a as r,x as y,h as t,b as u,N as xt,G as a,g as p,y as g,q as M,o as v,B as j,v as kt}from"../chunks/vendor-hf-doc-builder.js";import{T as Jt}from"../chunks/Tip-hf-doc-builder.js";import{I as ia}from"../chunks/IconCopyLink-hf-doc-builder.js";import{C as I}from"../chunks/CodeBlock-hf-doc-builder.js";function Zt(ra){let m,z,b,$,G;return{c(){m=n("p"),z=s("Echa un vistazo a la documentaci\xF3n de "),b=n("code"),$=s("pipeline()"),G=s(" para obtener una lista completa de tareas admitidas.")},l(U){m=o(U,"P",{});var J=r(m);z=t(J,"Echa un vistazo a la documentaci\xF3n de "),b=o(J,"CODE",{});var V=r(b);$=t(V,"pipeline()"),V.forEach(l),G=t(J," para obtener una lista completa de tareas admitidas."),J.forEach(l)},m(U,J){p(U,m,J),a(m,z),a(m,b),a(b,$),a(m,G)},d(U){U&&l(m)}}}function Tt(ra){let m,z,b,$,G,U,J,V,el,pa,w,al,Je,ll,sl,K,tl,nl,Ze,ol,il,ca,Z,ee,rl,Te,pl,cl,dl,Ie,ul,ml,ae,fl,Ge,hl,yl,da,P,ua,C,R,Ce,le,gl,We,Ml,ma,_,vl,Be,jl,bl,qe,El,Ul,ze,$l,wl,fa,Ue,se,_l,Ve,xl,kl,ha,te,ya,ne,oe,Jl,Pe,Zl,Tl,ga,ie,Ma,$e,Il,va,re,ja,E,Gl,Re,Cl,Wl,Se,Bl,ql,Ae,zl,Vl,Xe,Pl,Rl,ba,pe,Ea,W,S,De,ce,Sl,He,Al,Ua,f,Xl,Ne,Dl,Hl,de,Nl,Fl,Fe,Yl,Ol,Ye,Ll,Ql,Oe,Kl,es,$a,ue,wa,A,as,Le,ls,ss,_a,me,xa,X,ts,Qe,ns,os,ka,fe,Ja,B,D,Ke,he,is,ea,rs,Za,H,ps,aa,cs,ds,Ta,x,us,ye,ms,fs,ge,hs,ys,la,gs,Ms,Ia,Me,Ga,N,vs,sa,js,bs,Ca,ve,Wa,q,F,ta,je,Es,na,Us,Ba,Y,$s,oa,ws,_s,qa,we,xs,za,_e,xe,ks,Va,be,Pa;return U=new ia({}),P=new Jt({props:{$$slots:{default:[Zt]},$$scope:{ctx:ra}}}),le=new ia({}),te=new I({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMHBpcGVsaW5lJTBBJTBBZ2VuZXJhdG9yJTIwJTNEJTIwcGlwZWxpbmUodGFzayUzRCUyMnRleHQtZ2VuZXJhdGlvbiUyMik=",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 I({props:{code:"Z2VuZXJhdG9yKCUyMlRocmVlJTIwUmluZ3MlMjBmb3IlMjB0aGUlMjBFbHZlbi1raW5ncyUyMHVuZGVyJTIwdGhlJTIwc2t5JTJDJTIwU2V2ZW4lMjBmb3IlMjB0aGUlMjBEd2FyZi1sb3JkcyUyMGluJTIwdGhlaXIlMjBoYWxscyUyMG9mJTIwc3RvbmUlMjIp",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 I({props:{code:"Z2VuZXJhdG9yKCUwQSUyMCUyMCUyMCUyMCU1QiUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMlRocmVlJTIwUmluZ3MlMjBmb3IlMjB0aGUlMjBFbHZlbi1raW5ncyUyMHVuZGVyJTIwdGhlJTIwc2t5JTJDJTIwU2V2ZW4lMjBmb3IlMjB0aGUlMjBEd2FyZi1sb3JkcyUyMGluJTIwdGhlaXIlMjBoYWxscyUyMG9mJTIwc3RvbmUlMjIlMkMlMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjJOaW5lJTIwZm9yJTIwTW9ydGFsJTIwTWVuJTJDJTIwZG9vbWVkJTIwdG8lMjBkaWUlMkMlMjBPbmUlMjBmb3IlMjB0aGUlMjBEYXJrJTIwTG9yZCUyMG9uJTIwaGlzJTIwZGFyayUyMHRocm9uZSUyMiUyQyUwQSUyMCUyMCUyMCUyMCU1RCUwQSk=",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 I({props:{code:"Z2VuZXJhdG9yKCUwQSUyMCUyMCUyMCUyMCUyMlRocmVlJTIwUmluZ3MlMjBmb3IlMjB0aGUlMjBFbHZlbi1raW5ncyUyMHVuZGVyJTIwdGhlJTIwc2t5JTJDJTIwU2V2ZW4lMjBmb3IlMjB0aGUlMjBEd2FyZi1sb3JkcyUyMGluJTIwdGhlaXIlMjBoYWxscyUyMG9mJTIwc3RvbmUlMjIlMkMlMEElMjAlMjAlMjAlMjBudW1fcmV0dXJuX3NlcXVlbmNlcyUzRDIlMkMlMEEp",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 ia({}),ue=new I({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMEF1dG9Ub2tlbml6ZXIlMkMlMjBBdXRvTW9kZWxGb3JDYXVzYWxMTSUwQSUwQXRva2VuaXplciUyMCUzRCUyMEF1dG9Ub2tlbml6ZXIuZnJvbV9wcmV0cmFpbmVkKCUyMmRpc3RpbGdwdDIlMjIpJTBBbW9kZWwlMjAlM0QlMjBBdXRvTW9kZWxGb3JDYXVzYWxMTS5mcm9tX3ByZXRyYWluZWQoJTIyZGlzdGlsZ3B0MiUyMik=",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>)`}}),me=new I({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMHBpcGVsaW5lJTBBJTBBZ2VuZXJhdG9yJTIwJTNEJTIwcGlwZWxpbmUodGFzayUzRCUyMnRleHQtZ2VuZXJhdGlvbiUyMiUyQyUyMG1vZGVsJTNEbW9kZWwlMkMlMjB0b2tlbml6ZXIlM0R0b2tlbml6ZXIp",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)`}}),fe=new I({props:{code:"Z2VuZXJhdG9yKCUyMlRocmVlJTIwUmluZ3MlMjBmb3IlMjB0aGUlMjBFbHZlbi1raW5ncyUyMHVuZGVyJTIwdGhlJTIwc2t5JTJDJTIwU2V2ZW4lMjBmb3IlMjB0aGUlMjBEd2FyZi1sb3JkcyUyMGluJTIwdGhlaXIlMjBoYWxscyUyMG9mJTIwc3RvbmUlMjIp",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 ia({}),Me=new I({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMHBpcGVsaW5lJTBBJTBBYXVkaW9fY2xhc3NpZmllciUyMCUzRCUyMHBpcGVsaW5lKCUwQSUyMCUyMCUyMCUyMHRhc2slM0QlMjJhdWRpby1jbGFzc2lmaWNhdGlvbiUyMiUyQyUyMG1vZGVsJTNEJTIyZWhjYWxhYnJlcyUyRndhdjJ2ZWMyLWxnLXhsc3ItZW4tc3BlZWNoLWVtb3Rpb24tcmVjb2duaXRpb24lMjIlMEEp",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>)`}}),ve=new I({props:{code:"YXVkaW9fY2xhc3NpZmllciglMjJqZmtfbW9vbl9zcGVlY2gud2F2JTIyKQ==",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>}]`}}),je=new ia({}),be=new I({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMHBpcGVsaW5lJTBBJTBBdmlzaW9uX2NsYXNzaWZpZXIlMjAlM0QlMjBwaXBlbGluZSh0YXNrJTNEJTIyaW1hZ2UtY2xhc3NpZmljYXRpb24lMjIpJTBBdmlzaW9uX2NsYXNzaWZpZXIoJTBBJTIwJTIwJTIwJTIwaW1hZ2VzJTNEJTIyaHR0cHMlM0ElMkYlMkZodWdnaW5nZmFjZS5jbyUyRmRhdGFzZXRzJTJGaHVnZ2luZ2ZhY2UlMkZkb2N1bWVudGF0aW9uLWltYWdlcyUyRnJlc29sdmUlMkZtYWluJTJGcGlwZWxpbmUtY2F0LWNob25rLmpwZWclMjIlMEEp",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(){m=n("meta"),z=c(),b=n("h1"),$=n("a"),G=n("span"),h(U.$$.fragment),J=c(),V=n("span"),el=s("Pipelines para inferencia"),pa=c(),w=n("p"),al=s("Un "),Je=n("code"),ll=s("pipeline()"),sl=s(" simplifica el uso de cualquier modelo del "),K=n("a"),tl=s("Model Hub"),nl=s(" 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 "),Ze=n("code"),ol=s("pipeline()"),il=s("! Este tutorial te ense\xF1ar\xE1 a:"),ca=c(),Z=n("ul"),ee=n("li"),rl=s("Utilizar un "),Te=n("code"),pl=s("pipeline()"),cl=s(" para inferencia."),dl=c(),Ie=n("li"),ul=s("Utilizar un tokenizador o modelo espec\xEDfico."),ml=c(),ae=n("li"),fl=s("Utilizar un "),Ge=n("code"),hl=s("pipeline()"),yl=s(" para tareas de audio y visi\xF3n."),da=c(),h(P.$$.fragment),ua=c(),C=n("h2"),R=n("a"),Ce=n("span"),h(le.$$.fragment),gl=c(),We=n("span"),Ml=s("Uso del pipeline"),ma=c(),_=n("p"),vl=s("Si bien cada tarea tiene un "),Be=n("code"),jl=s("pipeline()"),bl=s(" asociado, es m\xE1s sencillo usar la abstracci\xF3n general "),qe=n("code"),El=s("pipeline()"),Ul=s(" que contiene todos los pipelines de tareas espec\xEDficas. El "),ze=n("code"),$l=s("pipeline()"),wl=s(" carga autom\xE1ticamente un modelo predeterminado y un tokenizador con capacidad de inferencia para tu tarea."),fa=c(),Ue=n("ol"),se=n("li"),_l=s("Comienza creando un "),Ve=n("code"),xl=s("pipeline()"),kl=s(" y espec\xEDfica una tarea de inferencia:"),ha=c(),h(te.$$.fragment),ya=c(),ne=n("ol"),oe=n("li"),Jl=s("Pasa tu texto de entrada al "),Pe=n("code"),Zl=s("pipeline()"),Tl=s(":"),ga=c(),h(ie.$$.fragment),Ma=c(),$e=n("p"),Il=s("Si tienes m\xE1s de una entrada, p\xE1sala como una lista:"),va=c(),h(re.$$.fragment),ja=c(),E=n("p"),Gl=s("Cualquier par\xE1metro adicional para tu tarea tambi\xE9n se puede incluir en el "),Re=n("code"),Cl=s("pipeline()"),Wl=s(". La tarea "),Se=n("code"),Bl=s("text-generation"),ql=s(" tiene un m\xE9todo "),Ae=n("code"),zl=s("generate()"),Vl=s(" con varios par\xE1metros para controlar la salida. Por ejemplo, si deseas generar m\xE1s de una salida, def\xEDnelo en el par\xE1metro "),Xe=n("code"),Pl=s("num_return_sequences"),Rl=s(":"),ba=c(),h(pe.$$.fragment),Ea=c(),W=n("h3"),S=n("a"),De=n("span"),h(ce.$$.fragment),Sl=c(),He=n("span"),Al=s("Selecciona un modelo y un tokenizador"),Ua=c(),f=n("p"),Xl=s("El "),Ne=n("code"),Dl=s("pipeline()"),Hl=s(" acepta cualquier modelo del "),de=n("a"),Nl=s("Model Hub"),Fl=s(". 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 "),Fe=n("code"),Yl=s("AutoModelFor"),Ol=s(" y "),Ye=n("code"),Ll=s("AutoTokenizer"),Ql=s(" correspondientes. Por ejemplo, carga la clase "),Oe=n("code"),Kl=s("AutoModelForCausalLM"),es=s(" para una tarea de modelado de lenguaje causal:"),$a=c(),h(ue.$$.fragment),wa=c(),A=n("p"),as=s("Crea un "),Le=n("code"),ls=s("pipeline()"),ss=s(" para tu tarea y espec\xEDfica el modelo y el tokenizador que cargaste:"),_a=c(),h(me.$$.fragment),xa=c(),X=n("p"),ts=s("Pasa tu texto de entrada a "),Qe=n("code"),ns=s("pipeline()"),os=s(" para generar algo de texto:"),ka=c(),h(fe.$$.fragment),Ja=c(),B=n("h2"),D=n("a"),Ke=n("span"),h(he.$$.fragment),is=c(),ea=n("span"),rs=s("Pipeline de audio"),Za=c(),H=n("p"),ps=s("La flexibilidad de "),aa=n("code"),cs=s("pipeline()"),ds=s(" significa que tambi\xE9n se puede extender a tareas de audio."),Ta=c(),x=n("p"),us=s("Por ejemplo, clasifiquemos la emoci\xF3n de un breve fragmento del famoso discurso de John F. Kennedy "),ye=n("a"),ms=s("\u201CWe choose to go to the Moon\u201D"),fs=s(". Encuentra un modelo de "),ge=n("a"),hs=s("audio classification"),ys=s(" para reconocimiento de emociones en el Model Hub y c\xE1rgalo en el "),la=n("code"),gs=s("pipeline()"),Ms=s(":"),Ia=c(),h(Me.$$.fragment),Ga=c(),N=n("p"),vs=s("Pasa el archivo de audio al "),sa=n("code"),js=s("pipeline()"),bs=s(":"),Ca=c(),h(ve.$$.fragment),Wa=c(),q=n("h2"),F=n("a"),ta=n("span"),h(je.$$.fragment),Es=c(),na=n("span"),Us=s("Pipeline de visi\xF3n"),Ba=c(),Y=n("p"),$s=s("Finalmente, utilizar un "),oa=n("code"),ws=s("pipeline()"),_s=s(" para tareas de visi\xF3n es pr\xE1cticamente igual."),qa=c(),we=n("p"),xs=s("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?"),za=c(),_e=n("p"),xe=n("img"),Va=c(),h(be.$$.fragment),this.h()},l(e){const i=_t('[data-svelte="svelte-1phssyn"]',document.head);m=o(i,"META",{name:!0,content:!0}),i.forEach(l),z=d(e),b=o(e,"H1",{class:!0});var Ee=r(b);$=o(Ee,"A",{id:!0,class:!0,href:!0});var Js=r($);G=o(Js,"SPAN",{});var Zs=r(G);y(U.$$.fragment,Zs),Zs.forEach(l),Js.forEach(l),J=d(Ee),V=o(Ee,"SPAN",{});var Ts=r(V);el=t(Ts,"Pipelines para inferencia"),Ts.forEach(l),Ee.forEach(l),pa=d(e),w=o(e,"P",{});var O=r(w);al=t(O,"Un "),Je=o(O,"CODE",{});var Is=r(Je);ll=t(Is,"pipeline()"),Is.forEach(l),sl=t(O," simplifica el uso de cualquier modelo del "),K=o(O,"A",{href:!0,rel:!0});var Gs=r(K);tl=t(Gs,"Model Hub"),Gs.forEach(l),nl=t(O," 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 "),Ze=o(O,"CODE",{});var Cs=r(Ze);ol=t(Cs,"pipeline()"),Cs.forEach(l),il=t(O,"! Este tutorial te ense\xF1ar\xE1 a:"),O.forEach(l),ca=d(e),Z=o(e,"UL",{});var ke=r(Z);ee=o(ke,"LI",{});var Ra=r(ee);rl=t(Ra,"Utilizar un "),Te=o(Ra,"CODE",{});var Ws=r(Te);pl=t(Ws,"pipeline()"),Ws.forEach(l),cl=t(Ra," para inferencia."),Ra.forEach(l),dl=d(ke),Ie=o(ke,"LI",{});var Bs=r(Ie);ul=t(Bs,"Utilizar un tokenizador o modelo espec\xEDfico."),Bs.forEach(l),ml=d(ke),ae=o(ke,"LI",{});var Sa=r(ae);fl=t(Sa,"Utilizar un "),Ge=o(Sa,"CODE",{});var qs=r(Ge);hl=t(qs,"pipeline()"),qs.forEach(l),yl=t(Sa," para tareas de audio y visi\xF3n."),Sa.forEach(l),ke.forEach(l),da=d(e),y(P.$$.fragment,e),ua=d(e),C=o(e,"H2",{class:!0});var Aa=r(C);R=o(Aa,"A",{id:!0,class:!0,href:!0});var zs=r(R);Ce=o(zs,"SPAN",{});var Vs=r(Ce);y(le.$$.fragment,Vs),Vs.forEach(l),zs.forEach(l),gl=d(Aa),We=o(Aa,"SPAN",{});var Ps=r(We);Ml=t(Ps,"Uso del pipeline"),Ps.forEach(l),Aa.forEach(l),ma=d(e),_=o(e,"P",{});var L=r(_);vl=t(L,"Si bien cada tarea tiene un "),Be=o(L,"CODE",{});var Rs=r(Be);jl=t(Rs,"pipeline()"),Rs.forEach(l),bl=t(L," asociado, es m\xE1s sencillo usar la abstracci\xF3n general "),qe=o(L,"CODE",{});var Ss=r(qe);El=t(Ss,"pipeline()"),Ss.forEach(l),Ul=t(L," que contiene todos los pipelines de tareas espec\xEDficas. El "),ze=o(L,"CODE",{});var As=r(ze);$l=t(As,"pipeline()"),As.forEach(l),wl=t(L," carga autom\xE1ticamente un modelo predeterminado y un tokenizador con capacidad de inferencia para tu tarea."),L.forEach(l),fa=d(e),Ue=o(e,"OL",{});var Xs=r(Ue);se=o(Xs,"LI",{});var Xa=r(se);_l=t(Xa,"Comienza creando un "),Ve=o(Xa,"CODE",{});var Ds=r(Ve);xl=t(Ds,"pipeline()"),Ds.forEach(l),kl=t(Xa," y espec\xEDfica una tarea de inferencia:"),Xa.forEach(l),Xs.forEach(l),ha=d(e),y(te.$$.fragment,e),ya=d(e),ne=o(e,"OL",{start:!0});var Hs=r(ne);oe=o(Hs,"LI",{});var Da=r(oe);Jl=t(Da,"Pasa tu texto de entrada al "),Pe=o(Da,"CODE",{});var Ns=r(Pe);Zl=t(Ns,"pipeline()"),Ns.forEach(l),Tl=t(Da,":"),Da.forEach(l),Hs.forEach(l),ga=d(e),y(ie.$$.fragment,e),Ma=d(e),$e=o(e,"P",{});var Fs=r($e);Il=t(Fs,"Si tienes m\xE1s de una entrada, p\xE1sala como una lista:"),Fs.forEach(l),va=d(e),y(re.$$.fragment,e),ja=d(e),E=o(e,"P",{});var T=r(E);Gl=t(T,"Cualquier par\xE1metro adicional para tu tarea tambi\xE9n se puede incluir en el "),Re=o(T,"CODE",{});var Ys=r(Re);Cl=t(Ys,"pipeline()"),Ys.forEach(l),Wl=t(T,". La tarea "),Se=o(T,"CODE",{});var Os=r(Se);Bl=t(Os,"text-generation"),Os.forEach(l),ql=t(T," tiene un m\xE9todo "),Ae=o(T,"CODE",{});var Ls=r(Ae);zl=t(Ls,"generate()"),Ls.forEach(l),Vl=t(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 "),Xe=o(T,"CODE",{});var Qs=r(Xe);Pl=t(Qs,"num_return_sequences"),Qs.forEach(l),Rl=t(T,":"),T.forEach(l),ba=d(e),y(pe.$$.fragment,e),Ea=d(e),W=o(e,"H3",{class:!0});var Ha=r(W);S=o(Ha,"A",{id:!0,class:!0,href:!0});var Ks=r(S);De=o(Ks,"SPAN",{});var et=r(De);y(ce.$$.fragment,et),et.forEach(l),Ks.forEach(l),Sl=d(Ha),He=o(Ha,"SPAN",{});var at=r(He);Al=t(at,"Selecciona un modelo y un tokenizador"),at.forEach(l),Ha.forEach(l),Ua=d(e),f=o(e,"P",{});var k=r(f);Xl=t(k,"El "),Ne=o(k,"CODE",{});var lt=r(Ne);Dl=t(lt,"pipeline()"),lt.forEach(l),Hl=t(k," acepta cualquier modelo del "),de=o(k,"A",{href:!0,rel:!0});var st=r(de);Nl=t(st,"Model Hub"),st.forEach(l),Fl=t(k,". 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 "),Fe=o(k,"CODE",{});var tt=r(Fe);Yl=t(tt,"AutoModelFor"),tt.forEach(l),Ol=t(k," y "),Ye=o(k,"CODE",{});var nt=r(Ye);Ll=t(nt,"AutoTokenizer"),nt.forEach(l),Ql=t(k," correspondientes. Por ejemplo, carga la clase "),Oe=o(k,"CODE",{});var ot=r(Oe);Kl=t(ot,"AutoModelForCausalLM"),ot.forEach(l),es=t(k," para una tarea de modelado de lenguaje causal:"),k.forEach(l),$a=d(e),y(ue.$$.fragment,e),wa=d(e),A=o(e,"P",{});var Na=r(A);as=t(Na,"Crea un "),Le=o(Na,"CODE",{});var it=r(Le);ls=t(it,"pipeline()"),it.forEach(l),ss=t(Na," para tu tarea y espec\xEDfica el modelo y el tokenizador que cargaste:"),Na.forEach(l),_a=d(e),y(me.$$.fragment,e),xa=d(e),X=o(e,"P",{});var Fa=r(X);ts=t(Fa,"Pasa tu texto de entrada a "),Qe=o(Fa,"CODE",{});var rt=r(Qe);ns=t(rt,"pipeline()"),rt.forEach(l),os=t(Fa," para generar algo de texto:"),Fa.forEach(l),ka=d(e),y(fe.$$.fragment,e),Ja=d(e),B=o(e,"H2",{class:!0});var Ya=r(B);D=o(Ya,"A",{id:!0,class:!0,href:!0});var pt=r(D);Ke=o(pt,"SPAN",{});var ct=r(Ke);y(he.$$.fragment,ct),ct.forEach(l),pt.forEach(l),is=d(Ya),ea=o(Ya,"SPAN",{});var dt=r(ea);rs=t(dt,"Pipeline de audio"),dt.forEach(l),Ya.forEach(l),Za=d(e),H=o(e,"P",{});var Oa=r(H);ps=t(Oa,"La flexibilidad de "),aa=o(Oa,"CODE",{});var ut=r(aa);cs=t(ut,"pipeline()"),ut.forEach(l),ds=t(Oa," significa que tambi\xE9n se puede extender a tareas de audio."),Oa.forEach(l),Ta=d(e),x=o(e,"P",{});var Q=r(x);us=t(Q,"Por ejemplo, clasifiquemos la emoci\xF3n de un breve fragmento del famoso discurso de John F. Kennedy "),ye=o(Q,"A",{href:!0,rel:!0});var mt=r(ye);ms=t(mt,"\u201CWe choose to go to the Moon\u201D"),mt.forEach(l),fs=t(Q,". Encuentra un modelo de "),ge=o(Q,"A",{href:!0,rel:!0});var ft=r(ge);hs=t(ft,"audio classification"),ft.forEach(l),ys=t(Q," para reconocimiento de emociones en el Model Hub y c\xE1rgalo en el "),la=o(Q,"CODE",{});var ht=r(la);gs=t(ht,"pipeline()"),ht.forEach(l),Ms=t(Q,":"),Q.forEach(l),Ia=d(e),y(Me.$$.fragment,e),Ga=d(e),N=o(e,"P",{});var La=r(N);vs=t(La,"Pasa el archivo de audio al "),sa=o(La,"CODE",{});var yt=r(sa);js=t(yt,"pipeline()"),yt.forEach(l),bs=t(La,":"),La.forEach(l),Ca=d(e),y(ve.$$.fragment,e),Wa=d(e),q=o(e,"H2",{class:!0});var Qa=r(q);F=o(Qa,"A",{id:!0,class:!0,href:!0});var gt=r(F);ta=o(gt,"SPAN",{});var Mt=r(ta);y(je.$$.fragment,Mt),Mt.forEach(l),gt.forEach(l),Es=d(Qa),na=o(Qa,"SPAN",{});var vt=r(na);Us=t(vt,"Pipeline de visi\xF3n"),vt.forEach(l),Qa.forEach(l),Ba=d(e),Y=o(e,"P",{});var Ka=r(Y);$s=t(Ka,"Finalmente, utilizar un "),oa=o(Ka,"CODE",{});var jt=r(oa);ws=t(jt,"pipeline()"),jt.forEach(l),_s=t(Ka," para tareas de visi\xF3n es pr\xE1cticamente igual."),Ka.forEach(l),qa=d(e),we=o(e,"P",{});var bt=r(we);xs=t(bt,"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?"),bt.forEach(l),za=d(e),_e=o(e,"P",{});var Et=r(_e);xe=o(Et,"IMG",{src:!0,alt:!0}),Et.forEach(l),Va=d(e),y(be.$$.fragment,e),this.h()},h(){u(m,"name","hf:doc:metadata"),u(m,"content",JSON.stringify(It)),u($,"id","pipelines-para-inferencia"),u($,"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($,"href","#pipelines-para-inferencia"),u(b,"class","relative group"),u(K,"href","https://huggingface.co/models"),u(K,"rel","nofollow"),u(R,"id","uso-del-pipeline"),u(R,"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(R,"href","#uso-del-pipeline"),u(C,"class","relative group"),u(ne,"start","2"),u(S,"id","selecciona-un-modelo-y-un-tokenizador"),u(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"),u(S,"href","#selecciona-un-modelo-y-un-tokenizador"),u(W,"class","relative group"),u(de,"href","https://huggingface.co/models"),u(de,"rel","nofollow"),u(D,"id","pipeline-de-audio"),u(D,"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(D,"href","#pipeline-de-audio"),u(B,"class","relative group"),u(ye,"href","https://en.wikipedia.org/wiki/We_choose_to_go_to_the_Moon"),u(ye,"rel","nofollow"),u(ge,"href","https://huggingface.co/models?pipeline_tag=audio-classification"),u(ge,"rel","nofollow"),u(F,"id","pipeline-de-visin"),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","#pipeline-de-visin"),u(q,"class","relative group"),xt(xe.src,ks="https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/pipeline-cat-chonk.jpeg")||u(xe,"src",ks),u(xe,"alt","pipeline-cat-chonk")},m(e,i){a(document.head,m),p(e,z,i),p(e,b,i),a(b,$),a($,G),g(U,G,null),a(b,J),a(b,V),a(V,el),p(e,pa,i),p(e,w,i),a(w,al),a(w,Je),a(Je,ll),a(w,sl),a(w,K),a(K,tl),a(w,nl),a(w,Ze),a(Ze,ol),a(w,il),p(e,ca,i),p(e,Z,i),a(Z,ee),a(ee,rl),a(ee,Te),a(Te,pl),a(ee,cl),a(Z,dl),a(Z,Ie),a(Ie,ul),a(Z,ml),a(Z,ae),a(ae,fl),a(ae,Ge),a(Ge,hl),a(ae,yl),p(e,da,i),g(P,e,i),p(e,ua,i),p(e,C,i),a(C,R),a(R,Ce),g(le,Ce,null),a(C,gl),a(C,We),a(We,Ml),p(e,ma,i),p(e,_,i),a(_,vl),a(_,Be),a(Be,jl),a(_,bl),a(_,qe),a(qe,El),a(_,Ul),a(_,ze),a(ze,$l),a(_,wl),p(e,fa,i),p(e,Ue,i),a(Ue,se),a(se,_l),a(se,Ve),a(Ve,xl),a(se,kl),p(e,ha,i),g(te,e,i),p(e,ya,i),p(e,ne,i),a(ne,oe),a(oe,Jl),a(oe,Pe),a(Pe,Zl),a(oe,Tl),p(e,ga,i),g(ie,e,i),p(e,Ma,i),p(e,$e,i),a($e,Il),p(e,va,i),g(re,e,i),p(e,ja,i),p(e,E,i),a(E,Gl),a(E,Re),a(Re,Cl),a(E,Wl),a(E,Se),a(Se,Bl),a(E,ql),a(E,Ae),a(Ae,zl),a(E,Vl),a(E,Xe),a(Xe,Pl),a(E,Rl),p(e,ba,i),g(pe,e,i),p(e,Ea,i),p(e,W,i),a(W,S),a(S,De),g(ce,De,null),a(W,Sl),a(W,He),a(He,Al),p(e,Ua,i),p(e,f,i),a(f,Xl),a(f,Ne),a(Ne,Dl),a(f,Hl),a(f,de),a(de,Nl),a(f,Fl),a(f,Fe),a(Fe,Yl),a(f,Ol),a(f,Ye),a(Ye,Ll),a(f,Ql),a(f,Oe),a(Oe,Kl),a(f,es),p(e,$a,i),g(ue,e,i),p(e,wa,i),p(e,A,i),a(A,as),a(A,Le),a(Le,ls),a(A,ss),p(e,_a,i),g(me,e,i),p(e,xa,i),p(e,X,i),a(X,ts),a(X,Qe),a(Qe,ns),a(X,os),p(e,ka,i),g(fe,e,i),p(e,Ja,i),p(e,B,i),a(B,D),a(D,Ke),g(he,Ke,null),a(B,is),a(B,ea),a(ea,rs),p(e,Za,i),p(e,H,i),a(H,ps),a(H,aa),a(aa,cs),a(H,ds),p(e,Ta,i),p(e,x,i),a(x,us),a(x,ye),a(ye,ms),a(x,fs),a(x,ge),a(ge,hs),a(x,ys),a(x,la),a(la,gs),a(x,Ms),p(e,Ia,i),g(Me,e,i),p(e,Ga,i),p(e,N,i),a(N,vs),a(N,sa),a(sa,js),a(N,bs),p(e,Ca,i),g(ve,e,i),p(e,Wa,i),p(e,q,i),a(q,F),a(F,ta),g(je,ta,null),a(q,Es),a(q,na),a(na,Us),p(e,Ba,i),p(e,Y,i),a(Y,$s),a(Y,oa),a(oa,ws),a(Y,_s),p(e,qa,i),p(e,we,i),a(we,xs),p(e,za,i),p(e,_e,i),a(_e,xe),p(e,Va,i),g(be,e,i),Pa=!0},p(e,[i]){const Ee={};i&2&&(Ee.$$scope={dirty:i,ctx:e}),P.$set(Ee)},i(e){Pa||(M(U.$$.fragment,e),M(P.$$.fragment,e),M(le.$$.fragment,e),M(te.$$.fragment,e),M(ie.$$.fragment,e),M(re.$$.fragment,e),M(pe.$$.fragment,e),M(ce.$$.fragment,e),M(ue.$$.fragment,e),M(me.$$.fragment,e),M(fe.$$.fragment,e),M(he.$$.fragment,e),M(Me.$$.fragment,e),M(ve.$$.fragment,e),M(je.$$.fragment,e),M(be.$$.fragment,e),Pa=!0)},o(e){v(U.$$.fragment,e),v(P.$$.fragment,e),v(le.$$.fragment,e),v(te.$$.fragment,e),v(ie.$$.fragment,e),v(re.$$.fragment,e),v(pe.$$.fragment,e),v(ce.$$.fragment,e),v(ue.$$.fragment,e),v(me.$$.fragment,e),v(fe.$$.fragment,e),v(he.$$.fragment,e),v(Me.$$.fragment,e),v(ve.$$.fragment,e),v(je.$$.fragment,e),v(be.$$.fragment,e),Pa=!1},d(e){l(m),e&&l(z),e&&l(b),j(U),e&&l(pa),e&&l(w),e&&l(ca),e&&l(Z),e&&l(da),j(P,e),e&&l(ua),e&&l(C),j(le),e&&l(ma),e&&l(_),e&&l(fa),e&&l(Ue),e&&l(ha),j(te,e),e&&l(ya),e&&l(ne),e&&l(ga),j(ie,e),e&&l(Ma),e&&l($e),e&&l(va),j(re,e),e&&l(ja),e&&l(E),e&&l(ba),j(pe,e),e&&l(Ea),e&&l(W),j(ce),e&&l(Ua),e&&l(f),e&&l($a),j(ue,e),e&&l(wa),e&&l(A),e&&l(_a),j(me,e),e&&l(xa),e&&l(X),e&&l(ka),j(fe,e),e&&l(Ja),e&&l(B),j(he),e&&l(Za),e&&l(H),e&&l(Ta),e&&l(x),e&&l(Ia),j(Me,e),e&&l(Ga),e&&l(N),e&&l(Ca),j(ve,e),e&&l(Wa),e&&l(q),j(je),e&&l(Ba),e&&l(Y),e&&l(qa),e&&l(we),e&&l(za),e&&l(_e),e&&l(Va),j(be,e)}}}const It={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 Gt(ra){return kt(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class zt extends Ut{constructor(m){super();$t(this,m,Gt,Tt,wt,{})}}export{zt as default,It as metadata};
