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 g,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 Tr}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 ms,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,h){y(s,r,h),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,h){y(s,r,h),d=!0},p(r,h){const _={};h&2&&(_.$$scope={dirty:h,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,h){y(s,r,h),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,h){y(s,r,h),d=!0},p(r,h){const _={};h&2&&(_.$$scope={dirty:h,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,h,_;return{c(){s=l("p"),d=o("For a complete list of available tasks, check out the "),r=l("a"),h=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);h=n(M,"pipeline API reference"),M.forEach(a),_=n(j,"."),j.forEach(a),this.h()},h(){g(r,"href","./main_classes/pipelines")},m(v,j){m(v,s,j),e(s,d),e(s,r),e(r,h),e(s,_)},d(v){v&&a(s)}}}function d$(F){let s,d,r,h,_,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"),h=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);h=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(){g(r,"href","/docs/transformers/v4.27.1/en/model_doc/auto#transformers.AutoModelForSequenceClassification"),g(v,"href","/docs/transformers/v4.27.1/en/model_doc/auto#transformers.AutoTokenizer")},m(q,P){m(q,s,P),e(s,d),e(s,r),e(r,h),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,h){y(s,r,h),d=!0},p(r,h){const _={};h&2&&(_.$$scope={dirty:h,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,h,_,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"),h=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);h=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(){g(r,"href","/docs/transformers/v4.27.1/en/model_doc/auto#transformers.TFAutoModelForSequenceClassification"),g(v,"href","/docs/transformers/v4.27.1/en/model_doc/auto#transformers.AutoTokenizer")},m(q,P){m(q,s,P),e(s,d),e(s,r),e(r,h),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,h){y(s,r,h),d=!0},p(r,h){const _={};h&2&&(_.$$scope={dirty:h,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,h){y(s,r,h),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,h){y(s,r,h),d=!0},p(r,h){const _={};h&2&&(_.$$scope={dirty:h,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,h){y(s,r,h),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,h){y(s,r,h),d=!0},p(r,h){const _={};h&2&&(_.$$scope={dirty:h,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,h,_,v,j,M,$,z,D,I,O,L;return{c(){s=l("p"),d=o("Check out the "),r=l("a"),h=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);h=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(){g(r,"href","./preprocessing"),g(v,"href","/docs/transformers/v4.27.1/en/model_doc/auto#transformers.AutoImageProcessor"),g($,"href","/docs/transformers/v4.27.1/en/model_doc/auto#transformers.AutoFeatureExtractor"),g(I,"href","/docs/transformers/v4.27.1/en/model_doc/auto#transformers.AutoProcessor")},m(q,P){m(q,s,P),e(s,d),e(s,r),e(r,h),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,h,_,v,j,M;return{c(){s=l("p"),d=o("See the "),r=l("a"),h=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);h=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(){g(r,"href","./task_summary"),g(v,"href","/docs/transformers/v4.27.1/en/model_doc/auto#transformers.AutoModel")},m($,z){m($,s,z),e(s,d),e(s,r),e(r,h),e(s,_),e(s,v),e(v,j),e(s,M)},d($){$&&a(s)}}}function T$(F){let s,d,r,h,_,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 Tr({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"),h=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);h=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 ds=p(pe);ne=n(ds,"**"),ds.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 hs=p(Q);be=n(hs,"logits"),hs.forEach(a),$e=n(he," attribute. Apply the softmax function to the "),J=i(he,"CODE",{});var gs=p(J);se=n(gs,"logits"),gs.forEach(a),Z=n(he," to retrieve the probabilities:"),he.forEach(a),x=u(C),w(W.$$.fragment,C),this.h()},h(){g(r,"href","/docs/transformers/v4.27.1/en/model_doc/auto#transformers.AutoModel"),g(v,"href","/docs/transformers/v4.27.1/en/model_doc/auto#transformers.AutoTokenizer"),g($,"href","/docs/transformers/v4.27.1/en/model_doc/auto#transformers.AutoModel"),g(I,"href","/docs/transformers/v4.27.1/en/model_doc/auto#transformers.AutoModelForSequenceClassification")},m(C,H){m(C,s,H),e(s,d),e(s,r),e(r,h),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,h){y(s,r,h),d=!0},p(r,h){const _={};h&2&&(_.$$scope={dirty:h,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,h,_,v,j,M;return{c(){s=l("p"),d=o("See the "),r=l("a"),h=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);h=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(){g(r,"href","./task_summary"),g(v,"href","/docs/transformers/v4.27.1/en/model_doc/auto#transformers.AutoModel")},m($,z){m($,s,z),e(s,d),e(s,r),e(r,h),e(s,_),e(s,v),e(v,j),e(s,M)},d($){$&&a(s)}}}function j$(F){let s,d,r,h,_,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 Tr({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"),h=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);h=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(){g(r,"href","/docs/transformers/v4.27.1/en/model_doc/auto#transformers.TFAutoModel"),g(v,"href","/docs/transformers/v4.27.1/en/model_doc/auto#transformers.AutoTokenizer"),g($,"href","/docs/transformers/v4.27.1/en/model_doc/auto#transformers.TFAutoModel"),g(I,"href","/docs/transformers/v4.27.1/en/model_doc/auto#transformers.TFAutoModelForSequenceClassification")},m(x,W){m(x,s,W),e(s,d),e(s,r),e(r,h),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,h){y(s,r,h),d=!0},p(r,h){const _={};h&2&&(_.$$scope={dirty:h,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,h,_;return{c(){s=l("p"),d=o("All \u{1F917} Transformers models (PyTorch or TensorFlow) output the tensors "),r=l("em"),h=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);h=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,h),e(s,_)},d(v){v&&a(s)}}}function P$(F){let s,d,r,h,_,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"),h=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);h=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(){g(r,"href","/docs/transformers/v4.27.1/en/main_classes/model#transformers.PreTrainedModel.save_pretrained"),g(D,"href","/docs/transformers/v4.27.1/en/main_classes/model#transformers.PreTrainedModel.from_pretrained")},m(A,S){m(A,s,S),e(s,d),e(s,r),e(r,h),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,h){y(s,r,h),d=!0},p(r,h){const _={};h&2&&(_.$$scope={dirty:h,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,h,_,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"),h=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);h=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(){g(r,"href","/docs/transformers/v4.27.1/en/main_classes/model#transformers.TFPreTrainedModel.save_pretrained"),g(D,"href","/docs/transformers/v4.27.1/en/main_classes/model#transformers.TFPreTrainedModel.from_pretrained")},m(A,S){m(A,s,S),e(s,d),e(s,r),e(r,h),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,h){y(s,r,h),d=!0},p(r,h){const _={};h&2&&(_.$$scope={dirty:h,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,h){y(s,r,h),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,h){y(s,r,h),d=!0},p(r,h){const _={};h&2&&(_.$$scope={dirty:h,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,h){y(s,r,h),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,h){y(s,r,h),d=!0},p(r,h){const _={};h&2&&(_.$$scope={dirty:h,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,h,_,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"),h=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);h=n(D,"AutoModel.from_config()"),D.forEach(a),_=n(z,":"),z.forEach(a),v=u($),w(j.$$.fragment,$),this.h()},h(){g(r,"href","/docs/transformers/v4.27.1/en/model_doc/auto#transformers.FlaxAutoModelForVision2Seq.from_config")},m($,z){m($,s,z),e(s,d),e(s,r),e(r,h),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,h){y(s,r,h),d=!0},p(r,h){const _={};h&2&&(_.$$scope={dirty:h,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,h,_,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"),h=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);h=n(D,"TFAutoModel.from_config()"),D.forEach(a),_=n(z,":"),z.forEach(a),v=u($),w(j.$$.fragment,$),this.h()},h(){g(r,"href","/docs/transformers/v4.27.1/en/model_doc/auto#transformers.FlaxAutoModelForVision2Seq.from_config")},m($,z){m($,s,z),e(s,d),e(s,r),e(r,h),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,h){y(s,r,h),d=!0},p(r,h){const _={};h&2&&(_.$$scope={dirty:h,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,h,_,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"),h=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);h=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),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u,Ku,El,Ga,Al,Wt,Bu,er,Vu,Ju,jl,Ka,zl,Ht,ql,Ve,Qu,tr,Zu,Xu,ar,em,tm,Pl,Je,am,sr,sm,rm,rr,om,nm,xl,lt,Lt,Xo,Ba,lm,en,im,Fl,te,pm,Va,tn,fm,cm,Ja,um,mm,or,dm,hm,an,gm,$m,Qa,sn,_m,vm,Za,rn,km,wm,Ml,ce,Xa,it,ym,nr,bm,Tm,es,on,Em,Am,jm,ts,zm,as,nn,qm,Pm,ss,xm,rs,ln,Fm,Mm,os,Cm,ns,pt,Sm,pn,Dm,Im,lr,Om,Nm,Wm,ls,Hm,is,ft,Lm,fn,Rm,Ym,cn,Um,Gm,Km,ps,Cl,ct,Rt,un,fs,Bm,mn,Vm,Sl,ir,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 ms({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 Tr({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 ms({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 ms({props:{pytorch:!0,tensorflow:!0,jax:!1,$$slots:{tensorflow:[w$],pytorch:[v$]},$$scope:{ctx:F}}}),jt=new Tr({props:{$$slots:{default:[y$]},$$scope:{ctx:F}}}),Ea=new Oe({}),qt=new ms({props:{pytorch:!0,tensorflow:!0,jax:!1,$$slots:{tensorflow:[z$],pytorch:[E$]},$$scope:{ctx:F}}}),Pt=new Tr({props:{$$slots:{default:[q$]},$$scope:{ctx:F}}}),Aa=new Oe({}),Ft=new ms({props:{pytorch:!0,tensorflow:!0,jax:!1,$$slots:{tensorflow:[M$],pytorch:[x$]},$$scope:{ctx:F}}}),Mt=new ms({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 ms({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>])`}}),La=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>)'}}),Ua=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)`}}),Ga=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>`}}),Ka=new N({props:{code:"trainer.train()",highlighted:'<span class="hljs-meta">&gt;&gt;&gt; </span>trainer.train()'}}),Ht=new Tr({props:{$$slots:{default:[L$]},$$scope:{ctx:F}}}),Ba=new Oe({}),ts=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>)`}}),ss=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>)`}}),os=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>`}}),ls=new N({props:{code:`dataset = dataset.map(tokenize_dataset)  # doctest: +SKIP
tf_dataset = model.prepare_tf_dataset(
    dataset, batch_size=16, shuffle=True, tokenizer=tokenizer
)  # doctest: +SKIP`,highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span>dataset = dataset.<span class="hljs-built_in">map</span>(tokenize_dataset)  <span class="hljs-comment"># doctest: +SKIP</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>tf_dataset = model.prepare_tf_dataset(
<span class="hljs-meta">... </span>    dataset, batch_size=<span class="hljs-number">16</span>, shuffle=<span class="hljs-literal">True</span>, tokenizer=tokenizer
<span class="hljs-meta">... </span>)  <span class="hljs-comment"># doctest: +SKIP</span>`}}),ps=new N({props:{code:`from tensorflow.keras.optimizers import Adam

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

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