import{S as s$,i as r$,s as o$,e as l,k as c,w as k,t as o,M as n$,c as i,d as a,m as u,a as p,x as w,h as n,b as h,G as e,g as m,y,q as b,o as T,B as E,v as l$,L as ye}from"../chunks/vendor-hf-doc-builder.js";import{T as Ar}from"../chunks/Tip-hf-doc-builder.js";import{Y as a$}from"../chunks/Youtube-hf-doc-builder.js";import{I as Oe}from"../chunks/IconCopyLink-hf-doc-builder.js";import{C as N}from"../chunks/CodeBlock-hf-doc-builder.js";import{D as i$}from"../chunks/DocNotebookDropdown-hf-doc-builder.js";import{F as hs,M as me}from"../chunks/Markdown-hf-doc-builder.js";function p$(F){let s,d;return s=new N({props:{code:"pip install torch",highlighted:"pip install torch"}}),{c(){k(s.$$.fragment)},l(r){w(s.$$.fragment,r)},m(r,g){y(s,r,g),d=!0},p:ye,i(r){d||(b(s.$$.fragment,r),d=!0)},o(r){T(s.$$.fragment,r),d=!1},d(r){E(s,r)}}}function f$(F){let s,d;return s=new me({props:{$$slots:{default:[p$]},$$scope:{ctx:F}}}),{c(){k(s.$$.fragment)},l(r){w(s.$$.fragment,r)},m(r,g){y(s,r,g),d=!0},p(r,g){const _={};g&2&&(_.$$scope={dirty:g,ctx:r}),s.$set(_)},i(r){d||(b(s.$$.fragment,r),d=!0)},o(r){T(s.$$.fragment,r),d=!1},d(r){E(s,r)}}}function c$(F){let s,d;return s=new N({props:{code:"pip install tensorflow",highlighted:"pip install tensorflow"}}),{c(){k(s.$$.fragment)},l(r){w(s.$$.fragment,r)},m(r,g){y(s,r,g),d=!0},p:ye,i(r){d||(b(s.$$.fragment,r),d=!0)},o(r){T(s.$$.fragment,r),d=!1},d(r){E(s,r)}}}function u$(F){let s,d;return s=new me({props:{$$slots:{default:[c$]},$$scope:{ctx:F}}}),{c(){k(s.$$.fragment)},l(r){w(s.$$.fragment,r)},m(r,g){y(s,r,g),d=!0},p(r,g){const _={};g&2&&(_.$$scope={dirty:g,ctx:r}),s.$set(_)},i(r){d||(b(s.$$.fragment,r),d=!0)},o(r){T(s.$$.fragment,r),d=!1},d(r){E(s,r)}}}function m$(F){let s,d,r,g,_;return{c(){s=l("p"),d=o("For a complete list of available tasks, check out the "),r=l("a"),g=o("pipeline API reference"),_=o("."),this.h()},l(v){s=i(v,"P",{});var j=p(s);d=n(j,"For a complete list of available tasks, check out the "),r=i(j,"A",{href:!0});var M=p(r);g=n(M,"pipeline API reference"),M.forEach(a),_=n(j,"."),j.forEach(a),this.h()},h(){h(r,"href","./main_classes/pipelines")},m(v,j){m(v,s,j),e(s,d),e(s,r),e(r,g),e(s,_)},d(v){v&&a(s)}}}function d$(F){let s,d,r,g,_,v,j,M,$,z,D,I,O,L;return O=new N({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(){s=l("p"),d=o("Use "),r=l("a"),g=o("AutoModelForSequenceClassification"),_=o(" and "),v=l("a"),j=o("AutoTokenizer"),M=o(" to load the pretrained model and it\u2019s associated tokenizer (more on an "),$=l("code"),z=o("AutoClass"),D=o(" in the next section):"),I=c(),k(O.$$.fragment),this.h()},l(q){s=i(q,"P",{});var P=p(s);d=n(P,"Use "),r=i(P,"A",{href:!0});var A=p(r);g=n(A,"AutoModelForSequenceClassification"),A.forEach(a),_=n(P," and "),v=i(P,"A",{href:!0});var S=p(v);j=n(S,"AutoTokenizer"),S.forEach(a),M=n(P," to load the pretrained model and it\u2019s associated tokenizer (more on an "),$=i(P,"CODE",{});var Y=p($);z=n(Y,"AutoClass"),Y.forEach(a),D=n(P," in the next section):"),P.forEach(a),I=u(q),w(O.$$.fragment,q),this.h()},h(){h(r,"href","/docs/transformers/v4.29.0/en/model_doc/auto#transformers.AutoModelForSequenceClassification"),h(v,"href","/docs/transformers/v4.29.0/en/model_doc/auto#transformers.AutoTokenizer")},m(q,P){m(q,s,P),e(s,d),e(s,r),e(r,g),e(s,_),e(s,v),e(v,j),e(s,M),e(s,$),e($,z),e(s,D),m(q,I,P),y(O,q,P),L=!0},p:ye,i(q){L||(b(O.$$.fragment,q),L=!0)},o(q){T(O.$$.fragment,q),L=!1},d(q){q&&a(s),q&&a(I),E(O,q)}}}function h$(F){let s,d;return s=new me({props:{$$slots:{default:[d$]},$$scope:{ctx:F}}}),{c(){k(s.$$.fragment)},l(r){w(s.$$.fragment,r)},m(r,g){y(s,r,g),d=!0},p(r,g){const _={};g&2&&(_.$$scope={dirty:g,ctx:r}),s.$set(_)},i(r){d||(b(s.$$.fragment,r),d=!0)},o(r){T(s.$$.fragment,r),d=!1},d(r){E(s,r)}}}function g$(F){let s,d,r,g,_,v,j,M,$,z,D,I,O,L;return O=new N({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(){s=l("p"),d=o("Use "),r=l("a"),g=o("TFAutoModelForSequenceClassification"),_=o(" and "),v=l("a"),j=o("AutoTokenizer"),M=o(" to load the pretrained model and it\u2019s associated tokenizer (more on an "),$=l("code"),z=o("TFAutoClass"),D=o(" in the next section):"),I=c(),k(O.$$.fragment),this.h()},l(q){s=i(q,"P",{});var P=p(s);d=n(P,"Use "),r=i(P,"A",{href:!0});var A=p(r);g=n(A,"TFAutoModelForSequenceClassification"),A.forEach(a),_=n(P," and "),v=i(P,"A",{href:!0});var S=p(v);j=n(S,"AutoTokenizer"),S.forEach(a),M=n(P," to load the pretrained model and it\u2019s associated tokenizer (more on an "),$=i(P,"CODE",{});var Y=p($);z=n(Y,"TFAutoClass"),Y.forEach(a),D=n(P," in the next section):"),P.forEach(a),I=u(q),w(O.$$.fragment,q),this.h()},h(){h(r,"href","/docs/transformers/v4.29.0/en/model_doc/auto#transformers.TFAutoModelForSequenceClassification"),h(v,"href","/docs/transformers/v4.29.0/en/model_doc/auto#transformers.AutoTokenizer")},m(q,P){m(q,s,P),e(s,d),e(s,r),e(r,g),e(s,_),e(s,v),e(v,j),e(s,M),e(s,$),e($,z),e(s,D),m(q,I,P),y(O,q,P),L=!0},p:ye,i(q){L||(b(O.$$.fragment,q),L=!0)},o(q){T(O.$$.fragment,q),L=!1},d(q){q&&a(s),q&&a(I),E(O,q)}}}function $$(F){let s,d;return s=new me({props:{$$slots:{default:[g$]},$$scope:{ctx:F}}}),{c(){k(s.$$.fragment)},l(r){w(s.$$.fragment,r)},m(r,g){y(s,r,g),d=!0},p(r,g){const _={};g&2&&(_.$$scope={dirty:g,ctx:r}),s.$set(_)},i(r){d||(b(s.$$.fragment,r),d=!0)},o(r){T(s.$$.fragment,r),d=!1},d(r){E(s,r)}}}function _$(F){let s,d;return s=new N({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(s.$$.fragment)},l(r){w(s.$$.fragment,r)},m(r,g){y(s,r,g),d=!0},p:ye,i(r){d||(b(s.$$.fragment,r),d=!0)},o(r){T(s.$$.fragment,r),d=!1},d(r){E(s,r)}}}function v$(F){let s,d;return s=new me({props:{$$slots:{default:[_$]},$$scope:{ctx:F}}}),{c(){k(s.$$.fragment)},l(r){w(s.$$.fragment,r)},m(r,g){y(s,r,g),d=!0},p(r,g){const _={};g&2&&(_.$$scope={dirty:g,ctx:r}),s.$set(_)},i(r){d||(b(s.$$.fragment,r),d=!0)},o(r){T(s.$$.fragment,r),d=!1},d(r){E(s,r)}}}function k$(F){let s,d;return s=new N({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(s.$$.fragment)},l(r){w(s.$$.fragment,r)},m(r,g){y(s,r,g),d=!0},p:ye,i(r){d||(b(s.$$.fragment,r),d=!0)},o(r){T(s.$$.fragment,r),d=!1},d(r){E(s,r)}}}function w$(F){let s,d;return s=new me({props:{$$slots:{default:[k$]},$$scope:{ctx:F}}}),{c(){k(s.$$.fragment)},l(r){w(s.$$.fragment,r)},m(r,g){y(s,r,g),d=!0},p(r,g){const _={};g&2&&(_.$$scope={dirty:g,ctx:r}),s.$set(_)},i(r){d||(b(s.$$.fragment,r),d=!0)},o(r){T(s.$$.fragment,r),d=!1},d(r){E(s,r)}}}function y$(F){let s,d,r,g,_,v,j,M,$,z,D,I,O,L;return{c(){s=l("p"),d=o("Check out the "),r=l("a"),g=o("preprocess"),_=o(" tutorial for more details about tokenization, and how to use an "),v=l("a"),j=o("AutoImageProcessor"),M=o(", "),$=l("a"),z=o("AutoFeatureExtractor"),D=o(" and "),I=l("a"),O=o("AutoProcessor"),L=o(" to preprocess image, audio, and multimodal inputs."),this.h()},l(q){s=i(q,"P",{});var P=p(s);d=n(P,"Check out the "),r=i(P,"A",{href:!0});var A=p(r);g=n(A,"preprocess"),A.forEach(a),_=n(P," tutorial for more details about tokenization, and how to use an "),v=i(P,"A",{href:!0});var S=p(v);j=n(S,"AutoImageProcessor"),S.forEach(a),M=n(P,", "),$=i(P,"A",{href:!0});var Y=p($);z=n(Y,"AutoFeatureExtractor"),Y.forEach(a),D=n(P," and "),I=i(P,"A",{href:!0});var R=p(I);O=n(R,"AutoProcessor"),R.forEach(a),L=n(P," to preprocess image, audio, and multimodal inputs."),P.forEach(a),this.h()},h(){h(r,"href","./preprocessing"),h(v,"href","/docs/transformers/v4.29.0/en/model_doc/auto#transformers.AutoImageProcessor"),h($,"href","/docs/transformers/v4.29.0/en/model_doc/auto#transformers.AutoFeatureExtractor"),h(I,"href","/docs/transformers/v4.29.0/en/model_doc/auto#transformers.AutoProcessor")},m(q,P){m(q,s,P),e(s,d),e(s,r),e(r,g),e(s,_),e(s,v),e(v,j),e(s,M),e(s,$),e($,z),e(s,D),e(s,I),e(I,O),e(s,L)},d(q){q&&a(s)}}}function b$(F){let s,d,r,g,_,v,j,M;return{c(){s=l("p"),d=o("See the "),r=l("a"),g=o("task summary"),_=o(" for tasks supported by an "),v=l("a"),j=o("AutoModel"),M=o(" class."),this.h()},l($){s=i($,"P",{});var z=p(s);d=n(z,"See the "),r=i(z,"A",{href:!0});var D=p(r);g=n(D,"task summary"),D.forEach(a),_=n(z," for tasks supported by an "),v=i(z,"A",{href:!0});var I=p(v);j=n(I,"AutoModel"),I.forEach(a),M=n(z," class."),z.forEach(a),this.h()},h(){h(r,"href","./task_summary"),h(v,"href","/docs/transformers/v4.29.0/en/model_doc/auto#transformers.AutoModel")},m($,z){m($,s,z),e(s,d),e(s,r),e(r,g),e(s,_),e(s,v),e(v,j),e(s,M)},d($){$&&a(s)}}}function T$(F){let s,d,r,g,_,v,j,M,$,z,D,I,O,L,q,P,A,S,Y,R,V,pe,ne,de,G,le,ie,K,ge,Q,be,$e,J,se,Z,x,W,X;return P=new N({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 Ar({props:{$$slots:{default:[b$]},$$scope:{ctx:F}}}),le=new N({props:{code:"pt_outputs = pt_model(**pt_batch)",highlighted:'<span class="hljs-meta">&gt;&gt;&gt; </span>pt_outputs = pt_model(**pt_batch)'}}),W=new N({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(){s=l("p"),d=o("\u{1F917} Transformers provides a simple and unified way to load pretrained instances. This means you can load an "),r=l("a"),g=o("AutoModel"),_=o(" like you would load an "),v=l("a"),j=o("AutoTokenizer"),M=o(". The only difference is selecting the correct "),$=l("a"),z=o("AutoModel"),D=o(" for the task. For text (or sequence) classification, you should load "),I=l("a"),O=o("AutoModelForSequenceClassification"),L=o(":"),q=c(),k(P.$$.fragment),A=c(),k(S.$$.fragment),Y=c(),R=l("p"),V=o("Now pass your preprocessed batch of inputs directly to the model. You just have to unpack the dictionary by adding "),pe=l("code"),ne=o("**"),de=o(":"),G=c(),k(le.$$.fragment),ie=c(),K=l("p"),ge=o("The model outputs the final activations in the "),Q=l("code"),be=o("logits"),$e=o(" attribute. Apply the softmax function to the "),J=l("code"),se=o("logits"),Z=o(" to retrieve the probabilities:"),x=c(),k(W.$$.fragment),this.h()},l(C){s=i(C,"P",{});var H=p(s);d=n(H,"\u{1F917} Transformers provides a simple and unified way to load pretrained instances. This means you can load an "),r=i(H,"A",{href:!0});var _e=p(r);g=n(_e,"AutoModel"),_e.forEach(a),_=n(H," like you would load an "),v=i(H,"A",{href:!0});var Ne=p(v);j=n(Ne,"AutoTokenizer"),Ne.forEach(a),M=n(H,". The only difference is selecting the correct "),$=i(H,"A",{href:!0});var ae=p($);z=n(ae,"AutoModel"),ae.forEach(a),D=n(H," for the task. For text (or sequence) classification, you should load "),I=i(H,"A",{href:!0});var We=p(I);O=n(We,"AutoModelForSequenceClassification"),We.forEach(a),L=n(H,":"),H.forEach(a),q=u(C),w(P.$$.fragment,C),A=u(C),w(S.$$.fragment,C),Y=u(C),R=i(C,"P",{});var ee=p(R);V=n(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 gs=p(pe);ne=n(gs,"**"),gs.forEach(a),de=n(ee,":"),ee.forEach(a),G=u(C),w(le.$$.fragment,C),ie=u(C),K=i(C,"P",{});var he=p(K);ge=n(he,"The model outputs the final activations in the "),Q=i(he,"CODE",{});var $s=p(Q);be=n($s,"logits"),$s.forEach(a),$e=n(he," attribute. Apply the softmax function to the "),J=i(he,"CODE",{});var _s=p(J);se=n(_s,"logits"),_s.forEach(a),Z=n(he," to retrieve the probabilities:"),he.forEach(a),x=u(C),w(W.$$.fragment,C),this.h()},h(){h(r,"href","/docs/transformers/v4.29.0/en/model_doc/auto#transformers.AutoModel"),h(v,"href","/docs/transformers/v4.29.0/en/model_doc/auto#transformers.AutoTokenizer"),h($,"href","/docs/transformers/v4.29.0/en/model_doc/auto#transformers.AutoModel"),h(I,"href","/docs/transformers/v4.29.0/en/model_doc/auto#transformers.AutoModelForSequenceClassification")},m(C,H){m(C,s,H),e(s,d),e(s,r),e(r,g),e(s,_),e(s,v),e(v,j),e(s,M),e(s,$),e($,z),e(s,D),e(s,I),e(I,O),e(s,L),m(C,q,H),y(P,C,H),m(C,A,H),y(S,C,H),m(C,Y,H),m(C,R,H),e(R,V),e(R,pe),e(pe,ne),e(R,de),m(C,G,H),y(le,C,H),m(C,ie,H),m(C,K,H),e(K,ge),e(K,Q),e(Q,be),e(K,$e),e(K,J),e(J,se),e(K,Z),m(C,x,H),y(W,C,H),X=!0},p(C,H){const _e={};H&2&&(_e.$$scope={dirty:H,ctx:C}),S.$set(_e)},i(C){X||(b(P.$$.fragment,C),b(S.$$.fragment,C),b(le.$$.fragment,C),b(W.$$.fragment,C),X=!0)},o(C){T(P.$$.fragment,C),T(S.$$.fragment,C),T(le.$$.fragment,C),T(W.$$.fragment,C),X=!1},d(C){C&&a(s),C&&a(q),E(P,C),C&&a(A),E(S,C),C&&a(Y),C&&a(R),C&&a(G),E(le,C),C&&a(ie),C&&a(K),C&&a(x),E(W,C)}}}function E$(F){let s,d;return s=new me({props:{$$slots:{default:[T$]},$$scope:{ctx:F}}}),{c(){k(s.$$.fragment)},l(r){w(s.$$.fragment,r)},m(r,g){y(s,r,g),d=!0},p(r,g){const _={};g&2&&(_.$$scope={dirty:g,ctx:r}),s.$set(_)},i(r){d||(b(s.$$.fragment,r),d=!0)},o(r){T(s.$$.fragment,r),d=!1},d(r){E(s,r)}}}function A$(F){let s,d,r,g,_,v,j,M;return{c(){s=l("p"),d=o("See the "),r=l("a"),g=o("task summary"),_=o(" for tasks supported by an "),v=l("a"),j=o("AutoModel"),M=o(" class."),this.h()},l($){s=i($,"P",{});var z=p(s);d=n(z,"See the "),r=i(z,"A",{href:!0});var D=p(r);g=n(D,"task summary"),D.forEach(a),_=n(z," for tasks supported by an "),v=i(z,"A",{href:!0});var I=p(v);j=n(I,"AutoModel"),I.forEach(a),M=n(z," class."),z.forEach(a),this.h()},h(){h(r,"href","./task_summary"),h(v,"href","/docs/transformers/v4.29.0/en/model_doc/auto#transformers.AutoModel")},m($,z){m($,s,z),e(s,d),e(s,r),e(r,g),e(s,_),e(s,v),e(v,j),e(s,M)},d($){$&&a(s)}}}function j$(F){let s,d,r,g,_,v,j,M,$,z,D,I,O,L,q,P,A,S,Y,R,V,pe,ne,de,G,le,ie,K,ge,Q,be,$e,J,se,Z;return P=new N({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 Ar({props:{$$slots:{default:[A$]},$$scope:{ctx:F}}}),ne=new N({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 N({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(){s=l("p"),d=o("\u{1F917} Transformers provides a simple and unified way to load pretrained instances. This means you can load an "),r=l("a"),g=o("TFAutoModel"),_=o(" like you would load an "),v=l("a"),j=o("AutoTokenizer"),M=o(". The only difference is selecting the correct "),$=l("a"),z=o("TFAutoModel"),D=o(" for the task. For text (or sequence) classification, you should load "),I=l("a"),O=o("TFAutoModelForSequenceClassification"),L=o(":"),q=c(),k(P.$$.fragment),A=c(),k(S.$$.fragment),Y=c(),R=l("p"),V=o("Now pass your preprocessed batch of inputs directly to the model by passing the dictionary keys directly to the tensors:"),pe=c(),k(ne.$$.fragment),de=c(),G=l("p"),le=o("The model outputs the final activations in the "),ie=l("code"),K=o("logits"),ge=o(" attribute. Apply the softmax function to the "),Q=l("code"),be=o("logits"),$e=o(" to retrieve the probabilities:"),J=c(),k(se.$$.fragment),this.h()},l(x){s=i(x,"P",{});var W=p(s);d=n(W,"\u{1F917} Transformers provides a simple and unified way to load pretrained instances. This means you can load an "),r=i(W,"A",{href:!0});var X=p(r);g=n(X,"TFAutoModel"),X.forEach(a),_=n(W," like you would load an "),v=i(W,"A",{href:!0});var C=p(v);j=n(C,"AutoTokenizer"),C.forEach(a),M=n(W,". The only difference is selecting the correct "),$=i(W,"A",{href:!0});var H=p($);z=n(H,"TFAutoModel"),H.forEach(a),D=n(W," for the task. For text (or sequence) classification, you should load "),I=i(W,"A",{href:!0});var _e=p(I);O=n(_e,"TFAutoModelForSequenceClassification"),_e.forEach(a),L=n(W,":"),W.forEach(a),q=u(x),w(P.$$.fragment,x),A=u(x),w(S.$$.fragment,x),Y=u(x),R=i(x,"P",{});var Ne=p(R);V=n(Ne,"Now pass your preprocessed batch of inputs directly to the model by passing the dictionary keys directly to the tensors:"),Ne.forEach(a),pe=u(x),w(ne.$$.fragment,x),de=u(x),G=i(x,"P",{});var ae=p(G);le=n(ae,"The model outputs the final activations in the "),ie=i(ae,"CODE",{});var We=p(ie);K=n(We,"logits"),We.forEach(a),ge=n(ae," attribute. Apply the softmax function to the "),Q=i(ae,"CODE",{});var ee=p(Q);be=n(ee,"logits"),ee.forEach(a),$e=n(ae," to retrieve the probabilities:"),ae.forEach(a),J=u(x),w(se.$$.fragment,x),this.h()},h(){h(r,"href","/docs/transformers/v4.29.0/en/model_doc/auto#transformers.TFAutoModel"),h(v,"href","/docs/transformers/v4.29.0/en/model_doc/auto#transformers.AutoTokenizer"),h($,"href","/docs/transformers/v4.29.0/en/model_doc/auto#transformers.TFAutoModel"),h(I,"href","/docs/transformers/v4.29.0/en/model_doc/auto#transformers.TFAutoModelForSequenceClassification")},m(x,W){m(x,s,W),e(s,d),e(s,r),e(r,g),e(s,_),e(s,v),e(v,j),e(s,M),e(s,$),e($,z),e(s,D),e(s,I),e(I,O),e(s,L),m(x,q,W),y(P,x,W),m(x,A,W),y(S,x,W),m(x,Y,W),m(x,R,W),e(R,V),m(x,pe,W),y(ne,x,W),m(x,de,W),m(x,G,W),e(G,le),e(G,ie),e(ie,K),e(G,ge),e(G,Q),e(Q,be),e(G,$e),m(x,J,W),y(se,x,W),Z=!0},p(x,W){const X={};W&2&&(X.$$scope={dirty:W,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(s),x&&a(q),E(P,x),x&&a(A),E(S,x),x&&a(Y),x&&a(R),x&&a(pe),E(ne,x),x&&a(de),x&&a(G),x&&a(J),E(se,x)}}}function z$(F){let s,d;return s=new me({props:{$$slots:{default:[j$]},$$scope:{ctx:F}}}),{c(){k(s.$$.fragment)},l(r){w(s.$$.fragment,r)},m(r,g){y(s,r,g),d=!0},p(r,g){const _={};g&2&&(_.$$scope={dirty:g,ctx:r}),s.$set(_)},i(r){d||(b(s.$$.fragment,r),d=!0)},o(r){T(s.$$.fragment,r),d=!1},d(r){E(s,r)}}}function q$(F){let s,d,r,g,_;return{c(){s=l("p"),d=o("All \u{1F917} Transformers models (PyTorch or TensorFlow) output the tensors "),r=l("em"),g=o("before"),_=o(` 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){s=i(v,"P",{});var j=p(s);d=n(j,"All \u{1F917} Transformers models (PyTorch or TensorFlow) output the tensors "),r=i(j,"EM",{});var M=p(r);g=n(M,"before"),M.forEach(a),_=n(j,` 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.`),j.forEach(a)},m(v,j){m(v,s,j),e(s,d),e(s,r),e(r,g),e(s,_)},d(v){v&&a(s)}}}function P$(F){let s,d,r,g,_,v,j,M,$,z,D,I,O,L,q,P;return j=new N({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 N({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(){s=l("p"),d=o("Once your model is fine-tuned, you can save it with its tokenizer using "),r=l("a"),g=o("PreTrainedModel.save_pretrained()"),_=o(":"),v=c(),k(j.$$.fragment),M=c(),$=l("p"),z=o("When you are ready to use the model again, reload it with "),D=l("a"),I=o("PreTrainedModel.from_pretrained()"),O=o(":"),L=c(),k(q.$$.fragment),this.h()},l(A){s=i(A,"P",{});var S=p(s);d=n(S,"Once your model is fine-tuned, you can save it with its tokenizer using "),r=i(S,"A",{href:!0});var Y=p(r);g=n(Y,"PreTrainedModel.save_pretrained()"),Y.forEach(a),_=n(S,":"),S.forEach(a),v=u(A),w(j.$$.fragment,A),M=u(A),$=i(A,"P",{});var R=p($);z=n(R,"When you are ready to use the model again, reload it with "),D=i(R,"A",{href:!0});var V=p(D);I=n(V,"PreTrainedModel.from_pretrained()"),V.forEach(a),O=n(R,":"),R.forEach(a),L=u(A),w(q.$$.fragment,A),this.h()},h(){h(r,"href","/docs/transformers/v4.29.0/en/main_classes/model#transformers.PreTrainedModel.save_pretrained"),h(D,"href","/docs/transformers/v4.29.0/en/main_classes/model#transformers.PreTrainedModel.from_pretrained")},m(A,S){m(A,s,S),e(s,d),e(s,r),e(r,g),e(s,_),m(A,v,S),y(j,A,S),m(A,M,S),m(A,$,S),e($,z),e($,D),e(D,I),e($,O),m(A,L,S),y(q,A,S),P=!0},p:ye,i(A){P||(b(j.$$.fragment,A),b(q.$$.fragment,A),P=!0)},o(A){T(j.$$.fragment,A),T(q.$$.fragment,A),P=!1},d(A){A&&a(s),A&&a(v),E(j,A),A&&a(M),A&&a($),A&&a(L),E(q,A)}}}function x$(F){let s,d;return s=new me({props:{$$slots:{default:[P$]},$$scope:{ctx:F}}}),{c(){k(s.$$.fragment)},l(r){w(s.$$.fragment,r)},m(r,g){y(s,r,g),d=!0},p(r,g){const _={};g&2&&(_.$$scope={dirty:g,ctx:r}),s.$set(_)},i(r){d||(b(s.$$.fragment,r),d=!0)},o(r){T(s.$$.fragment,r),d=!1},d(r){E(s,r)}}}function F$(F){let s,d,r,g,_,v,j,M,$,z,D,I,O,L,q,P;return j=new N({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 N({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(){s=l("p"),d=o("Once your model is fine-tuned, you can save it with its tokenizer using "),r=l("a"),g=o("TFPreTrainedModel.save_pretrained()"),_=o(":"),v=c(),k(j.$$.fragment),M=c(),$=l("p"),z=o("When you are ready to use the model again, reload it with "),D=l("a"),I=o("TFPreTrainedModel.from_pretrained()"),O=o(":"),L=c(),k(q.$$.fragment),this.h()},l(A){s=i(A,"P",{});var S=p(s);d=n(S,"Once your model is fine-tuned, you can save it with its tokenizer using "),r=i(S,"A",{href:!0});var Y=p(r);g=n(Y,"TFPreTrainedModel.save_pretrained()"),Y.forEach(a),_=n(S,":"),S.forEach(a),v=u(A),w(j.$$.fragment,A),M=u(A),$=i(A,"P",{});var R=p($);z=n(R,"When you are ready to use the model again, reload it with "),D=i(R,"A",{href:!0});var V=p(D);I=n(V,"TFPreTrainedModel.from_pretrained()"),V.forEach(a),O=n(R,":"),R.forEach(a),L=u(A),w(q.$$.fragment,A),this.h()},h(){h(r,"href","/docs/transformers/v4.29.0/en/main_classes/model#transformers.TFPreTrainedModel.save_pretrained"),h(D,"href","/docs/transformers/v4.29.0/en/main_classes/model#transformers.TFPreTrainedModel.from_pretrained")},m(A,S){m(A,s,S),e(s,d),e(s,r),e(r,g),e(s,_),m(A,v,S),y(j,A,S),m(A,M,S),m(A,$,S),e($,z),e($,D),e(D,I),e($,O),m(A,L,S),y(q,A,S),P=!0},p:ye,i(A){P||(b(j.$$.fragment,A),b(q.$$.fragment,A),P=!0)},o(A){T(j.$$.fragment,A),T(q.$$.fragment,A),P=!1},d(A){A&&a(s),A&&a(v),E(j,A),A&&a(M),A&&a($),A&&a(L),E(q,A)}}}function M$(F){let s,d;return s=new me({props:{$$slots:{default:[F$]},$$scope:{ctx:F}}}),{c(){k(s.$$.fragment)},l(r){w(s.$$.fragment,r)},m(r,g){y(s,r,g),d=!0},p(r,g){const _={};g&2&&(_.$$scope={dirty:g,ctx:r}),s.$set(_)},i(r){d||(b(s.$$.fragment,r),d=!0)},o(r){T(s.$$.fragment,r),d=!1},d(r){E(s,r)}}}function C$(F){let s,d;return s=new N({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(s.$$.fragment)},l(r){w(s.$$.fragment,r)},m(r,g){y(s,r,g),d=!0},p:ye,i(r){d||(b(s.$$.fragment,r),d=!0)},o(r){T(s.$$.fragment,r),d=!1},d(r){E(s,r)}}}function S$(F){let s,d;return s=new me({props:{$$slots:{default:[C$]},$$scope:{ctx:F}}}),{c(){k(s.$$.fragment)},l(r){w(s.$$.fragment,r)},m(r,g){y(s,r,g),d=!0},p(r,g){const _={};g&2&&(_.$$scope={dirty:g,ctx:r}),s.$set(_)},i(r){d||(b(s.$$.fragment,r),d=!0)},o(r){T(s.$$.fragment,r),d=!1},d(r){E(s,r)}}}function D$(F){let s,d;return s=new N({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(s.$$.fragment)},l(r){w(s.$$.fragment,r)},m(r,g){y(s,r,g),d=!0},p:ye,i(r){d||(b(s.$$.fragment,r),d=!0)},o(r){T(s.$$.fragment,r),d=!1},d(r){E(s,r)}}}function I$(F){let s,d;return s=new me({props:{$$slots:{default:[D$]},$$scope:{ctx:F}}}),{c(){k(s.$$.fragment)},l(r){w(s.$$.fragment,r)},m(r,g){y(s,r,g),d=!0},p(r,g){const _={};g&2&&(_.$$scope={dirty:g,ctx:r}),s.$set(_)},i(r){d||(b(s.$$.fragment,r),d=!0)},o(r){T(s.$$.fragment,r),d=!1},d(r){E(s,r)}}}function O$(F){let s,d,r,g,_,v,j,M;return j=new N({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(){s=l("p"),d=o("Create a model from your custom configuration with "),r=l("a"),g=o("AutoModel.from_config()"),_=o(":"),v=c(),k(j.$$.fragment),this.h()},l($){s=i($,"P",{});var z=p(s);d=n(z,"Create a model from your custom configuration with "),r=i(z,"A",{href:!0});var D=p(r);g=n(D,"AutoModel.from_config()"),D.forEach(a),_=n(z,":"),z.forEach(a),v=u($),w(j.$$.fragment,$),this.h()},h(){h(r,"href","/docs/transformers/v4.29.0/en/model_doc/auto#transformers.FlaxAutoModelForVision2Seq.from_config")},m($,z){m($,s,z),e(s,d),e(s,r),e(r,g),e(s,_),m($,v,z),y(j,$,z),M=!0},p:ye,i($){M||(b(j.$$.fragment,$),M=!0)},o($){T(j.$$.fragment,$),M=!1},d($){$&&a(s),$&&a(v),E(j,$)}}}function N$(F){let s,d;return s=new me({props:{$$slots:{default:[O$]},$$scope:{ctx:F}}}),{c(){k(s.$$.fragment)},l(r){w(s.$$.fragment,r)},m(r,g){y(s,r,g),d=!0},p(r,g){const _={};g&2&&(_.$$scope={dirty:g,ctx:r}),s.$set(_)},i(r){d||(b(s.$$.fragment,r),d=!0)},o(r){T(s.$$.fragment,r),d=!1},d(r){E(s,r)}}}function W$(F){let s,d,r,g,_,v,j,M;return j=new N({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(){s=l("p"),d=o("Create a model from your custom configuration with "),r=l("a"),g=o("TFAutoModel.from_config()"),_=o(":"),v=c(),k(j.$$.fragment),this.h()},l($){s=i($,"P",{});var z=p(s);d=n(z,"Create a model from your custom configuration with "),r=i(z,"A",{href:!0});var D=p(r);g=n(D,"TFAutoModel.from_config()"),D.forEach(a),_=n(z,":"),z.forEach(a),v=u($),w(j.$$.fragment,$),this.h()},h(){h(r,"href","/docs/transformers/v4.29.0/en/model_doc/auto#transformers.FlaxAutoModelForVision2Seq.from_config")},m($,z){m($,s,z),e(s,d),e(s,r),e(r,g),e(s,_),m($,v,z),y(j,$,z),M=!0},p:ye,i($){M||(b(j.$$.fragment,$),M=!0)},o($){T(j.$$.fragment,$),M=!1},d($){$&&a(s),$&&a(v),E(j,$)}}}function H$(F){let s,d;return s=new me({props:{$$slots:{default:[W$]},$$scope:{ctx:F}}}),{c(){k(s.$$.fragment)},l(r){w(s.$$.fragment,r)},m(r,g){y(s,r,g),d=!0},p(r,g){const _={};g&2&&(_.$$scope={dirty:g,ctx:r}),s.$set(_)},i(r){d||(b(s.$$.fragment,r),d=!0)},o(r){T(s.$$.fragment,r),d=!1},d(r){E(s,r)}}}function L$(F){let s,d,r,g,_,v,j,M;return{c(){s=l("p"),d=o("For tasks - like translation or summarization - that use a sequence-to-sequence model, use the "),r=l("a"),g=o("Seq2SeqTrainer"),_=o(" and "),v=l("a"),j=o("Seq2SeqTrainingArguments"),M=o(" classes instead."),this.h()},l($){s=i($,"P",{});var z=p(s);d=n(z,"For tasks - like translation or summarization - that use a sequence-to-sequence model, use the "),r=i(z,"A",{href:!0});var D=p(r);g=n(D,"Seq2SeqTrainer"),D.forEach(a),_=n(z," and "),v=i(z,"A",{href:!0});var I=p(v);j=n(I,"Seq2SeqTrainingArguments"),I.forEach(a),M=n(z," classes instead."),z.forEach(a),this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,Ku,El,Ka,Al,Wt,Bu,ar,Vu,Ju,jl,Ba,zl,Ht,ql,Ve,Qu,sr,Zu,Xu,rr,em,tm,Pl,Je,am,or,sm,rm,nr,om,nm,xl,lt,Lt,en,Va,lm,tn,im,Fl,te,pm,Ja,an,fm,cm,Qa,um,mm,lr,dm,hm,sn,gm,$m,Za,rn,_m,vm,Xa,on,km,wm,Ml,ce,es,it,ym,ir,bm,Tm,ts,nn,Em,Am,jm,as,zm,ss,ln,qm,Pm,rs,xm,os,pn,Fm,Mm,ns,Cm,ls,pt,Sm,is,Dm,Im,pr,Om,Nm,Wm,ps,Hm,fs,ft,Lm,fn,Rm,Ym,cn,Um,Gm,Km,cs,Cl,ct,Rt,un,us,Bm,mn,Vm,Sl,fr,Jm,Dl;return v=new Oe({}),D=new i$({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"}]}}),K=new N({props:{code:"!pip install transformers datasets",highlighted:"!pip install transformers datasets"}}),J=new hs({props:{pytorch:!0,tensorflow:!0,jax:!1,$$slots:{tensorflow:[u$],pytorch:[f$]},$$scope:{ctx:F}}}),X=new Oe({}),ae=new a$({props:{id:"tiZFewofSLM"}}),ut=new Ar({props:{$$slots:{default:[m$]},$$scope:{ctx:F}}}),ra=new N({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>)`}}),na=new N({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>}]`}}),la=new N({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>`}}),ia=new N({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>)`}}),ca=new N({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>)`}}),ma=new N({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))'}}),da=new N({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;FONDERING HOW I&#x27;D SET UP A JOIN TO HELL T 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 APSO 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 AN 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 FURN A JOINA COUT&#x27;</span>]`}}),ha=new Oe({}),_a=new N({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>'}}),kt=new hs({props:{pytorch:!0,tensorflow:!0,jax:!1,$$slots:{tensorflow:[$$],pytorch:[h$]},$$scope:{ctx:F}}}),va=new N({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>}]`}}),ka=new Oe({}),wa=new a$({props:{id:"AhChOFRegn4"}}),ya=new Oe({}),ba=new N({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)`}}),Ta=new N({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>]}`}}),At=new hs({props:{pytorch:!0,tensorflow:!0,jax:!1,$$slots:{tensorflow:[w$],pytorch:[v$]},$$scope:{ctx:F}}}),jt=new Ar({props:{$$slots:{default:[y$]},$$scope:{ctx:F}}}),Ea=new Oe({}),qt=new hs({props:{pytorch:!0,tensorflow:!0,jax:!1,$$slots:{tensorflow:[z$],pytorch:[E$]},$$scope:{ctx:F}}}),Pt=new Ar({props:{$$slots:{default:[q$]},$$scope:{ctx:F}}}),Aa=new Oe({}),Ft=new hs({props:{pytorch:!0,tensorflow:!0,jax:!1,$$slots:{tensorflow:[M$],pytorch:[x$]},$$scope:{ctx:F}}}),Mt=new hs({props:{pytorch:!0,tensorflow:!0,jax:!1,$$slots:{tensorflow:[I$],pytorch:[S$]},$$scope:{ctx:F}}}),ja=new Oe({}),za=new N({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>)`}}),St=new hs({props:{pytorch:!0,tensorflow:!0,jax:!1,$$slots:{tensorflow:[H$],pytorch:[N$]},$$scope:{ctx:F}}}),qa=new Oe({}),Ma=new N({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>)`}}),Sa=new N({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>)`}}),Ia=new N({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>)`}}),Na=new N({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>`}}),Wa=new N({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>])`}}),Ra=new N({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>)'}}),Ga=new N({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)`}}),Ka=new N({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>`}}),Ba=new N({props:{code:"trainer.train()",highlighted:'<span class="hljs-meta">&gt;&gt;&gt; </span>trainer.train()'}}),Ht=new Ar({props:{$$slots:{default:[L$]},$$scope:{ctx:F}}}),Va=new Oe({}),as=new N({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>)`}}),rs=new N({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>)`}}),ns=new N({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>`}}),ps=new N({props:{code:`dataset = dataset.map(tokenize_dataset)  # doctest: +SKIP
tf_dataset = model.prepare_tf_dataset(
    dataset["train"], 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[<span class="hljs-string">&quot;train&quot;</span>], 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>`}}),cs=new N({props:{code:`from tensorflow.keras.optimizers import Adam

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