import{S as ap,i as tp,s as np,e as t,k as o,w as u,t as c,M as ip,c as n,d as e,m as p,a as i,x as f,h,b as m,G as a,g as r,y as d,L as lp,q as g,o as v,B as b,v as rp}from"../chunks/vendor-hf-doc-builder.js";import{I as j}from"../chunks/IconCopyLink-hf-doc-builder.js";import{C as x}from"../chunks/CodeBlock-hf-doc-builder.js";function op(sr){let _,Da,E,M,Se,xs,In,ze,Ln,Ra,Zs,Nn,Wa,se,Sn,Ga,P,Q,He,ws,zn,Oe,Hn,Ma,ee,On,Qa,ae,Fn,Ba,T,B,Fe,ys,Cn,Ce,Un,Ya,te,Dn,Ka,w,Ue,Rn,Wn,De,Gn,Mn,Re,Qn,Bn,We,Yn,Ja,ks,Va,A,Y,Ge,$s,Kn,Me,Jn,Xa,ne,Vn,Za,ie,Xn,st,qs,et,I,K,Qe,_s,Zn,Be,si,at,J,ei,le,ai,ti,tt,re,ni,nt,V,Ye,ii,li,Ke,ri,it,L,X,Je,Es,oi,Ve,pi,lt,oe,ci,rt,y,Xe,hi,mi,Ze,ui,fi,sa,di,gi,ea,vi,ot,Ps,pt,N,Z,aa,Ts,bi,ta,ji,ct,pe,xi,ht,$,na,wi,yi,ia,ki,$i,la,qi,mt,As,ut,S,ss,ra,Is,_i,oa,Ei,ft,ce,Pi,dt,es,pa,Ti,Ai,Ls,Ii,ca,Li,Ni,gt,he,Si,vt,Ns,bt,z,as,ha,Ss,zi,ma,Hi,jt,me,Oi,xt,ue,Fi,wt,ts,ua,Ci,Ui,fa,Di,yt,zs,kt,H,ns,da,Hs,Ri,ga,Wi,$t,fe,Gi,qt,O,is,va,Os,Mi,ba,Qi,_t,de,Bi,Et,ls,F,Yi,ja,Ki,Ji,xa,Vi,Xi,Zi,k,sl,wa,el,al,ya,tl,nl,ka,il,ll,Pt,Fs,Tt,C,rs,$a,Cs,rl,qa,ol,At,os,pl,ge,cl,hl,It,ve,ml,Lt,ps,_a,ul,fl,Ea,dl,Nt,Us,St,U,cs,Pa,Ds,gl,Ta,vl,zt,be,bl,Ht,je,jl,Ot,hs,Aa,xl,wl,D,yl,xe,kl,$l,we,ql,_l,Ft,Rs,Ct,R,ms,Ia,Ws,El,La,Pl,Ut,ye,Tl,Dt,ke,Al,Rt,us,Na,Il,Ll,Gs,Nl,$e,Sl,zl,Wt,Ms,Gt,W,fs,Sa,Qs,Hl,za,Ol,Mt,qe,Fl,Qt,_e,Cl,Bt,Bs,Yt,G,ds,Ha,Ys,Ul,Oa,Dl,Kt,Ee,Rl,Jt,Pe,Wl,Vt,gs,Ks,Fa,Gl,Ml,Js,Ql,Vs,Ca,Bl,Yl,Xs,Xt,q,Kl,Te,Jl,Vl,Ua,Xl,Zl,Zt;return xs=new j({}),ws=new j({}),ys=new j({}),ks=new x({props:{code:`from transformers import pipeline

classifier = pipeline(task="audio-classification", model="superb/hubert-base-superb-er")
preds = classifier("https://huggingface.co/datasets/Narsil/asr_dummy/resolve/main/mlk.flac")
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>classifier = pipeline(task=<span class="hljs-string">&quot;audio-classification&quot;</span>, model=<span class="hljs-string">&quot;superb/hubert-base-superb-er&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>preds = classifier(<span class="hljs-string">&quot;https://huggingface.co/datasets/Narsil/asr_dummy/resolve/main/mlk.flac&quot;</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.4532</span>, <span class="hljs-string">&#x27;label&#x27;</span>: <span class="hljs-string">&#x27;hap&#x27;</span>},
 {<span class="hljs-string">&#x27;score&#x27;</span>: <span class="hljs-number">0.3622</span>, <span class="hljs-string">&#x27;label&#x27;</span>: <span class="hljs-string">&#x27;sad&#x27;</span>},
 {<span class="hljs-string">&#x27;score&#x27;</span>: <span class="hljs-number">0.0943</span>, <span class="hljs-string">&#x27;label&#x27;</span>: <span class="hljs-string">&#x27;neu&#x27;</span>},
 {<span class="hljs-string">&#x27;score&#x27;</span>: <span class="hljs-number">0.0903</span>, <span class="hljs-string">&#x27;label&#x27;</span>: <span class="hljs-string">&#x27;ang&#x27;</span>}]`}}),$s=new j({}),qs=new x({props:{code:`from transformers import pipeline

transcriber = pipeline(task="automatic-speech-recognition", model="openai/whisper-small")
transcriber("https://huggingface.co/datasets/Narsil/asr_dummy/resolve/main/mlk.flac")`,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>transcriber = pipeline(task=<span class="hljs-string">&quot;automatic-speech-recognition&quot;</span>, model=<span class="hljs-string">&quot;openai/whisper-small&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>transcriber(<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>}`}}),_s=new j({}),Es=new j({}),Ps=new x({props:{code:`from transformers import pipeline

classifier = pipeline(task="image-classification")
preds = classifier(
    "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]
print(*preds, sep="\\n")`,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>classifier = pipeline(task=<span class="hljs-string">&quot;image-classification&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>preds = classifier(
<span class="hljs-meta">... </span>    <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><span class="hljs-built_in">print</span>(*preds, sep=<span class="hljs-string">&quot;\\n&quot;</span>)
{<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>}`}}),Ts=new j({}),As=new x({props:{code:`from transformers import pipeline

detector = pipeline(task="object-detection")
preds = detector(
    "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/pipeline-cat-chonk.jpeg"
)
preds = [{"score": round(pred["score"], 4), "label": pred["label"], "box": pred["box"]} 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>detector = pipeline(task=<span class="hljs-string">&quot;object-detection&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>preds = detector(
<span class="hljs-meta">... </span>    <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-string">&quot;box&quot;</span>: pred[<span class="hljs-string">&quot;box&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.9865</span>,
  <span class="hljs-string">&#x27;label&#x27;</span>: <span class="hljs-string">&#x27;cat&#x27;</span>,
  <span class="hljs-string">&#x27;box&#x27;</span>: {<span class="hljs-string">&#x27;xmin&#x27;</span>: <span class="hljs-number">178</span>, <span class="hljs-string">&#x27;ymin&#x27;</span>: <span class="hljs-number">154</span>, <span class="hljs-string">&#x27;xmax&#x27;</span>: <span class="hljs-number">882</span>, <span class="hljs-string">&#x27;ymax&#x27;</span>: <span class="hljs-number">598</span>}}]`}}),Is=new j({}),Ns=new x({props:{code:`from transformers import pipeline

segmenter = pipeline(task="image-segmentation")
preds = segmenter(
    "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]
print(*preds, sep="\\n")`,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>segmenter = pipeline(task=<span class="hljs-string">&quot;image-segmentation&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>preds = segmenter(
<span class="hljs-meta">... </span>    <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><span class="hljs-built_in">print</span>(*preds, sep=<span class="hljs-string">&quot;\\n&quot;</span>)
{<span class="hljs-string">&#x27;score&#x27;</span>: <span class="hljs-number">0.9879</span>, <span class="hljs-string">&#x27;label&#x27;</span>: <span class="hljs-string">&#x27;LABEL_184&#x27;</span>}
{<span class="hljs-string">&#x27;score&#x27;</span>: <span class="hljs-number">0.9973</span>, <span class="hljs-string">&#x27;label&#x27;</span>: <span class="hljs-string">&#x27;snow&#x27;</span>}
{<span class="hljs-string">&#x27;score&#x27;</span>: <span class="hljs-number">0.9972</span>, <span class="hljs-string">&#x27;label&#x27;</span>: <span class="hljs-string">&#x27;cat&#x27;</span>}`}}),Ss=new j({}),zs=new x({props:{code:`from transformers import pipeline

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

<span class="hljs-meta">&gt;&gt;&gt; </span>depth_estimator = pipeline(task=<span class="hljs-string">&quot;depth-estimation&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>preds = depth_estimator(
<span class="hljs-meta">... </span>    <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>)`}}),Hs=new j({}),Os=new j({}),Fs=new x({props:{code:`from transformers import pipeline

classifier = pipeline(task="sentiment-analysis")
preds = classifier("Hugging Face is the best thing since sliced bread!")
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>classifier = pipeline(task=<span class="hljs-string">&quot;sentiment-analysis&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>preds = classifier(<span class="hljs-string">&quot;Hugging Face is the best thing since sliced bread!&quot;</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.9991</span>, <span class="hljs-string">&#x27;label&#x27;</span>: <span class="hljs-string">&#x27;POSITIVE&#x27;</span>}]`}}),Cs=new j({}),Us=new x({props:{code:`from transformers import pipeline

classifier = pipeline(task="ner")
preds = classifier("Hugging Face is a French company based in New York City.")
preds = [
    {
        "entity": pred["entity"],
        "score": round(pred["score"], 4),
        "index": pred["index"],
        "word": pred["word"],
        "start": pred["start"],
        "end": pred["end"],
    }
    for pred in preds
]
print(*preds, sep="\\n")`,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>classifier = pipeline(task=<span class="hljs-string">&quot;ner&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>preds = classifier(<span class="hljs-string">&quot;Hugging Face is a French company based in New York City.&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>preds = [
<span class="hljs-meta">... </span>    {
<span class="hljs-meta">... </span>        <span class="hljs-string">&quot;entity&quot;</span>: pred[<span class="hljs-string">&quot;entity&quot;</span>],
<span class="hljs-meta">... </span>        <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-meta">... </span>        <span class="hljs-string">&quot;index&quot;</span>: pred[<span class="hljs-string">&quot;index&quot;</span>],
<span class="hljs-meta">... </span>        <span class="hljs-string">&quot;word&quot;</span>: pred[<span class="hljs-string">&quot;word&quot;</span>],
<span class="hljs-meta">... </span>        <span class="hljs-string">&quot;start&quot;</span>: pred[<span class="hljs-string">&quot;start&quot;</span>],
<span class="hljs-meta">... </span>        <span class="hljs-string">&quot;end&quot;</span>: pred[<span class="hljs-string">&quot;end&quot;</span>],
<span class="hljs-meta">... </span>    }
<span class="hljs-meta">... </span>    <span class="hljs-keyword">for</span> pred <span class="hljs-keyword">in</span> preds
<span class="hljs-meta">... </span>]
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-built_in">print</span>(*preds, sep=<span class="hljs-string">&quot;\\n&quot;</span>)
{<span class="hljs-string">&#x27;entity&#x27;</span>: <span class="hljs-string">&#x27;I-ORG&#x27;</span>, <span class="hljs-string">&#x27;score&#x27;</span>: <span class="hljs-number">0.9968</span>, <span class="hljs-string">&#x27;index&#x27;</span>: <span class="hljs-number">1</span>, <span class="hljs-string">&#x27;word&#x27;</span>: <span class="hljs-string">&#x27;Hu&#x27;</span>, <span class="hljs-string">&#x27;start&#x27;</span>: <span class="hljs-number">0</span>, <span class="hljs-string">&#x27;end&#x27;</span>: <span class="hljs-number">2</span>}
{<span class="hljs-string">&#x27;entity&#x27;</span>: <span class="hljs-string">&#x27;I-ORG&#x27;</span>, <span class="hljs-string">&#x27;score&#x27;</span>: <span class="hljs-number">0.9293</span>, <span class="hljs-string">&#x27;index&#x27;</span>: <span class="hljs-number">2</span>, <span class="hljs-string">&#x27;word&#x27;</span>: <span class="hljs-string">&#x27;##gging&#x27;</span>, <span class="hljs-string">&#x27;start&#x27;</span>: <span class="hljs-number">2</span>, <span class="hljs-string">&#x27;end&#x27;</span>: <span class="hljs-number">7</span>}
{<span class="hljs-string">&#x27;entity&#x27;</span>: <span class="hljs-string">&#x27;I-ORG&#x27;</span>, <span class="hljs-string">&#x27;score&#x27;</span>: <span class="hljs-number">0.9763</span>, <span class="hljs-string">&#x27;index&#x27;</span>: <span class="hljs-number">3</span>, <span class="hljs-string">&#x27;word&#x27;</span>: <span class="hljs-string">&#x27;Face&#x27;</span>, <span class="hljs-string">&#x27;start&#x27;</span>: <span class="hljs-number">8</span>, <span class="hljs-string">&#x27;end&#x27;</span>: <span class="hljs-number">12</span>}
{<span class="hljs-string">&#x27;entity&#x27;</span>: <span class="hljs-string">&#x27;I-MISC&#x27;</span>, <span class="hljs-string">&#x27;score&#x27;</span>: <span class="hljs-number">0.9983</span>, <span class="hljs-string">&#x27;index&#x27;</span>: <span class="hljs-number">6</span>, <span class="hljs-string">&#x27;word&#x27;</span>: <span class="hljs-string">&#x27;French&#x27;</span>, <span class="hljs-string">&#x27;start&#x27;</span>: <span class="hljs-number">18</span>, <span class="hljs-string">&#x27;end&#x27;</span>: <span class="hljs-number">24</span>}
{<span class="hljs-string">&#x27;entity&#x27;</span>: <span class="hljs-string">&#x27;I-LOC&#x27;</span>, <span class="hljs-string">&#x27;score&#x27;</span>: <span class="hljs-number">0.999</span>, <span class="hljs-string">&#x27;index&#x27;</span>: <span class="hljs-number">10</span>, <span class="hljs-string">&#x27;word&#x27;</span>: <span class="hljs-string">&#x27;New&#x27;</span>, <span class="hljs-string">&#x27;start&#x27;</span>: <span class="hljs-number">42</span>, <span class="hljs-string">&#x27;end&#x27;</span>: <span class="hljs-number">45</span>}
{<span class="hljs-string">&#x27;entity&#x27;</span>: <span class="hljs-string">&#x27;I-LOC&#x27;</span>, <span class="hljs-string">&#x27;score&#x27;</span>: <span class="hljs-number">0.9987</span>, <span class="hljs-string">&#x27;index&#x27;</span>: <span class="hljs-number">11</span>, <span class="hljs-string">&#x27;word&#x27;</span>: <span class="hljs-string">&#x27;York&#x27;</span>, <span class="hljs-string">&#x27;start&#x27;</span>: <span class="hljs-number">46</span>, <span class="hljs-string">&#x27;end&#x27;</span>: <span class="hljs-number">50</span>}
{<span class="hljs-string">&#x27;entity&#x27;</span>: <span class="hljs-string">&#x27;I-LOC&#x27;</span>, <span class="hljs-string">&#x27;score&#x27;</span>: <span class="hljs-number">0.9992</span>, <span class="hljs-string">&#x27;index&#x27;</span>: <span class="hljs-number">12</span>, <span class="hljs-string">&#x27;word&#x27;</span>: <span class="hljs-string">&#x27;City&#x27;</span>, <span class="hljs-string">&#x27;start&#x27;</span>: <span class="hljs-number">51</span>, <span class="hljs-string">&#x27;end&#x27;</span>: <span class="hljs-number">55</span>}`}}),Ds=new j({}),Rs=new x({props:{code:`from transformers import pipeline

question_answerer = pipeline(task="question-answering")
preds = question_answerer(
    question="What is the name of the repository?",
    context="The name of the repository is huggingface/transformers",
)
print(
    f"score: {round(preds['score'], 4)}, start: {preds['start']}, end: {preds['end']}, answer: {preds['answer']}"
)`,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>question_answerer = pipeline(task=<span class="hljs-string">&quot;question-answering&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>preds = question_answerer(
<span class="hljs-meta">... </span>    question=<span class="hljs-string">&quot;What is the name of the repository?&quot;</span>,
<span class="hljs-meta">... </span>    context=<span class="hljs-string">&quot;The name of the repository is huggingface/transformers&quot;</span>,
<span class="hljs-meta">... </span>)
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-built_in">print</span>(
<span class="hljs-meta">... </span>    <span class="hljs-string">f&quot;score: <span class="hljs-subst">{<span class="hljs-built_in">round</span>(preds[<span class="hljs-string">&#x27;score&#x27;</span>], <span class="hljs-number">4</span>)}</span>, start: <span class="hljs-subst">{preds[<span class="hljs-string">&#x27;start&#x27;</span>]}</span>, end: <span class="hljs-subst">{preds[<span class="hljs-string">&#x27;end&#x27;</span>]}</span>, answer: <span class="hljs-subst">{preds[<span class="hljs-string">&#x27;answer&#x27;</span>]}</span>&quot;</span>
<span class="hljs-meta">... </span>)
score: <span class="hljs-number">0.9327</span>, start: <span class="hljs-number">30</span>, end: <span class="hljs-number">54</span>, answer: huggingface/transformers`}}),Ws=new j({}),Ms=new x({props:{code:`from transformers import pipeline

summarizer = pipeline(task="summarization")
summarizer(
    "In this work, we presented the Transformer, the first sequence transduction model based entirely on attention, replacing the recurrent layers most commonly used in encoder-decoder architectures with multi-headed self-attention. For translation tasks, the Transformer can be trained significantly faster than architectures based on recurrent or convolutional layers. On both WMT 2014 English-to-German and WMT 2014 English-to-French translation tasks, we achieve a new state of the art. In the former task our best model outperforms even all previously reported ensembles."
)`,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>summarizer = pipeline(task=<span class="hljs-string">&quot;summarization&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>summarizer(
<span class="hljs-meta">... </span>    <span class="hljs-string">&quot;In this work, we presented the Transformer, the first sequence transduction model based entirely on attention, replacing the recurrent layers most commonly used in encoder-decoder architectures with multi-headed self-attention. For translation tasks, the Transformer can be trained significantly faster than architectures based on recurrent or convolutional layers. On both WMT 2014 English-to-German and WMT 2014 English-to-French translation tasks, we achieve a new state of the art. In the former task our best model outperforms even all previously reported ensembles.&quot;</span>
<span class="hljs-meta">... </span>)
[{<span class="hljs-string">&#x27;summary_text&#x27;</span>: <span class="hljs-string">&#x27; The Transformer is the first sequence transduction model based entirely on attention . It replaces the recurrent layers most commonly used in encoder-decoder architectures with multi-headed self-attention . For translation tasks, the Transformer can be trained significantly faster than architectures based on recurrent or convolutional layers .&#x27;</span>}]`}}),Qs=new j({}),Bs=new x({props:{code:`from transformers import pipeline

text = "translate English to French: Hugging Face is a community-based open-source platform for machine learning."
translator = pipeline(task="translation", model="t5-small")
translator(text)`,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>text = <span class="hljs-string">&quot;translate English to French: Hugging Face is a community-based open-source platform for machine learning.&quot;</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>translator = pipeline(task=<span class="hljs-string">&quot;translation&quot;</span>, model=<span class="hljs-string">&quot;t5-small&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>translator(text)
[{<span class="hljs-string">&#x27;translation_text&#x27;</span>: <span class="hljs-string">&quot;Hugging Face est une tribune communautaire de l&#x27;apprentissage des machines.&quot;</span>}]`}}),Ys=new j({}),Js=new x({props:{code:`from transformers import pipeline

prompt = "Hugging Face is a community-based open-source platform for machine learning."
generator = pipeline(task="text-generation")
generator(prompt)  # doctest: +SKIP`,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>prompt = <span class="hljs-string">&quot;Hugging Face is a community-based open-source platform for machine learning.&quot;</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>generator = pipeline(task=<span class="hljs-string">&quot;text-generation&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>generator(prompt)  <span class="hljs-comment"># doctest: +SKIP</span>`}}),Xs=new x({props:{code:`text = "Hugging Face is a community-based open-source <mask> for machine learning."
fill_mask = pipeline(task="fill-mask")
preds = fill_mask(text, top_k=1)
preds = [
    {
        "score": round(pred["score"], 4),
        "token": pred["token"],
        "token_str": pred["token_str"],
        "sequence": pred["sequence"],
    }
    for pred in preds
]
preds`,highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span>text = <span class="hljs-string">&quot;Hugging Face is a community-based open-source &lt;mask&gt; for machine learning.&quot;</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>fill_mask = pipeline(task=<span class="hljs-string">&quot;fill-mask&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>preds = fill_mask(text, top_k=<span class="hljs-number">1</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>preds = [
<span class="hljs-meta">... </span>    {
<span class="hljs-meta">... </span>        <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-meta">... </span>        <span class="hljs-string">&quot;token&quot;</span>: pred[<span class="hljs-string">&quot;token&quot;</span>],
<span class="hljs-meta">... </span>        <span class="hljs-string">&quot;token_str&quot;</span>: pred[<span class="hljs-string">&quot;token_str&quot;</span>],
<span class="hljs-meta">... </span>        <span class="hljs-string">&quot;sequence&quot;</span>: pred[<span class="hljs-string">&quot;sequence&quot;</span>],
<span class="hljs-meta">... </span>    }
<span class="hljs-meta">... </span>    <span class="hljs-keyword">for</span> pred <span class="hljs-keyword">in</span> preds
<span class="hljs-meta">... </span>]
<span class="hljs-meta">&gt;&gt;&gt; </span>preds
[{<span class="hljs-string">&#x27;score&#x27;</span>: <span class="hljs-number">0.2236</span>,
  <span class="hljs-string">&#x27;token&#x27;</span>: <span class="hljs-number">1761</span>,
  <span class="hljs-string">&#x27;token_str&#x27;</span>: <span class="hljs-string">&#x27; platform&#x27;</span>,
  <span class="hljs-string">&#x27;sequence&#x27;</span>: <span class="hljs-string">&#x27;Hugging Face is a community-based open-source platform for machine learning.&#x27;</span>}]`}}),{c(){_=t("meta"),Da=o(),E=t("h1"),M=t("a"),Se=t("span"),u(xs.$$.fragment),In=o(),ze=t("span"),Ln=c("What \u{1F917} Transformers can do"),Ra=o(),Zs=t("p"),Nn=c("\u{1F917} Transformers is a library of pretrained state-of-the-art models for natural language processing (NLP), computer vision, and audio and speech processing tasks. Not only does the library contain Transformer models, but it also has non-Transformer models like modern convolutional networks for computer vision tasks. If you look at some of the most popular consumer products today, like smartphones, apps, and televisions, odds are that some kind of deep learning technology is behind it. Want to remove a background object from a picture taken by your smartphone? This is an example of a panoptic segmentation task (don\u2019t worry if you don\u2019t know what this means yet, we\u2019ll describe it in the following sections!)."),Wa=o(),se=t("p"),Sn=c("This page provides an overview of the different speech and audio, computer vision, and NLP tasks that can be solved with the \u{1F917} Transformers library in just three lines of code!"),Ga=o(),P=t("h2"),Q=t("a"),He=t("span"),u(ws.$$.fragment),zn=o(),Oe=t("span"),Hn=c("Audio"),Ma=o(),ee=t("p"),On=c("Audio and speech processing tasks are a little different from the other modalities mainly because audio as an input is a continuous signal. Unlike text, a raw audio waveform can\u2019t be neatly split into discrete chunks the way a sentence can be divided into words. To get around this, the raw audio signal is typically sampled at regular intervals. If you take more samples within an interval, the sampling rate is higher, and the audio more closely resembles the original audio source."),Qa=o(),ae=t("p"),Fn=c("Previous approaches preprocessed the audio to extract useful features from it. It is now more common to start audio and speech processing tasks by directly feeding the raw audio waveform to a feature encoder to extract an audio representation. This simplifies the preprocessing step and allows the model to learn the most essential features."),Ba=o(),T=t("h3"),B=t("a"),Fe=t("span"),u(ys.$$.fragment),Cn=o(),Ce=t("span"),Un=c("Audio classification"),Ya=o(),te=t("p"),Dn=c("Audio classification is a task that labels audio data from a predefined set of classes. It is a broad category with many specific applications, some of which include:"),Ka=o(),w=t("ul"),Ue=t("li"),Rn=c("acoustic scene classification: label audio with a scene label (\u201Coffice\u201D, \u201Cbeach\u201D, \u201Cstadium\u201D)"),Wn=o(),De=t("li"),Gn=c("acoustic event detection: label audio with a sound event label (\u201Ccar horn\u201D, \u201Cwhale calling\u201D, \u201Cglass breaking\u201D)"),Mn=o(),Re=t("li"),Qn=c("tagging: label audio containing multiple sounds (birdsongs, speaker identification in a meeting)"),Bn=o(),We=t("li"),Yn=c("music classification: label music with a genre label (\u201Cmetal\u201D, \u201Chip-hop\u201D, \u201Ccountry\u201D)"),Ja=o(),u(ks.$$.fragment),Va=o(),A=t("h3"),Y=t("a"),Ge=t("span"),u($s.$$.fragment),Kn=o(),Me=t("span"),Jn=c("Automatic speech recognition"),Xa=o(),ne=t("p"),Vn=c("Automatic speech recognition (ASR) transcribes speech into text. It is one of the most common audio tasks due partly to speech being such a natural form of human communication. Today, ASR systems are embedded in \u201Csmart\u201D technology products like speakers, phones, and cars. We can ask our virtual assistants to play music, set reminders, and tell us the weather."),Za=o(),ie=t("p"),Xn=c("But one of the key challenges Transformer architectures have helped with is in low-resource languages. By pretraining on large amounts of speech data, finetuning the model on only one hour of labeled speech data in a low-resource language can still produce high-quality results compared to previous ASR systems trained on 100x more labeled data."),st=o(),u(qs.$$.fragment),et=o(),I=t("h2"),K=t("a"),Qe=t("span"),u(_s.$$.fragment),Zn=o(),Be=t("span"),si=c("Computer vision"),at=o(),J=t("p"),ei=c("One of the first and earliest successful computer vision tasks was recognizing images of zip code numbers using a "),le=t("a"),ai=c("convolutional neural network (CNN)"),ti=c(". An image is composed of pixels, and each pixel has a numerical value. This makes it easy to represent an image as a matrix of pixel values. Each particular combination of pixel values describes the colors of an image."),tt=o(),re=t("p"),ni=c("Two general ways computer vision tasks can be solved are:"),nt=o(),V=t("ol"),Ye=t("li"),ii=c("Use convolutions to learn the hierarchical features of an image from low-level features to high-level abstract things."),li=o(),Ke=t("li"),ri=c("Split an image into patches and use a Transformer to gradually learn how each image patch is related to each other to form an image. Unlike the bottom-up approach favored by a CNN, this is kind of like starting out with a blurry image and then gradually bringing it into focus."),it=o(),L=t("h3"),X=t("a"),Je=t("span"),u(Es.$$.fragment),oi=o(),Ve=t("span"),pi=c("Image classification"),lt=o(),oe=t("p"),ci=c("Image classification labels an entire image from a predefined set of classes. Like most classification tasks, there are many practical use cases for image classification, some of which include:"),rt=o(),y=t("ul"),Xe=t("li"),hi=c("healthcare: label medical images to detect disease or monitor patient health"),mi=o(),Ze=t("li"),ui=c("environment: label satellite images to monitor deforestation, inform wildland management or detect wildfires"),fi=o(),sa=t("li"),di=c("agriculture: label images of crops to monitor plant health or satellite images for land use monitoring"),gi=o(),ea=t("li"),vi=c("ecology: label images of animal or plant species to monitor wildlife populations or track endangered species"),ot=o(),u(Ps.$$.fragment),pt=o(),N=t("h3"),Z=t("a"),aa=t("span"),u(Ts.$$.fragment),bi=o(),ta=t("span"),ji=c("Object detection"),ct=o(),pe=t("p"),xi=c("Unlike image classification, object detection identifies multiple objects within an image and the objects\u2019 positions in an image (defined by the bounding box). Some example applications of object detection include:"),ht=o(),$=t("ul"),na=t("li"),wi=c("self-driving vehicles: detect everyday traffic objects such as other vehicles, pedestrians, and traffic lights"),yi=o(),ia=t("li"),ki=c("remote sensing: disaster monitoring, urban planning, and weather forecasting"),$i=o(),la=t("li"),qi=c("defect detection: detect cracks or structural damage in buildings, and manufacturing defects"),mt=o(),u(As.$$.fragment),ut=o(),S=t("h3"),ss=t("a"),ra=t("span"),u(Is.$$.fragment),_i=o(),oa=t("span"),Ei=c("Image segmentation"),ft=o(),ce=t("p"),Pi=c("Image segmentation is a pixel-level task that assigns every pixel in an image to a class. It differs from object detection, which uses bounding boxes to label and predict objects in an image because segmentation is more granular. Segmentation can detect objects at a pixel-level. There are several types of image segmentation:"),dt=o(),es=t("ul"),pa=t("li"),Ti=c("instance segmentation: in addition to labeling the class of an object, it also labels each distinct instance of an object (\u201Cdog-1\u201D, \u201Cdog-2\u201D)"),Ai=o(),Ls=t("li"),Ii=c("panoptic segmentation: a combination of semantic and instance segmentation; it labels each pixel with a semantic class "),ca=t("strong"),Li=c("and"),Ni=c(" each distinct instance of an object"),gt=o(),he=t("p"),Si=c("Segmentation tasks are helpful in self-driving vehicles to create a pixel-level map of the world around them so they can navigate safely around pedestrians and other vehicles. It is also useful for medical imaging, where the task\u2019s finer granularity can help identify abnormal cells or organ features. Image segmentation can also be used in ecommerce to virtually try on clothes or create augmented reality experiences by overlaying objects in the real world through your camera."),vt=o(),u(Ns.$$.fragment),bt=o(),z=t("h3"),as=t("a"),ha=t("span"),u(Ss.$$.fragment),zi=o(),ma=t("span"),Hi=c("Depth estimation"),jt=o(),me=t("p"),Oi=c("Depth estimation predicts the distance of each pixel in an image from the camera. This computer vision task is especially important for scene understanding and reconstruction. For example, in self-driving cars, vehicles need to understand how far objects like pedestrians, traffic signs, and other vehicles are to avoid obstacles and collisions. Depth information is also helpful for constructing 3D representations from 2D images and can be used to create high-quality 3D representations of biological structures or buildings."),xt=o(),ue=t("p"),Fi=c("There are two approaches to depth estimation:"),wt=o(),ts=t("ul"),ua=t("li"),Ci=c("stereo: depths are estimated by comparing two images of the same image from slightly different angles"),Ui=o(),fa=t("li"),Di=c("monocular: depths are estimated from a single image"),yt=o(),u(zs.$$.fragment),kt=o(),H=t("h2"),ns=t("a"),da=t("span"),u(Hs.$$.fragment),Ri=o(),ga=t("span"),Wi=c("Natural language processing"),$t=o(),fe=t("p"),Gi=c("NLP tasks are among the most common types of tasks because text is such a natural way for us to communicate. To get text into a format recognized by a model, it needs to be tokenized. This means dividing a sequence of text into separate words or subwords (tokens) and then converting these tokens into numbers. As a result, you can represent a sequence of text as a sequence of numbers, and once you have a sequence of numbers, it can be input into a model to solve all sorts of NLP tasks!"),qt=o(),O=t("h3"),is=t("a"),va=t("span"),u(Os.$$.fragment),Mi=o(),ba=t("span"),Qi=c("Text classification"),_t=o(),de=t("p"),Bi=c("Like classification tasks in any modality, text classification labels a sequence of text (it can be sentence-level, a paragraph, or a document) from a predefined set of classes. There are many practical applications for text classification, some of which include:"),Et=o(),ls=t("ul"),F=t("li"),Yi=c("sentiment analysis: label text according to some polarity like "),ja=t("code"),Ki=c("positive"),Ji=c(" or "),xa=t("code"),Vi=c("negative"),Xi=c(" which can inform and support decision-making in fields like politics, finance, and marketing"),Zi=o(),k=t("li"),sl=c("content classification: label text according to some topic to help organize and filter information in news and social media feeds ("),wa=t("code"),el=c("weather"),al=c(", "),ya=t("code"),tl=c("sports"),nl=c(", "),ka=t("code"),il=c("finance"),ll=c(", etc.)"),Pt=o(),u(Fs.$$.fragment),Tt=o(),C=t("h3"),rs=t("a"),$a=t("span"),u(Cs.$$.fragment),rl=o(),qa=t("span"),ol=c("Token classification"),At=o(),os=t("p"),pl=c("In any NLP task, text is preprocessed by separating the sequence of text into individual words or subwords. These are known as "),ge=t("a"),cl=c("tokens"),hl=c(". Token classification assigns each token a label from a predefined set of classes."),It=o(),ve=t("p"),ml=c("Two common types of token classification are:"),Lt=o(),ps=t("ul"),_a=t("li"),ul=c("named entity recognition (NER): label a token according to an entity category like organization, person, location or date. NER is especially popular in biomedical settings, where it can label genes, proteins, and drug names."),fl=o(),Ea=t("li"),dl=c("part-of-speech tagging (POS): label a token according to its part-of-speech like noun, verb, or adjective. POS is useful for helping translation systems understand how two identical words are grammatically different (bank as a noun versus bank as a verb)."),Nt=o(),u(Us.$$.fragment),St=o(),U=t("h3"),cs=t("a"),Pa=t("span"),u(Ds.$$.fragment),gl=o(),Ta=t("span"),vl=c("Question answering"),zt=o(),be=t("p"),bl=c("Question answering is another token-level task that returns an answer to a question, sometimes with context (open-domain) and other times without context (closed-domain). This task happens whenever we ask a virtual assistant something like whether a restaurant is open. It can also provide customer or technical support and help search engines retrieve the relevant information you\u2019re asking for."),Ht=o(),je=t("p"),jl=c("There are two common types of question answering:"),Ot=o(),hs=t("ul"),Aa=t("li"),xl=c("extractive: extractive: given a question and some context, the answer is a span of text from the context the model must extract"),wl=o(),D=t("li"),yl=c("abstractive: given a question and some context, the answer is generated from the context; this approach is handled by the "),xe=t("a"),kl=c("Text2TextGenerationPipeline"),$l=c(" instead of the "),we=t("a"),ql=c("QuestionAnsweringPipeline"),_l=c(" shown below"),Ft=o(),u(Rs.$$.fragment),Ct=o(),R=t("h3"),ms=t("a"),Ia=t("span"),u(Ws.$$.fragment),El=o(),La=t("span"),Pl=c("Summarization"),Ut=o(),ye=t("p"),Tl=c("Summarization creates a shorter version of a text from a longer one while trying to preserve most of the meaning of the original document. Summarization is a sequence-to-sequence task; it outputs a shorter text sequence than the input. There are a lot of long-form documents that can be summarized to help readers quickly understand the main points. Legislative bills, legal and financial documents, patents, and scientific papers are a few examples of documents that could be summarized to save readers time and serve as a reading aid."),Dt=o(),ke=t("p"),Al=c("Like question answering, there are two types of summarization:"),Rt=o(),us=t("ul"),Na=t("li"),Il=c("extractive: identify and extract the most important sentences from the original text"),Ll=o(),Gs=t("li"),Nl=c("abstractive: generate the target summary (which may include new words not in the input document) from the original text; the "),$e=t("a"),Sl=c("SummarizationPipeline"),zl=c(" uses the abstractive approach"),Wt=o(),u(Ms.$$.fragment),Gt=o(),W=t("h3"),fs=t("a"),Sa=t("span"),u(Qs.$$.fragment),Hl=o(),za=t("span"),Ol=c("Translation"),Mt=o(),qe=t("p"),Fl=c("Translation converts a sequence of text in one language to another. It is important in helping people from different backgrounds communicate with each other, help translate content to reach wider audiences, and even be a learning tool to help people learn a new language. Along with summarization, translation is a sequence-to-sequence task, meaning the model receives an input sequence and returns a target output sequence."),Qt=o(),_e=t("p"),Cl=c("In the early days, translation models were mostly monolingual, but recently, there has been increasing interest in multilingual models that can translate between many pairs of languages."),Bt=o(),u(Bs.$$.fragment),Yt=o(),G=t("h3"),ds=t("a"),Ha=t("span"),u(Ys.$$.fragment),Ul=o(),Oa=t("span"),Dl=c("Language modeling"),Kt=o(),Ee=t("p"),Rl=c("Language modeling is a task that predicts a word in a sequence of text. It has become a very popular NLP task because a pretrained language model can be finetuned for many other downstream tasks. Lately, there has been a lot of interest in large language models (LLMs) which demonstrate zero- or few-shot learning. This means the model can solve tasks it wasn\u2019t explicitly trained to do! Language models can be used to generate fluent and convincing text, though you need to be careful since the text may not always be accurate."),Jt=o(),Pe=t("p"),Wl=c("There are two types of language modeling:"),Vt=o(),gs=t("ul"),Ks=t("li"),Fa=t("p"),Gl=c("causal: the model\u2019s objective is to predict the next token in a sequence, and future tokens are masked"),Ml=o(),u(Js.$$.fragment),Ql=o(),Vs=t("li"),Ca=t("p"),Bl=c("masked: the model\u2019s objective is to predict a masked token in a sequence with full access to the tokens in the sequence"),Yl=o(),u(Xs.$$.fragment),Xt=o(),q=t("p"),Kl=c("Hopefully, this page has given you some more background information about all the types of tasks in each modality and the practical importance of each one. In the next "),Te=t("a"),Jl=c("section"),Vl=c(", you\u2019ll learn "),Ua=t("strong"),Xl=c("how"),Zl=c(" \u{1F917} Transformers work to solve these tasks."),this.h()},l(s){const l=ip('[data-svelte="svelte-1phssyn"]',document.head);_=n(l,"META",{name:!0,content:!0}),l.forEach(e),Da=p(s),E=n(s,"H1",{class:!0});var sn=i(E);M=n(sn,"A",{id:!0,class:!0,href:!0});var er=i(M);Se=n(er,"SPAN",{});var ar=i(Se);f(xs.$$.fragment,ar),ar.forEach(e),er.forEach(e),In=p(sn),ze=n(sn,"SPAN",{});var tr=i(ze);Ln=h(tr,"What \u{1F917} Transformers can do"),tr.forEach(e),sn.forEach(e),Ra=p(s),Zs=n(s,"P",{});var nr=i(Zs);Nn=h(nr,"\u{1F917} Transformers is a library of pretrained state-of-the-art models for natural language processing (NLP), computer vision, and audio and speech processing tasks. Not only does the library contain Transformer models, but it also has non-Transformer models like modern convolutional networks for computer vision tasks. If you look at some of the most popular consumer products today, like smartphones, apps, and televisions, odds are that some kind of deep learning technology is behind it. Want to remove a background object from a picture taken by your smartphone? This is an example of a panoptic segmentation task (don\u2019t worry if you don\u2019t know what this means yet, we\u2019ll describe it in the following sections!)."),nr.forEach(e),Wa=p(s),se=n(s,"P",{});var ir=i(se);Sn=h(ir,"This page provides an overview of the different speech and audio, computer vision, and NLP tasks that can be solved with the \u{1F917} Transformers library in just three lines of code!"),ir.forEach(e),Ga=p(s),P=n(s,"H2",{class:!0});var en=i(P);Q=n(en,"A",{id:!0,class:!0,href:!0});var lr=i(Q);He=n(lr,"SPAN",{});var rr=i(He);f(ws.$$.fragment,rr),rr.forEach(e),lr.forEach(e),zn=p(en),Oe=n(en,"SPAN",{});var or=i(Oe);Hn=h(or,"Audio"),or.forEach(e),en.forEach(e),Ma=p(s),ee=n(s,"P",{});var pr=i(ee);On=h(pr,"Audio and speech processing tasks are a little different from the other modalities mainly because audio as an input is a continuous signal. Unlike text, a raw audio waveform can\u2019t be neatly split into discrete chunks the way a sentence can be divided into words. To get around this, the raw audio signal is typically sampled at regular intervals. If you take more samples within an interval, the sampling rate is higher, and the audio more closely resembles the original audio source."),pr.forEach(e),Qa=p(s),ae=n(s,"P",{});var cr=i(ae);Fn=h(cr,"Previous approaches preprocessed the audio to extract useful features from it. It is now more common to start audio and speech processing tasks by directly feeding the raw audio waveform to a feature encoder to extract an audio representation. This simplifies the preprocessing step and allows the model to learn the most essential features."),cr.forEach(e),Ba=p(s),T=n(s,"H3",{class:!0});var an=i(T);B=n(an,"A",{id:!0,class:!0,href:!0});var hr=i(B);Fe=n(hr,"SPAN",{});var mr=i(Fe);f(ys.$$.fragment,mr),mr.forEach(e),hr.forEach(e),Cn=p(an),Ce=n(an,"SPAN",{});var ur=i(Ce);Un=h(ur,"Audio classification"),ur.forEach(e),an.forEach(e),Ya=p(s),te=n(s,"P",{});var fr=i(te);Dn=h(fr,"Audio classification is a task that labels audio data from a predefined set of classes. It is a broad category with many specific applications, some of which include:"),fr.forEach(e),Ka=p(s),w=n(s,"UL",{});var vs=i(w);Ue=n(vs,"LI",{});var dr=i(Ue);Rn=h(dr,"acoustic scene classification: label audio with a scene label (\u201Coffice\u201D, \u201Cbeach\u201D, \u201Cstadium\u201D)"),dr.forEach(e),Wn=p(vs),De=n(vs,"LI",{});var gr=i(De);Gn=h(gr,"acoustic event detection: label audio with a sound event label (\u201Ccar horn\u201D, \u201Cwhale calling\u201D, \u201Cglass breaking\u201D)"),gr.forEach(e),Mn=p(vs),Re=n(vs,"LI",{});var vr=i(Re);Qn=h(vr,"tagging: label audio containing multiple sounds (birdsongs, speaker identification in a meeting)"),vr.forEach(e),Bn=p(vs),We=n(vs,"LI",{});var br=i(We);Yn=h(br,"music classification: label music with a genre label (\u201Cmetal\u201D, \u201Chip-hop\u201D, \u201Ccountry\u201D)"),br.forEach(e),vs.forEach(e),Ja=p(s),f(ks.$$.fragment,s),Va=p(s),A=n(s,"H3",{class:!0});var tn=i(A);Y=n(tn,"A",{id:!0,class:!0,href:!0});var jr=i(Y);Ge=n(jr,"SPAN",{});var xr=i(Ge);f($s.$$.fragment,xr),xr.forEach(e),jr.forEach(e),Kn=p(tn),Me=n(tn,"SPAN",{});var wr=i(Me);Jn=h(wr,"Automatic speech recognition"),wr.forEach(e),tn.forEach(e),Xa=p(s),ne=n(s,"P",{});var yr=i(ne);Vn=h(yr,"Automatic speech recognition (ASR) transcribes speech into text. It is one of the most common audio tasks due partly to speech being such a natural form of human communication. Today, ASR systems are embedded in \u201Csmart\u201D technology products like speakers, phones, and cars. We can ask our virtual assistants to play music, set reminders, and tell us the weather."),yr.forEach(e),Za=p(s),ie=n(s,"P",{});var kr=i(ie);Xn=h(kr,"But one of the key challenges Transformer architectures have helped with is in low-resource languages. By pretraining on large amounts of speech data, finetuning the model on only one hour of labeled speech data in a low-resource language can still produce high-quality results compared to previous ASR systems trained on 100x more labeled data."),kr.forEach(e),st=p(s),f(qs.$$.fragment,s),et=p(s),I=n(s,"H2",{class:!0});var nn=i(I);K=n(nn,"A",{id:!0,class:!0,href:!0});var $r=i(K);Qe=n($r,"SPAN",{});var qr=i(Qe);f(_s.$$.fragment,qr),qr.forEach(e),$r.forEach(e),Zn=p(nn),Be=n(nn,"SPAN",{});var _r=i(Be);si=h(_r,"Computer vision"),_r.forEach(e),nn.forEach(e),at=p(s),J=n(s,"P",{});var ln=i(J);ei=h(ln,"One of the first and earliest successful computer vision tasks was recognizing images of zip code numbers using a "),le=n(ln,"A",{href:!0});var Er=i(le);ai=h(Er,"convolutional neural network (CNN)"),Er.forEach(e),ti=h(ln,". An image is composed of pixels, and each pixel has a numerical value. This makes it easy to represent an image as a matrix of pixel values. Each particular combination of pixel values describes the colors of an image."),ln.forEach(e),tt=p(s),re=n(s,"P",{});var Pr=i(re);ni=h(Pr,"Two general ways computer vision tasks can be solved are:"),Pr.forEach(e),nt=p(s),V=n(s,"OL",{});var rn=i(V);Ye=n(rn,"LI",{});var Tr=i(Ye);ii=h(Tr,"Use convolutions to learn the hierarchical features of an image from low-level features to high-level abstract things."),Tr.forEach(e),li=p(rn),Ke=n(rn,"LI",{});var Ar=i(Ke);ri=h(Ar,"Split an image into patches and use a Transformer to gradually learn how each image patch is related to each other to form an image. Unlike the bottom-up approach favored by a CNN, this is kind of like starting out with a blurry image and then gradually bringing it into focus."),Ar.forEach(e),rn.forEach(e),it=p(s),L=n(s,"H3",{class:!0});var on=i(L);X=n(on,"A",{id:!0,class:!0,href:!0});var Ir=i(X);Je=n(Ir,"SPAN",{});var Lr=i(Je);f(Es.$$.fragment,Lr),Lr.forEach(e),Ir.forEach(e),oi=p(on),Ve=n(on,"SPAN",{});var Nr=i(Ve);pi=h(Nr,"Image classification"),Nr.forEach(e),on.forEach(e),lt=p(s),oe=n(s,"P",{});var Sr=i(oe);ci=h(Sr,"Image classification labels an entire image from a predefined set of classes. Like most classification tasks, there are many practical use cases for image classification, some of which include:"),Sr.forEach(e),rt=p(s),y=n(s,"UL",{});var bs=i(y);Xe=n(bs,"LI",{});var zr=i(Xe);hi=h(zr,"healthcare: label medical images to detect disease or monitor patient health"),zr.forEach(e),mi=p(bs),Ze=n(bs,"LI",{});var Hr=i(Ze);ui=h(Hr,"environment: label satellite images to monitor deforestation, inform wildland management or detect wildfires"),Hr.forEach(e),fi=p(bs),sa=n(bs,"LI",{});var Or=i(sa);di=h(Or,"agriculture: label images of crops to monitor plant health or satellite images for land use monitoring"),Or.forEach(e),gi=p(bs),ea=n(bs,"LI",{});var Fr=i(ea);vi=h(Fr,"ecology: label images of animal or plant species to monitor wildlife populations or track endangered species"),Fr.forEach(e),bs.forEach(e),ot=p(s),f(Ps.$$.fragment,s),pt=p(s),N=n(s,"H3",{class:!0});var pn=i(N);Z=n(pn,"A",{id:!0,class:!0,href:!0});var Cr=i(Z);aa=n(Cr,"SPAN",{});var Ur=i(aa);f(Ts.$$.fragment,Ur),Ur.forEach(e),Cr.forEach(e),bi=p(pn),ta=n(pn,"SPAN",{});var Dr=i(ta);ji=h(Dr,"Object detection"),Dr.forEach(e),pn.forEach(e),ct=p(s),pe=n(s,"P",{});var Rr=i(pe);xi=h(Rr,"Unlike image classification, object detection identifies multiple objects within an image and the objects\u2019 positions in an image (defined by the bounding box). Some example applications of object detection include:"),Rr.forEach(e),ht=p(s),$=n(s,"UL",{});var Ae=i($);na=n(Ae,"LI",{});var Wr=i(na);wi=h(Wr,"self-driving vehicles: detect everyday traffic objects such as other vehicles, pedestrians, and traffic lights"),Wr.forEach(e),yi=p(Ae),ia=n(Ae,"LI",{});var Gr=i(ia);ki=h(Gr,"remote sensing: disaster monitoring, urban planning, and weather forecasting"),Gr.forEach(e),$i=p(Ae),la=n(Ae,"LI",{});var Mr=i(la);qi=h(Mr,"defect detection: detect cracks or structural damage in buildings, and manufacturing defects"),Mr.forEach(e),Ae.forEach(e),mt=p(s),f(As.$$.fragment,s),ut=p(s),S=n(s,"H3",{class:!0});var cn=i(S);ss=n(cn,"A",{id:!0,class:!0,href:!0});var Qr=i(ss);ra=n(Qr,"SPAN",{});var Br=i(ra);f(Is.$$.fragment,Br),Br.forEach(e),Qr.forEach(e),_i=p(cn),oa=n(cn,"SPAN",{});var Yr=i(oa);Ei=h(Yr,"Image segmentation"),Yr.forEach(e),cn.forEach(e),ft=p(s),ce=n(s,"P",{});var Kr=i(ce);Pi=h(Kr,"Image segmentation is a pixel-level task that assigns every pixel in an image to a class. It differs from object detection, which uses bounding boxes to label and predict objects in an image because segmentation is more granular. Segmentation can detect objects at a pixel-level. There are several types of image segmentation:"),Kr.forEach(e),dt=p(s),es=n(s,"UL",{});var hn=i(es);pa=n(hn,"LI",{});var Jr=i(pa);Ti=h(Jr,"instance segmentation: in addition to labeling the class of an object, it also labels each distinct instance of an object (\u201Cdog-1\u201D, \u201Cdog-2\u201D)"),Jr.forEach(e),Ai=p(hn),Ls=n(hn,"LI",{});var mn=i(Ls);Ii=h(mn,"panoptic segmentation: a combination of semantic and instance segmentation; it labels each pixel with a semantic class "),ca=n(mn,"STRONG",{});var Vr=i(ca);Li=h(Vr,"and"),Vr.forEach(e),Ni=h(mn," each distinct instance of an object"),mn.forEach(e),hn.forEach(e),gt=p(s),he=n(s,"P",{});var Xr=i(he);Si=h(Xr,"Segmentation tasks are helpful in self-driving vehicles to create a pixel-level map of the world around them so they can navigate safely around pedestrians and other vehicles. It is also useful for medical imaging, where the task\u2019s finer granularity can help identify abnormal cells or organ features. Image segmentation can also be used in ecommerce to virtually try on clothes or create augmented reality experiences by overlaying objects in the real world through your camera."),Xr.forEach(e),vt=p(s),f(Ns.$$.fragment,s),bt=p(s),z=n(s,"H3",{class:!0});var un=i(z);as=n(un,"A",{id:!0,class:!0,href:!0});var Zr=i(as);ha=n(Zr,"SPAN",{});var so=i(ha);f(Ss.$$.fragment,so),so.forEach(e),Zr.forEach(e),zi=p(un),ma=n(un,"SPAN",{});var eo=i(ma);Hi=h(eo,"Depth estimation"),eo.forEach(e),un.forEach(e),jt=p(s),me=n(s,"P",{});var ao=i(me);Oi=h(ao,"Depth estimation predicts the distance of each pixel in an image from the camera. This computer vision task is especially important for scene understanding and reconstruction. For example, in self-driving cars, vehicles need to understand how far objects like pedestrians, traffic signs, and other vehicles are to avoid obstacles and collisions. Depth information is also helpful for constructing 3D representations from 2D images and can be used to create high-quality 3D representations of biological structures or buildings."),ao.forEach(e),xt=p(s),ue=n(s,"P",{});var to=i(ue);Fi=h(to,"There are two approaches to depth estimation:"),to.forEach(e),wt=p(s),ts=n(s,"UL",{});var fn=i(ts);ua=n(fn,"LI",{});var no=i(ua);Ci=h(no,"stereo: depths are estimated by comparing two images of the same image from slightly different angles"),no.forEach(e),Ui=p(fn),fa=n(fn,"LI",{});var io=i(fa);Di=h(io,"monocular: depths are estimated from a single image"),io.forEach(e),fn.forEach(e),yt=p(s),f(zs.$$.fragment,s),kt=p(s),H=n(s,"H2",{class:!0});var dn=i(H);ns=n(dn,"A",{id:!0,class:!0,href:!0});var lo=i(ns);da=n(lo,"SPAN",{});var ro=i(da);f(Hs.$$.fragment,ro),ro.forEach(e),lo.forEach(e),Ri=p(dn),ga=n(dn,"SPAN",{});var oo=i(ga);Wi=h(oo,"Natural language processing"),oo.forEach(e),dn.forEach(e),$t=p(s),fe=n(s,"P",{});var po=i(fe);Gi=h(po,"NLP tasks are among the most common types of tasks because text is such a natural way for us to communicate. To get text into a format recognized by a model, it needs to be tokenized. This means dividing a sequence of text into separate words or subwords (tokens) and then converting these tokens into numbers. As a result, you can represent a sequence of text as a sequence of numbers, and once you have a sequence of numbers, it can be input into a model to solve all sorts of NLP tasks!"),po.forEach(e),qt=p(s),O=n(s,"H3",{class:!0});var gn=i(O);is=n(gn,"A",{id:!0,class:!0,href:!0});var co=i(is);va=n(co,"SPAN",{});var ho=i(va);f(Os.$$.fragment,ho),ho.forEach(e),co.forEach(e),Mi=p(gn),ba=n(gn,"SPAN",{});var mo=i(ba);Qi=h(mo,"Text classification"),mo.forEach(e),gn.forEach(e),_t=p(s),de=n(s,"P",{});var uo=i(de);Bi=h(uo,"Like classification tasks in any modality, text classification labels a sequence of text (it can be sentence-level, a paragraph, or a document) from a predefined set of classes. There are many practical applications for text classification, some of which include:"),uo.forEach(e),Et=p(s),ls=n(s,"UL",{});var vn=i(ls);F=n(vn,"LI",{});var Ie=i(F);Yi=h(Ie,"sentiment analysis: label text according to some polarity like "),ja=n(Ie,"CODE",{});var fo=i(ja);Ki=h(fo,"positive"),fo.forEach(e),Ji=h(Ie," or "),xa=n(Ie,"CODE",{});var go=i(xa);Vi=h(go,"negative"),go.forEach(e),Xi=h(Ie," which can inform and support decision-making in fields like politics, finance, and marketing"),Ie.forEach(e),Zi=p(vn),k=n(vn,"LI",{});var js=i(k);sl=h(js,"content classification: label text according to some topic to help organize and filter information in news and social media feeds ("),wa=n(js,"CODE",{});var vo=i(wa);el=h(vo,"weather"),vo.forEach(e),al=h(js,", "),ya=n(js,"CODE",{});var bo=i(ya);tl=h(bo,"sports"),bo.forEach(e),nl=h(js,", "),ka=n(js,"CODE",{});var jo=i(ka);il=h(jo,"finance"),jo.forEach(e),ll=h(js,", etc.)"),js.forEach(e),vn.forEach(e),Pt=p(s),f(Fs.$$.fragment,s),Tt=p(s),C=n(s,"H3",{class:!0});var bn=i(C);rs=n(bn,"A",{id:!0,class:!0,href:!0});var xo=i(rs);$a=n(xo,"SPAN",{});var wo=i($a);f(Cs.$$.fragment,wo),wo.forEach(e),xo.forEach(e),rl=p(bn),qa=n(bn,"SPAN",{});var yo=i(qa);ol=h(yo,"Token classification"),yo.forEach(e),bn.forEach(e),At=p(s),os=n(s,"P",{});var jn=i(os);pl=h(jn,"In any NLP task, text is preprocessed by separating the sequence of text into individual words or subwords. These are known as "),ge=n(jn,"A",{href:!0});var ko=i(ge);cl=h(ko,"tokens"),ko.forEach(e),hl=h(jn,". Token classification assigns each token a label from a predefined set of classes."),jn.forEach(e),It=p(s),ve=n(s,"P",{});var $o=i(ve);ml=h($o,"Two common types of token classification are:"),$o.forEach(e),Lt=p(s),ps=n(s,"UL",{});var xn=i(ps);_a=n(xn,"LI",{});var qo=i(_a);ul=h(qo,"named entity recognition (NER): label a token according to an entity category like organization, person, location or date. NER is especially popular in biomedical settings, where it can label genes, proteins, and drug names."),qo.forEach(e),fl=p(xn),Ea=n(xn,"LI",{});var _o=i(Ea);dl=h(_o,"part-of-speech tagging (POS): label a token according to its part-of-speech like noun, verb, or adjective. POS is useful for helping translation systems understand how two identical words are grammatically different (bank as a noun versus bank as a verb)."),_o.forEach(e),xn.forEach(e),Nt=p(s),f(Us.$$.fragment,s),St=p(s),U=n(s,"H3",{class:!0});var wn=i(U);cs=n(wn,"A",{id:!0,class:!0,href:!0});var Eo=i(cs);Pa=n(Eo,"SPAN",{});var Po=i(Pa);f(Ds.$$.fragment,Po),Po.forEach(e),Eo.forEach(e),gl=p(wn),Ta=n(wn,"SPAN",{});var To=i(Ta);vl=h(To,"Question answering"),To.forEach(e),wn.forEach(e),zt=p(s),be=n(s,"P",{});var Ao=i(be);bl=h(Ao,"Question answering is another token-level task that returns an answer to a question, sometimes with context (open-domain) and other times without context (closed-domain). This task happens whenever we ask a virtual assistant something like whether a restaurant is open. It can also provide customer or technical support and help search engines retrieve the relevant information you\u2019re asking for."),Ao.forEach(e),Ht=p(s),je=n(s,"P",{});var Io=i(je);jl=h(Io,"There are two common types of question answering:"),Io.forEach(e),Ot=p(s),hs=n(s,"UL",{});var yn=i(hs);Aa=n(yn,"LI",{});var Lo=i(Aa);xl=h(Lo,"extractive: extractive: given a question and some context, the answer is a span of text from the context the model must extract"),Lo.forEach(e),wl=p(yn),D=n(yn,"LI",{});var Le=i(D);yl=h(Le,"abstractive: given a question and some context, the answer is generated from the context; this approach is handled by the "),xe=n(Le,"A",{href:!0});var No=i(xe);kl=h(No,"Text2TextGenerationPipeline"),No.forEach(e),$l=h(Le," instead of the "),we=n(Le,"A",{href:!0});var So=i(we);ql=h(So,"QuestionAnsweringPipeline"),So.forEach(e),_l=h(Le," shown below"),Le.forEach(e),yn.forEach(e),Ft=p(s),f(Rs.$$.fragment,s),Ct=p(s),R=n(s,"H3",{class:!0});var kn=i(R);ms=n(kn,"A",{id:!0,class:!0,href:!0});var zo=i(ms);Ia=n(zo,"SPAN",{});var Ho=i(Ia);f(Ws.$$.fragment,Ho),Ho.forEach(e),zo.forEach(e),El=p(kn),La=n(kn,"SPAN",{});var Oo=i(La);Pl=h(Oo,"Summarization"),Oo.forEach(e),kn.forEach(e),Ut=p(s),ye=n(s,"P",{});var Fo=i(ye);Tl=h(Fo,"Summarization creates a shorter version of a text from a longer one while trying to preserve most of the meaning of the original document. Summarization is a sequence-to-sequence task; it outputs a shorter text sequence than the input. There are a lot of long-form documents that can be summarized to help readers quickly understand the main points. Legislative bills, legal and financial documents, patents, and scientific papers are a few examples of documents that could be summarized to save readers time and serve as a reading aid."),Fo.forEach(e),Dt=p(s),ke=n(s,"P",{});var Co=i(ke);Al=h(Co,"Like question answering, there are two types of summarization:"),Co.forEach(e),Rt=p(s),us=n(s,"UL",{});var $n=i(us);Na=n($n,"LI",{});var Uo=i(Na);Il=h(Uo,"extractive: identify and extract the most important sentences from the original text"),Uo.forEach(e),Ll=p($n),Gs=n($n,"LI",{});var qn=i(Gs);Nl=h(qn,"abstractive: generate the target summary (which may include new words not in the input document) from the original text; the "),$e=n(qn,"A",{href:!0});var Do=i($e);Sl=h(Do,"SummarizationPipeline"),Do.forEach(e),zl=h(qn," uses the abstractive approach"),qn.forEach(e),$n.forEach(e),Wt=p(s),f(Ms.$$.fragment,s),Gt=p(s),W=n(s,"H3",{class:!0});var _n=i(W);fs=n(_n,"A",{id:!0,class:!0,href:!0});var Ro=i(fs);Sa=n(Ro,"SPAN",{});var Wo=i(Sa);f(Qs.$$.fragment,Wo),Wo.forEach(e),Ro.forEach(e),Hl=p(_n),za=n(_n,"SPAN",{});var Go=i(za);Ol=h(Go,"Translation"),Go.forEach(e),_n.forEach(e),Mt=p(s),qe=n(s,"P",{});var Mo=i(qe);Fl=h(Mo,"Translation converts a sequence of text in one language to another. It is important in helping people from different backgrounds communicate with each other, help translate content to reach wider audiences, and even be a learning tool to help people learn a new language. Along with summarization, translation is a sequence-to-sequence task, meaning the model receives an input sequence and returns a target output sequence."),Mo.forEach(e),Qt=p(s),_e=n(s,"P",{});var Qo=i(_e);Cl=h(Qo,"In the early days, translation models were mostly monolingual, but recently, there has been increasing interest in multilingual models that can translate between many pairs of languages."),Qo.forEach(e),Bt=p(s),f(Bs.$$.fragment,s),Yt=p(s),G=n(s,"H3",{class:!0});var En=i(G);ds=n(En,"A",{id:!0,class:!0,href:!0});var Bo=i(ds);Ha=n(Bo,"SPAN",{});var Yo=i(Ha);f(Ys.$$.fragment,Yo),Yo.forEach(e),Bo.forEach(e),Ul=p(En),Oa=n(En,"SPAN",{});var Ko=i(Oa);Dl=h(Ko,"Language modeling"),Ko.forEach(e),En.forEach(e),Kt=p(s),Ee=n(s,"P",{});var Jo=i(Ee);Rl=h(Jo,"Language modeling is a task that predicts a word in a sequence of text. It has become a very popular NLP task because a pretrained language model can be finetuned for many other downstream tasks. Lately, there has been a lot of interest in large language models (LLMs) which demonstrate zero- or few-shot learning. This means the model can solve tasks it wasn\u2019t explicitly trained to do! Language models can be used to generate fluent and convincing text, though you need to be careful since the text may not always be accurate."),Jo.forEach(e),Jt=p(s),Pe=n(s,"P",{});var Vo=i(Pe);Wl=h(Vo,"There are two types of language modeling:"),Vo.forEach(e),Vt=p(s),gs=n(s,"UL",{});var Pn=i(gs);Ks=n(Pn,"LI",{});var Tn=i(Ks);Fa=n(Tn,"P",{});var Xo=i(Fa);Gl=h(Xo,"causal: the model\u2019s objective is to predict the next token in a sequence, and future tokens are masked"),Xo.forEach(e),Ml=p(Tn),f(Js.$$.fragment,Tn),Tn.forEach(e),Ql=p(Pn),Vs=n(Pn,"LI",{});var An=i(Vs);Ca=n(An,"P",{});var Zo=i(Ca);Bl=h(Zo,"masked: the model\u2019s objective is to predict a masked token in a sequence with full access to the tokens in the sequence"),Zo.forEach(e),Yl=p(An),f(Xs.$$.fragment,An),An.forEach(e),Pn.forEach(e),Xt=p(s),q=n(s,"P",{});var Ne=i(q);Kl=h(Ne,"Hopefully, this page has given you some more background information about all the types of tasks in each modality and the practical importance of each one. In the next "),Te=n(Ne,"A",{href:!0});var sp=i(Te);Jl=h(sp,"section"),sp.forEach(e),Vl=h(Ne,", you\u2019ll learn "),Ua=n(Ne,"STRONG",{});var ep=i(Ua);Xl=h(ep,"how"),ep.forEach(e),Zl=h(Ne," \u{1F917} Transformers work to solve these tasks."),Ne.forEach(e),this.h()},h(){m(_,"name","hf:doc:metadata"),m(_,"content",JSON.stringify(pp)),m(M,"id","what-transformers-can-do"),m(M,"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"),m(M,"href","#what-transformers-can-do"),m(E,"class","relative group"),m(Q,"id","audio"),m(Q,"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"),m(Q,"href","#audio"),m(P,"class","relative group"),m(B,"id","audio-classification"),m(B,"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"),m(B,"href","#audio-classification"),m(T,"class","relative group"),m(Y,"id","automatic-speech-recognition"),m(Y,"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"),m(Y,"href","#automatic-speech-recognition"),m(A,"class","relative group"),m(K,"id","computer-vision"),m(K,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),m(K,"href","#computer-vision"),m(I,"class","relative group"),m(le,"href","glossary#convolution"),m(X,"id","image-classification"),m(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"),m(X,"href","#image-classification"),m(L,"class","relative group"),m(Z,"id","object-detection"),m(Z,"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"),m(Z,"href","#object-detection"),m(N,"class","relative group"),m(ss,"id","image-segmentation"),m(ss,"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"),m(ss,"href","#image-segmentation"),m(S,"class","relative group"),m(as,"id","depth-estimation"),m(as,"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"),m(as,"href","#depth-estimation"),m(z,"class","relative group"),m(ns,"id","natural-language-processing"),m(ns,"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"),m(ns,"href","#natural-language-processing"),m(H,"class","relative group"),m(is,"id","text-classification"),m(is,"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"),m(is,"href","#text-classification"),m(O,"class","relative group"),m(rs,"id","token-classification"),m(rs,"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"),m(rs,"href","#token-classification"),m(C,"class","relative group"),m(ge,"href","/glossary#token"),m(cs,"id","question-answering"),m(cs,"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"),m(cs,"href","#question-answering"),m(U,"class","relative group"),m(xe,"href","/docs/transformers/main/en/main_classes/pipelines#transformers.Text2TextGenerationPipeline"),m(we,"href","/docs/transformers/main/en/main_classes/pipelines#transformers.QuestionAnsweringPipeline"),m(ms,"id","summarization"),m(ms,"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"),m(ms,"href","#summarization"),m(R,"class","relative group"),m($e,"href","/docs/transformers/main/en/main_classes/pipelines#transformers.SummarizationPipeline"),m(fs,"id","translation"),m(fs,"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"),m(fs,"href","#translation"),m(W,"class","relative group"),m(ds,"id","language-modeling"),m(ds,"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"),m(ds,"href","#language-modeling"),m(G,"class","relative group"),m(Te,"href","tasks_explained")},m(s,l){a(document.head,_),r(s,Da,l),r(s,E,l),a(E,M),a(M,Se),d(xs,Se,null),a(E,In),a(E,ze),a(ze,Ln),r(s,Ra,l),r(s,Zs,l),a(Zs,Nn),r(s,Wa,l),r(s,se,l),a(se,Sn),r(s,Ga,l),r(s,P,l),a(P,Q),a(Q,He),d(ws,He,null),a(P,zn),a(P,Oe),a(Oe,Hn),r(s,Ma,l),r(s,ee,l),a(ee,On),r(s,Qa,l),r(s,ae,l),a(ae,Fn),r(s,Ba,l),r(s,T,l),a(T,B),a(B,Fe),d(ys,Fe,null),a(T,Cn),a(T,Ce),a(Ce,Un),r(s,Ya,l),r(s,te,l),a(te,Dn),r(s,Ka,l),r(s,w,l),a(w,Ue),a(Ue,Rn),a(w,Wn),a(w,De),a(De,Gn),a(w,Mn),a(w,Re),a(Re,Qn),a(w,Bn),a(w,We),a(We,Yn),r(s,Ja,l),d(ks,s,l),r(s,Va,l),r(s,A,l),a(A,Y),a(Y,Ge),d($s,Ge,null),a(A,Kn),a(A,Me),a(Me,Jn),r(s,Xa,l),r(s,ne,l),a(ne,Vn),r(s,Za,l),r(s,ie,l),a(ie,Xn),r(s,st,l),d(qs,s,l),r(s,et,l),r(s,I,l),a(I,K),a(K,Qe),d(_s,Qe,null),a(I,Zn),a(I,Be),a(Be,si),r(s,at,l),r(s,J,l),a(J,ei),a(J,le),a(le,ai),a(J,ti),r(s,tt,l),r(s,re,l),a(re,ni),r(s,nt,l),r(s,V,l),a(V,Ye),a(Ye,ii),a(V,li),a(V,Ke),a(Ke,ri),r(s,it,l),r(s,L,l),a(L,X),a(X,Je),d(Es,Je,null),a(L,oi),a(L,Ve),a(Ve,pi),r(s,lt,l),r(s,oe,l),a(oe,ci),r(s,rt,l),r(s,y,l),a(y,Xe),a(Xe,hi),a(y,mi),a(y,Ze),a(Ze,ui),a(y,fi),a(y,sa),a(sa,di),a(y,gi),a(y,ea),a(ea,vi),r(s,ot,l),d(Ps,s,l),r(s,pt,l),r(s,N,l),a(N,Z),a(Z,aa),d(Ts,aa,null),a(N,bi),a(N,ta),a(ta,ji),r(s,ct,l),r(s,pe,l),a(pe,xi),r(s,ht,l),r(s,$,l),a($,na),a(na,wi),a($,yi),a($,ia),a(ia,ki),a($,$i),a($,la),a(la,qi),r(s,mt,l),d(As,s,l),r(s,ut,l),r(s,S,l),a(S,ss),a(ss,ra),d(Is,ra,null),a(S,_i),a(S,oa),a(oa,Ei),r(s,ft,l),r(s,ce,l),a(ce,Pi),r(s,dt,l),r(s,es,l),a(es,pa),a(pa,Ti),a(es,Ai),a(es,Ls),a(Ls,Ii),a(Ls,ca),a(ca,Li),a(Ls,Ni),r(s,gt,l),r(s,he,l),a(he,Si),r(s,vt,l),d(Ns,s,l),r(s,bt,l),r(s,z,l),a(z,as),a(as,ha),d(Ss,ha,null),a(z,zi),a(z,ma),a(ma,Hi),r(s,jt,l),r(s,me,l),a(me,Oi),r(s,xt,l),r(s,ue,l),a(ue,Fi),r(s,wt,l),r(s,ts,l),a(ts,ua),a(ua,Ci),a(ts,Ui),a(ts,fa),a(fa,Di),r(s,yt,l),d(zs,s,l),r(s,kt,l),r(s,H,l),a(H,ns),a(ns,da),d(Hs,da,null),a(H,Ri),a(H,ga),a(ga,Wi),r(s,$t,l),r(s,fe,l),a(fe,Gi),r(s,qt,l),r(s,O,l),a(O,is),a(is,va),d(Os,va,null),a(O,Mi),a(O,ba),a(ba,Qi),r(s,_t,l),r(s,de,l),a(de,Bi),r(s,Et,l),r(s,ls,l),a(ls,F),a(F,Yi),a(F,ja),a(ja,Ki),a(F,Ji),a(F,xa),a(xa,Vi),a(F,Xi),a(ls,Zi),a(ls,k),a(k,sl),a(k,wa),a(wa,el),a(k,al),a(k,ya),a(ya,tl),a(k,nl),a(k,ka),a(ka,il),a(k,ll),r(s,Pt,l),d(Fs,s,l),r(s,Tt,l),r(s,C,l),a(C,rs),a(rs,$a),d(Cs,$a,null),a(C,rl),a(C,qa),a(qa,ol),r(s,At,l),r(s,os,l),a(os,pl),a(os,ge),a(ge,cl),a(os,hl),r(s,It,l),r(s,ve,l),a(ve,ml),r(s,Lt,l),r(s,ps,l),a(ps,_a),a(_a,ul),a(ps,fl),a(ps,Ea),a(Ea,dl),r(s,Nt,l),d(Us,s,l),r(s,St,l),r(s,U,l),a(U,cs),a(cs,Pa),d(Ds,Pa,null),a(U,gl),a(U,Ta),a(Ta,vl),r(s,zt,l),r(s,be,l),a(be,bl),r(s,Ht,l),r(s,je,l),a(je,jl),r(s,Ot,l),r(s,hs,l),a(hs,Aa),a(Aa,xl),a(hs,wl),a(hs,D),a(D,yl),a(D,xe),a(xe,kl),a(D,$l),a(D,we),a(we,ql),a(D,_l),r(s,Ft,l),d(Rs,s,l),r(s,Ct,l),r(s,R,l),a(R,ms),a(ms,Ia),d(Ws,Ia,null),a(R,El),a(R,La),a(La,Pl),r(s,Ut,l),r(s,ye,l),a(ye,Tl),r(s,Dt,l),r(s,ke,l),a(ke,Al),r(s,Rt,l),r(s,us,l),a(us,Na),a(Na,Il),a(us,Ll),a(us,Gs),a(Gs,Nl),a(Gs,$e),a($e,Sl),a(Gs,zl),r(s,Wt,l),d(Ms,s,l),r(s,Gt,l),r(s,W,l),a(W,fs),a(fs,Sa),d(Qs,Sa,null),a(W,Hl),a(W,za),a(za,Ol),r(s,Mt,l),r(s,qe,l),a(qe,Fl),r(s,Qt,l),r(s,_e,l),a(_e,Cl),r(s,Bt,l),d(Bs,s,l),r(s,Yt,l),r(s,G,l),a(G,ds),a(ds,Ha),d(Ys,Ha,null),a(G,Ul),a(G,Oa),a(Oa,Dl),r(s,Kt,l),r(s,Ee,l),a(Ee,Rl),r(s,Jt,l),r(s,Pe,l),a(Pe,Wl),r(s,Vt,l),r(s,gs,l),a(gs,Ks),a(Ks,Fa),a(Fa,Gl),a(Ks,Ml),d(Js,Ks,null),a(gs,Ql),a(gs,Vs),a(Vs,Ca),a(Ca,Bl),a(Vs,Yl),d(Xs,Vs,null),r(s,Xt,l),r(s,q,l),a(q,Kl),a(q,Te),a(Te,Jl),a(q,Vl),a(q,Ua),a(Ua,Xl),a(q,Zl),Zt=!0},p:lp,i(s){Zt||(g(xs.$$.fragment,s),g(ws.$$.fragment,s),g(ys.$$.fragment,s),g(ks.$$.fragment,s),g($s.$$.fragment,s),g(qs.$$.fragment,s),g(_s.$$.fragment,s),g(Es.$$.fragment,s),g(Ps.$$.fragment,s),g(Ts.$$.fragment,s),g(As.$$.fragment,s),g(Is.$$.fragment,s),g(Ns.$$.fragment,s),g(Ss.$$.fragment,s),g(zs.$$.fragment,s),g(Hs.$$.fragment,s),g(Os.$$.fragment,s),g(Fs.$$.fragment,s),g(Cs.$$.fragment,s),g(Us.$$.fragment,s),g(Ds.$$.fragment,s),g(Rs.$$.fragment,s),g(Ws.$$.fragment,s),g(Ms.$$.fragment,s),g(Qs.$$.fragment,s),g(Bs.$$.fragment,s),g(Ys.$$.fragment,s),g(Js.$$.fragment,s),g(Xs.$$.fragment,s),Zt=!0)},o(s){v(xs.$$.fragment,s),v(ws.$$.fragment,s),v(ys.$$.fragment,s),v(ks.$$.fragment,s),v($s.$$.fragment,s),v(qs.$$.fragment,s),v(_s.$$.fragment,s),v(Es.$$.fragment,s),v(Ps.$$.fragment,s),v(Ts.$$.fragment,s),v(As.$$.fragment,s),v(Is.$$.fragment,s),v(Ns.$$.fragment,s),v(Ss.$$.fragment,s),v(zs.$$.fragment,s),v(Hs.$$.fragment,s),v(Os.$$.fragment,s),v(Fs.$$.fragment,s),v(Cs.$$.fragment,s),v(Us.$$.fragment,s),v(Ds.$$.fragment,s),v(Rs.$$.fragment,s),v(Ws.$$.fragment,s),v(Ms.$$.fragment,s),v(Qs.$$.fragment,s),v(Bs.$$.fragment,s),v(Ys.$$.fragment,s),v(Js.$$.fragment,s),v(Xs.$$.fragment,s),Zt=!1},d(s){e(_),s&&e(Da),s&&e(E),b(xs),s&&e(Ra),s&&e(Zs),s&&e(Wa),s&&e(se),s&&e(Ga),s&&e(P),b(ws),s&&e(Ma),s&&e(ee),s&&e(Qa),s&&e(ae),s&&e(Ba),s&&e(T),b(ys),s&&e(Ya),s&&e(te),s&&e(Ka),s&&e(w),s&&e(Ja),b(ks,s),s&&e(Va),s&&e(A),b($s),s&&e(Xa),s&&e(ne),s&&e(Za),s&&e(ie),s&&e(st),b(qs,s),s&&e(et),s&&e(I),b(_s),s&&e(at),s&&e(J),s&&e(tt),s&&e(re),s&&e(nt),s&&e(V),s&&e(it),s&&e(L),b(Es),s&&e(lt),s&&e(oe),s&&e(rt),s&&e(y),s&&e(ot),b(Ps,s),s&&e(pt),s&&e(N),b(Ts),s&&e(ct),s&&e(pe),s&&e(ht),s&&e($),s&&e(mt),b(As,s),s&&e(ut),s&&e(S),b(Is),s&&e(ft),s&&e(ce),s&&e(dt),s&&e(es),s&&e(gt),s&&e(he),s&&e(vt),b(Ns,s),s&&e(bt),s&&e(z),b(Ss),s&&e(jt),s&&e(me),s&&e(xt),s&&e(ue),s&&e(wt),s&&e(ts),s&&e(yt),b(zs,s),s&&e(kt),s&&e(H),b(Hs),s&&e($t),s&&e(fe),s&&e(qt),s&&e(O),b(Os),s&&e(_t),s&&e(de),s&&e(Et),s&&e(ls),s&&e(Pt),b(Fs,s),s&&e(Tt),s&&e(C),b(Cs),s&&e(At),s&&e(os),s&&e(It),s&&e(ve),s&&e(Lt),s&&e(ps),s&&e(Nt),b(Us,s),s&&e(St),s&&e(U),b(Ds),s&&e(zt),s&&e(be),s&&e(Ht),s&&e(je),s&&e(Ot),s&&e(hs),s&&e(Ft),b(Rs,s),s&&e(Ct),s&&e(R),b(Ws),s&&e(Ut),s&&e(ye),s&&e(Dt),s&&e(ke),s&&e(Rt),s&&e(us),s&&e(Wt),b(Ms,s),s&&e(Gt),s&&e(W),b(Qs),s&&e(Mt),s&&e(qe),s&&e(Qt),s&&e(_e),s&&e(Bt),b(Bs,s),s&&e(Yt),s&&e(G),b(Ys),s&&e(Kt),s&&e(Ee),s&&e(Jt),s&&e(Pe),s&&e(Vt),s&&e(gs),b(Js),b(Xs),s&&e(Xt),s&&e(q)}}}const pp={local:"what-transformers-can-do",sections:[{local:"audio",sections:[{local:"audio-classification",title:"Audio classification"},{local:"automatic-speech-recognition",title:"Automatic speech recognition"}],title:"Audio"},{local:"computer-vision",sections:[{local:"image-classification",title:"Image classification"},{local:"object-detection",title:"Object detection"},{local:"image-segmentation",title:"Image segmentation"},{local:"depth-estimation",title:"Depth estimation"}],title:"Computer vision"},{local:"natural-language-processing",sections:[{local:"text-classification",title:"Text classification"},{local:"token-classification",title:"Token classification"},{local:"question-answering",title:"Question answering"},{local:"summarization",title:"Summarization"},{local:"translation",title:"Translation"},{local:"language-modeling",title:"Language modeling"}],title:"Natural language processing"}],title:"What \u{1F917} Transformers can do"};function cp(sr){return rp(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class fp extends ap{constructor(_){super();tp(this,_,cp,op,np,{})}}export{fp as default,pp as metadata};
