import{S as qp,i as Pp,s as Ip,e as n,k as h,w as $,t as i,M as Ap,c as o,d as t,m as c,a as l,x as b,h as r,b as u,N as Sp,F as s,g as p,y as x,q as _,o as k,B as E,v as Hp}from"../../chunks/vendor-1e8b365d.js";import{T as Fe}from"../../chunks/Tip-62b14c6e.js";import{Y as Op}from"../../chunks/Youtube-c2a8cc39.js";import{I as F}from"../../chunks/IconCopyLink-483c28ba.js";import{C as S}from"../../chunks/CodeBlock-e5764662.js";import{D as Cp}from"../../chunks/DocNotebookDropdown-37d928d3.js";function Np(O){let f,y,d,v,g,m,w,T,H;return{c(){f=i("\u{1F440} See that "),y=n("em"),d=i("Open in Colab"),v=i(` button on the top right? Click on it to open a Google Colab notebook with all the code samples of this section. This button will be present in any section containing code examples. 
`),g=n("p"),m=i("If you want to run the examples locally, we recommend taking a look at the "),w=n("a"),T=i("setup"),H=i("."),this.h()},l(q){f=r(q,"\u{1F440} See that "),y=o(q,"EM",{});var P=l(y);d=r(P,"Open in Colab"),P.forEach(t),v=r(q,` button on the top right? Click on it to open a Google Colab notebook with all the code samples of this section. This button will be present in any section containing code examples. 
`),g=o(q,"P",{});var A=l(g);m=r(A,"If you want to run the examples locally, we recommend taking a look at the "),w=o(A,"A",{href:!0});var j=l(w);T=r(j,"setup"),j.forEach(t),H=r(A,"."),A.forEach(t),this.h()},h(){u(w,"href","/course/chapter0")},m(q,P){p(q,f,P),p(q,y,P),s(y,d),p(q,v,P),p(q,g,P),s(g,m),s(g,w),s(w,T),s(g,H)},d(q){q&&t(f),q&&t(y),q&&t(v),q&&t(g)}}}function zp(O){let f,y,d,v;return{c(){f=i("\u26A0\uFE0F The Hugging Face Hub is not limited to Transformer models. Anyone can share any kind of models or datasets they want! "),y=n("a"),d=i("Create a huggingface.co"),v=i(" account to benefit from all available features!"),this.h()},l(g){f=r(g,"\u26A0\uFE0F The Hugging Face Hub is not limited to Transformer models. Anyone can share any kind of models or datasets they want! "),y=o(g,"A",{href:!0});var m=l(y);d=r(m,"Create a huggingface.co"),m.forEach(t),v=r(g," account to benefit from all available features!"),this.h()},h(){u(y,"href","https://huggingface.co/join")},m(g,m){p(g,f,m),p(g,y,m),s(y,d),p(g,v,m)},d(g){g&&t(f),g&&t(y),g&&t(v)}}}function Dp(O){let f,y,d,v,g;return{c(){f=n("p"),y=i("\u270F\uFE0F "),d=n("strong"),v=i("Try it out!"),g=i(" Play around with your own sequences and labels and see how the model behaves.")},l(m){f=o(m,"P",{});var w=l(f);y=r(w,"\u270F\uFE0F "),d=o(w,"STRONG",{});var T=l(d);v=r(T,"Try it out!"),T.forEach(t),g=r(w," Play around with your own sequences and labels and see how the model behaves."),w.forEach(t)},m(m,w){p(m,f,w),s(f,y),s(f,d),s(d,v),s(f,g)},d(m){m&&t(f)}}}function Fp(O){let f,y,d,v,g,m,w,T,H,q,P;return{c(){f=n("p"),y=i("\u270F\uFE0F "),d=n("strong"),v=i("Try it out!"),g=i(" Use the "),m=n("code"),w=i("num_return_sequences"),T=i(" and "),H=n("code"),q=i("max_length"),P=i(" arguments to generate two sentences of 15 words each.")},l(A){f=o(A,"P",{});var j=l(f);y=r(j,"\u270F\uFE0F "),d=o(j,"STRONG",{});var V=l(d);v=r(V,"Try it out!"),V.forEach(t),g=r(j," Use the "),m=o(j,"CODE",{});var L=l(m);w=r(L,"num_return_sequences"),L.forEach(t),T=r(j," and "),H=o(j,"CODE",{});var Z=l(H);q=r(Z,"max_length"),Z.forEach(t),P=r(j," arguments to generate two sentences of 15 words each."),j.forEach(t)},m(A,j){p(A,f,j),s(f,y),s(f,d),s(d,v),s(f,g),s(f,m),s(m,w),s(f,T),s(f,H),s(H,q),s(f,P)},d(A){A&&t(f)}}}function Lp(O){let f,y,d,v,g;return{c(){f=n("p"),y=i("\u270F\uFE0F "),d=n("strong"),v=i("Try it out!"),g=i(" Use the filters to find a text generation model for another language. Feel free to play with the widget and use it in a pipeline!")},l(m){f=o(m,"P",{});var w=l(f);y=r(w,"\u270F\uFE0F "),d=o(w,"STRONG",{});var T=l(d);v=r(T,"Try it out!"),T.forEach(t),g=r(w," Use the filters to find a text generation model for another language. Feel free to play with the widget and use it in a pipeline!"),w.forEach(t)},m(m,w){p(m,f,w),s(f,y),s(f,d),s(d,v),s(f,g)},d(m){m&&t(f)}}}function Mp(O){let f,y,d,v,g,m,w,T,H,q,P;return{c(){f=n("p"),y=i("\u270F\uFE0F "),d=n("strong"),v=i("Try it out!"),g=i(" Search for the "),m=n("code"),w=i("bert-base-cased"),T=i(" model on the Hub and identify its mask word in the Inference API widget. What does this model predict for the sentence in our "),H=n("code"),q=i("pipeline"),P=i(" example above?")},l(A){f=o(A,"P",{});var j=l(f);y=r(j,"\u270F\uFE0F "),d=o(j,"STRONG",{});var V=l(d);v=r(V,"Try it out!"),V.forEach(t),g=r(j," Search for the "),m=o(j,"CODE",{});var L=l(m);w=r(L,"bert-base-cased"),L.forEach(t),T=r(j," model on the Hub and identify its mask word in the Inference API widget. What does this model predict for the sentence in our "),H=o(j,"CODE",{});var Z=l(H);q=r(Z,"pipeline"),Z.forEach(t),P=r(j," example above?"),j.forEach(t)},m(A,j){p(A,f,j),s(f,y),s(f,d),s(d,v),s(f,g),s(f,m),s(m,w),s(f,T),s(f,H),s(H,q),s(f,P)},d(A){A&&t(f)}}}function Rp(O){let f,y,d,v,g;return{c(){f=n("p"),y=i("\u270F\uFE0F "),d=n("strong"),v=i("Try it out!"),g=i(" Search the Model Hub for a model able to do part-of-speech tagging (usually abbreviated as POS) in English. What does this model predict for the sentence in the example above?")},l(m){f=o(m,"P",{});var w=l(f);y=r(w,"\u270F\uFE0F "),d=o(w,"STRONG",{});var T=l(d);v=r(T,"Try it out!"),T.forEach(t),g=r(w," Search the Model Hub for a model able to do part-of-speech tagging (usually abbreviated as POS) in English. What does this model predict for the sentence in the example above?"),w.forEach(t)},m(m,w){p(m,f,w),s(f,y),s(f,d),s(d,v),s(f,g)},d(m){m&&t(f)}}}function Gp(O){let f,y,d,v,g;return{c(){f=n("p"),y=i("\u270F\uFE0F "),d=n("strong"),v=i("Try it out!"),g=i(" Search for translation models in other languages and try to translate the previous sentence into a few different languages.")},l(m){f=o(m,"P",{});var w=l(f);y=r(w,"\u270F\uFE0F "),d=o(w,"STRONG",{});var T=l(d);v=r(T,"Try it out!"),T.forEach(t),g=r(w," Search for translation models in other languages and try to translate the previous sentence into a few different languages."),w.forEach(t)},m(m,w){p(m,f,w),s(f,y),s(f,d),s(d,v),s(f,g)},d(m){m&&t(f)}}}function Wp(O){let f,y,d,v,g,m,w,T,H,q,P,A,j,V,L,Z,so,ua,re,ma,Q,le,Jt,Le,ao,Kt,no,da,It,oo,ga,pe,Fr,wa,M,io,Me,ro,lo,Re,po,ho,ya,he,va,At,co,$a,J,ce,Xt,Ge,fo,es,uo,ba,We,xa,fe,mo,ts,go,wo,_a,Be,ka,Ye,Ea,St,yo,ja,Ue,Ta,Ve,qa,ue,vo,ss,$o,bo,Pa,Ht,xo,Ia,R,as,_o,ko,ns,Eo,jo,os,To,Aa,me,qo,Ze,Po,Io,Sa,I,Ot,is,Ao,So,Ho,rs,ls,Oo,Co,Ct,ps,No,zo,Do,hs,cs,Fo,Lo,fs,us,Mo,Ro,ms,ds,Go,Wo,gs,ws,Bo,Yo,ys,vs,Uo,Vo,$s,bs,Zo,Ha,Nt,Qo,Oa,K,de,xs,Qe,Jo,_s,Ko,Ca,ge,Xo,ks,ei,ti,Na,Je,za,Ke,Da,we,si,Es,ai,ni,Fa,ye,La,X,ve,js,Xe,oi,Ts,ii,Ma,zt,ri,Ra,et,Ga,tt,Wa,G,li,qs,pi,hi,Ps,ci,fi,Ba,$e,Ya,ee,be,Is,st,ui,As,mi,Ua,W,di,at,gi,wi,nt,yi,vi,Va,xe,$i,ot,Ss,bi,xi,Za,it,Qa,rt,Ja,Dt,_i,Ka,Ft,ki,Xa,_e,en,te,ke,Hs,lt,Ei,Os,ji,tn,Ee,Ti,pt,qi,Pi,sn,je,Ii,ht,Ai,Si,an,se,Te,Cs,ct,Hi,Ns,Oi,nn,qe,Ci,zs,Ni,zi,on,ft,rn,ut,ln,D,Di,Ds,Fi,Li,Fs,Mi,Ri,Ls,Gi,Wi,pn,Pe,hn,ae,Ie,Ms,mt,Bi,Rs,Yi,cn,Lt,Ui,fn,dt,un,gt,mn,Mt,Vi,dn,C,Zi,Gs,Qi,Ji,Ws,Ki,Xi,Bs,er,tr,Ys,sr,ar,Us,nr,or,Vs,ir,rr,gn,Ae,wn,ne,Se,Zs,wt,lr,Qs,pr,yn,He,hr,Js,cr,fr,vn,yt,$n,vt,bn,Rt,ur,xn,oe,Oe,Ks,$t,mr,Xs,dr,_n,Gt,gr,kn,bt,En,xt,jn,B,wr,ea,yr,vr,ta,$r,br,Tn,ie,Ce,sa,_t,xr,aa,_r,qn,Y,kr,na,Er,jr,kt,Tr,qr,Pn,Et,In,jt,An,U,Pr,oa,Ir,Ar,ia,Sr,Hr,Sn,Ne,Hn,ze,Or,ra,Cr,Nr,On;return m=new F({}),P=new Cp({props:{classNames:"absolute z-10 right-0 top-0",options:[{label:"Google Colab",value:"https://colab.research.google.com/github/huggingface/notebooks/blob/master/course/chapter1/section3.ipynb"},{label:"Aws Studio",value:"https://studiolab.sagemaker.aws/import/github/huggingface/notebooks/blob/master/course/chapter1/section3.ipynb"}]}}),re=new Fe({props:{$$slots:{default:[Np]},$$scope:{ctx:O}}}),Le=new F({}),he=new Fe({props:{$$slots:{default:[zp]},$$scope:{ctx:O}}}),Ge=new F({}),We=new Op({props:{id:"tiZFewofSLM"}}),Be=new S({props:{code:`from transformers import pipeline

classifier = pipeline("sentiment-analysis")
classifier("I've been waiting for a HuggingFace course my whole life.")`,highlighted:`<span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> pipeline

classifier = pipeline(<span class="hljs-string">&quot;sentiment-analysis&quot;</span>)
classifier(<span class="hljs-string">&quot;I&#x27;ve been waiting for a HuggingFace course my whole life.&quot;</span>)`}}),Ye=new S({props:{code:"[{'label': 'POSITIVE', 'score': 0.9598047137260437}]",highlighted:'[{<span class="hljs-string">&#x27;label&#x27;</span>: <span class="hljs-string">&#x27;POSITIVE&#x27;</span>, <span class="hljs-string">&#x27;score&#x27;</span>: <span class="hljs-number">0.9598047137260437</span>}]'}}),Ue=new S({props:{code:`classifier(
    ["I've been waiting for a HuggingFace course my whole life.", "I hate this so much!"]
)`,highlighted:`classifier(
    [<span class="hljs-string">&quot;I&#x27;ve been waiting for a HuggingFace course my whole life.&quot;</span>, <span class="hljs-string">&quot;I hate this so much!&quot;</span>]
)`}}),Ve=new S({props:{code:`[{'label': 'POSITIVE', 'score': 0.9598047137260437},
 {'label': 'NEGATIVE', 'score': 0.9994558095932007}]`,highlighted:`[{<span class="hljs-string">&#x27;label&#x27;</span>: <span class="hljs-string">&#x27;POSITIVE&#x27;</span>, <span class="hljs-string">&#x27;score&#x27;</span>: <span class="hljs-number">0.9598047137260437</span>},
 {<span class="hljs-string">&#x27;label&#x27;</span>: <span class="hljs-string">&#x27;NEGATIVE&#x27;</span>, <span class="hljs-string">&#x27;score&#x27;</span>: <span class="hljs-number">0.9994558095932007</span>}]`}}),Qe=new F({}),Je=new S({props:{code:`from transformers import pipeline

classifier = pipeline("zero-shot-classification")
classifier(
    "This is a course about the Transformers library",
    candidate_labels=["education", "politics", "business"],
)`,highlighted:`<span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> pipeline

classifier = pipeline(<span class="hljs-string">&quot;zero-shot-classification&quot;</span>)
classifier(
    <span class="hljs-string">&quot;This is a course about the Transformers library&quot;</span>,
    candidate_labels=[<span class="hljs-string">&quot;education&quot;</span>, <span class="hljs-string">&quot;politics&quot;</span>, <span class="hljs-string">&quot;business&quot;</span>],
)`}}),Ke=new S({props:{code:`{'sequence': 'This is a course about the Transformers library',
 'labels': ['education', 'business', 'politics'],
 'scores': [0.8445963859558105, 0.111976258456707, 0.043427448719739914]}`,highlighted:`{<span class="hljs-string">&#x27;sequence&#x27;</span>: <span class="hljs-string">&#x27;This is a course about the Transformers library&#x27;</span>,
 <span class="hljs-string">&#x27;labels&#x27;</span>: [<span class="hljs-string">&#x27;education&#x27;</span>, <span class="hljs-string">&#x27;business&#x27;</span>, <span class="hljs-string">&#x27;politics&#x27;</span>],
 <span class="hljs-string">&#x27;scores&#x27;</span>: [<span class="hljs-number">0.8445963859558105</span>, <span class="hljs-number">0.111976258456707</span>, <span class="hljs-number">0.043427448719739914</span>]}`}}),ye=new Fe({props:{$$slots:{default:[Dp]},$$scope:{ctx:O}}}),Xe=new F({}),et=new S({props:{code:`from transformers import pipeline

generator = pipeline("text-generation")
generator("In this course, we will teach you how to")`,highlighted:`<span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> pipeline

generator = pipeline(<span class="hljs-string">&quot;text-generation&quot;</span>)
generator(<span class="hljs-string">&quot;In this course, we will teach you how to&quot;</span>)`}}),tt=new S({props:{code:`[{'generated_text': 'In this course, we will teach you how to understand and use '
                    'data flow and data interchange when handling user data. We '
                    'will be working with one or more of the most commonly used '
                    'data flows \u2014 data flows of various types, as seen by the '
                    'HTTP'}]`,highlighted:`[{<span class="hljs-string">&#x27;generated_text&#x27;</span>: <span class="hljs-string">&#x27;In this course, we will teach you how to understand and use &#x27;</span>
                    <span class="hljs-string">&#x27;data flow and data interchange when handling user data. We &#x27;</span>
                    <span class="hljs-string">&#x27;will be working with one or more of the most commonly used &#x27;</span>
                    <span class="hljs-string">&#x27;data flows \u2014 data flows of various types, as seen by the &#x27;</span>
                    <span class="hljs-string">&#x27;HTTP&#x27;</span>}]`}}),$e=new Fe({props:{$$slots:{default:[Fp]},$$scope:{ctx:O}}}),st=new F({}),it=new S({props:{code:`from transformers import pipeline

generator = pipeline("text-generation", model="distilgpt2")
generator(
    "In this course, we will teach you how to",
    max_length=30,
    num_return_sequences=2,
)`,highlighted:`<span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> pipeline

generator = pipeline(<span class="hljs-string">&quot;text-generation&quot;</span>, model=<span class="hljs-string">&quot;distilgpt2&quot;</span>)
generator(
    <span class="hljs-string">&quot;In this course, we will teach you how to&quot;</span>,
    max_length=<span class="hljs-number">30</span>,
    num_return_sequences=<span class="hljs-number">2</span>,
)`}}),rt=new S({props:{code:`[{'generated_text': 'In this course, we will teach you how to manipulate the world and '
                    'move your mental and physical capabilities to your advantage.'},
 {'generated_text': 'In this course, we will teach you how to become an expert and '
                    'practice realtime, and with a hands on experience on both real '
                    'time and real'}]`,highlighted:`[{<span class="hljs-string">&#x27;generated_text&#x27;</span>: <span class="hljs-string">&#x27;In this course, we will teach you how to manipulate the world and &#x27;</span>
                    <span class="hljs-string">&#x27;move your mental and physical capabilities to your advantage.&#x27;</span>},
 {<span class="hljs-string">&#x27;generated_text&#x27;</span>: <span class="hljs-string">&#x27;In this course, we will teach you how to become an expert and &#x27;</span>
                    <span class="hljs-string">&#x27;practice realtime, and with a hands on experience on both real &#x27;</span>
                    <span class="hljs-string">&#x27;time and real&#x27;</span>}]`}}),_e=new Fe({props:{$$slots:{default:[Lp]},$$scope:{ctx:O}}}),lt=new F({}),ct=new F({}),ft=new S({props:{code:`from transformers import pipeline

unmasker = pipeline("fill-mask")
unmasker("This course will teach you all about <mask> models.", top_k=2)`,highlighted:`<span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> pipeline

unmasker = pipeline(<span class="hljs-string">&quot;fill-mask&quot;</span>)
unmasker(<span class="hljs-string">&quot;This course will teach you all about &lt;mask&gt; models.&quot;</span>, top_k=<span class="hljs-number">2</span>)`}}),ut=new S({props:{code:`[{'sequence': 'This course will teach you all about mathematical models.',
  'score': 0.19619831442832947,
  'token': 30412,
  'token_str': ' mathematical'},
 {'sequence': 'This course will teach you all about computational models.',
  'score': 0.04052725434303284,
  'token': 38163,
  'token_str': ' computational'}]`,highlighted:`[{<span class="hljs-string">&#x27;sequence&#x27;</span>: <span class="hljs-string">&#x27;This course will teach you all about mathematical models.&#x27;</span>,
  <span class="hljs-string">&#x27;score&#x27;</span>: <span class="hljs-number">0.19619831442832947</span>,
  <span class="hljs-string">&#x27;token&#x27;</span>: <span class="hljs-number">30412</span>,
  <span class="hljs-string">&#x27;token_str&#x27;</span>: <span class="hljs-string">&#x27; mathematical&#x27;</span>},
 {<span class="hljs-string">&#x27;sequence&#x27;</span>: <span class="hljs-string">&#x27;This course will teach you all about computational models.&#x27;</span>,
  <span class="hljs-string">&#x27;score&#x27;</span>: <span class="hljs-number">0.04052725434303284</span>,
  <span class="hljs-string">&#x27;token&#x27;</span>: <span class="hljs-number">38163</span>,
  <span class="hljs-string">&#x27;token_str&#x27;</span>: <span class="hljs-string">&#x27; computational&#x27;</span>}]`}}),Pe=new Fe({props:{$$slots:{default:[Mp]},$$scope:{ctx:O}}}),mt=new F({}),dt=new S({props:{code:`from transformers import pipeline

ner = pipeline("ner", grouped_entities=True)
ner("My name is Sylvain and I work at Hugging Face in Brooklyn.")`,highlighted:`<span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> pipeline

ner = pipeline(<span class="hljs-string">&quot;ner&quot;</span>, grouped_entities=<span class="hljs-literal">True</span>)
ner(<span class="hljs-string">&quot;My name is Sylvain and I work at Hugging Face in Brooklyn.&quot;</span>)`}}),gt=new S({props:{code:`[{'entity_group': 'PER', 'score': 0.99816, 'word': 'Sylvain', 'start': 11, 'end': 18}, 
 {'entity_group': 'ORG', 'score': 0.97960, 'word': 'Hugging Face', 'start': 33, 'end': 45}, 
 {'entity_group': 'LOC', 'score': 0.99321, 'word': 'Brooklyn', 'start': 49, 'end': 57}
]`,highlighted:`[{<span class="hljs-string">&#x27;entity_group&#x27;</span>: <span class="hljs-string">&#x27;PER&#x27;</span>, <span class="hljs-string">&#x27;score&#x27;</span>: <span class="hljs-number">0.99816</span>, <span class="hljs-string">&#x27;word&#x27;</span>: <span class="hljs-string">&#x27;Sylvain&#x27;</span>, <span class="hljs-string">&#x27;start&#x27;</span>: <span class="hljs-number">11</span>, <span class="hljs-string">&#x27;end&#x27;</span>: <span class="hljs-number">18</span>}, 
 {<span class="hljs-string">&#x27;entity_group&#x27;</span>: <span class="hljs-string">&#x27;ORG&#x27;</span>, <span class="hljs-string">&#x27;score&#x27;</span>: <span class="hljs-number">0.97960</span>, <span class="hljs-string">&#x27;word&#x27;</span>: <span class="hljs-string">&#x27;Hugging Face&#x27;</span>, <span class="hljs-string">&#x27;start&#x27;</span>: <span class="hljs-number">33</span>, <span class="hljs-string">&#x27;end&#x27;</span>: <span class="hljs-number">45</span>}, 
 {<span class="hljs-string">&#x27;entity_group&#x27;</span>: <span class="hljs-string">&#x27;LOC&#x27;</span>, <span class="hljs-string">&#x27;score&#x27;</span>: <span class="hljs-number">0.99321</span>, <span class="hljs-string">&#x27;word&#x27;</span>: <span class="hljs-string">&#x27;Brooklyn&#x27;</span>, <span class="hljs-string">&#x27;start&#x27;</span>: <span class="hljs-number">49</span>, <span class="hljs-string">&#x27;end&#x27;</span>: <span class="hljs-number">57</span>}
]`}}),Ae=new Fe({props:{$$slots:{default:[Rp]},$$scope:{ctx:O}}}),wt=new F({}),yt=new S({props:{code:`from transformers import pipeline

question_answerer = pipeline("question-answering")
question_answerer(
    question="Where do I work?",
    context="My name is Sylvain and I work at Hugging Face in Brooklyn",
)`,highlighted:`<span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> pipeline

question_answerer = pipeline(<span class="hljs-string">&quot;question-answering&quot;</span>)
question_answerer(
    question=<span class="hljs-string">&quot;Where do I work?&quot;</span>,
    context=<span class="hljs-string">&quot;My name is Sylvain and I work at Hugging Face in Brooklyn&quot;</span>,
)`}}),vt=new S({props:{code:"{'score': 0.6385916471481323, 'start': 33, 'end': 45, 'answer': 'Hugging Face'}",highlighted:'{<span class="hljs-string">&#x27;score&#x27;</span>: <span class="hljs-number">0.6385916471481323</span>, <span class="hljs-string">&#x27;start&#x27;</span>: <span class="hljs-number">33</span>, <span class="hljs-string">&#x27;end&#x27;</span>: <span class="hljs-number">45</span>, <span class="hljs-string">&#x27;answer&#x27;</span>: <span class="hljs-string">&#x27;Hugging Face&#x27;</span>}'}}),$t=new F({}),bt=new S({props:{code:`from transformers import pipeline

summarizer = pipeline("summarization")
summarizer(
    """
    America has changed dramatically during recent years. Not only has the number of 
    graduates in traditional engineering disciplines such as mechanical, civil, 
    electrical, chemical, and aeronautical engineering declined, but in most of 
    the premier American universities engineering curricula now concentrate on 
    and encourage largely the study of engineering science. As a result, there 
    are declining offerings in engineering subjects dealing with infrastructure, 
    the environment, and related issues, and greater concentration on high 
    technology subjects, largely supporting increasingly complex scientific 
    developments. While the latter is important, it should not be at the expense 
    of more traditional engineering.

    Rapidly developing economies such as China and India, as well as other 
    industrial countries in Europe and Asia, continue to encourage and advance 
    the teaching of engineering. Both China and India, respectively, graduate 
    six and eight times as many traditional engineers as does the United States. 
    Other industrial countries at minimum maintain their output, while America 
    suffers an increasingly serious decline in the number of engineering graduates 
    and a lack of well-educated engineers.
"""
)`,highlighted:`<span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> pipeline

summarizer = pipeline(<span class="hljs-string">&quot;summarization&quot;</span>)
summarizer(
    <span class="hljs-string">&quot;&quot;&quot;
    America has changed dramatically during recent years. Not only has the number of 
    graduates in traditional engineering disciplines such as mechanical, civil, 
    electrical, chemical, and aeronautical engineering declined, but in most of 
    the premier American universities engineering curricula now concentrate on 
    and encourage largely the study of engineering science. As a result, there 
    are declining offerings in engineering subjects dealing with infrastructure, 
    the environment, and related issues, and greater concentration on high 
    technology subjects, largely supporting increasingly complex scientific 
    developments. While the latter is important, it should not be at the expense 
    of more traditional engineering.

    Rapidly developing economies such as China and India, as well as other 
    industrial countries in Europe and Asia, continue to encourage and advance 
    the teaching of engineering. Both China and India, respectively, graduate 
    six and eight times as many traditional engineers as does the United States. 
    Other industrial countries at minimum maintain their output, while America 
    suffers an increasingly serious decline in the number of engineering graduates 
    and a lack of well-educated engineers.
&quot;&quot;&quot;</span>
)`}}),xt=new S({props:{code:`[{'summary_text': ' America has changed dramatically during recent years . The '
                  'number of engineering graduates in the U.S. has declined in '
                  'traditional engineering disciplines such as mechanical, civil '
                  ', electrical, chemical, and aeronautical engineering . Rapidly '
                  'developing economies such as China and India, as well as other '
                  'industrial countries in Europe and Asia, continue to encourage '
                  'and advance engineering .'}]`,highlighted:`[{<span class="hljs-string">&#x27;summary_text&#x27;</span>: <span class="hljs-string">&#x27; America has changed dramatically during recent years . The &#x27;</span>
                  <span class="hljs-string">&#x27;number of engineering graduates in the U.S. has declined in &#x27;</span>
                  <span class="hljs-string">&#x27;traditional engineering disciplines such as mechanical, civil &#x27;</span>
                  <span class="hljs-string">&#x27;, electrical, chemical, and aeronautical engineering . Rapidly &#x27;</span>
                  <span class="hljs-string">&#x27;developing economies such as China and India, as well as other &#x27;</span>
                  <span class="hljs-string">&#x27;industrial countries in Europe and Asia, continue to encourage &#x27;</span>
                  <span class="hljs-string">&#x27;and advance engineering .&#x27;</span>}]`}}),_t=new F({}),Et=new S({props:{code:`from transformers import pipeline

translator = pipeline("translation", model="Helsinki-NLP/opus-mt-fr-en")
translator("Ce cours est produit par Hugging Face.")`,highlighted:`<span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> pipeline

translator = pipeline(<span class="hljs-string">&quot;translation&quot;</span>, model=<span class="hljs-string">&quot;Helsinki-NLP/opus-mt-fr-en&quot;</span>)
translator(<span class="hljs-string">&quot;Ce cours est produit par Hugging Face.&quot;</span>)`}}),jt=new S({props:{code:"[{'translation_text': 'This course is produced by Hugging Face.'}]",highlighted:'[{<span class="hljs-string">&#x27;translation_text&#x27;</span>: <span class="hljs-string">&#x27;This course is produced by Hugging Face.&#x27;</span>}]'}}),Ne=new Fe({props:{$$slots:{default:[Gp]},$$scope:{ctx:O}}}),{c(){f=n("meta"),y=h(),d=n("h1"),v=n("a"),g=n("span"),$(m.$$.fragment),w=h(),T=n("span"),H=i("Transformers, what can they do?"),q=h(),$(P.$$.fragment),A=h(),j=n("p"),V=i("In this section, we will look at what Transformer models can do and use our first tool from the \u{1F917} Transformers library: the "),L=n("code"),Z=i("pipeline()"),so=i(" function."),ua=h(),$(re.$$.fragment),ma=h(),Q=n("h2"),le=n("a"),Jt=n("span"),$(Le.$$.fragment),ao=h(),Kt=n("span"),no=i("Transformers are everywhere!"),da=h(),It=n("p"),oo=i("Transformer models are used to solve all kinds of NLP tasks, like the ones mentioned in the previous section. Here are some of the companies and organizations using Hugging Face and Transformer models, who also contribute back to the community by sharing their models:"),ga=h(),pe=n("img"),wa=h(),M=n("p"),io=i("The "),Me=n("a"),ro=i("\u{1F917} Transformers library"),lo=i(" provides the functionality to create and use those shared models. The "),Re=n("a"),po=i("Model Hub"),ho=i(" contains thousands of pretrained models that anyone can download and use. You can also upload your own models to the Hub!"),ya=h(),$(he.$$.fragment),va=h(),At=n("p"),co=i("Before diving into how Transformer models work under the hood, let\u2019s look at a few examples of how they can be used to solve some interesting NLP problems."),$a=h(),J=n("h2"),ce=n("a"),Xt=n("span"),$(Ge.$$.fragment),fo=h(),es=n("span"),uo=i("Working with pipelines"),ba=h(),$(We.$$.fragment),xa=h(),fe=n("p"),mo=i("The most basic object in the \u{1F917} Transformers library is the "),ts=n("code"),go=i("pipeline()"),wo=i(" function. It connects a model with its necessary preprocessing and postprocessing steps, allowing us to directly input any text and get an intelligible answer:"),_a=h(),$(Be.$$.fragment),ka=h(),$(Ye.$$.fragment),Ea=h(),St=n("p"),yo=i("We can even pass several sentences!"),ja=h(),$(Ue.$$.fragment),Ta=h(),$(Ve.$$.fragment),qa=h(),ue=n("p"),vo=i("By default, this pipeline selects a particular pretrained model that has been fine-tuned for sentiment analysis in English. The model is downloaded and cached when you create the "),ss=n("code"),$o=i("classifier"),bo=i(" object. If you rerun the command, the cached model will be used instead and there is no need to download the model again."),Pa=h(),Ht=n("p"),xo=i("There are three main steps involved when you pass some text to a pipeline:"),Ia=h(),R=n("ol"),as=n("li"),_o=i("The text is preprocessed into a format the model can understand."),ko=h(),ns=n("li"),Eo=i("The preprocessed inputs are passed to the model."),jo=h(),os=n("li"),To=i("The predictions of the model are post-processed, so you can make sense of them."),Aa=h(),me=n("p"),qo=i("Some of the currently "),Ze=n("a"),Po=i("available pipelines"),Io=i(" are:"),Sa=h(),I=n("ul"),Ot=n("li"),is=n("code"),Ao=i("feature-extraction"),So=i(" (get the vector representation of a text)"),Ho=h(),rs=n("li"),ls=n("code"),Oo=i("fill-mask"),Co=h(),Ct=n("li"),ps=n("code"),No=i("ner"),zo=i(" (named entity recognition)"),Do=h(),hs=n("li"),cs=n("code"),Fo=i("question-answering"),Lo=h(),fs=n("li"),us=n("code"),Mo=i("sentiment-analysis"),Ro=h(),ms=n("li"),ds=n("code"),Go=i("summarization"),Wo=h(),gs=n("li"),ws=n("code"),Bo=i("text-generation"),Yo=h(),ys=n("li"),vs=n("code"),Uo=i("translation"),Vo=h(),$s=n("li"),bs=n("code"),Zo=i("zero-shot-classification"),Ha=h(),Nt=n("p"),Qo=i("Let\u2019s have a look at a few of these!"),Oa=h(),K=n("h2"),de=n("a"),xs=n("span"),$(Qe.$$.fragment),Jo=h(),_s=n("span"),Ko=i("Zero-shot classification"),Ca=h(),ge=n("p"),Xo=i("We\u2019ll start by tackling a more challenging task where we need to classify texts that haven\u2019t been labelled. This is a common scenario in real-world projects because annotating text is usually time-consuming and requires domain expertise. For this use case, the "),ks=n("code"),ei=i("zero-shot-classification"),ti=i(" pipeline is very powerful: it allows you to specify which labels to use for the classification, so you don\u2019t have to rely on the labels of the pretrained model. You\u2019ve already seen how the model can classify a sentence as positive or negative using those two labels \u2014 but it can also classify the text using any other set of labels you like."),Na=h(),$(Je.$$.fragment),za=h(),$(Ke.$$.fragment),Da=h(),we=n("p"),si=i("This pipeline is called "),Es=n("em"),ai=i("zero-shot"),ni=i(" because you don\u2019t need to fine-tune the model on your data to use it. It can directly return probability scores for any list of labels you want!"),Fa=h(),$(ye.$$.fragment),La=h(),X=n("h2"),ve=n("a"),js=n("span"),$(Xe.$$.fragment),oi=h(),Ts=n("span"),ii=i("Text generation"),Ma=h(),zt=n("p"),ri=i("Now let\u2019s see how to use a pipeline to generate some text. The main idea here is that you provide a prompt and the model will auto-complete it by generating the remaining text. This is similar to the predictive text feature that is found on many phones. Text generation involves randomness, so it\u2019s normal if you don\u2019t get the same results as shown below."),Ra=h(),$(et.$$.fragment),Ga=h(),$(tt.$$.fragment),Wa=h(),G=n("p"),li=i("You can control how many different sequences are generated with the argument "),qs=n("code"),pi=i("num_return_sequences"),hi=i(" and the total length of the output text with the argument "),Ps=n("code"),ci=i("max_length"),fi=i("."),Ba=h(),$($e.$$.fragment),Ya=h(),ee=n("h2"),be=n("a"),Is=n("span"),$(st.$$.fragment),ui=h(),As=n("span"),mi=i("Using any model from the Hub in a pipeline"),Ua=h(),W=n("p"),di=i("The previous examples used the default model for the task at hand, but you can also choose a particular model from the Hub to use in a pipeline for a specific task \u2014 say, text generation. Go to the "),at=n("a"),gi=i("Model Hub"),wi=i(" and click on the corresponding tag on the left to display only the supported models for that task. You should get to a page like "),nt=n("a"),yi=i("this one"),vi=i("."),Va=h(),xe=n("p"),$i=i("Let\u2019s try the "),ot=n("a"),Ss=n("code"),bi=i("distilgpt2"),xi=i(" model! Here\u2019s how to load it in the same pipeline as before:"),Za=h(),$(it.$$.fragment),Qa=h(),$(rt.$$.fragment),Ja=h(),Dt=n("p"),_i=i("You can refine your search for a model by clicking on the language tags, and pick a model that will generate text in another language. The Model Hub even contains checkpoints for multilingual models that support several languages."),Ka=h(),Ft=n("p"),ki=i("Once you select a model by clicking on it, you\u2019ll see that there is a widget enabling you to try it directly online. This way you can quickly test the model\u2019s capabilities before downloading it."),Xa=h(),$(_e.$$.fragment),en=h(),te=n("h3"),ke=n("a"),Hs=n("span"),$(lt.$$.fragment),Ei=h(),Os=n("span"),ji=i("The Inference API"),tn=h(),Ee=n("p"),Ti=i("All the models can be tested directly through your browser using the Inference API, which is available on the Hugging Face "),pt=n("a"),qi=i("website"),Pi=i(". You can play with the model directly on this page by inputting custom text and watching the model process the input data."),sn=h(),je=n("p"),Ii=i("The Inference API that powers the widget is also available as a paid product, which comes in handy if you need it for your workflows. See the "),ht=n("a"),Ai=i("pricing page"),Si=i(" for more details."),an=h(),se=n("h2"),Te=n("a"),Cs=n("span"),$(ct.$$.fragment),Hi=h(),Ns=n("span"),Oi=i("Mask filling"),nn=h(),qe=n("p"),Ci=i("The next pipeline you\u2019ll try is "),zs=n("code"),Ni=i("fill-mask"),zi=i(". The idea of this task is to fill in the blanks in a given text:"),on=h(),$(ft.$$.fragment),rn=h(),$(ut.$$.fragment),ln=h(),D=n("p"),Di=i("The "),Ds=n("code"),Fi=i("top_k"),Li=i(" argument controls how many possibilities you want to be displayed. Note that here the model fills in the special "),Fs=n("code"),Mi=i("<mask>"),Ri=i(" word, which is often referred to as a "),Ls=n("em"),Gi=i("mask token"),Wi=i(". Other mask-filling models might have different mask tokens, so it\u2019s always good to verify the proper mask word when exploring other models. One way to check it is by looking at the mask word used in the widget."),pn=h(),$(Pe.$$.fragment),hn=h(),ae=n("h2"),Ie=n("a"),Ms=n("span"),$(mt.$$.fragment),Bi=h(),Rs=n("span"),Yi=i("Named entity recognition"),cn=h(),Lt=n("p"),Ui=i("Named entity recognition (NER) is a task where the model has to find which parts of the input text correspond to entities such as persons, locations, or organizations. Let\u2019s look at an example:"),fn=h(),$(dt.$$.fragment),un=h(),$(gt.$$.fragment),mn=h(),Mt=n("p"),Vi=i("Here the model correctly identified that Sylvain is a person (PER), Hugging Face an organization (ORG), and Brooklyn a location (LOC)."),dn=h(),C=n("p"),Zi=i("We pass the option "),Gs=n("code"),Qi=i("grouped_entities=True"),Ji=i(" in the pipeline creation function to tell the pipeline to regroup together the parts of the sentence that correspond to the same entity: here the model correctly grouped \u201CHugging\u201D and \u201CFace\u201D as a single organization, even though the name consists of multiple words. In fact, as we will see in the next chapter, the preprocessing even splits some words into smaller parts. For instance, "),Ws=n("code"),Ki=i("Sylvain"),Xi=i(" is split into four pieces: "),Bs=n("code"),er=i("S"),tr=i(", "),Ys=n("code"),sr=i("##yl"),ar=i(", "),Us=n("code"),nr=i("##va"),or=i(", and "),Vs=n("code"),ir=i("##in"),rr=i(". In the post-processing step, the pipeline successfully regrouped those pieces."),gn=h(),$(Ae.$$.fragment),wn=h(),ne=n("h2"),Se=n("a"),Zs=n("span"),$(wt.$$.fragment),lr=h(),Qs=n("span"),pr=i("Question answering"),yn=h(),He=n("p"),hr=i("The "),Js=n("code"),cr=i("question-answering"),fr=i(" pipeline answers questions using information from a given context:"),vn=h(),$(yt.$$.fragment),$n=h(),$(vt.$$.fragment),bn=h(),Rt=n("p"),ur=i("Note that this pipeline works by extracting information from the provided context; it does not generate the answer."),xn=h(),oe=n("h2"),Oe=n("a"),Ks=n("span"),$($t.$$.fragment),mr=h(),Xs=n("span"),dr=i("Summarization"),_n=h(),Gt=n("p"),gr=i("Summarization is the task of reducing a text into a shorter text while keeping all (or most) of the important aspects referenced in the text. Here\u2019s an example:"),kn=h(),$(bt.$$.fragment),En=h(),$(xt.$$.fragment),jn=h(),B=n("p"),wr=i("Like with text generation, you can specify a "),ea=n("code"),yr=i("max_length"),vr=i(" or a "),ta=n("code"),$r=i("min_length"),br=i(" for the result."),Tn=h(),ie=n("h2"),Ce=n("a"),sa=n("span"),$(_t.$$.fragment),xr=h(),aa=n("span"),_r=i("Translation"),qn=h(),Y=n("p"),kr=i("For translation, you can use a default model if you provide a language pair in the task name (such as "),na=n("code"),Er=i('"translation_en_to_fr"'),jr=i("), but the easiest way is to pick the model you want to use on the "),kt=n("a"),Tr=i("Model Hub"),qr=i(". Here we\u2019ll try translating from French to English:"),Pn=h(),$(Et.$$.fragment),In=h(),$(jt.$$.fragment),An=h(),U=n("p"),Pr=i("Like with text generation and summarization, you can specify a "),oa=n("code"),Ir=i("max_length"),Ar=i(" or a "),ia=n("code"),Sr=i("min_length"),Hr=i(" for the result."),Sn=h(),$(Ne.$$.fragment),Hn=h(),ze=n("p"),Or=i("The pipelines shown so far are mostly for demonstrative purposes. They were programmed for specific tasks and cannot perform variations of them. In the next chapter, you\u2019ll learn what\u2019s inside a "),ra=n("code"),Cr=i("pipeline()"),Nr=i(" function and how to customize its behavior."),this.h()},l(e){const a=Ap('[data-svelte="svelte-1phssyn"]',document.head);f=o(a,"META",{name:!0,content:!0}),a.forEach(t),y=c(e),d=o(e,"H1",{class:!0});var Tt=l(d);v=o(Tt,"A",{id:!0,class:!0,href:!0});var la=l(v);g=o(la,"SPAN",{});var pa=l(g);b(m.$$.fragment,pa),pa.forEach(t),la.forEach(t),w=c(Tt),T=o(Tt,"SPAN",{});var ha=l(T);H=r(ha,"Transformers, what can they do?"),ha.forEach(t),Tt.forEach(t),q=c(e),b(P.$$.fragment,e),A=c(e),j=o(e,"P",{});var qt=l(j);V=r(qt,"In this section, we will look at what Transformer models can do and use our first tool from the \u{1F917} Transformers library: the "),L=o(qt,"CODE",{});var ca=l(L);Z=r(ca,"pipeline()"),ca.forEach(t),so=r(qt," function."),qt.forEach(t),ua=c(e),b(re.$$.fragment,e),ma=c(e),Q=o(e,"H2",{class:!0});var Pt=l(Q);le=o(Pt,"A",{id:!0,class:!0,href:!0});var fa=l(le);Jt=o(fa,"SPAN",{});var Lr=l(Jt);b(Le.$$.fragment,Lr),Lr.forEach(t),fa.forEach(t),ao=c(Pt),Kt=o(Pt,"SPAN",{});var Mr=l(Kt);no=r(Mr,"Transformers are everywhere!"),Mr.forEach(t),Pt.forEach(t),da=c(e),It=o(e,"P",{});var Rr=l(It);oo=r(Rr,"Transformer models are used to solve all kinds of NLP tasks, like the ones mentioned in the previous section. Here are some of the companies and organizations using Hugging Face and Transformer models, who also contribute back to the community by sharing their models:"),Rr.forEach(t),ga=c(e),pe=o(e,"IMG",{src:!0,alt:!0,width:!0}),wa=c(e),M=o(e,"P",{});var Wt=l(M);io=r(Wt,"The "),Me=o(Wt,"A",{href:!0,rel:!0});var Gr=l(Me);ro=r(Gr,"\u{1F917} Transformers library"),Gr.forEach(t),lo=r(Wt," provides the functionality to create and use those shared models. The "),Re=o(Wt,"A",{href:!0,rel:!0});var Wr=l(Re);po=r(Wr,"Model Hub"),Wr.forEach(t),ho=r(Wt," contains thousands of pretrained models that anyone can download and use. You can also upload your own models to the Hub!"),Wt.forEach(t),ya=c(e),b(he.$$.fragment,e),va=c(e),At=o(e,"P",{});var Br=l(At);co=r(Br,"Before diving into how Transformer models work under the hood, let\u2019s look at a few examples of how they can be used to solve some interesting NLP problems."),Br.forEach(t),$a=c(e),J=o(e,"H2",{class:!0});var Cn=l(J);ce=o(Cn,"A",{id:!0,class:!0,href:!0});var Yr=l(ce);Xt=o(Yr,"SPAN",{});var Ur=l(Xt);b(Ge.$$.fragment,Ur),Ur.forEach(t),Yr.forEach(t),fo=c(Cn),es=o(Cn,"SPAN",{});var Vr=l(es);uo=r(Vr,"Working with pipelines"),Vr.forEach(t),Cn.forEach(t),ba=c(e),b(We.$$.fragment,e),xa=c(e),fe=o(e,"P",{});var Nn=l(fe);mo=r(Nn,"The most basic object in the \u{1F917} Transformers library is the "),ts=o(Nn,"CODE",{});var Zr=l(ts);go=r(Zr,"pipeline()"),Zr.forEach(t),wo=r(Nn," function. It connects a model with its necessary preprocessing and postprocessing steps, allowing us to directly input any text and get an intelligible answer:"),Nn.forEach(t),_a=c(e),b(Be.$$.fragment,e),ka=c(e),b(Ye.$$.fragment,e),Ea=c(e),St=o(e,"P",{});var Qr=l(St);yo=r(Qr,"We can even pass several sentences!"),Qr.forEach(t),ja=c(e),b(Ue.$$.fragment,e),Ta=c(e),b(Ve.$$.fragment,e),qa=c(e),ue=o(e,"P",{});var zn=l(ue);vo=r(zn,"By default, this pipeline selects a particular pretrained model that has been fine-tuned for sentiment analysis in English. The model is downloaded and cached when you create the "),ss=o(zn,"CODE",{});var Jr=l(ss);$o=r(Jr,"classifier"),Jr.forEach(t),bo=r(zn," object. If you rerun the command, the cached model will be used instead and there is no need to download the model again."),zn.forEach(t),Pa=c(e),Ht=o(e,"P",{});var Kr=l(Ht);xo=r(Kr,"There are three main steps involved when you pass some text to a pipeline:"),Kr.forEach(t),Ia=c(e),R=o(e,"OL",{});var Bt=l(R);as=o(Bt,"LI",{});var Xr=l(as);_o=r(Xr,"The text is preprocessed into a format the model can understand."),Xr.forEach(t),ko=c(Bt),ns=o(Bt,"LI",{});var el=l(ns);Eo=r(el,"The preprocessed inputs are passed to the model."),el.forEach(t),jo=c(Bt),os=o(Bt,"LI",{});var tl=l(os);To=r(tl,"The predictions of the model are post-processed, so you can make sense of them."),tl.forEach(t),Bt.forEach(t),Aa=c(e),me=o(e,"P",{});var Dn=l(me);qo=r(Dn,"Some of the currently "),Ze=o(Dn,"A",{href:!0,rel:!0});var sl=l(Ze);Po=r(sl,"available pipelines"),sl.forEach(t),Io=r(Dn," are:"),Dn.forEach(t),Sa=c(e),I=o(e,"UL",{});var N=l(I);Ot=o(N,"LI",{});var zr=l(Ot);is=o(zr,"CODE",{});var al=l(is);Ao=r(al,"feature-extraction"),al.forEach(t),So=r(zr," (get the vector representation of a text)"),zr.forEach(t),Ho=c(N),rs=o(N,"LI",{});var nl=l(rs);ls=o(nl,"CODE",{});var ol=l(ls);Oo=r(ol,"fill-mask"),ol.forEach(t),nl.forEach(t),Co=c(N),Ct=o(N,"LI",{});var Dr=l(Ct);ps=o(Dr,"CODE",{});var il=l(ps);No=r(il,"ner"),il.forEach(t),zo=r(Dr," (named entity recognition)"),Dr.forEach(t),Do=c(N),hs=o(N,"LI",{});var rl=l(hs);cs=o(rl,"CODE",{});var ll=l(cs);Fo=r(ll,"question-answering"),ll.forEach(t),rl.forEach(t),Lo=c(N),fs=o(N,"LI",{});var pl=l(fs);us=o(pl,"CODE",{});var hl=l(us);Mo=r(hl,"sentiment-analysis"),hl.forEach(t),pl.forEach(t),Ro=c(N),ms=o(N,"LI",{});var cl=l(ms);ds=o(cl,"CODE",{});var fl=l(ds);Go=r(fl,"summarization"),fl.forEach(t),cl.forEach(t),Wo=c(N),gs=o(N,"LI",{});var ul=l(gs);ws=o(ul,"CODE",{});var ml=l(ws);Bo=r(ml,"text-generation"),ml.forEach(t),ul.forEach(t),Yo=c(N),ys=o(N,"LI",{});var dl=l(ys);vs=o(dl,"CODE",{});var gl=l(vs);Uo=r(gl,"translation"),gl.forEach(t),dl.forEach(t),Vo=c(N),$s=o(N,"LI",{});var wl=l($s);bs=o(wl,"CODE",{});var yl=l(bs);Zo=r(yl,"zero-shot-classification"),yl.forEach(t),wl.forEach(t),N.forEach(t),Ha=c(e),Nt=o(e,"P",{});var vl=l(Nt);Qo=r(vl,"Let\u2019s have a look at a few of these!"),vl.forEach(t),Oa=c(e),K=o(e,"H2",{class:!0});var Fn=l(K);de=o(Fn,"A",{id:!0,class:!0,href:!0});var $l=l(de);xs=o($l,"SPAN",{});var bl=l(xs);b(Qe.$$.fragment,bl),bl.forEach(t),$l.forEach(t),Jo=c(Fn),_s=o(Fn,"SPAN",{});var xl=l(_s);Ko=r(xl,"Zero-shot classification"),xl.forEach(t),Fn.forEach(t),Ca=c(e),ge=o(e,"P",{});var Ln=l(ge);Xo=r(Ln,"We\u2019ll start by tackling a more challenging task where we need to classify texts that haven\u2019t been labelled. This is a common scenario in real-world projects because annotating text is usually time-consuming and requires domain expertise. For this use case, the "),ks=o(Ln,"CODE",{});var _l=l(ks);ei=r(_l,"zero-shot-classification"),_l.forEach(t),ti=r(Ln," pipeline is very powerful: it allows you to specify which labels to use for the classification, so you don\u2019t have to rely on the labels of the pretrained model. You\u2019ve already seen how the model can classify a sentence as positive or negative using those two labels \u2014 but it can also classify the text using any other set of labels you like."),Ln.forEach(t),Na=c(e),b(Je.$$.fragment,e),za=c(e),b(Ke.$$.fragment,e),Da=c(e),we=o(e,"P",{});var Mn=l(we);si=r(Mn,"This pipeline is called "),Es=o(Mn,"EM",{});var kl=l(Es);ai=r(kl,"zero-shot"),kl.forEach(t),ni=r(Mn," because you don\u2019t need to fine-tune the model on your data to use it. It can directly return probability scores for any list of labels you want!"),Mn.forEach(t),Fa=c(e),b(ye.$$.fragment,e),La=c(e),X=o(e,"H2",{class:!0});var Rn=l(X);ve=o(Rn,"A",{id:!0,class:!0,href:!0});var El=l(ve);js=o(El,"SPAN",{});var jl=l(js);b(Xe.$$.fragment,jl),jl.forEach(t),El.forEach(t),oi=c(Rn),Ts=o(Rn,"SPAN",{});var Tl=l(Ts);ii=r(Tl,"Text generation"),Tl.forEach(t),Rn.forEach(t),Ma=c(e),zt=o(e,"P",{});var ql=l(zt);ri=r(ql,"Now let\u2019s see how to use a pipeline to generate some text. The main idea here is that you provide a prompt and the model will auto-complete it by generating the remaining text. This is similar to the predictive text feature that is found on many phones. Text generation involves randomness, so it\u2019s normal if you don\u2019t get the same results as shown below."),ql.forEach(t),Ra=c(e),b(et.$$.fragment,e),Ga=c(e),b(tt.$$.fragment,e),Wa=c(e),G=o(e,"P",{});var Yt=l(G);li=r(Yt,"You can control how many different sequences are generated with the argument "),qs=o(Yt,"CODE",{});var Pl=l(qs);pi=r(Pl,"num_return_sequences"),Pl.forEach(t),hi=r(Yt," and the total length of the output text with the argument "),Ps=o(Yt,"CODE",{});var Il=l(Ps);ci=r(Il,"max_length"),Il.forEach(t),fi=r(Yt,"."),Yt.forEach(t),Ba=c(e),b($e.$$.fragment,e),Ya=c(e),ee=o(e,"H2",{class:!0});var Gn=l(ee);be=o(Gn,"A",{id:!0,class:!0,href:!0});var Al=l(be);Is=o(Al,"SPAN",{});var Sl=l(Is);b(st.$$.fragment,Sl),Sl.forEach(t),Al.forEach(t),ui=c(Gn),As=o(Gn,"SPAN",{});var Hl=l(As);mi=r(Hl,"Using any model from the Hub in a pipeline"),Hl.forEach(t),Gn.forEach(t),Ua=c(e),W=o(e,"P",{});var Ut=l(W);di=r(Ut,"The previous examples used the default model for the task at hand, but you can also choose a particular model from the Hub to use in a pipeline for a specific task \u2014 say, text generation. Go to the "),at=o(Ut,"A",{href:!0,rel:!0});var Ol=l(at);gi=r(Ol,"Model Hub"),Ol.forEach(t),wi=r(Ut," and click on the corresponding tag on the left to display only the supported models for that task. You should get to a page like "),nt=o(Ut,"A",{href:!0,rel:!0});var Cl=l(nt);yi=r(Cl,"this one"),Cl.forEach(t),vi=r(Ut,"."),Ut.forEach(t),Va=c(e),xe=o(e,"P",{});var Wn=l(xe);$i=r(Wn,"Let\u2019s try the "),ot=o(Wn,"A",{href:!0,rel:!0});var Nl=l(ot);Ss=o(Nl,"CODE",{});var zl=l(Ss);bi=r(zl,"distilgpt2"),zl.forEach(t),Nl.forEach(t),xi=r(Wn," model! Here\u2019s how to load it in the same pipeline as before:"),Wn.forEach(t),Za=c(e),b(it.$$.fragment,e),Qa=c(e),b(rt.$$.fragment,e),Ja=c(e),Dt=o(e,"P",{});var Dl=l(Dt);_i=r(Dl,"You can refine your search for a model by clicking on the language tags, and pick a model that will generate text in another language. The Model Hub even contains checkpoints for multilingual models that support several languages."),Dl.forEach(t),Ka=c(e),Ft=o(e,"P",{});var Fl=l(Ft);ki=r(Fl,"Once you select a model by clicking on it, you\u2019ll see that there is a widget enabling you to try it directly online. This way you can quickly test the model\u2019s capabilities before downloading it."),Fl.forEach(t),Xa=c(e),b(_e.$$.fragment,e),en=c(e),te=o(e,"H3",{class:!0});var Bn=l(te);ke=o(Bn,"A",{id:!0,class:!0,href:!0});var Ll=l(ke);Hs=o(Ll,"SPAN",{});var Ml=l(Hs);b(lt.$$.fragment,Ml),Ml.forEach(t),Ll.forEach(t),Ei=c(Bn),Os=o(Bn,"SPAN",{});var Rl=l(Os);ji=r(Rl,"The Inference API"),Rl.forEach(t),Bn.forEach(t),tn=c(e),Ee=o(e,"P",{});var Yn=l(Ee);Ti=r(Yn,"All the models can be tested directly through your browser using the Inference API, which is available on the Hugging Face "),pt=o(Yn,"A",{href:!0,rel:!0});var Gl=l(pt);qi=r(Gl,"website"),Gl.forEach(t),Pi=r(Yn,". You can play with the model directly on this page by inputting custom text and watching the model process the input data."),Yn.forEach(t),sn=c(e),je=o(e,"P",{});var Un=l(je);Ii=r(Un,"The Inference API that powers the widget is also available as a paid product, which comes in handy if you need it for your workflows. See the "),ht=o(Un,"A",{href:!0,rel:!0});var Wl=l(ht);Ai=r(Wl,"pricing page"),Wl.forEach(t),Si=r(Un," for more details."),Un.forEach(t),an=c(e),se=o(e,"H2",{class:!0});var Vn=l(se);Te=o(Vn,"A",{id:!0,class:!0,href:!0});var Bl=l(Te);Cs=o(Bl,"SPAN",{});var Yl=l(Cs);b(ct.$$.fragment,Yl),Yl.forEach(t),Bl.forEach(t),Hi=c(Vn),Ns=o(Vn,"SPAN",{});var Ul=l(Ns);Oi=r(Ul,"Mask filling"),Ul.forEach(t),Vn.forEach(t),nn=c(e),qe=o(e,"P",{});var Zn=l(qe);Ci=r(Zn,"The next pipeline you\u2019ll try is "),zs=o(Zn,"CODE",{});var Vl=l(zs);Ni=r(Vl,"fill-mask"),Vl.forEach(t),zi=r(Zn,". The idea of this task is to fill in the blanks in a given text:"),Zn.forEach(t),on=c(e),b(ft.$$.fragment,e),rn=c(e),b(ut.$$.fragment,e),ln=c(e),D=o(e,"P",{});var De=l(D);Di=r(De,"The "),Ds=o(De,"CODE",{});var Zl=l(Ds);Fi=r(Zl,"top_k"),Zl.forEach(t),Li=r(De," argument controls how many possibilities you want to be displayed. Note that here the model fills in the special "),Fs=o(De,"CODE",{});var Ql=l(Fs);Mi=r(Ql,"<mask>"),Ql.forEach(t),Ri=r(De," word, which is often referred to as a "),Ls=o(De,"EM",{});var Jl=l(Ls);Gi=r(Jl,"mask token"),Jl.forEach(t),Wi=r(De,". Other mask-filling models might have different mask tokens, so it\u2019s always good to verify the proper mask word when exploring other models. One way to check it is by looking at the mask word used in the widget."),De.forEach(t),pn=c(e),b(Pe.$$.fragment,e),hn=c(e),ae=o(e,"H2",{class:!0});var Qn=l(ae);Ie=o(Qn,"A",{id:!0,class:!0,href:!0});var Kl=l(Ie);Ms=o(Kl,"SPAN",{});var Xl=l(Ms);b(mt.$$.fragment,Xl),Xl.forEach(t),Kl.forEach(t),Bi=c(Qn),Rs=o(Qn,"SPAN",{});var ep=l(Rs);Yi=r(ep,"Named entity recognition"),ep.forEach(t),Qn.forEach(t),cn=c(e),Lt=o(e,"P",{});var tp=l(Lt);Ui=r(tp,"Named entity recognition (NER) is a task where the model has to find which parts of the input text correspond to entities such as persons, locations, or organizations. Let\u2019s look at an example:"),tp.forEach(t),fn=c(e),b(dt.$$.fragment,e),un=c(e),b(gt.$$.fragment,e),mn=c(e),Mt=o(e,"P",{});var sp=l(Mt);Vi=r(sp,"Here the model correctly identified that Sylvain is a person (PER), Hugging Face an organization (ORG), and Brooklyn a location (LOC)."),sp.forEach(t),dn=c(e),C=o(e,"P",{});var z=l(C);Zi=r(z,"We pass the option "),Gs=o(z,"CODE",{});var ap=l(Gs);Qi=r(ap,"grouped_entities=True"),ap.forEach(t),Ji=r(z," in the pipeline creation function to tell the pipeline to regroup together the parts of the sentence that correspond to the same entity: here the model correctly grouped \u201CHugging\u201D and \u201CFace\u201D as a single organization, even though the name consists of multiple words. In fact, as we will see in the next chapter, the preprocessing even splits some words into smaller parts. For instance, "),Ws=o(z,"CODE",{});var np=l(Ws);Ki=r(np,"Sylvain"),np.forEach(t),Xi=r(z," is split into four pieces: "),Bs=o(z,"CODE",{});var op=l(Bs);er=r(op,"S"),op.forEach(t),tr=r(z,", "),Ys=o(z,"CODE",{});var ip=l(Ys);sr=r(ip,"##yl"),ip.forEach(t),ar=r(z,", "),Us=o(z,"CODE",{});var rp=l(Us);nr=r(rp,"##va"),rp.forEach(t),or=r(z,", and "),Vs=o(z,"CODE",{});var lp=l(Vs);ir=r(lp,"##in"),lp.forEach(t),rr=r(z,". In the post-processing step, the pipeline successfully regrouped those pieces."),z.forEach(t),gn=c(e),b(Ae.$$.fragment,e),wn=c(e),ne=o(e,"H2",{class:!0});var Jn=l(ne);Se=o(Jn,"A",{id:!0,class:!0,href:!0});var pp=l(Se);Zs=o(pp,"SPAN",{});var hp=l(Zs);b(wt.$$.fragment,hp),hp.forEach(t),pp.forEach(t),lr=c(Jn),Qs=o(Jn,"SPAN",{});var cp=l(Qs);pr=r(cp,"Question answering"),cp.forEach(t),Jn.forEach(t),yn=c(e),He=o(e,"P",{});var Kn=l(He);hr=r(Kn,"The "),Js=o(Kn,"CODE",{});var fp=l(Js);cr=r(fp,"question-answering"),fp.forEach(t),fr=r(Kn," pipeline answers questions using information from a given context:"),Kn.forEach(t),vn=c(e),b(yt.$$.fragment,e),$n=c(e),b(vt.$$.fragment,e),bn=c(e),Rt=o(e,"P",{});var up=l(Rt);ur=r(up,"Note that this pipeline works by extracting information from the provided context; it does not generate the answer."),up.forEach(t),xn=c(e),oe=o(e,"H2",{class:!0});var Xn=l(oe);Oe=o(Xn,"A",{id:!0,class:!0,href:!0});var mp=l(Oe);Ks=o(mp,"SPAN",{});var dp=l(Ks);b($t.$$.fragment,dp),dp.forEach(t),mp.forEach(t),mr=c(Xn),Xs=o(Xn,"SPAN",{});var gp=l(Xs);dr=r(gp,"Summarization"),gp.forEach(t),Xn.forEach(t),_n=c(e),Gt=o(e,"P",{});var wp=l(Gt);gr=r(wp,"Summarization is the task of reducing a text into a shorter text while keeping all (or most) of the important aspects referenced in the text. Here\u2019s an example:"),wp.forEach(t),kn=c(e),b(bt.$$.fragment,e),En=c(e),b(xt.$$.fragment,e),jn=c(e),B=o(e,"P",{});var Vt=l(B);wr=r(Vt,"Like with text generation, you can specify a "),ea=o(Vt,"CODE",{});var yp=l(ea);yr=r(yp,"max_length"),yp.forEach(t),vr=r(Vt," or a "),ta=o(Vt,"CODE",{});var vp=l(ta);$r=r(vp,"min_length"),vp.forEach(t),br=r(Vt," for the result."),Vt.forEach(t),Tn=c(e),ie=o(e,"H2",{class:!0});var eo=l(ie);Ce=o(eo,"A",{id:!0,class:!0,href:!0});var $p=l(Ce);sa=o($p,"SPAN",{});var bp=l(sa);b(_t.$$.fragment,bp),bp.forEach(t),$p.forEach(t),xr=c(eo),aa=o(eo,"SPAN",{});var xp=l(aa);_r=r(xp,"Translation"),xp.forEach(t),eo.forEach(t),qn=c(e),Y=o(e,"P",{});var Zt=l(Y);kr=r(Zt,"For translation, you can use a default model if you provide a language pair in the task name (such as "),na=o(Zt,"CODE",{});var _p=l(na);Er=r(_p,'"translation_en_to_fr"'),_p.forEach(t),jr=r(Zt,"), but the easiest way is to pick the model you want to use on the "),kt=o(Zt,"A",{href:!0,rel:!0});var kp=l(kt);Tr=r(kp,"Model Hub"),kp.forEach(t),qr=r(Zt,". Here we\u2019ll try translating from French to English:"),Zt.forEach(t),Pn=c(e),b(Et.$$.fragment,e),In=c(e),b(jt.$$.fragment,e),An=c(e),U=o(e,"P",{});var Qt=l(U);Pr=r(Qt,"Like with text generation and summarization, you can specify a "),oa=o(Qt,"CODE",{});var Ep=l(oa);Ir=r(Ep,"max_length"),Ep.forEach(t),Ar=r(Qt," or a "),ia=o(Qt,"CODE",{});var jp=l(ia);Sr=r(jp,"min_length"),jp.forEach(t),Hr=r(Qt," for the result."),Qt.forEach(t),Sn=c(e),b(Ne.$$.fragment,e),Hn=c(e),ze=o(e,"P",{});var to=l(ze);Or=r(to,"The pipelines shown so far are mostly for demonstrative purposes. They were programmed for specific tasks and cannot perform variations of them. In the next chapter, you\u2019ll learn what\u2019s inside a "),ra=o(to,"CODE",{});var Tp=l(ra);Cr=r(Tp,"pipeline()"),Tp.forEach(t),Nr=r(to," function and how to customize its behavior."),to.forEach(t),this.h()},h(){u(f,"name","hf:doc:metadata"),u(f,"content",JSON.stringify(Bp)),u(v,"id","transformers-what-can-they-do"),u(v,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),u(v,"href","#transformers-what-can-they-do"),u(d,"class","relative group"),u(le,"id","transformers-are-everywhere"),u(le,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),u(le,"href","#transformers-are-everywhere"),u(Q,"class","relative group"),Sp(pe.src,Fr="https://huggingface.co/datasets/huggingface-course/documentation-images/resolve/main/en/chapter1/companies.PNG")||u(pe,"src",Fr),u(pe,"alt","Companies using Hugging Face"),u(pe,"width","100%"),u(Me,"href","https://github.com/huggingface/transformers"),u(Me,"rel","nofollow"),u(Re,"href","https://huggingface.co/models"),u(Re,"rel","nofollow"),u(ce,"id","working-with-pipelines"),u(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"),u(ce,"href","#working-with-pipelines"),u(J,"class","relative group"),u(Ze,"href","https://huggingface.co/transformers/main_classes/pipelines.html"),u(Ze,"rel","nofollow"),u(de,"id","zeroshot-classification"),u(de,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),u(de,"href","#zeroshot-classification"),u(K,"class","relative group"),u(ve,"id","text-generation"),u(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"),u(ve,"href","#text-generation"),u(X,"class","relative group"),u(be,"id","using-any-model-from-the-hub-in-a-pipeline"),u(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"),u(be,"href","#using-any-model-from-the-hub-in-a-pipeline"),u(ee,"class","relative group"),u(at,"href","https://huggingface.co/models"),u(at,"rel","nofollow"),u(nt,"href","https://huggingface.co/models?pipeline_tag=text-generation"),u(nt,"rel","nofollow"),u(ot,"href","https://huggingface.co/distilgpt2"),u(ot,"rel","nofollow"),u(ke,"id","the-inference-api"),u(ke,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),u(ke,"href","#the-inference-api"),u(te,"class","relative group"),u(pt,"href","https://huggingface.co/"),u(pt,"rel","nofollow"),u(ht,"href","https://huggingface.co/pricing"),u(ht,"rel","nofollow"),u(Te,"id","mask-filling"),u(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"),u(Te,"href","#mask-filling"),u(se,"class","relative group"),u(Ie,"id","named-entity-recognition"),u(Ie,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),u(Ie,"href","#named-entity-recognition"),u(ae,"class","relative group"),u(Se,"id","question-answering"),u(Se,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),u(Se,"href","#question-answering"),u(ne,"class","relative group"),u(Oe,"id","summarization"),u(Oe,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),u(Oe,"href","#summarization"),u(oe,"class","relative group"),u(Ce,"id","translation"),u(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"),u(Ce,"href","#translation"),u(ie,"class","relative group"),u(kt,"href","https://huggingface.co/models"),u(kt,"rel","nofollow")},m(e,a){s(document.head,f),p(e,y,a),p(e,d,a),s(d,v),s(v,g),x(m,g,null),s(d,w),s(d,T),s(T,H),p(e,q,a),x(P,e,a),p(e,A,a),p(e,j,a),s(j,V),s(j,L),s(L,Z),s(j,so),p(e,ua,a),x(re,e,a),p(e,ma,a),p(e,Q,a),s(Q,le),s(le,Jt),x(Le,Jt,null),s(Q,ao),s(Q,Kt),s(Kt,no),p(e,da,a),p(e,It,a),s(It,oo),p(e,ga,a),p(e,pe,a),p(e,wa,a),p(e,M,a),s(M,io),s(M,Me),s(Me,ro),s(M,lo),s(M,Re),s(Re,po),s(M,ho),p(e,ya,a),x(he,e,a),p(e,va,a),p(e,At,a),s(At,co),p(e,$a,a),p(e,J,a),s(J,ce),s(ce,Xt),x(Ge,Xt,null),s(J,fo),s(J,es),s(es,uo),p(e,ba,a),x(We,e,a),p(e,xa,a),p(e,fe,a),s(fe,mo),s(fe,ts),s(ts,go),s(fe,wo),p(e,_a,a),x(Be,e,a),p(e,ka,a),x(Ye,e,a),p(e,Ea,a),p(e,St,a),s(St,yo),p(e,ja,a),x(Ue,e,a),p(e,Ta,a),x(Ve,e,a),p(e,qa,a),p(e,ue,a),s(ue,vo),s(ue,ss),s(ss,$o),s(ue,bo),p(e,Pa,a),p(e,Ht,a),s(Ht,xo),p(e,Ia,a),p(e,R,a),s(R,as),s(as,_o),s(R,ko),s(R,ns),s(ns,Eo),s(R,jo),s(R,os),s(os,To),p(e,Aa,a),p(e,me,a),s(me,qo),s(me,Ze),s(Ze,Po),s(me,Io),p(e,Sa,a),p(e,I,a),s(I,Ot),s(Ot,is),s(is,Ao),s(Ot,So),s(I,Ho),s(I,rs),s(rs,ls),s(ls,Oo),s(I,Co),s(I,Ct),s(Ct,ps),s(ps,No),s(Ct,zo),s(I,Do),s(I,hs),s(hs,cs),s(cs,Fo),s(I,Lo),s(I,fs),s(fs,us),s(us,Mo),s(I,Ro),s(I,ms),s(ms,ds),s(ds,Go),s(I,Wo),s(I,gs),s(gs,ws),s(ws,Bo),s(I,Yo),s(I,ys),s(ys,vs),s(vs,Uo),s(I,Vo),s(I,$s),s($s,bs),s(bs,Zo),p(e,Ha,a),p(e,Nt,a),s(Nt,Qo),p(e,Oa,a),p(e,K,a),s(K,de),s(de,xs),x(Qe,xs,null),s(K,Jo),s(K,_s),s(_s,Ko),p(e,Ca,a),p(e,ge,a),s(ge,Xo),s(ge,ks),s(ks,ei),s(ge,ti),p(e,Na,a),x(Je,e,a),p(e,za,a),x(Ke,e,a),p(e,Da,a),p(e,we,a),s(we,si),s(we,Es),s(Es,ai),s(we,ni),p(e,Fa,a),x(ye,e,a),p(e,La,a),p(e,X,a),s(X,ve),s(ve,js),x(Xe,js,null),s(X,oi),s(X,Ts),s(Ts,ii),p(e,Ma,a),p(e,zt,a),s(zt,ri),p(e,Ra,a),x(et,e,a),p(e,Ga,a),x(tt,e,a),p(e,Wa,a),p(e,G,a),s(G,li),s(G,qs),s(qs,pi),s(G,hi),s(G,Ps),s(Ps,ci),s(G,fi),p(e,Ba,a),x($e,e,a),p(e,Ya,a),p(e,ee,a),s(ee,be),s(be,Is),x(st,Is,null),s(ee,ui),s(ee,As),s(As,mi),p(e,Ua,a),p(e,W,a),s(W,di),s(W,at),s(at,gi),s(W,wi),s(W,nt),s(nt,yi),s(W,vi),p(e,Va,a),p(e,xe,a),s(xe,$i),s(xe,ot),s(ot,Ss),s(Ss,bi),s(xe,xi),p(e,Za,a),x(it,e,a),p(e,Qa,a),x(rt,e,a),p(e,Ja,a),p(e,Dt,a),s(Dt,_i),p(e,Ka,a),p(e,Ft,a),s(Ft,ki),p(e,Xa,a),x(_e,e,a),p(e,en,a),p(e,te,a),s(te,ke),s(ke,Hs),x(lt,Hs,null),s(te,Ei),s(te,Os),s(Os,ji),p(e,tn,a),p(e,Ee,a),s(Ee,Ti),s(Ee,pt),s(pt,qi),s(Ee,Pi),p(e,sn,a),p(e,je,a),s(je,Ii),s(je,ht),s(ht,Ai),s(je,Si),p(e,an,a),p(e,se,a),s(se,Te),s(Te,Cs),x(ct,Cs,null),s(se,Hi),s(se,Ns),s(Ns,Oi),p(e,nn,a),p(e,qe,a),s(qe,Ci),s(qe,zs),s(zs,Ni),s(qe,zi),p(e,on,a),x(ft,e,a),p(e,rn,a),x(ut,e,a),p(e,ln,a),p(e,D,a),s(D,Di),s(D,Ds),s(Ds,Fi),s(D,Li),s(D,Fs),s(Fs,Mi),s(D,Ri),s(D,Ls),s(Ls,Gi),s(D,Wi),p(e,pn,a),x(Pe,e,a),p(e,hn,a),p(e,ae,a),s(ae,Ie),s(Ie,Ms),x(mt,Ms,null),s(ae,Bi),s(ae,Rs),s(Rs,Yi),p(e,cn,a),p(e,Lt,a),s(Lt,Ui),p(e,fn,a),x(dt,e,a),p(e,un,a),x(gt,e,a),p(e,mn,a),p(e,Mt,a),s(Mt,Vi),p(e,dn,a),p(e,C,a),s(C,Zi),s(C,Gs),s(Gs,Qi),s(C,Ji),s(C,Ws),s(Ws,Ki),s(C,Xi),s(C,Bs),s(Bs,er),s(C,tr),s(C,Ys),s(Ys,sr),s(C,ar),s(C,Us),s(Us,nr),s(C,or),s(C,Vs),s(Vs,ir),s(C,rr),p(e,gn,a),x(Ae,e,a),p(e,wn,a),p(e,ne,a),s(ne,Se),s(Se,Zs),x(wt,Zs,null),s(ne,lr),s(ne,Qs),s(Qs,pr),p(e,yn,a),p(e,He,a),s(He,hr),s(He,Js),s(Js,cr),s(He,fr),p(e,vn,a),x(yt,e,a),p(e,$n,a),x(vt,e,a),p(e,bn,a),p(e,Rt,a),s(Rt,ur),p(e,xn,a),p(e,oe,a),s(oe,Oe),s(Oe,Ks),x($t,Ks,null),s(oe,mr),s(oe,Xs),s(Xs,dr),p(e,_n,a),p(e,Gt,a),s(Gt,gr),p(e,kn,a),x(bt,e,a),p(e,En,a),x(xt,e,a),p(e,jn,a),p(e,B,a),s(B,wr),s(B,ea),s(ea,yr),s(B,vr),s(B,ta),s(ta,$r),s(B,br),p(e,Tn,a),p(e,ie,a),s(ie,Ce),s(Ce,sa),x(_t,sa,null),s(ie,xr),s(ie,aa),s(aa,_r),p(e,qn,a),p(e,Y,a),s(Y,kr),s(Y,na),s(na,Er),s(Y,jr),s(Y,kt),s(kt,Tr),s(Y,qr),p(e,Pn,a),x(Et,e,a),p(e,In,a),x(jt,e,a),p(e,An,a),p(e,U,a),s(U,Pr),s(U,oa),s(oa,Ir),s(U,Ar),s(U,ia),s(ia,Sr),s(U,Hr),p(e,Sn,a),x(Ne,e,a),p(e,Hn,a),p(e,ze,a),s(ze,Or),s(ze,ra),s(ra,Cr),s(ze,Nr),On=!0},p(e,[a]){const Tt={};a&2&&(Tt.$$scope={dirty:a,ctx:e}),re.$set(Tt);const la={};a&2&&(la.$$scope={dirty:a,ctx:e}),he.$set(la);const pa={};a&2&&(pa.$$scope={dirty:a,ctx:e}),ye.$set(pa);const ha={};a&2&&(ha.$$scope={dirty:a,ctx:e}),$e.$set(ha);const qt={};a&2&&(qt.$$scope={dirty:a,ctx:e}),_e.$set(qt);const ca={};a&2&&(ca.$$scope={dirty:a,ctx:e}),Pe.$set(ca);const Pt={};a&2&&(Pt.$$scope={dirty:a,ctx:e}),Ae.$set(Pt);const fa={};a&2&&(fa.$$scope={dirty:a,ctx:e}),Ne.$set(fa)},i(e){On||(_(m.$$.fragment,e),_(P.$$.fragment,e),_(re.$$.fragment,e),_(Le.$$.fragment,e),_(he.$$.fragment,e),_(Ge.$$.fragment,e),_(We.$$.fragment,e),_(Be.$$.fragment,e),_(Ye.$$.fragment,e),_(Ue.$$.fragment,e),_(Ve.$$.fragment,e),_(Qe.$$.fragment,e),_(Je.$$.fragment,e),_(Ke.$$.fragment,e),_(ye.$$.fragment,e),_(Xe.$$.fragment,e),_(et.$$.fragment,e),_(tt.$$.fragment,e),_($e.$$.fragment,e),_(st.$$.fragment,e),_(it.$$.fragment,e),_(rt.$$.fragment,e),_(_e.$$.fragment,e),_(lt.$$.fragment,e),_(ct.$$.fragment,e),_(ft.$$.fragment,e),_(ut.$$.fragment,e),_(Pe.$$.fragment,e),_(mt.$$.fragment,e),_(dt.$$.fragment,e),_(gt.$$.fragment,e),_(Ae.$$.fragment,e),_(wt.$$.fragment,e),_(yt.$$.fragment,e),_(vt.$$.fragment,e),_($t.$$.fragment,e),_(bt.$$.fragment,e),_(xt.$$.fragment,e),_(_t.$$.fragment,e),_(Et.$$.fragment,e),_(jt.$$.fragment,e),_(Ne.$$.fragment,e),On=!0)},o(e){k(m.$$.fragment,e),k(P.$$.fragment,e),k(re.$$.fragment,e),k(Le.$$.fragment,e),k(he.$$.fragment,e),k(Ge.$$.fragment,e),k(We.$$.fragment,e),k(Be.$$.fragment,e),k(Ye.$$.fragment,e),k(Ue.$$.fragment,e),k(Ve.$$.fragment,e),k(Qe.$$.fragment,e),k(Je.$$.fragment,e),k(Ke.$$.fragment,e),k(ye.$$.fragment,e),k(Xe.$$.fragment,e),k(et.$$.fragment,e),k(tt.$$.fragment,e),k($e.$$.fragment,e),k(st.$$.fragment,e),k(it.$$.fragment,e),k(rt.$$.fragment,e),k(_e.$$.fragment,e),k(lt.$$.fragment,e),k(ct.$$.fragment,e),k(ft.$$.fragment,e),k(ut.$$.fragment,e),k(Pe.$$.fragment,e),k(mt.$$.fragment,e),k(dt.$$.fragment,e),k(gt.$$.fragment,e),k(Ae.$$.fragment,e),k(wt.$$.fragment,e),k(yt.$$.fragment,e),k(vt.$$.fragment,e),k($t.$$.fragment,e),k(bt.$$.fragment,e),k(xt.$$.fragment,e),k(_t.$$.fragment,e),k(Et.$$.fragment,e),k(jt.$$.fragment,e),k(Ne.$$.fragment,e),On=!1},d(e){t(f),e&&t(y),e&&t(d),E(m),e&&t(q),E(P,e),e&&t(A),e&&t(j),e&&t(ua),E(re,e),e&&t(ma),e&&t(Q),E(Le),e&&t(da),e&&t(It),e&&t(ga),e&&t(pe),e&&t(wa),e&&t(M),e&&t(ya),E(he,e),e&&t(va),e&&t(At),e&&t($a),e&&t(J),E(Ge),e&&t(ba),E(We,e),e&&t(xa),e&&t(fe),e&&t(_a),E(Be,e),e&&t(ka),E(Ye,e),e&&t(Ea),e&&t(St),e&&t(ja),E(Ue,e),e&&t(Ta),E(Ve,e),e&&t(qa),e&&t(ue),e&&t(Pa),e&&t(Ht),e&&t(Ia),e&&t(R),e&&t(Aa),e&&t(me),e&&t(Sa),e&&t(I),e&&t(Ha),e&&t(Nt),e&&t(Oa),e&&t(K),E(Qe),e&&t(Ca),e&&t(ge),e&&t(Na),E(Je,e),e&&t(za),E(Ke,e),e&&t(Da),e&&t(we),e&&t(Fa),E(ye,e),e&&t(La),e&&t(X),E(Xe),e&&t(Ma),e&&t(zt),e&&t(Ra),E(et,e),e&&t(Ga),E(tt,e),e&&t(Wa),e&&t(G),e&&t(Ba),E($e,e),e&&t(Ya),e&&t(ee),E(st),e&&t(Ua),e&&t(W),e&&t(Va),e&&t(xe),e&&t(Za),E(it,e),e&&t(Qa),E(rt,e),e&&t(Ja),e&&t(Dt),e&&t(Ka),e&&t(Ft),e&&t(Xa),E(_e,e),e&&t(en),e&&t(te),E(lt),e&&t(tn),e&&t(Ee),e&&t(sn),e&&t(je),e&&t(an),e&&t(se),E(ct),e&&t(nn),e&&t(qe),e&&t(on),E(ft,e),e&&t(rn),E(ut,e),e&&t(ln),e&&t(D),e&&t(pn),E(Pe,e),e&&t(hn),e&&t(ae),E(mt),e&&t(cn),e&&t(Lt),e&&t(fn),E(dt,e),e&&t(un),E(gt,e),e&&t(mn),e&&t(Mt),e&&t(dn),e&&t(C),e&&t(gn),E(Ae,e),e&&t(wn),e&&t(ne),E(wt),e&&t(yn),e&&t(He),e&&t(vn),E(yt,e),e&&t($n),E(vt,e),e&&t(bn),e&&t(Rt),e&&t(xn),e&&t(oe),E($t),e&&t(_n),e&&t(Gt),e&&t(kn),E(bt,e),e&&t(En),E(xt,e),e&&t(jn),e&&t(B),e&&t(Tn),e&&t(ie),E(_t),e&&t(qn),e&&t(Y),e&&t(Pn),E(Et,e),e&&t(In),E(jt,e),e&&t(An),e&&t(U),e&&t(Sn),E(Ne,e),e&&t(Hn),e&&t(ze)}}}const Bp={local:"transformers-what-can-they-do",sections:[{local:"transformers-are-everywhere",title:"Transformers are everywhere!"},{local:"working-with-pipelines",title:"Working with pipelines"},{local:"zeroshot-classification",title:"Zero-shot classification"},{local:"text-generation",title:"Text generation"},{local:"using-any-model-from-the-hub-in-a-pipeline",sections:[{local:"the-inference-api",title:"The Inference API"}],title:"Using any model from the Hub in a pipeline"},{local:"mask-filling",title:"Mask filling"},{local:"named-entity-recognition",title:"Named entity recognition"},{local:"question-answering",title:"Question answering"},{local:"summarization",title:"Summarization"},{local:"translation",title:"Translation"}],title:"Transformers, what can they do?"};function Yp(O){return Hp(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class Xp extends qp{constructor(f){super();Pp(this,f,Yp,Wp,Ip,{})}}export{Xp as default,Bp as metadata};
