import{S as Ga,i as Na,s as Pa,e as l,k as m,w as P,t as s,M as Va,c as n,d as a,m as d,a as i,x as V,h as r,b as y,G as t,g as p,y as z,q as R,o as L,B as I,v as za,L as Ra}from"../chunks/vendor-hf-doc-builder.js";import{T as Ca}from"../chunks/Tip-hf-doc-builder.js";import{I as qe}from"../chunks/IconCopyLink-hf-doc-builder.js";import{C as de}from"../chunks/CodeBlock-hf-doc-builder.js";import{F as La,M as Ua}from"../chunks/Markdown-hf-doc-builder.js";function Ia(oe){let o,_,h,w,M,g,q,C;return{c(){o=l("p"),_=s("Remember, architecture refers to the skeleton of the model and checkpoints are the weights for a given architecture. For example, "),h=l("a"),w=s("BERT"),M=s(" is an architecture, while "),g=l("code"),q=s("bert-base-uncased"),C=s(" is a checkpoint. Model is a general term that can mean either architecture or checkpoint."),this.h()},l(E){o=n(E,"P",{});var F=i(o);_=r(F,"Remember, architecture refers to the skeleton of the model and checkpoints are the weights for a given architecture. For example, "),h=n(F,"A",{href:!0,rel:!0});var Z=i(h);w=r(Z,"BERT"),Z.forEach(a),M=r(F," is an architecture, while "),g=n(F,"CODE",{});var W=i(g);q=r(W,"bert-base-uncased"),W.forEach(a),C=r(F," is a checkpoint. Model is a general term that can mean either architecture or checkpoint."),F.forEach(a),this.h()},h(){y(h,"href","https://huggingface.co/bert-base-uncased"),y(h,"rel","nofollow")},m(E,F){p(E,o,F),t(o,_),t(o,h),t(h,w),t(o,M),t(o,g),t(g,q),t(o,C)},d(E){E&&a(o)}}}function qa(oe){let o,_,h,w,M,g,q,C,E,F,Z,W,x,Q,T,D,O,A,Y,k,H,v,ae,U,j,K,S,B,ee,G,te,u;return{c(){o=l("p"),_=s("For PyTorch models, the "),h=l("code"),w=s("from_pretrained()"),M=s(" method uses "),g=l("code"),q=s("torch.load()"),C=s(" which internally uses "),E=l("code"),F=s("pickle"),Z=s(" and is known to be insecure. In general, never load a model that could have come from an untrusted source, or that could have been tampered with. This security risk is partially mitigated for public models hosted on the Hugging Face Hub, which are "),W=l("a"),x=s("scanned for malware"),Q=s(" at each commit. See the "),T=l("a"),D=s("Hub documentation"),O=s(" for best practices like "),A=l("a"),Y=s("signed commit verification"),k=s(" with GPG."),H=m(),v=l("p"),ae=s("TensorFlow and Flax checkpoints are not affected, and can be loaded within PyTorch architectures using the "),U=l("code"),j=s("from_tf"),K=s(" and "),S=l("code"),B=s("from_flax"),ee=s(" kwargs for the "),G=l("code"),te=s("from_pretrained"),u=s(" method to circumvent this issue."),this.h()},l(b){o=n(b,"P",{});var c=i(o);_=r(c,"For PyTorch models, the "),h=n(c,"CODE",{});var $=i(h);w=r($,"from_pretrained()"),$.forEach(a),M=r(c," method uses "),g=n(c,"CODE",{});var se=i(g);q=r(se,"torch.load()"),se.forEach(a),C=r(c," which internally uses "),E=n(c,"CODE",{});var le=i(E);F=r(le,"pickle"),le.forEach(a),Z=r(c," and is known to be insecure. In general, never load a model that could have come from an untrusted source, or that could have been tampered with. This security risk is partially mitigated for public models hosted on the Hugging Face Hub, which are "),W=n(c,"A",{href:!0,rel:!0});var N=i(W);x=r(N,"scanned for malware"),N.forEach(a),Q=r(c," at each commit. See the "),T=n(c,"A",{href:!0,rel:!0});var ne=i(T);D=r(ne,"Hub documentation"),ne.forEach(a),O=r(c," for best practices like "),A=n(c,"A",{href:!0,rel:!0});var X=i(A);Y=r(X,"signed commit verification"),X.forEach(a),k=r(c," with GPG."),c.forEach(a),H=d(b),v=n(b,"P",{});var J=i(v);ae=r(J,"TensorFlow and Flax checkpoints are not affected, and can be loaded within PyTorch architectures using the "),U=n(J,"CODE",{});var re=i(U);j=r(re,"from_tf"),re.forEach(a),K=r(J," and "),S=n(J,"CODE",{});var ie=i(S);B=r(ie,"from_flax"),ie.forEach(a),ee=r(J," kwargs for the "),G=n(J,"CODE",{});var ce=i(G);te=r(ce,"from_pretrained"),ce.forEach(a),u=r(J," method to circumvent this issue."),J.forEach(a),this.h()},h(){y(W,"href","https://huggingface.co/docs/hub/security-malware"),y(W,"rel","nofollow"),y(T,"href","https://huggingface.co/docs/hub/security"),y(T,"rel","nofollow"),y(A,"href","https://huggingface.co/docs/hub/security-gpg#signing-commits-with-gpg"),y(A,"rel","nofollow")},m(b,c){p(b,o,c),t(o,_),t(o,h),t(h,w),t(o,M),t(o,g),t(g,q),t(o,C),t(o,E),t(E,F),t(o,Z),t(o,W),t(W,x),t(o,Q),t(o,T),t(T,D),t(o,O),t(o,A),t(A,Y),t(o,k),p(b,H,c),p(b,v,c),t(v,ae),t(v,U),t(U,j),t(v,K),t(v,S),t(S,B),t(v,ee),t(v,G),t(G,te),t(v,u)},d(b){b&&a(o),b&&a(H),b&&a(v)}}}function Sa(oe){let o,_,h,w,M,g,q,C,E,F,Z,W,x,Q,T,D,O,A,Y,k,H,v,ae,U,j,K,S,B,ee,G,te,u,b;return x=new de({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMEF1dG9Nb2RlbEZvclNlcXVlbmNlQ2xhc3NpZmljYXRpb24lMEElMEFtb2RlbCUyMCUzRCUyMEF1dG9Nb2RlbEZvclNlcXVlbmNlQ2xhc3NpZmljYXRpb24uZnJvbV9wcmV0cmFpbmVkKCUyMmRpc3RpbGJlcnQtYmFzZS11bmNhc2VkJTIyKQ==",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>)`}}),A=new de({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMEF1dG9Nb2RlbEZvclRva2VuQ2xhc3NpZmljYXRpb24lMEElMEFtb2RlbCUyMCUzRCUyMEF1dG9Nb2RlbEZvclRva2VuQ2xhc3NpZmljYXRpb24uZnJvbV9wcmV0cmFpbmVkKCUyMmRpc3RpbGJlcnQtYmFzZS11bmNhc2VkJTIyKQ==",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoModelForTokenClassification

<span class="hljs-meta">&gt;&gt;&gt; </span>model = AutoModelForTokenClassification.from_pretrained(<span class="hljs-string">&quot;distilbert-base-uncased&quot;</span>)`}}),k=new Ca({props:{warning:!0,$$slots:{default:[qa]},$$scope:{ctx:oe}}}),{c(){o=l("p"),_=s("Finally, the "),h=l("code"),w=s("AutoModelFor"),M=s(" classes let you load a pretrained model for a given task (see "),g=l("a"),q=s("here"),C=s(" for a complete list of available tasks). For example, load a model for sequence classification with "),E=l("a"),F=s("AutoModelForSequenceClassification.from_pretrained()"),Z=s(":"),W=m(),P(x.$$.fragment),Q=m(),T=l("p"),D=s("Easily reuse the same checkpoint to load an architecture for a different task:"),O=m(),P(A.$$.fragment),Y=m(),P(k.$$.fragment),H=m(),v=l("p"),ae=s("Generally, we recommend using the "),U=l("code"),j=s("AutoTokenizer"),K=s(" class and the "),S=l("code"),B=s("AutoModelFor"),ee=s(" class to load pretrained instances of models. This will ensure you load the correct architecture every time. In the next "),G=l("a"),te=s("tutorial"),u=s(", learn how to use your newly loaded tokenizer, image processor, feature extractor and processor to preprocess a dataset for fine-tuning."),this.h()},l(c){o=n(c,"P",{});var $=i(o);_=r($,"Finally, the "),h=n($,"CODE",{});var se=i(h);w=r(se,"AutoModelFor"),se.forEach(a),M=r($," classes let you load a pretrained model for a given task (see "),g=n($,"A",{href:!0});var le=i(g);q=r(le,"here"),le.forEach(a),C=r($," for a complete list of available tasks). For example, load a model for sequence classification with "),E=n($,"A",{href:!0});var N=i(E);F=r(N,"AutoModelForSequenceClassification.from_pretrained()"),N.forEach(a),Z=r($,":"),$.forEach(a),W=d(c),V(x.$$.fragment,c),Q=d(c),T=n(c,"P",{});var ne=i(T);D=r(ne,"Easily reuse the same checkpoint to load an architecture for a different task:"),ne.forEach(a),O=d(c),V(A.$$.fragment,c),Y=d(c),V(k.$$.fragment,c),H=d(c),v=n(c,"P",{});var X=i(v);ae=r(X,"Generally, we recommend using the "),U=n(X,"CODE",{});var J=i(U);j=r(J,"AutoTokenizer"),J.forEach(a),K=r(X," class and the "),S=n(X,"CODE",{});var re=i(S);B=r(re,"AutoModelFor"),re.forEach(a),ee=r(X," class to load pretrained instances of models. This will ensure you load the correct architecture every time. In the next "),G=n(X,"A",{href:!0});var ie=i(G);te=r(ie,"tutorial"),ie.forEach(a),u=r(X,", learn how to use your newly loaded tokenizer, image processor, feature extractor and processor to preprocess a dataset for fine-tuning."),X.forEach(a),this.h()},h(){y(g,"href","model_doc/auto"),y(E,"href","/docs/transformers/main/en/model_doc/auto#transformers.FlaxAutoModelForVision2Seq.from_pretrained"),y(G,"href","preprocessing")},m(c,$){p(c,o,$),t(o,_),t(o,h),t(h,w),t(o,M),t(o,g),t(g,q),t(o,C),t(o,E),t(E,F),t(o,Z),p(c,W,$),z(x,c,$),p(c,Q,$),p(c,T,$),t(T,D),p(c,O,$),z(A,c,$),p(c,Y,$),z(k,c,$),p(c,H,$),p(c,v,$),t(v,ae),t(v,U),t(U,j),t(v,K),t(v,S),t(S,B),t(v,ee),t(v,G),t(G,te),t(v,u),b=!0},p(c,$){const se={};$&2&&(se.$$scope={dirty:$,ctx:c}),k.$set(se)},i(c){b||(R(x.$$.fragment,c),R(A.$$.fragment,c),R(k.$$.fragment,c),b=!0)},o(c){L(x.$$.fragment,c),L(A.$$.fragment,c),L(k.$$.fragment,c),b=!1},d(c){c&&a(o),c&&a(W),I(x,c),c&&a(Q),c&&a(T),c&&a(O),I(A,c),c&&a(Y),I(k,c),c&&a(H),c&&a(v)}}}function Xa(oe){let o,_;return o=new Ua({props:{$$slots:{default:[Sa]},$$scope:{ctx:oe}}}),{c(){P(o.$$.fragment)},l(h){V(o.$$.fragment,h)},m(h,w){z(o,h,w),_=!0},p(h,w){const M={};w&2&&(M.$$scope={dirty:w,ctx:h}),o.$set(M)},i(h){_||(R(o.$$.fragment,h),_=!0)},o(h){L(o.$$.fragment,h),_=!1},d(h){I(o,h)}}}function Ya(oe){let o,_,h,w,M,g,q,C,E,F,Z,W,x,Q,T,D,O,A,Y,k,H,v,ae,U,j,K,S,B,ee,G,te;return x=new de({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMFRGQXV0b01vZGVsRm9yU2VxdWVuY2VDbGFzc2lmaWNhdGlvbiUwQSUwQW1vZGVsJTIwJTNEJTIwVEZBdXRvTW9kZWxGb3JTZXF1ZW5jZUNsYXNzaWZpY2F0aW9uLmZyb21fcHJldHJhaW5lZCglMjJkaXN0aWxiZXJ0LWJhc2UtdW5jYXNlZCUyMik=",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>)`}}),A=new de({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMFRGQXV0b01vZGVsRm9yVG9rZW5DbGFzc2lmaWNhdGlvbiUwQSUwQW1vZGVsJTIwJTNEJTIwVEZBdXRvTW9kZWxGb3JUb2tlbkNsYXNzaWZpY2F0aW9uLmZyb21fcHJldHJhaW5lZCglMjJkaXN0aWxiZXJ0LWJhc2UtdW5jYXNlZCUyMik=",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> TFAutoModelForTokenClassification

<span class="hljs-meta">&gt;&gt;&gt; </span>model = TFAutoModelForTokenClassification.from_pretrained(<span class="hljs-string">&quot;distilbert-base-uncased&quot;</span>)`}}),{c(){o=l("p"),_=s("Finally, the "),h=l("code"),w=s("TFAutoModelFor"),M=s(" classes let you load a pretrained model for a given task (see "),g=l("a"),q=s("here"),C=s(" for a complete list of available tasks). For example, load a model for sequence classification with "),E=l("a"),F=s("TFAutoModelForSequenceClassification.from_pretrained()"),Z=s(":"),W=m(),P(x.$$.fragment),Q=m(),T=l("p"),D=s("Easily reuse the same checkpoint to load an architecture for a different task:"),O=m(),P(A.$$.fragment),Y=m(),k=l("p"),H=s("Generally, we recommend using the "),v=l("code"),ae=s("AutoTokenizer"),U=s(" class and the "),j=l("code"),K=s("TFAutoModelFor"),S=s(" class to load pretrained instances of models. This will ensure you load the correct architecture every time. In the next "),B=l("a"),ee=s("tutorial"),G=s(", learn how to use your newly loaded tokenizer, image processor, feature extractor and processor to preprocess a dataset for fine-tuning."),this.h()},l(u){o=n(u,"P",{});var b=i(o);_=r(b,"Finally, the "),h=n(b,"CODE",{});var c=i(h);w=r(c,"TFAutoModelFor"),c.forEach(a),M=r(b," classes let you load a pretrained model for a given task (see "),g=n(b,"A",{href:!0});var $=i(g);q=r($,"here"),$.forEach(a),C=r(b," for a complete list of available tasks). For example, load a model for sequence classification with "),E=n(b,"A",{href:!0});var se=i(E);F=r(se,"TFAutoModelForSequenceClassification.from_pretrained()"),se.forEach(a),Z=r(b,":"),b.forEach(a),W=d(u),V(x.$$.fragment,u),Q=d(u),T=n(u,"P",{});var le=i(T);D=r(le,"Easily reuse the same checkpoint to load an architecture for a different task:"),le.forEach(a),O=d(u),V(A.$$.fragment,u),Y=d(u),k=n(u,"P",{});var N=i(k);H=r(N,"Generally, we recommend using the "),v=n(N,"CODE",{});var ne=i(v);ae=r(ne,"AutoTokenizer"),ne.forEach(a),U=r(N," class and the "),j=n(N,"CODE",{});var X=i(j);K=r(X,"TFAutoModelFor"),X.forEach(a),S=r(N," class to load pretrained instances of models. This will ensure you load the correct architecture every time. In the next "),B=n(N,"A",{href:!0});var J=i(B);ee=r(J,"tutorial"),J.forEach(a),G=r(N,", learn how to use your newly loaded tokenizer, image processor, feature extractor and processor to preprocess a dataset for fine-tuning."),N.forEach(a),this.h()},h(){y(g,"href","model_doc/auto"),y(E,"href","/docs/transformers/main/en/model_doc/auto#transformers.FlaxAutoModelForVision2Seq.from_pretrained"),y(B,"href","preprocessing")},m(u,b){p(u,o,b),t(o,_),t(o,h),t(h,w),t(o,M),t(o,g),t(g,q),t(o,C),t(o,E),t(E,F),t(o,Z),p(u,W,b),z(x,u,b),p(u,Q,b),p(u,T,b),t(T,D),p(u,O,b),z(A,u,b),p(u,Y,b),p(u,k,b),t(k,H),t(k,v),t(v,ae),t(k,U),t(k,j),t(j,K),t(k,S),t(k,B),t(B,ee),t(k,G),te=!0},p:Ra,i(u){te||(R(x.$$.fragment,u),R(A.$$.fragment,u),te=!0)},o(u){L(x.$$.fragment,u),L(A.$$.fragment,u),te=!1},d(u){u&&a(o),u&&a(W),I(x,u),u&&a(Q),u&&a(T),u&&a(O),I(A,u),u&&a(Y),u&&a(k)}}}function Ha(oe){let o,_;return o=new Ua({props:{$$slots:{default:[Ya]},$$scope:{ctx:oe}}}),{c(){P(o.$$.fragment)},l(h){V(o.$$.fragment,h)},m(h,w){z(o,h,w),_=!0},p(h,w){const M={};w&2&&(M.$$scope={dirty:w,ctx:h}),o.$set(M)},i(h){_||(R(o.$$.fragment,h),_=!0)},o(h){L(o.$$.fragment,h),_=!1},d(h){I(o,h)}}}function Ba(oe){let o,_,h,w,M,g,q,C,E,F,Z,W,x,Q,T,D,O,A,Y,k,H,v,ae,U,j,K,S,B,ee,G,te,u,b,c,$,se,le,N,ne,X,J,re,ie,ce,Zt,Se,xt,tt,Ue,Tt,at,ye,Wt,Ge,Jt,Ct,st,je,rt,Ne,Ut,ot,Me,lt,he,be,Xe,Ae,Gt,Ye,Nt,nt,Pe,Pt,it,Fe,ct,fe,ve,He,Ze,Vt,Be,zt,pt,Ve,Rt,ht,$e,Lt,ze,It,qt,ft,xe,ut,ue,we,Qe,Te,St,De,Xt,mt,ke,Yt,Re,Ht,Bt,dt,ge,Qt,Le,Dt,Ot,yt,We,bt,me,_e,Oe,Je,Kt,Ke,ea,vt,Ee,$t;return g=new qe({}),k=new Ca({props:{$$slots:{default:[Ia]},$$scope:{ctx:oe}}}),ce=new qe({}),je=new de({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMEF1dG9Ub2tlbml6ZXIlMEElMEF0b2tlbml6ZXIlMjAlM0QlMjBBdXRvVG9rZW5pemVyLmZyb21fcHJldHJhaW5lZCglMjJiZXJ0LWJhc2UtdW5jYXNlZCUyMik=",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;bert-base-uncased&quot;</span>)`}}),Me=new de({props:{code:"c2VxdWVuY2UlMjAlM0QlMjAlMjJJbiUyMGElMjBob2xlJTIwaW4lMjB0aGUlMjBncm91bmQlMjB0aGVyZSUyMGxpdmVkJTIwYSUyMGhvYmJpdC4lMjIlMEFwcmludCh0b2tlbml6ZXIoc2VxdWVuY2UpKQ==",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span>sequence = <span class="hljs-string">&quot;In a hole in the ground there lived a hobbit.&quot;</span>
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-built_in">print</span>(tokenizer(sequence))
{<span class="hljs-string">&#x27;input_ids&#x27;</span>: [<span class="hljs-number">101</span>, <span class="hljs-number">1999</span>, <span class="hljs-number">1037</span>, <span class="hljs-number">4920</span>, <span class="hljs-number">1999</span>, <span class="hljs-number">1996</span>, <span class="hljs-number">2598</span>, <span class="hljs-number">2045</span>, <span class="hljs-number">2973</span>, <span class="hljs-number">1037</span>, <span class="hljs-number">7570</span>, <span class="hljs-number">10322</span>, <span class="hljs-number">4183</span>, <span class="hljs-number">1012</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-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>, <span class="hljs-number">1</span>]}`}}),Ae=new qe({}),Fe=new de({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMEF1dG9JbWFnZVByb2Nlc3NvciUwQSUwQWltYWdlX3Byb2Nlc3NvciUyMCUzRCUyMEF1dG9JbWFnZVByb2Nlc3Nvci5mcm9tX3ByZXRyYWluZWQoJTIyZ29vZ2xlJTJGdml0LWJhc2UtcGF0Y2gxNi0yMjQlMjIp",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoImageProcessor

<span class="hljs-meta">&gt;&gt;&gt; </span>image_processor = AutoImageProcessor.from_pretrained(<span class="hljs-string">&quot;google/vit-base-patch16-224&quot;</span>)`}}),Ze=new qe({}),xe=new de({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMEF1dG9GZWF0dXJlRXh0cmFjdG9yJTBBJTBBZmVhdHVyZV9leHRyYWN0b3IlMjAlM0QlMjBBdXRvRmVhdHVyZUV4dHJhY3Rvci5mcm9tX3ByZXRyYWluZWQoJTBBJTIwJTIwJTIwJTIwJTIyZWhjYWxhYnJlcyUyRndhdjJ2ZWMyLWxnLXhsc3ItZW4tc3BlZWNoLWVtb3Rpb24tcmVjb2duaXRpb24lMjIlMEEp",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoFeatureExtractor

<span class="hljs-meta">&gt;&gt;&gt; </span>feature_extractor = AutoFeatureExtractor.from_pretrained(
<span class="hljs-meta">... </span>    <span class="hljs-string">&quot;ehcalabres/wav2vec2-lg-xlsr-en-speech-emotion-recognition&quot;</span>
<span class="hljs-meta">... </span>)`}}),Te=new qe({}),We=new de({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMEF1dG9Qcm9jZXNzb3IlMEElMEFwcm9jZXNzb3IlMjAlM0QlMjBBdXRvUHJvY2Vzc29yLmZyb21fcHJldHJhaW5lZCglMjJtaWNyb3NvZnQlMkZsYXlvdXRsbXYyLWJhc2UtdW5jYXNlZCUyMik=",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoProcessor

<span class="hljs-meta">&gt;&gt;&gt; </span>processor = AutoProcessor.from_pretrained(<span class="hljs-string">&quot;microsoft/layoutlmv2-base-uncased&quot;</span>)`}}),Je=new qe({}),Ee=new La({props:{pytorch:!0,tensorflow:!0,jax:!1,$$slots:{tensorflow:[Ha],pytorch:[Xa]},$$scope:{ctx:oe}}}),{c(){o=l("meta"),_=m(),h=l("h1"),w=l("a"),M=l("span"),P(g.$$.fragment),q=m(),C=l("span"),E=s("Load pretrained instances with an AutoClass"),F=m(),Z=l("p"),W=s("With so many different Transformer architectures, it can be challenging to create one for your checkpoint. As a part of \u{1F917} Transformers core philosophy to make the library easy, simple and flexible to use, an "),x=l("code"),Q=s("AutoClass"),T=s(" automatically infer and load the correct architecture from a given checkpoint. The "),D=l("code"),O=s("from_pretrained()"),A=s(" method lets you quickly load a pretrained model for any architecture so you don\u2019t have to devote time and resources to train a model from scratch. Producing this type of checkpoint-agnostic code means if your code works for one checkpoint, it will work with another checkpoint - as long as it was trained for a similar task - even if the architecture is different."),Y=m(),P(k.$$.fragment),H=m(),v=l("p"),ae=s("In this tutorial, learn to:"),U=m(),j=l("ul"),K=l("li"),S=s("Load a pretrained tokenizer."),B=m(),ee=l("li"),G=s("Load a pretrained image processor"),te=m(),u=l("li"),b=s("Load a pretrained feature extractor."),c=m(),$=l("li"),se=s("Load a pretrained processor."),le=m(),N=l("li"),ne=s("Load a pretrained model."),X=m(),J=l("h2"),re=l("a"),ie=l("span"),P(ce.$$.fragment),Zt=m(),Se=l("span"),xt=s("AutoTokenizer"),tt=m(),Ue=l("p"),Tt=s("Nearly every NLP task begins with a tokenizer. A tokenizer converts your input into a format that can be processed by the model."),at=m(),ye=l("p"),Wt=s("Load a tokenizer with "),Ge=l("a"),Jt=s("AutoTokenizer.from_pretrained()"),Ct=s(":"),st=m(),P(je.$$.fragment),rt=m(),Ne=l("p"),Ut=s("Then tokenize your input as shown below:"),ot=m(),P(Me.$$.fragment),lt=m(),he=l("h2"),be=l("a"),Xe=l("span"),P(Ae.$$.fragment),Gt=m(),Ye=l("span"),Nt=s("AutoImageProcessor"),nt=m(),Pe=l("p"),Pt=s("For vision tasks, an image processor processes the image into the correct input format."),it=m(),P(Fe.$$.fragment),ct=m(),fe=l("h2"),ve=l("a"),He=l("span"),P(Ze.$$.fragment),Vt=m(),Be=l("span"),zt=s("AutoFeatureExtractor"),pt=m(),Ve=l("p"),Rt=s("For audio tasks, a feature extractor processes the audio signal the correct input format."),ht=m(),$e=l("p"),Lt=s("Load a feature extractor with "),ze=l("a"),It=s("AutoFeatureExtractor.from_pretrained()"),qt=s(":"),ft=m(),P(xe.$$.fragment),ut=m(),ue=l("h2"),we=l("a"),Qe=l("span"),P(Te.$$.fragment),St=m(),De=l("span"),Xt=s("AutoProcessor"),mt=m(),ke=l("p"),Yt=s("Multimodal tasks require a processor that combines two types of preprocessing tools. For example, the "),Re=l("a"),Ht=s("LayoutLMV2"),Bt=s(" model requires an image processor to handle images and a tokenizer to handle text; a processor combines both of them."),dt=m(),ge=l("p"),Qt=s("Load a processor with "),Le=l("a"),Dt=s("AutoProcessor.from_pretrained()"),Ot=s(":"),yt=m(),P(We.$$.fragment),bt=m(),me=l("h2"),_e=l("a"),Oe=l("span"),P(Je.$$.fragment),Kt=m(),Ke=l("span"),ea=s("AutoModel"),vt=m(),P(Ee.$$.fragment),this.h()},l(e){const f=Va('[data-svelte="svelte-1phssyn"]',document.head);o=n(f,"META",{name:!0,content:!0}),f.forEach(a),_=d(e),h=n(e,"H1",{class:!0});var Ce=i(h);w=n(Ce,"A",{id:!0,class:!0,href:!0});var et=i(w);M=n(et,"SPAN",{});var ta=i(M);V(g.$$.fragment,ta),ta.forEach(a),et.forEach(a),q=d(Ce),C=n(Ce,"SPAN",{});var aa=i(C);E=r(aa,"Load pretrained instances with an AutoClass"),aa.forEach(a),Ce.forEach(a),F=d(e),Z=n(e,"P",{});var Ie=i(Z);W=r(Ie,"With so many different Transformer architectures, it can be challenging to create one for your checkpoint. As a part of \u{1F917} Transformers core philosophy to make the library easy, simple and flexible to use, an "),x=n(Ie,"CODE",{});var sa=i(x);Q=r(sa,"AutoClass"),sa.forEach(a),T=r(Ie," automatically infer and load the correct architecture from a given checkpoint. The "),D=n(Ie,"CODE",{});var ra=i(D);O=r(ra,"from_pretrained()"),ra.forEach(a),A=r(Ie," method lets you quickly load a pretrained model for any architecture so you don\u2019t have to devote time and resources to train a model from scratch. Producing this type of checkpoint-agnostic code means if your code works for one checkpoint, it will work with another checkpoint - as long as it was trained for a similar task - even if the architecture is different."),Ie.forEach(a),Y=d(e),V(k.$$.fragment,e),H=d(e),v=n(e,"P",{});var oa=i(v);ae=r(oa,"In this tutorial, learn to:"),oa.forEach(a),U=d(e),j=n(e,"UL",{});var pe=i(j);K=n(pe,"LI",{});var la=i(K);S=r(la,"Load a pretrained tokenizer."),la.forEach(a),B=d(pe),ee=n(pe,"LI",{});var na=i(ee);G=r(na,"Load a pretrained image processor"),na.forEach(a),te=d(pe),u=n(pe,"LI",{});var ia=i(u);b=r(ia,"Load a pretrained feature extractor."),ia.forEach(a),c=d(pe),$=n(pe,"LI",{});var ca=i($);se=r(ca,"Load a pretrained processor."),ca.forEach(a),le=d(pe),N=n(pe,"LI",{});var pa=i(N);ne=r(pa,"Load a pretrained model."),pa.forEach(a),pe.forEach(a),X=d(e),J=n(e,"H2",{class:!0});var wt=i(J);re=n(wt,"A",{id:!0,class:!0,href:!0});var ha=i(re);ie=n(ha,"SPAN",{});var fa=i(ie);V(ce.$$.fragment,fa),fa.forEach(a),ha.forEach(a),Zt=d(wt),Se=n(wt,"SPAN",{});var ua=i(Se);xt=r(ua,"AutoTokenizer"),ua.forEach(a),wt.forEach(a),tt=d(e),Ue=n(e,"P",{});var ma=i(Ue);Tt=r(ma,"Nearly every NLP task begins with a tokenizer. A tokenizer converts your input into a format that can be processed by the model."),ma.forEach(a),at=d(e),ye=n(e,"P",{});var kt=i(ye);Wt=r(kt,"Load a tokenizer with "),Ge=n(kt,"A",{href:!0});var da=i(Ge);Jt=r(da,"AutoTokenizer.from_pretrained()"),da.forEach(a),Ct=r(kt,":"),kt.forEach(a),st=d(e),V(je.$$.fragment,e),rt=d(e),Ne=n(e,"P",{});var ya=i(Ne);Ut=r(ya,"Then tokenize your input as shown below:"),ya.forEach(a),ot=d(e),V(Me.$$.fragment,e),lt=d(e),he=n(e,"H2",{class:!0});var gt=i(he);be=n(gt,"A",{id:!0,class:!0,href:!0});var ba=i(be);Xe=n(ba,"SPAN",{});var va=i(Xe);V(Ae.$$.fragment,va),va.forEach(a),ba.forEach(a),Gt=d(gt),Ye=n(gt,"SPAN",{});var $a=i(Ye);Nt=r($a,"AutoImageProcessor"),$a.forEach(a),gt.forEach(a),nt=d(e),Pe=n(e,"P",{});var wa=i(Pe);Pt=r(wa,"For vision tasks, an image processor processes the image into the correct input format."),wa.forEach(a),it=d(e),V(Fe.$$.fragment,e),ct=d(e),fe=n(e,"H2",{class:!0});var _t=i(fe);ve=n(_t,"A",{id:!0,class:!0,href:!0});var ka=i(ve);He=n(ka,"SPAN",{});var ga=i(He);V(Ze.$$.fragment,ga),ga.forEach(a),ka.forEach(a),Vt=d(_t),Be=n(_t,"SPAN",{});var _a=i(Be);zt=r(_a,"AutoFeatureExtractor"),_a.forEach(a),_t.forEach(a),pt=d(e),Ve=n(e,"P",{});var Ea=i(Ve);Rt=r(Ea,"For audio tasks, a feature extractor processes the audio signal the correct input format."),Ea.forEach(a),ht=d(e),$e=n(e,"P",{});var Et=i($e);Lt=r(Et,"Load a feature extractor with "),ze=n(Et,"A",{href:!0});var ja=i(ze);It=r(ja,"AutoFeatureExtractor.from_pretrained()"),ja.forEach(a),qt=r(Et,":"),Et.forEach(a),ft=d(e),V(xe.$$.fragment,e),ut=d(e),ue=n(e,"H2",{class:!0});var jt=i(ue);we=n(jt,"A",{id:!0,class:!0,href:!0});var Ma=i(we);Qe=n(Ma,"SPAN",{});var Aa=i(Qe);V(Te.$$.fragment,Aa),Aa.forEach(a),Ma.forEach(a),St=d(jt),De=n(jt,"SPAN",{});var Fa=i(De);Xt=r(Fa,"AutoProcessor"),Fa.forEach(a),jt.forEach(a),mt=d(e),ke=n(e,"P",{});var Mt=i(ke);Yt=r(Mt,"Multimodal tasks require a processor that combines two types of preprocessing tools. For example, the "),Re=n(Mt,"A",{href:!0});var Za=i(Re);Ht=r(Za,"LayoutLMV2"),Za.forEach(a),Bt=r(Mt," model requires an image processor to handle images and a tokenizer to handle text; a processor combines both of them."),Mt.forEach(a),dt=d(e),ge=n(e,"P",{});var At=i(ge);Qt=r(At,"Load a processor with "),Le=n(At,"A",{href:!0});var xa=i(Le);Dt=r(xa,"AutoProcessor.from_pretrained()"),xa.forEach(a),Ot=r(At,":"),At.forEach(a),yt=d(e),V(We.$$.fragment,e),bt=d(e),me=n(e,"H2",{class:!0});var Ft=i(me);_e=n(Ft,"A",{id:!0,class:!0,href:!0});var Ta=i(_e);Oe=n(Ta,"SPAN",{});var Wa=i(Oe);V(Je.$$.fragment,Wa),Wa.forEach(a),Ta.forEach(a),Kt=d(Ft),Ke=n(Ft,"SPAN",{});var Ja=i(Ke);ea=r(Ja,"AutoModel"),Ja.forEach(a),Ft.forEach(a),vt=d(e),V(Ee.$$.fragment,e),this.h()},h(){y(o,"name","hf:doc:metadata"),y(o,"content",JSON.stringify(Qa)),y(w,"id","load-pretrained-instances-with-an-autoclass"),y(w,"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"),y(w,"href","#load-pretrained-instances-with-an-autoclass"),y(h,"class","relative group"),y(re,"id","autotokenizer"),y(re,"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"),y(re,"href","#autotokenizer"),y(J,"class","relative group"),y(Ge,"href","/docs/transformers/main/en/model_doc/auto#transformers.AutoTokenizer.from_pretrained"),y(be,"id","autoimageprocessor"),y(be,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),y(be,"href","#autoimageprocessor"),y(he,"class","relative group"),y(ve,"id","autofeatureextractor"),y(ve,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),y(ve,"href","#autofeatureextractor"),y(fe,"class","relative group"),y(ze,"href","/docs/transformers/main/en/model_doc/auto#transformers.AutoFeatureExtractor.from_pretrained"),y(we,"id","autoprocessor"),y(we,"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"),y(we,"href","#autoprocessor"),y(ue,"class","relative group"),y(Re,"href","model_doc/layoutlmv2"),y(Le,"href","/docs/transformers/main/en/model_doc/auto#transformers.AutoProcessor.from_pretrained"),y(_e,"id","automodel"),y(_e,"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"),y(_e,"href","#automodel"),y(me,"class","relative group")},m(e,f){t(document.head,o),p(e,_,f),p(e,h,f),t(h,w),t(w,M),z(g,M,null),t(h,q),t(h,C),t(C,E),p(e,F,f),p(e,Z,f),t(Z,W),t(Z,x),t(x,Q),t(Z,T),t(Z,D),t(D,O),t(Z,A),p(e,Y,f),z(k,e,f),p(e,H,f),p(e,v,f),t(v,ae),p(e,U,f),p(e,j,f),t(j,K),t(K,S),t(j,B),t(j,ee),t(ee,G),t(j,te),t(j,u),t(u,b),t(j,c),t(j,$),t($,se),t(j,le),t(j,N),t(N,ne),p(e,X,f),p(e,J,f),t(J,re),t(re,ie),z(ce,ie,null),t(J,Zt),t(J,Se),t(Se,xt),p(e,tt,f),p(e,Ue,f),t(Ue,Tt),p(e,at,f),p(e,ye,f),t(ye,Wt),t(ye,Ge),t(Ge,Jt),t(ye,Ct),p(e,st,f),z(je,e,f),p(e,rt,f),p(e,Ne,f),t(Ne,Ut),p(e,ot,f),z(Me,e,f),p(e,lt,f),p(e,he,f),t(he,be),t(be,Xe),z(Ae,Xe,null),t(he,Gt),t(he,Ye),t(Ye,Nt),p(e,nt,f),p(e,Pe,f),t(Pe,Pt),p(e,it,f),z(Fe,e,f),p(e,ct,f),p(e,fe,f),t(fe,ve),t(ve,He),z(Ze,He,null),t(fe,Vt),t(fe,Be),t(Be,zt),p(e,pt,f),p(e,Ve,f),t(Ve,Rt),p(e,ht,f),p(e,$e,f),t($e,Lt),t($e,ze),t(ze,It),t($e,qt),p(e,ft,f),z(xe,e,f),p(e,ut,f),p(e,ue,f),t(ue,we),t(we,Qe),z(Te,Qe,null),t(ue,St),t(ue,De),t(De,Xt),p(e,mt,f),p(e,ke,f),t(ke,Yt),t(ke,Re),t(Re,Ht),t(ke,Bt),p(e,dt,f),p(e,ge,f),t(ge,Qt),t(ge,Le),t(Le,Dt),t(ge,Ot),p(e,yt,f),z(We,e,f),p(e,bt,f),p(e,me,f),t(me,_e),t(_e,Oe),z(Je,Oe,null),t(me,Kt),t(me,Ke),t(Ke,ea),p(e,vt,f),z(Ee,e,f),$t=!0},p(e,[f]){const Ce={};f&2&&(Ce.$$scope={dirty:f,ctx:e}),k.$set(Ce);const et={};f&2&&(et.$$scope={dirty:f,ctx:e}),Ee.$set(et)},i(e){$t||(R(g.$$.fragment,e),R(k.$$.fragment,e),R(ce.$$.fragment,e),R(je.$$.fragment,e),R(Me.$$.fragment,e),R(Ae.$$.fragment,e),R(Fe.$$.fragment,e),R(Ze.$$.fragment,e),R(xe.$$.fragment,e),R(Te.$$.fragment,e),R(We.$$.fragment,e),R(Je.$$.fragment,e),R(Ee.$$.fragment,e),$t=!0)},o(e){L(g.$$.fragment,e),L(k.$$.fragment,e),L(ce.$$.fragment,e),L(je.$$.fragment,e),L(Me.$$.fragment,e),L(Ae.$$.fragment,e),L(Fe.$$.fragment,e),L(Ze.$$.fragment,e),L(xe.$$.fragment,e),L(Te.$$.fragment,e),L(We.$$.fragment,e),L(Je.$$.fragment,e),L(Ee.$$.fragment,e),$t=!1},d(e){a(o),e&&a(_),e&&a(h),I(g),e&&a(F),e&&a(Z),e&&a(Y),I(k,e),e&&a(H),e&&a(v),e&&a(U),e&&a(j),e&&a(X),e&&a(J),I(ce),e&&a(tt),e&&a(Ue),e&&a(at),e&&a(ye),e&&a(st),I(je,e),e&&a(rt),e&&a(Ne),e&&a(ot),I(Me,e),e&&a(lt),e&&a(he),I(Ae),e&&a(nt),e&&a(Pe),e&&a(it),I(Fe,e),e&&a(ct),e&&a(fe),I(Ze),e&&a(pt),e&&a(Ve),e&&a(ht),e&&a($e),e&&a(ft),I(xe,e),e&&a(ut),e&&a(ue),I(Te),e&&a(mt),e&&a(ke),e&&a(dt),e&&a(ge),e&&a(yt),I(We,e),e&&a(bt),e&&a(me),I(Je),e&&a(vt),I(Ee,e)}}}const Qa={local:"load-pretrained-instances-with-an-autoclass",sections:[{local:"autotokenizer",title:"AutoTokenizer"},{local:"autoimageprocessor",title:"AutoImageProcessor"},{local:"autofeatureextractor",title:"AutoFeatureExtractor"},{local:"autoprocessor",title:"AutoProcessor"},{local:"automodel",title:"AutoModel"}],title:"Load pretrained instances with an AutoClass"};function Da(oe){return za(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class ss extends Ga{constructor(o){super();Na(this,o,Da,Ba,Pa,{})}}export{ss as default,Qa as metadata};
