import{S as rt,i as it,s as pt,e as n,k as c,w as f,t as l,M as ct,c as r,d as s,m,a as i,x as h,h as t,b as d,N as mt,G as a,g as p,y as g,q as y,o as M,B as v,v as dt}from"../chunks/vendor-hf-doc-builder.js";import{T as ut}from"../chunks/Tip-hf-doc-builder.js";import{I as la}from"../chunks/IconCopyLink-hf-doc-builder.js";import{C as I}from"../chunks/CodeBlock-hf-doc-builder.js";function ft(ta){let u,z,j,x,G;return{c(){u=n("p"),z=l("Acesse a documenta\xE7\xE3o do "),j=n("code"),x=l("pipeline()"),G=l(" para obter uma lista completa de tarefas poss\xEDveis.")},l($){u=r($,"P",{});var E=i(u);z=t(E,"Acesse a documenta\xE7\xE3o do "),j=r(E,"CODE",{});var V=i(j);x=t(V,"pipeline()"),V.forEach(s),G=t(E," para obter uma lista completa de tarefas poss\xEDveis."),E.forEach(s)},m($,E){p($,u,E),a(u,z),a(u,j),a(j,x),a(u,G)},d($){$&&s(u)}}}function ht(ta){let u,z,j,x,G,$,E,V,Ya,oa,P,Oa,L,La,Qa,na,_,Q,Ka,_e,es,as,ss,ke,ls,ts,K,os,Je,ns,rs,ra,A,ia,C,R,Ze,ee,is,Te,ps,pa,w,cs,Ie,ms,ds,Ge,us,fs,Ce,hs,gs,ca,je,ae,ys,We,Ms,vs,ma,se,da,le,te,js,qe,bs,Us,ua,oe,fa,be,$s,ha,ne,ga,b,xs,Be,ws,Es,ze,_s,ks,Ve,Js,Zs,Pe,Ts,Is,ya,re,Ma,W,S,Ae,ie,Gs,Re,Cs,va,U,Ws,Se,qs,Bs,pe,zs,Vs,Xe,Ps,As,He,Rs,Ss,ja,ce,ba,X,Xs,De,Hs,Ds,Ua,me,$a,H,Ns,Ne,Fs,Ys,xa,de,wa,q,D,Fe,ue,Os,Ye,Ls,Ea,k,Qs,Oe,Ks,el,Le,al,sl,_a,J,ll,fe,tl,ol,Qe,nl,rl,ka,he,Ja,N,il,Ke,pl,cl,Za,ge,Ta,B,F,ea,ye,ml,aa,dl,Ia,Y,ul,sa,fl,hl,Ga,Ue,$e,gl,Ca,Me,Wa;return $=new la({}),A=new ut({props:{$$slots:{default:[ft]},$$scope:{ctx:ta}}}),ee=new la({}),se=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>)`}}),oe=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>}]`}}),ne=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>)`}}),re=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>)`}}),ie=new la({}),ce=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)`}}),de=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>}]`}}),ue=new la({}),he=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>)`}}),ge=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>}]`}}),ye=new la({}),Me=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(){u=n("meta"),z=c(),j=n("h1"),x=n("a"),G=n("span"),f($.$$.fragment),E=c(),V=n("span"),Ya=l("Pipelines para infer\xEAncia"),oa=c(),P=n("p"),Oa=l("Um [pipeline] simplifica o uso dos modelos no "),L=n("a"),La=l("Model Hub"),Qa=l(` para a infer\xEAncia de uma diversidade de tarefas,
como a gera\xE7\xE3o de texto, a segmenta\xE7\xE3o de imagens e a classifica\xE7\xE3o de \xE1udio.
Inclusive, se n\xE3o tem experi\xEAncia com alguma modalidade espec\xEDfica ou n\xE3o compreende o c\xF3digo que forma os modelos,
pode usar eles mesmo assim com o [pipeline]! Este tutorial te ensinar\xE1 a:`),na=c(),_=n("ul"),Q=n("li"),Ka=l("Utilizar um "),_e=n("code"),es=l("pipeline()"),as=l(" para infer\xEAncia."),ss=c(),ke=n("li"),ls=l("Utilizar um tokenizador ou model espec\xEDfico."),ts=c(),K=n("li"),os=l("Utilizar um "),Je=n("code"),ns=l("pipeline()"),rs=l(" para tarefas de \xE1udio e vis\xE3o computacional."),ra=c(),f(A.$$.fragment),ia=c(),C=n("h2"),R=n("a"),Ze=n("span"),f(ee.$$.fragment),is=c(),Te=n("span"),ps=l("Uso do pipeline"),pa=c(),w=n("p"),cs=l("Mesmo que cada tarefa tenha um "),Ie=n("code"),ms=l("pipeline()"),ds=l(" associado, \xE9 mais simples usar a abstra\xE7\xE3o geral do "),Ge=n("code"),us=l("pipeline()"),fs=l(` que
cont\xE9m todos os pipelines das tarefas mais espec\xEDficas.
O `),Ce=n("code"),hs=l("pipeline()"),gs=l(` carrega automaticamenta um modelo predeterminado e um tokenizador com capacidade de infer\xEAncia para sua
tarefa.`),ca=c(),je=n("ol"),ae=n("li"),ys=l("Comece carregando um "),We=n("code"),Ms=l("pipeline()"),vs=l(" e especifique uma tarefa de infer\xEAncia:"),ma=c(),f(se.$$.fragment),da=c(),le=n("ol"),te=n("li"),js=l("Passe seu dado de entrada, no caso um texto, ao "),qe=n("code"),bs=l("pipeline()"),Us=l(":"),ua=c(),f(oe.$$.fragment),fa=c(),be=n("p"),$s=l("Se tiver mais de uma entrada, passe-a como uma lista:"),ha=c(),f(ne.$$.fragment),ga=c(),b=n("p"),xs=l("Qualquer par\xE2metro adicional para a sua tarefa tamb\xE9m pode ser inclu\xEDdo no "),Be=n("code"),ws=l("pipeline()"),Es=l(". A tarefa "),ze=n("code"),_s=l("text-generation"),ks=l(` tem um m\xE9todo
`),Ve=n("code"),Js=l("generate()"),Zs=l(` com v\xE1rios par\xE2metros para controlar a sa\xEDda.
Por exemplo, se quiser gerar mais de uma sa\xEDda, defina-a no par\xE2metro `),Pe=n("code"),Ts=l("num_return_sequences"),Is=l(":"),ya=c(),f(re.$$.fragment),Ma=c(),W=n("h3"),S=n("a"),Ae=n("span"),f(ie.$$.fragment),Gs=c(),Re=n("span"),Cs=l("Selecionando um modelo e um tokenizador"),va=c(),U=n("p"),Ws=l("O "),Se=n("code"),qs=l("pipeline()"),Bs=l(" aceita qualquer modelo do "),pe=n("a"),zs=l("Model Hub"),Vs=l(`. H\xE1 r\xF3tulos adicionais no Model Hub
que te permitem filtrar pelo modelo que gostaria de usar para sua tarefa. Uma vez que tiver escolhido o modelo apropriado,
carregue-o com as classes `),Xe=n("code"),Ps=l("AutoModelFor"),As=l(" e [`AutoTokenizer\u2019] correspondentes. Por exemplo, carregue a classe "),He=n("code"),Rs=l("AutoModelForCausalLM"),Ss=l(`
para uma tarefa de modelagem de linguagem causal:`),ja=c(),f(ce.$$.fragment),ba=c(),X=n("p"),Xs=l("Crie uma "),De=n("code"),Hs=l("pipeline()"),Ds=l(" para a sua tarefa e especif\xEDque o modelo e o tokenizador que foram carregados:"),Ua=c(),f(me.$$.fragment),$a=c(),H=n("p"),Ns=l("Passe seu texto de entrada ao "),Ne=n("code"),Fs=l("pipeline()"),Ys=l(" para gerar algum texto:"),xa=c(),f(de.$$.fragment),wa=c(),q=n("h2"),D=n("a"),Fe=n("span"),f(ue.$$.fragment),Os=c(),Ye=n("span"),Ls=l("Pipeline de audio"),Ea=c(),k=n("p"),Qs=l("A flexibilidade do "),Oe=n("code"),Ks=l("pipeline()"),el=l(` significa que tamb\xE9m pode-se extender \xE0s tarefas de \xE1udio.
La flexibilidad de `),Le=n("code"),al=l("pipeline()"),sl=l(" significa que tambi\xE9n se puede extender a tareas de audio."),_a=c(),J=n("p"),ll=l(`Por exemplo, classifiquemos a emo\xE7\xE3o de um breve fragmento do famoso discurso de John F. Kennedy /home/rzimmerdev/dev/transformers/docs/source/pt/pipeline_tutorial.mdx
Encontre um modelo de `),fe=n("a"),tl=l("audio classification"),ol=l(` para
reconhecimento de emo\xE7\xF5es no Model Hub e carregue-o usando o `),Qe=n("code"),nl=l("pipeline()"),rl=l(":"),ka=c(),f(he.$$.fragment),Ja=c(),N=n("p"),il=l("Passe o arquivo de \xE1udio ao "),Ke=n("code"),pl=l("pipeline()"),cl=l(":"),Za=c(),f(ge.$$.fragment),Ta=c(),B=n("h2"),F=n("a"),ea=n("span"),f(ye.$$.fragment),ml=c(),aa=n("span"),dl=l("Pipeline de vis\xE3o computacional"),Ia=c(),Y=n("p"),ul=l("Finalmente, utilizar um "),sa=n("code"),fl=l("pipeline()"),hl=l(` para tarefas de vis\xE3o \xE9 praticamente a mesma coisa.
Especifique a sua tarefa de vis\xE3o e passe a sua imagem ao classificador.
A imagem pode ser um link ou uma rota local \xE0 imagem. Por exemplo, que esp\xE9cie de gato est\xE1 presente na imagem?`),Ga=c(),Ue=n("p"),$e=n("img"),Ca=c(),f(Me.$$.fragment),this.h()},l(e){const o=ct('[data-svelte="svelte-1phssyn"]',document.head);u=r(o,"META",{name:!0,content:!0}),o.forEach(s),z=m(e),j=r(e,"H1",{class:!0});var ve=i(j);x=r(ve,"A",{id:!0,class:!0,href:!0});var yl=i(x);G=r(yl,"SPAN",{});var Ml=i(G);h($.$$.fragment,Ml),Ml.forEach(s),yl.forEach(s),E=m(ve),V=r(ve,"SPAN",{});var vl=i(V);Ya=t(vl,"Pipelines para infer\xEAncia"),vl.forEach(s),ve.forEach(s),oa=m(e),P=r(e,"P",{});var qa=i(P);Oa=t(qa,"Um [pipeline] simplifica o uso dos modelos no "),L=r(qa,"A",{href:!0,rel:!0});var jl=i(L);La=t(jl,"Model Hub"),jl.forEach(s),Qa=t(qa,` para a infer\xEAncia de uma diversidade de tarefas,
como a gera\xE7\xE3o de texto, a segmenta\xE7\xE3o de imagens e a classifica\xE7\xE3o de \xE1udio.
Inclusive, se n\xE3o tem experi\xEAncia com alguma modalidade espec\xEDfica ou n\xE3o compreende o c\xF3digo que forma os modelos,
pode usar eles mesmo assim com o [pipeline]! Este tutorial te ensinar\xE1 a:`),qa.forEach(s),na=m(e),_=r(e,"UL",{});var xe=i(_);Q=r(xe,"LI",{});var Ba=i(Q);Ka=t(Ba,"Utilizar um "),_e=r(Ba,"CODE",{});var bl=i(_e);es=t(bl,"pipeline()"),bl.forEach(s),as=t(Ba," para infer\xEAncia."),Ba.forEach(s),ss=m(xe),ke=r(xe,"LI",{});var Ul=i(ke);ls=t(Ul,"Utilizar um tokenizador ou model espec\xEDfico."),Ul.forEach(s),ts=m(xe),K=r(xe,"LI",{});var za=i(K);os=t(za,"Utilizar um "),Je=r(za,"CODE",{});var $l=i(Je);ns=t($l,"pipeline()"),$l.forEach(s),rs=t(za," para tarefas de \xE1udio e vis\xE3o computacional."),za.forEach(s),xe.forEach(s),ra=m(e),h(A.$$.fragment,e),ia=m(e),C=r(e,"H2",{class:!0});var Va=i(C);R=r(Va,"A",{id:!0,class:!0,href:!0});var xl=i(R);Ze=r(xl,"SPAN",{});var wl=i(Ze);h(ee.$$.fragment,wl),wl.forEach(s),xl.forEach(s),is=m(Va),Te=r(Va,"SPAN",{});var El=i(Te);ps=t(El,"Uso do pipeline"),El.forEach(s),Va.forEach(s),pa=m(e),w=r(e,"P",{});var O=i(w);cs=t(O,"Mesmo que cada tarefa tenha um "),Ie=r(O,"CODE",{});var _l=i(Ie);ms=t(_l,"pipeline()"),_l.forEach(s),ds=t(O," associado, \xE9 mais simples usar a abstra\xE7\xE3o geral do "),Ge=r(O,"CODE",{});var kl=i(Ge);us=t(kl,"pipeline()"),kl.forEach(s),fs=t(O,` que
cont\xE9m todos os pipelines das tarefas mais espec\xEDficas.
O `),Ce=r(O,"CODE",{});var Jl=i(Ce);hs=t(Jl,"pipeline()"),Jl.forEach(s),gs=t(O,` carrega automaticamenta um modelo predeterminado e um tokenizador com capacidade de infer\xEAncia para sua
tarefa.`),O.forEach(s),ca=m(e),je=r(e,"OL",{});var Zl=i(je);ae=r(Zl,"LI",{});var Pa=i(ae);ys=t(Pa,"Comece carregando um "),We=r(Pa,"CODE",{});var Tl=i(We);Ms=t(Tl,"pipeline()"),Tl.forEach(s),vs=t(Pa," e especifique uma tarefa de infer\xEAncia:"),Pa.forEach(s),Zl.forEach(s),ma=m(e),h(se.$$.fragment,e),da=m(e),le=r(e,"OL",{start:!0});var Il=i(le);te=r(Il,"LI",{});var Aa=i(te);js=t(Aa,"Passe seu dado de entrada, no caso um texto, ao "),qe=r(Aa,"CODE",{});var Gl=i(qe);bs=t(Gl,"pipeline()"),Gl.forEach(s),Us=t(Aa,":"),Aa.forEach(s),Il.forEach(s),ua=m(e),h(oe.$$.fragment,e),fa=m(e),be=r(e,"P",{});var Cl=i(be);$s=t(Cl,"Se tiver mais de uma entrada, passe-a como uma lista:"),Cl.forEach(s),ha=m(e),h(ne.$$.fragment,e),ga=m(e),b=r(e,"P",{});var Z=i(b);xs=t(Z,"Qualquer par\xE2metro adicional para a sua tarefa tamb\xE9m pode ser inclu\xEDdo no "),Be=r(Z,"CODE",{});var Wl=i(Be);ws=t(Wl,"pipeline()"),Wl.forEach(s),Es=t(Z,". A tarefa "),ze=r(Z,"CODE",{});var ql=i(ze);_s=t(ql,"text-generation"),ql.forEach(s),ks=t(Z,` tem um m\xE9todo
`),Ve=r(Z,"CODE",{});var Bl=i(Ve);Js=t(Bl,"generate()"),Bl.forEach(s),Zs=t(Z,` com v\xE1rios par\xE2metros para controlar a sa\xEDda.
Por exemplo, se quiser gerar mais de uma sa\xEDda, defina-a no par\xE2metro `),Pe=r(Z,"CODE",{});var zl=i(Pe);Ts=t(zl,"num_return_sequences"),zl.forEach(s),Is=t(Z,":"),Z.forEach(s),ya=m(e),h(re.$$.fragment,e),Ma=m(e),W=r(e,"H3",{class:!0});var Ra=i(W);S=r(Ra,"A",{id:!0,class:!0,href:!0});var Vl=i(S);Ae=r(Vl,"SPAN",{});var Pl=i(Ae);h(ie.$$.fragment,Pl),Pl.forEach(s),Vl.forEach(s),Gs=m(Ra),Re=r(Ra,"SPAN",{});var Al=i(Re);Cs=t(Al,"Selecionando um modelo e um tokenizador"),Al.forEach(s),Ra.forEach(s),va=m(e),U=r(e,"P",{});var T=i(U);Ws=t(T,"O "),Se=r(T,"CODE",{});var Rl=i(Se);qs=t(Rl,"pipeline()"),Rl.forEach(s),Bs=t(T," aceita qualquer modelo do "),pe=r(T,"A",{href:!0,rel:!0});var Sl=i(pe);zs=t(Sl,"Model Hub"),Sl.forEach(s),Vs=t(T,`. H\xE1 r\xF3tulos adicionais no Model Hub
que te permitem filtrar pelo modelo que gostaria de usar para sua tarefa. Uma vez que tiver escolhido o modelo apropriado,
carregue-o com as classes `),Xe=r(T,"CODE",{});var Xl=i(Xe);Ps=t(Xl,"AutoModelFor"),Xl.forEach(s),As=t(T," e [`AutoTokenizer\u2019] correspondentes. Por exemplo, carregue a classe "),He=r(T,"CODE",{});var Hl=i(He);Rs=t(Hl,"AutoModelForCausalLM"),Hl.forEach(s),Ss=t(T,`
para uma tarefa de modelagem de linguagem causal:`),T.forEach(s),ja=m(e),h(ce.$$.fragment,e),ba=m(e),X=r(e,"P",{});var Sa=i(X);Xs=t(Sa,"Crie uma "),De=r(Sa,"CODE",{});var Dl=i(De);Hs=t(Dl,"pipeline()"),Dl.forEach(s),Ds=t(Sa," para a sua tarefa e especif\xEDque o modelo e o tokenizador que foram carregados:"),Sa.forEach(s),Ua=m(e),h(me.$$.fragment,e),$a=m(e),H=r(e,"P",{});var Xa=i(H);Ns=t(Xa,"Passe seu texto de entrada ao "),Ne=r(Xa,"CODE",{});var Nl=i(Ne);Fs=t(Nl,"pipeline()"),Nl.forEach(s),Ys=t(Xa," para gerar algum texto:"),Xa.forEach(s),xa=m(e),h(de.$$.fragment,e),wa=m(e),q=r(e,"H2",{class:!0});var Ha=i(q);D=r(Ha,"A",{id:!0,class:!0,href:!0});var Fl=i(D);Fe=r(Fl,"SPAN",{});var Yl=i(Fe);h(ue.$$.fragment,Yl),Yl.forEach(s),Fl.forEach(s),Os=m(Ha),Ye=r(Ha,"SPAN",{});var Ol=i(Ye);Ls=t(Ol,"Pipeline de audio"),Ol.forEach(s),Ha.forEach(s),Ea=m(e),k=r(e,"P",{});var we=i(k);Qs=t(we,"A flexibilidade do "),Oe=r(we,"CODE",{});var Ll=i(Oe);Ks=t(Ll,"pipeline()"),Ll.forEach(s),el=t(we,` significa que tamb\xE9m pode-se extender \xE0s tarefas de \xE1udio.
La flexibilidad de `),Le=r(we,"CODE",{});var Ql=i(Le);al=t(Ql,"pipeline()"),Ql.forEach(s),sl=t(we," significa que tambi\xE9n se puede extender a tareas de audio."),we.forEach(s),_a=m(e),J=r(e,"P",{});var Ee=i(J);ll=t(Ee,`Por exemplo, classifiquemos a emo\xE7\xE3o de um breve fragmento do famoso discurso de John F. Kennedy /home/rzimmerdev/dev/transformers/docs/source/pt/pipeline_tutorial.mdx
Encontre um modelo de `),fe=r(Ee,"A",{href:!0,rel:!0});var Kl=i(fe);tl=t(Kl,"audio classification"),Kl.forEach(s),ol=t(Ee,` para
reconhecimento de emo\xE7\xF5es no Model Hub e carregue-o usando o `),Qe=r(Ee,"CODE",{});var et=i(Qe);nl=t(et,"pipeline()"),et.forEach(s),rl=t(Ee,":"),Ee.forEach(s),ka=m(e),h(he.$$.fragment,e),Ja=m(e),N=r(e,"P",{});var Da=i(N);il=t(Da,"Passe o arquivo de \xE1udio ao "),Ke=r(Da,"CODE",{});var at=i(Ke);pl=t(at,"pipeline()"),at.forEach(s),cl=t(Da,":"),Da.forEach(s),Za=m(e),h(ge.$$.fragment,e),Ta=m(e),B=r(e,"H2",{class:!0});var Na=i(B);F=r(Na,"A",{id:!0,class:!0,href:!0});var st=i(F);ea=r(st,"SPAN",{});var lt=i(ea);h(ye.$$.fragment,lt),lt.forEach(s),st.forEach(s),ml=m(Na),aa=r(Na,"SPAN",{});var tt=i(aa);dl=t(tt,"Pipeline de vis\xE3o computacional"),tt.forEach(s),Na.forEach(s),Ia=m(e),Y=r(e,"P",{});var Fa=i(Y);ul=t(Fa,"Finalmente, utilizar um "),sa=r(Fa,"CODE",{});var ot=i(sa);fl=t(ot,"pipeline()"),ot.forEach(s),hl=t(Fa,` para tarefas de vis\xE3o \xE9 praticamente a mesma coisa.
Especifique a sua tarefa de vis\xE3o e passe a sua imagem ao classificador.
A imagem pode ser um link ou uma rota local \xE0 imagem. Por exemplo, que esp\xE9cie de gato est\xE1 presente na imagem?`),Fa.forEach(s),Ga=m(e),Ue=r(e,"P",{});var nt=i(Ue);$e=r(nt,"IMG",{src:!0,alt:!0}),nt.forEach(s),Ca=m(e),h(Me.$$.fragment,e),this.h()},h(){d(u,"name","hf:doc:metadata"),d(u,"content",JSON.stringify(gt)),d(x,"id","pipelines-para-inferncia"),d(x,"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"),d(x,"href","#pipelines-para-inferncia"),d(j,"class","relative group"),d(L,"href","https://huggingface.co/models"),d(L,"rel","nofollow"),d(R,"id","uso-do-pipeline"),d(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"),d(R,"href","#uso-do-pipeline"),d(C,"class","relative group"),d(le,"start","2"),d(S,"id","selecionando-um-modelo-e-um-tokenizador"),d(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"),d(S,"href","#selecionando-um-modelo-e-um-tokenizador"),d(W,"class","relative group"),d(pe,"href","https://huggingface.co/models"),d(pe,"rel","nofollow"),d(D,"id","pipeline-de-audio"),d(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"),d(D,"href","#pipeline-de-audio"),d(q,"class","relative group"),d(fe,"href","https://huggingface.co/models?pipeline_tag=audio-classification"),d(fe,"rel","nofollow"),d(F,"id","pipeline-de-viso-computacional"),d(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"),d(F,"href","#pipeline-de-viso-computacional"),d(B,"class","relative group"),mt($e.src,gl="https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/pipeline-cat-chonk.jpeg")||d($e,"src",gl),d($e,"alt","pipeline-cat-chonk")},m(e,o){a(document.head,u),p(e,z,o),p(e,j,o),a(j,x),a(x,G),g($,G,null),a(j,E),a(j,V),a(V,Ya),p(e,oa,o),p(e,P,o),a(P,Oa),a(P,L),a(L,La),a(P,Qa),p(e,na,o),p(e,_,o),a(_,Q),a(Q,Ka),a(Q,_e),a(_e,es),a(Q,as),a(_,ss),a(_,ke),a(ke,ls),a(_,ts),a(_,K),a(K,os),a(K,Je),a(Je,ns),a(K,rs),p(e,ra,o),g(A,e,o),p(e,ia,o),p(e,C,o),a(C,R),a(R,Ze),g(ee,Ze,null),a(C,is),a(C,Te),a(Te,ps),p(e,pa,o),p(e,w,o),a(w,cs),a(w,Ie),a(Ie,ms),a(w,ds),a(w,Ge),a(Ge,us),a(w,fs),a(w,Ce),a(Ce,hs),a(w,gs),p(e,ca,o),p(e,je,o),a(je,ae),a(ae,ys),a(ae,We),a(We,Ms),a(ae,vs),p(e,ma,o),g(se,e,o),p(e,da,o),p(e,le,o),a(le,te),a(te,js),a(te,qe),a(qe,bs),a(te,Us),p(e,ua,o),g(oe,e,o),p(e,fa,o),p(e,be,o),a(be,$s),p(e,ha,o),g(ne,e,o),p(e,ga,o),p(e,b,o),a(b,xs),a(b,Be),a(Be,ws),a(b,Es),a(b,ze),a(ze,_s),a(b,ks),a(b,Ve),a(Ve,Js),a(b,Zs),a(b,Pe),a(Pe,Ts),a(b,Is),p(e,ya,o),g(re,e,o),p(e,Ma,o),p(e,W,o),a(W,S),a(S,Ae),g(ie,Ae,null),a(W,Gs),a(W,Re),a(Re,Cs),p(e,va,o),p(e,U,o),a(U,Ws),a(U,Se),a(Se,qs),a(U,Bs),a(U,pe),a(pe,zs),a(U,Vs),a(U,Xe),a(Xe,Ps),a(U,As),a(U,He),a(He,Rs),a(U,Ss),p(e,ja,o),g(ce,e,o),p(e,ba,o),p(e,X,o),a(X,Xs),a(X,De),a(De,Hs),a(X,Ds),p(e,Ua,o),g(me,e,o),p(e,$a,o),p(e,H,o),a(H,Ns),a(H,Ne),a(Ne,Fs),a(H,Ys),p(e,xa,o),g(de,e,o),p(e,wa,o),p(e,q,o),a(q,D),a(D,Fe),g(ue,Fe,null),a(q,Os),a(q,Ye),a(Ye,Ls),p(e,Ea,o),p(e,k,o),a(k,Qs),a(k,Oe),a(Oe,Ks),a(k,el),a(k,Le),a(Le,al),a(k,sl),p(e,_a,o),p(e,J,o),a(J,ll),a(J,fe),a(fe,tl),a(J,ol),a(J,Qe),a(Qe,nl),a(J,rl),p(e,ka,o),g(he,e,o),p(e,Ja,o),p(e,N,o),a(N,il),a(N,Ke),a(Ke,pl),a(N,cl),p(e,Za,o),g(ge,e,o),p(e,Ta,o),p(e,B,o),a(B,F),a(F,ea),g(ye,ea,null),a(B,ml),a(B,aa),a(aa,dl),p(e,Ia,o),p(e,Y,o),a(Y,ul),a(Y,sa),a(sa,fl),a(Y,hl),p(e,Ga,o),p(e,Ue,o),a(Ue,$e),p(e,Ca,o),g(Me,e,o),Wa=!0},p(e,[o]){const ve={};o&2&&(ve.$$scope={dirty:o,ctx:e}),A.$set(ve)},i(e){Wa||(y($.$$.fragment,e),y(A.$$.fragment,e),y(ee.$$.fragment,e),y(se.$$.fragment,e),y(oe.$$.fragment,e),y(ne.$$.fragment,e),y(re.$$.fragment,e),y(ie.$$.fragment,e),y(ce.$$.fragment,e),y(me.$$.fragment,e),y(de.$$.fragment,e),y(ue.$$.fragment,e),y(he.$$.fragment,e),y(ge.$$.fragment,e),y(ye.$$.fragment,e),y(Me.$$.fragment,e),Wa=!0)},o(e){M($.$$.fragment,e),M(A.$$.fragment,e),M(ee.$$.fragment,e),M(se.$$.fragment,e),M(oe.$$.fragment,e),M(ne.$$.fragment,e),M(re.$$.fragment,e),M(ie.$$.fragment,e),M(ce.$$.fragment,e),M(me.$$.fragment,e),M(de.$$.fragment,e),M(ue.$$.fragment,e),M(he.$$.fragment,e),M(ge.$$.fragment,e),M(ye.$$.fragment,e),M(Me.$$.fragment,e),Wa=!1},d(e){s(u),e&&s(z),e&&s(j),v($),e&&s(oa),e&&s(P),e&&s(na),e&&s(_),e&&s(ra),v(A,e),e&&s(ia),e&&s(C),v(ee),e&&s(pa),e&&s(w),e&&s(ca),e&&s(je),e&&s(ma),v(se,e),e&&s(da),e&&s(le),e&&s(ua),v(oe,e),e&&s(fa),e&&s(be),e&&s(ha),v(ne,e),e&&s(ga),e&&s(b),e&&s(ya),v(re,e),e&&s(Ma),e&&s(W),v(ie),e&&s(va),e&&s(U),e&&s(ja),v(ce,e),e&&s(ba),e&&s(X),e&&s(Ua),v(me,e),e&&s($a),e&&s(H),e&&s(xa),v(de,e),e&&s(wa),e&&s(q),v(ue),e&&s(Ea),e&&s(k),e&&s(_a),e&&s(J),e&&s(ka),v(he,e),e&&s(Ja),e&&s(N),e&&s(Za),v(ge,e),e&&s(Ta),e&&s(B),v(ye),e&&s(Ia),e&&s(Y),e&&s(Ga),e&&s(Ue),e&&s(Ca),v(Me,e)}}}const gt={local:"pipelines-para-inferncia",sections:[{local:"uso-do-pipeline",sections:[{local:"selecionando-um-modelo-e-um-tokenizador",title:"Selecionando um modelo e um tokenizador"}],title:"Uso do pipeline"},{local:"pipeline-de-audio",title:"Pipeline de audio"},{local:"pipeline-de-viso-computacional",title:"Pipeline de vis\xE3o computacional"}],title:"Pipelines para infer\xEAncia"};function yt(ta){return dt(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class Ut extends rt{constructor(u){super();it(this,u,yt,ht,pt,{})}}export{Ut as default,gt as metadata};
