import{S as Uo,i as Do,s as Oo,e as i,k as h,w as m,t,M as Lo,c as r,d as s,m as f,a as p,x as d,h as l,b as c,N as Ho,G as a,g as o,y as g,q as v,o as y,B as w,v as Co,L as Ro}from"../chunks/vendor-hf-doc-builder.js";import{T as Fr}from"../chunks/Tip-hf-doc-builder.js";import{I as S}from"../chunks/IconCopyLink-hf-doc-builder.js";import{C as E}from"../chunks/CodeBlock-hf-doc-builder.js";function Fo(ae){let u,x,j,$,T;return{c(){u=i("p"),x=t("Take a look at the "),j=i("a"),$=t("pipeline()"),T=t(" documentation for a complete list of supported tasks and available parameters."),this.h()},l(k){u=r(k,"P",{});var A=p(u);x=l(A,"Take a look at the "),j=r(A,"A",{href:!0});var q=p(j);$=l(q,"pipeline()"),q.forEach(s),T=l(A," documentation for a complete list of supported tasks and available parameters."),A.forEach(s),this.h()},h(){c(j,"href","/docs/transformers/v4.27.1/en/main_classes/pipelines#transformers.pipeline")},m(k,A){o(k,u,A),a(u,x),a(u,j),a(j,$),a(u,T)},d(k){k&&s(u)}}}function zo(ae){let u;return{c(){u=t(`Creating an inference engine is a complex topic which deserves it's own
page.`)},l(x){u=l(x,`Creating an inference engine is a complex topic which deserves it's own
page.`)},m(x,j){o(x,u,j)},d(x){x&&s(u)}}}function Mo(ae){let u,x,j,$,T,k,A,q,te;return q=new E({props:{code:`sudo apt install -y tesseract-ocr
pip install pytesseract`,highlighted:`sudo apt install -y tesseract-ocr
pip install pytesseract`}}),{c(){u=i("p"),x=t("To run the example above you need to have "),j=i("a"),$=i("code"),T=t("pytesseract"),k=t(" installed in addition to \u{1F917} Transformers:"),A=h(),m(q.$$.fragment),this.h()},l(b){u=r(b,"P",{});var _=p(u);x=l(_,"To run the example above you need to have "),j=r(_,"A",{href:!0,rel:!0});var xs=p(j);$=r(xs,"CODE",{});var z=p($);T=l(z,"pytesseract"),z.forEach(s),xs.forEach(s),k=l(_," installed in addition to \u{1F917} Transformers:"),_.forEach(s),A=f(b),d(q.$$.fragment,b),this.h()},h(){c(j,"href","https://pypi.org/project/pytesseract/"),c(j,"rel","nofollow")},m(b,_){o(b,u,_),a(u,x),a(u,j),a(j,$),a($,T),a(u,k),o(b,A,_),g(q,b,_),te=!0},p:Ro,i(b){te||(v(q.$$.fragment,b),te=!0)},o(b){y(q.$$.fragment,b),te=!1},d(b){b&&s(u),b&&s(A),w(q,b)}}}function Go(ae){let u,x,j,$,T,k,A,q,te,b,_,xs,z,Vl,Wl,Ue,Yl,Kl,$s,Ql,Jl,tt,U,De,Xl,ks,Zl,en,sn,ca,an,tn,Oe,ln,Es,nn,rn,lt,le,nt,M,ne,ha,Le,pn,fa,on,it,N,cn,qs,hn,fn,As,un,mn,Ps,dn,gn,rt,Ts,He,vn,Ns,yn,wn,pt,Ce,ot,Re,Fe,jn,Is,_n,bn,ct,ze,ht,D,xn,Me,$n,kn,Ge,En,qn,ft,Be,ut,ie,An,Ss,Pn,Tn,mt,Us,Nn,dt,Ve,gt,Ds,In,vt,Os,Ls,Sn,yt,Hs,Cs,Un,wt,G,re,ua,We,Dn,ma,On,jt,Ye,Rs,Ln,Hn,_t,Ke,bt,Fs,Cn,xt,B,pe,da,Qe,Rn,ga,Fn,$t,oe,zn,va,Mn,Gn,kt,Je,Et,O,Bn,ya,Vn,Wn,Xe,Yn,Kn,qt,Ze,At,I,Qn,wa,Jn,Xn,ja,Zn,ei,_a,si,ai,Pt,V,ce,ba,es,ti,xa,li,Tt,he,ni,ss,ii,ri,Nt,zs,pi,It,as,St,Ms,oi,Ut,fe,ci,Gs,$a,hi,fi,Dt,W,ue,ka,ts,ui,Ea,mi,Ot,L,di,me,gi,qa,vi,yi,wi,Aa,ji,_i,Lt,ls,Ht,de,bi,Pa,xi,$i,Ct,H,ki,Bs,Ei,qi,Ta,Ai,Pi,Rt,ge,Ti,ns,Ni,Ii,Ft,Y,ve,Na,is,Si,Ia,Ui,zt,Vs,Di,Mt,rs,Gt,C,Oi,Sa,Li,Hi,ps,Ci,Ri,Bt,ye,Fi,Ua,zi,Mi,Vt,we,Gi,os,Bi,Vi,Wt,cs,Yt,K,je,Da,hs,Wi,Oa,Yi,Kt,_e,Qt,Ws,Ys,Ki,Jt,Q,be,La,fs,Qi,Ha,Ji,Xt,xe,Xi,Ks,Zi,er,Zt,Qs,sr,el,Js,Xs,zr,sl,us,al,J,$e,Ca,ms,ar,Ra,tr,tl,ke,lr,Zs,nr,ir,ll,ds,nl,X,Ee,Fa,gs,rr,za,pr,il,qe,or,ea,cr,hr,rl,Ae,fr,vs,ur,mr,pl,ys,ol,Pe,cl,Z,Te,Ma,ws,dr,ee,gr,Ga,vr,yr,Ba,wr,jr,hl,P,_r,Va,br,xr,Wa,$r,kr,Ya,Er,qr,Ka,Ar,Pr,fl,R,Tr,Qa,Nr,Ir,Ja,Sr,Ur,ul,js,ml,se,Dr,Xa,Or,Lr,Za,Hr,dl,_s,gl,sa,Cr,vl;return k=new S({}),le=new Fr({props:{$$slots:{default:[Fo]},$$scope:{ctx:ae}}}),Le=new S({}),Ce=new E({props:{code:`from transformers import pipeline

generator = pipeline(task="automatic-speech-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>generator = pipeline(task=<span class="hljs-string">&quot;automatic-speech-recognition&quot;</span>)`}}),ze=new E({props:{code:'generator("https://huggingface.co/datasets/Narsil/asr_dummy/resolve/main/mlk.flac")',highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span>generator(<span class="hljs-string">&quot;https://huggingface.co/datasets/Narsil/asr_dummy/resolve/main/mlk.flac&quot;</span>)
{<span class="hljs-string">&#x27;text&#x27;</span>: <span class="hljs-string">&#x27;I HAVE A DREAM BUT ONE DAY THIS NATION WILL RISE UP LIVE UP THE TRUE MEANING OF ITS TREES&#x27;</span>}`}}),Be=new E({props:{code:`generator = pipeline(model="openai/whisper-large")
generator("https://huggingface.co/datasets/Narsil/asr_dummy/resolve/main/mlk.flac")`,highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span>generator = pipeline(model=<span class="hljs-string">&quot;openai/whisper-large&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>generator(<span class="hljs-string">&quot;https://huggingface.co/datasets/Narsil/asr_dummy/resolve/main/mlk.flac&quot;</span>)
{<span class="hljs-string">&#x27;text&#x27;</span>: <span class="hljs-string">&#x27; I have a dream that one day this nation will rise up and live out the true meaning of its creed.&#x27;</span>}`}}),Ve=new E({props:{code:`generator(
    [
        "https://huggingface.co/datasets/Narsil/asr_dummy/resolve/main/mlk.flac",
        "https://huggingface.co/datasets/Narsil/asr_dummy/resolve/main/1.flac",
    ]
)`,highlighted:`generator(
    [
        <span class="hljs-string">&quot;https://huggingface.co/datasets/Narsil/asr_dummy/resolve/main/mlk.flac&quot;</span>,
        <span class="hljs-string">&quot;https://huggingface.co/datasets/Narsil/asr_dummy/resolve/main/1.flac&quot;</span>,
    ]
)`}}),We=new S({}),Ke=new E({props:{code:'generator(model="openai/whisper-large", my_parameter=1)\nout = generate(...)  # This will use `my_parameter=1`.\nout = generate(..., my_parameter=2)  # This will override and use `my_parameter=2`.\nout = generate(...)  # This will go back to using `my_parameter=1`.',highlighted:'generator(model=<span class="hljs-string">&quot;openai/whisper-large&quot;</span>, my_parameter=<span class="hljs-number">1</span>)\nout = generate(...)  <span class="hljs-comment"># This will use `my_parameter=1`.</span>\nout = generate(..., my_parameter=<span class="hljs-number">2</span>)  <span class="hljs-comment"># This will override and use `my_parameter=2`.</span>\nout = generate(...)  <span class="hljs-comment"># This will go back to using `my_parameter=1`.</span>'}}),Qe=new S({}),Je=new E({props:{code:'generator(model="openai/whisper-large", device=0)',highlighted:'generator(model=<span class="hljs-string">&quot;openai/whisper-large&quot;</span>, device=<span class="hljs-number">0</span>)'}}),Ze=new E({props:{code:`#!pip install accelerate
generator(model="openai/whisper-large", device_map="auto")`,highlighted:`<span class="hljs-comment">#!pip install accelerate</span>
generator(model=<span class="hljs-string">&quot;openai/whisper-large&quot;</span>, device_map=<span class="hljs-string">&quot;auto&quot;</span>)`}}),es=new S({}),as=new E({props:{code:`generator(model="openai/whisper-large", device=0, batch_size=2)
audio_filenames = [f"audio_{i}.flac" for i in range(10)]
texts = generator(audio_filenames)`,highlighted:`generator(model=<span class="hljs-string">&quot;openai/whisper-large&quot;</span>, device=<span class="hljs-number">0</span>, batch_size=<span class="hljs-number">2</span>)
audio_filenames = [<span class="hljs-string">f&quot;audio_<span class="hljs-subst">{i}</span>.flac&quot;</span> <span class="hljs-keyword">for</span> i <span class="hljs-keyword">in</span> <span class="hljs-built_in">range</span>(<span class="hljs-number">10</span>)]
texts = generator(audio_filenames)`}}),ts=new S({}),ls=new E({props:{code:`# Not using whisper, as it cannot provide timestamps.
generator = pipeline(model="facebook/wav2vec2-large-960h-lv60-self", return_timestamps="word")
generator("https://huggingface.co/datasets/Narsil/asr_dummy/resolve/main/mlk.flac")`,highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># Not using whisper, as it cannot provide timestamps.</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>generator = pipeline(model=<span class="hljs-string">&quot;facebook/wav2vec2-large-960h-lv60-self&quot;</span>, return_timestamps=<span class="hljs-string">&quot;word&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>generator(<span class="hljs-string">&quot;https://huggingface.co/datasets/Narsil/asr_dummy/resolve/main/mlk.flac&quot;</span>)
{<span class="hljs-string">&#x27;text&#x27;</span>: <span class="hljs-string">&#x27;I HAVE A DREAM BUT ONE DAY THIS NATION WILL RISE UP AND LIVE OUT THE TRUE MEANING OF ITS CREED&#x27;</span>, <span class="hljs-string">&#x27;chunks&#x27;</span>: [{<span class="hljs-string">&#x27;text&#x27;</span>: <span class="hljs-string">&#x27;I&#x27;</span>, <span class="hljs-string">&#x27;timestamp&#x27;</span>: (<span class="hljs-number">1.22</span>, <span class="hljs-number">1.24</span>)}, {<span class="hljs-string">&#x27;text&#x27;</span>: <span class="hljs-string">&#x27;HAVE&#x27;</span>, <span class="hljs-string">&#x27;timestamp&#x27;</span>: (<span class="hljs-number">1.42</span>, <span class="hljs-number">1.58</span>)}, {<span class="hljs-string">&#x27;text&#x27;</span>: <span class="hljs-string">&#x27;A&#x27;</span>, <span class="hljs-string">&#x27;timestamp&#x27;</span>: (<span class="hljs-number">1.66</span>, <span class="hljs-number">1.68</span>)}, {<span class="hljs-string">&#x27;text&#x27;</span>: <span class="hljs-string">&#x27;DREAM&#x27;</span>, <span class="hljs-string">&#x27;timestamp&#x27;</span>: (<span class="hljs-number">1.76</span>, <span class="hljs-number">2.14</span>)}, {<span class="hljs-string">&#x27;text&#x27;</span>: <span class="hljs-string">&#x27;BUT&#x27;</span>, <span class="hljs-string">&#x27;timestamp&#x27;</span>: (<span class="hljs-number">3.68</span>, <span class="hljs-number">3.8</span>)}, {<span class="hljs-string">&#x27;text&#x27;</span>: <span class="hljs-string">&#x27;ONE&#x27;</span>, <span class="hljs-string">&#x27;timestamp&#x27;</span>: (<span class="hljs-number">3.94</span>, <span class="hljs-number">4.06</span>)}, {<span class="hljs-string">&#x27;text&#x27;</span>: <span class="hljs-string">&#x27;DAY&#x27;</span>, <span class="hljs-string">&#x27;timestamp&#x27;</span>: (<span class="hljs-number">4.16</span>, <span class="hljs-number">4.3</span>)}, {<span class="hljs-string">&#x27;text&#x27;</span>: <span class="hljs-string">&#x27;THIS&#x27;</span>, <span class="hljs-string">&#x27;timestamp&#x27;</span>: (<span class="hljs-number">6.36</span>, <span class="hljs-number">6.54</span>)}, {<span class="hljs-string">&#x27;text&#x27;</span>: <span class="hljs-string">&#x27;NATION&#x27;</span>, <span class="hljs-string">&#x27;timestamp&#x27;</span>: (<span class="hljs-number">6.68</span>, <span class="hljs-number">7.1</span>)}, {<span class="hljs-string">&#x27;text&#x27;</span>: <span class="hljs-string">&#x27;WILL&#x27;</span>, <span class="hljs-string">&#x27;timestamp&#x27;</span>: (<span class="hljs-number">7.32</span>, <span class="hljs-number">7.56</span>)}, {<span class="hljs-string">&#x27;text&#x27;</span>: <span class="hljs-string">&#x27;RISE&#x27;</span>, <span class="hljs-string">&#x27;timestamp&#x27;</span>: (<span class="hljs-number">7.8</span>, <span class="hljs-number">8.26</span>)}, {<span class="hljs-string">&#x27;text&#x27;</span>: <span class="hljs-string">&#x27;UP&#x27;</span>, <span class="hljs-string">&#x27;timestamp&#x27;</span>: (<span class="hljs-number">8.38</span>, <span class="hljs-number">8.48</span>)}, {<span class="hljs-string">&#x27;text&#x27;</span>: <span class="hljs-string">&#x27;AND&#x27;</span>, <span class="hljs-string">&#x27;timestamp&#x27;</span>: (<span class="hljs-number">10.08</span>, <span class="hljs-number">10.18</span>)}, {<span class="hljs-string">&#x27;text&#x27;</span>: <span class="hljs-string">&#x27;LIVE&#x27;</span>, <span class="hljs-string">&#x27;timestamp&#x27;</span>: (<span class="hljs-number">10.26</span>, <span class="hljs-number">10.48</span>)}, {<span class="hljs-string">&#x27;text&#x27;</span>: <span class="hljs-string">&#x27;OUT&#x27;</span>, <span class="hljs-string">&#x27;timestamp&#x27;</span>: (<span class="hljs-number">10.58</span>, <span class="hljs-number">10.7</span>)}, {<span class="hljs-string">&#x27;text&#x27;</span>: <span class="hljs-string">&#x27;THE&#x27;</span>, <span class="hljs-string">&#x27;timestamp&#x27;</span>: (<span class="hljs-number">10.82</span>, <span class="hljs-number">10.9</span>)}, {<span class="hljs-string">&#x27;text&#x27;</span>: <span class="hljs-string">&#x27;TRUE&#x27;</span>, <span class="hljs-string">&#x27;timestamp&#x27;</span>: (<span class="hljs-number">10.98</span>, <span class="hljs-number">11.18</span>)}, {<span class="hljs-string">&#x27;text&#x27;</span>: <span class="hljs-string">&#x27;MEANING&#x27;</span>, <span class="hljs-string">&#x27;timestamp&#x27;</span>: (<span class="hljs-number">11.26</span>, <span class="hljs-number">11.58</span>)}, {<span class="hljs-string">&#x27;text&#x27;</span>: <span class="hljs-string">&#x27;OF&#x27;</span>, <span class="hljs-string">&#x27;timestamp&#x27;</span>: (<span class="hljs-number">11.66</span>, <span class="hljs-number">11.7</span>)}, {<span class="hljs-string">&#x27;text&#x27;</span>: <span class="hljs-string">&#x27;ITS&#x27;</span>, <span class="hljs-string">&#x27;timestamp&#x27;</span>: (<span class="hljs-number">11.76</span>, <span class="hljs-number">11.88</span>)}, {<span class="hljs-string">&#x27;text&#x27;</span>: <span class="hljs-string">&#x27;CREED&#x27;</span>, <span class="hljs-string">&#x27;timestamp&#x27;</span>: (<span class="hljs-number">12.0</span>, <span class="hljs-number">12.38</span>)}]}`}}),is=new S({}),rs=new E({props:{code:`def data():
    for i in range(1000):
        yield f"My example {i}"


pipe = pipeline(model="gpt2", device=0)
generated_characters = 0
for out in pipe(data()):
    generated_characters += len(out[0]["generated_text"])`,highlighted:`<span class="hljs-keyword">def</span> <span class="hljs-title function_">data</span>():
    <span class="hljs-keyword">for</span> i <span class="hljs-keyword">in</span> <span class="hljs-built_in">range</span>(<span class="hljs-number">1000</span>):
        <span class="hljs-keyword">yield</span> <span class="hljs-string">f&quot;My example <span class="hljs-subst">{i}</span>&quot;</span>


pipe = pipeline(model=<span class="hljs-string">&quot;gpt2&quot;</span>, device=<span class="hljs-number">0</span>)
generated_characters = <span class="hljs-number">0</span>
<span class="hljs-keyword">for</span> out <span class="hljs-keyword">in</span> pipe(data()):
    generated_characters += <span class="hljs-built_in">len</span>(out[<span class="hljs-number">0</span>][<span class="hljs-string">&quot;generated_text&quot;</span>])`}}),cs=new E({props:{code:`# KeyDataset is a util that will just output the item we're interested in.
from transformers.pipelines.pt_utils import KeyDataset
from datasets import load_dataset

pipe = pipeline(model="hf-internal-testing/tiny-random-wav2vec2", device=0)
dataset = load_dataset("hf-internal-testing/librispeech_asr_dummy", "clean", split="validation[:10]")

for out in pipe(KeyDataset(dataset, "audio")):
    print(out)`,highlighted:`<span class="hljs-comment"># KeyDataset is a util that will just output the item we&#x27;re interested in.</span>
<span class="hljs-keyword">from</span> transformers.pipelines.pt_utils <span class="hljs-keyword">import</span> KeyDataset
<span class="hljs-keyword">from</span> datasets <span class="hljs-keyword">import</span> load_dataset

pipe = pipeline(model=<span class="hljs-string">&quot;hf-internal-testing/tiny-random-wav2vec2&quot;</span>, device=<span class="hljs-number">0</span>)
dataset = load_dataset(<span class="hljs-string">&quot;hf-internal-testing/librispeech_asr_dummy&quot;</span>, <span class="hljs-string">&quot;clean&quot;</span>, split=<span class="hljs-string">&quot;validation[:10]&quot;</span>)

<span class="hljs-keyword">for</span> out <span class="hljs-keyword">in</span> pipe(KeyDataset(dataset, <span class="hljs-string">&quot;audio&quot;</span>)):
    <span class="hljs-built_in">print</span>(out)`}}),hs=new S({}),_e=new Fr({props:{$$slots:{default:[zo]},$$scope:{ctx:ae}}}),fs=new S({}),us=new E({props:{code:`from transformers import pipeline

vision_classifier = pipeline(model="google/vit-base-patch16-224")
preds = vision_classifier(
    images="https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/pipeline-cat-chonk.jpeg"
)
preds = [{"score": round(pred["score"], 4), "label": pred["label"]} for pred in preds]
preds`,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(model=<span class="hljs-string">&quot;google/vit-base-patch16-224&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>preds = 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-meta">&gt;&gt;&gt; </span>preds = [{<span class="hljs-string">&quot;score&quot;</span>: <span class="hljs-built_in">round</span>(pred[<span class="hljs-string">&quot;score&quot;</span>], <span class="hljs-number">4</span>), <span class="hljs-string">&quot;label&quot;</span>: pred[<span class="hljs-string">&quot;label&quot;</span>]} <span class="hljs-keyword">for</span> pred <span class="hljs-keyword">in</span> preds]
<span class="hljs-meta">&gt;&gt;&gt; </span>preds
[{<span class="hljs-string">&#x27;score&#x27;</span>: <span class="hljs-number">0.4335</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.0348</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.0324</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.0239</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.0229</span>, <span class="hljs-string">&#x27;label&#x27;</span>: <span class="hljs-string">&#x27;tiger cat&#x27;</span>}]`}}),ms=new S({}),ds=new E({props:{code:`from transformers import pipeline

# This model is a \`zero-shot-classification\` model.
# It will classify text, except you are free to choose any label you might imagine
classifier = pipeline(model="facebook/bart-large-mnli")
classifier(
    "I have a problem with my iphone that needs to be resolved asap!!",
    candidate_labels=["urgent", "not urgent", "phone", "tablet", "computer"],
)`,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><span class="hljs-comment"># This model is a \`zero-shot-classification\` model.</span>
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># It will classify text, except you are free to choose any label you might imagine</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>classifier = pipeline(model=<span class="hljs-string">&quot;facebook/bart-large-mnli&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>classifier(
<span class="hljs-meta">... </span>    <span class="hljs-string">&quot;I have a problem with my iphone that needs to be resolved asap!!&quot;</span>,
<span class="hljs-meta">... </span>    candidate_labels=[<span class="hljs-string">&quot;urgent&quot;</span>, <span class="hljs-string">&quot;not urgent&quot;</span>, <span class="hljs-string">&quot;phone&quot;</span>, <span class="hljs-string">&quot;tablet&quot;</span>, <span class="hljs-string">&quot;computer&quot;</span>],
<span class="hljs-meta">... </span>)
{<span class="hljs-string">&#x27;sequence&#x27;</span>: <span class="hljs-string">&#x27;I have a problem with my iphone that needs to be resolved asap!!&#x27;</span>, <span class="hljs-string">&#x27;labels&#x27;</span>: [<span class="hljs-string">&#x27;urgent&#x27;</span>, <span class="hljs-string">&#x27;phone&#x27;</span>, <span class="hljs-string">&#x27;computer&#x27;</span>, <span class="hljs-string">&#x27;not urgent&#x27;</span>, <span class="hljs-string">&#x27;tablet&#x27;</span>], <span class="hljs-string">&#x27;scores&#x27;</span>: [<span class="hljs-number">0.504</span>, <span class="hljs-number">0.479</span>, <span class="hljs-number">0.013</span>, <span class="hljs-number">0.003</span>, <span class="hljs-number">0.002</span>]}`}}),gs=new S({}),ys=new E({props:{code:`from transformers import pipeline

vqa = pipeline(model="impira/layoutlm-document-qa")
vqa(
    image="https://huggingface.co/spaces/impira/docquery/resolve/2359223c1837a7587402bda0f2643382a6eefeab/invoice.png",
    question="What is the invoice number?",
)`,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>vqa = pipeline(model=<span class="hljs-string">&quot;impira/layoutlm-document-qa&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>vqa(
<span class="hljs-meta">... </span>    image=<span class="hljs-string">&quot;https://huggingface.co/spaces/impira/docquery/resolve/2359223c1837a7587402bda0f2643382a6eefeab/invoice.png&quot;</span>,
<span class="hljs-meta">... </span>    question=<span class="hljs-string">&quot;What is the invoice number?&quot;</span>,
<span class="hljs-meta">... </span>)
[{<span class="hljs-string">&#x27;score&#x27;</span>: <span class="hljs-number">0.42515</span>, <span class="hljs-string">&#x27;answer&#x27;</span>: <span class="hljs-string">&#x27;us-001&#x27;</span>, <span class="hljs-string">&#x27;start&#x27;</span>: <span class="hljs-number">16</span>, <span class="hljs-string">&#x27;end&#x27;</span>: <span class="hljs-number">16</span>}]`}}),Pe=new Fr({props:{$$slots:{default:[Mo]},$$scope:{ctx:ae}}}),ws=new S({}),js=new E({props:{code:`# pip install accelerate
import torch
from transformers import pipeline

pipe = pipeline(model="facebook/opt-1.3b", torch_dtype=torch.bfloat16, device_map="auto")
output = pipe("This is a cool example!", do_sample=True, top_p=0.95)`,highlighted:`<span class="hljs-comment"># pip install accelerate</span>
<span class="hljs-keyword">import</span> torch
<span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> pipeline

pipe = pipeline(model=<span class="hljs-string">&quot;facebook/opt-1.3b&quot;</span>, torch_dtype=torch.bfloat16, device_map=<span class="hljs-string">&quot;auto&quot;</span>)
output = pipe(<span class="hljs-string">&quot;This is a cool example!&quot;</span>, do_sample=<span class="hljs-literal">True</span>, top_p=<span class="hljs-number">0.95</span>)`}}),_s=new E({props:{code:`# pip install accelerate bitsandbytes
import torch
from transformers import pipeline

pipe = pipeline(model="facebook/opt-1.3b", device_map="auto", model_kwargs={"load_in_8bit": True})
output = pipe("This is a cool example!", do_sample=True, top_p=0.95)`,highlighted:`<span class="hljs-comment"># pip install accelerate bitsandbytes</span>
<span class="hljs-keyword">import</span> torch
<span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> pipeline

pipe = pipeline(model=<span class="hljs-string">&quot;facebook/opt-1.3b&quot;</span>, device_map=<span class="hljs-string">&quot;auto&quot;</span>, model_kwargs={<span class="hljs-string">&quot;load_in_8bit&quot;</span>: <span class="hljs-literal">True</span>})
output = pipe(<span class="hljs-string">&quot;This is a cool example!&quot;</span>, do_sample=<span class="hljs-literal">True</span>, top_p=<span class="hljs-number">0.95</span>)`}}),{c(){u=i("meta"),x=h(),j=i("h1"),$=i("a"),T=i("span"),m(k.$$.fragment),A=h(),q=i("span"),te=t("Pipelines for inference"),b=h(),_=i("p"),xs=t("The "),z=i("a"),Vl=t("pipeline()"),Wl=t(" makes it simple to use any model from the "),Ue=i("a"),Yl=t("Hub"),Kl=t(" for inference on any language, computer vision, speech, and multimodal tasks. Even if you don\u2019t have experience with a specific modality or aren\u2019t familiar with the underlying code behind the models, you can still use them for inference with the "),$s=i("a"),Ql=t("pipeline()"),Jl=t("! This tutorial will teach you to:"),tt=h(),U=i("ul"),De=i("li"),Xl=t("Use a "),ks=i("a"),Zl=t("pipeline()"),en=t(" for inference."),sn=h(),ca=i("li"),an=t("Use a specific tokenizer or model."),tn=h(),Oe=i("li"),ln=t("Use a "),Es=i("a"),nn=t("pipeline()"),rn=t(" for audio, vision, and multimodal tasks."),lt=h(),m(le.$$.fragment),nt=h(),M=i("h2"),ne=i("a"),ha=i("span"),m(Le.$$.fragment),pn=h(),fa=i("span"),on=t("Pipeline usage"),it=h(),N=i("p"),cn=t("While each task has an associated "),qs=i("a"),hn=t("pipeline()"),fn=t(", it is simpler to use the general "),As=i("a"),un=t("pipeline()"),mn=t(" abstraction which contains all the task-specific pipelines. The "),Ps=i("a"),dn=t("pipeline()"),gn=t(" automatically loads a default model and a preprocessing class capable of inference for your task."),rt=h(),Ts=i("ol"),He=i("li"),vn=t("Start by creating a "),Ns=i("a"),yn=t("pipeline()"),wn=t(" and specify an inference task:"),pt=h(),m(Ce.$$.fragment),ot=h(),Re=i("ol"),Fe=i("li"),jn=t("Pass your input text to the "),Is=i("a"),_n=t("pipeline()"),bn=t(":"),ct=h(),m(ze.$$.fragment),ht=h(),D=i("p"),xn=t("Not the result you had in mind? Check out some of the "),Me=i("a"),$n=t("most downloaded automatic speech recognition models"),kn=t(` on the Hub to see if you can get a better transcription.
Let\u2019s try `),Ge=i("a"),En=t("openai/whisper-large"),qn=t(":"),ft=h(),m(Be.$$.fragment),ut=h(),ie=i("p"),An=t(`Now this result looks more accurate!
We really encourage you to check out the Hub for models in different languages, models specialized in your field, and more.
You can check out and compare model results directly from your browser on the Hub to see if it fits or
handles corner cases better than other ones.
And if you don\u2019t find a model for your use case, you can always start `),Ss=i("a"),Pn=t("training"),Tn=t(" your own!"),mt=h(),Us=i("p"),Nn=t("If you have several inputs, you can pass your input as a list:"),dt=h(),m(Ve.$$.fragment),gt=h(),Ds=i("p"),In=t("If you want to iterate over a whole dataset, or want to use it for inference in a webserver, check out dedicated parts"),vt=h(),Os=i("p"),Ls=i("a"),Sn=t("Using pipelines on a dataset"),yt=h(),Hs=i("p"),Cs=i("a"),Un=t("Using pipelines for a webserver"),wt=h(),G=i("h2"),re=i("a"),ua=i("span"),m(We.$$.fragment),Dn=h(),ma=i("span"),On=t("Parameters"),jt=h(),Ye=i("p"),Rs=i("a"),Ln=t("pipeline()"),Hn=t(` supports many parameters; some are task specific, and some are general to all pipelines.
In general you can specify parameters anywhere you want:`),_t=h(),m(Ke.$$.fragment),bt=h(),Fs=i("p"),Cn=t("Let\u2019s check out 3 important ones:"),xt=h(),B=i("h3"),pe=i("a"),da=i("span"),m(Qe.$$.fragment),Rn=h(),ga=i("span"),Fn=t("Device"),$t=h(),oe=i("p"),zn=t("If you use "),va=i("code"),Mn=t("device=n"),Gn=t(`, the pipeline automatically puts the model on the specified device.
This will work regardless of whether you are using PyTorch or Tensorflow.`),kt=h(),m(Je.$$.fragment),Et=h(),O=i("p"),Bn=t("If the model is too large for a single GPU, you can set "),ya=i("code"),Vn=t('device_map="auto"'),Wn=t(" to allow \u{1F917} "),Xe=i("a"),Yn=t("Accelerate"),Kn=t(" to automatically determine how to load and store the model weights."),qt=h(),m(Ze.$$.fragment),At=h(),I=i("p"),Qn=t("Note that if  "),wa=i("code"),Jn=t('device_map="auto"'),Xn=t(" is passed, there is no need to add the argument "),ja=i("code"),Zn=t("device=device"),ei=t(" when instantiating your "),_a=i("code"),si=t("pipeline"),ai=t(" as you may encounter some unexpected behavior!"),Pt=h(),V=i("h3"),ce=i("a"),ba=i("span"),m(es.$$.fragment),ti=h(),xa=i("span"),li=t("Batch size"),Tt=h(),he=i("p"),ni=t("By default, pipelines will not batch inference for reasons explained in detail "),ss=i("a"),ii=t("here"),ri=t(". The reason is that batching is not necessarily faster, and can actually be quite slower in some cases."),Nt=h(),zs=i("p"),pi=t("But if it works in your use case, you can use:"),It=h(),m(as.$$.fragment),St=h(),Ms=i("p"),oi=t(`This runs the pipeline on the 10 provided audio files, but it will pass them in batches of 2
to the model (which is on a GPU, where batching is more likely to help) without requiring any further code from you.
The output should always match what you would have received without batching. It is only meant as a way to help you get more speed out of a pipeline.`),Ut=h(),fe=i("p"),ci=t("Pipelines can also alleviate some of the complexities of batching because, for some pipelines, a single item (like a long audio file) needs to be chunked into multiple parts to be processed by a model. The pipeline performs this "),Gs=i("a"),$a=i("em"),hi=t("chunk batching"),fi=t(" for you."),Dt=h(),W=i("h3"),ue=i("a"),ka=i("span"),m(ts.$$.fragment),ui=h(),Ea=i("span"),mi=t("Task specific parameters"),Ot=h(),L=i("p"),di=t(`All tasks provide task specific parameters which allow for additional flexibility and options to help you get your job done.
For instance, the `),me=i("a"),gi=t("transformers.AutomaticSpeechRecognitionPipeline."),qa=i("strong"),vi=t("call"),yi=t("()"),wi=t(" method has a "),Aa=i("code"),ji=t("return_timestamps"),_i=t(" parameter which sounds promising for subtitling videos:"),Lt=h(),m(ls.$$.fragment),Ht=h(),de=i("p"),bi=t("As you can see, the model inferred the text and also outputted "),Pa=i("strong"),xi=t("when"),$i=t(` the various words were pronounced
in the sentence.`),Ct=h(),H=i("p"),ki=t(`There are many parameters available for each task, so check out each task\u2019s API reference to see what you can tinker with!
For instance, the `),Bs=i("a"),Ei=t("AutomaticSpeechRecognitionPipeline"),qi=t(" has a "),Ta=i("code"),Ai=t("chunk_length_s"),Pi=t(" parameter which is helpful for working on really long audio files (for example, subtitling entire movies or hour-long videos) that a model typically cannot handle on its own."),Rt=h(),ge=i("p"),Ti=t("If you can\u2019t find a parameter that would really help you out, feel free to "),ns=i("a"),Ni=t("request it"),Ii=t("!"),Ft=h(),Y=i("h2"),ve=i("a"),Na=i("span"),m(is.$$.fragment),Si=h(),Ia=i("span"),Ui=t("Using pipelines on a dataset"),zt=h(),Vs=i("p"),Di=t("The pipeline can also run inference on a large dataset. The easiest way we recommend doing this is by using an iterator:"),Mt=h(),m(rs.$$.fragment),Gt=h(),C=i("p"),Oi=t("The iterator "),Sa=i("code"),Li=t("data()"),Hi=t(` yields each result, and the pipeline automatically
recognizes the input is iterable and will start fetching the data while
it continues to process it on the GPU (this uses `),ps=i("a"),Ci=t("DataLoader"),Ri=t(` under the hood).
This is important because you don\u2019t have to allocate memory for the whole dataset
and you can feed the GPU as fast as possible.`),Bt=h(),ye=i("p"),Fi=t("Since batching could speed things up, it may be useful to try tuning the "),Ua=i("code"),zi=t("batch_size"),Mi=t(" parameter here."),Vt=h(),we=i("p"),Gi=t("The simplest way to iterate over a dataset is to just load one from \u{1F917} "),os=i("a"),Bi=t("Datasets"),Vi=t(":"),Wt=h(),m(cs.$$.fragment),Yt=h(),K=i("h2"),je=i("a"),Da=i("span"),m(hs.$$.fragment),Wi=h(),Oa=i("span"),Yi=t("Using pipelines for a webserver"),Kt=h(),m(_e.$$.fragment),Qt=h(),Ws=i("p"),Ys=i("a"),Ki=t("Link"),Jt=h(),Q=i("h2"),be=i("a"),La=i("span"),m(fs.$$.fragment),Qi=h(),Ha=i("span"),Ji=t("Vision pipeline"),Xt=h(),xe=i("p"),Xi=t("Using a "),Ks=i("a"),Zi=t("pipeline()"),er=t(" for vision tasks is practically identical."),Zt=h(),Qs=i("p"),sr=t("Specify your task and pass your image to the classifier. The image can be a link or a local path to the image. For example, what species of cat is shown below?"),el=h(),Js=i("p"),Xs=i("img"),sl=h(),m(us.$$.fragment),al=h(),J=i("h2"),$e=i("a"),Ca=i("span"),m(ms.$$.fragment),ar=h(),Ra=i("span"),tr=t("Text pipeline"),tl=h(),ke=i("p"),lr=t("Using a "),Zs=i("a"),nr=t("pipeline()"),ir=t(" for NLP tasks is practically identical."),ll=h(),m(ds.$$.fragment),nl=h(),X=i("h2"),Ee=i("a"),Fa=i("span"),m(gs.$$.fragment),rr=h(),za=i("span"),pr=t("Multimodal pipeline"),il=h(),qe=i("p"),or=t("The "),ea=i("a"),cr=t("pipeline()"),hr=t(" supports more than one modality. For example, a visual question answering (VQA) task combines text and image. Feel free to use any image link you like and a question you want to ask about the image. The image can be a URL or a local path to the image."),rl=h(),Ae=i("p"),fr=t("For example, if you use this "),vs=i("a"),ur=t("invoice image"),mr=t(":"),pl=h(),m(ys.$$.fragment),ol=h(),m(Pe.$$.fragment),cl=h(),Z=i("h2"),Te=i("a"),Ma=i("span"),m(ws.$$.fragment),dr=h(),ee=i("span"),gr=t("Using "),Ga=i("code"),vr=t("pipeline"),yr=t(" on large models with \u{1F917} "),Ba=i("code"),wr=t("accelerate"),jr=t(":"),hl=h(),P=i("p"),_r=t("You can easily run "),Va=i("code"),br=t("pipeline"),xr=t(" on large models using \u{1F917} "),Wa=i("code"),$r=t("accelerate"),kr=t("! First make sure you have installed "),Ya=i("code"),Er=t("accelerate"),qr=t(" with "),Ka=i("code"),Ar=t("pip install accelerate"),Pr=t("."),fl=h(),R=i("p"),Tr=t("First load your model using "),Qa=i("code"),Nr=t('device_map="auto"'),Ir=t("! We will use "),Ja=i("code"),Sr=t("facebook/opt-1.3b"),Ur=t(" for our example."),ul=h(),m(js.$$.fragment),ml=h(),se=i("p"),Dr=t("You can also pass 8-bit loaded models if you install "),Xa=i("code"),Or=t("bitsandbytes"),Lr=t(" and add the argument "),Za=i("code"),Hr=t("load_in_8bit=True"),dl=h(),m(_s.$$.fragment),gl=h(),sa=i("p"),Cr=t("Note that you can replace the checkpoint with any of the Hugging Face model that supports large model loading such as BLOOM!"),this.h()},l(e){const n=Lo('[data-svelte="svelte-1phssyn"]',document.head);u=r(n,"META",{name:!0,content:!0}),n.forEach(s),x=f(e),j=r(e,"H1",{class:!0});var bs=p(j);$=r(bs,"A",{id:!0,class:!0,href:!0});var et=p($);T=r(et,"SPAN",{});var st=p(T);d(k.$$.fragment,st),st.forEach(s),et.forEach(s),A=f(bs),q=r(bs,"SPAN",{});var Mr=p(q);te=l(Mr,"Pipelines for inference"),Mr.forEach(s),bs.forEach(s),b=f(e),_=r(e,"P",{});var Ne=p(_);xs=l(Ne,"The "),z=r(Ne,"A",{href:!0});var Gr=p(z);Vl=l(Gr,"pipeline()"),Gr.forEach(s),Wl=l(Ne," makes it simple to use any model from the "),Ue=r(Ne,"A",{href:!0,rel:!0});var Br=p(Ue);Yl=l(Br,"Hub"),Br.forEach(s),Kl=l(Ne," for inference on any language, computer vision, speech, and multimodal tasks. Even if you don\u2019t have experience with a specific modality or aren\u2019t familiar with the underlying code behind the models, you can still use them for inference with the "),$s=r(Ne,"A",{href:!0});var Vr=p($s);Ql=l(Vr,"pipeline()"),Vr.forEach(s),Jl=l(Ne,"! This tutorial will teach you to:"),Ne.forEach(s),tt=f(e),U=r(e,"UL",{});var aa=p(U);De=r(aa,"LI",{});var yl=p(De);Xl=l(yl,"Use a "),ks=r(yl,"A",{href:!0});var Wr=p(ks);Zl=l(Wr,"pipeline()"),Wr.forEach(s),en=l(yl," for inference."),yl.forEach(s),sn=f(aa),ca=r(aa,"LI",{});var Yr=p(ca);an=l(Yr,"Use a specific tokenizer or model."),Yr.forEach(s),tn=f(aa),Oe=r(aa,"LI",{});var wl=p(Oe);ln=l(wl,"Use a "),Es=r(wl,"A",{href:!0});var Kr=p(Es);nn=l(Kr,"pipeline()"),Kr.forEach(s),rn=l(wl," for audio, vision, and multimodal tasks."),wl.forEach(s),aa.forEach(s),lt=f(e),d(le.$$.fragment,e),nt=f(e),M=r(e,"H2",{class:!0});var jl=p(M);ne=r(jl,"A",{id:!0,class:!0,href:!0});var Qr=p(ne);ha=r(Qr,"SPAN",{});var Jr=p(ha);d(Le.$$.fragment,Jr),Jr.forEach(s),Qr.forEach(s),pn=f(jl),fa=r(jl,"SPAN",{});var Xr=p(fa);on=l(Xr,"Pipeline usage"),Xr.forEach(s),jl.forEach(s),it=f(e),N=r(e,"P",{});var Ie=p(N);cn=l(Ie,"While each task has an associated "),qs=r(Ie,"A",{href:!0});var Zr=p(qs);hn=l(Zr,"pipeline()"),Zr.forEach(s),fn=l(Ie,", it is simpler to use the general "),As=r(Ie,"A",{href:!0});var ep=p(As);un=l(ep,"pipeline()"),ep.forEach(s),mn=l(Ie," abstraction which contains all the task-specific pipelines. The "),Ps=r(Ie,"A",{href:!0});var sp=p(Ps);dn=l(sp,"pipeline()"),sp.forEach(s),gn=l(Ie," automatically loads a default model and a preprocessing class capable of inference for your task."),Ie.forEach(s),rt=f(e),Ts=r(e,"OL",{});var ap=p(Ts);He=r(ap,"LI",{});var _l=p(He);vn=l(_l,"Start by creating a "),Ns=r(_l,"A",{href:!0});var tp=p(Ns);yn=l(tp,"pipeline()"),tp.forEach(s),wn=l(_l," and specify an inference task:"),_l.forEach(s),ap.forEach(s),pt=f(e),d(Ce.$$.fragment,e),ot=f(e),Re=r(e,"OL",{start:!0});var lp=p(Re);Fe=r(lp,"LI",{});var bl=p(Fe);jn=l(bl,"Pass your input text to the "),Is=r(bl,"A",{href:!0});var np=p(Is);_n=l(np,"pipeline()"),np.forEach(s),bn=l(bl,":"),bl.forEach(s),lp.forEach(s),ct=f(e),d(ze.$$.fragment,e),ht=f(e),D=r(e,"P",{});var ta=p(D);xn=l(ta,"Not the result you had in mind? Check out some of the "),Me=r(ta,"A",{href:!0,rel:!0});var ip=p(Me);$n=l(ip,"most downloaded automatic speech recognition models"),ip.forEach(s),kn=l(ta,` on the Hub to see if you can get a better transcription.
Let\u2019s try `),Ge=r(ta,"A",{href:!0,rel:!0});var rp=p(Ge);En=l(rp,"openai/whisper-large"),rp.forEach(s),qn=l(ta,":"),ta.forEach(s),ft=f(e),d(Be.$$.fragment,e),ut=f(e),ie=r(e,"P",{});var xl=p(ie);An=l(xl,`Now this result looks more accurate!
We really encourage you to check out the Hub for models in different languages, models specialized in your field, and more.
You can check out and compare model results directly from your browser on the Hub to see if it fits or
handles corner cases better than other ones.
And if you don\u2019t find a model for your use case, you can always start `),Ss=r(xl,"A",{href:!0});var pp=p(Ss);Pn=l(pp,"training"),pp.forEach(s),Tn=l(xl," your own!"),xl.forEach(s),mt=f(e),Us=r(e,"P",{});var op=p(Us);Nn=l(op,"If you have several inputs, you can pass your input as a list:"),op.forEach(s),dt=f(e),d(Ve.$$.fragment,e),gt=f(e),Ds=r(e,"P",{});var cp=p(Ds);In=l(cp,"If you want to iterate over a whole dataset, or want to use it for inference in a webserver, check out dedicated parts"),cp.forEach(s),vt=f(e),Os=r(e,"P",{});var hp=p(Os);Ls=r(hp,"A",{href:!0});var fp=p(Ls);Sn=l(fp,"Using pipelines on a dataset"),fp.forEach(s),hp.forEach(s),yt=f(e),Hs=r(e,"P",{});var up=p(Hs);Cs=r(up,"A",{href:!0});var mp=p(Cs);Un=l(mp,"Using pipelines for a webserver"),mp.forEach(s),up.forEach(s),wt=f(e),G=r(e,"H2",{class:!0});var $l=p(G);re=r($l,"A",{id:!0,class:!0,href:!0});var dp=p(re);ua=r(dp,"SPAN",{});var gp=p(ua);d(We.$$.fragment,gp),gp.forEach(s),dp.forEach(s),Dn=f($l),ma=r($l,"SPAN",{});var vp=p(ma);On=l(vp,"Parameters"),vp.forEach(s),$l.forEach(s),jt=f(e),Ye=r(e,"P",{});var Rr=p(Ye);Rs=r(Rr,"A",{href:!0});var yp=p(Rs);Ln=l(yp,"pipeline()"),yp.forEach(s),Hn=l(Rr,` supports many parameters; some are task specific, and some are general to all pipelines.
In general you can specify parameters anywhere you want:`),Rr.forEach(s),_t=f(e),d(Ke.$$.fragment,e),bt=f(e),Fs=r(e,"P",{});var wp=p(Fs);Cn=l(wp,"Let\u2019s check out 3 important ones:"),wp.forEach(s),xt=f(e),B=r(e,"H3",{class:!0});var kl=p(B);pe=r(kl,"A",{id:!0,class:!0,href:!0});var jp=p(pe);da=r(jp,"SPAN",{});var _p=p(da);d(Qe.$$.fragment,_p),_p.forEach(s),jp.forEach(s),Rn=f(kl),ga=r(kl,"SPAN",{});var bp=p(ga);Fn=l(bp,"Device"),bp.forEach(s),kl.forEach(s),$t=f(e),oe=r(e,"P",{});var El=p(oe);zn=l(El,"If you use "),va=r(El,"CODE",{});var xp=p(va);Mn=l(xp,"device=n"),xp.forEach(s),Gn=l(El,`, the pipeline automatically puts the model on the specified device.
This will work regardless of whether you are using PyTorch or Tensorflow.`),El.forEach(s),kt=f(e),d(Je.$$.fragment,e),Et=f(e),O=r(e,"P",{});var la=p(O);Bn=l(la,"If the model is too large for a single GPU, you can set "),ya=r(la,"CODE",{});var $p=p(ya);Vn=l($p,'device_map="auto"'),$p.forEach(s),Wn=l(la," to allow \u{1F917} "),Xe=r(la,"A",{href:!0,rel:!0});var kp=p(Xe);Yn=l(kp,"Accelerate"),kp.forEach(s),Kn=l(la," to automatically determine how to load and store the model weights."),la.forEach(s),qt=f(e),d(Ze.$$.fragment,e),At=f(e),I=r(e,"P",{});var Se=p(I);Qn=l(Se,"Note that if  "),wa=r(Se,"CODE",{});var Ep=p(wa);Jn=l(Ep,'device_map="auto"'),Ep.forEach(s),Xn=l(Se," is passed, there is no need to add the argument "),ja=r(Se,"CODE",{});var qp=p(ja);Zn=l(qp,"device=device"),qp.forEach(s),ei=l(Se," when instantiating your "),_a=r(Se,"CODE",{});var Ap=p(_a);si=l(Ap,"pipeline"),Ap.forEach(s),ai=l(Se," as you may encounter some unexpected behavior!"),Se.forEach(s),Pt=f(e),V=r(e,"H3",{class:!0});var ql=p(V);ce=r(ql,"A",{id:!0,class:!0,href:!0});var Pp=p(ce);ba=r(Pp,"SPAN",{});var Tp=p(ba);d(es.$$.fragment,Tp),Tp.forEach(s),Pp.forEach(s),ti=f(ql),xa=r(ql,"SPAN",{});var Np=p(xa);li=l(Np,"Batch size"),Np.forEach(s),ql.forEach(s),Tt=f(e),he=r(e,"P",{});var Al=p(he);ni=l(Al,"By default, pipelines will not batch inference for reasons explained in detail "),ss=r(Al,"A",{href:!0,rel:!0});var Ip=p(ss);ii=l(Ip,"here"),Ip.forEach(s),ri=l(Al,". The reason is that batching is not necessarily faster, and can actually be quite slower in some cases."),Al.forEach(s),Nt=f(e),zs=r(e,"P",{});var Sp=p(zs);pi=l(Sp,"But if it works in your use case, you can use:"),Sp.forEach(s),It=f(e),d(as.$$.fragment,e),St=f(e),Ms=r(e,"P",{});var Up=p(Ms);oi=l(Up,`This runs the pipeline on the 10 provided audio files, but it will pass them in batches of 2
to the model (which is on a GPU, where batching is more likely to help) without requiring any further code from you.
The output should always match what you would have received without batching. It is only meant as a way to help you get more speed out of a pipeline.`),Up.forEach(s),Ut=f(e),fe=r(e,"P",{});var Pl=p(fe);ci=l(Pl,"Pipelines can also alleviate some of the complexities of batching because, for some pipelines, a single item (like a long audio file) needs to be chunked into multiple parts to be processed by a model. The pipeline performs this "),Gs=r(Pl,"A",{href:!0});var Dp=p(Gs);$a=r(Dp,"EM",{});var Op=p($a);hi=l(Op,"chunk batching"),Op.forEach(s),Dp.forEach(s),fi=l(Pl," for you."),Pl.forEach(s),Dt=f(e),W=r(e,"H3",{class:!0});var Tl=p(W);ue=r(Tl,"A",{id:!0,class:!0,href:!0});var Lp=p(ue);ka=r(Lp,"SPAN",{});var Hp=p(ka);d(ts.$$.fragment,Hp),Hp.forEach(s),Lp.forEach(s),ui=f(Tl),Ea=r(Tl,"SPAN",{});var Cp=p(Ea);mi=l(Cp,"Task specific parameters"),Cp.forEach(s),Tl.forEach(s),Ot=f(e),L=r(e,"P",{});var na=p(L);di=l(na,`All tasks provide task specific parameters which allow for additional flexibility and options to help you get your job done.
For instance, the `),me=r(na,"A",{href:!0});var Nl=p(me);gi=l(Nl,"transformers.AutomaticSpeechRecognitionPipeline."),qa=r(Nl,"STRONG",{});var Rp=p(qa);vi=l(Rp,"call"),Rp.forEach(s),yi=l(Nl,"()"),Nl.forEach(s),wi=l(na," method has a "),Aa=r(na,"CODE",{});var Fp=p(Aa);ji=l(Fp,"return_timestamps"),Fp.forEach(s),_i=l(na," parameter which sounds promising for subtitling videos:"),na.forEach(s),Lt=f(e),d(ls.$$.fragment,e),Ht=f(e),de=r(e,"P",{});var Il=p(de);bi=l(Il,"As you can see, the model inferred the text and also outputted "),Pa=r(Il,"STRONG",{});var zp=p(Pa);xi=l(zp,"when"),zp.forEach(s),$i=l(Il,` the various words were pronounced
in the sentence.`),Il.forEach(s),Ct=f(e),H=r(e,"P",{});var ia=p(H);ki=l(ia,`There are many parameters available for each task, so check out each task\u2019s API reference to see what you can tinker with!
For instance, the `),Bs=r(ia,"A",{href:!0});var Mp=p(Bs);Ei=l(Mp,"AutomaticSpeechRecognitionPipeline"),Mp.forEach(s),qi=l(ia," has a "),Ta=r(ia,"CODE",{});var Gp=p(Ta);Ai=l(Gp,"chunk_length_s"),Gp.forEach(s),Pi=l(ia," parameter which is helpful for working on really long audio files (for example, subtitling entire movies or hour-long videos) that a model typically cannot handle on its own."),ia.forEach(s),Rt=f(e),ge=r(e,"P",{});var Sl=p(ge);Ti=l(Sl,"If you can\u2019t find a parameter that would really help you out, feel free to "),ns=r(Sl,"A",{href:!0,rel:!0});var Bp=p(ns);Ni=l(Bp,"request it"),Bp.forEach(s),Ii=l(Sl,"!"),Sl.forEach(s),Ft=f(e),Y=r(e,"H2",{class:!0});var Ul=p(Y);ve=r(Ul,"A",{id:!0,class:!0,href:!0});var Vp=p(ve);Na=r(Vp,"SPAN",{});var Wp=p(Na);d(is.$$.fragment,Wp),Wp.forEach(s),Vp.forEach(s),Si=f(Ul),Ia=r(Ul,"SPAN",{});var Yp=p(Ia);Ui=l(Yp,"Using pipelines on a dataset"),Yp.forEach(s),Ul.forEach(s),zt=f(e),Vs=r(e,"P",{});var Kp=p(Vs);Di=l(Kp,"The pipeline can also run inference on a large dataset. The easiest way we recommend doing this is by using an iterator:"),Kp.forEach(s),Mt=f(e),d(rs.$$.fragment,e),Gt=f(e),C=r(e,"P",{});var ra=p(C);Oi=l(ra,"The iterator "),Sa=r(ra,"CODE",{});var Qp=p(Sa);Li=l(Qp,"data()"),Qp.forEach(s),Hi=l(ra,` yields each result, and the pipeline automatically
recognizes the input is iterable and will start fetching the data while
it continues to process it on the GPU (this uses `),ps=r(ra,"A",{href:!0,rel:!0});var Jp=p(ps);Ci=l(Jp,"DataLoader"),Jp.forEach(s),Ri=l(ra,` under the hood).
This is important because you don\u2019t have to allocate memory for the whole dataset
and you can feed the GPU as fast as possible.`),ra.forEach(s),Bt=f(e),ye=r(e,"P",{});var Dl=p(ye);Fi=l(Dl,"Since batching could speed things up, it may be useful to try tuning the "),Ua=r(Dl,"CODE",{});var Xp=p(Ua);zi=l(Xp,"batch_size"),Xp.forEach(s),Mi=l(Dl," parameter here."),Dl.forEach(s),Vt=f(e),we=r(e,"P",{});var Ol=p(we);Gi=l(Ol,"The simplest way to iterate over a dataset is to just load one from \u{1F917} "),os=r(Ol,"A",{href:!0,rel:!0});var Zp=p(os);Bi=l(Zp,"Datasets"),Zp.forEach(s),Vi=l(Ol,":"),Ol.forEach(s),Wt=f(e),d(cs.$$.fragment,e),Yt=f(e),K=r(e,"H2",{class:!0});var Ll=p(K);je=r(Ll,"A",{id:!0,class:!0,href:!0});var eo=p(je);Da=r(eo,"SPAN",{});var so=p(Da);d(hs.$$.fragment,so),so.forEach(s),eo.forEach(s),Wi=f(Ll),Oa=r(Ll,"SPAN",{});var ao=p(Oa);Yi=l(ao,"Using pipelines for a webserver"),ao.forEach(s),Ll.forEach(s),Kt=f(e),d(_e.$$.fragment,e),Qt=f(e),Ws=r(e,"P",{});var to=p(Ws);Ys=r(to,"A",{href:!0});var lo=p(Ys);Ki=l(lo,"Link"),lo.forEach(s),to.forEach(s),Jt=f(e),Q=r(e,"H2",{class:!0});var Hl=p(Q);be=r(Hl,"A",{id:!0,class:!0,href:!0});var no=p(be);La=r(no,"SPAN",{});var io=p(La);d(fs.$$.fragment,io),io.forEach(s),no.forEach(s),Qi=f(Hl),Ha=r(Hl,"SPAN",{});var ro=p(Ha);Ji=l(ro,"Vision pipeline"),ro.forEach(s),Hl.forEach(s),Xt=f(e),xe=r(e,"P",{});var Cl=p(xe);Xi=l(Cl,"Using a "),Ks=r(Cl,"A",{href:!0});var po=p(Ks);Zi=l(po,"pipeline()"),po.forEach(s),er=l(Cl," for vision tasks is practically identical."),Cl.forEach(s),Zt=f(e),Qs=r(e,"P",{});var oo=p(Qs);sr=l(oo,"Specify your task and pass your image to the classifier. The image can be a link or a local path to the image. For example, what species of cat is shown below?"),oo.forEach(s),el=f(e),Js=r(e,"P",{});var co=p(Js);Xs=r(co,"IMG",{src:!0,alt:!0}),co.forEach(s),sl=f(e),d(us.$$.fragment,e),al=f(e),J=r(e,"H2",{class:!0});var Rl=p(J);$e=r(Rl,"A",{id:!0,class:!0,href:!0});var ho=p($e);Ca=r(ho,"SPAN",{});var fo=p(Ca);d(ms.$$.fragment,fo),fo.forEach(s),ho.forEach(s),ar=f(Rl),Ra=r(Rl,"SPAN",{});var uo=p(Ra);tr=l(uo,"Text pipeline"),uo.forEach(s),Rl.forEach(s),tl=f(e),ke=r(e,"P",{});var Fl=p(ke);lr=l(Fl,"Using a "),Zs=r(Fl,"A",{href:!0});var mo=p(Zs);nr=l(mo,"pipeline()"),mo.forEach(s),ir=l(Fl," for NLP tasks is practically identical."),Fl.forEach(s),ll=f(e),d(ds.$$.fragment,e),nl=f(e),X=r(e,"H2",{class:!0});var zl=p(X);Ee=r(zl,"A",{id:!0,class:!0,href:!0});var go=p(Ee);Fa=r(go,"SPAN",{});var vo=p(Fa);d(gs.$$.fragment,vo),vo.forEach(s),go.forEach(s),rr=f(zl),za=r(zl,"SPAN",{});var yo=p(za);pr=l(yo,"Multimodal pipeline"),yo.forEach(s),zl.forEach(s),il=f(e),qe=r(e,"P",{});var Ml=p(qe);or=l(Ml,"The "),ea=r(Ml,"A",{href:!0});var wo=p(ea);cr=l(wo,"pipeline()"),wo.forEach(s),hr=l(Ml," supports more than one modality. For example, a visual question answering (VQA) task combines text and image. Feel free to use any image link you like and a question you want to ask about the image. The image can be a URL or a local path to the image."),Ml.forEach(s),rl=f(e),Ae=r(e,"P",{});var Gl=p(Ae);fr=l(Gl,"For example, if you use this "),vs=r(Gl,"A",{href:!0,rel:!0});var jo=p(vs);ur=l(jo,"invoice image"),jo.forEach(s),mr=l(Gl,":"),Gl.forEach(s),pl=f(e),d(ys.$$.fragment,e),ol=f(e),d(Pe.$$.fragment,e),cl=f(e),Z=r(e,"H2",{class:!0});var Bl=p(Z);Te=r(Bl,"A",{id:!0,class:!0,href:!0});var _o=p(Te);Ma=r(_o,"SPAN",{});var bo=p(Ma);d(ws.$$.fragment,bo),bo.forEach(s),_o.forEach(s),dr=f(Bl),ee=r(Bl,"SPAN",{});var pa=p(ee);gr=l(pa,"Using "),Ga=r(pa,"CODE",{});var xo=p(Ga);vr=l(xo,"pipeline"),xo.forEach(s),yr=l(pa," on large models with \u{1F917} "),Ba=r(pa,"CODE",{});var $o=p(Ba);wr=l($o,"accelerate"),$o.forEach(s),jr=l(pa,":"),pa.forEach(s),Bl.forEach(s),hl=f(e),P=r(e,"P",{});var F=p(P);_r=l(F,"You can easily run "),Va=r(F,"CODE",{});var ko=p(Va);br=l(ko,"pipeline"),ko.forEach(s),xr=l(F," on large models using \u{1F917} "),Wa=r(F,"CODE",{});var Eo=p(Wa);$r=l(Eo,"accelerate"),Eo.forEach(s),kr=l(F,"! First make sure you have installed "),Ya=r(F,"CODE",{});var qo=p(Ya);Er=l(qo,"accelerate"),qo.forEach(s),qr=l(F," with "),Ka=r(F,"CODE",{});var Ao=p(Ka);Ar=l(Ao,"pip install accelerate"),Ao.forEach(s),Pr=l(F,"."),F.forEach(s),fl=f(e),R=r(e,"P",{});var oa=p(R);Tr=l(oa,"First load your model using "),Qa=r(oa,"CODE",{});var Po=p(Qa);Nr=l(Po,'device_map="auto"'),Po.forEach(s),Ir=l(oa,"! We will use "),Ja=r(oa,"CODE",{});var To=p(Ja);Sr=l(To,"facebook/opt-1.3b"),To.forEach(s),Ur=l(oa," for our example."),oa.forEach(s),ul=f(e),d(js.$$.fragment,e),ml=f(e),se=r(e,"P",{});var at=p(se);Dr=l(at,"You can also pass 8-bit loaded models if you install "),Xa=r(at,"CODE",{});var No=p(Xa);Or=l(No,"bitsandbytes"),No.forEach(s),Lr=l(at," and add the argument "),Za=r(at,"CODE",{});var Io=p(Za);Hr=l(Io,"load_in_8bit=True"),Io.forEach(s),at.forEach(s),dl=f(e),d(_s.$$.fragment,e),gl=f(e),sa=r(e,"P",{});var So=p(sa);Cr=l(So,"Note that you can replace the checkpoint with any of the Hugging Face model that supports large model loading such as BLOOM!"),So.forEach(s),this.h()},h(){c(u,"name","hf:doc:metadata"),c(u,"content",JSON.stringify(Bo)),c($,"id","pipelines-for-inference"),c($,"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"),c($,"href","#pipelines-for-inference"),c(j,"class","relative group"),c(z,"href","/docs/transformers/v4.27.1/en/main_classes/pipelines#transformers.pipeline"),c(Ue,"href","https://huggingface.co/models"),c(Ue,"rel","nofollow"),c($s,"href","/docs/transformers/v4.27.1/en/main_classes/pipelines#transformers.pipeline"),c(ks,"href","/docs/transformers/v4.27.1/en/main_classes/pipelines#transformers.pipeline"),c(Es,"href","/docs/transformers/v4.27.1/en/main_classes/pipelines#transformers.pipeline"),c(ne,"id","pipeline-usage"),c(ne,"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"),c(ne,"href","#pipeline-usage"),c(M,"class","relative group"),c(qs,"href","/docs/transformers/v4.27.1/en/main_classes/pipelines#transformers.pipeline"),c(As,"href","/docs/transformers/v4.27.1/en/main_classes/pipelines#transformers.pipeline"),c(Ps,"href","/docs/transformers/v4.27.1/en/main_classes/pipelines#transformers.pipeline"),c(Ns,"href","/docs/transformers/v4.27.1/en/main_classes/pipelines#transformers.pipeline"),c(Is,"href","/docs/transformers/v4.27.1/en/main_classes/pipelines#transformers.pipeline"),c(Re,"start","2"),c(Me,"href","https://huggingface.co/models?pipeline_tag=automatic-speech-recognition&sort=downloads"),c(Me,"rel","nofollow"),c(Ge,"href","https://huggingface.co/openai/whisper-large"),c(Ge,"rel","nofollow"),c(Ss,"href","training"),c(Ls,"href","#using-pipelines-on-a-dataset"),c(Cs,"href","./pipeline_webserver"),c(re,"id","parameters"),c(re,"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"),c(re,"href","#parameters"),c(G,"class","relative group"),c(Rs,"href","/docs/transformers/v4.27.1/en/main_classes/pipelines#transformers.pipeline"),c(pe,"id","device"),c(pe,"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"),c(pe,"href","#device"),c(B,"class","relative group"),c(Xe,"href","https://huggingface.co/docs/accelerate"),c(Xe,"rel","nofollow"),c(ce,"id","batch-size"),c(ce,"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"),c(ce,"href","#batch-size"),c(V,"class","relative group"),c(ss,"href","https://huggingface.co/docs/transformers/main_classes/pipelines#pipeline-batching"),c(ss,"rel","nofollow"),c(Gs,"href","./main_classes/pipelines#pipeline-chunk-batching"),c(ue,"id","task-specific-parameters"),c(ue,"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"),c(ue,"href","#task-specific-parameters"),c(W,"class","relative group"),c(me,"href","/docs/transformers/v4.27.1/en/main_classes/pipelines#transformers.AutomaticSpeechRecognitionPipeline.__call__"),c(Bs,"href","/docs/transformers/v4.27.1/en/main_classes/pipelines#transformers.AutomaticSpeechRecognitionPipeline"),c(ns,"href","https://github.com/huggingface/transformers/issues/new?assignees=&labels=feature&template=feature-request.yml"),c(ns,"rel","nofollow"),c(ve,"id","using-pipelines-on-a-dataset"),c(ve,"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"),c(ve,"href","#using-pipelines-on-a-dataset"),c(Y,"class","relative group"),c(ps,"href","https://pytorch.org/docs/stable/data.html#torch.utils.data.DataLoader"),c(ps,"rel","nofollow"),c(os,"href","https://github.com/huggingface/datasets/"),c(os,"rel","nofollow"),c(je,"id","using-pipelines-for-a-webserver"),c(je,"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"),c(je,"href","#using-pipelines-for-a-webserver"),c(K,"class","relative group"),c(Ys,"href","./pipeline_webserver"),c(be,"id","vision-pipeline"),c(be,"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"),c(be,"href","#vision-pipeline"),c(Q,"class","relative group"),c(Ks,"href","/docs/transformers/v4.27.1/en/main_classes/pipelines#transformers.pipeline"),Ho(Xs.src,zr="https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/pipeline-cat-chonk.jpeg")||c(Xs,"src",zr),c(Xs,"alt","pipeline-cat-chonk"),c($e,"id","text-pipeline"),c($e,"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"),c($e,"href","#text-pipeline"),c(J,"class","relative group"),c(Zs,"href","/docs/transformers/v4.27.1/en/main_classes/pipelines#transformers.pipeline"),c(Ee,"id","multimodal-pipeline"),c(Ee,"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"),c(Ee,"href","#multimodal-pipeline"),c(X,"class","relative group"),c(ea,"href","/docs/transformers/v4.27.1/en/main_classes/pipelines#transformers.pipeline"),c(vs,"href","https://huggingface.co/spaces/impira/docquery/resolve/2359223c1837a7587402bda0f2643382a6eefeab/invoice.png"),c(vs,"rel","nofollow"),c(Te,"id","using-pipeline-on-large-models-with-accelerate"),c(Te,"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"),c(Te,"href","#using-pipeline-on-large-models-with-accelerate"),c(Z,"class","relative group")},m(e,n){a(document.head,u),o(e,x,n),o(e,j,n),a(j,$),a($,T),g(k,T,null),a(j,A),a(j,q),a(q,te),o(e,b,n),o(e,_,n),a(_,xs),a(_,z),a(z,Vl),a(_,Wl),a(_,Ue),a(Ue,Yl),a(_,Kl),a(_,$s),a($s,Ql),a(_,Jl),o(e,tt,n),o(e,U,n),a(U,De),a(De,Xl),a(De,ks),a(ks,Zl),a(De,en),a(U,sn),a(U,ca),a(ca,an),a(U,tn),a(U,Oe),a(Oe,ln),a(Oe,Es),a(Es,nn),a(Oe,rn),o(e,lt,n),g(le,e,n),o(e,nt,n),o(e,M,n),a(M,ne),a(ne,ha),g(Le,ha,null),a(M,pn),a(M,fa),a(fa,on),o(e,it,n),o(e,N,n),a(N,cn),a(N,qs),a(qs,hn),a(N,fn),a(N,As),a(As,un),a(N,mn),a(N,Ps),a(Ps,dn),a(N,gn),o(e,rt,n),o(e,Ts,n),a(Ts,He),a(He,vn),a(He,Ns),a(Ns,yn),a(He,wn),o(e,pt,n),g(Ce,e,n),o(e,ot,n),o(e,Re,n),a(Re,Fe),a(Fe,jn),a(Fe,Is),a(Is,_n),a(Fe,bn),o(e,ct,n),g(ze,e,n),o(e,ht,n),o(e,D,n),a(D,xn),a(D,Me),a(Me,$n),a(D,kn),a(D,Ge),a(Ge,En),a(D,qn),o(e,ft,n),g(Be,e,n),o(e,ut,n),o(e,ie,n),a(ie,An),a(ie,Ss),a(Ss,Pn),a(ie,Tn),o(e,mt,n),o(e,Us,n),a(Us,Nn),o(e,dt,n),g(Ve,e,n),o(e,gt,n),o(e,Ds,n),a(Ds,In),o(e,vt,n),o(e,Os,n),a(Os,Ls),a(Ls,Sn),o(e,yt,n),o(e,Hs,n),a(Hs,Cs),a(Cs,Un),o(e,wt,n),o(e,G,n),a(G,re),a(re,ua),g(We,ua,null),a(G,Dn),a(G,ma),a(ma,On),o(e,jt,n),o(e,Ye,n),a(Ye,Rs),a(Rs,Ln),a(Ye,Hn),o(e,_t,n),g(Ke,e,n),o(e,bt,n),o(e,Fs,n),a(Fs,Cn),o(e,xt,n),o(e,B,n),a(B,pe),a(pe,da),g(Qe,da,null),a(B,Rn),a(B,ga),a(ga,Fn),o(e,$t,n),o(e,oe,n),a(oe,zn),a(oe,va),a(va,Mn),a(oe,Gn),o(e,kt,n),g(Je,e,n),o(e,Et,n),o(e,O,n),a(O,Bn),a(O,ya),a(ya,Vn),a(O,Wn),a(O,Xe),a(Xe,Yn),a(O,Kn),o(e,qt,n),g(Ze,e,n),o(e,At,n),o(e,I,n),a(I,Qn),a(I,wa),a(wa,Jn),a(I,Xn),a(I,ja),a(ja,Zn),a(I,ei),a(I,_a),a(_a,si),a(I,ai),o(e,Pt,n),o(e,V,n),a(V,ce),a(ce,ba),g(es,ba,null),a(V,ti),a(V,xa),a(xa,li),o(e,Tt,n),o(e,he,n),a(he,ni),a(he,ss),a(ss,ii),a(he,ri),o(e,Nt,n),o(e,zs,n),a(zs,pi),o(e,It,n),g(as,e,n),o(e,St,n),o(e,Ms,n),a(Ms,oi),o(e,Ut,n),o(e,fe,n),a(fe,ci),a(fe,Gs),a(Gs,$a),a($a,hi),a(fe,fi),o(e,Dt,n),o(e,W,n),a(W,ue),a(ue,ka),g(ts,ka,null),a(W,ui),a(W,Ea),a(Ea,mi),o(e,Ot,n),o(e,L,n),a(L,di),a(L,me),a(me,gi),a(me,qa),a(qa,vi),a(me,yi),a(L,wi),a(L,Aa),a(Aa,ji),a(L,_i),o(e,Lt,n),g(ls,e,n),o(e,Ht,n),o(e,de,n),a(de,bi),a(de,Pa),a(Pa,xi),a(de,$i),o(e,Ct,n),o(e,H,n),a(H,ki),a(H,Bs),a(Bs,Ei),a(H,qi),a(H,Ta),a(Ta,Ai),a(H,Pi),o(e,Rt,n),o(e,ge,n),a(ge,Ti),a(ge,ns),a(ns,Ni),a(ge,Ii),o(e,Ft,n),o(e,Y,n),a(Y,ve),a(ve,Na),g(is,Na,null),a(Y,Si),a(Y,Ia),a(Ia,Ui),o(e,zt,n),o(e,Vs,n),a(Vs,Di),o(e,Mt,n),g(rs,e,n),o(e,Gt,n),o(e,C,n),a(C,Oi),a(C,Sa),a(Sa,Li),a(C,Hi),a(C,ps),a(ps,Ci),a(C,Ri),o(e,Bt,n),o(e,ye,n),a(ye,Fi),a(ye,Ua),a(Ua,zi),a(ye,Mi),o(e,Vt,n),o(e,we,n),a(we,Gi),a(we,os),a(os,Bi),a(we,Vi),o(e,Wt,n),g(cs,e,n),o(e,Yt,n),o(e,K,n),a(K,je),a(je,Da),g(hs,Da,null),a(K,Wi),a(K,Oa),a(Oa,Yi),o(e,Kt,n),g(_e,e,n),o(e,Qt,n),o(e,Ws,n),a(Ws,Ys),a(Ys,Ki),o(e,Jt,n),o(e,Q,n),a(Q,be),a(be,La),g(fs,La,null),a(Q,Qi),a(Q,Ha),a(Ha,Ji),o(e,Xt,n),o(e,xe,n),a(xe,Xi),a(xe,Ks),a(Ks,Zi),a(xe,er),o(e,Zt,n),o(e,Qs,n),a(Qs,sr),o(e,el,n),o(e,Js,n),a(Js,Xs),o(e,sl,n),g(us,e,n),o(e,al,n),o(e,J,n),a(J,$e),a($e,Ca),g(ms,Ca,null),a(J,ar),a(J,Ra),a(Ra,tr),o(e,tl,n),o(e,ke,n),a(ke,lr),a(ke,Zs),a(Zs,nr),a(ke,ir),o(e,ll,n),g(ds,e,n),o(e,nl,n),o(e,X,n),a(X,Ee),a(Ee,Fa),g(gs,Fa,null),a(X,rr),a(X,za),a(za,pr),o(e,il,n),o(e,qe,n),a(qe,or),a(qe,ea),a(ea,cr),a(qe,hr),o(e,rl,n),o(e,Ae,n),a(Ae,fr),a(Ae,vs),a(vs,ur),a(Ae,mr),o(e,pl,n),g(ys,e,n),o(e,ol,n),g(Pe,e,n),o(e,cl,n),o(e,Z,n),a(Z,Te),a(Te,Ma),g(ws,Ma,null),a(Z,dr),a(Z,ee),a(ee,gr),a(ee,Ga),a(Ga,vr),a(ee,yr),a(ee,Ba),a(Ba,wr),a(ee,jr),o(e,hl,n),o(e,P,n),a(P,_r),a(P,Va),a(Va,br),a(P,xr),a(P,Wa),a(Wa,$r),a(P,kr),a(P,Ya),a(Ya,Er),a(P,qr),a(P,Ka),a(Ka,Ar),a(P,Pr),o(e,fl,n),o(e,R,n),a(R,Tr),a(R,Qa),a(Qa,Nr),a(R,Ir),a(R,Ja),a(Ja,Sr),a(R,Ur),o(e,ul,n),g(js,e,n),o(e,ml,n),o(e,se,n),a(se,Dr),a(se,Xa),a(Xa,Or),a(se,Lr),a(se,Za),a(Za,Hr),o(e,dl,n),g(_s,e,n),o(e,gl,n),o(e,sa,n),a(sa,Cr),vl=!0},p(e,[n]){const bs={};n&2&&(bs.$$scope={dirty:n,ctx:e}),le.$set(bs);const et={};n&2&&(et.$$scope={dirty:n,ctx:e}),_e.$set(et);const st={};n&2&&(st.$$scope={dirty:n,ctx:e}),Pe.$set(st)},i(e){vl||(v(k.$$.fragment,e),v(le.$$.fragment,e),v(Le.$$.fragment,e),v(Ce.$$.fragment,e),v(ze.$$.fragment,e),v(Be.$$.fragment,e),v(Ve.$$.fragment,e),v(We.$$.fragment,e),v(Ke.$$.fragment,e),v(Qe.$$.fragment,e),v(Je.$$.fragment,e),v(Ze.$$.fragment,e),v(es.$$.fragment,e),v(as.$$.fragment,e),v(ts.$$.fragment,e),v(ls.$$.fragment,e),v(is.$$.fragment,e),v(rs.$$.fragment,e),v(cs.$$.fragment,e),v(hs.$$.fragment,e),v(_e.$$.fragment,e),v(fs.$$.fragment,e),v(us.$$.fragment,e),v(ms.$$.fragment,e),v(ds.$$.fragment,e),v(gs.$$.fragment,e),v(ys.$$.fragment,e),v(Pe.$$.fragment,e),v(ws.$$.fragment,e),v(js.$$.fragment,e),v(_s.$$.fragment,e),vl=!0)},o(e){y(k.$$.fragment,e),y(le.$$.fragment,e),y(Le.$$.fragment,e),y(Ce.$$.fragment,e),y(ze.$$.fragment,e),y(Be.$$.fragment,e),y(Ve.$$.fragment,e),y(We.$$.fragment,e),y(Ke.$$.fragment,e),y(Qe.$$.fragment,e),y(Je.$$.fragment,e),y(Ze.$$.fragment,e),y(es.$$.fragment,e),y(as.$$.fragment,e),y(ts.$$.fragment,e),y(ls.$$.fragment,e),y(is.$$.fragment,e),y(rs.$$.fragment,e),y(cs.$$.fragment,e),y(hs.$$.fragment,e),y(_e.$$.fragment,e),y(fs.$$.fragment,e),y(us.$$.fragment,e),y(ms.$$.fragment,e),y(ds.$$.fragment,e),y(gs.$$.fragment,e),y(ys.$$.fragment,e),y(Pe.$$.fragment,e),y(ws.$$.fragment,e),y(js.$$.fragment,e),y(_s.$$.fragment,e),vl=!1},d(e){s(u),e&&s(x),e&&s(j),w(k),e&&s(b),e&&s(_),e&&s(tt),e&&s(U),e&&s(lt),w(le,e),e&&s(nt),e&&s(M),w(Le),e&&s(it),e&&s(N),e&&s(rt),e&&s(Ts),e&&s(pt),w(Ce,e),e&&s(ot),e&&s(Re),e&&s(ct),w(ze,e),e&&s(ht),e&&s(D),e&&s(ft),w(Be,e),e&&s(ut),e&&s(ie),e&&s(mt),e&&s(Us),e&&s(dt),w(Ve,e),e&&s(gt),e&&s(Ds),e&&s(vt),e&&s(Os),e&&s(yt),e&&s(Hs),e&&s(wt),e&&s(G),w(We),e&&s(jt),e&&s(Ye),e&&s(_t),w(Ke,e),e&&s(bt),e&&s(Fs),e&&s(xt),e&&s(B),w(Qe),e&&s($t),e&&s(oe),e&&s(kt),w(Je,e),e&&s(Et),e&&s(O),e&&s(qt),w(Ze,e),e&&s(At),e&&s(I),e&&s(Pt),e&&s(V),w(es),e&&s(Tt),e&&s(he),e&&s(Nt),e&&s(zs),e&&s(It),w(as,e),e&&s(St),e&&s(Ms),e&&s(Ut),e&&s(fe),e&&s(Dt),e&&s(W),w(ts),e&&s(Ot),e&&s(L),e&&s(Lt),w(ls,e),e&&s(Ht),e&&s(de),e&&s(Ct),e&&s(H),e&&s(Rt),e&&s(ge),e&&s(Ft),e&&s(Y),w(is),e&&s(zt),e&&s(Vs),e&&s(Mt),w(rs,e),e&&s(Gt),e&&s(C),e&&s(Bt),e&&s(ye),e&&s(Vt),e&&s(we),e&&s(Wt),w(cs,e),e&&s(Yt),e&&s(K),w(hs),e&&s(Kt),w(_e,e),e&&s(Qt),e&&s(Ws),e&&s(Jt),e&&s(Q),w(fs),e&&s(Xt),e&&s(xe),e&&s(Zt),e&&s(Qs),e&&s(el),e&&s(Js),e&&s(sl),w(us,e),e&&s(al),e&&s(J),w(ms),e&&s(tl),e&&s(ke),e&&s(ll),w(ds,e),e&&s(nl),e&&s(X),w(gs),e&&s(il),e&&s(qe),e&&s(rl),e&&s(Ae),e&&s(pl),w(ys,e),e&&s(ol),w(Pe,e),e&&s(cl),e&&s(Z),w(ws),e&&s(hl),e&&s(P),e&&s(fl),e&&s(R),e&&s(ul),w(js,e),e&&s(ml),e&&s(se),e&&s(dl),w(_s,e),e&&s(gl),e&&s(sa)}}}const Bo={local:"pipelines-for-inference",sections:[{local:"pipeline-usage",title:"Pipeline usage"},{local:"parameters",sections:[{local:"device",title:"Device"},{local:"batch-size",title:"Batch size"},{local:"task-specific-parameters",title:"Task specific parameters"}],title:"Parameters"},{local:"using-pipelines-on-a-dataset",title:"Using pipelines on a dataset"},{local:"using-pipelines-for-a-webserver",title:"Using pipelines for a webserver"},{local:"vision-pipeline",title:"Vision pipeline"},{local:"text-pipeline",title:"Text pipeline"},{local:"multimodal-pipeline",title:"Multimodal pipeline"},{local:"using-pipeline-on-large-models-with-accelerate",title:"Using `pipeline` on large models with \u{1F917} `accelerate`:"}],title:"Pipelines for inference"};function Vo(ae){return Co(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class Jo extends Uo{constructor(u){super();Do(this,u,Vo,Go,Oo,{})}}export{Jo as default,Bo as metadata};
