import{S as U$,i as G$,s as K$,e as l,k as f,w as k,t as s,M as B$,c as i,d as a,m as c,a as p,x as w,h as r,b as h,G as e,g as d,y,q as b,o as T,B as E,v as V$,L as be}from"../chunks/vendor-hf-doc-builder.js";import{T as Mn}from"../chunks/Tip-hf-doc-builder.js";import{Y as Y$}from"../chunks/Youtube-hf-doc-builder.js";import{I as We}from"../chunks/IconCopyLink-hf-doc-builder.js";import{C as O}from"../chunks/CodeBlock-hf-doc-builder.js";import{D as Q$}from"../chunks/DocNotebookDropdown-hf-doc-builder.js";import{F as _s,M as ue}from"../chunks/Markdown-hf-doc-builder.js";function J$(F){let o,u;return o=new O({props:{code:"pip install torch",highlighted:"pip install torch"}}),{c(){k(o.$$.fragment)},l(n){w(o.$$.fragment,n)},m(n,g){y(o,n,g),u=!0},p:be,i(n){u||(b(o.$$.fragment,n),u=!0)},o(n){T(o.$$.fragment,n),u=!1},d(n){E(o,n)}}}function Z$(F){let o,u;return o=new ue({props:{$$slots:{default:[J$]},$$scope:{ctx:F}}}),{c(){k(o.$$.fragment)},l(n){w(o.$$.fragment,n)},m(n,g){y(o,n,g),u=!0},p(n,g){const _={};g&2&&(_.$$scope={dirty:g,ctx:n}),o.$set(_)},i(n){u||(b(o.$$.fragment,n),u=!0)},o(n){T(o.$$.fragment,n),u=!1},d(n){E(o,n)}}}function X$(F){let o,u;return o=new O({props:{code:"pip install tensorflow",highlighted:"pip install tensorflow"}}),{c(){k(o.$$.fragment)},l(n){w(o.$$.fragment,n)},m(n,g){y(o,n,g),u=!0},p:be,i(n){u||(b(o.$$.fragment,n),u=!0)},o(n){T(o.$$.fragment,n),u=!1},d(n){E(o,n)}}}function e_(F){let o,u;return o=new ue({props:{$$slots:{default:[X$]},$$scope:{ctx:F}}}),{c(){k(o.$$.fragment)},l(n){w(o.$$.fragment,n)},m(n,g){y(o,n,g),u=!0},p(n,g){const _={};g&2&&(_.$$scope={dirty:g,ctx:n}),o.$set(_)},i(n){u||(b(o.$$.fragment,n),u=!0)},o(n){T(o.$$.fragment,n),u=!1},d(n){E(o,n)}}}function t_(F){let o,u,n,g,_,v,z,M,$,j,D,I,N,H;return N=new O({props:{code:`from transformers import AutoTokenizer, AutoModelForSequenceClassification

model = AutoModelForSequenceClassification.from_pretrained(model_name)
tokenizer = AutoTokenizer.from_pretrained(model_name)`,highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoTokenizer, AutoModelForSequenceClassification

<span class="hljs-meta">&gt;&gt;&gt; </span>model = AutoModelForSequenceClassification.from_pretrained(model_name)
<span class="hljs-meta">&gt;&gt;&gt; </span>tokenizer = AutoTokenizer.from_pretrained(model_name)`}}),{c(){o=l("p"),u=s("Use "),n=l("a"),g=s("AutoModelForSequenceClassification"),_=s(" and "),v=l("a"),z=s("AutoTokenizer"),M=s(" to load the pretrained model and it\u2019s associated tokenizer (more on an "),$=l("code"),j=s("AutoClass"),D=s(" in the next section):"),I=f(),k(N.$$.fragment),this.h()},l(q){o=i(q,"P",{});var P=p(o);u=r(P,"Use "),n=i(P,"A",{href:!0});var A=p(n);g=r(A,"AutoModelForSequenceClassification"),A.forEach(a),_=r(P," and "),v=i(P,"A",{href:!0});var S=p(v);z=r(S,"AutoTokenizer"),S.forEach(a),M=r(P," to load the pretrained model and it\u2019s associated tokenizer (more on an "),$=i(P,"CODE",{});var U=p($);j=r(U,"AutoClass"),U.forEach(a),D=r(P," in the next section):"),P.forEach(a),I=c(q),w(N.$$.fragment,q),this.h()},h(){h(n,"href","/docs/transformers/main/en/model_doc/auto#transformers.AutoModelForSequenceClassification"),h(v,"href","/docs/transformers/main/en/model_doc/auto#transformers.AutoTokenizer")},m(q,P){d(q,o,P),e(o,u),e(o,n),e(n,g),e(o,_),e(o,v),e(v,z),e(o,M),e(o,$),e($,j),e(o,D),d(q,I,P),y(N,q,P),H=!0},p:be,i(q){H||(b(N.$$.fragment,q),H=!0)},o(q){T(N.$$.fragment,q),H=!1},d(q){q&&a(o),q&&a(I),E(N,q)}}}function a_(F){let o,u;return o=new ue({props:{$$slots:{default:[t_]},$$scope:{ctx:F}}}),{c(){k(o.$$.fragment)},l(n){w(o.$$.fragment,n)},m(n,g){y(o,n,g),u=!0},p(n,g){const _={};g&2&&(_.$$scope={dirty:g,ctx:n}),o.$set(_)},i(n){u||(b(o.$$.fragment,n),u=!0)},o(n){T(o.$$.fragment,n),u=!1},d(n){E(o,n)}}}function s_(F){let o,u,n,g,_,v,z,M,$,j,D,I,N,H;return N=new O({props:{code:`from transformers import AutoTokenizer, TFAutoModelForSequenceClassification

model = TFAutoModelForSequenceClassification.from_pretrained(model_name)
tokenizer = AutoTokenizer.from_pretrained(model_name)`,highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoTokenizer, TFAutoModelForSequenceClassification

<span class="hljs-meta">&gt;&gt;&gt; </span>model = TFAutoModelForSequenceClassification.from_pretrained(model_name)
<span class="hljs-meta">&gt;&gt;&gt; </span>tokenizer = AutoTokenizer.from_pretrained(model_name)`}}),{c(){o=l("p"),u=s("Use "),n=l("a"),g=s("TFAutoModelForSequenceClassification"),_=s(" and "),v=l("a"),z=s("AutoTokenizer"),M=s(" to load the pretrained model and it\u2019s associated tokenizer (more on an "),$=l("code"),j=s("TFAutoClass"),D=s(" in the next section):"),I=f(),k(N.$$.fragment),this.h()},l(q){o=i(q,"P",{});var P=p(o);u=r(P,"Use "),n=i(P,"A",{href:!0});var A=p(n);g=r(A,"TFAutoModelForSequenceClassification"),A.forEach(a),_=r(P," and "),v=i(P,"A",{href:!0});var S=p(v);z=r(S,"AutoTokenizer"),S.forEach(a),M=r(P," to load the pretrained model and it\u2019s associated tokenizer (more on an "),$=i(P,"CODE",{});var U=p($);j=r(U,"TFAutoClass"),U.forEach(a),D=r(P," in the next section):"),P.forEach(a),I=c(q),w(N.$$.fragment,q),this.h()},h(){h(n,"href","/docs/transformers/main/en/model_doc/auto#transformers.TFAutoModelForSequenceClassification"),h(v,"href","/docs/transformers/main/en/model_doc/auto#transformers.AutoTokenizer")},m(q,P){d(q,o,P),e(o,u),e(o,n),e(n,g),e(o,_),e(o,v),e(v,z),e(o,M),e(o,$),e($,j),e(o,D),d(q,I,P),y(N,q,P),H=!0},p:be,i(q){H||(b(N.$$.fragment,q),H=!0)},o(q){T(N.$$.fragment,q),H=!1},d(q){q&&a(o),q&&a(I),E(N,q)}}}function r_(F){let o,u;return o=new ue({props:{$$slots:{default:[s_]},$$scope:{ctx:F}}}),{c(){k(o.$$.fragment)},l(n){w(o.$$.fragment,n)},m(n,g){y(o,n,g),u=!0},p(n,g){const _={};g&2&&(_.$$scope={dirty:g,ctx:n}),o.$set(_)},i(n){u||(b(o.$$.fragment,n),u=!0)},o(n){T(o.$$.fragment,n),u=!1},d(n){E(o,n)}}}function o_(F){let o,u;return o=new O({props:{code:`pt_batch = tokenizer(
    ["We are very happy to show you the \u{1F917} Transformers library.", "We hope you don't hate it."],
    padding=True,
    truncation=True,
    max_length=512,
    return_tensors="pt",
)`,highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span>pt_batch = tokenizer(
<span class="hljs-meta">... </span>    [<span class="hljs-string">&quot;We are very happy to show you the \u{1F917} Transformers library.&quot;</span>, <span class="hljs-string">&quot;We hope you don&#x27;t hate it.&quot;</span>],
<span class="hljs-meta">... </span>    padding=<span class="hljs-literal">True</span>,
<span class="hljs-meta">... </span>    truncation=<span class="hljs-literal">True</span>,
<span class="hljs-meta">... </span>    max_length=<span class="hljs-number">512</span>,
<span class="hljs-meta">... </span>    return_tensors=<span class="hljs-string">&quot;pt&quot;</span>,
<span class="hljs-meta">... </span>)`}}),{c(){k(o.$$.fragment)},l(n){w(o.$$.fragment,n)},m(n,g){y(o,n,g),u=!0},p:be,i(n){u||(b(o.$$.fragment,n),u=!0)},o(n){T(o.$$.fragment,n),u=!1},d(n){E(o,n)}}}function n_(F){let o,u;return o=new ue({props:{$$slots:{default:[o_]},$$scope:{ctx:F}}}),{c(){k(o.$$.fragment)},l(n){w(o.$$.fragment,n)},m(n,g){y(o,n,g),u=!0},p(n,g){const _={};g&2&&(_.$$scope={dirty:g,ctx:n}),o.$set(_)},i(n){u||(b(o.$$.fragment,n),u=!0)},o(n){T(o.$$.fragment,n),u=!1},d(n){E(o,n)}}}function l_(F){let o,u;return o=new O({props:{code:`tf_batch = tokenizer(
    ["We are very happy to show you the \u{1F917} Transformers library.", "We hope you don't hate it."],
    padding=True,
    truncation=True,
    max_length=512,
    return_tensors="tf",
)`,highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span>tf_batch = tokenizer(
<span class="hljs-meta">... </span>    [<span class="hljs-string">&quot;We are very happy to show you the \u{1F917} Transformers library.&quot;</span>, <span class="hljs-string">&quot;We hope you don&#x27;t hate it.&quot;</span>],
<span class="hljs-meta">... </span>    padding=<span class="hljs-literal">True</span>,
<span class="hljs-meta">... </span>    truncation=<span class="hljs-literal">True</span>,
<span class="hljs-meta">... </span>    max_length=<span class="hljs-number">512</span>,
<span class="hljs-meta">... </span>    return_tensors=<span class="hljs-string">&quot;tf&quot;</span>,
<span class="hljs-meta">... </span>)`}}),{c(){k(o.$$.fragment)},l(n){w(o.$$.fragment,n)},m(n,g){y(o,n,g),u=!0},p:be,i(n){u||(b(o.$$.fragment,n),u=!0)},o(n){T(o.$$.fragment,n),u=!1},d(n){E(o,n)}}}function i_(F){let o,u;return o=new ue({props:{$$slots:{default:[l_]},$$scope:{ctx:F}}}),{c(){k(o.$$.fragment)},l(n){w(o.$$.fragment,n)},m(n,g){y(o,n,g),u=!0},p(n,g){const _={};g&2&&(_.$$scope={dirty:g,ctx:n}),o.$set(_)},i(n){u||(b(o.$$.fragment,n),u=!0)},o(n){T(o.$$.fragment,n),u=!1},d(n){E(o,n)}}}function p_(F){let o,u,n,g,_,v,z,M,$,j,D,I,N,H;return{c(){o=l("p"),u=s("Check out the "),n=l("a"),g=s("preprocess"),_=s(" tutorial for more details about tokenization, and how to use an "),v=l("a"),z=s("AutoImageProcessor"),M=s(", "),$=l("a"),j=s("AutoFeatureExtractor"),D=s(" and "),I=l("a"),N=s("AutoProcessor"),H=s(" to preprocess image, audio, and multimodal inputs."),this.h()},l(q){o=i(q,"P",{});var P=p(o);u=r(P,"Check out the "),n=i(P,"A",{href:!0});var A=p(n);g=r(A,"preprocess"),A.forEach(a),_=r(P," tutorial for more details about tokenization, and how to use an "),v=i(P,"A",{href:!0});var S=p(v);z=r(S,"AutoImageProcessor"),S.forEach(a),M=r(P,", "),$=i(P,"A",{href:!0});var U=p($);j=r(U,"AutoFeatureExtractor"),U.forEach(a),D=r(P," and "),I=i(P,"A",{href:!0});var R=p(I);N=r(R,"AutoProcessor"),R.forEach(a),H=r(P," to preprocess image, audio, and multimodal inputs."),P.forEach(a),this.h()},h(){h(n,"href","./preprocessing"),h(v,"href","/docs/transformers/main/en/model_doc/auto#transformers.AutoImageProcessor"),h($,"href","/docs/transformers/main/en/model_doc/auto#transformers.AutoFeatureExtractor"),h(I,"href","/docs/transformers/main/en/model_doc/auto#transformers.AutoProcessor")},m(q,P){d(q,o,P),e(o,u),e(o,n),e(n,g),e(o,_),e(o,v),e(v,z),e(o,M),e(o,$),e($,j),e(o,D),e(o,I),e(I,N),e(o,H)},d(q){q&&a(o)}}}function f_(F){let o,u,n,g,_,v,z,M;return{c(){o=l("p"),u=s("See the "),n=l("a"),g=s("task summary"),_=s(" for tasks supported by an "),v=l("a"),z=s("AutoModel"),M=s(" class."),this.h()},l($){o=i($,"P",{});var j=p(o);u=r(j,"See the "),n=i(j,"A",{href:!0});var D=p(n);g=r(D,"task summary"),D.forEach(a),_=r(j," for tasks supported by an "),v=i(j,"A",{href:!0});var I=p(v);z=r(I,"AutoModel"),I.forEach(a),M=r(j," class."),j.forEach(a),this.h()},h(){h(n,"href","./task_summary"),h(v,"href","/docs/transformers/main/en/model_doc/auto#transformers.AutoModel")},m($,j){d($,o,j),e(o,u),e(o,n),e(n,g),e(o,_),e(o,v),e(v,z),e(o,M)},d($){$&&a(o)}}}function c_(F){let o,u,n,g,_,v,z,M,$,j,D,I,N,H,q,P,A,S,U,R,V,pe,ne,he,K,le,ie,B,$e,J,Te,_e,Q,se,Z,x,L,X;return P=new O({props:{code:`from transformers import AutoModelForSequenceClassification

model_name = "nlptown/bert-base-multilingual-uncased-sentiment"
pt_model = AutoModelForSequenceClassification.from_pretrained(model_name)`,highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoModelForSequenceClassification

<span class="hljs-meta">&gt;&gt;&gt; </span>model_name = <span class="hljs-string">&quot;nlptown/bert-base-multilingual-uncased-sentiment&quot;</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>pt_model = AutoModelForSequenceClassification.from_pretrained(model_name)`}}),S=new Mn({props:{$$slots:{default:[f_]},$$scope:{ctx:F}}}),le=new O({props:{code:"pt_outputs = pt_model(**pt_batch)",highlighted:'<span class="hljs-meta">&gt;&gt;&gt; </span>pt_outputs = pt_model(**pt_batch)'}}),L=new O({props:{code:`from torch import nn

pt_predictions = nn.functional.softmax(pt_outputs.logits, dim=-1)
print(pt_predictions)`,highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> torch <span class="hljs-keyword">import</span> nn

<span class="hljs-meta">&gt;&gt;&gt; </span>pt_predictions = nn.functional.softmax(pt_outputs.logits, dim=-<span class="hljs-number">1</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-built_in">print</span>(pt_predictions)
tensor([[<span class="hljs-number">0.0021</span>, <span class="hljs-number">0.0018</span>, <span class="hljs-number">0.0115</span>, <span class="hljs-number">0.2121</span>, <span class="hljs-number">0.7725</span>],
        [<span class="hljs-number">0.2084</span>, <span class="hljs-number">0.1826</span>, <span class="hljs-number">0.1969</span>, <span class="hljs-number">0.1755</span>, <span class="hljs-number">0.2365</span>]], grad_fn=&lt;SoftmaxBackward0&gt;)`}}),{c(){o=l("p"),u=s("\u{1F917} Transformers provides a simple and unified way to load pretrained instances. This means you can load an "),n=l("a"),g=s("AutoModel"),_=s(" like you would load an "),v=l("a"),z=s("AutoTokenizer"),M=s(". The only difference is selecting the correct "),$=l("a"),j=s("AutoModel"),D=s(" for the task. For text (or sequence) classification, you should load "),I=l("a"),N=s("AutoModelForSequenceClassification"),H=s(":"),q=f(),k(P.$$.fragment),A=f(),k(S.$$.fragment),U=f(),R=l("p"),V=s("Now pass your preprocessed batch of inputs directly to the model. You just have to unpack the dictionary by adding "),pe=l("code"),ne=s("**"),he=s(":"),K=f(),k(le.$$.fragment),ie=f(),B=l("p"),$e=s("The model outputs the final activations in the "),J=l("code"),Te=s("logits"),_e=s(" attribute. Apply the softmax function to the "),Q=l("code"),se=s("logits"),Z=s(" to retrieve the probabilities:"),x=f(),k(L.$$.fragment),this.h()},l(C){o=i(C,"P",{});var W=p(o);u=r(W,"\u{1F917} Transformers provides a simple and unified way to load pretrained instances. This means you can load an "),n=i(W,"A",{href:!0});var ve=p(n);g=r(ve,"AutoModel"),ve.forEach(a),_=r(W," like you would load an "),v=i(W,"A",{href:!0});var He=p(v);z=r(He,"AutoTokenizer"),He.forEach(a),M=r(W,". The only difference is selecting the correct "),$=i(W,"A",{href:!0});var ae=p($);j=r(ae,"AutoModel"),ae.forEach(a),D=r(W," for the task. For text (or sequence) classification, you should load "),I=i(W,"A",{href:!0});var Re=p(I);N=r(Re,"AutoModelForSequenceClassification"),Re.forEach(a),H=r(W,":"),W.forEach(a),q=c(C),w(P.$$.fragment,C),A=c(C),w(S.$$.fragment,C),U=c(C),R=i(C,"P",{});var ee=p(R);V=r(ee,"Now pass your preprocessed batch of inputs directly to the model. You just have to unpack the dictionary by adding "),pe=i(ee,"CODE",{});var vs=p(pe);ne=r(vs,"**"),vs.forEach(a),he=r(ee,":"),ee.forEach(a),K=c(C),w(le.$$.fragment,C),ie=c(C),B=i(C,"P",{});var ge=p(B);$e=r(ge,"The model outputs the final activations in the "),J=i(ge,"CODE",{});var ks=p(J);Te=r(ks,"logits"),ks.forEach(a),_e=r(ge," attribute. Apply the softmax function to the "),Q=i(ge,"CODE",{});var ws=p(Q);se=r(ws,"logits"),ws.forEach(a),Z=r(ge," to retrieve the probabilities:"),ge.forEach(a),x=c(C),w(L.$$.fragment,C),this.h()},h(){h(n,"href","/docs/transformers/main/en/model_doc/auto#transformers.AutoModel"),h(v,"href","/docs/transformers/main/en/model_doc/auto#transformers.AutoTokenizer"),h($,"href","/docs/transformers/main/en/model_doc/auto#transformers.AutoModel"),h(I,"href","/docs/transformers/main/en/model_doc/auto#transformers.AutoModelForSequenceClassification")},m(C,W){d(C,o,W),e(o,u),e(o,n),e(n,g),e(o,_),e(o,v),e(v,z),e(o,M),e(o,$),e($,j),e(o,D),e(o,I),e(I,N),e(o,H),d(C,q,W),y(P,C,W),d(C,A,W),y(S,C,W),d(C,U,W),d(C,R,W),e(R,V),e(R,pe),e(pe,ne),e(R,he),d(C,K,W),y(le,C,W),d(C,ie,W),d(C,B,W),e(B,$e),e(B,J),e(J,Te),e(B,_e),e(B,Q),e(Q,se),e(B,Z),d(C,x,W),y(L,C,W),X=!0},p(C,W){const ve={};W&2&&(ve.$$scope={dirty:W,ctx:C}),S.$set(ve)},i(C){X||(b(P.$$.fragment,C),b(S.$$.fragment,C),b(le.$$.fragment,C),b(L.$$.fragment,C),X=!0)},o(C){T(P.$$.fragment,C),T(S.$$.fragment,C),T(le.$$.fragment,C),T(L.$$.fragment,C),X=!1},d(C){C&&a(o),C&&a(q),E(P,C),C&&a(A),E(S,C),C&&a(U),C&&a(R),C&&a(K),E(le,C),C&&a(ie),C&&a(B),C&&a(x),E(L,C)}}}function m_(F){let o,u;return o=new ue({props:{$$slots:{default:[c_]},$$scope:{ctx:F}}}),{c(){k(o.$$.fragment)},l(n){w(o.$$.fragment,n)},m(n,g){y(o,n,g),u=!0},p(n,g){const _={};g&2&&(_.$$scope={dirty:g,ctx:n}),o.$set(_)},i(n){u||(b(o.$$.fragment,n),u=!0)},o(n){T(o.$$.fragment,n),u=!1},d(n){E(o,n)}}}function d_(F){let o,u,n,g,_,v,z,M;return{c(){o=l("p"),u=s("See the "),n=l("a"),g=s("task summary"),_=s(" for tasks supported by an "),v=l("a"),z=s("AutoModel"),M=s(" class."),this.h()},l($){o=i($,"P",{});var j=p(o);u=r(j,"See the "),n=i(j,"A",{href:!0});var D=p(n);g=r(D,"task summary"),D.forEach(a),_=r(j," for tasks supported by an "),v=i(j,"A",{href:!0});var I=p(v);z=r(I,"AutoModel"),I.forEach(a),M=r(j," class."),j.forEach(a),this.h()},h(){h(n,"href","./task_summary"),h(v,"href","/docs/transformers/main/en/model_doc/auto#transformers.AutoModel")},m($,j){d($,o,j),e(o,u),e(o,n),e(n,g),e(o,_),e(o,v),e(v,z),e(o,M)},d($){$&&a(o)}}}function u_(F){let o,u,n,g,_,v,z,M,$,j,D,I,N,H,q,P,A,S,U,R,V,pe,ne,he,K,le,ie,B,$e,J,Te,_e,Q,se,Z;return P=new O({props:{code:`from transformers import TFAutoModelForSequenceClassification

model_name = "nlptown/bert-base-multilingual-uncased-sentiment"
tf_model = TFAutoModelForSequenceClassification.from_pretrained(model_name)`,highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> TFAutoModelForSequenceClassification

<span class="hljs-meta">&gt;&gt;&gt; </span>model_name = <span class="hljs-string">&quot;nlptown/bert-base-multilingual-uncased-sentiment&quot;</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>tf_model = TFAutoModelForSequenceClassification.from_pretrained(model_name)`}}),S=new Mn({props:{$$slots:{default:[d_]},$$scope:{ctx:F}}}),ne=new O({props:{code:"tf_outputs = tf_model(tf_batch)",highlighted:'<span class="hljs-meta">&gt;&gt;&gt; </span>tf_outputs = tf_model(tf_batch)'}}),se=new O({props:{code:`import tensorflow as tf

tf_predictions = tf.nn.softmax(tf_outputs.logits, axis=-1)
tf_predictions`,highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">import</span> tensorflow <span class="hljs-keyword">as</span> tf

<span class="hljs-meta">&gt;&gt;&gt; </span>tf_predictions = tf.nn.softmax(tf_outputs.logits, axis=-<span class="hljs-number">1</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>tf_predictions`}}),{c(){o=l("p"),u=s("\u{1F917} Transformers provides a simple and unified way to load pretrained instances. This means you can load an "),n=l("a"),g=s("TFAutoModel"),_=s(" like you would load an "),v=l("a"),z=s("AutoTokenizer"),M=s(". The only difference is selecting the correct "),$=l("a"),j=s("TFAutoModel"),D=s(" for the task. For text (or sequence) classification, you should load "),I=l("a"),N=s("TFAutoModelForSequenceClassification"),H=s(":"),q=f(),k(P.$$.fragment),A=f(),k(S.$$.fragment),U=f(),R=l("p"),V=s("Now pass your preprocessed batch of inputs directly to the model by passing the dictionary keys directly to the tensors:"),pe=f(),k(ne.$$.fragment),he=f(),K=l("p"),le=s("The model outputs the final activations in the "),ie=l("code"),B=s("logits"),$e=s(" attribute. Apply the softmax function to the "),J=l("code"),Te=s("logits"),_e=s(" to retrieve the probabilities:"),Q=f(),k(se.$$.fragment),this.h()},l(x){o=i(x,"P",{});var L=p(o);u=r(L,"\u{1F917} Transformers provides a simple and unified way to load pretrained instances. This means you can load an "),n=i(L,"A",{href:!0});var X=p(n);g=r(X,"TFAutoModel"),X.forEach(a),_=r(L," like you would load an "),v=i(L,"A",{href:!0});var C=p(v);z=r(C,"AutoTokenizer"),C.forEach(a),M=r(L,". The only difference is selecting the correct "),$=i(L,"A",{href:!0});var W=p($);j=r(W,"TFAutoModel"),W.forEach(a),D=r(L," for the task. For text (or sequence) classification, you should load "),I=i(L,"A",{href:!0});var ve=p(I);N=r(ve,"TFAutoModelForSequenceClassification"),ve.forEach(a),H=r(L,":"),L.forEach(a),q=c(x),w(P.$$.fragment,x),A=c(x),w(S.$$.fragment,x),U=c(x),R=i(x,"P",{});var He=p(R);V=r(He,"Now pass your preprocessed batch of inputs directly to the model by passing the dictionary keys directly to the tensors:"),He.forEach(a),pe=c(x),w(ne.$$.fragment,x),he=c(x),K=i(x,"P",{});var ae=p(K);le=r(ae,"The model outputs the final activations in the "),ie=i(ae,"CODE",{});var Re=p(ie);B=r(Re,"logits"),Re.forEach(a),$e=r(ae," attribute. Apply the softmax function to the "),J=i(ae,"CODE",{});var ee=p(J);Te=r(ee,"logits"),ee.forEach(a),_e=r(ae," to retrieve the probabilities:"),ae.forEach(a),Q=c(x),w(se.$$.fragment,x),this.h()},h(){h(n,"href","/docs/transformers/main/en/model_doc/auto#transformers.TFAutoModel"),h(v,"href","/docs/transformers/main/en/model_doc/auto#transformers.AutoTokenizer"),h($,"href","/docs/transformers/main/en/model_doc/auto#transformers.TFAutoModel"),h(I,"href","/docs/transformers/main/en/model_doc/auto#transformers.TFAutoModelForSequenceClassification")},m(x,L){d(x,o,L),e(o,u),e(o,n),e(n,g),e(o,_),e(o,v),e(v,z),e(o,M),e(o,$),e($,j),e(o,D),e(o,I),e(I,N),e(o,H),d(x,q,L),y(P,x,L),d(x,A,L),y(S,x,L),d(x,U,L),d(x,R,L),e(R,V),d(x,pe,L),y(ne,x,L),d(x,he,L),d(x,K,L),e(K,le),e(K,ie),e(ie,B),e(K,$e),e(K,J),e(J,Te),e(K,_e),d(x,Q,L),y(se,x,L),Z=!0},p(x,L){const X={};L&2&&(X.$$scope={dirty:L,ctx:x}),S.$set(X)},i(x){Z||(b(P.$$.fragment,x),b(S.$$.fragment,x),b(ne.$$.fragment,x),b(se.$$.fragment,x),Z=!0)},o(x){T(P.$$.fragment,x),T(S.$$.fragment,x),T(ne.$$.fragment,x),T(se.$$.fragment,x),Z=!1},d(x){x&&a(o),x&&a(q),E(P,x),x&&a(A),E(S,x),x&&a(U),x&&a(R),x&&a(pe),E(ne,x),x&&a(he),x&&a(K),x&&a(Q),E(se,x)}}}function h_(F){let o,u;return o=new ue({props:{$$slots:{default:[u_]},$$scope:{ctx:F}}}),{c(){k(o.$$.fragment)},l(n){w(o.$$.fragment,n)},m(n,g){y(o,n,g),u=!0},p(n,g){const _={};g&2&&(_.$$scope={dirty:g,ctx:n}),o.$set(_)},i(n){u||(b(o.$$.fragment,n),u=!0)},o(n){T(o.$$.fragment,n),u=!1},d(n){E(o,n)}}}function g_(F){let o,u,n,g,_;return{c(){o=l("p"),u=s("All \u{1F917} Transformers models (PyTorch or TensorFlow) output the tensors "),n=l("em"),g=s("before"),_=s(` the final activation
function (like softmax) because the final activation function is often fused with the loss. Model outputs are special dataclasses so their attributes are autocompleted in an IDE. The model outputs behave like a tuple or a dictionary (you can index with an integer, a slice or a string) in which case, attributes that are None are ignored.`)},l(v){o=i(v,"P",{});var z=p(o);u=r(z,"All \u{1F917} Transformers models (PyTorch or TensorFlow) output the tensors "),n=i(z,"EM",{});var M=p(n);g=r(M,"before"),M.forEach(a),_=r(z,` the final activation
function (like softmax) because the final activation function is often fused with the loss. Model outputs are special dataclasses so their attributes are autocompleted in an IDE. The model outputs behave like a tuple or a dictionary (you can index with an integer, a slice or a string) in which case, attributes that are None are ignored.`),z.forEach(a)},m(v,z){d(v,o,z),e(o,u),e(o,n),e(n,g),e(o,_)},d(v){v&&a(o)}}}function $_(F){let o,u,n,g,_,v,z,M,$,j,D,I,N,H,q,P;return z=new O({props:{code:`pt_save_directory = "./pt_save_pretrained"
tokenizer.save_pretrained(pt_save_directory)
pt_model.save_pretrained(pt_save_directory)`,highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span>pt_save_directory = <span class="hljs-string">&quot;./pt_save_pretrained&quot;</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>tokenizer.save_pretrained(pt_save_directory)
<span class="hljs-meta">&gt;&gt;&gt; </span>pt_model.save_pretrained(pt_save_directory)`}}),q=new O({props:{code:'pt_model = AutoModelForSequenceClassification.from_pretrained("./pt_save_pretrained")',highlighted:'<span class="hljs-meta">&gt;&gt;&gt; </span>pt_model = AutoModelForSequenceClassification.from_pretrained(<span class="hljs-string">&quot;./pt_save_pretrained&quot;</span>)'}}),{c(){o=l("p"),u=s("Once your model is fine-tuned, you can save it with its tokenizer using "),n=l("a"),g=s("PreTrainedModel.save_pretrained()"),_=s(":"),v=f(),k(z.$$.fragment),M=f(),$=l("p"),j=s("When you are ready to use the model again, reload it with "),D=l("a"),I=s("PreTrainedModel.from_pretrained()"),N=s(":"),H=f(),k(q.$$.fragment),this.h()},l(A){o=i(A,"P",{});var S=p(o);u=r(S,"Once your model is fine-tuned, you can save it with its tokenizer using "),n=i(S,"A",{href:!0});var U=p(n);g=r(U,"PreTrainedModel.save_pretrained()"),U.forEach(a),_=r(S,":"),S.forEach(a),v=c(A),w(z.$$.fragment,A),M=c(A),$=i(A,"P",{});var R=p($);j=r(R,"When you are ready to use the model again, reload it with "),D=i(R,"A",{href:!0});var V=p(D);I=r(V,"PreTrainedModel.from_pretrained()"),V.forEach(a),N=r(R,":"),R.forEach(a),H=c(A),w(q.$$.fragment,A),this.h()},h(){h(n,"href","/docs/transformers/main/en/main_classes/model#transformers.PreTrainedModel.save_pretrained"),h(D,"href","/docs/transformers/main/en/main_classes/model#transformers.PreTrainedModel.from_pretrained")},m(A,S){d(A,o,S),e(o,u),e(o,n),e(n,g),e(o,_),d(A,v,S),y(z,A,S),d(A,M,S),d(A,$,S),e($,j),e($,D),e(D,I),e($,N),d(A,H,S),y(q,A,S),P=!0},p:be,i(A){P||(b(z.$$.fragment,A),b(q.$$.fragment,A),P=!0)},o(A){T(z.$$.fragment,A),T(q.$$.fragment,A),P=!1},d(A){A&&a(o),A&&a(v),E(z,A),A&&a(M),A&&a($),A&&a(H),E(q,A)}}}function __(F){let o,u;return o=new ue({props:{$$slots:{default:[$_]},$$scope:{ctx:F}}}),{c(){k(o.$$.fragment)},l(n){w(o.$$.fragment,n)},m(n,g){y(o,n,g),u=!0},p(n,g){const _={};g&2&&(_.$$scope={dirty:g,ctx:n}),o.$set(_)},i(n){u||(b(o.$$.fragment,n),u=!0)},o(n){T(o.$$.fragment,n),u=!1},d(n){E(o,n)}}}function v_(F){let o,u,n,g,_,v,z,M,$,j,D,I,N,H,q,P;return z=new O({props:{code:`tf_save_directory = "./tf_save_pretrained"
tokenizer.save_pretrained(tf_save_directory)
tf_model.save_pretrained(tf_save_directory)`,highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span>tf_save_directory = <span class="hljs-string">&quot;./tf_save_pretrained&quot;</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>tokenizer.save_pretrained(tf_save_directory)
<span class="hljs-meta">&gt;&gt;&gt; </span>tf_model.save_pretrained(tf_save_directory)`}}),q=new O({props:{code:'tf_model = TFAutoModelForSequenceClassification.from_pretrained("./tf_save_pretrained")',highlighted:'<span class="hljs-meta">&gt;&gt;&gt; </span>tf_model = TFAutoModelForSequenceClassification.from_pretrained(<span class="hljs-string">&quot;./tf_save_pretrained&quot;</span>)'}}),{c(){o=l("p"),u=s("Once your model is fine-tuned, you can save it with its tokenizer using "),n=l("a"),g=s("TFPreTrainedModel.save_pretrained()"),_=s(":"),v=f(),k(z.$$.fragment),M=f(),$=l("p"),j=s("When you are ready to use the model again, reload it with "),D=l("a"),I=s("TFPreTrainedModel.from_pretrained()"),N=s(":"),H=f(),k(q.$$.fragment),this.h()},l(A){o=i(A,"P",{});var S=p(o);u=r(S,"Once your model is fine-tuned, you can save it with its tokenizer using "),n=i(S,"A",{href:!0});var U=p(n);g=r(U,"TFPreTrainedModel.save_pretrained()"),U.forEach(a),_=r(S,":"),S.forEach(a),v=c(A),w(z.$$.fragment,A),M=c(A),$=i(A,"P",{});var R=p($);j=r(R,"When you are ready to use the model again, reload it with "),D=i(R,"A",{href:!0});var V=p(D);I=r(V,"TFPreTrainedModel.from_pretrained()"),V.forEach(a),N=r(R,":"),R.forEach(a),H=c(A),w(q.$$.fragment,A),this.h()},h(){h(n,"href","/docs/transformers/main/en/main_classes/model#transformers.TFPreTrainedModel.save_pretrained"),h(D,"href","/docs/transformers/main/en/main_classes/model#transformers.TFPreTrainedModel.from_pretrained")},m(A,S){d(A,o,S),e(o,u),e(o,n),e(n,g),e(o,_),d(A,v,S),y(z,A,S),d(A,M,S),d(A,$,S),e($,j),e($,D),e(D,I),e($,N),d(A,H,S),y(q,A,S),P=!0},p:be,i(A){P||(b(z.$$.fragment,A),b(q.$$.fragment,A),P=!0)},o(A){T(z.$$.fragment,A),T(q.$$.fragment,A),P=!1},d(A){A&&a(o),A&&a(v),E(z,A),A&&a(M),A&&a($),A&&a(H),E(q,A)}}}function k_(F){let o,u;return o=new ue({props:{$$slots:{default:[v_]},$$scope:{ctx:F}}}),{c(){k(o.$$.fragment)},l(n){w(o.$$.fragment,n)},m(n,g){y(o,n,g),u=!0},p(n,g){const _={};g&2&&(_.$$scope={dirty:g,ctx:n}),o.$set(_)},i(n){u||(b(o.$$.fragment,n),u=!0)},o(n){T(o.$$.fragment,n),u=!1},d(n){E(o,n)}}}function w_(F){let o,u;return o=new O({props:{code:`from transformers import AutoModel

tokenizer = AutoTokenizer.from_pretrained(tf_save_directory)
pt_model = AutoModelForSequenceClassification.from_pretrained(tf_save_directory, from_tf=True)`,highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoModel

<span class="hljs-meta">&gt;&gt;&gt; </span>tokenizer = AutoTokenizer.from_pretrained(tf_save_directory)
<span class="hljs-meta">&gt;&gt;&gt; </span>pt_model = AutoModelForSequenceClassification.from_pretrained(tf_save_directory, from_tf=<span class="hljs-literal">True</span>)`}}),{c(){k(o.$$.fragment)},l(n){w(o.$$.fragment,n)},m(n,g){y(o,n,g),u=!0},p:be,i(n){u||(b(o.$$.fragment,n),u=!0)},o(n){T(o.$$.fragment,n),u=!1},d(n){E(o,n)}}}function y_(F){let o,u;return o=new ue({props:{$$slots:{default:[w_]},$$scope:{ctx:F}}}),{c(){k(o.$$.fragment)},l(n){w(o.$$.fragment,n)},m(n,g){y(o,n,g),u=!0},p(n,g){const _={};g&2&&(_.$$scope={dirty:g,ctx:n}),o.$set(_)},i(n){u||(b(o.$$.fragment,n),u=!0)},o(n){T(o.$$.fragment,n),u=!1},d(n){E(o,n)}}}function b_(F){let o,u;return o=new O({props:{code:`from transformers import TFAutoModel

tokenizer = AutoTokenizer.from_pretrained(pt_save_directory)
tf_model = TFAutoModelForSequenceClassification.from_pretrained(pt_save_directory, from_pt=True)`,highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> TFAutoModel

<span class="hljs-meta">&gt;&gt;&gt; </span>tokenizer = AutoTokenizer.from_pretrained(pt_save_directory)
<span class="hljs-meta">&gt;&gt;&gt; </span>tf_model = TFAutoModelForSequenceClassification.from_pretrained(pt_save_directory, from_pt=<span class="hljs-literal">True</span>)`}}),{c(){k(o.$$.fragment)},l(n){w(o.$$.fragment,n)},m(n,g){y(o,n,g),u=!0},p:be,i(n){u||(b(o.$$.fragment,n),u=!0)},o(n){T(o.$$.fragment,n),u=!1},d(n){E(o,n)}}}function T_(F){let o,u;return o=new ue({props:{$$slots:{default:[b_]},$$scope:{ctx:F}}}),{c(){k(o.$$.fragment)},l(n){w(o.$$.fragment,n)},m(n,g){y(o,n,g),u=!0},p(n,g){const _={};g&2&&(_.$$scope={dirty:g,ctx:n}),o.$set(_)},i(n){u||(b(o.$$.fragment,n),u=!0)},o(n){T(o.$$.fragment,n),u=!1},d(n){E(o,n)}}}function E_(F){let o,u,n,g,_,v,z,M;return z=new O({props:{code:`from transformers import AutoModel

my_model = AutoModel.from_config(my_config)`,highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoModel

<span class="hljs-meta">&gt;&gt;&gt; </span>my_model = AutoModel.from_config(my_config)`}}),{c(){o=l("p"),u=s("Create a model from your custom configuration with "),n=l("a"),g=s("AutoModel.from_config()"),_=s(":"),v=f(),k(z.$$.fragment),this.h()},l($){o=i($,"P",{});var j=p(o);u=r(j,"Create a model from your custom configuration with "),n=i(j,"A",{href:!0});var D=p(n);g=r(D,"AutoModel.from_config()"),D.forEach(a),_=r(j,":"),j.forEach(a),v=c($),w(z.$$.fragment,$),this.h()},h(){h(n,"href","/docs/transformers/main/en/model_doc/auto#transformers.FlaxAutoModelForVision2Seq.from_config")},m($,j){d($,o,j),e(o,u),e(o,n),e(n,g),e(o,_),d($,v,j),y(z,$,j),M=!0},p:be,i($){M||(b(z.$$.fragment,$),M=!0)},o($){T(z.$$.fragment,$),M=!1},d($){$&&a(o),$&&a(v),E(z,$)}}}function A_(F){let o,u;return o=new ue({props:{$$slots:{default:[E_]},$$scope:{ctx:F}}}),{c(){k(o.$$.fragment)},l(n){w(o.$$.fragment,n)},m(n,g){y(o,n,g),u=!0},p(n,g){const _={};g&2&&(_.$$scope={dirty:g,ctx:n}),o.$set(_)},i(n){u||(b(o.$$.fragment,n),u=!0)},o(n){T(o.$$.fragment,n),u=!1},d(n){E(o,n)}}}function j_(F){let o,u,n,g,_,v,z,M;return z=new O({props:{code:`from transformers import TFAutoModel

my_model = TFAutoModel.from_config(my_config)`,highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> TFAutoModel

<span class="hljs-meta">&gt;&gt;&gt; </span>my_model = TFAutoModel.from_config(my_config)`}}),{c(){o=l("p"),u=s("Create a model from your custom configuration with "),n=l("a"),g=s("TFAutoModel.from_config()"),_=s(":"),v=f(),k(z.$$.fragment),this.h()},l($){o=i($,"P",{});var j=p(o);u=r(j,"Create a model from your custom configuration with "),n=i(j,"A",{href:!0});var D=p(n);g=r(D,"TFAutoModel.from_config()"),D.forEach(a),_=r(j,":"),j.forEach(a),v=c($),w(z.$$.fragment,$),this.h()},h(){h(n,"href","/docs/transformers/main/en/model_doc/auto#transformers.FlaxAutoModelForVision2Seq.from_config")},m($,j){d($,o,j),e(o,u),e(o,n),e(n,g),e(o,_),d($,v,j),y(z,$,j),M=!0},p:be,i($){M||(b(z.$$.fragment,$),M=!0)},o($){T(z.$$.fragment,$),M=!1},d($){$&&a(o),$&&a(v),E(z,$)}}}function z_(F){let o,u;return o=new ue({props:{$$slots:{default:[j_]},$$scope:{ctx:F}}}),{c(){k(o.$$.fragment)},l(n){w(o.$$.fragment,n)},m(n,g){y(o,n,g),u=!0},p(n,g){const _={};g&2&&(_.$$scope={dirty:g,ctx:n}),o.$set(_)},i(n){u||(b(o.$$.fragment,n),u=!0)},o(n){T(o.$$.fragment,n),u=!1},d(n){E(o,n)}}}function q_(F){let o,u,n,g,_,v,z,M;return{c(){o=l("p"),u=s("For tasks - like translation or summarization - that use a sequence-to-sequence model, use the "),n=l("a"),g=s("Seq2SeqTrainer"),_=s(" and "),v=l("a"),z=s("Seq2SeqTrainingArguments"),M=s(" classes instead."),this.h()},l($){o=i($,"P",{});var j=p(o);u=r(j,"For tasks - like translation or summarization - that use a sequence-to-sequence model, use the "),n=i(j,"A",{href:!0});var D=p(n);g=r(D,"Seq2SeqTrainer"),D.forEach(a),_=r(j," and "),v=i(j,"A",{href:!0});var I=p(v);z=r(I,"Seq2SeqTrainingArguments"),I.forEach(a),M=r(j," classes instead."),j.forEach(a),this.h()},h(){h(n,"href","/docs/transformers/main/en/main_classes/trainer#transformers.Seq2SeqTrainer"),h(v,"href","/docs/transformers/main/en/main_classes/trainer#transformers.Seq2SeqTrainingArguments")},m($,j){d($,o,j),e(o,u),e(o,n),e(n,g),e(o,_),e(o,v),e(v,z),e(o,M)},d($){$&&a(o)}}}function P_(F){let o,u,n,g,_,v,z,M,$,j,D,I,N,H,q,P,A,S,U,R,V,pe,ne,he,K,le,ie,B,$e,J,Te,_e,Q,se,Z,x,L,X,C,W,ve,He,ae,Re,ee,vs,ge,ks,ws,ys,qi,Pi,Cn,ht,Pr,Ee,xr,Fr,xi,Fi,Mr,Cr,Mi,Ci,Sr,Dr,Si,Di,Ir,Nr,Ii,Ni,Y,Ae,Or,Oi,Li,Lr,W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hu,ur,gu,$u,_u,ds,vu,us,dt,ku,wn,wu,yu,yn,bu,Tu,Eu,hs,Ul,ut,Ut,bn,gs,Au,Tn,ju,Gl,hr,zu,Kl;return v=new We({}),D=new Q$({props:{classNames:"absolute z-10 right-0 top-0",options:[{label:"Mixed",value:"https://colab.research.google.com/github/huggingface/notebooks/blob/main/transformers_doc/en/quicktour.ipynb"},{label:"PyTorch",value:"https://colab.research.google.com/github/huggingface/notebooks/blob/main/transformers_doc/en/pytorch/quicktour.ipynb"},{label:"TensorFlow",value:"https://colab.research.google.com/github/huggingface/notebooks/blob/main/transformers_doc/en/tensorflow/quicktour.ipynb"},{label:"Mixed",value:"https://studiolab.sagemaker.aws/import/github/huggingface/notebooks/blob/main/transformers_doc/en/quicktour.ipynb"},{label:"PyTorch",value:"https://studiolab.sagemaker.aws/import/github/huggingface/notebooks/blob/main/transformers_doc/en/pytorch/quicktour.ipynb"},{label:"TensorFlow",value:"https://studiolab.sagemaker.aws/import/github/huggingface/notebooks/blob/main/transformers_doc/en/tensorflow/quicktour.ipynb"}]}}),B=new O({props:{code:"!pip install transformers datasets",highlighted:"!pip install transformers datasets"}}),Q=new _s({props:{pytorch:!0,tensorflow:!0,jax:!1,$$slots:{tensorflow:[e_],pytorch:[Z$]},$$scope:{ctx:F}}}),X=new We({}),ae=new Y$({props:{id:"tiZFewofSLM"}}),ia=new O({props:{code:`from transformers import pipeline

classifier = pipeline("sentiment-analysis")`,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(<span class="hljs-string">&quot;sentiment-analysis&quot;</span>)`}}),fa=new O({props:{code:'classifier("We are very happy to show you the \u{1F917} Transformers library.")',highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span>classifier(<span class="hljs-string">&quot;We are very happy to show you the \u{1F917} Transformers library.&quot;</span>)
[{<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.9998</span>}]`}}),ca=new O({props:{code:`results = classifier(["We are very happy to show you the \u{1F917} Transformers library.", "We hope you don't hate it."])
for result in results:
    print(f"label: {result['label']}, with score: {round(result['score'], 4)}")`,highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span>results = classifier([<span class="hljs-string">&quot;We are very happy to show you the \u{1F917} Transformers library.&quot;</span>, <span class="hljs-string">&quot;We hope you don&#x27;t hate it.&quot;</span>])
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">for</span> result <span class="hljs-keyword">in</span> results:
<span class="hljs-meta">... </span>    <span class="hljs-built_in">print</span>(<span class="hljs-string">f&quot;label: <span class="hljs-subst">{result[<span class="hljs-string">&#x27;label&#x27;</span>]}</span>, with score: <span class="hljs-subst">{<span class="hljs-built_in">round</span>(result[<span class="hljs-string">&#x27;score&#x27;</span>], <span class="hljs-number">4</span>)}</span>&quot;</span>)
label: POSITIVE, <span class="hljs-keyword">with</span> score: <span class="hljs-number">0.9998</span>
label: NEGATIVE, <span class="hljs-keyword">with</span> score: <span class="hljs-number">0.5309</span>`}}),ma=new O({props:{code:`import torch
from transformers import pipeline

speech_recognizer = pipeline("automatic-speech-recognition", model="facebook/wav2vec2-base-960h")`,highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">import</span> torch
<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>speech_recognizer = pipeline(<span class="hljs-string">&quot;automatic-speech-recognition&quot;</span>, model=<span class="hljs-string">&quot;facebook/wav2vec2-base-960h&quot;</span>)`}}),ha=new O({props:{code:`from datasets import load_dataset, Audio

dataset = load_dataset("PolyAI/minds14", name="en-US", split="train")`,highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> datasets <span class="hljs-keyword">import</span> load_dataset, Audio

<span class="hljs-meta">&gt;&gt;&gt; </span>dataset = load_dataset(<span class="hljs-string">&quot;PolyAI/minds14&quot;</span>, name=<span class="hljs-string">&quot;en-US&quot;</span>, split=<span class="hljs-string">&quot;train&quot;</span>)`}}),$a=new O({props:{code:'dataset = dataset.cast_column("audio", Audio(sampling_rate=speech_recognizer.feature_extractor.sampling_rate))',highlighted:'<span class="hljs-meta">&gt;&gt;&gt; </span>dataset = dataset.cast_column(<span class="hljs-string">&quot;audio&quot;</span>, Audio(sampling_rate=speech_recognizer.feature_extractor.sampling_rate))'}}),_a=new O({props:{code:`result = speech_recognizer(dataset[:4]["audio"])
print([d["text"] for d in result])`,highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span>result = speech_recognizer(dataset[:<span class="hljs-number">4</span>][<span class="hljs-string">&quot;audio&quot;</span>])
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-built_in">print</span>([d[<span class="hljs-string">&quot;text&quot;</span>] <span class="hljs-keyword">for</span> d <span class="hljs-keyword">in</span> result])
[<span class="hljs-string">&#x27;I WOULD LIKE TO SET UP A JOINT ACCOUNT WITH MY PARTNER HOW DO I PROCEED WITH DOING THAT&#x27;</span>, <span class="hljs-string">&quot;FODING HOW I&#x27;D SET UP A JOIN TO HET WITH MY WIFE AND WHERE THE AP MIGHT BE&quot;</span>, <span class="hljs-string">&quot;I I&#x27;D LIKE TOY SET UP A JOINT ACCOUNT WITH MY PARTNER I&#x27;M NOT SEEING THE OPTION TO DO IT ON THE AP SO I CALLED IN TO GET SOME HELP CAN I JUST DO IT OVER THE PHONE WITH YOU AND GIVE YOU THE INFORMATION OR SHOULD I DO IT IN THE AP AND I&#x27;M MISSING SOMETHING UQUETTE HAD PREFERRED TO JUST DO IT OVER THE PHONE OF POSSIBLE THINGS&quot;</span>, <span class="hljs-string">&#x27;HOW DO I THURN A JOIN A COUNT&#x27;</span>]`}}),va=new We({}),ya=new O({props:{code:'model_name = "nlptown/bert-base-multilingual-uncased-sentiment"',highlighted:'<span class="hljs-meta">&gt;&gt;&gt; </span>model_name = <span class="hljs-string">&quot;nlptown/bert-base-multilingual-uncased-sentiment&quot;</span>'}}),yt=new _s({props:{pytorch:!0,tensorflow:!0,jax:!1,$$slots:{tensorflow:[r_],pytorch:[a_]},$$scope:{ctx:F}}}),ba=new O({props:{code:`classifier = pipeline("sentiment-analysis", model=model, tokenizer=tokenizer)
classifier("Nous sommes tr\xE8s heureux de vous pr\xE9senter la biblioth\xE8que \u{1F917} Transformers.")`,highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span>classifier = pipeline(<span class="hljs-string">&quot;sentiment-analysis&quot;</span>, model=model, tokenizer=tokenizer)
<span class="hljs-meta">&gt;&gt;&gt; </span>classifier(<span class="hljs-string">&quot;Nous sommes tr\xE8s heureux de vous pr\xE9senter la biblioth\xE8que \u{1F917} Transformers.&quot;</span>)
[{<span class="hljs-string">&#x27;label&#x27;</span>: <span class="hljs-string">&#x27;5 stars&#x27;</span>, <span class="hljs-string">&#x27;score&#x27;</span>: <span class="hljs-number">0.7273</span>}]`}}),Ta=new We({}),Ea=new Y$({props:{id:"AhChOFRegn4"}}),Aa=new We({}),ja=new O({props:{code:`from transformers import AutoTokenizer

model_name = "nlptown/bert-base-multilingual-uncased-sentiment"
tokenizer = AutoTokenizer.from_pretrained(model_name)`,highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoTokenizer

<span class="hljs-meta">&gt;&gt;&gt; </span>model_name = <span class="hljs-string">&quot;nlptown/bert-base-multilingual-uncased-sentiment&quot;</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>tokenizer = AutoTokenizer.from_pretrained(model_name)`}}),za=new O({props:{code:`encoding = tokenizer("We are very happy to show you the \u{1F917} Transformers library.")
print(encoding)`,highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span>encoding = tokenizer(<span class="hljs-string">&quot;We are very happy to show you the \u{1F917} Transformers library.&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-built_in">print</span>(encoding)
{<span class="hljs-string">&#x27;input_ids&#x27;</span>: [<span class="hljs-number">101</span>, <span class="hljs-number">11312</span>, <span class="hljs-number">10320</span>, <span class="hljs-number">12495</span>, <span class="hljs-number">19308</span>, <span class="hljs-number">10114</span>, <span class="hljs-number">11391</span>, <span class="hljs-number">10855</span>, <span class="hljs-number">10103</span>, <span class="hljs-number">100</span>, <span class="hljs-number">58263</span>, <span class="hljs-number">13299</span>, <span class="hljs-number">119</span>, <span class="hljs-number">102</span>],
 <span class="hljs-string">&#x27;token_type_ids&#x27;</span>: [<span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>],
 <span class="hljs-string">&#x27;attention_mask&#x27;</span>: [<span class="hljs-number">1</span>, <span class="hljs-number">1</span>, <span class="hljs-number">1</span>, <span class="hljs-number">1</span>, <span class="hljs-number">1</span>, <span class="hljs-number">1</span>, <span class="hljs-number">1</span>, <span class="hljs-number">1</span>, <span class="hljs-number">1</span>, <span class="hljs-number">1</span>, <span class="hljs-number">1</span>, <span class="hljs-number">1</span>, <span class="hljs-number">1</span>, <span class="hljs-number">1</span>]}`}}),zt=new _s({props:{pytorch:!0,tensorflow:!0,jax:!1,$$slots:{tensorflow:[i_],pytorch:[n_]},$$scope:{ctx:F}}}),qt=new Mn({props:{$$slots:{default:[p_]},$$scope:{ctx:F}}}),qa=new We({}),xt=new _s({props:{pytorch:!0,tensorflow:!0,jax:!1,$$slots:{tensorflow:[h_],pytorch:[m_]},$$scope:{ctx:F}}}),Ft=new Mn({props:{$$slots:{default:[g_]},$$scope:{ctx:F}}}),Pa=new We({}),Ct=new _s({props:{pytorch:!0,tensorflow:!0,jax:!1,$$slots:{tensorflow:[k_],pytorch:[__]},$$scope:{ctx:F}}}),St=new _s({props:{pytorch:!0,tensorflow:!0,jax:!1,$$slots:{tensorflow:[T_],pytorch:[y_]},$$scope:{ctx:F}}}),xa=new We({}),Fa=new O({props:{code:`from transformers import AutoConfig

my_config = AutoConfig.from_pretrained("distilbert-base-uncased", n_heads=12)`,highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoConfig

<span class="hljs-meta">&gt;&gt;&gt; </span>my_config = AutoConfig.from_pretrained(<span class="hljs-string">&quot;distilbert-base-uncased&quot;</span>, n_heads=<span class="hljs-number">12</span>)`}}),It=new _s({props:{pytorch:!0,tensorflow:!0,jax:!1,$$slots:{tensorflow:[z_],pytorch:[A_]},$$scope:{ctx:F}}}),Ma=new We({}),Ia=new O({props:{code:`from transformers import AutoModelForSequenceClassification

model = AutoModelForSequenceClassification.from_pretrained("distilbert-base-uncased")`,highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoModelForSequenceClassification

<span class="hljs-meta">&gt;&gt;&gt; </span>model = AutoModelForSequenceClassification.from_pretrained(<span class="hljs-string">&quot;distilbert-base-uncased&quot;</span>)`}}),Oa=new O({props:{code:`from transformers import TrainingArguments

training_args = TrainingArguments(
    output_dir="path/to/save/folder/",
    learning_rate=2e-5,
    per_device_train_batch_size=8,
    per_device_eval_batch_size=8,
    num_train_epochs=2,
)`,highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> TrainingArguments

<span class="hljs-meta">&gt;&gt;&gt; </span>training_args = TrainingArguments(
<span class="hljs-meta">... </span>    output_dir=<span class="hljs-string">&quot;path/to/save/folder/&quot;</span>,
<span class="hljs-meta">... </span>    learning_rate=<span class="hljs-number">2e-5</span>,
<span class="hljs-meta">... </span>    per_device_train_batch_size=<span class="hljs-number">8</span>,
<span class="hljs-meta">... </span>    per_device_eval_batch_size=<span class="hljs-number">8</span>,
<span class="hljs-meta">... </span>    num_train_epochs=<span class="hljs-number">2</span>,
<span class="hljs-meta">... </span>)`}}),Wa=new O({props:{code:`from transformers import AutoTokenizer

tokenizer = AutoTokenizer.from_pretrained("distilbert-base-uncased")`,highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoTokenizer

<span class="hljs-meta">&gt;&gt;&gt; </span>tokenizer = AutoTokenizer.from_pretrained(<span class="hljs-string">&quot;distilbert-base-uncased&quot;</span>)`}}),Ra=new O({props:{code:`from datasets import load_dataset

dataset = load_dataset("rotten_tomatoes")  # doctest: +IGNORE_RESULT`,highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> datasets <span class="hljs-keyword">import</span> load_dataset

<span class="hljs-meta">&gt;&gt;&gt; </span>dataset = load_dataset(<span class="hljs-string">&quot;rotten_tomatoes&quot;</span>)  <span class="hljs-comment"># doctest: +IGNORE_RESULT</span>`}}),Ya=new O({props:{code:`def tokenize_dataset(dataset):
    return tokenizer(dataset["text"])`,highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">def</span> <span class="hljs-title function_">tokenize_dataset</span>(<span class="hljs-params">dataset</span>):
<span class="hljs-meta">... </span>    <span class="hljs-keyword">return</span> tokenizer(dataset[<span class="hljs-string">&quot;text&quot;</span>])`}}),Ka=new O({props:{code:"dataset = dataset.map(tokenize_dataset, batched=True)",highlighted:'<span class="hljs-meta">&gt;&gt;&gt; </span>dataset = dataset.<span class="hljs-built_in">map</span>(tokenize_dataset, batched=<span class="hljs-literal">True</span>)'}}),Qa=new O({props:{code:`from transformers import DataCollatorWithPadding

data_collator = DataCollatorWithPadding(tokenizer=tokenizer)`,highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> DataCollatorWithPadding

<span class="hljs-meta">&gt;&gt;&gt; </span>data_collator = DataCollatorWithPadding(tokenizer=tokenizer)`}}),Ja=new O({props:{code:`from transformers import Trainer

trainer = Trainer(
    model=model,
    args=training_args,
    train_dataset=dataset["train"],
    eval_dataset=dataset["test"],
    tokenizer=tokenizer,
    data_collator=data_collator,
)  # doctest: +SKIP`,highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> Trainer

<span class="hljs-meta">&gt;&gt;&gt; </span>trainer = Trainer(
<span class="hljs-meta">... </span>    model=model,
<span class="hljs-meta">... </span>    args=training_args,
<span class="hljs-meta">... </span>    train_dataset=dataset[<span class="hljs-string">&quot;train&quot;</span>],
<span class="hljs-meta">... </span>    eval_dataset=dataset[<span class="hljs-string">&quot;test&quot;</span>],
<span class="hljs-meta">... </span>    tokenizer=tokenizer,
<span class="hljs-meta">... </span>    data_collator=data_collator,
<span class="hljs-meta">... </span>)  <span class="hljs-comment"># doctest: +SKIP</span>`}}),Za=new O({props:{code:"trainer.train()",highlighted:'<span class="hljs-meta">&gt;&gt;&gt; </span>trainer.train()'}}),Rt=new Mn({props:{$$slots:{default:[q_]},$$scope:{ctx:F}}}),Xa=new We({}),ns=new O({props:{code:`from transformers import TFAutoModelForSequenceClassification

model = TFAutoModelForSequenceClassification.from_pretrained("distilbert-base-uncased")`,highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> TFAutoModelForSequenceClassification

<span class="hljs-meta">&gt;&gt;&gt; </span>model = TFAutoModelForSequenceClassification.from_pretrained(<span class="hljs-string">&quot;distilbert-base-uncased&quot;</span>)`}}),is=new O({props:{code:`from transformers import AutoTokenizer

tokenizer = AutoTokenizer.from_pretrained("distilbert-base-uncased")`,highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoTokenizer

<span class="hljs-meta">&gt;&gt;&gt; </span>tokenizer = AutoTokenizer.from_pretrained(<span class="hljs-string">&quot;distilbert-base-uncased&quot;</span>)`}}),fs=new O({props:{code:`def tokenize_dataset(dataset):
    return tokenizer(dataset["text"])  # doctest: +SKIP`,highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">def</span> <span class="hljs-title function_">tokenize_dataset</span>(<span class="hljs-params">dataset</span>):
<span class="hljs-meta">... </span>    <span class="hljs-keyword">return</span> tokenizer(dataset[<span class="hljs-string">&quot;text&quot;</span>])  <span class="hljs-comment"># doctest: +SKIP</span>`}}),ds=new O({props:{code:`dataset = dataset.map(tokenize_dataset)  # doctest: +SKIP
tf_dataset = model.prepare_tf_dataset(
    dataset, batch_size=16, shuffle=True, tokenizer=tokenizer
)  # doctest: +SKIP`,highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span>dataset = dataset.<span class="hljs-built_in">map</span>(tokenize_dataset)  <span class="hljs-comment"># doctest: +SKIP</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>tf_dataset = model.prepare_tf_dataset(
<span class="hljs-meta">... </span>    dataset, batch_size=<span class="hljs-number">16</span>, shuffle=<span class="hljs-literal">True</span>, tokenizer=tokenizer
<span class="hljs-meta">... </span>)  <span class="hljs-comment"># doctest: +SKIP</span>`}}),hs=new O({props:{code:`from tensorflow.keras.optimizers import Adam

model.compile(optimizer=Adam(3e-5))
model.fit(dataset)  # doctest: +SKIP`,highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> tensorflow.keras.optimizers <span class="hljs-keyword">import</span> Adam

<span class="hljs-meta">&gt;&gt;&gt; </span>model.<span class="hljs-built_in">compile</span>(optimizer=Adam(<span class="hljs-number">3e-5</span>))
<span class="hljs-meta">&gt;&gt;&gt; </span>model.fit(dataset)  <span class="hljs-comment"># doctest: +SKIP</span>`}}),gs=new We({}),{c(){o=l("meta"),u=f(),n=l("h1"),g=l("a"),_=l("span"),k(v.$$.fragment),z=f(),M=l("span"),$=s("Quick tour"),j=f(),k(D.$$.fragment),I=f(),N=l("p"),H=s("Get up and running with \u{1F917} Transformers! Whether you\u2019re a developer or an everyday user, this quick tour will help you get started and show you how to use the "),q=l("a"),P=s("pipeline()"),A=s(" for inference, load a pretrained model and preprocessor with an "),S=l("a"),U=s("AutoClass"),R=s(", and quickly train a model with PyTorch or TensorFlow. If you\u2019re a beginner, we recommend checking out our tutorials or "),V=l("a"),pe=s("course"),ne=s(" next for more in-depth explanations of the concepts introduced here."),he=f(),K=l("p"),le=s("Before you begin, make sure you have all the necessary libraries installed:"),ie=f(),k(B.$$.fragment),$e=f(),J=l("p"),Te=s("You\u2019ll also need to install your preferred machine learning framework:"),_e=f(),k(Q.$$.fragment),se=f(),Z=l("h2"),x=l("a"),L=l("span"),k(X.$$.fragment),C=f(),W=l("span"),ve=s("Pipeline"),He=f(),k(ae.$$.fragment),Re=f(),ee=l("p"),vs=s("The "),ge=l("a"),ks=s("pipeline()"),ws=s(" is the easiest way to use a pretrained model for inference. You can use the "),ys=l("a"),qi=s("pipeline()"),Pi=s(" out-of-the-box for many tasks across different modalities. Take a look at the table below for some supported tasks:"),Cn=f(),ht=l("table"),Pr=l("thead"),Ee=l("tr"),xr=l("th"),Fr=l("strong"),xi=s("Task"),Fi=f(),Mr=l("th"),Cr=l("strong"),Mi=s("Description"),Ci=f(),Sr=l("th"),Dr=l("strong"),Si=s("Modality"),Di=f(),Ir=l("th"),Nr=l("strong"),Ii=s("Pipeline identifier"),Ni=f(),Y=l("tbody"),Ae=l("tr"),Or=l("td"),Oi=s("Text classification"),Li=f(),Lr=l("td"),Wi=s("assign a label to a given sequence of text"),Hi=f(),Wr=l("td"),Ri=s("NLP"),Yi=f(),Hr=l("td"),Ui=s("pipeline(task=\u201Csentiment-analysis\u201D)"),Gi=f(),je=l("tr"),Rr=l("td"),Ki=s("Text generation"),Bi=f(),Yr=l("td"),Vi=s("generate text that follows a given prompt"),Qi=f(),Ur=l("td"),Ji=s("NLP"),Zi=f(),Gr=l("td"),Xi=s("pipeline(task=\u201Ctext-generation\u201D)"),ep=f(),ze=l("tr"),Kr=l("td"),tp=s("Name entity recognition"),ap=f(),Br=l("td"),sp=s("assign a label to each token in a sequence (people, organization, location, etc.)"),rp=f(),Vr=l("td"),op=s("NLP"),np=f(),Qr=l("td"),lp=s("pipeline(task=\u201Cner\u201D)"),ip=f(),qe=l("tr"),Jr=l("td"),pp=s("Question answering"),fp=f(),Zr=l("td"),cp=s("extract an answer from the text given some context and a question"),mp=f(),Xr=l("td"),dp=s("NLP"),up=f(),eo=l("td"),hp=s("pipeline(task=\u201Cquestion-answering\u201D)"),gp=f(),Pe=l("tr"),to=l("td"),$p=s("Fill-mask"),_p=f(),ao=l("td"),vp=s("predict the correct masked token in a sequence"),kp=f(),so=l("td"),wp=s("NLP"),yp=f(),ro=l("td"),bp=s("pipeline(task=\u201Cfill-mask\u201D)"),Tp=f(),xe=l("tr"),oo=l("td"),Ep=s("Summarization"),Ap=f(),no=l("td"),jp=s("generate a summary of a sequence of text or document"),zp=f(),lo=l("td"),qp=s("NLP"),Pp=f(),io=l("td"),xp=s("pipeline(task=\u201Csummarization\u201D)"),Fp=f(),Fe=l("tr"),po=l("td"),Mp=s("Translation"),Cp=f(),fo=l("td"),Sp=s("translate text from one language into another"),Dp=f(),co=l("td"),Ip=s("NLP"),Np=f(),mo=l("td"),Op=s("pipeline(task=\u201Ctranslation\u201D)"),Lp=f(),Me=l("tr"),uo=l("td"),Wp=s("Image classification"),Hp=f(),ho=l("td"),Rp=s("assign a label to an image"),Yp=f(),go=l("td"),Up=s("Computer vision"),Gp=f(),$o=l("td"),Kp=s("pipeline(task=\u201Cimage-classification\u201D)"),Bp=f(),Ce=l("tr"),_o=l("td"),Vp=s("Image segmentation"),Qp=f(),vo=l("td"),Jp=s("assign a label to each individual pixel of an image (supports semantic, panoptic, and instance segmentation)"),Zp=f(),ko=l("td"),Xp=s("Computer vision"),ef=f(),wo=l("td"),tf=s("pipeline(task=\u201Cimage-segmentation\u201D)"),af=f(),Se=l("tr"),yo=l("td"),sf=s("Object detection"),rf=f(),bo=l("td"),of=s("predict the bounding boxes and classes of objects in an image"),nf=f(),To=l("td"),lf=s("Computer vision"),pf=f(),Eo=l("td"),ff=s("pipeline(task=\u201Cobject-detection\u201D)"),cf=f(),De=l("tr"),Ao=l("td"),mf=s("Audio classification"),df=f(),jo=l("td"),uf=s("assign a label to an audio file"),hf=f(),zo=l("td"),gf=s("Audio"),$f=f(),qo=l("td"),_f=s("pipeline(task=\u201Caudio-classification\u201D)"),vf=f(),Ie=l("tr"),Po=l("td"),kf=s("Automatic speech recognition"),wf=f(),xo=l("td"),yf=s("extract speech from an audio file into text"),bf=f(),Fo=l("td"),Tf=s("Audio"),Ef=f(),Mo=l("td"),Af=s("pipeline(task=\u201Cautomatic-speech-recognition\u201D)"),jf=f(),Ne=l("tr"),Co=l("td"),zf=s("Visual question answering"),qf=f(),So=l("td"),Pf=s("given an image and a question, correctly answer a question about the image"),xf=f(),Do=l("td"),Ff=s("Multimodal"),Mf=f(),Io=l("td"),Cf=s("pipeline(task=\u201Cvqa\u201D)"),Sn=f(),fe=l("p"),Sf=s("Start by creating an instance of "),bs=l("a"),Df=s("pipeline()"),If=s(" and specifying a task you want to use it for. You can use the "),Ts=l("a"),Nf=s("pipeline()"),Of=s(" for any of the previously mentioned tasks, and for a complete list of supported tasks, take a look at the "),Es=l("a"),Lf=s("pipeline API reference"),Wf=s(". In this guide though, you\u2019ll use the "),As=l("a"),Hf=s("pipeline()"),Rf=s(" for sentiment analysis as an example:"),Dn=f(),k(ia.$$.fragment),In=f(),ke=l("p"),Yf=s("The "),js=l("a"),Uf=s("pipeline()"),Gf=s(" downloads and caches a default "),pa=l("a"),Kf=s("pretrained model"),Bf=s(" and tokenizer for sentiment analysis. Now you can use the "),No=l("code"),Vf=s("classifier"),Qf=s(" on your target text:"),Nn=f(),k(fa.$$.fragment),On=f(),gt=l("p"),Jf=s("If you have more than one input, pass your inputs as a list to the "),zs=l("a"),Zf=s("pipeline()"),Xf=s(" to return a list of dictionaries:"),Ln=f(),k(ca.$$.fragment),Wn=f(),$t=l("p"),ec=s("The "),qs=l("a"),tc=s("pipeline()"),ac=s(" can also iterate over an entire dataset for any task you like. For this example, let\u2019s choose automatic speech recognition as our task:"),Hn=f(),k(ma.$$.fragment),Rn=f(),Ye=l("p"),sc=s("Load an audio dataset (see the \u{1F917} Datasets "),da=l("a"),rc=s("Quick Start"),oc=s(" for more details) you\u2019d like to iterate over. For example, load the "),ua=l("a"),nc=s("MInDS-14"),lc=s(" dataset:"),Yn=f(),k(ha.$$.fragment),Un=f(),_t=l("p"),ic=s(`You need to make sure the sampling rate of the dataset matches the sampling
rate `),ga=l("a"),Oo=l("code"),pc=s("facebook/wav2vec2-base-960h"),fc=s(" was trained on:"),Gn=f(),k($a.$$.fragment),Kn=f(),vt=l("p"),cc=s("The audio files are automatically loaded and resampled when calling the "),Lo=l("code"),mc=s('"audio"'),dc=s(` column.
Extract the raw waveform arrays from the first 4 samples and pass it as a list to the pipeline:`),Bn=f(),k(_a.$$.fragment),Vn=f(),kt=l("p"),uc=s("For larger datasets where the inputs are big (like in speech or vision), you\u2019ll want to pass a generator instead of a list to load all the inputs in memory. Take a look at the "),Ps=l("a"),hc=s("pipeline API reference"),gc=s(" for more information."),Qn=f(),at=l("h3"),wt=l("a"),Wo=l("span"),k(va.$$.fragment),$c=f(),Ho=l("span"),_c=s("Use another model and tokenizer in the pipeline"),Jn=f(),ce=l("p"),vc=s("The "),xs=l("a"),kc=s("pipeline()"),wc=s(" can accommodate any model from the "),ka=l("a"),yc=s("Hub"),bc=s(", making it easy to adapt the "),Fs=l("a"),Tc=s("pipeline()"),Ec=s(" for other use-cases. For example, if you\u2019d like a model capable of handling French text, use the tags on the Hub to filter for an appropriate model. The top filtered result returns a multilingual "),wa=l("a"),Ac=s("BERT model"),jc=s(" finetuned for sentiment analysis you can use for French text:"),Zn=f(),k(ya.$$.fragment),Xn=f(),k(yt.$$.fragment),el=f(),Ue=l("p"),zc=s("Specify the model and tokenizer in the "),Ms=l("a"),qc=s("pipeline()"),Pc=s(", and now you can apply the "),Ro=l("code"),xc=s("classifier"),Fc=s(" on French text:"),tl=f(),k(ba.$$.fragment),al=f(),Ge=l("p"),Mc=s("If you can\u2019t find a model for your use-case, you\u2019ll need to finetune a pretrained model on your data. Take a look at our "),Cs=l("a"),Cc=s("finetuning tutorial"),Sc=s(" to learn how. Finally, after you\u2019ve finetuned your pretrained model, please consider "),Ss=l("a"),Dc=s("sharing"),Ic=s(" the model with the community on the Hub to democratize machine learning for everyone! \u{1F917}"),sl=f(),st=l("h2"),bt=l("a"),Yo=l("span"),k(Ta.$$.fragment),Nc=f(),Uo=l("span"),Oc=s("AutoClass"),rl=f(),k(Ea.$$.fragment),ol=f(),re=l("p"),Lc=s("Under the hood, the "),Ds=l("a"),Wc=s("AutoModelForSequenceClassification"),Hc=s(" and "),Is=l("a"),Rc=s("AutoTokenizer"),Yc=s(" classes work together to power the "),Ns=l("a"),Uc=s("pipeline()"),Gc=s(" you used above. An "),Os=l("a"),Kc=s("AutoClass"),Bc=s(" is a shortcut that automatically retrieves the architecture of a pretrained model from its name or path. You only need to select the appropriate "),Go=l("code"),Vc=s("AutoClass"),Qc=s(" for your task and it\u2019s associated preprocessing class."),nl=f(),Ke=l("p"),Jc=s("Let\u2019s return to the example from the previous section and see how you can use the "),Ko=l("code"),Zc=s("AutoClass"),Xc=s(" to replicate the results of the "),Ls=l("a"),em=s("pipeline()"),tm=s("."),ll=f(),rt=l("h3"),Tt=l("a"),Bo=l("span"),k(Aa.$$.fragment),am=f(),Vo=l("span"),sm=s("AutoTokenizer"),il=f(),Et=l("p"),rm=s("A tokenizer is responsible for preprocessing text into an array of numbers as inputs to a model. There are multiple rules that govern the tokenization process, including how to split a word and at what level words should be split (learn more about tokenization in the "),Ws=l("a"),om=s("tokenizer summary"),nm=s("). The most important thing to remember is you need to instantiate a tokenizer with the same model name to ensure you\u2019re using the same tokenization rules a model was pretrained with."),pl=f(),At=l("p"),lm=s("Load a tokenizer with "),Hs=l("a"),im=s("AutoTokenizer"),pm=s(":"),fl=f(),k(ja.$$.fragment),cl=f(),Rs=l("p"),fm=s("Pass your text to the tokenizer:"),ml=f(),k(za.$$.fragment),dl=f(),Ys=l("p"),cm=s("The tokenizer returns a dictionary containing:"),ul=f(),jt=l("ul"),Us=l("li"),Gs=l("a"),mm=s("input_ids"),dm=s(": numerical representations of your tokens."),um=f(),Ks=l("li"),Bs=l("a"),hm=s("attention_mask"),gm=s(": indicates which tokens should be attended to."),hl=f(),Vs=l("p"),$m=s("A tokenizer can also accept a list of inputs, and pad and truncate the text to return a batch with uniform length:"),gl=f(),k(zt.$$.fragment),$l=f(),k(qt.$$.fragment),_l=f(),ot=l("h3"),Pt=l("a"),Qo=l("span"),k(qa.$$.fragment),_m=f(),Jo=l("span"),vm=s("AutoModel"),vl=f(),k(xt.$$.fragment),kl=f(),k(Ft.$$.fragment),wl=f(),nt=l("h3"),Mt=l("a"),Zo=l("span"),k(Pa.$$.fragment),km=f(),Xo=l("span"),wm=s("Save a model"),yl=f(),k(Ct.$$.fragment),bl=f(),Be=l("p"),ym=s("One particularly cool \u{1F917} Transformers feature is the ability to save a model and reload it as either a PyTorch or TensorFlow model. The "),en=l("code"),bm=s("from_pt"),Tm=s(" or "),tn=l("code"),Em=s("from_tf"),Am=s(" parameter can convert the model from one framework to the other:"),Tl=f(),k(St.$$.fragment),El=f(),lt=l("h2"),Dt=l("a"),an=l("span"),k(xa.$$.fragment),jm=f(),sn=l("span"),zm=s("Custom model builds"),Al=f(),Qs=l("p"),qm=s("You can modify the model\u2019s configuration class to change how a model is built. The configuration specifies a model\u2019s attributes, such as the number of hidden layers or attention heads. You start from scratch when you initialize a model from a custom configuration class. The model attributes are randomly initialized, and you\u2019ll need to train the model before you can use it to get meaningful results."),jl=f(),Ve=l("p"),Pm=s("Start by importing "),Js=l("a"),xm=s("AutoConfig"),Fm=s(", and then load the pretrained model you want to modify. Within "),Zs=l("a"),Mm=s("AutoConfig.from_pretrained()"),Cm=s(", you can specify the attribute you want to change, such as the number of attention heads:"),zl=f(),k(Fa.$$.fragment),ql=f(),k(It.$$.fragment),Pl=f(),Nt=l("p"),Sm=s("Take a look at the "),Xs=l("a"),Dm=s("Create a custom architecture"),Im=s(" guide for more information about building custom configurations."),xl=f(),it=l("h2"),Ot=l("a"),rn=l("span"),k(Ma.$$.fragment),Nm=f(),on=l("span"),Om=s("Trainer - a PyTorch optimized training loop"),Fl=f(),Qe=l("p"),Lm=s("All models are a standard "),Ca=l("a"),nn=l("code"),Wm=s("torch.nn.Module"),Hm=s(" so you can use them in any typical training loop. While you can write your own training loop, \u{1F917} Transformers provides a "),er=l("a"),Rm=s("Trainer"),Ym=s(" class for PyTorch, which contains the basic training loop and adds additional functionality for features like distributed training, mixed precision, and more."),Ml=f(),Lt=l("p"),Um=s("Depending on your task, you\u2019ll typically pass the following parameters to "),tr=l("a"),Gm=s("Trainer"),Km=s(":"),Cl=f(),oe=l("ol"),Sa=l("li"),pt=l("p"),Bm=s("A "),ar=l("a"),Vm=s("PreTrainedModel"),Qm=s(" or a "),Da=l("a"),ln=l("code"),Jm=s("torch.nn.Module"),Zm=s(":"),Xm=f(),k(Ia.$$.fragment),ed=f(),Na=l("li"),sr=l("p"),rr=l("a"),td=s("TrainingArguments"),ad=s(" contains the model hyperparameters you can change like learning rate, batch size, and the number of epochs to train for. The default values are used if you don\u2019t specify any training arguments:"),sd=f(),k(Oa.$$.fragment),rd=f(),La=l("li"),pn=l("p"),od=s("A preprocessing class like a tokenizer, image processor, feature extractor, or processor:"),nd=f(),k(Wa.$$.fragment),ld=f(),Ha=l("li"),fn=l("p"),id=s("Load a dataset:"),pd=f(),k(Ra.$$.fragment),fd=f(),Oe=l("li"),cn=l("p"),cd=s("Create a function to tokenize the dataset:"),md=f(),k(Ya.$$.fragment),dd=f(),Ua=l("p"),ud=s("Then apply it over the entire dataset with "),Ga=l("a"),hd=s("map"),gd=s(":"),$d=f(),k(Ka.$$.fragment),_d=f(),Ba=l("li"),Va=l("p"),vd=s("A "),or=l("a"),kd=s("DataCollatorWithPadding"),wd=s(" to create a batch of examples from your dataset:"),yd=f(),k(Qa.$$.fragment),Sl=f(),Wt=l("p"),bd=s("Now gather all these classes in "),nr=l("a"),Td=s("Trainer"),Ed=s(":"),Dl=f(),k(Ja.$$.fragment),Il=f(),Ht=l("p"),Ad=s("When you\u2019re ready, call "),lr=l("a"),jd=s("train()"),zd=s(" to start training:"),Nl=f(),k(Za.$$.fragment),Ol=f(),k(Rt.$$.fragment),Ll=f(),Je=l("p"),qd=s("You can customize the training loop behavior by subclassing the methods inside "),ir=l("a"),Pd=s("Trainer"),xd=s(". This allows you to customize features such as the loss function, optimizer, and scheduler. Take a look at the "),pr=l("a"),Fd=s("Trainer"),Md=s(" reference for which methods can be subclassed."),Wl=f(),Ze=l("p"),Cd=s("The other way to customize the training loop is by using "),fr=l("a"),Sd=s("Callbacks"),Dd=s(". You can use callbacks to integrate with other libraries and inspect the training loop to report on progress or stop the training early. Callbacks do not modify anything in the training loop itself. To customize something like the loss function, you need to subclass the "),cr=l("a"),Id=s("Trainer"),Nd=s(" instead."),Hl=f(),ft=l("h2"),Yt=l("a"),mn=l("span"),k(Xa.$$.fragment),Od=f(),dn=l("span"),Ld=s("Train with TensorFlow"),Rl=f(),te=l("p"),Wd=s("All models are a standard "),es=l("a"),un=l("code"),Hd=s("tf.keras.Model"),Rd=s(" so they can be trained in TensorFlow with the "),ts=l("a"),Yd=s("Keras"),Ud=s(" API. \u{1F917} Transformers provides the "),mr=l("a"),Gd=s("prepare_tf_dataset()"),Kd=s(" method to easily load your dataset as a "),hn=l("code"),Bd=s("tf.data.Dataset"),Vd=s(" so you can start training right away with Keras\u2019 "),as=l("a"),gn=l("code"),Qd=s("compile"),Jd=s(" and "),ss=l("a"),$n=l("code"),Zd=s("fit"),Xd=s(" methods."),Yl=f(),me=l("ol"),rs=l("li"),ct=l("p"),eu=s("You\u2019ll start with a "),dr=l("a"),tu=s("TFPreTrainedModel"),au=s(" or a "),os=l("a"),_n=l("code"),su=s("tf.keras.Model"),ru=s(":"),ou=f(),k(ns.$$.fragment),nu=f(),ls=l("li"),vn=l("p"),lu=s("A preprocessing class like a tokenizer, image processor, feature extractor, or processor:"),iu=f(),k(is.$$.fragment),pu=f(),ps=l("li"),kn=l("p"),fu=s("Create a function to tokenize the dataset:"),cu=f(),k(fs.$$.fragment),mu=f(),cs=l("li"),mt=l("p"),du=s("Apply the tokenizer over the entire dataset with "),ms=l("a"),uu=s("map"),hu=s(" and then pass the dataset and tokenizer to "),ur=l("a"),gu=s("prepare_tf_dataset()"),$u=s(". You can also change the batch size and shuffle the dataset here if you\u2019d like:"),_u=f(),k(ds.$$.fragment),vu=f(),us=l("li"),dt=l("p"),ku=s("When you\u2019re ready, you can call "),wn=l("code"),wu=s("compile"),yu=s(" and "),yn=l("code"),bu=s("fit"),Tu=s(" to start training:"),Eu=f(),k(hs.$$.fragment),Ul=f(),ut=l("h2"),Ut=l("a"),bn=l("span"),k(gs.$$.fragment),Au=f(),Tn=l("span"),ju=s("What's next?"),Gl=f(),hr=l("p"),zu=s("Now that you\u2019ve completed the \u{1F917} Transformers quick tour, check out our guides and learn how to do more specific things like writing a custom model, fine-tuning a model for a task, and how to train a model with a script. If you\u2019re interested in learning more about \u{1F917} Transformers core concepts, grab a cup of coffee and take a look at our Conceptual Guides!"),this.h()},l(t){const m=B$('[data-svelte="svelte-1phssyn"]',document.head);o=i(m,"META",{name:!0,content:!0}),m.forEach(a),u=c(t),n=i(t,"H1",{class:!0});var $s=p(n);g=i($s,"A",{id:!0,class:!0,href:!0});var En=p(g);_=i(En,"SPAN",{});var An=p(_);w(v.$$.fragment,An),An.forEach(a),En.forEach(a),z=c($s),M=i($s,"SPAN",{});var jn=p(M);$=r(jn,"Quick tour"),jn.forEach(a),$s.forEach(a),j=c(t),w(D.$$.fragment,t),I=c(t),N=i(t,"P",{});var Le=p(N);H=r(Le,"Get up and running with \u{1F917} Transformers! Whether you\u2019re a developer or an everyday user, this quick tour will help you get started and show you how to use the "),q=i(Le,"A",{href:!0});var zn=p(q);P=r(zn,"pipeline()"),zn.forEach(a),A=r(Le," for inference, load a pretrained model and preprocessor with an "),S=i(Le,"A",{href:!0});var qn=p(S);U=r(qn,"AutoClass"),qn.forEach(a),R=r(Le,", and quickly train a model with PyTorch or TensorFlow. If you\u2019re a beginner, we recommend checking out our tutorials or "),V=i(Le,"A",{href:!0,rel:!0});var Pn=p(V);pe=r(Pn,"course"),Pn.forEach(a),ne=r(Le," next for more in-depth explanations of the concepts introduced here."),Le.forEach(a),he=c(t),K=i(t,"P",{});var xn=p(K);le=r(xn,"Before you begin, make sure you have all the necessary libraries installed:"),xn.forEach(a),ie=c(t),w(B.$$.fragment,t),$e=c(t),J=i(t,"P",{});var Fn=p(J);Te=r(Fn,"You\u2019ll also need to install your preferred machine learning framework:"),Fn.forEach(a),_e=c(t),w(Q.$$.fragment,t),se=c(t),Z=i(t,"H2",{class:!0});var Bl=p(Z);x=i(Bl,"A",{id:!0,class:!0,href:!0});var Fu=p(x);L=i(Fu,"SPAN",{});var Mu=p(L);w(X.$$.fragment,Mu),Mu.forEach(a),Fu.forEach(a),C=c(Bl),W=i(Bl,"SPAN",{});var Cu=p(W);ve=r(Cu,"Pipeline"),Cu.forEach(a),Bl.forEach(a),He=c(t),w(ae.$$.fragment,t),Re=c(t),ee=i(t,"P",{});var gr=p(ee);vs=r(gr,"The "),ge=i(gr,"A",{href:!0});var Su=p(ge);ks=r(Su,"pipeline()"),Su.forEach(a),ws=r(gr," is the easiest way to use a pretrained model for inference. You can use the "),ys=i(gr,"A",{href:!0});var Du=p(ys);qi=r(Du,"pipeline()"),Du.forEach(a),Pi=r(gr," out-of-the-box for many tasks across different modalities. Take a look at the table below for some supported tasks:"),gr.forEach(a),Cn=c(t),ht=i(t,"TABLE",{});var Vl=p(ht);Pr=i(Vl,"THEAD",{});var Iu=p(Pr);Ee=i(Iu,"TR",{});var Gt=p(Ee);xr=i(Gt,"TH",{});var Nu=p(xr);Fr=i(Nu,"STRONG",{});var Ou=p(Fr);xi=r(Ou,"Task"),Ou.forEach(a),Nu.forEach(a),Fi=c(Gt),Mr=i(Gt,"TH",{});var Lu=p(Mr);Cr=i(Lu,"STRONG",{});var Wu=p(Cr);Mi=r(Wu,"Description"),Wu.forEach(a),Lu.forEach(a),Ci=c(Gt),Sr=i(Gt,"TH",{});var Hu=p(Sr);Dr=i(Hu,"STRONG",{});var Ru=p(Dr);Si=r(Ru,"Modality"),Ru.forEach(a),Hu.forEach(a),Di=c(Gt),Ir=i(Gt,"TH",{});var Yu=p(Ir);Nr=i(Yu,"STRONG",{});var Uu=p(Nr);Ii=r(Uu,"Pipeline identifier"),Uu.forEach(a),Yu.forEach(a),Gt.forEach(a),Iu.forEach(a),Ni=c(Vl),Y=i(Vl,"TBODY",{});var G=p(Y);Ae=i(G,"TR",{});var Kt=p(Ae);Or=i(Kt,"TD",{});var Gu=p(Or);Oi=r(Gu,"Text classification"),Gu.forEach(a),Li=c(Kt),Lr=i(Kt,"TD",{});var Ku=p(Lr);Wi=r(Ku,"assign a label to a given sequence of text"),Ku.forEach(a),Hi=c(Kt),Wr=i(Kt,"TD",{});var Bu=p(Wr);Ri=r(Bu,"NLP"),Bu.forEach(a),Yi=c(Kt),Hr=i(Kt,"TD",{});var Vu=p(Hr);Ui=r(Vu,"pipeline(task=\u201Csentiment-analysis\u201D)"),Vu.forEach(a),Kt.forEach(a),Gi=c(G),je=i(G,"TR",{});var Bt=p(je);Rr=i(Bt,"TD",{});var Qu=p(Rr);Ki=r(Qu,"Text generation"),Qu.forEach(a),Bi=c(Bt),Yr=i(Bt,"TD",{});var Ju=p(Yr);Vi=r(Ju,"generate text that follows a given prompt"),Ju.forEach(a),Qi=c(Bt),Ur=i(Bt,"TD",{});var Zu=p(Ur);Ji=r(Zu,"NLP"),Zu.forEach(a),Zi=c(Bt),Gr=i(Bt,"TD",{});var Xu=p(Gr);Xi=r(Xu,"pipeline(task=\u201Ctext-generation\u201D)"),Xu.forEach(a),Bt.forEach(a),ep=c(G),ze=i(G,"TR",{});var Vt=p(ze);Kr=i(Vt,"TD",{});var eh=p(Kr);tp=r(eh,"Name entity recognition"),eh.forEach(a),ap=c(Vt),Br=i(Vt,"TD",{});var th=p(Br);sp=r(th,"assign a label to each token in a sequence (people, organization, location, etc.)"),th.forEach(a),rp=c(Vt),Vr=i(Vt,"TD",{});var ah=p(Vr);op=r(ah,"NLP"),ah.forEach(a),np=c(Vt),Qr=i(Vt,"TD",{});var sh=p(Qr);lp=r(sh,"pipeline(task=\u201Cner\u201D)"),sh.forEach(a),Vt.forEach(a),ip=c(G),qe=i(G,"TR",{});var Qt=p(qe);Jr=i(Qt,"TD",{});var rh=p(Jr);pp=r(rh,"Question answering"),rh.forEach(a),fp=c(Qt),Zr=i(Qt,"TD",{});var oh=p(Zr);cp=r(oh,"extract an answer from the text given some context and a question"),oh.forEach(a),mp=c(Qt),Xr=i(Qt,"TD",{});var nh=p(Xr);dp=r(nh,"NLP"),nh.forEach(a),up=c(Qt),eo=i(Qt,"TD",{});var lh=p(eo);hp=r(lh,"pipeline(task=\u201Cquestion-answering\u201D)"),lh.forEach(a),Qt.forEach(a),gp=c(G),Pe=i(G,"TR",{});var Jt=p(Pe);to=i(Jt,"TD",{});var ih=p(to);$p=r(ih,"Fill-mask"),ih.forEach(a),_p=c(Jt),ao=i(Jt,"TD",{});var ph=p(ao);vp=r(ph,"predict the correct masked token in a sequence"),ph.forEach(a),kp=c(Jt),so=i(Jt,"TD",{});var fh=p(so);wp=r(fh,"NLP"),fh.forEach(a),yp=c(Jt),ro=i(Jt,"TD",{});var ch=p(ro);bp=r(ch,"pipeline(task=\u201Cfill-mask\u201D)"),ch.forEach(a),Jt.forEach(a),Tp=c(G),xe=i(G,"TR",{});var Zt=p(xe);oo=i(Zt,"TD",{});var mh=p(oo);Ep=r(mh,"Summarization"),mh.forEach(a),Ap=c(Zt),no=i(Zt,"TD",{});var dh=p(no);jp=r(dh,"generate a summary of a sequence of text or document"),dh.forEach(a),zp=c(Zt),lo=i(Zt,"TD",{});var uh=p(lo);qp=r(uh,"NLP"),uh.forEach(a),Pp=c(Zt),io=i(Zt,"TD",{});var hh=p(io);xp=r(hh,"pipeline(task=\u201Csummarization\u201D)"),hh.forEach(a),Zt.forEach(a),Fp=c(G),Fe=i(G,"TR",{});var Xt=p(Fe);po=i(Xt,"TD",{});var gh=p(po);Mp=r(gh,"Translation"),gh.forEach(a),Cp=c(Xt),fo=i(Xt,"TD",{});var $h=p(fo);Sp=r($h,"translate text from one language into another"),$h.forEach(a),Dp=c(Xt),co=i(Xt,"TD",{});var _h=p(co);Ip=r(_h,"NLP"),_h.forEach(a),Np=c(Xt),mo=i(Xt,"TD",{});var vh=p(mo);Op=r(vh,"pipeline(task=\u201Ctranslation\u201D)"),vh.forEach(a),Xt.forEach(a),Lp=c(G),Me=i(G,"TR",{});var ea=p(Me);uo=i(ea,"TD",{});var kh=p(uo);Wp=r(kh,"Image classification"),kh.forEach(a),Hp=c(ea),ho=i(ea,"TD",{});var wh=p(ho);Rp=r(wh,"assign a label to an image"),wh.forEach(a),Yp=c(ea),go=i(ea,"TD",{});var yh=p(go);Up=r(yh,"Computer vision"),yh.forEach(a),Gp=c(ea),$o=i(ea,"TD",{});var bh=p($o);Kp=r(bh,"pipeline(task=\u201Cimage-classification\u201D)"),bh.forEach(a),ea.forEach(a),Bp=c(G),Ce=i(G,"TR",{});var ta=p(Ce);_o=i(ta,"TD",{});var Th=p(_o);Vp=r(Th,"Image segmentation"),Th.forEach(a),Qp=c(ta),vo=i(ta,"TD",{});var Eh=p(vo);Jp=r(Eh,"assign a label to each individual pixel of an image (supports semantic, panoptic, and instance segmentation)"),Eh.forEach(a),Zp=c(ta),ko=i(ta,"TD",{});var Ah=p(ko);Xp=r(Ah,"Computer vision"),Ah.forEach(a),ef=c(ta),wo=i(ta,"TD",{});var jh=p(wo);tf=r(jh,"pipeline(task=\u201Cimage-segmentation\u201D)"),jh.forEach(a),ta.forEach(a),af=c(G),Se=i(G,"TR",{});var aa=p(Se);yo=i(aa,"TD",{});var zh=p(yo);sf=r(zh,"Object detection"),zh.forEach(a),rf=c(aa),bo=i(aa,"TD",{});var qh=p(bo);of=r(qh,"predict the bounding boxes and classes of objects in an image"),qh.forEach(a),nf=c(aa),To=i(aa,"TD",{});var Ph=p(To);lf=r(Ph,"Computer vision"),Ph.forEach(a),pf=c(aa),Eo=i(aa,"TD",{});var xh=p(Eo);ff=r(xh,"pipeline(task=\u201Cobject-detection\u201D)"),xh.forEach(a),aa.forEach(a),cf=c(G),De=i(G,"TR",{});var sa=p(De);Ao=i(sa,"TD",{});var Fh=p(Ao);mf=r(Fh,"Audio classification"),Fh.forEach(a),df=c(sa),jo=i(sa,"TD",{});var Mh=p(jo);uf=r(Mh,"assign a label to an audio file"),Mh.forEach(a),hf=c(sa),zo=i(sa,"TD",{});var Ch=p(zo);gf=r(Ch,"Audio"),Ch.forEach(a),$f=c(sa),qo=i(sa,"TD",{});var Sh=p(qo);_f=r(Sh,"pipeline(task=\u201Caudio-classification\u201D)"),Sh.forEach(a),sa.forEach(a),vf=c(G),Ie=i(G,"TR",{});var ra=p(Ie);Po=i(ra,"TD",{});var Dh=p(Po);kf=r(Dh,"Automatic speech recognition"),Dh.forEach(a),wf=c(ra),xo=i(ra,"TD",{});var Ih=p(xo);yf=r(Ih,"extract speech from an audio file into text"),Ih.forEach(a),bf=c(ra),Fo=i(ra,"TD",{});var Nh=p(Fo);Tf=r(Nh,"Audio"),Nh.forEach(a),Ef=c(ra),Mo=i(ra,"TD",{});var Oh=p(Mo);Af=r(Oh,"pipeline(task=\u201Cautomatic-speech-recognition\u201D)"),Oh.forEach(a),ra.forEach(a),jf=c(G),Ne=i(G,"TR",{});var oa=p(Ne);Co=i(oa,"TD",{});var Lh=p(Co);zf=r(Lh,"Visual question answering"),Lh.forEach(a),qf=c(oa),So=i(oa,"TD",{});var Wh=p(So);Pf=r(Wh,"given an image and a question, correctly answer a question about the image"),Wh.forEach(a),xf=c(oa),Do=i(oa,"TD",{});var Hh=p(Do);Ff=r(Hh,"Multimodal"),Hh.forEach(a),Mf=c(oa),Io=i(oa,"TD",{});var Rh=p(Io);Cf=r(Rh,"pipeline(task=\u201Cvqa\u201D)"),Rh.forEach(a),oa.forEach(a),G.forEach(a),Vl.forEach(a),Sn=c(t),fe=i(t,"P",{});var Xe=p(fe);Sf=r(Xe,"Start by creating an instance of "),bs=i(Xe,"A",{href:!0});var Yh=p(bs);Df=r(Yh,"pipeline()"),Yh.forEach(a),If=r(Xe," and specifying a task you want to use it for. You can use the "),Ts=i(Xe,"A",{href:!0});var Uh=p(Ts);Nf=r(Uh,"pipeline()"),Uh.forEach(a),Of=r(Xe," for any of the previously mentioned tasks, and for a complete list of supported tasks, take a look at the "),Es=i(Xe,"A",{href:!0});var Gh=p(Es);Lf=r(Gh,"pipeline API reference"),Gh.forEach(a),Wf=r(Xe,". In this guide though, you\u2019ll use the "),As=i(Xe,"A",{href:!0});var Kh=p(As);Hf=r(Kh,"pipeline()"),Kh.forEach(a),Rf=r(Xe," for sentiment analysis as an example:"),Xe.forEach(a),Dn=c(t),w(ia.$$.fragment,t),In=c(t),ke=i(t,"P",{});var na=p(ke);Yf=r(na,"The "),js=i(na,"A",{href:!0});var Bh=p(js);Uf=r(Bh,"pipeline()"),Bh.forEach(a),Gf=r(na," downloads and caches a default "),pa=i(na,"A",{href:!0,rel:!0});var Vh=p(pa);Kf=r(Vh,"pretrained model"),Vh.forEach(a),Bf=r(na," and tokenizer for sentiment analysis. Now you can use the "),No=i(na,"CODE",{});var Qh=p(No);Vf=r(Qh,"classifier"),Qh.forEach(a),Qf=r(na," on your target text:"),na.forEach(a),Nn=c(t),w(fa.$$.fragment,t),On=c(t),gt=i(t,"P",{});var Ql=p(gt);Jf=r(Ql,"If you have more than one input, pass your inputs as a list to the "),zs=i(Ql,"A",{href:!0});var Jh=p(zs);Zf=r(Jh,"pipeline()"),Jh.forEach(a),Xf=r(Ql," to return a list of dictionaries:"),Ql.forEach(a),Ln=c(t),w(ca.$$.fragment,t),Wn=c(t),$t=i(t,"P",{});var Jl=p($t);ec=r(Jl,"The "),qs=i(Jl,"A",{href:!0});var Zh=p(qs);tc=r(Zh,"pipeline()"),Zh.forEach(a),ac=r(Jl," can also iterate over an entire dataset for any task you like. For this example, let\u2019s choose automatic speech recognition as our task:"),Jl.forEach(a),Hn=c(t),w(ma.$$.fragment,t),Rn=c(t),Ye=i(t,"P",{});var $r=p(Ye);sc=r($r,"Load an audio dataset (see the \u{1F917} Datasets "),da=i($r,"A",{href:!0,rel:!0});var Xh=p(da);rc=r(Xh,"Quick Start"),Xh.forEach(a),oc=r($r," for more details) you\u2019d like to iterate over. For example, load the "),ua=i($r,"A",{href:!0,rel:!0});var eg=p(ua);nc=r(eg,"MInDS-14"),eg.forEach(a),lc=r($r," dataset:"),$r.forEach(a),Yn=c(t),w(ha.$$.fragment,t),Un=c(t),_t=i(t,"P",{});var Zl=p(_t);ic=r(Zl,`You need to make sure the sampling rate of the dataset matches the sampling
rate `),ga=i(Zl,"A",{href:!0,rel:!0});var tg=p(ga);Oo=i(tg,"CODE",{});var ag=p(Oo);pc=r(ag,"facebook/wav2vec2-base-960h"),ag.forEach(a),tg.forEach(a),fc=r(Zl," was trained on:"),Zl.forEach(a),Gn=c(t),w($a.$$.fragment,t),Kn=c(t),vt=i(t,"P",{});var Xl=p(vt);cc=r(Xl,"The audio files are automatically loaded and resampled when calling the "),Lo=i(Xl,"CODE",{});var sg=p(Lo);mc=r(sg,'"audio"'),sg.forEach(a),dc=r(Xl,` column.
Extract the raw waveform arrays from the first 4 samples and pass it as a list to the pipeline:`),Xl.forEach(a),Bn=c(t),w(_a.$$.fragment,t),Vn=c(t),kt=i(t,"P",{});var ei=p(kt);uc=r(ei,"For larger datasets where the inputs are big (like in speech or vision), you\u2019ll want to pass a generator instead of a list to load all the inputs in memory. Take a look at the "),Ps=i(ei,"A",{href:!0});var rg=p(Ps);hc=r(rg,"pipeline API reference"),rg.forEach(a),gc=r(ei," for more information."),ei.forEach(a),Qn=c(t),at=i(t,"H3",{class:!0});var ti=p(at);wt=i(ti,"A",{id:!0,class:!0,href:!0});var og=p(wt);Wo=i(og,"SPAN",{});var ng=p(Wo);w(va.$$.fragment,ng),ng.forEach(a),og.forEach(a),$c=c(ti),Ho=i(ti,"SPAN",{});var lg=p(Ho);_c=r(lg,"Use another model and tokenizer in the pipeline"),lg.forEach(a),ti.forEach(a),Jn=c(t),ce=i(t,"P",{});var et=p(ce);vc=r(et,"The "),xs=i(et,"A",{href:!0});var ig=p(xs);kc=r(ig,"pipeline()"),ig.forEach(a),wc=r(et," can accommodate any model from the "),ka=i(et,"A",{href:!0,rel:!0});var pg=p(ka);yc=r(pg,"Hub"),pg.forEach(a),bc=r(et,", making it easy to adapt the "),Fs=i(et,"A",{href:!0});var fg=p(Fs);Tc=r(fg,"pipeline()"),fg.forEach(a),Ec=r(et," for other use-cases. For example, if you\u2019d like a model capable of handling French text, use the tags on the Hub to filter for an appropriate model. The top filtered result returns a multilingual "),wa=i(et,"A",{href:!0,rel:!0});var cg=p(wa);Ac=r(cg,"BERT model"),cg.forEach(a),jc=r(et," finetuned for sentiment analysis you can use for French text:"),et.forEach(a),Zn=c(t),w(ya.$$.fragment,t),Xn=c(t),w(yt.$$.fragment,t),el=c(t),Ue=i(t,"P",{});var _r=p(Ue);zc=r(_r,"Specify the model and tokenizer in the "),Ms=i(_r,"A",{href:!0});var mg=p(Ms);qc=r(mg,"pipeline()"),mg.forEach(a),Pc=r(_r,", and now you can apply the "),Ro=i(_r,"CODE",{});var dg=p(Ro);xc=r(dg,"classifier"),dg.forEach(a),Fc=r(_r," on French text:"),_r.forEach(a),tl=c(t),w(ba.$$.fragment,t),al=c(t),Ge=i(t,"P",{});var vr=p(Ge);Mc=r(vr,"If you can\u2019t find a model for your use-case, you\u2019ll need to finetune a pretrained model on your data. Take a look at our "),Cs=i(vr,"A",{href:!0});var ug=p(Cs);Cc=r(ug,"finetuning tutorial"),ug.forEach(a),Sc=r(vr," to learn how. Finally, after you\u2019ve finetuned your pretrained model, please consider "),Ss=i(vr,"A",{href:!0});var hg=p(Ss);Dc=r(hg,"sharing"),hg.forEach(a),Ic=r(vr," the model with the community on the Hub to democratize machine learning for everyone! \u{1F917}"),vr.forEach(a),sl=c(t),st=i(t,"H2",{class:!0});var ai=p(st);bt=i(ai,"A",{id:!0,class:!0,href:!0});var gg=p(bt);Yo=i(gg,"SPAN",{});var $g=p(Yo);w(Ta.$$.fragment,$g),$g.forEach(a),gg.forEach(a),Nc=c(ai),Uo=i(ai,"SPAN",{});var _g=p(Uo);Oc=r(_g,"AutoClass"),_g.forEach(a),ai.forEach(a),rl=c(t),w(Ea.$$.fragment,t),ol=c(t),re=i(t,"P",{});var we=p(re);Lc=r(we,"Under the hood, the "),Ds=i(we,"A",{href:!0});var vg=p(Ds);Wc=r(vg,"AutoModelForSequenceClassification"),vg.forEach(a),Hc=r(we," and "),Is=i(we,"A",{href:!0});var kg=p(Is);Rc=r(kg,"AutoTokenizer"),kg.forEach(a),Yc=r(we," classes work together to power the "),Ns=i(we,"A",{href:!0});var wg=p(Ns);Uc=r(wg,"pipeline()"),wg.forEach(a),Gc=r(we," you used above. An "),Os=i(we,"A",{href:!0});var yg=p(Os);Kc=r(yg,"AutoClass"),yg.forEach(a),Bc=r(we," is a shortcut that automatically retrieves the architecture of a pretrained model from its name or path. You only need to select the appropriate "),Go=i(we,"CODE",{});var bg=p(Go);Vc=r(bg,"AutoClass"),bg.forEach(a),Qc=r(we," for your task and it\u2019s associated preprocessing class."),we.forEach(a),nl=c(t),Ke=i(t,"P",{});var kr=p(Ke);Jc=r(kr,"Let\u2019s return to the example from the previous section and see how you can use the "),Ko=i(kr,"CODE",{});var Tg=p(Ko);Zc=r(Tg,"AutoClass"),Tg.forEach(a),Xc=r(kr," to replicate the results of the "),Ls=i(kr,"A",{href:!0});var Eg=p(Ls);em=r(Eg,"pipeline()"),Eg.forEach(a),tm=r(kr,"."),kr.forEach(a),ll=c(t),rt=i(t,"H3",{class:!0});var si=p(rt);Tt=i(si,"A",{id:!0,class:!0,href:!0});var Ag=p(Tt);Bo=i(Ag,"SPAN",{});var jg=p(Bo);w(Aa.$$.fragment,jg),jg.forEach(a),Ag.forEach(a),am=c(si),Vo=i(si,"SPAN",{});var zg=p(Vo);sm=r(zg,"AutoTokenizer"),zg.forEach(a),si.forEach(a),il=c(t),Et=i(t,"P",{});var ri=p(Et);rm=r(ri,"A tokenizer is responsible for preprocessing text into an array of numbers as inputs to a model. There are multiple rules that govern the tokenization process, including how to split a word and at what level words should be split (learn more about tokenization in the "),Ws=i(ri,"A",{href:!0});var qg=p(Ws);om=r(qg,"tokenizer summary"),qg.forEach(a),nm=r(ri,"). The most important thing to remember is you need to instantiate a tokenizer with the same model name to ensure you\u2019re using the same tokenization rules a model was pretrained with."),ri.forEach(a),pl=c(t),At=i(t,"P",{});var oi=p(At);lm=r(oi,"Load a tokenizer with "),Hs=i(oi,"A",{href:!0});var Pg=p(Hs);im=r(Pg,"AutoTokenizer"),Pg.forEach(a),pm=r(oi,":"),oi.forEach(a),fl=c(t),w(ja.$$.fragment,t),cl=c(t),Rs=i(t,"P",{});var xg=p(Rs);fm=r(xg,"Pass your text to the tokenizer:"),xg.forEach(a),ml=c(t),w(za.$$.fragment,t),dl=c(t),Ys=i(t,"P",{});var Fg=p(Ys);cm=r(Fg,"The tokenizer returns a dictionary containing:"),Fg.forEach(a),ul=c(t),jt=i(t,"UL",{});var ni=p(jt);Us=i(ni,"LI",{});var qu=p(Us);Gs=i(qu,"A",{href:!0});var Mg=p(Gs);mm=r(Mg,"input_ids"),Mg.forEach(a),dm=r(qu,": numerical representations of your tokens."),qu.forEach(a),um=c(ni),Ks=i(ni,"LI",{});var Pu=p(Ks);Bs=i(Pu,"A",{href:!0});var Cg=p(Bs);hm=r(Cg,"attention_mask"),Cg.forEach(a),gm=r(Pu,": indicates which tokens should be attended to."),Pu.forEach(a),ni.forEach(a),hl=c(t),Vs=i(t,"P",{});var Sg=p(Vs);$m=r(Sg,"A tokenizer can also accept a list of inputs, and pad and truncate the text to return a batch with uniform length:"),Sg.forEach(a),gl=c(t),w(zt.$$.fragment,t),$l=c(t),w(qt.$$.fragment,t),_l=c(t),ot=i(t,"H3",{class:!0});var li=p(ot);Pt=i(li,"A",{id:!0,class:!0,href:!0});var Dg=p(Pt);Qo=i(Dg,"SPAN",{});var Ig=p(Qo);w(qa.$$.fragment,Ig),Ig.forEach(a),Dg.forEach(a),_m=c(li),Jo=i(li,"SPAN",{});var Ng=p(Jo);vm=r(Ng,"AutoModel"),Ng.forEach(a),li.forEach(a),vl=c(t),w(xt.$$.fragment,t),kl=c(t),w(Ft.$$.fragment,t),wl=c(t),nt=i(t,"H3",{class:!0});var ii=p(nt);Mt=i(ii,"A",{id:!0,class:!0,href:!0});var Og=p(Mt);Zo=i(Og,"SPAN",{});var Lg=p(Zo);w(Pa.$$.fragment,Lg),Lg.forEach(a),Og.forEach(a),km=c(ii),Xo=i(ii,"SPAN",{});var Wg=p(Xo);wm=r(Wg,"Save a model"),Wg.forEach(a),ii.forEach(a),yl=c(t),w(Ct.$$.fragment,t),bl=c(t),Be=i(t,"P",{});var wr=p(Be);ym=r(wr,"One particularly cool \u{1F917} Transformers feature is the ability to save a model and reload it as either a PyTorch or TensorFlow model. The "),en=i(wr,"CODE",{});var Hg=p(en);bm=r(Hg,"from_pt"),Hg.forEach(a),Tm=r(wr," or "),tn=i(wr,"CODE",{});var Rg=p(tn);Em=r(Rg,"from_tf"),Rg.forEach(a),Am=r(wr," parameter can convert the model from one framework to the other:"),wr.forEach(a),Tl=c(t),w(St.$$.fragment,t),El=c(t),lt=i(t,"H2",{class:!0});var pi=p(lt);Dt=i(pi,"A",{id:!0,class:!0,href:!0});var Yg=p(Dt);an=i(Yg,"SPAN",{});var Ug=p(an);w(xa.$$.fragment,Ug),Ug.forEach(a),Yg.forEach(a),jm=c(pi),sn=i(pi,"SPAN",{});var Gg=p(sn);zm=r(Gg,"Custom model builds"),Gg.forEach(a),pi.forEach(a),Al=c(t),Qs=i(t,"P",{});var Kg=p(Qs);qm=r(Kg,"You can modify the model\u2019s configuration class to change how a model is built. The configuration specifies a model\u2019s attributes, such as the number of hidden layers or attention heads. You start from scratch when you initialize a model from a custom configuration class. The model attributes are randomly initialized, and you\u2019ll need to train the model before you can use it to get meaningful results."),Kg.forEach(a),jl=c(t),Ve=i(t,"P",{});var yr=p(Ve);Pm=r(yr,"Start by importing "),Js=i(yr,"A",{href:!0});var Bg=p(Js);xm=r(Bg,"AutoConfig"),Bg.forEach(a),Fm=r(yr,", and then load the pretrained model you want to modify. Within "),Zs=i(yr,"A",{href:!0});var Vg=p(Zs);Mm=r(Vg,"AutoConfig.from_pretrained()"),Vg.forEach(a),Cm=r(yr,", you can specify the attribute you want to change, such as the number of attention heads:"),yr.forEach(a),zl=c(t),w(Fa.$$.fragment,t),ql=c(t),w(It.$$.fragment,t),Pl=c(t),Nt=i(t,"P",{});var fi=p(Nt);Sm=r(fi,"Take a look at the "),Xs=i(fi,"A",{href:!0});var Qg=p(Xs);Dm=r(Qg,"Create a custom architecture"),Qg.forEach(a),Im=r(fi," guide for more information about building custom configurations."),fi.forEach(a),xl=c(t),it=i(t,"H2",{class:!0});var ci=p(it);Ot=i(ci,"A",{id:!0,class:!0,href:!0});var Jg=p(Ot);rn=i(Jg,"SPAN",{});var Zg=p(rn);w(Ma.$$.fragment,Zg),Zg.forEach(a),Jg.forEach(a),Nm=c(ci),on=i(ci,"SPAN",{});var Xg=p(on);Om=r(Xg,"Trainer - a PyTorch optimized training loop"),Xg.forEach(a),ci.forEach(a),Fl=c(t),Qe=i(t,"P",{});var br=p(Qe);Lm=r(br,"All models are a standard "),Ca=i(br,"A",{href:!0,rel:!0});var e$=p(Ca);nn=i(e$,"CODE",{});var t$=p(nn);Wm=r(t$,"torch.nn.Module"),t$.forEach(a),e$.forEach(a),Hm=r(br," so you can use them in any typical training loop. While you can write your own training loop, \u{1F917} Transformers provides a "),er=i(br,"A",{href:!0});var a$=p(er);Rm=r(a$,"Trainer"),a$.forEach(a),Ym=r(br," class for PyTorch, which contains the basic training loop and adds additional functionality for features like distributed training, mixed precision, and more."),br.forEach(a),Ml=c(t),Lt=i(t,"P",{});var mi=p(Lt);Um=r(mi,"Depending on your task, you\u2019ll typically pass the following parameters to "),tr=i(mi,"A",{href:!0});var s$=p(tr);Gm=r(s$,"Trainer"),s$.forEach(a),Km=r(mi,":"),mi.forEach(a),Cl=c(t),oe=i(t,"OL",{});var ye=p(oe);Sa=i(ye,"LI",{});var di=p(Sa);pt=i(di,"P",{});var Tr=p(pt);Bm=r(Tr,"A "),ar=i(Tr,"A",{href:!0});var r$=p(ar);Vm=r(r$,"PreTrainedModel"),r$.forEach(a),Qm=r(Tr," or a "),Da=i(Tr,"A",{href:!0,rel:!0});var o$=p(Da);ln=i(o$,"CODE",{});var n$=p(ln);Jm=r(n$,"torch.nn.Module"),n$.forEach(a),o$.forEach(a),Zm=r(Tr,":"),Tr.forEach(a),Xm=c(di),w(Ia.$$.fragment,di),di.forEach(a),ed=c(ye),Na=i(ye,"LI",{});var ui=p(Na);sr=i(ui,"P",{});var xu=p(sr);rr=i(xu,"A",{href:!0});var l$=p(rr);td=r(l$,"TrainingArguments"),l$.forEach(a),ad=r(xu," contains the model hyperparameters you can change like learning rate, batch size, and the number of epochs to train for. The default values are used if you don\u2019t specify any training arguments:"),xu.forEach(a),sd=c(ui),w(Oa.$$.fragment,ui),ui.forEach(a),rd=c(ye),La=i(ye,"LI",{});var hi=p(La);pn=i(hi,"P",{});var i$=p(pn);od=r(i$,"A preprocessing class like a tokenizer, image processor, feature extractor, or processor:"),i$.forEach(a),nd=c(hi),w(Wa.$$.fragment,hi),hi.forEach(a),ld=c(ye),Ha=i(ye,"LI",{});var gi=p(Ha);fn=i(gi,"P",{});var p$=p(fn);id=r(p$,"Load a dataset:"),p$.forEach(a),pd=c(gi),w(Ra.$$.fragment,gi),gi.forEach(a),fd=c(ye),Oe=i(ye,"LI",{});var la=p(Oe);cn=i(la,"P",{});var f$=p(cn);cd=r(f$,"Create a function to tokenize the dataset:"),f$.forEach(a),md=c(la),w(Ya.$$.fragment,la),dd=c(la),Ua=i(la,"P",{});var $i=p(Ua);ud=r($i,"Then apply it over the entire dataset with "),Ga=i($i,"A",{href:!0,rel:!0});var c$=p(Ga);hd=r(c$,"map"),c$.forEach(a),gd=r($i,":"),$i.forEach(a),$d=c(la),w(Ka.$$.fragment,la),la.forEach(a),_d=c(ye),Ba=i(ye,"LI",{});var _i=p(Ba);Va=i(_i,"P",{});var vi=p(Va);vd=r(vi,"A "),or=i(vi,"A",{href:!0});var m$=p(or);kd=r(m$,"DataCollatorWithPadding"),m$.forEach(a),wd=r(vi," to create a batch of examples from your dataset:"),vi.forEach(a),yd=c(_i),w(Qa.$$.fragment,_i),_i.forEach(a),ye.forEach(a),Sl=c(t),Wt=i(t,"P",{});var ki=p(Wt);bd=r(ki,"Now gather all these classes in "),nr=i(ki,"A",{href:!0});var d$=p(nr);Td=r(d$,"Trainer"),d$.forEach(a),Ed=r(ki,":"),ki.forEach(a),Dl=c(t),w(Ja.$$.fragment,t),Il=c(t),Ht=i(t,"P",{});var wi=p(Ht);Ad=r(wi,"When you\u2019re ready, call "),lr=i(wi,"A",{href:!0});var u$=p(lr);jd=r(u$,"train()"),u$.forEach(a),zd=r(wi," to start training:"),wi.forEach(a),Nl=c(t),w(Za.$$.fragment,t),Ol=c(t),w(Rt.$$.fragment,t),Ll=c(t),Je=i(t,"P",{});var Er=p(Je);qd=r(Er,"You can customize the training loop behavior by subclassing the methods inside "),ir=i(Er,"A",{href:!0});var h$=p(ir);Pd=r(h$,"Trainer"),h$.forEach(a),xd=r(Er,". This allows you to customize features such as the loss function, optimizer, and scheduler. Take a look at the "),pr=i(Er,"A",{href:!0});var g$=p(pr);Fd=r(g$,"Trainer"),g$.forEach(a),Md=r(Er," reference for which methods can be subclassed."),Er.forEach(a),Wl=c(t),Ze=i(t,"P",{});var Ar=p(Ze);Cd=r(Ar,"The other way to customize the training loop is by using "),fr=i(Ar,"A",{href:!0});var $$=p(fr);Sd=r($$,"Callbacks"),$$.forEach(a),Dd=r(Ar,". You can use callbacks to integrate with other libraries and inspect the training loop to report on progress or stop the training early. Callbacks do not modify anything in the training loop itself. To customize something like the loss function, you need to subclass the "),cr=i(Ar,"A",{href:!0});var _$=p(cr);Id=r(_$,"Trainer"),_$.forEach(a),Nd=r(Ar," instead."),Ar.forEach(a),Hl=c(t),ft=i(t,"H2",{class:!0});var yi=p(ft);Yt=i(yi,"A",{id:!0,class:!0,href:!0});var v$=p(Yt);mn=i(v$,"SPAN",{});var k$=p(mn);w(Xa.$$.fragment,k$),k$.forEach(a),v$.forEach(a),Od=c(yi),dn=i(yi,"SPAN",{});var w$=p(dn);Ld=r(w$,"Train with TensorFlow"),w$.forEach(a),yi.forEach(a),Rl=c(t),te=i(t,"P",{});var de=p(te);Wd=r(de,"All models are a standard "),es=i(de,"A",{href:!0,rel:!0});var y$=p(es);un=i(y$,"CODE",{});var b$=p(un);Hd=r(b$,"tf.keras.Model"),b$.forEach(a),y$.forEach(a),Rd=r(de," so they can be trained in TensorFlow with the "),ts=i(de,"A",{href:!0,rel:!0});var T$=p(ts);Yd=r(T$,"Keras"),T$.forEach(a),Ud=r(de," API. \u{1F917} Transformers provides the "),mr=i(de,"A",{href:!0});var E$=p(mr);Gd=r(E$,"prepare_tf_dataset()"),E$.forEach(a),Kd=r(de," method to easily load your dataset as a "),hn=i(de,"CODE",{});var A$=p(hn);Bd=r(A$,"tf.data.Dataset"),A$.forEach(a),Vd=r(de," so you can start training right away with Keras\u2019 "),as=i(de,"A",{href:!0,rel:!0});var j$=p(as);gn=i(j$,"CODE",{});var z$=p(gn);Qd=r(z$,"compile"),z$.forEach(a),j$.forEach(a),Jd=r(de," and "),ss=i(de,"A",{href:!0,rel:!0});var q$=p(ss);$n=i(q$,"CODE",{});var P$=p($n);Zd=r(P$,"fit"),P$.forEach(a),q$.forEach(a),Xd=r(de," methods."),de.forEach(a),Yl=c(t),me=i(t,"OL",{});var tt=p(me);rs=i(tt,"LI",{});var bi=p(rs);ct=i(bi,"P",{});var jr=p(ct);eu=r(jr,"You\u2019ll start with a "),dr=i(jr,"A",{href:!0});var x$=p(dr);tu=r(x$,"TFPreTrainedModel"),x$.forEach(a),au=r(jr," or a "),os=i(jr,"A",{href:!0,rel:!0});var F$=p(os);_n=i(F$,"CODE",{});var M$=p(_n);su=r(M$,"tf.keras.Model"),M$.forEach(a),F$.forEach(a),ru=r(jr,":"),jr.forEach(a),ou=c(bi),w(ns.$$.fragment,bi),bi.forEach(a),nu=c(tt),ls=i(tt,"LI",{});var Ti=p(ls);vn=i(Ti,"P",{});var C$=p(vn);lu=r(C$,"A preprocessing class like a tokenizer, image processor, feature extractor, or processor:"),C$.forEach(a),iu=c(Ti),w(is.$$.fragment,Ti),Ti.forEach(a),pu=c(tt),ps=i(tt,"LI",{});var Ei=p(ps);kn=i(Ei,"P",{});var S$=p(kn);fu=r(S$,"Create a function to tokenize the dataset:"),S$.forEach(a),cu=c(Ei),w(fs.$$.fragment,Ei),Ei.forEach(a),mu=c(tt),cs=i(tt,"LI",{});var Ai=p(cs);mt=i(Ai,"P",{});var zr=p(mt);du=r(zr,"Apply the tokenizer over the entire dataset with "),ms=i(zr,"A",{href:!0,rel:!0});var D$=p(ms);uu=r(D$,"map"),D$.forEach(a),hu=r(zr," and then pass the dataset and tokenizer to "),ur=i(zr,"A",{href:!0});var I$=p(ur);gu=r(I$,"prepare_tf_dataset()"),I$.forEach(a),$u=r(zr,". You can also change the batch size and shuffle the dataset here if you\u2019d like:"),zr.forEach(a),_u=c(Ai),w(ds.$$.fragment,Ai),Ai.forEach(a),vu=c(tt),us=i(tt,"LI",{});var ji=p(us);dt=i(ji,"P",{});var qr=p(dt);ku=r(qr,"When you\u2019re ready, you can call "),wn=i(qr,"CODE",{});var N$=p(wn);wu=r(N$,"compile"),N$.forEach(a),yu=r(qr," and "),yn=i(qr,"CODE",{});var O$=p(yn);bu=r(O$,"fit"),O$.forEach(a),Tu=r(qr," to start training:"),qr.forEach(a),Eu=c(ji),w(hs.$$.fragment,ji),ji.forEach(a),tt.forEach(a),Ul=c(t),ut=i(t,"H2",{class:!0});var zi=p(ut);Ut=i(zi,"A",{id:!0,class:!0,href:!0});var L$=p(Ut);bn=i(L$,"SPAN",{});var W$=p(bn);w(gs.$$.fragment,W$),W$.forEach(a),L$.forEach(a),Au=c(zi),Tn=i(zi,"SPAN",{});var H$=p(Tn);ju=r(H$,"What's next?"),H$.forEach(a),zi.forEach(a),Gl=c(t),hr=i(t,"P",{});var R$=p(hr);zu=r(R$,"Now that you\u2019ve completed the \u{1F917} Transformers quick tour, check out our guides and learn how to do more specific things like writing a custom model, fine-tuning a model for a task, and how to train a model with a script. If you\u2019re interested in learning more about \u{1F917} Transformers core concepts, grab a cup of coffee and take a look at our Conceptual Guides!"),R$.forEach(a),this.h()},h(){h(o,"name","hf:doc:metadata"),h(o,"content",JSON.stringify(x_)),h(g,"id","quick-tour"),h(g,"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"),h(g,"href","#quick-tour"),h(n,"class","relative group"),h(q,"href","/docs/transformers/main/en/main_classes/pipelines#transformers.pipeline"),h(S,"href","./model_doc/auto"),h(V,"href","https://huggingface.co/course/chapter1/1"),h(V,"rel","nofollow"),h(x,"id","pipeline"),h(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"),h(x,"href","#pipeline"),h(Z,"class","relative group"),h(ge,"href","/docs/transformers/main/en/main_classes/pipelines#transformers.pipeline"),h(ys,"href","/docs/transformers/main/en/main_classes/pipelines#transformers.pipeline"),h(bs,"href","/docs/transformers/main/en/main_classes/pipelines#transformers.pipeline"),h(Ts,"href","/docs/transformers/main/en/main_classes/pipelines#transformers.pipeline"),h(Es,"href","./main_classes/pipelines"),h(As,"href","/docs/transformers/main/en/main_classes/pipelines#transformers.pipeline"),h(js,"href","/docs/transformers/main/en/main_classes/pipelines#transformers.pipeline"),h(pa,"href","https://huggingface.co/distilbert-base-uncased-finetuned-sst-2-english"),h(pa,"rel","nofollow"),h(zs,"href","/docs/transformers/main/en/main_classes/pipelines#transformers.pipeline"),h(qs,"href","/docs/transformers/main/en/main_classes/pipelines#transformers.pipeline"),h(da,"href","https://huggingface.co/docs/datasets/quickstart#audio"),h(da,"rel","nofollow"),h(ua,"href","https://huggingface.co/datasets/PolyAI/minds14"),h(ua,"rel","nofollow"),h(ga,"href","https://huggingface.co/facebook/wav2vec2-base-960h"),h(ga,"rel","nofollow"),h(Ps,"href","./main_classes/pipelines"),h(wt,"id","use-another-model-and-tokenizer-in-the-pipeline"),h(wt,"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"),h(wt,"href","#use-another-model-and-tokenizer-in-the-pipeline"),h(at,"class","relative group"),h(xs,"href","/docs/transformers/main/en/main_classes/pipelines#transformers.pipeline"),h(ka,"href","https://huggingface.co/models"),h(ka,"rel","nofollow"),h(Fs,"href","/docs/transformers/main/en/main_classes/pipelines#transformers.pipeline"),h(wa,"href","https://huggingface.co/nlptown/bert-base-multilingual-uncased-sentiment"),h(wa,"rel","nofollow"),h(Ms,"href","/docs/transformers/main/en/main_classes/pipelines#transformers.pipeline"),h(Cs,"href","./training"),h(Ss,"href","./model_sharing"),h(bt,"id","autoclass"),h(bt,"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"),h(bt,"href","#autoclass"),h(st,"class","relative group"),h(Ds,"href","/docs/transformers/main/en/model_doc/auto#transformers.AutoModelForSequenceClassification"),h(Is,"href","/docs/transformers/main/en/model_doc/auto#transformers.AutoTokenizer"),h(Ns,"href","/docs/transformers/main/en/main_classes/pipelines#transformers.pipeline"),h(Os,"href","./model_doc/auto"),h(Ls,"href","/docs/transformers/main/en/main_classes/pipelines#transformers.pipeline"),h(Tt,"id","autotokenizer"),h(Tt,"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"),h(Tt,"href","#autotokenizer"),h(rt,"class","relative group"),h(Ws,"href","./tokenizer_summary"),h(Hs,"href","/docs/transformers/main/en/model_doc/auto#transformers.AutoTokenizer"),h(Gs,"href","./glossary#input-ids"),h(Bs,"href",".glossary#attention-mask"),h(Pt,"id","automodel"),h(Pt,"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"),h(Pt,"href","#automodel"),h(ot,"class","relative group"),h(Mt,"id","save-a-model"),h(Mt,"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"),h(Mt,"href","#save-a-model"),h(nt,"class","relative group"),h(Dt,"id","custom-model-builds"),h(Dt,"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"),h(Dt,"href","#custom-model-builds"),h(lt,"class","relative group"),h(Js,"href","/docs/transformers/main/en/model_doc/auto#transformers.AutoConfig"),h(Zs,"href","/docs/transformers/main/en/model_doc/auto#transformers.AutoConfig.from_pretrained"),h(Xs,"href","./create_a_model"),h(Ot,"id","trainer-a-pytorch-optimized-training-loop"),h(Ot,"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"),h(Ot,"href","#trainer-a-pytorch-optimized-training-loop"),h(it,"class","relative group"),h(Ca,"href","https://pytorch.org/docs/stable/nn.html#torch.nn.Module"),h(Ca,"rel","nofollow"),h(er,"href","/docs/transformers/main/en/main_classes/trainer#transformers.Trainer"),h(tr,"href","/docs/transformers/main/en/main_classes/trainer#transformers.Trainer"),h(ar,"href","/docs/transformers/main/en/main_classes/model#transformers.PreTrainedModel"),h(Da,"href","https://pytorch.org/docs/stable/nn.html#torch.nn.Module"),h(Da,"rel","nofollow"),h(rr,"href","/docs/transformers/main/en/main_classes/trainer#transformers.TrainingArguments"),h(Ga,"href","https://huggingface.co/docs/datasets/main/en/package_reference/main_classes#datasets.Dataset.map"),h(Ga,"rel","nofollow"),h(or,"href","/docs/transformers/main/en/main_classes/data_collator#transformers.DataCollatorWithPadding"),h(nr,"href","/docs/transformers/main/en/main_classes/trainer#transformers.Trainer"),h(lr,"href","/docs/transformers/main/en/main_classes/trainer#transformers.Trainer.train"),h(ir,"href","/docs/transformers/main/en/main_classes/trainer#transformers.Trainer"),h(pr,"href","/docs/transformers/main/en/main_classes/trainer#transformers.Trainer"),h(fr,"href","./main_classes/callbacks"),h(cr,"href","/docs/transformers/main/en/main_classes/trainer#transformers.Trainer"),h(Yt,"id","train-with-tensorflow"),h(Yt,"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"),h(Yt,"href","#train-with-tensorflow"),h(ft,"class","relative group"),h(es,"href","https://www.tensorflow.org/api_docs/python/tf/keras/Model"),h(es,"rel","nofollow"),h(ts,"href","https://keras.io/"),h(ts,"rel","nofollow"),h(mr,"href","/docs/transformers/main/en/main_classes/model#transformers.TFPreTrainedModel.prepare_tf_dataset"),h(as,"href","https://keras.io/api/models/model_training_apis/#compile-method"),h(as,"rel","nofollow"),h(ss,"href","https://keras.io/api/models/model_training_apis/#fit-method"),h(ss,"rel","nofollow"),h(dr,"href","/docs/transformers/main/en/main_classes/model#transformers.TFPreTrainedModel"),h(os,"href","https://www.tensorflow.org/api_docs/python/tf/keras/Model"),h(os,"rel","nofollow"),h(ms,"href","https://huggingface.co/docs/datasets/main/en/package_reference/main_classes#datasets.Dataset.map"),h(ms,"rel","nofollow"),h(ur,"href","/docs/transformers/main/en/main_classes/model#transformers.TFPreTrainedModel.prepare_tf_dataset"),h(Ut,"id","whats-next"),h(Ut,"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"),h(Ut,"href","#whats-next"),h(ut,"class","relative group")},m(t,m){e(document.head,o),d(t,u,m),d(t,n,m),e(n,g),e(g,_),y(v,_,null),e(n,z),e(n,M),e(M,$),d(t,j,m),y(D,t,m),d(t,I,m),d(t,N,m),e(N,H),e(N,q),e(q,P),e(N,A),e(N,S),e(S,U),e(N,R),e(N,V),e(V,pe),e(N,ne),d(t,he,m),d(t,K,m),e(K,le),d(t,ie,m),y(B,t,m),d(t,$e,m),d(t,J,m),e(J,Te),d(t,_e,m),y(Q,t,m),d(t,se,m),d(t,Z,m),e(Z,x),e(x,L),y(X,L,null),e(Z,C),e(Z,W),e(W,ve),d(t,He,m),y(ae,t,m),d(t,Re,m),d(t,ee,m),e(ee,vs),e(ee,ge),e(ge,ks),e(ee,ws),e(ee,ys),e(ys,qi),e(ee,Pi),d(t,Cn,m),d(t,ht,m),e(ht,Pr),e(Pr,Ee),e(Ee,xr),e(xr,Fr),e(Fr,xi),e(Ee,Fi),e(Ee,Mr),e(Mr,Cr),e(Cr,Mi),e(Ee,Ci),e(Ee,Sr),e(Sr,Dr),e(Dr,Si),e(Ee,Di),e(Ee,Ir),e(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mr,Gd),e(te,Kd),e(te,hn),e(hn,Bd),e(te,Vd),e(te,as),e(as,gn),e(gn,Qd),e(te,Jd),e(te,ss),e(ss,$n),e($n,Zd),e(te,Xd),d(t,Yl,m),d(t,me,m),e(me,rs),e(rs,ct),e(ct,eu),e(ct,dr),e(dr,tu),e(ct,au),e(ct,os),e(os,_n),e(_n,su),e(ct,ru),e(rs,ou),y(ns,rs,null),e(me,nu),e(me,ls),e(ls,vn),e(vn,lu),e(ls,iu),y(is,ls,null),e(me,pu),e(me,ps),e(ps,kn),e(kn,fu),e(ps,cu),y(fs,ps,null),e(me,mu),e(me,cs),e(cs,mt),e(mt,du),e(mt,ms),e(ms,uu),e(mt,hu),e(mt,ur),e(ur,gu),e(mt,$u),e(cs,_u),y(ds,cs,null),e(me,vu),e(me,us),e(us,dt),e(dt,ku),e(dt,wn),e(wn,wu),e(dt,yu),e(dt,yn),e(yn,bu),e(dt,Tu),e(us,Eu),y(hs,us,null),d(t,Ul,m),d(t,ut,m),e(ut,Ut),e(Ut,bn),y(gs,bn,null),e(ut,Au),e(ut,Tn),e(Tn,ju),d(t,Gl,m),d(t,hr,m),e(hr,zu),Kl=!0},p(t,[m]){const $s={};m&2&&($s.$$scope={dirty:m,ctx:t}),Q.$set($s);const En={};m&2&&(En.$$scope={dirty:m,ctx:t}),yt.$set(En);const An={};m&2&&(An.$$scope={dirty:m,ctx:t}),zt.$set(An);const jn={};m&2&&(jn.$$scope={dirty:m,ctx:t}),qt.$set(jn);const Le={};m&2&&(Le.$$scope={dirty:m,ctx:t}),xt.$set(Le);const zn={};m&2&&(zn.$$scope={dirty:m,ctx:t}),Ft.$set(zn);const qn={};m&2&&(qn.$$scope={dirty:m,ctx:t}),Ct.$set(qn);const Pn={};m&2&&(Pn.$$scope={dirty:m,ctx:t}),St.$set(Pn);const xn={};m&2&&(xn.$$scope={dirty:m,ctx:t}),It.$set(xn);const Fn={};m&2&&(Fn.$$scope={dirty:m,ctx:t}),Rt.$set(Fn)},i(t){Kl||(b(v.$$.fragment,t),b(D.$$.fragment,t),b(B.$$.fragment,t),b(Q.$$.fragment,t),b(X.$$.fragment,t),b(ae.$$.fragment,t),b(ia.$$.fragment,t),b(fa.$$.fragment,t),b(ca.$$.fragment,t),b(ma.$$.fragment,t),b(ha.$$.fragment,t),b($a.$$.fragment,t),b(_a.$$.fragment,t),b(va.$$.fragment,t),b(ya.$$.fragment,t),b(yt.$$.fragment,t),b(ba.$$.fragment,t),b(Ta.$$.fragment,t),b(Ea.$$.fragment,t),b(Aa.$$.fragment,t),b(ja.$$.fragment,t),b(za.$$.fragment,t),b(zt.$$.fragment,t),b(qt.$$.fragment,t),b(qa.$$.fragment,t),b(xt.$$.fragment,t),b(Ft.$$.fragment,t),b(Pa.$$.fragment,t),b(Ct.$$.fragment,t),b(St.$$.fragment,t),b(xa.$$.fragment,t),b(Fa.$$.fragment,t),b(It.$$.fragment,t),b(Ma.$$.fragment,t),b(Ia.$$.fragment,t),b(Oa.$$.fragment,t),b(Wa.$$.fragment,t),b(Ra.$$.fragment,t),b(Ya.$$.fragment,t),b(Ka.$$.fragment,t),b(Qa.$$.fragment,t),b(Ja.$$.fragment,t),b(Za.$$.fragment,t),b(Rt.$$.fragment,t),b(Xa.$$.fragment,t),b(ns.$$.fragment,t),b(is.$$.fragment,t),b(fs.$$.fragment,t),b(ds.$$.fragment,t),b(hs.$$.fragment,t),b(gs.$$.fragment,t),Kl=!0)},o(t){T(v.$$.fragment,t),T(D.$$.fragment,t),T(B.$$.fragment,t),T(Q.$$.fragment,t),T(X.$$.fragment,t),T(ae.$$.fragment,t),T(ia.$$.fragment,t),T(fa.$$.fragment,t),T(ca.$$.fragment,t),T(ma.$$.fragment,t),T(ha.$$.fragment,t),T($a.$$.fragment,t),T(_a.$$.fragment,t),T(va.$$.fragment,t),T(ya.$$.fragment,t),T(yt.$$.fragment,t),T(ba.$$.fragment,t),T(Ta.$$.fragment,t),T(Ea.$$.fragment,t),T(Aa.$$.fragment,t),T(ja.$$.fragment,t),T(za.$$.fragment,t),T(zt.$$.fragment,t),T(qt.$$.fragment,t),T(qa.$$.fragment,t),T(xt.$$.fragment,t),T(Ft.$$.fragment,t),T(Pa.$$.fragment,t),T(Ct.$$.fragment,t),T(St.$$.fragment,t),T(xa.$$.fragment,t),T(Fa.$$.fragment,t),T(It.$$.fragment,t),T(Ma.$$.fragment,t),T(Ia.$$.fragment,t),T(Oa.$$.fragment,t),T(Wa.$$.fragment,t),T(Ra.$$.fragment,t),T(Ya.$$.fragment,t),T(Ka.$$.fragment,t),T(Qa.$$.fragment,t),T(Ja.$$.fragment,t),T(Za.$$.fragment,t),T(Rt.$$.fragment,t),T(Xa.$$.fragment,t),T(ns.$$.fragment,t),T(is.$$.fragment,t),T(fs.$$.fragment,t),T(ds.$$.fragment,t),T(hs.$$.fragment,t),T(gs.$$.fragment,t),Kl=!1},d(t){a(o),t&&a(u),t&&a(n),E(v),t&&a(j),E(D,t),t&&a(I),t&&a(N),t&&a(he),t&&a(K),t&&a(ie),E(B,t),t&&a($e),t&&a(J),t&&a(_e),E(Q,t),t&&a(se),t&&a(Z),E(X),t&&a(He),E(ae,t),t&&a(Re),t&&a(ee),t&&a(Cn),t&&a(ht),t&&a(Sn),t&&a(fe),t&&a(Dn),E(ia,t),t&&a(In),t&&a(ke),t&&a(Nn),E(fa,t),t&&a(On),t&&a(gt),t&&a(Ln),E(ca,t),t&&a(Wn),t&&a($t),t&&a(Hn),E(ma,t),t&&a(Rn),t&&a(Ye),t&&a(Yn),E(ha,t),t&&a(Un),t&&a(_t),t&&a(Gn),E($a,t),t&&a(Kn),t&&a(vt),t&&a(Bn),E(_a,t),t&&a(Vn),t&&a(kt),t&&a(Qn),t&&a(at),E(va),t&&a(Jn),t&&a(ce),t&&a(Zn),E(ya,t),t&&a(Xn),E(yt,t),t&&a(el),t&&a(Ue),t&&a(tl),E(ba,t),t&&a(al),t&&a(Ge),t&&a(sl),t&&a(st),E(Ta),t&&a(rl),E(Ea,t),t&&a(ol),t&&a(re),t&&a(nl),t&&a(Ke),t&&a(ll),t&&a(rt),E(Aa),t&&a(il),t&&a(Et),t&&a(pl),t&&a(At),t&&a(fl),E(ja,t),t&&a(cl),t&&a(Rs),t&&a(ml),E(za,t),t&&a(dl),t&&a(Ys),t&&a(ul),t&&a(jt),t&&a(hl),t&&a(Vs),t&&a(gl),E(zt,t),t&&a($l),E(qt,t),t&&a(_l),t&&a(ot),E(qa),t&&a(vl),E(xt,t),t&&a(kl),E(Ft,t),t&&a(wl),t&&a(nt),E(Pa),t&&a(yl),E(Ct,t),t&&a(bl),t&&a(Be),t&&a(Tl),E(St,t),t&&a(El),t&&a(lt),E(xa),t&&a(Al),t&&a(Qs),t&&a(jl),t&&a(Ve),t&&a(zl),E(Fa,t),t&&a(ql),E(It,t),t&&a(Pl),t&&a(Nt),t&&a(xl),t&&a(it),E(Ma),t&&a(Fl),t&&a(Qe),t&&a(Ml),t&&a(Lt),t&&a(Cl),t&&a(oe),E(Ia),E(Oa),E(Wa),E(Ra),E(Ya),E(Ka),E(Qa),t&&a(Sl),t&&a(Wt),t&&a(Dl),E(Ja,t),t&&a(Il),t&&a(Ht),t&&a(Nl),E(Za,t),t&&a(Ol),E(Rt,t),t&&a(Ll),t&&a(Je),t&&a(Wl),t&&a(Ze),t&&a(Hl),t&&a(ft),E(Xa),t&&a(Rl),t&&a(te),t&&a(Yl),t&&a(me),E(ns),E(is),E(fs),E(ds),E(hs),t&&a(Ul),t&&a(ut),E(gs),t&&a(Gl),t&&a(hr)}}}const x_={local:"quick-tour",sections:[{local:"pipeline",sections:[{local:"use-another-model-and-tokenizer-in-the-pipeline",title:"Use another model and tokenizer in the pipeline"}],title:"Pipeline"},{local:"autoclass",sections:[{local:"autotokenizer",title:"AutoTokenizer"},{local:"automodel",title:"AutoModel"},{local:"save-a-model",title:"Save a model"}],title:"AutoClass"},{local:"custom-model-builds",title:"Custom model builds"},{local:"trainer-a-pytorch-optimized-training-loop",title:"Trainer - a PyTorch optimized training loop"},{local:"train-with-tensorflow",title:"Train with TensorFlow"},{local:"whats-next",title:"What's next?"}],title:"Quick tour"};function F_(F){return V$(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class L_ extends U${constructor(o){super();G$(this,o,F_,P_,K$,{})}}export{L_ as default,x_ as metadata};
