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