import{S as Ig,i as Pg,s as Xg,e as a,k as i,w as C,t as s,M as Mg,c as l,d as o,m as p,a as r,x as D,h as n,b as v,G as e,g as c,y as L,q,o as A,B as I,v as Bg,L as qg}from"../chunks/vendor-hf-doc-builder.js";import{T as Te}from"../chunks/Tip-hf-doc-builder.js";import{I as gt}from"../chunks/IconCopyLink-hf-doc-builder.js";import{C as F}from"../chunks/CodeBlock-hf-doc-builder.js";import{F as Rg,M as Ag}from"../chunks/Markdown-hf-doc-builder.js";function Fg(X){let d,w,m,_,b,g,O,T,x,$,y,k,N,E,j,P,R,S,U,de,te,ne,H,oe,M,K,W,se,G,he,ue,J,ae,Pe,ce,le,Xe,h,Ne,_t;return{c(){d=a("p"),w=s("You can also export \u{1F917} Transformers models with the "),m=a("a"),_=a("code"),b=s("optimum.exporters.onnx"),g=s(" package"),O=s(`
from \u{1F917} Optimum.`),T=i(),x=a("p"),$=s("Once exported, a model can be:"),y=i(),k=a("ul"),N=a("li"),E=s("Optimized for inference via techniques such as quantization and graph optimization."),j=i(),P=a("li"),R=s("Run with ONNX Runtime via "),S=a("a"),U=a("code"),de=s("ORTModelForXXX"),te=s(" classes"),ne=s(`,
which follow the same `),H=a("code"),oe=s("AutoModel"),M=s(" API as the one you are used to in \u{1F917} Transformers."),K=i(),W=a("li"),se=s("Run with "),G=a("a"),he=s("optimized inference pipelines"),ue=s(`,
which has the same API as the `),J=a("a"),ae=s("pipeline()"),Pe=s(" function in \u{1F917} Transformers."),ce=i(),le=a("p"),Xe=s("To explore all these features,  check out the "),h=a("a"),Ne=s("\u{1F917} Optimum library"),_t=s("."),this.h()},l(B){d=l(B,"P",{});var z=r(d);w=n(z,"You can also export \u{1F917} Transformers models with the "),m=l(z,"A",{href:!0,rel:!0});var vt=r(m);_=l(vt,"CODE",{});var ho=r(_);b=n(ho,"optimum.exporters.onnx"),ho.forEach(o),g=n(vt," package"),vt.forEach(o),O=n(z,`
from \u{1F917} Optimum.`),z.forEach(o),T=p(B),x=l(B,"P",{});var Me=r(x);$=n(Me,"Once exported, a model can be:"),Me.forEach(o),y=p(B),k=l(B,"UL",{});var me=r(k);N=l(me,"LI",{});var uo=r(N);E=n(uo,"Optimized for inference via techniques such as quantization and graph optimization."),uo.forEach(o),j=p(me),P=l(me,"LI",{});var re=r(P);R=n(re,"Run with ONNX Runtime via "),S=l(re,"A",{href:!0,rel:!0});var Et=r(S);U=l(Et,"CODE",{});var mo=r(U);de=n(mo,"ORTModelForXXX"),mo.forEach(o),te=n(Et," classes"),Et.forEach(o),ne=n(re,`,
which follow the same `),H=l(re,"CODE",{});var Be=r(H);oe=n(Be,"AutoModel"),Be.forEach(o),M=n(re," API as the one you are used to in \u{1F917} Transformers."),re.forEach(o),K=p(me),W=l(me,"LI",{});var ge=r(W);se=n(ge,"Run with "),G=l(ge,"A",{href:!0,rel:!0});var go=r(G);he=n(go,"optimized inference pipelines"),go.forEach(o),ue=n(ge,`,
which has the same API as the `),J=l(ge,"A",{href:!0});var Re=r(J);ae=n(Re,"pipeline()"),Re.forEach(o),Pe=n(ge," function in \u{1F917} Transformers."),ge.forEach(o),me.forEach(o),ce=p(B),le=l(B,"P",{});var Fe=r(le);Xe=n(Fe,"To explore all these features,  check out the "),h=l(Fe,"A",{href:!0,rel:!0});var _o=r(h);Ne=n(_o,"\u{1F917} Optimum library"),_o.forEach(o),_t=n(Fe,"."),Fe.forEach(o),this.h()},h(){v(m,"href","https://huggingface.co/docs/optimum/exporters/onnx/usage_guides/export_a_model"),v(m,"rel","nofollow"),v(S,"href","https://huggingface.co/docs/optimum/onnxruntime/package_reference/modeling_ort"),v(S,"rel","nofollow"),v(G,"href","https://huggingface.co/docs/optimum/main/en/onnxruntime/usage_guides/pipelines"),v(G,"rel","nofollow"),v(J,"href","/docs/transformers/main/en/main_classes/pipelines#transformers.pipeline"),v(h,"href","https://github.com/huggingface/optimum"),v(h,"rel","nofollow")},m(B,z){c(B,d,z),e(d,w),e(d,m),e(m,_),e(_,b),e(m,g),e(d,O),c(B,T,z),c(B,x,z),e(x,$),c(B,y,z),c(B,k,z),e(k,N),e(N,E),e(k,j),e(k,P),e(P,R),e(P,S),e(S,U),e(U,de),e(S,te),e(P,ne),e(P,H),e(H,oe),e(P,M),e(k,K),e(k,W),e(W,se),e(W,G),e(G,he),e(W,ue),e(W,J),e(J,ae),e(W,Pe),c(B,ce,z),c(B,le,z),e(le,Xe),e(le,h),e(h,Ne),e(le,_t)},d(B){B&&o(d),B&&o(T),B&&o(x),B&&o(y),B&&o(k),B&&o(ce),B&&o(le)}}}function Sg(X){let d,w,m,_,b,g,O,T,x;return{c(){d=a("p"),w=s(`The recommended way of exporting a model is now to use
`),m=a("a"),_=a("code"),b=s("optimum.exporters.onnx"),g=s(`,
do not worry it is very similar to `),O=a("code"),T=s("transformers.onnx"),x=s("!"),this.h()},l($){d=l($,"P",{});var y=r(d);w=n(y,`The recommended way of exporting a model is now to use
`),m=l(y,"A",{href:!0,rel:!0});var k=r(m);_=l(k,"CODE",{});var N=r(_);b=n(N,"optimum.exporters.onnx"),N.forEach(o),k.forEach(o),g=n(y,`,
do not worry it is very similar to `),O=l(y,"CODE",{});var E=r(O);T=n(E,"transformers.onnx"),E.forEach(o),x=n(y,"!"),y.forEach(o),this.h()},h(){v(m,"href","https://huggingface.co/docs/optimum/main/en/exporters/onnx/usage_guides/export_a_model#exporting-a-model-to-onnx-using-the-cli"),v(m,"rel","nofollow")},m($,y){c($,d,y),e(d,w),e(d,m),e(m,_),e(_,b),e(d,g),e(d,O),e(O,T),e(d,x)},d($){$&&o(d)}}}function zg(X){let d,w,m,_,b,g,O,T,x,$,y,k,N;return d=new F({props:{code:`from transformers import AutoTokenizer, AutoModelForSequenceClassification

# Load tokenizer and PyTorch weights form the Hub
tokenizer = AutoTokenizer.from_pretrained("distilbert-base-uncased")
pt_model = AutoModelForSequenceClassification.from_pretrained("distilbert-base-uncased")
# Save to disk
tokenizer.save_pretrained("local-pt-checkpoint")
pt_model.save_pretrained("local-pt-checkpoint")`,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><span class="hljs-comment"># Load tokenizer and PyTorch weights form the Hub</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>tokenizer = AutoTokenizer.from_pretrained(<span class="hljs-string">&quot;distilbert-base-uncased&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>pt_model = AutoModelForSequenceClassification.from_pretrained(<span class="hljs-string">&quot;distilbert-base-uncased&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># Save to disk</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>tokenizer.save_pretrained(<span class="hljs-string">&quot;local-pt-checkpoint&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>pt_model.save_pretrained(<span class="hljs-string">&quot;local-pt-checkpoint&quot;</span>)`}}),k=new F({props:{code:"python -m transformers.onnx --model=local-pt-checkpoint onnx/",highlighted:"python -m transformers.onnx --model=local-pt-checkpoint onnx/"}}),{c(){C(d.$$.fragment),w=i(),m=a("p"),_=s("Once the checkpoint is saved, we can export it to ONNX by pointing the "),b=a("code"),g=s("--model"),O=s(`
argument of the `),T=a("code"),x=s("transformers.onnx"),$=s(" package to the desired directory:"),y=i(),C(k.$$.fragment)},l(E){D(d.$$.fragment,E),w=p(E),m=l(E,"P",{});var j=r(m);_=n(j,"Once the checkpoint is saved, we can export it to ONNX by pointing the "),b=l(j,"CODE",{});var P=r(b);g=n(P,"--model"),P.forEach(o),O=n(j,`
argument of the `),T=l(j,"CODE",{});var R=r(T);x=n(R,"transformers.onnx"),R.forEach(o),$=n(j," package to the desired directory:"),j.forEach(o),y=p(E),D(k.$$.fragment,E)},m(E,j){L(d,E,j),c(E,w,j),c(E,m,j),e(m,_),e(m,b),e(b,g),e(m,O),e(m,T),e(T,x),e(m,$),c(E,y,j),L(k,E,j),N=!0},p:qg,i(E){N||(q(d.$$.fragment,E),q(k.$$.fragment,E),N=!0)},o(E){A(d.$$.fragment,E),A(k.$$.fragment,E),N=!1},d(E){I(d,E),E&&o(w),E&&o(m),E&&o(y),I(k,E)}}}function Vg(X){let d,w;return d=new Ag({props:{$$slots:{default:[zg]},$$scope:{ctx:X}}}),{c(){C(d.$$.fragment)},l(m){D(d.$$.fragment,m)},m(m,_){L(d,m,_),w=!0},p(m,_){const b={};_&2&&(b.$$scope={dirty:_,ctx:m}),d.$set(b)},i(m){w||(q(d.$$.fragment,m),w=!0)},o(m){A(d.$$.fragment,m),w=!1},d(m){I(d,m)}}}function Hg(X){let d,w,m,_,b,g,O,T,x,$,y,k,N;return d=new F({props:{code:`from transformers import AutoTokenizer, TFAutoModelForSequenceClassification

# Load tokenizer and TensorFlow weights from the Hub
tokenizer = AutoTokenizer.from_pretrained("distilbert-base-uncased")
tf_model = TFAutoModelForSequenceClassification.from_pretrained("distilbert-base-uncased")
# Save to disk
tokenizer.save_pretrained("local-tf-checkpoint")
tf_model.save_pretrained("local-tf-checkpoint")`,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><span class="hljs-comment"># Load tokenizer and TensorFlow weights from the Hub</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>tokenizer = AutoTokenizer.from_pretrained(<span class="hljs-string">&quot;distilbert-base-uncased&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>tf_model = TFAutoModelForSequenceClassification.from_pretrained(<span class="hljs-string">&quot;distilbert-base-uncased&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># Save to disk</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>tokenizer.save_pretrained(<span class="hljs-string">&quot;local-tf-checkpoint&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>tf_model.save_pretrained(<span class="hljs-string">&quot;local-tf-checkpoint&quot;</span>)`}}),k=new F({props:{code:"python -m transformers.onnx --model=local-tf-checkpoint onnx/",highlighted:"python -m transformers.onnx --model=local-tf-checkpoint onnx/"}}),{c(){C(d.$$.fragment),w=i(),m=a("p"),_=s("Once the checkpoint is saved, we can export it to ONNX by pointing the "),b=a("code"),g=s("--model"),O=s(`
argument of the `),T=a("code"),x=s("transformers.onnx"),$=s(" package to the desired directory:"),y=i(),C(k.$$.fragment)},l(E){D(d.$$.fragment,E),w=p(E),m=l(E,"P",{});var j=r(m);_=n(j,"Once the checkpoint is saved, we can export it to ONNX by pointing the "),b=l(j,"CODE",{});var P=r(b);g=n(P,"--model"),P.forEach(o),O=n(j,`
argument of the `),T=l(j,"CODE",{});var R=r(T);x=n(R,"transformers.onnx"),R.forEach(o),$=n(j," package to the desired directory:"),j.forEach(o),y=p(E),D(k.$$.fragment,E)},m(E,j){L(d,E,j),c(E,w,j),c(E,m,j),e(m,_),e(m,b),e(b,g),e(m,O),e(m,T),e(T,x),e(m,$),c(E,y,j),L(k,E,j),N=!0},p:qg,i(E){N||(q(d.$$.fragment,E),q(k.$$.fragment,E),N=!0)},o(E){A(d.$$.fragment,E),A(k.$$.fragment,E),N=!1},d(E){I(d,E),E&&o(w),E&&o(m),E&&o(y),I(k,E)}}}function Wg(X){let d,w;return d=new Ag({props:{$$slots:{default:[Hg]},$$scope:{ctx:X}}}),{c(){C(d.$$.fragment)},l(m){D(d.$$.fragment,m)},m(m,_){L(d,m,_),w=!0},p(m,_){const b={};_&2&&(b.$$scope={dirty:_,ctx:m}),d.$set(b)},i(m){w||(q(d.$$.fragment,m),w=!0)},o(m){A(d.$$.fragment,m),w=!1},d(m){I(d,m)}}}function Gg(X){let d,w,m,_,b,g,O,T;return{c(){d=a("p"),w=s("The recommended way of exporting a model is now to use "),m=a("code"),_=s("optimum.exporters.onnx"),b=s(`.
You can check the `),g=a("a"),O=s("\u{1F917} Optimum documentation"),T=s(`
to learn how to select a task.`),this.h()},l(x){d=l(x,"P",{});var $=r(d);w=n($,"The recommended way of exporting a model is now to use "),m=l($,"CODE",{});var y=r(m);_=n(y,"optimum.exporters.onnx"),y.forEach(o),b=n($,`.
You can check the `),g=l($,"A",{href:!0,rel:!0});var k=r(g);O=n(k,"\u{1F917} Optimum documentation"),k.forEach(o),T=n($,`
to learn how to select a task.`),$.forEach(o),this.h()},h(){v(g,"href","https://huggingface.co/docs/optimum/main/en/exporters/onnx/usage_guides/export_a_model#selecting-a-task"),v(g,"rel","nofollow")},m(x,$){c(x,d,$),e(d,w),e(d,m),e(m,_),e(d,b),e(d,g),e(g,O),e(d,T)},d(x){x&&o(d)}}}function Yg(X){let d,w,m,_,b,g,O,T;return{c(){d=a("p"),w=s("The features that have a "),m=a("code"),_=s("with-past"),b=s(" suffix (like "),g=a("code"),O=s("causal-lm-with-past"),T=s(`) correspond to
model classes with precomputed hidden states (key and values in the attention blocks)
that can be used for fast autoregressive decoding.`)},l(x){d=l(x,"P",{});var $=r(d);w=n($,"The features that have a "),m=l($,"CODE",{});var y=r(m);_=n(y,"with-past"),y.forEach(o),b=n($," suffix (like "),g=l($,"CODE",{});var k=r(g);O=n(k,"causal-lm-with-past"),k.forEach(o),T=n($,`) correspond to
model classes with precomputed hidden states (key and values in the attention blocks)
that can be used for fast autoregressive decoding.`),$.forEach(o)},m(x,$){c(x,d,$),e(d,w),e(d,m),e(m,_),e(d,b),e(d,g),e(g,O),e(d,T)},d(x){x&&o(d)}}}function Ug(X){let d,w,m,_,b,g,O,T,x,$,y;return{c(){d=a("p"),w=s("For "),m=a("code"),_=s("VisionEncoderDecoder"),b=s(` type models, the encoder and decoder parts are
exported separately as two ONNX files named `),g=a("code"),O=s("encoder_model.onnx"),T=s(" and "),x=a("code"),$=s("decoder_model.onnx"),y=s(" respectively.")},l(k){d=l(k,"P",{});var N=r(d);w=n(N,"For "),m=l(N,"CODE",{});var E=r(m);_=n(E,"VisionEncoderDecoder"),E.forEach(o),b=n(N,` type models, the encoder and decoder parts are
exported separately as two ONNX files named `),g=l(N,"CODE",{});var j=r(g);O=n(j,"encoder_model.onnx"),j.forEach(o),T=n(N," and "),x=l(N,"CODE",{});var P=r(x);$=n(P,"decoder_model.onnx"),P.forEach(o),y=n(N," respectively."),N.forEach(o)},m(k,N){c(k,d,N),e(d,w),e(d,m),e(m,_),e(d,b),e(d,g),e(g,O),e(d,T),e(d,x),e(x,$),e(d,y)},d(k){k&&o(d)}}}function Kg(X){let d,w,m,_,b,g,O,T,x;return{c(){d=a("p"),w=s(`If you wish to contribute by adding support for a model that cannot be currently exported, you should first check if it is
supported in `),m=a("a"),_=a("code"),b=s("optimum.exporters.onnx"),g=s(`,
and if it is not, `),O=a("a"),T=s("contribute to \u{1F917} Optimum"),x=s(`
directly.`),this.h()},l($){d=l($,"P",{});var y=r(d);w=n(y,`If you wish to contribute by adding support for a model that cannot be currently exported, you should first check if it is
supported in `),m=l(y,"A",{href:!0,rel:!0});var k=r(m);_=l(k,"CODE",{});var N=r(_);b=n(N,"optimum.exporters.onnx"),N.forEach(o),k.forEach(o),g=n(y,`,
and if it is not, `),O=l(y,"A",{href:!0,rel:!0});var E=r(O);T=n(E,"contribute to \u{1F917} Optimum"),E.forEach(o),x=n(y,`
directly.`),y.forEach(o),this.h()},h(){v(m,"href","https://huggingface.co/docs/optimum/main/en/exporters/onnx/package_reference/configuration#supported-architectures"),v(m,"rel","nofollow"),v(O,"href","https://huggingface.co/docs/optimum/main/en/exporters/onnx/usage_guides/contribute"),v(O,"rel","nofollow")},m($,y){c($,d,y),e(d,w),e(d,m),e(m,_),e(_,b),e(d,g),e(d,O),e(O,T),e(d,x)},d($){$&&o(d)}}}function Jg(X){let d,w,m,_,b;return{c(){d=a("p"),w=s(`A good way to implement a custom ONNX configuration is to look at the existing
implementation in the `),m=a("code"),_=s("configuration_<model_name>.py"),b=s(" file of a similar architecture.")},l(g){d=l(g,"P",{});var O=r(d);w=n(O,`A good way to implement a custom ONNX configuration is to look at the existing
implementation in the `),m=l(O,"CODE",{});var T=r(m);_=n(T,"configuration_<model_name>.py"),T.forEach(o),b=n(O," file of a similar architecture."),O.forEach(o)},m(g,O){c(g,d,O),e(d,w),e(d,m),e(m,_),e(d,b)},d(g){g&&o(d)}}}function Qg(X){let d,w,m,_,b,g,O,T,x,$,y,k,N,E,j,P,R,S,U,de,te,ne,H;return{c(){d=a("p"),w=s("Notice that "),m=a("code"),_=s("inputs"),b=s(" property for "),g=a("code"),O=s("DistilBertOnnxConfig"),T=s(" returns an "),x=a("code"),$=s("OrderedDict"),y=s(`. This
ensures that the inputs are matched with their relative position within the
`),k=a("code"),N=s("PreTrainedModel.forward()"),E=s(` method when tracing the graph. We recommend using an
`),j=a("code"),P=s("OrderedDict"),R=s(" for the "),S=a("code"),U=s("inputs"),de=s(" and "),te=a("code"),ne=s("outputs"),H=s(` properties when implementing custom ONNX
configurations.`)},l(oe){d=l(oe,"P",{});var M=r(d);w=n(M,"Notice that "),m=l(M,"CODE",{});var K=r(m);_=n(K,"inputs"),K.forEach(o),b=n(M," property for "),g=l(M,"CODE",{});var W=r(g);O=n(W,"DistilBertOnnxConfig"),W.forEach(o),T=n(M," returns an "),x=l(M,"CODE",{});var se=r(x);$=n(se,"OrderedDict"),se.forEach(o),y=n(M,`. This
ensures that the inputs are matched with their relative position within the
`),k=l(M,"CODE",{});var G=r(k);N=n(G,"PreTrainedModel.forward()"),G.forEach(o),E=n(M,` method when tracing the graph. We recommend using an
`),j=l(M,"CODE",{});var he=r(j);P=n(he,"OrderedDict"),he.forEach(o),R=n(M," for the "),S=l(M,"CODE",{});var ue=r(S);U=n(ue,"inputs"),ue.forEach(o),de=n(M," and "),te=l(M,"CODE",{});var J=r(te);ne=n(J,"outputs"),J.forEach(o),H=n(M,` properties when implementing custom ONNX
configurations.`),M.forEach(o)},m(oe,M){c(oe,d,M),e(d,w),e(d,m),e(m,_),e(d,b),e(d,g),e(g,O),e(d,T),e(d,x),e(x,$),e(d,y),e(d,k),e(k,N),e(d,E),e(d,j),e(j,P),e(d,R),e(d,S),e(S,U),e(d,de),e(d,te),e(te,ne),e(d,H)},d(oe){oe&&o(d)}}}function Zg(X){let d,w,m,_,b,g,O,T;return{c(){d=a("p"),w=s("All of the base properties and methods associated with "),m=a("a"),_=s("OnnxConfig"),b=s(` and
the other configuration classes can be overridden if needed. Check out `),g=a("code"),O=s("BartOnnxConfig"),T=s(`
for an advanced example.`),this.h()},l(x){d=l(x,"P",{});var $=r(d);w=n($,"All of the base properties and methods associated with "),m=l($,"A",{href:!0});var y=r(m);_=n(y,"OnnxConfig"),y.forEach(o),b=n($,` and
the other configuration classes can be overridden if needed. Check out `),g=l($,"CODE",{});var k=r(g);O=n(k,"BartOnnxConfig"),k.forEach(o),T=n($,`
for an advanced example.`),$.forEach(o),this.h()},h(){v(m,"href","/docs/transformers/main/en/main_classes/onnx#transformers.onnx.OnnxConfig")},m(x,$){c(x,d,$),e(d,w),e(d,m),e(m,_),e(d,b),e(d,g),e(g,O),e(d,T)},d(x){x&&o(d)}}}function e_(X){let d,w,m,_,b,g,O,T,x,$,y;return{c(){d=a("p"),w=s(`If your model is larger than 2GB, you will see that many additional files are created
during the export. This is `),m=a("em"),_=s("expected"),b=s(" because ONNX uses "),g=a("a"),O=s(`Protocol
Buffers`),T=s(` to store the model and these
have a size limit of 2GB. See the `),x=a("a"),$=s(`ONNX
documentation`),y=s(` for
instructions on how to load models with external data.`),this.h()},l(k){d=l(k,"P",{});var N=r(d);w=n(N,`If your model is larger than 2GB, you will see that many additional files are created
during the export. This is `),m=l(N,"EM",{});var E=r(m);_=n(E,"expected"),E.forEach(o),b=n(N," because ONNX uses "),g=l(N,"A",{href:!0,rel:!0});var j=r(g);O=n(j,`Protocol
Buffers`),j.forEach(o),T=n(N,` to store the model and these
have a size limit of 2GB. See the `),x=l(N,"A",{href:!0,rel:!0});var P=r(x);$=n(P,`ONNX
documentation`),P.forEach(o),y=n(N,` for
instructions on how to load models with external data.`),N.forEach(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gc,_c,ha,vc,Ec,Bl,Zt,Rl,rt,Fl,qe,it,ua,eo,$c,ma,wc,Sl,xe,xc,ga,bc,kc,_a,yc,Oc,zl,to,Vl,Y,Tc,va,Nc,jc,Ea,Cc,Dc,$a,Lc,qc,wa,Ac,Ic,xa,Pc,Xc,Hl,oo,Wl,pt,Gl,Ae,ft,ba,so,Mc,ka,Bc,Yl,be,Rc,ya,Fc,Sc,Oa,zc,Vc,Ul,no,Kl,dt,Hc,Xo,Wc,Gc,Jl,Ie,ct,Ta,ao,Yc,Na,Uc,Ql,Mo,Kc,Zl,ke,lo,Jc,ja,Qc,Zc,eh,Bo,th,Ca,oh,sh,Ro,nh,Da,ah,er,ht,lh,ro,rh,ih,tr;return g=new gt({}),ae=new Te({props:{$$slots:{default:[Fg]},$$scope:{ctx:X}}}),wt=new gt({}),Ve=new Te({props:{$$slots:{default:[Sg]},$$scope:{ctx:X}}}),xt=new F({props:{code:"pip install transformers[onnx]",highlighted:"pip install transformers[onnx]"}}),bt=new F({props:{code:`python -m transformers.onnx --help

usage: Hugging Face Transformers ONNX exporter [-h] -m MODEL [--feature {causal-lm, ...}] [--opset OPSET] [--atol ATOL] output

positional arguments:
  output                Path indicating where to store generated ONNX model.

optional arguments:
  -h, --help            show this help message and exit
  -m MODEL, --model MODEL
                        Model ID on huggingface.co or path on disk to load model from.
  --feature {causal-lm, ...}
                        The type of features to export the model with.
  --opset OPSET         ONNX opset version to export the model with.
  --atol ATOL           Absolute difference tolerance when validating the model.`,highlighted:`python -m transformers.onnx --<span class="hljs-built_in">help</span>

usage: Hugging Face Transformers ONNX exporter [-h] -m MODEL [--feature {causal-lm, ...}] [--opset OPSET] [--atol ATOL] output

positional arguments:
  output                Path indicating <span class="hljs-built_in">where</span> to store generated ONNX model.

optional arguments:
  -h, --<span class="hljs-built_in">help</span>            show this <span class="hljs-built_in">help</span> message and <span class="hljs-built_in">exit</span>
  -m MODEL, --model MODEL
                        Model ID on huggingface.co or path on disk to load model from.
  --feature {causal-lm, ...}
                        The <span class="hljs-built_in">type</span> of features to <span class="hljs-built_in">export</span> the model with.
  --opset OPSET         ONNX opset version to <span class="hljs-built_in">export</span> the model with.
  --atol ATOL           Absolute difference tolerance when validating the model.`}}),kt=new F({props:{code:"python -m transformers.onnx --model=distilbert-base-uncased onnx/",highlighted:"python -m transformers.onnx --model=distilbert-base-uncased onnx/"}}),yt=new F({props:{code:`Validating ONNX model...
        -[\u2713] ONNX model output names match reference model ({'last_hidden_state'})
        - Validating ONNX Model output "last_hidden_state":
                -[\u2713] (2, 8, 768) matches (2, 8, 768)
                -[\u2713] all values close (atol: 1e-05)
All good, model saved at: onnx/model.onnx`,highlighted:`Validating ONNX model...
        -[\u2713] ONNX model output names match reference model ({<span class="hljs-string">&#x27;last_hidden_state&#x27;</span>})
        - Validating ONNX Model output <span class="hljs-string">&quot;last_hidden_state&quot;</span>:
                -[\u2713] (2, 8, 768) matches (2, 8, 768)
                -[\u2713] all values close (atol: 1e-05)
All good, model saved at: onnx/model.onnx`}}),Nt=new F({props:{code:`from transformers import AutoTokenizer
from onnxruntime import InferenceSession

tokenizer = AutoTokenizer.from_pretrained("distilbert-base-uncased")
session = InferenceSession("onnx/model.onnx")
# ONNX Runtime expects NumPy arrays as input
inputs = tokenizer("Using DistilBERT with ONNX Runtime!", return_tensors="np")
outputs = session.run(output_names=["last_hidden_state"], input_feed=dict(inputs))`,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><span class="hljs-keyword">from</span> onnxruntime <span class="hljs-keyword">import</span> InferenceSession

<span class="hljs-meta">&gt;&gt;&gt; </span>tokenizer = AutoTokenizer.from_pretrained(<span class="hljs-string">&quot;distilbert-base-uncased&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>session = InferenceSession(<span class="hljs-string">&quot;onnx/model.onnx&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># ONNX Runtime expects NumPy arrays as input</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>inputs = tokenizer(<span class="hljs-string">&quot;Using DistilBERT with ONNX Runtime!&quot;</span>, return_tensors=<span class="hljs-string">&quot;np&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>outputs = session.run(output_names=[<span class="hljs-string">&quot;last_hidden_state&quot;</span>], input_feed=<span class="hljs-built_in">dict</span>(inputs))`}}),jt=new F({props:{code:`from transformers.models.distilbert import DistilBertConfig, DistilBertOnnxConfig

config = DistilBertConfig()
onnx_config = DistilBertOnnxConfig(config)
print(list(onnx_config.outputs.keys()))`,highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers.models.distilbert <span class="hljs-keyword">import</span> DistilBertConfig, DistilBertOnnxConfig

<span class="hljs-meta">&gt;&gt;&gt; </span>config = DistilBertConfig()
<span class="hljs-meta">&gt;&gt;&gt; </span>onnx_config = DistilBertOnnxConfig(config)
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-built_in">print</span>(<span class="hljs-built_in">list</span>(onnx_config.outputs.keys()))
[<span class="hljs-string">&quot;last_hidden_state&quot;</span>]`}}),Dt=new F({props:{code:"python -m transformers.onnx --model=keras-io/transformers-qa onnx/",highlighted:"python -m transformers.onnx --model=keras-io/transformers-qa onnx/"}}),Ye=new Rg({props:{pytorch:!0,tensorflow:!0,jax:!1,$$slots:{tensorflow:[Wg],pytorch:[Vg]},$$scope:{ctx:X}}}),Lt=new gt({}),Ke=new Te({props:{$$slots:{default:[Gg]},$$scope:{ctx:X}}}),Vt=new F({props:{code:`from transformers.onnx.features import FeaturesManager

distilbert_features = list(FeaturesManager.get_supported_features_for_model_type("distilbert").keys())
print(distilbert_features)`,highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers.onnx.features <span class="hljs-keyword">import</span> FeaturesManager

<span class="hljs-meta">&gt;&gt;&gt; </span>distilbert_features = <span class="hljs-built_in">list</span>(FeaturesManager.get_supported_features_for_model_type(<span class="hljs-string">&quot;distilbert&quot;</span>).keys())
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-built_in">print</span>(distilbert_features)
[<span class="hljs-string">&quot;default&quot;</span>, <span class="hljs-string">&quot;masked-lm&quot;</span>, <span class="hljs-string">&quot;causal-lm&quot;</span>, <span class="hljs-string">&quot;sequence-classification&quot;</span>, <span class="hljs-string">&quot;token-classification&quot;</span>, <span class="hljs-string">&quot;question-answering&quot;</span>]`}}),Ht=new F({props:{code:`python -m transformers.onnx --model=distilbert-base-uncased-finetuned-sst-2-english \\
                            --feature=sequence-classification onnx/`,highlighted:`python -m transformers.onnx --model=distilbert-base-uncased-finetuned-sst-2-english \\
                            --feature=sequence-classification onnx/`}}),Wt=new F({props:{code:`Validating ONNX model...
        -[\u2713] ONNX model output names match reference model ({'logits'})
        - Validating ONNX Model output "logits":
                -[\u2713] (2, 2) matches (2, 2)
                -[\u2713] all values close (atol: 1e-05)
All good, model saved at: onnx/model.onnx`,highlighted:`Validating ONNX model...
        -[\u2713] ONNX model output names match reference model ({<span class="hljs-string">&#x27;logits&#x27;</span>})
        - Validating ONNX Model output <span class="hljs-string">&quot;logits&quot;</span>:
                -[\u2713] (2, 2) matches (2, 2)
                -[\u2713] all values close (atol: 1e-05)
All good, model saved at: onnx/model.onnx`}}),Ze=new Te({props:{$$slots:{default:[Yg]},$$scope:{ctx:X}}}),et=new Te({props:{$$slots:{default:[Ug]},$$scope:{ctx:X}}}),Gt=new gt({}),ot=new Te({props:{$$slots:{default:[Kg]},$$scope:{ctx:X}}}),Yt=new gt({}),nt=new Te({props:{$$slots:{default:[Jg]},$$scope:{ctx:X}}}),Ut=new F({props:{code:`from typing import Mapping, OrderedDict
from transformers.onnx import OnnxConfig


class DistilBertOnnxConfig(OnnxConfig):
    @property
    def inputs(self) -> Mapping[str, Mapping[int, str]]:
        return OrderedDict(
            [
                ("input_ids", {0: "batch", 1: "sequence"}),
                ("attention_mask", {0: "batch", 1: "sequence"}),
            ]
        )`,highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> typing <span class="hljs-keyword">import</span> Mapping, OrderedDict
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers.onnx <span class="hljs-keyword">import</span> OnnxConfig


<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">class</span> <span class="hljs-title class_">DistilBertOnnxConfig</span>(<span class="hljs-title class_ inherited__">OnnxConfig</span>):
<span class="hljs-meta">... </span>    @<span class="hljs-built_in">property</span>
<span class="hljs-meta">... </span>    <span class="hljs-keyword">def</span> <span class="hljs-title function_">inputs</span>(<span class="hljs-params">self</span>) -&gt; Mapping[<span class="hljs-built_in">str</span>, Mapping[<span class="hljs-built_in">int</span>, <span class="hljs-built_in">str</span>]]:
<span class="hljs-meta">... </span>        <span class="hljs-keyword">return</span> OrderedDict(
<span class="hljs-meta">... </span>            [
<span class="hljs-meta">... </span>                (<span class="hljs-string">&quot;input_ids&quot;</span>, {<span class="hljs-number">0</span>: <span class="hljs-string">&quot;batch&quot;</span>, <span class="hljs-number">1</span>: <span class="hljs-string">&quot;sequence&quot;</span>}),
<span class="hljs-meta">... </span>                (<span class="hljs-string">&quot;attention_mask&quot;</span>, {<span class="hljs-number">0</span>: <span class="hljs-string">&quot;batch&quot;</span>, <span class="hljs-number">1</span>: <span class="hljs-string">&quot;sequence&quot;</span>}),
<span class="hljs-meta">... </span>            ]
<span class="hljs-meta">... </span>        )`}}),lt=new Te({props:{$$slots:{default:[Qg]},$$scope:{ctx:X}}}),Kt=new F({props:{code:`from transformers import AutoConfig

config = AutoConfig.from_pretrained("distilbert-base-uncased")
onnx_config = DistilBertOnnxConfig(config)`,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>config = AutoConfig.from_pretrained(<span class="hljs-string">&quot;distilbert-base-uncased&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>onnx_config = DistilBertOnnxConfig(config)`}}),Jt=new F({props:{code:"print(onnx_config.default_onnx_opset)",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-built_in">print</span>(onnx_config.default_onnx_opset)
<span class="hljs-number">11</span>`}}),Qt=new F({props:{code:"print(onnx_config.outputs)",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-built_in">print</span>(onnx_config.outputs)
OrderedDict([(<span class="hljs-string">&quot;last_hidden_state&quot;</span>, {<span class="hljs-number">0</span>: <span class="hljs-string">&quot;batch&quot;</span>, <span class="hljs-number">1</span>: <span class="hljs-string">&quot;sequence&quot;</span>})])`}}),Zt=new F({props:{code:`from transformers import AutoConfig

config = AutoConfig.from_pretrained("distilbert-base-uncased")
onnx_config_for_seq_clf = DistilBertOnnxConfig(config, task="sequence-classification")
print(onnx_config_for_seq_clf.outputs)`,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>config = AutoConfig.from_pretrained(<span class="hljs-string">&quot;distilbert-base-uncased&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>onnx_config_for_seq_clf = DistilBertOnnxConfig(config, task=<span class="hljs-string">&quot;sequence-classification&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-built_in">print</span>(onnx_config_for_seq_clf.outputs)
OrderedDict([(<span class="hljs-string">&#x27;logits&#x27;</span>, {<span class="hljs-number">0</span>: <span class="hljs-string">&#x27;batch&#x27;</span>})])`}}),rt=new Te({props:{$$slots:{default:[Zg]},$$scope:{ctx:X}}}),eo=new gt({}),to=new F({props:{code:`from pathlib import Path
from transformers.onnx import export
from transformers import AutoTokenizer, AutoModel

onnx_path = Path("model.onnx")
model_ckpt = "distilbert-base-uncased"
base_model = AutoModel.from_pretrained(model_ckpt)
tokenizer = AutoTokenizer.from_pretrained(model_ckpt)

onnx_inputs, onnx_outputs = export(tokenizer, base_model, onnx_config, onnx_config.default_onnx_opset, onnx_path)`,highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> pathlib <span class="hljs-keyword">import</span> Path
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers.onnx <span class="hljs-keyword">import</span> export
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoTokenizer, AutoModel

<span class="hljs-meta">&gt;&gt;&gt; </span>onnx_path = Path(<span class="hljs-string">&quot;model.onnx&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>model_ckpt = <span class="hljs-string">&quot;distilbert-base-uncased&quot;</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>base_model = AutoModel.from_pretrained(model_ckpt)
<span class="hljs-meta">&gt;&gt;&gt; </span>tokenizer = AutoTokenizer.from_pretrained(model_ckpt)

<span class="hljs-meta">&gt;&gt;&gt; </span>onnx_inputs, onnx_outputs = export(tokenizer, base_model, onnx_config, onnx_config.default_onnx_opset, onnx_path)`}}),oo=new F({props:{code:`import onnx

onnx_model = onnx.load("model.onnx")
onnx.checker.check_model(onnx_model)`,highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">import</span> onnx

<span class="hljs-meta">&gt;&gt;&gt; </span>onnx_model = onnx.load(<span class="hljs-string">&quot;model.onnx&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>onnx.checker.check_model(onnx_model)`}}),pt=new Te({props:{$$slots:{default:[e_]},$$scope:{ctx:X}}}),so=new gt({}),no=new F({props:{code:`from transformers.onnx import validate_model_outputs

validate_model_outputs(
    onnx_config, tokenizer, base_model, onnx_path, onnx_outputs, onnx_config.atol_for_validation
)`,highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers.onnx <span class="hljs-keyword">import</span> validate_model_outputs

<span class="hljs-meta">&gt;&gt;&gt; </span>validate_model_outputs(
<span class="hljs-meta">... </span>    onnx_config, tokenizer, base_model, onnx_path, onnx_outputs, onnx_config.atol_for_validation
<span class="hljs-meta">... </span>)`}}),ao=new gt({}),{c(){d=a("meta"),w=i(),m=a("h1"),_=a("a"),b=a("span"),C(g.$$.fragment),O=i(),T=a("span"),x=s("Export to ONNX"),$=i(),y=a("p"),k=s(`If you need to deploy \u{1F917} Transformers models in production environments, we recommend
exporting them to a serialized format that can be loaded and executed on specialized
runtimes and hardware. In this guide, we\u2019ll show you how to export \u{1F917} Transformers
models to `),N=a("a"),E=s("ONNX (Open Neural Network eXchange)"),j=s("."),P=i(),R=a("p"),S=s(`ONNX is an open standard that defines a common set of operators and a common file format
to represent deep learning models in a wide variety of frameworks, including PyTorch and
TensorFlow. When a model is exported to the ONNX format, these operators are used to
construct a computational graph (often called an `),U=a("em"),de=s("intermediate representation"),te=s(`) which
represents the flow of data through the neural network.`),ne=i(),H=a("p"),oe=s(`By exposing a graph with standardized operators and data types, ONNX makes it easy to
switch between frameworks. For example, a model trained in PyTorch can be exported to
ONNX format and then imported in TensorFlow (and vice versa).`),M=i(),K=a("p"),W=s("\u{1F917} Transformers provides a "),se=a("a"),G=a("code"),he=s("transformers.onnx"),ue=s(` package that enables
you to convert model checkpoints to an ONNX graph by leveraging configuration objects.
These configuration objects come ready made for a number of model architectures, and are
designed to be easily extendable to other architectures.`),J=i(),C(ae.$$.fragment),Pe=i(),ce=a("p"),le=s("Ready-made configurations include the following architectures:"),Xe=i(),h=a("ul"),Ne=a("li"),_t=s("ALBERT"),B=i(),z=a("li"),vt=s("BART"),ho=i(),Me=a("li"),me=s("BEiT"),uo=i(),re=a("li"),Et=s("BERT"),mo=i(),Be=a("li"),ge=s("BigBird"),go=i(),Re=a("li"),Fe=s("BigBird-Pegasus"),_o=i(),Uo=a("li"),Dr=s("Blenderbot"),Lr=i(),Ko=a("li"),qr=s("BlenderbotSmall"),Ar=i(),Jo=a("li"),Ir=s("BLOOM"),Pr=i(),Qo=a("li"),Xr=s("CamemBERT"),Mr=i(),Zo=a("li"),Br=s("Chinese-CLIP"),Rr=i(),es=a("li"),Fr=s("CLIP"),Sr=i(),ts=a("li"),zr=s("CodeGen"),Vr=i(),os=a("li"),Hr=s("Conditional DETR"),Wr=i(),ss=a("li"),Gr=s("ConvBERT"),Yr=i(),ns=a("li"),Ur=s("ConvNeXT"),Kr=i(),as=a("li"),Jr=s("Data2VecText"),Qr=i(),ls=a("li"),Zr=s("Data2VecVision"),ei=i(),rs=a("li"),ti=s("DeBERTa"),oi=i(),is=a("li"),si=s("DeBERTa-v2"),ni=i(),ps=a("li"),ai=s("DeiT"),li=i(),fs=a("li"),ri=s("DETR"),ii=i(),ds=a("li"),pi=s("DistilBERT"),fi=i(),cs=a("li"),di=s("ELECTRA"),ci=i(),hs=a("li"),hi=s("ERNIE"),ui=i(),us=a("li"),mi=s("FlauBERT"),gi=i(),ms=a("li"),_i=s("GPT Neo"),vi=i(),gs=a("li"),Ei=s("GPT-J"),$i=i(),_s=a("li"),wi=s("GPT-Sw3"),xi=i(),vs=a("li"),bi=s("GroupViT"),ki=i(),Es=a("li"),yi=s("I-BERT"),Oi=i(),$s=a("li"),Ti=s("ImageGPT"),Ni=i(),ws=a("li"),ji=s("LayoutLM"),Ci=i(),xs=a("li"),Di=s("LayoutLMv3"),Li=i(),bs=a("li"),qi=s("LeViT"),Ai=i(),ks=a("li"),Ii=s("Longformer"),Pi=i(),ys=a("li"),Xi=s("LongT5"),Mi=i(),Os=a("li"),Bi=s("M2M100"),Ri=i(),Ts=a("li"),Fi=s("Marian"),Si=i(),Ns=a("li"),zi=s("mBART"),Vi=i(),js=a("li"),Hi=s("MobileBERT"),Wi=i(),Cs=a("li"),Gi=s("MobileNetV1"),Yi=i(),Ds=a("li"),Ui=s("MobileNetV2"),Ki=i(),Ls=a("li"),Ji=s("MobileViT"),Qi=i(),qs=a("li"),Zi=s("MT5"),ep=i(),As=a("li"),tp=s("OpenAI GPT-2"),op=i(),Is=a("li"),sp=s("OWL-ViT"),np=i(),Ps=a("li"),ap=s("Perceiver"),lp=i(),Xs=a("li"),rp=s("PLBart"),ip=i(),Ms=a("li"),pp=s("PoolFormer"),fp=i(),Bs=a("li"),dp=s("RemBERT"),cp=i(),Rs=a("li"),hp=s("ResNet"),up=i(),Fs=a("li"),mp=s("RoBERTa"),gp=i(),Ss=a("li"),_p=s("RoBERTa-PreLayerNorm"),vp=i(),zs=a("li"),Ep=s("RoFormer"),$p=i(),Vs=a("li"),wp=s("SegFormer"),xp=i(),Hs=a("li"),bp=s("SqueezeBERT"),kp=i(),Ws=a("li"),yp=s("Swin Transformer"),Op=i(),Gs=a("li"),Tp=s("T5"),Np=i(),Ys=a("li"),jp=s("Table Transformer"),Cp=i(),Us=a("li"),Dp=s("Vision Encoder decoder"),Lp=i(),Ks=a("li"),qp=s("ViT"),Ap=i(),Js=a("li"),Ip=s("Whisper"),Pp=i(),Qs=a("li"),Xp=s("XLM"),Mp=i(),Zs=a("li"),Bp=s("XLM-RoBERTa"),Rp=i(),en=a("li"),Fp=s("XLM-RoBERTa-XL"),Sp=i(),tn=a("li"),zp=s("YOLOS"),Ba=i(),vo=a("p"),Vp=s("In the next two sections, we\u2019ll show you how to:"),Ra=i(),Se=a("ul"),$t=a("li"),Hp=s("Export a supported model using the "),on=a("code"),Wp=s("transformers.onnx"),Gp=s(" package."),Yp=i(),sn=a("li"),Up=s("Export a custom model for an unsupported architecture."),Fa=i(),je=a("h2"),ze=a("a"),nn=a("span"),C(wt.$$.fragment),Kp=i(),an=a("span"),Jp=s("Exporting a model to ONNX"),Sa=i(),C(Ve.$$.fragment),za=i(),Eo=a("p"),Qp=s(`To export a \u{1F917} Transformers model to ONNX, you\u2019ll first need to install some extra
dependencies:`),Va=i(),C(xt.$$.fragment),Ha=i(),He=a("p"),Zp=s("The "),ln=a("code"),ef=s("transformers.onnx"),tf=s(" package can then be used as a Python module:"),Wa=i(),C(bt.$$.fragment),Ga=i(),$o=a("p"),of=s("Exporting a checkpoint using a ready-made configuration can be done as follows:"),Ya=i(),C(kt.$$.fragment),Ua=i(),wo=a("p"),sf=s("You should see the following logs:"),Ka=i(),C(yt.$$.fragment),Ja=i(),_e=a("p"),nf=s("This exports an ONNX graph of the checkpoint defined by the "),rn=a("code"),af=s("--model"),lf=s(` argument. In this
example, it is `),pn=a("code"),rf=s("distilbert-base-uncased"),pf=s(`, but it can be any checkpoint on the Hugging
Face Hub or one that\u2019s stored locally.`),Qa=i(),ie=a("p"),ff=s("The resulting "),fn=a("code"),df=s("model.onnx"),cf=s(" file can then be run on one of the "),Ot=a("a"),hf=s(`many
accelerators`),uf=s(` that support the ONNX
standard. For example, we can load and run the model with `),Tt=a("a"),mf=s(`ONNX
Runtime`),gf=s(" as follows:"),Za=i(),C(Nt.$$.fragment),el=i(),We=a("p"),_f=s("The required output names (like "),dn=a("code"),vf=s('["last_hidden_state"]'),Ef=s(`) can be obtained by taking a
look at the ONNX configuration of each model. For example, for DistilBERT we have:`),tl=i(),C(jt.$$.fragment),ol=i(),Ge=a("p"),$f=s(`The process is identical for TensorFlow checkpoints on the Hub. For example, we can
export a pure TensorFlow checkpoint from the `),Ct=a("a"),wf=s(`Keras
organization`),xf=s(" as follows:"),sl=i(),C(Dt.$$.fragment),nl=i(),xo=a("p"),bf=s(`To export a model that\u2019s stored locally, you\u2019ll need to have the model\u2019s weights and
tokenizer files stored in a directory. For example, we can load and save a checkpoint as
follows:`),al=i(),C(Ye.$$.fragment),ll=i(),Ce=a("h2"),Ue=a("a"),cn=a("span"),C(Lt.$$.fragment),kf=i(),hn=a("span"),yf=s("Selecting features for different model tasks"),rl=i(),C(Ke.$$.fragment),il=i(),ve=a("p"),Of=s("Each ready-made configuration comes with a set of "),un=a("em"),Tf=s("features"),Nf=s(` that enable you to export
models for different types of tasks. As shown in the table below, each feature is
associated with a different `),mn=a("code"),jf=s("AutoClass"),Cf=s(":"),pl=i(),Je=a("table"),gn=a("thead"),qt=a("tr"),_n=a("th"),Df=s("Feature"),Lf=i(),vn=a("th"),qf=s("Auto Class"),Af=i(),V=a("tbody"),At=a("tr"),It=a("td"),En=a("code"),If=s("causal-lm"),Pf=s(", "),$n=a("code"),Xf=s("causal-lm-with-past"),Mf=i(),wn=a("td"),xn=a("code"),Bf=s("AutoModelForCausalLM"),Rf=i(),Pt=a("tr"),Xt=a("td"),bn=a("code"),Ff=s("default"),Sf=s(", "),kn=a("code"),zf=s("default-with-past"),Vf=i(),yn=a("td"),On=a("code"),Hf=s("AutoModel"),Wf=i(),Mt=a("tr"),Tn=a("td"),Nn=a("code"),Gf=s("masked-lm"),Yf=i(),jn=a("td"),Cn=a("code"),Uf=s("AutoModelForMaskedLM"),Kf=i(),Bt=a("tr"),Dn=a("td"),Ln=a("code"),Jf=s("question-answering"),Qf=i(),qn=a("td"),An=a("code"),Zf=s("AutoModelForQuestionAnswering"),ed=i(),Rt=a("tr"),Ft=a("td"),In=a("code"),td=s("seq2seq-lm"),od=s(", "),Pn=a("code"),sd=s("seq2seq-lm-with-past"),nd=i(),Xn=a("td"),Mn=a("code"),ad=s("AutoModelForSeq2SeqLM"),ld=i(),St=a("tr"),Bn=a("td"),Rn=a("code"),rd=s("sequence-classification"),id=i(),Fn=a("td"),Sn=a("code"),pd=s("AutoModelForSequenceClassification"),fd=i(),zt=a("tr"),zn=a("td"),Vn=a("code"),dd=s("token-classification"),cd=i(),Hn=a("td"),Wn=a("code"),hd=s("AutoModelForTokenClassification"),fl=i(),Qe=a("p"),ud=s(`For each configuration, you can find the list of supported features via the
`),bo=a("a"),md=s("FeaturesManager"),gd=s(". For example, for DistilBERT we have:"),dl=i(),C(Vt.$$.fragment),cl=i(),Ee=a("p"),_d=s("You can then pass one of these features to the "),Gn=a("code"),vd=s("--feature"),Ed=s(` argument in the
`),Yn=a("code"),$d=s("transformers.onnx"),wd=s(` package. For example, to export a text-classification model we can
pick a fine-tuned model from the Hub and run:`),hl=i(),C(Ht.$$.fragment),ul=i(),ko=a("p"),xd=s("This displays the following logs:"),ml=i(),C(Wt.$$.fragment),gl=i(),pe=a("p"),bd=s("Notice that in this case, the output names from the fine-tuned model are "),Un=a("code"),kd=s("logits"),yd=s(`
instead of the `),Kn=a("code"),Od=s("last_hidden_state"),Td=s(" we saw with the "),Jn=a("code"),Nd=s("distilbert-base-uncased"),jd=s(` checkpoint
earlier. This is expected since the fine-tuned model has a sequence classification head.`),_l=i(),C(Ze.$$.fragment),vl=i(),C(et.$$.fragment),El=i(),De=a("h2"),tt=a("a"),Qn=a("span"),C(Gt.$$.fragment),Cd=i(),Zn=a("span"),Dd=s("Exporting a model for an unsupported architecture"),$l=i(),C(ot.$$.fragment),wl=i(),yo=a("p"),Ld=s(`If you wish to export a model whose architecture is not natively supported by the
library, there are three main steps to follow:`),xl=i(),$e=a("ol"),ea=a("li"),qd=s("Implement a custom ONNX configuration."),Ad=i(),ta=a("li"),Id=s("Export the model to ONNX."),Pd=i(),oa=a("li"),Xd=s("Validate the outputs of the PyTorch and exported models."),bl=i(),Oo=a("p"),Md=s(`In this section, we\u2019ll look at how DistilBERT was implemented to show what\u2019s involved
with each step.`),kl=i(),Le=a("h3"),st=a("a"),sa=a("span"),C(Yt.$$.fragment),Bd=i(),na=a("span"),Rd=s("Implementing a custom ONNX configuration"),yl=i(),To=a("p"),Fd=s(`Let\u2019s start with the ONNX configuration object. We provide three abstract classes that
you should inherit from, depending on the type of model architecture you wish to export:`),Ol=i(),we=a("ul"),No=a("li"),Sd=s("Encoder-based models inherit from "),jo=a("a"),zd=s("OnnxConfig"),Vd=i(),Co=a("li"),Hd=s("Decoder-based models inherit from "),Do=a("a"),Wd=s("OnnxConfigWithPast"),Gd=i(),Lo=a("li"),Yd=s("Encoder-decoder models inherit from "),qo=a("a"),Ud=s("OnnxSeq2SeqConfigWithPast"),Tl=i(),C(nt.$$.fragment),Nl=i(),at=a("p"),Kd=s(`Since DistilBERT is an encoder-based model, its configuration inherits from
`),aa=a("code"),Jd=s("OnnxConfig"),Qd=s(":"),jl=i(),C(Ut.$$.fragment),Cl=i(),Q=a("p"),Zd=s("Every configuration object must implement the "),la=a("code"),ec=s("inputs"),tc=s(` property and return a mapping,
where each key corresponds to an expected input, and each value indicates the axis of
that input. For DistilBERT, we can see that two inputs are required: `),ra=a("code"),oc=s("input_ids"),sc=s(` and
`),ia=a("code"),nc=s("attention_mask"),ac=s(". These inputs have the same shape of "),pa=a("code"),lc=s("(batch_size, sequence_length)"),rc=s(`
which is why we see the same axes used in the configuration.`),Dl=i(),C(lt.$$.fragment),Ll=i(),Ao=a("p"),ic=s(`Once you have implemented an ONNX configuration, you can instantiate it by providing the
base model\u2019s configuration as follows:`),ql=i(),C(Kt.$$.fragment),Al=i(),Io=a("p"),pc=s(`The resulting object has several useful properties. For example, you can view the ONNX
operator set that will be used during the export:`),Il=i(),C(Jt.$$.fragment),Pl=i(),Po=a("p"),fc=s("You can also view the outputs associated with the model as follows:"),Xl=i(),C(Qt.$$.fragment),Ml=i(),Z=a("p"),dc=s(`Notice that the outputs property follows the same structure as the inputs; it returns an
`),fa=a("code"),cc=s("OrderedDict"),hc=s(` of named outputs and their shapes. The output structure is linked to the
choice of feature that the configuration is initialised with. By default, the ONNX
configuration is initialized with the `),da=a("code"),uc=s("default"),mc=s(` feature that corresponds to exporting a
model loaded with the `),ca=a("code"),gc=s("AutoModel"),_c=s(` class. If you want to export a model for another task,
just provide a different feature to the `),ha=a("code"),vc=s("task"),Ec=s(` argument when you initialize the ONNX
configuration. For example, if we wished to export DistilBERT with a sequence
classification head, we could use:`),Bl=i(),C(Zt.$$.fragment),Rl=i(),C(rt.$$.fragment),Fl=i(),qe=a("h3"),it=a("a"),ua=a("span"),C(eo.$$.fragment),$c=i(),ma=a("span"),wc=s("Exporting the model"),Sl=i(),xe=a("p"),xc=s(`Once you have implemented the ONNX configuration, the next step is to export the model.
Here we can use the `),ga=a("code"),bc=s("export()"),kc=s(" function provided by the "),_a=a("code"),yc=s("transformers.onnx"),Oc=s(` package.
This function expects the ONNX configuration, along with the base model and tokenizer,
and the path to save the exported file:`),zl=i(),C(to.$$.fragment),Vl=i(),Y=a("p"),Tc=s("The "),va=a("code"),Nc=s("onnx_inputs"),jc=s(" and "),Ea=a("code"),Cc=s("onnx_outputs"),Dc=s(" returned by the "),$a=a("code"),Lc=s("export()"),qc=s(` function are lists of
the keys defined in the `),wa=a("code"),Ac=s("inputs"),Ic=s(" and "),xa=a("code"),Pc=s("outputs"),Xc=s(` properties of the configuration. Once the
model is exported, you can test that the model is well formed as follows:`),Hl=i(),C(oo.$$.fragment),Wl=i(),C(pt.$$.fragment),Gl=i(),Ae=a("h3"),ft=a("a"),ba=a("span"),C(so.$$.fragment),Mc=i(),ka=a("span"),Bc=s("Validating the model outputs"),Yl=i(),be=a("p"),Rc=s(`The final step is to validate that the outputs from the base and exported model agree
within some absolute tolerance. Here we can use the `),ya=a("code"),Fc=s("validate_model_outputs()"),Sc=s(` function
provided by the `),Oa=a("code"),zc=s("transformers.onnx"),Vc=s(" package as follows:"),Ul=i(),C(no.$$.fragment),Kl=i(),dt=a("p"),Hc=s("This function uses the "),Xo=a("a"),Wc=s("generate_dummy_inputs()"),Gc=s(` method to
generate inputs for the base and exported model, and the absolute tolerance can be
defined in the configuration. We generally find numerical agreement in the 1e-6 to 1e-4
range, although anything smaller than 1e-3 is likely to be OK.`),Jl=i(),Ie=a("h2"),ct=a("a"),Ta=a("span"),C(ao.$$.fragment),Yc=i(),Na=a("span"),Uc=s("Contributing a new configuration to \u{1F917} Transformers"),Ql=i(),Mo=a("p"),Kc=s(`We are looking to expand the set of ready-made configurations and welcome contributions
from the community! If you would like to contribute your addition to the library, you
will need to:`),Zl=i(),ke=a("ul"),lo=a("li"),Jc=s("Implement the ONNX configuration in the corresponding "),ja=a("code"),Qc=s("configuration_<model_name>.py"),Zc=s(`
file`),eh=i(),Bo=a("li"),th=s(`Include the model architecture and corresponding features in
`),Ca=a("code"),oh=s("~onnx.features.FeatureManager"),sh=i(),Ro=a("li"),nh=s("Add your model architecture to the tests in "),Da=a("code"),ah=s("test_onnx_v2.py"),er=i(),ht=a("p"),lh=s("Check out how the configuration for "),ro=a("a"),rh=s(`IBERT was
contributed`),ih=s(` to get an
idea of what\u2019s involved.`),this.h()},l(t){const f=Mg('[data-svelte="svelte-1phssyn"]',document.head);d=l(f,"META",{name:!0,content:!0}),f.forEach(o),w=p(t),m=l(t,"H1",{class:!0});var io=r(m);_=l(io,"A",{id:!0,class:!0,href:!0});var La=r(_);b=l(La,"SPAN",{});var qa=r(b);D(g.$$.fragment,qa),qa.forEach(o),La.forEach(o),O=p(io),T=l(io,"SPAN",{});var Aa=r(T);x=n(Aa,"Export to ONNX"),Aa.forEach(o),io.forEach(o),$=p(t),y=l(t,"P",{});var po=r(y);k=n(po,`If you need to deploy \u{1F917} Transformers models in production environments, we recommend
exporting them to a serialized format that can be loaded and executed on specialized
runtimes and hardware. In this guide, we\u2019ll show you how to export \u{1F917} Transformers
models to `),N=l(po,"A",{href:!0,rel:!0});var Ia=r(N);E=n(Ia,"ONNX (Open Neural Network eXchange)"),Ia.forEach(o),j=n(po,"."),po.forEach(o),P=p(t),R=l(t,"P",{});var fo=r(R);S=n(fo,`ONNX is an open standard that defines a common set of operators and a common file format
to represent deep learning models in a wide variety of frameworks, including PyTorch and
TensorFlow. When a model is exported to the ONNX format, these operators are used to
construct a computational graph (often called an `),U=l(fo,"EM",{});var Pa=r(U);de=n(Pa,"intermediate representation"),Pa.forEach(o),te=n(fo,`) which
represents the flow of data through the neural network.`),fo.forEach(o),ne=p(t),H=l(t,"P",{});var Xa=r(H);oe=n(Xa,`By exposing a graph with standardized operators and data types, ONNX makes it easy to
switch between frameworks. For example, a model trained in PyTorch can be exported to
ONNX format and then imported in TensorFlow (and vice versa).`),Xa.forEach(o),M=p(t),K=l(t,"P",{});var co=r(K);W=n(co,"\u{1F917} Transformers provides a "),se=l(co,"A",{href:!0});var Ma=r(se);G=l(Ma,"CODE",{});var uh=r(G);he=n(uh,"transformers.onnx"),uh.forEach(o),Ma.forEach(o),ue=n(co,` package that enables
you to convert model checkpoints to an ONNX graph by leveraging configuration objects.
These configuration objects come ready made for a number of model architectures, and are
designed to be easily extendable to other architectures.`),co.forEach(o),J=p(t),D(ae.$$.fragment,t),Pe=p(t),ce=l(t,"P",{});var mh=r(ce);le=n(mh,"Ready-made configurations include the following architectures:"),mh.forEach(o),Xe=p(t),h=l(t,"UL",{});var u=r(h);Ne=l(u,"LI",{});var gh=r(Ne);_t=n(gh,"ALBERT"),gh.forEach(o),B=p(u),z=l(u,"LI",{});var _h=r(z);vt=n(_h,"BART"),_h.forEach(o),ho=p(u),Me=l(u,"LI",{});var vh=r(Me);me=n(vh,"BEiT"),vh.forEach(o),uo=p(u),re=l(u,"LI",{});var Eh=r(re);Et=n(Eh,"BERT"),Eh.forEach(o),mo=p(u),Be=l(u,"LI",{});var $h=r(Be);ge=n($h,"BigBird"),$h.forEach(o),go=p(u),Re=l(u,"LI",{});var wh=r(Re);Fe=n(wh,"BigBird-Pegasus"),wh.forEach(o),_o=p(u),Uo=l(u,"LI",{});var xh=r(Uo);Dr=n(xh,"Blenderbot"),xh.forEach(o),Lr=p(u),Ko=l(u,"LI",{});var bh=r(Ko);qr=n(bh,"BlenderbotSmall"),bh.forEach(o),Ar=p(u),Jo=l(u,"LI",{});var kh=r(Jo);Ir=n(kh,"BLOOM"),kh.forEach(o),Pr=p(u),Qo=l(u,"LI",{});var yh=r(Qo);Xr=n(yh,"CamemBERT"),yh.forEach(o),Mr=p(u),Zo=l(u,"LI",{});var Oh=r(Zo);Br=n(Oh,"Chinese-CLIP"),Oh.forEach(o),Rr=p(u),es=l(u,"LI",{});var Th=r(es);Fr=n(Th,"CLIP"),Th.forEach(o),Sr=p(u),ts=l(u,"LI",{});var Nh=r(ts);zr=n(Nh,"CodeGen"),Nh.forEach(o),Vr=p(u),os=l(u,"LI",{});var jh=r(os);Hr=n(jh,"Conditional DETR"),jh.forEach(o),Wr=p(u),ss=l(u,"LI",{});var Ch=r(ss);Gr=n(Ch,"ConvBERT"),Ch.forEach(o),Yr=p(u),ns=l(u,"LI",{});var Dh=r(ns);Ur=n(Dh,"ConvNeXT"),Dh.forEach(o),Kr=p(u),as=l(u,"LI",{});var Lh=r(as);Jr=n(Lh,"Data2VecText"),Lh.forEach(o),Qr=p(u),ls=l(u,"LI",{});var qh=r(ls);Zr=n(qh,"Data2VecVision"),qh.forEach(o),ei=p(u),rs=l(u,"LI",{});var Ah=r(rs);ti=n(Ah,"DeBERTa"),Ah.forEach(o),oi=p(u),is=l(u,"LI",{});var Ih=r(is);si=n(Ih,"DeBERTa-v2"),Ih.forEach(o),ni=p(u),ps=l(u,"LI",{});var Ph=r(ps);ai=n(Ph,"DeiT"),Ph.forEach(o),li=p(u),fs=l(u,"LI",{});var Xh=r(fs);ri=n(Xh,"DETR"),Xh.forEach(o),ii=p(u),ds=l(u,"LI",{});var Mh=r(ds);pi=n(Mh,"DistilBERT"),Mh.forEach(o),fi=p(u),cs=l(u,"LI",{});var Bh=r(cs);di=n(Bh,"ELECTRA"),Bh.forEach(o),ci=p(u),hs=l(u,"LI",{});var Rh=r(hs);hi=n(Rh,"ERNIE"),Rh.forEach(o),ui=p(u),us=l(u,"LI",{});var Fh=r(us);mi=n(Fh,"FlauBERT"),Fh.forEach(o),gi=p(u),ms=l(u,"LI",{});var Sh=r(ms);_i=n(Sh,"GPT Neo"),Sh.forEach(o),vi=p(u),gs=l(u,"LI",{});var zh=r(gs);Ei=n(zh,"GPT-J"),zh.forEach(o),$i=p(u),_s=l(u,"LI",{});var Vh=r(_s);wi=n(Vh,"GPT-Sw3"),Vh.forEach(o),xi=p(u),vs=l(u,"LI",{});var Hh=r(vs);bi=n(Hh,"GroupViT"),Hh.forEach(o),ki=p(u),Es=l(u,"LI",{});var Wh=r(Es);yi=n(Wh,"I-BERT"),Wh.forEach(o),Oi=p(u),$s=l(u,"LI",{});var Gh=r($s);Ti=n(Gh,"ImageGPT"),Gh.forEach(o),Ni=p(u),ws=l(u,"LI",{});var Yh=r(ws);ji=n(Yh,"LayoutLM"),Yh.forEach(o),Ci=p(u),xs=l(u,"LI",{});var Uh=r(xs);Di=n(Uh,"LayoutLMv3"),Uh.forEach(o),Li=p(u),bs=l(u,"LI",{});var Kh=r(bs);qi=n(Kh,"LeViT"),Kh.forEach(o),Ai=p(u),ks=l(u,"LI",{});var Jh=r(ks);Ii=n(Jh,"Longformer"),Jh.forEach(o),Pi=p(u),ys=l(u,"LI",{});var Qh=r(ys);Xi=n(Qh,"LongT5"),Qh.forEach(o),Mi=p(u),Os=l(u,"LI",{});var Zh=r(Os);Bi=n(Zh,"M2M100"),Zh.forEach(o),Ri=p(u),Ts=l(u,"LI",{});var eu=r(Ts);Fi=n(eu,"Marian"),eu.forEach(o),Si=p(u),Ns=l(u,"LI",{});var tu=r(Ns);zi=n(tu,"mBART"),tu.forEach(o),Vi=p(u),js=l(u,"LI",{});var ou=r(js);Hi=n(ou,"MobileBERT"),ou.forEach(o),Wi=p(u),Cs=l(u,"LI",{});var su=r(Cs);Gi=n(su,"MobileNetV1"),su.forEach(o),Yi=p(u),Ds=l(u,"LI",{});var nu=r(Ds);Ui=n(nu,"MobileNetV2"),nu.forEach(o),Ki=p(u),Ls=l(u,"LI",{});var au=r(Ls);Ji=n(au,"MobileViT"),au.forEach(o),Qi=p(u),qs=l(u,"LI",{});var lu=r(qs);Zi=n(lu,"MT5"),lu.forEach(o),ep=p(u),As=l(u,"LI",{});var ru=r(As);tp=n(ru,"OpenAI GPT-2"),ru.forEach(o),op=p(u),Is=l(u,"LI",{});var iu=r(Is);sp=n(iu,"OWL-ViT"),iu.forEach(o),np=p(u),Ps=l(u,"LI",{});var pu=r(Ps);ap=n(pu,"Perceiver"),pu.forEach(o),lp=p(u),Xs=l(u,"LI",{});var fu=r(Xs);rp=n(fu,"PLBart"),fu.forEach(o),ip=p(u),Ms=l(u,"LI",{});var du=r(Ms);pp=n(du,"PoolFormer"),du.forEach(o),fp=p(u),Bs=l(u,"LI",{});var cu=r(Bs);dp=n(cu,"RemBERT"),cu.forEach(o),cp=p(u),Rs=l(u,"LI",{});var hu=r(Rs);hp=n(hu,"ResNet"),hu.forEach(o),up=p(u),Fs=l(u,"LI",{});var uu=r(Fs);mp=n(uu,"RoBERTa"),uu.forEach(o),gp=p(u),Ss=l(u,"LI",{});var mu=r(Ss);_p=n(mu,"RoBERTa-PreLayerNorm"),mu.forEach(o),vp=p(u),zs=l(u,"LI",{});var gu=r(zs);Ep=n(gu,"RoFormer"),gu.forEach(o),$p=p(u),Vs=l(u,"LI",{});var _u=r(Vs);wp=n(_u,"SegFormer"),_u.forEach(o),xp=p(u),Hs=l(u,"LI",{});var vu=r(Hs);bp=n(vu,"SqueezeBERT"),vu.forEach(o),kp=p(u),Ws=l(u,"LI",{});var Eu=r(Ws);yp=n(Eu,"Swin Transformer"),Eu.forEach(o),Op=p(u),Gs=l(u,"LI",{});var $u=r(Gs);Tp=n($u,"T5"),$u.forEach(o),Np=p(u),Ys=l(u,"LI",{});var wu=r(Ys);jp=n(wu,"Table Transformer"),wu.forEach(o),Cp=p(u),Us=l(u,"LI",{});var xu=r(Us);Dp=n(xu,"Vision Encoder decoder"),xu.forEach(o),Lp=p(u),Ks=l(u,"LI",{});var bu=r(Ks);qp=n(bu,"ViT"),bu.forEach(o),Ap=p(u),Js=l(u,"LI",{});var ku=r(Js);Ip=n(ku,"Whisper"),ku.forEach(o),Pp=p(u),Qs=l(u,"LI",{});var yu=r(Qs);Xp=n(yu,"XLM"),yu.forEach(o),Mp=p(u),Zs=l(u,"LI",{});var Ou=r(Zs);Bp=n(Ou,"XLM-RoBERTa"),Ou.forEach(o),Rp=p(u),en=l(u,"LI",{});var Tu=r(en);Fp=n(Tu,"XLM-RoBERTa-XL"),Tu.forEach(o),Sp=p(u),tn=l(u,"LI",{});var Nu=r(tn);zp=n(Nu,"YOLOS"),Nu.forEach(o),u.forEach(o),Ba=p(t),vo=l(t,"P",{});var ju=r(vo);Vp=n(ju,"In the next two sections, we\u2019ll show you how to:"),ju.forEach(o),Ra=p(t),Se=l(t,"UL",{});var or=r(Se);$t=l(or,"LI",{});var sr=r($t);Hp=n(sr,"Export a supported model using the "),on=l(sr,"CODE",{});var Cu=r(on);Wp=n(Cu,"transformers.onnx"),Cu.forEach(o),Gp=n(sr," package."),sr.forEach(o),Yp=p(or),sn=l(or,"LI",{});var Du=r(sn);Up=n(Du,"Export a custom model for an unsupported architecture."),Du.forEach(o),or.forEach(o),Fa=p(t),je=l(t,"H2",{class:!0});var nr=r(je);ze=l(nr,"A",{id:!0,class:!0,href:!0});var Lu=r(ze);nn=l(Lu,"SPAN",{});var qu=r(nn);D(wt.$$.fragment,qu),qu.forEach(o),Lu.forEach(o),Kp=p(nr),an=l(nr,"SPAN",{});var Au=r(an);Jp=n(Au,"Exporting a model to ONNX"),Au.forEach(o),nr.forEach(o),Sa=p(t),D(Ve.$$.fragment,t),za=p(t),Eo=l(t,"P",{});var Iu=r(Eo);Qp=n(Iu,`To export a \u{1F917} Transformers model to ONNX, you\u2019ll first need to install some extra
dependencies:`),Iu.forEach(o),Va=p(t),D(xt.$$.fragment,t),Ha=p(t),He=l(t,"P",{});var ar=r(He);Zp=n(ar,"The "),ln=l(ar,"CODE",{});var Pu=r(ln);ef=n(Pu,"transformers.onnx"),Pu.forEach(o),tf=n(ar," package can then be used as a Python module:"),ar.forEach(o),Wa=p(t),D(bt.$$.fragment,t),Ga=p(t),$o=l(t,"P",{});var Xu=r($o);of=n(Xu,"Exporting a checkpoint using a ready-made configuration can be done as follows:"),Xu.forEach(o),Ya=p(t),D(kt.$$.fragment,t),Ua=p(t),wo=l(t,"P",{});var Mu=r(wo);sf=n(Mu,"You should see the following logs:"),Mu.forEach(o),Ka=p(t),D(yt.$$.fragment,t),Ja=p(t),_e=l(t,"P",{});var Fo=r(_e);nf=n(Fo,"This exports an ONNX graph of the checkpoint defined by the "),rn=l(Fo,"CODE",{});var Bu=r(rn);af=n(Bu,"--model"),Bu.forEach(o),lf=n(Fo,` argument. In this
example, it is `),pn=l(Fo,"CODE",{});var Ru=r(pn);rf=n(Ru,"distilbert-base-uncased"),Ru.forEach(o),pf=n(Fo,`, but it can be any checkpoint on the Hugging
Face Hub or one that\u2019s stored locally.`),Fo.forEach(o),Qa=p(t),ie=l(t,"P",{});var ut=r(ie);ff=n(ut,"The resulting "),fn=l(ut,"CODE",{});var Fu=r(fn);df=n(Fu,"model.onnx"),Fu.forEach(o),cf=n(ut," file can then be run on one of the "),Ot=l(ut,"A",{href:!0,rel:!0});var Su=r(Ot);hf=n(Su,`many
accelerators`),Su.forEach(o),uf=n(ut,` that support the ONNX
standard. For example, we can load and run the model with `),Tt=l(ut,"A",{href:!0,rel:!0});var zu=r(Tt);mf=n(zu,`ONNX
Runtime`),zu.forEach(o),gf=n(ut," as follows:"),ut.forEach(o),Za=p(t),D(Nt.$$.fragment,t),el=p(t),We=l(t,"P",{});var lr=r(We);_f=n(lr,"The required output names (like "),dn=l(lr,"CODE",{});var Vu=r(dn);vf=n(Vu,'["last_hidden_state"]'),Vu.forEach(o),Ef=n(lr,`) can be obtained by taking a
look at the ONNX configuration of each model. For example, for DistilBERT we have:`),lr.forEach(o),tl=p(t),D(jt.$$.fragment,t),ol=p(t),Ge=l(t,"P",{});var rr=r(Ge);$f=n(rr,`The process is identical for TensorFlow checkpoints on the Hub. For example, we can
export a pure TensorFlow checkpoint from the `),Ct=l(rr,"A",{href:!0,rel:!0});var Hu=r(Ct);wf=n(Hu,`Keras
organization`),Hu.forEach(o),xf=n(rr," as follows:"),rr.forEach(o),sl=p(t),D(Dt.$$.fragment,t),nl=p(t),xo=l(t,"P",{});var Wu=r(xo);bf=n(Wu,`To export a model that\u2019s stored locally, you\u2019ll need to have the model\u2019s weights and
tokenizer files stored in a directory. For example, we can load and save a checkpoint as
follows:`),Wu.forEach(o),al=p(t),D(Ye.$$.fragment,t),ll=p(t),Ce=l(t,"H2",{class:!0});var ir=r(Ce);Ue=l(ir,"A",{id:!0,class:!0,href:!0});var Gu=r(Ue);cn=l(Gu,"SPAN",{});var Yu=r(cn);D(Lt.$$.fragment,Yu),Yu.forEach(o),Gu.forEach(o),kf=p(ir),hn=l(ir,"SPAN",{});var Uu=r(hn);yf=n(Uu,"Selecting features for different model tasks"),Uu.forEach(o),ir.forEach(o),rl=p(t),D(Ke.$$.fragment,t),il=p(t),ve=l(t,"P",{});var So=r(ve);Of=n(So,"Each ready-made configuration comes with a set of "),un=l(So,"EM",{});var Ku=r(un);Tf=n(Ku,"features"),Ku.forEach(o),Nf=n(So,` that enable you to export
models for different types of tasks. As shown in the table below, each feature is
associated with a different `),mn=l(So,"CODE",{});var Ju=r(mn);jf=n(Ju,"AutoClass"),Ju.forEach(o),Cf=n(So,":"),So.forEach(o),pl=p(t),Je=l(t,"TABLE",{});var pr=r(Je);gn=l(pr,"THEAD",{});var Qu=r(gn);qt=l(Qu,"TR",{});var fr=r(qt);_n=l(fr,"TH",{});var Zu=r(_n);Df=n(Zu,"Feature"),Zu.forEach(o),Lf=p(fr),vn=l(fr,"TH",{});var em=r(vn);qf=n(em,"Auto Class"),em.forEach(o),fr.forEach(o),Qu.forEach(o),Af=p(pr),V=l(pr,"TBODY",{});var ee=r(V);At=l(ee,"TR",{});var dr=r(At);It=l(dr,"TD",{});var cr=r(It);En=l(cr,"CODE",{});var tm=r(En);If=n(tm,"causal-lm"),tm.forEach(o),Pf=n(cr,", "),$n=l(cr,"CODE",{});var om=r($n);Xf=n(om,"causal-lm-with-past"),om.forEach(o),cr.forEach(o),Mf=p(dr),wn=l(dr,"TD",{});var sm=r(wn);xn=l(sm,"CODE",{});var nm=r(xn);Bf=n(nm,"AutoModelForCausalLM"),nm.forEach(o),sm.forEach(o),dr.forEach(o),Rf=p(ee),Pt=l(ee,"TR",{});var hr=r(Pt);Xt=l(hr,"TD",{});var ur=r(Xt);bn=l(ur,"CODE",{});var am=r(bn);Ff=n(am,"default"),am.forEach(o),Sf=n(ur,", "),kn=l(ur,"CODE",{});var lm=r(kn);zf=n(lm,"default-with-past"),lm.forEach(o),ur.forEach(o),Vf=p(hr),yn=l(hr,"TD",{});var rm=r(yn);On=l(rm,"CODE",{});var im=r(On);Hf=n(im,"AutoModel"),im.forEach(o),rm.forEach(o),hr.forEach(o),Wf=p(ee),Mt=l(ee,"TR",{});var mr=r(Mt);Tn=l(mr,"TD",{});var pm=r(Tn);Nn=l(pm,"CODE",{});var fm=r(Nn);Gf=n(fm,"masked-lm"),fm.forEach(o),pm.forEach(o),Yf=p(mr),jn=l(mr,"TD",{});var dm=r(jn);Cn=l(dm,"CODE",{});var cm=r(Cn);Uf=n(cm,"AutoModelForMaskedLM"),cm.forEach(o),dm.forEach(o),mr.forEach(o),Kf=p(ee),Bt=l(ee,"TR",{});var gr=r(Bt);Dn=l(gr,"TD",{});var hm=r(Dn);Ln=l(hm,"CODE",{});var um=r(Ln);Jf=n(um,"question-answering"),um.forEach(o),hm.forEach(o),Qf=p(gr),qn=l(gr,"TD",{});var mm=r(qn);An=l(mm,"CODE",{});var gm=r(An);Zf=n(gm,"AutoModelForQuestionAnswering"),gm.forEach(o),mm.forEach(o),gr.forEach(o),ed=p(ee),Rt=l(ee,"TR",{});var _r=r(Rt);Ft=l(_r,"TD",{});var vr=r(Ft);In=l(vr,"CODE",{});var _m=r(In);td=n(_m,"seq2seq-lm"),_m.forEach(o),od=n(vr,", "),Pn=l(vr,"CODE",{});var vm=r(Pn);sd=n(vm,"seq2seq-lm-with-past"),vm.forEach(o),vr.forEach(o),nd=p(_r),Xn=l(_r,"TD",{});var Em=r(Xn);Mn=l(Em,"CODE",{});var $m=r(Mn);ad=n($m,"AutoModelForSeq2SeqLM"),$m.forEach(o),Em.forEach(o),_r.forEach(o),ld=p(ee),St=l(ee,"TR",{});var Er=r(St);Bn=l(Er,"TD",{});var wm=r(Bn);Rn=l(wm,"CODE",{});var xm=r(Rn);rd=n(xm,"sequence-classification"),xm.forEach(o),wm.forEach(o),id=p(Er),Fn=l(Er,"TD",{});var bm=r(Fn);Sn=l(bm,"CODE",{});var km=r(Sn);pd=n(km,"AutoModelForSequenceClassification"),km.forEach(o),bm.forEach(o),Er.forEach(o),fd=p(ee),zt=l(ee,"TR",{});var $r=r(zt);zn=l($r,"TD",{});var ym=r(zn);Vn=l(ym,"CODE",{});var Om=r(Vn);dd=n(Om,"token-classification"),Om.forEach(o),ym.forEach(o),cd=p($r),Hn=l($r,"TD",{});var Tm=r(Hn);Wn=l(Tm,"CODE",{});var Nm=r(Wn);hd=n(Nm,"AutoModelForTokenClassification"),Nm.forEach(o),Tm.forEach(o),$r.forEach(o),ee.forEach(o),pr.forEach(o),fl=p(t),Qe=l(t,"P",{});var wr=r(Qe);ud=n(wr,`For each configuration, you can find the list of supported features via the
`),bo=l(wr,"A",{href:!0});var jm=r(bo);md=n(jm,"FeaturesManager"),jm.forEach(o),gd=n(wr,". For example, for DistilBERT we have:"),wr.forEach(o),dl=p(t),D(Vt.$$.fragment,t),cl=p(t),Ee=l(t,"P",{});var zo=r(Ee);_d=n(zo,"You can then pass one of these features to the "),Gn=l(zo,"CODE",{});var Cm=r(Gn);vd=n(Cm,"--feature"),Cm.forEach(o),Ed=n(zo,` argument in the
`),Yn=l(zo,"CODE",{});var Dm=r(Yn);$d=n(Dm,"transformers.onnx"),Dm.forEach(o),wd=n(zo,` package. For example, to export a text-classification model we can
pick a fine-tuned model from the Hub and run:`),zo.forEach(o),hl=p(t),D(Ht.$$.fragment,t),ul=p(t),ko=l(t,"P",{});var Lm=r(ko);xd=n(Lm,"This displays the following logs:"),Lm.forEach(o),ml=p(t),D(Wt.$$.fragment,t),gl=p(t),pe=l(t,"P",{});var mt=r(pe);bd=n(mt,"Notice that in this case, the output names from the fine-tuned model are "),Un=l(mt,"CODE",{});var qm=r(Un);kd=n(qm,"logits"),qm.forEach(o),yd=n(mt,`
instead of the `),Kn=l(mt,"CODE",{});var Am=r(Kn);Od=n(Am,"last_hidden_state"),Am.forEach(o),Td=n(mt," we saw with the "),Jn=l(mt,"CODE",{});var Im=r(Jn);Nd=n(Im,"distilbert-base-uncased"),Im.forEach(o),jd=n(mt,` checkpoint
earlier. This is expected since the fine-tuned model has a sequence classification head.`),mt.forEach(o),_l=p(t),D(Ze.$$.fragment,t),vl=p(t),D(et.$$.fragment,t),El=p(t),De=l(t,"H2",{class:!0});var xr=r(De);tt=l(xr,"A",{id:!0,class:!0,href:!0});var Pm=r(tt);Qn=l(Pm,"SPAN",{});var Xm=r(Qn);D(Gt.$$.fragment,Xm),Xm.forEach(o),Pm.forEach(o),Cd=p(xr),Zn=l(xr,"SPAN",{});var Mm=r(Zn);Dd=n(Mm,"Exporting a model for an unsupported architecture"),Mm.forEach(o),xr.forEach(o),$l=p(t),D(ot.$$.fragment,t),wl=p(t),yo=l(t,"P",{});var Bm=r(yo);Ld=n(Bm,`If you wish to export a model whose architecture is not natively supported by the
library, there are three main steps to follow:`),Bm.forEach(o),xl=p(t),$e=l(t,"OL",{});var Vo=r($e);ea=l(Vo,"LI",{});var Rm=r(ea);qd=n(Rm,"Implement a custom ONNX configuration."),Rm.forEach(o),Ad=p(Vo),ta=l(Vo,"LI",{});var Fm=r(ta);Id=n(Fm,"Export the model to ONNX."),Fm.forEach(o),Pd=p(Vo),oa=l(Vo,"LI",{});var Sm=r(oa);Xd=n(Sm,"Validate the outputs of the PyTorch and exported models."),Sm.forEach(o),Vo.forEach(o),bl=p(t),Oo=l(t,"P",{});var zm=r(Oo);Md=n(zm,`In this section, we\u2019ll look at how DistilBERT was implemented to show what\u2019s involved
with each step.`),zm.forEach(o),kl=p(t),Le=l(t,"H3",{class:!0});var br=r(Le);st=l(br,"A",{id:!0,class:!0,href:!0});var Vm=r(st);sa=l(Vm,"SPAN",{});var Hm=r(sa);D(Yt.$$.fragment,Hm),Hm.forEach(o),Vm.forEach(o),Bd=p(br),na=l(br,"SPAN",{});var Wm=r(na);Rd=n(Wm,"Implementing a custom ONNX configuration"),Wm.forEach(o),br.forEach(o),yl=p(t),To=l(t,"P",{});var Gm=r(To);Fd=n(Gm,`Let\u2019s start with the ONNX configuration object. We provide three abstract classes that
you should inherit from, depending on the type of model architecture you wish to export:`),Gm.forEach(o),Ol=p(t),we=l(t,"UL",{});var Ho=r(we);No=l(Ho,"LI",{});var ph=r(No);Sd=n(ph,"Encoder-based models inherit from "),jo=l(ph,"A",{href:!0});var Ym=r(jo);zd=n(Ym,"OnnxConfig"),Ym.forEach(o),ph.forEach(o),Vd=p(Ho),Co=l(Ho,"LI",{});var fh=r(Co);Hd=n(fh,"Decoder-based models inherit from "),Do=l(fh,"A",{href:!0});var Um=r(Do);Wd=n(Um,"OnnxConfigWithPast"),Um.forEach(o),fh.forEach(o),Gd=p(Ho),Lo=l(Ho,"LI",{});var dh=r(Lo);Yd=n(dh,"Encoder-decoder models inherit from "),qo=l(dh,"A",{href:!0});var Km=r(qo);Ud=n(Km,"OnnxSeq2SeqConfigWithPast"),Km.forEach(o),dh.forEach(o),Ho.forEach(o),Tl=p(t),D(nt.$$.fragment,t),Nl=p(t),at=l(t,"P",{});var kr=r(at);Kd=n(kr,`Since DistilBERT is an encoder-based model, its configuration inherits from
`),aa=l(kr,"CODE",{});var Jm=r(aa);Jd=n(Jm,"OnnxConfig"),Jm.forEach(o),Qd=n(kr,":"),kr.forEach(o),jl=p(t),D(Ut.$$.fragment,t),Cl=p(t),Q=l(t,"P",{});var ye=r(Q);Zd=n(ye,"Every configuration object must implement the "),la=l(ye,"CODE",{});var Qm=r(la);ec=n(Qm,"inputs"),Qm.forEach(o),tc=n(ye,` property and return a mapping,
where each key corresponds to an expected input, and each value indicates the axis of
that input. For DistilBERT, we can see that two inputs are required: `),ra=l(ye,"CODE",{});var Zm=r(ra);oc=n(Zm,"input_ids"),Zm.forEach(o),sc=n(ye,` and
`),ia=l(ye,"CODE",{});var eg=r(ia);nc=n(eg,"attention_mask"),eg.forEach(o),ac=n(ye,". These inputs have the same shape of "),pa=l(ye,"CODE",{});var tg=r(pa);lc=n(tg,"(batch_size, sequence_length)"),tg.forEach(o),rc=n(ye,`
which is why we see the same axes used in the configuration.`),ye.forEach(o),Dl=p(t),D(lt.$$.fragment,t),Ll=p(t),Ao=l(t,"P",{});var og=r(Ao);ic=n(og,`Once you have implemented an ONNX configuration, you can instantiate it by providing the
base model\u2019s configuration as follows:`),og.forEach(o),ql=p(t),D(Kt.$$.fragment,t),Al=p(t),Io=l(t,"P",{});var sg=r(Io);pc=n(sg,`The resulting object has several useful properties. For example, you can view the ONNX
operator set that will be used during the export:`),sg.forEach(o),Il=p(t),D(Jt.$$.fragment,t),Pl=p(t),Po=l(t,"P",{});var ng=r(Po);fc=n(ng,"You can also view the outputs associated with the model as follows:"),ng.forEach(o),Xl=p(t),D(Qt.$$.fragment,t),Ml=p(t),Z=l(t,"P",{});var Oe=r(Z);dc=n(Oe,`Notice that the outputs property follows the same structure as the inputs; it returns an
`),fa=l(Oe,"CODE",{});var ag=r(fa);cc=n(ag,"OrderedDict"),ag.forEach(o),hc=n(Oe,` of named outputs and their shapes. The output structure is linked to the
choice of feature that the configuration is initialised with. By default, the ONNX
configuration is initialized with the `),da=l(Oe,"CODE",{});var lg=r(da);uc=n(lg,"default"),lg.forEach(o),mc=n(Oe,` feature that corresponds to exporting a
model loaded with the `),ca=l(Oe,"CODE",{});var rg=r(ca);gc=n(rg,"AutoModel"),rg.forEach(o),_c=n(Oe,` class. If you want to export a model for another task,
just provide a different feature to the `),ha=l(Oe,"CODE",{});var ig=r(ha);vc=n(ig,"task"),ig.forEach(o),Ec=n(Oe,` argument when you initialize the ONNX
configuration. For example, if we wished to export DistilBERT with a sequence
classification head, we could use:`),Oe.forEach(o),Bl=p(t),D(Zt.$$.fragment,t),Rl=p(t),D(rt.$$.fragment,t),Fl=p(t),qe=l(t,"H3",{class:!0});var yr=r(qe);it=l(yr,"A",{id:!0,class:!0,href:!0});var pg=r(it);ua=l(pg,"SPAN",{});var fg=r(ua);D(eo.$$.fragment,fg),fg.forEach(o),pg.forEach(o),$c=p(yr),ma=l(yr,"SPAN",{});var dg=r(ma);wc=n(dg,"Exporting the model"),dg.forEach(o),yr.forEach(o),Sl=p(t),xe=l(t,"P",{});var Wo=r(xe);xc=n(Wo,`Once you have implemented the ONNX configuration, the next step is to export the model.
Here we can use the `),ga=l(Wo,"CODE",{});var cg=r(ga);bc=n(cg,"export()"),cg.forEach(o),kc=n(Wo," function provided by the "),_a=l(Wo,"CODE",{});var hg=r(_a);yc=n(hg,"transformers.onnx"),hg.forEach(o),Oc=n(Wo,` package.
This function expects the ONNX configuration, along with the base model and tokenizer,
and the path to save the exported file:`),Wo.forEach(o),zl=p(t),D(to.$$.fragment,t),Vl=p(t),Y=l(t,"P",{});var fe=r(Y);Tc=n(fe,"The "),va=l(fe,"CODE",{});var ug=r(va);Nc=n(ug,"onnx_inputs"),ug.forEach(o),jc=n(fe," and "),Ea=l(fe,"CODE",{});var mg=r(Ea);Cc=n(mg,"onnx_outputs"),mg.forEach(o),Dc=n(fe," returned by the "),$a=l(fe,"CODE",{});var gg=r($a);Lc=n(gg,"export()"),gg.forEach(o),qc=n(fe,` function are lists of
the keys defined in the `),wa=l(fe,"CODE",{});var _g=r(wa);Ac=n(_g,"inputs"),_g.forEach(o),Ic=n(fe," and "),xa=l(fe,"CODE",{});var vg=r(xa);Pc=n(vg,"outputs"),vg.forEach(o),Xc=n(fe,` properties of the configuration. Once the
model is exported, you can test that the model is well formed as follows:`),fe.forEach(o),Hl=p(t),D(oo.$$.fragment,t),Wl=p(t),D(pt.$$.fragment,t),Gl=p(t),Ae=l(t,"H3",{class:!0});var Or=r(Ae);ft=l(Or,"A",{id:!0,class:!0,href:!0});var Eg=r(ft);ba=l(Eg,"SPAN",{});var $g=r(ba);D(so.$$.fragment,$g),$g.forEach(o),Eg.forEach(o),Mc=p(Or),ka=l(Or,"SPAN",{});var wg=r(ka);Bc=n(wg,"Validating the model outputs"),wg.forEach(o),Or.forEach(o),Yl=p(t),be=l(t,"P",{});var Go=r(be);Rc=n(Go,`The final step is to validate that the outputs from the base and exported model agree
within some absolute tolerance. Here we can use the `),ya=l(Go,"CODE",{});var xg=r(ya);Fc=n(xg,"validate_model_outputs()"),xg.forEach(o),Sc=n(Go,` function
provided by the `),Oa=l(Go,"CODE",{});var bg=r(Oa);zc=n(bg,"transformers.onnx"),bg.forEach(o),Vc=n(Go," package as follows:"),Go.forEach(o),Ul=p(t),D(no.$$.fragment,t),Kl=p(t),dt=l(t,"P",{});var Tr=r(dt);Hc=n(Tr,"This function uses the "),Xo=l(Tr,"A",{href:!0});var kg=r(Xo);Wc=n(kg,"generate_dummy_inputs()"),kg.forEach(o),Gc=n(Tr,` method to
generate inputs for the base and exported model, and the absolute tolerance can be
defined in the configuration. We generally find numerical agreement in the 1e-6 to 1e-4
range, although anything smaller than 1e-3 is likely to be OK.`),Tr.forEach(o),Jl=p(t),Ie=l(t,"H2",{class:!0});var Nr=r(Ie);ct=l(Nr,"A",{id:!0,class:!0,href:!0});var yg=r(ct);Ta=l(yg,"SPAN",{});var Og=r(Ta);D(ao.$$.fragment,Og),Og.forEach(o),yg.forEach(o),Yc=p(Nr),Na=l(Nr,"SPAN",{});var Tg=r(Na);Uc=n(Tg,"Contributing a new configuration to \u{1F917} Transformers"),Tg.forEach(o),Nr.forEach(o),Ql=p(t),Mo=l(t,"P",{});var Ng=r(Mo);Kc=n(Ng,`We are looking to expand the set of ready-made configurations and welcome contributions
from the community! If you would like to contribute your addition to the library, you
will need to:`),Ng.forEach(o),Zl=p(t),ke=l(t,"UL",{});var Yo=r(ke);lo=l(Yo,"LI",{});var jr=r(lo);Jc=n(jr,"Implement the ONNX configuration in the corresponding "),ja=l(jr,"CODE",{});var jg=r(ja);Qc=n(jg,"configuration_<model_name>.py"),jg.forEach(o),Zc=n(jr,`
file`),jr.forEach(o),eh=p(Yo),Bo=l(Yo,"LI",{});var ch=r(Bo);th=n(ch,`Include the model architecture and corresponding features in
`),Ca=l(ch,"CODE",{});var Cg=r(Ca);oh=n(Cg,"~onnx.features.FeatureManager"),Cg.forEach(o),ch.forEach(o),sh=p(Yo),Ro=l(Yo,"LI",{});var hh=r(Ro);nh=n(hh,"Add your model architecture to the tests in "),Da=l(hh,"CODE",{});var Dg=r(Da);ah=n(Dg,"test_onnx_v2.py"),Dg.forEach(o),hh.forEach(o),Yo.forEach(o),er=p(t),ht=l(t,"P",{});var Cr=r(ht);lh=n(Cr,"Check out how the configuration for "),ro=l(Cr,"A",{href:!0,rel:!0});var Lg=r(ro);rh=n(Lg,`IBERT was
contributed`),Lg.forEach(o),ih=n(Cr,` to get an
idea of what\u2019s involved.`),Cr.forEach(o),this.h()},h(){v(d,"name","hf:doc:metadata"),v(d,"content",JSON.stringify(o_)),v(_,"id","export-to-onnx"),v(_,"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"),v(_,"href","#export-to-onnx"),v(m,"class","relative group"),v(N,"href","http://onnx.ai"),v(N,"rel","nofollow"),v(se,"href","main_classes/onnx"),v(ze,"id","exporting-a-model-to-onnx"),v(ze,"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"),v(ze,"href","#exporting-a-model-to-onnx"),v(je,"class","relative group"),v(Ot,"href","https://onnx.ai/supported-tools.html#deployModel"),v(Ot,"rel","nofollow"),v(Tt,"href","https://onnxruntime.ai/"),v(Tt,"rel","nofollow"),v(Ct,"href","https://huggingface.co/keras-io"),v(Ct,"rel","nofollow"),v(Ue,"id","selecting-features-for-different-model-tasks"),v(Ue,"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"),v(Ue,"href","#selecting-features-for-different-model-tasks"),v(Ce,"class","relative group"),v(bo,"href","/docs/transformers/main/en/main_classes/onnx#transformers.onnx.FeaturesManager"),v(tt,"id","exporting-a-model-for-an-unsupported-architecture"),v(tt,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),v(tt,"href","#exporting-a-model-for-an-unsupported-architecture"),v(De,"class","relative group"),v(st,"id","implementing-a-custom-onnx-configuration"),v(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"),v(st,"href","#implementing-a-custom-onnx-configuration"),v(Le,"class","relative group"),v(jo,"href","/docs/transformers/main/en/main_classes/onnx#transformers.onnx.OnnxConfig"),v(Do,"href","/docs/transformers/main/en/main_classes/onnx#transformers.onnx.OnnxConfigWithPast"),v(qo,"href","/docs/transformers/main/en/main_classes/onnx#transformers.onnx.OnnxSeq2SeqConfigWithPast"),v(it,"id","exporting-the-model"),v(it,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),v(it,"href","#exporting-the-model"),v(qe,"class","relative group"),v(ft,"id","validating-the-model-outputs"),v(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"),v(ft,"href","#validating-the-model-outputs"),v(Ae,"class","relative group"),v(Xo,"href","/docs/transformers/main/en/main_classes/onnx#transformers.onnx.OnnxConfig.generate_dummy_inputs"),v(ct,"id","contributing-a-new-configuration-to-transformers"),v(ct,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),v(ct,"href","#contributing-a-new-configuration-to-transformers"),v(Ie,"class","relative group"),v(ro,"href","https://github.com/huggingface/transformers/pull/14868/files"),v(ro,"rel","nofollow")},m(t,f){e(document.head,d),c(t,w,f),c(t,m,f),e(m,_),e(_,b),L(g,b,null),e(m,O),e(m,T),e(T,x),c(t,$,f),c(t,y,f),e(y,k),e(y,N),e(N,E),e(y,j),c(t,P,f),c(t,R,f),e(R,S),e(R,U),e(U,de),e(R,te),c(t,ne,f),c(t,H,f),e(H,oe),c(t,M,f),c(t,K,f),e(K,W),e(K,se),e(se,G),e(G,he),e(K,ue),c(t,J,f),L(ae,t,f),c(t,Pe,f),c(t,ce,f),e(ce,le),c(t,Xe,f),c(t,h,f),e(h,Ne),e(Ne,_t),e(h,B),e(h,z),e(z,vt),e(h,ho),e(h,Me),e(Me,me),e(h,uo),e(h,re),e(re,Et),e(h,mo),e(h,Be),e(Be,ge),e(h,go),e(h,Re),e(Re,Fe),e(h,_o),e(h,Uo),e(Uo,Dr),e(h,Lr),e(h,Ko),e(Ko,qr),e(h,Ar),e(h,Jo),e(Jo,Ir),e(h,Pr),e(h,Qo),e(Qo,Xr),e(h,Mr),e(h,Zo),e(Zo,Br),e(h,Rr),e(h,es),e(es,Fr),e(h,Sr),e(h,ts),e(ts,zr),e(h,Vr),e(h,os),e(os,Hr),e(h,Wr),e(h,ss),e(ss,Gr),e(h,Yr),e(h,ns),e(ns,Ur),e(h,Kr),e(h,as),e(as,Jr),e(h,Qr),e(h,ls),e(ls,Zr),e(h,ei),e(h,rs),e(rs,ti),e(h,oi),e(h,is),e(is,si),e(h,ni),e(h,ps),e(ps,ai),e(h,li),e(h,fs),e(fs,ri),e(h,ii),e(h,ds),e(ds,pi),e(h,fi),e(h,cs),e(cs,di),e(h,ci),e(h,hs),e(hs,hi),e(h,ui),e(h,us),e(us,mi),e(h,gi),e(h,ms),e(ms,_i),e(h,vi),e(h,gs),e(gs,Ei),e(h,$i),e(h,_s),e(_s,wi),e(h,xi),e(h,vs),e(vs,bi),e(h,ki),e(h,Es),e(Es,yi),e(h,Oi),e(h,$s),e($s,Ti),e(h,Ni),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e(xa,Pc),e(Y,Xc),c(t,Hl,f),L(oo,t,f),c(t,Wl,f),L(pt,t,f),c(t,Gl,f),c(t,Ae,f),e(Ae,ft),e(ft,ba),L(so,ba,null),e(Ae,Mc),e(Ae,ka),e(ka,Bc),c(t,Yl,f),c(t,be,f),e(be,Rc),e(be,ya),e(ya,Fc),e(be,Sc),e(be,Oa),e(Oa,zc),e(be,Vc),c(t,Ul,f),L(no,t,f),c(t,Kl,f),c(t,dt,f),e(dt,Hc),e(dt,Xo),e(Xo,Wc),e(dt,Gc),c(t,Jl,f),c(t,Ie,f),e(Ie,ct),e(ct,Ta),L(ao,Ta,null),e(Ie,Yc),e(Ie,Na),e(Na,Uc),c(t,Ql,f),c(t,Mo,f),e(Mo,Kc),c(t,Zl,f),c(t,ke,f),e(ke,lo),e(lo,Jc),e(lo,ja),e(ja,Qc),e(lo,Zc),e(ke,eh),e(ke,Bo),e(Bo,th),e(Bo,Ca),e(Ca,oh),e(ke,sh),e(ke,Ro),e(Ro,nh),e(Ro,Da),e(Da,ah),c(t,er,f),c(t,ht,f),e(ht,lh),e(ht,ro),e(ro,rh),e(ht,ih),tr=!0},p(t,[f]){const io={};f&2&&(io.$$scope={dirty:f,ctx:t}),ae.$set(io);const La={};f&2&&(La.$$scope={dirty:f,ctx:t}),Ve.$set(La);const qa={};f&2&&(qa.$$scope={dirty:f,ctx:t}),Ye.$set(qa);const Aa={};f&2&&(Aa.$$scope={dirty:f,ctx:t}),Ke.$set(Aa);const po={};f&2&&(po.$$scope={dirty:f,ctx:t}),Ze.$set(po);const Ia={};f&2&&(Ia.$$scope={dirty:f,ctx:t}),et.$set(Ia);const fo={};f&2&&(fo.$$scope={dirty:f,ctx:t}),ot.$set(fo);const Pa={};f&2&&(Pa.$$scope={dirty:f,ctx:t}),nt.$set(Pa);const Xa={};f&2&&(Xa.$$scope={dirty:f,ctx:t}),lt.$set(Xa);const co={};f&2&&(co.$$scope={dirty:f,ctx:t}),rt.$set(co);const Ma={};f&2&&(Ma.$$scope={dirty:f,ctx:t}),pt.$set(Ma)},i(t){tr||(q(g.$$.fragment,t),q(ae.$$.fragment,t),q(wt.$$.fragment,t),q(Ve.$$.fragment,t),q(xt.$$.fragment,t),q(bt.$$.fragment,t),q(kt.$$.fragment,t),q(yt.$$.fragment,t),q(Nt.$$.fragment,t),q(jt.$$.fragment,t),q(Dt.$$.fragment,t),q(Ye.$$.fragment,t),q(Lt.$$.fragment,t),q(Ke.$$.fragment,t),q(Vt.$$.fragment,t),q(Ht.$$.fragment,t),q(Wt.$$.fragment,t),q(Ze.$$.fragment,t),q(et.$$.fragment,t),q(Gt.$$.fragment,t),q(ot.$$.fragment,t),q(Yt.$$.fragment,t),q(nt.$$.fragment,t),q(Ut.$$.fragment,t),q(lt.$$.fragment,t),q(Kt.$$.fragment,t),q(Jt.$$.fragment,t),q(Qt.$$.fragment,t),q(Zt.$$.fragment,t),q(rt.$$.fragment,t),q(eo.$$.fragment,t),q(to.$$.fragment,t),q(oo.$$.fragment,t),q(pt.$$.fragment,t),q(so.$$.fragment,t),q(no.$$.fragment,t),q(ao.$$.fragment,t),tr=!0)},o(t){A(g.$$.fragment,t),A(ae.$$.fragment,t),A(wt.$$.fragment,t),A(Ve.$$.fragment,t),A(xt.$$.fragment,t),A(bt.$$.fragment,t),A(kt.$$.fragment,t),A(yt.$$.fragment,t),A(Nt.$$.fragment,t),A(jt.$$.fragment,t),A(Dt.$$.fragment,t),A(Ye.$$.fragment,t),A(Lt.$$.fragment,t),A(Ke.$$.fragment,t),A(Vt.$$.fragment,t),A(Ht.$$.fragment,t),A(Wt.$$.fragment,t),A(Ze.$$.fragment,t),A(et.$$.fragment,t),A(Gt.$$.fragment,t),A(ot.$$.fragment,t),A(Yt.$$.fragment,t),A(nt.$$.fragment,t),A(Ut.$$.fragment,t),A(lt.$$.fragment,t),A(Kt.$$.fragment,t),A(Jt.$$.fragment,t),A(Qt.$$.fragment,t),A(Zt.$$.fragment,t),A(rt.$$.fragment,t),A(eo.$$.fragment,t),A(to.$$.fragment,t),A(oo.$$.fragment,t),A(pt.$$.fragment,t),A(so.$$.fragment,t),A(no.$$.fragment,t),A(ao.$$.fragment,t),tr=!1},d(t){o(d),t&&o(w),t&&o(m),I(g),t&&o($),t&&o(y),t&&o(P),t&&o(R),t&&o(ne),t&&o(H),t&&o(M),t&&o(K),t&&o(J),I(ae,t),t&&o(Pe),t&&o(ce),t&&o(Xe),t&&o(h),t&&o(Ba),t&&o(vo),t&&o(Ra),t&&o(Se),t&&o(Fa),t&&o(je),I(wt),t&&o(Sa),I(Ve,t),t&&o(za),t&&o(Eo),t&&o(Va),I(xt,t),t&&o(Ha),t&&o(He),t&&o(Wa),I(bt,t),t&&o(Ga),t&&o($o),t&&o(Ya),I(kt,t),t&&o(Ua),t&&o(wo),t&&o(Ka),I(yt,t),t&&o(Ja),t&&o(_e),t&&o(Qa),t&&o(ie),t&&o(Za),I(Nt,t),t&&o(el),t&&o(We),t&&o(tl),I(jt,t),t&&o(ol),t&&o(Ge),t&&o(sl),I(Dt,t),t&&o(nl),t&&o(xo),t&&o(al),I(Ye,t),t&&o(ll),t&&o(Ce),I(Lt),t&&o(rl),I(Ke,t),t&&o(il),t&&o(ve),t&&o(pl),t&&o(Je),t&&o(fl),t&&o(Qe),t&&o(dl),I(Vt,t),t&&o(cl),t&&o(Ee),t&&o(hl),I(Ht,t),t&&o(ul),t&&o(ko),t&&o(ml),I(Wt,t),t&&o(gl),t&&o(pe),t&&o(_l),I(Ze,t),t&&o(vl),I(et,t),t&&o(El),t&&o(De),I(Gt),t&&o($l),I(ot,t),t&&o(wl),t&&o(yo),t&&o(xl),t&&o($e),t&&o(bl),t&&o(Oo),t&&o(kl),t&&o(Le),I(Yt),t&&o(yl),t&&o(To),t&&o(Ol),t&&o(we),t&&o(Tl),I(nt,t),t&&o(Nl),t&&o(at),t&&o(jl),I(Ut,t),t&&o(Cl),t&&o(Q),t&&o(Dl),I(lt,t),t&&o(Ll),t&&o(Ao),t&&o(ql),I(Kt,t),t&&o(Al),t&&o(Io),t&&o(Il),I(Jt,t),t&&o(Pl),t&&o(Po),t&&o(Xl),I(Qt,t),t&&o(Ml),t&&o(Z),t&&o(Bl),I(Zt,t),t&&o(Rl),I(rt,t),t&&o(Fl),t&&o(qe),I(eo),t&&o(Sl),t&&o(xe),t&&o(zl),I(to,t),t&&o(Vl),t&&o(Y),t&&o(Hl),I(oo,t),t&&o(Wl),I(pt,t),t&&o(Gl),t&&o(Ae),I(so),t&&o(Yl),t&&o(be),t&&o(Ul),I(no,t),t&&o(Kl),t&&o(dt),t&&o(Jl),t&&o(Ie),I(ao),t&&o(Ql),t&&o(Mo),t&&o(Zl),t&&o(ke),t&&o(er),t&&o(ht)}}}const o_={local:"export-to-onnx",sections:[{local:"exporting-a-model-to-onnx",title:"Exporting a model to ONNX"},{local:"selecting-features-for-different-model-tasks",title:"Selecting features for different model tasks"},{local:"exporting-a-model-for-an-unsupported-architecture",sections:[{local:"implementing-a-custom-onnx-configuration",title:"Implementing a custom ONNX configuration"},{local:"exporting-the-model",title:"Exporting the model"},{local:"validating-the-model-outputs",title:"Validating the model outputs"}],title:"Exporting a model for an unsupported architecture"},{local:"contributing-a-new-configuration-to-transformers",title:"Contributing a new configuration to \u{1F917} Transformers"}],title:"Export to ONNX"};function s_(X){return Bg(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class p_ extends Ig{constructor(d){super();Pg(this,d,s_,t_,Xg,{})}}export{p_ as default,o_ as metadata};
