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