import{S as va,i as xa,s as Ta,e as a,k as m,w as f,t as l,M as Ma,c as r,d as o,m as c,a as i,x as h,h as n,b as d,G as t,g as p,y as u,q as b,o as w,B as y,v as Na}from"../chunks/vendor-hf-doc-builder.js";import{T as _a}from"../chunks/Tip-hf-doc-builder.js";import{I as at}from"../chunks/IconCopyLink-hf-doc-builder.js";import{C as T}from"../chunks/CodeBlock-hf-doc-builder.js";function ka(Vt){let v,$,M,_;return{c(){v=a("p"),$=a("code"),M=l("tranformers.onnx"),_=l(" is no longer maintained, please export models with \u{1F917} Optimum as described above. This section will be removed in the future versions.")},l(J){v=r(J,"P",{});var N=i(v);$=r(N,"CODE",{});var Fe=i($);M=n(Fe,"tranformers.onnx"),Fe.forEach(o),_=n(N," is no longer maintained, please export models with \u{1F917} Optimum as described above. This section will be removed in the future versions."),N.forEach(o)},m(J,N){p(J,v,N),t(v,$),t($,M),t(v,_)},d(J){J&&o(v)}}}function Ea(Vt){let v,$,M,_,J,N,Fe,rt,el,zt,Ve,tl,At,V,ol,it,ll,nl,St,z,sl,ze,al,rl,Ht,Z,A,pt,ie,il,mt,pl,Qt,O,pe,ml,cl,ct,dl,fl,Yt,Ae,hl,qt,Se,ul,Pt,X,W,bl,me,wl,yl,ce,gl,vl,xl,R,Tl,S,dt,Ml,Nl,_l,ft,kl,El,Jl,C,$l,de,Xl,Ul,He,jl,Zl,Lt,Qe,Ol,Dt,H,Wl,fe,Rl,Cl,Kt,Ye,Bl,eo,Q,ht,Gl,Il,he,Fl,ut,Vl,zl,to,B,Y,bt,ue,Al,wt,Sl,oo,qe,Hl,lo,be,no,q,Ql,we,Yl,ql,so,ye,ao,P,Pl,yt,Ll,Dl,ro,ge,io,L,Kl,gt,en,tn,po,ve,mo,g,on,vt,ln,nn,xt,sn,an,Tt,rn,pn,Mt,mn,cn,xe,dn,fn,Nt,hn,un,co,Te,fo,k,bn,_t,wn,yn,Me,gn,vn,Ne,xn,Tn,ho,_e,uo,D,Mn,ke,Nn,_n,bo,Ee,wo,G,K,kt,Je,kn,Pe,En,Et,Jn,yo,Le,$n,go,$e,vo,I,ee,Jt,Xe,Xn,$t,Un,xo,U,jn,Ue,Xt,Zn,On,je,Wn,Rn,To,F,te,Ut,Ze,Cn,De,Bn,jt,Gn,Mo,oe,No,le,In,Zt,Fn,Vn,_o,Oe,ko,ne,zn,Ot,An,Sn,Eo,We,Jo,j,Hn,Wt,Qn,Yn,Rt,qn,Pn,$o,Re,Xo,se,Ln,Ct,Dn,Kn,Uo,Ce,jo,Ke,es,Zo,Be,Oo,E,ts,Bt,os,ls,Gt,ns,ss,It,as,rs,Wo,Ge,Ro;return N=new at({}),ie=new at({}),ue=new at({}),be=new T({props:{code:"cGlwJTIwaW5zdGFsbCUyMG9wdGltdW0lNUJleHBvcnRlcnMlNUQ=",highlighted:"pip install optimum[exporters]"}}),ye=new T({props:{code:"b3B0aW11bS1jbGklMjBleHBvcnQlMjBvbm54JTIwLS1oZWxw",highlighted:'optimum-cli <span class="hljs-built_in">export</span> onnx --<span class="hljs-built_in">help</span>'}}),ge=new T({props:{code:"b3B0aW11bS1jbGklMjBleHBvcnQlMjBvbm54JTIwLS1tb2RlbCUyMGRpc3RpbGJlcnQtYmFzZS11bmNhc2VkLWRpc3RpbGxlZC1zcXVhZCUyMGRpc3RpbGJlcnRfYmFzZV91bmNhc2VkX3NxdWFkX29ubnglMkY=",highlighted:'optimum-cli <span class="hljs-built_in">export</span> onnx --model distilbert-base-uncased-distilled-squad distilbert_base_uncased_squad_onnx/'}}),ve=new T({props:{code:"VmFsaWRhdGluZyUyME9OTlglMjBtb2RlbCUyMGRpc3RpbGJlcnRfYmFzZV91bmNhc2VkX3NxdWFkX29ubnglMkZtb2RlbC5vbm54Li4uJTBBJTA5LSU1QiVFMiU5QyU5MyU1RCUyME9OTlglMjBtb2RlbCUyMG91dHB1dCUyMG5hbWVzJTIwbWF0Y2glMjByZWZlcmVuY2UlMjBtb2RlbCUyMChzdGFydF9sb2dpdHMlMkMlMjBlbmRfbG9naXRzKSUwQSUwOS0lMjBWYWxpZGF0aW5nJTIwT05OWCUyME1vZGVsJTIwb3V0cHV0JTIwJTIyc3RhcnRfbG9naXRzJTIyJTNBJTBBJTA5JTA5LSU1QiVFMiU5QyU5MyU1RCUyMCgyJTJDJTIwMTYpJTIwbWF0Y2hlcyUyMCgyJTJDJTIwMTYpJTBBJTA5JTA5LSU1QiVFMiU5QyU5MyU1RCUyMGFsbCUyMHZhbHVlcyUyMGNsb3NlJTIwKGF0b2wlM0ElMjAwLjAwMDEpJTBBJTA5LSUyMFZhbGlkYXRpbmclMjBPTk5YJTIwTW9kZWwlMjBvdXRwdXQlMjAlMjJlbmRfbG9naXRzJTIyJTNBJTBBJTA5JTA5LSU1QiVFMiU5QyU5MyU1RCUyMCgyJTJDJTIwMTYpJTIwbWF0Y2hlcyUyMCgyJTJDJTIwMTYpJTBBJTA5JTA5LSU1QiVFMiU5QyU5MyU1RCUyMGFsbCUyMHZhbHVlcyUyMGNsb3NlJTIwKGF0b2wlM0ElMjAwLjAwMDEpJTBBVGhlJTIwT05OWCUyMGV4cG9ydCUyMHN1Y2NlZWRlZCUyMGFuZCUyMHRoZSUyMGV4cG9ydGVkJTIwbW9kZWwlMjB3YXMlMjBzYXZlZCUyMGF0JTNBJTIwZGlzdGlsYmVydF9iYXNlX3VuY2FzZWRfc3F1YWRfb25ueA==",highlighted:`Validating ONNX model distilbert_base_uncased_squad_onnx/model.onnx...
	-[\u2713] ONNX model output names match reference model (start_logits, end_logits)
	- Validating ONNX Model output <span class="hljs-string">&quot;start_logits&quot;</span>:
		-[\u2713] (2, 16) matches (2, 16)
		-[\u2713] all values close (atol: 0.0001)
	- Validating ONNX Model output <span class="hljs-string">&quot;end_logits&quot;</span>:
		-[\u2713] (2, 16) matches (2, 16)
		-[\u2713] all values close (atol: 0.0001)
The ONNX <span class="hljs-built_in">export</span> succeeded and the exported model was saved at: distilbert_base_uncased_squad_onnx`}}),Te=new T({props:{code:"b3B0aW11bS1jbGklMjBleHBvcnQlMjBvbm54JTIwLS1tb2RlbCUyMGxvY2FsX3BhdGglMjAtLXRhc2slMjBxdWVzdGlvbi1hbnN3ZXJpbmclMjBkaXN0aWxiZXJ0X2Jhc2VfdW5jYXNlZF9zcXVhZF9vbm54JTJG",highlighted:'optimum-cli <span class="hljs-built_in">export</span> onnx --model local_path --task question-answering distilbert_base_uncased_squad_onnx/'}}),_e=new T({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMEF1dG9Ub2tlbml6ZXIlMEFmcm9tJTIwb3B0aW11bS5vbm54cnVudGltZSUyMGltcG9ydCUyME9SVE1vZGVsRm9yUXVlc3Rpb25BbnN3ZXJpbmclMEElMEF0b2tlbml6ZXIlMjAlM0QlMjBBdXRvVG9rZW5pemVyLmZyb21fcHJldHJhaW5lZCglMjJkaXN0aWxiZXJ0X2Jhc2VfdW5jYXNlZF9zcXVhZF9vbm54JTIyKSUwQW1vZGVsJTIwJTNEJTIwT1JUTW9kZWxGb3JRdWVzdGlvbkFuc3dlcmluZy5mcm9tX3ByZXRyYWluZWQoJTIyZGlzdGlsYmVydF9iYXNlX3VuY2FzZWRfc3F1YWRfb25ueCUyMiklMEFpbnB1dHMlMjAlM0QlMjB0b2tlbml6ZXIoJTIyV2hhdCUyMGFtJTIwSSUyMHVzaW5nJTNGJTIyJTJDJTIwJTIyVXNpbmclMjBEaXN0aWxCRVJUJTIwd2l0aCUyME9OTlglMjBSdW50aW1lISUyMiUyQyUyMHJldHVybl90ZW5zb3JzJTNEJTIycHQlMjIpJTBBb3V0cHV0cyUyMCUzRCUyMG1vZGVsKCoqaW5wdXRzKQ==",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> optimum.onnxruntime <span class="hljs-keyword">import</span> ORTModelForQuestionAnswering

<span class="hljs-meta">&gt;&gt;&gt; </span>tokenizer = AutoTokenizer.from_pretrained(<span class="hljs-string">&quot;distilbert_base_uncased_squad_onnx&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>model = ORTModelForQuestionAnswering.from_pretrained(<span class="hljs-string">&quot;distilbert_base_uncased_squad_onnx&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>inputs = tokenizer(<span class="hljs-string">&quot;What am I using?&quot;</span>, <span class="hljs-string">&quot;Using DistilBERT with ONNX Runtime!&quot;</span>, return_tensors=<span class="hljs-string">&quot;pt&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>outputs = model(**inputs)`}}),Ee=new T({props:{code:"b3B0aW11bS1jbGklMjBleHBvcnQlMjBvbm54JTIwLS1tb2RlbCUyMGtlcmFzLWlvJTJGdHJhbnNmb3JtZXJzLXFhJTIwZGlzdGlsYmVydF9iYXNlX2Nhc2VkX3NxdWFkX29ubnglMkY=",highlighted:'optimum-cli <span class="hljs-built_in">export</span> onnx --model keras-io/transformers-qa distilbert_base_cased_squad_onnx/'}}),Je=new at({}),$e=new T({props:{code:"ZnJvbSUyMG9wdGltdW0ub25ueHJ1bnRpbWUlMjBpbXBvcnQlMjBPUlRNb2RlbEZvclNlcXVlbmNlQ2xhc3NpZmljYXRpb24lMEFmcm9tJTIwdHJhbnNmb3JtZXJzJTIwaW1wb3J0JTIwQXV0b1Rva2VuaXplciUwQSUwQW1vZGVsX2NoZWNrcG9pbnQlMjAlM0QlMjAlMjJkaXN0aWxiZXJ0X2Jhc2VfdW5jYXNlZF9zcXVhZCUyMiUwQXNhdmVfZGlyZWN0b3J5JTIwJTNEJTIwJTIyb25ueCUyRiUyMiUwQSUwQSUyMyUyMExvYWQlMjBhJTIwbW9kZWwlMjBmcm9tJTIwdHJhbnNmb3JtZXJzJTIwYW5kJTIwZXhwb3J0JTIwaXQlMjB0byUyME9OTlglMEFvcnRfbW9kZWwlMjAlM0QlMjBPUlRNb2RlbEZvclNlcXVlbmNlQ2xhc3NpZmljYXRpb24uZnJvbV9wcmV0cmFpbmVkKG1vZGVsX2NoZWNrcG9pbnQlMkMlMjBleHBvcnQlM0RUcnVlKSUwQXRva2VuaXplciUyMCUzRCUyMEF1dG9Ub2tlbml6ZXIuZnJvbV9wcmV0cmFpbmVkKG1vZGVsX2NoZWNrcG9pbnQpJTBBJTBBJTIzJTIwU2F2ZSUyMHRoZSUyMG9ubnglMjBtb2RlbCUyMGFuZCUyMHRva2VuaXplciUwQW9ydF9tb2RlbC5zYXZlX3ByZXRyYWluZWQoc2F2ZV9kaXJlY3RvcnkpJTBBdG9rZW5pemVyLnNhdmVfcHJldHJhaW5lZChzYXZlX2RpcmVjdG9yeSk=",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> optimum.onnxruntime <span class="hljs-keyword">import</span> ORTModelForSequenceClassification
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoTokenizer

<span class="hljs-meta">&gt;&gt;&gt; </span>model_checkpoint = <span class="hljs-string">&quot;distilbert_base_uncased_squad&quot;</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>save_directory = <span class="hljs-string">&quot;onnx/&quot;</span>

<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># Load a model from transformers and export it to ONNX</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>ort_model = ORTModelForSequenceClassification.from_pretrained(model_checkpoint, export=<span class="hljs-literal">True</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>tokenizer = AutoTokenizer.from_pretrained(model_checkpoint)

<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># Save the onnx model and tokenizer</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>ort_model.save_pretrained(save_directory)
<span class="hljs-meta">&gt;&gt;&gt; </span>tokenizer.save_pretrained(save_directory)`}}),Xe=new at({}),Ze=new at({}),oe=new _a({props:{warning:!0,$$slots:{default:[ka]},$$scope:{ctx:Vt}}}),Oe=new T({props:{code:"cGlwJTIwaW5zdGFsbCUyMHRyYW5zZm9ybWVycyU1Qm9ubnglNUQ=",highlighted:"pip install transformers[onnx]"}}),We=new T({props:{code:"cHl0aG9uJTIwLW0lMjB0cmFuc2Zvcm1lcnMub25ueCUyMC0tbW9kZWwlM0RkaXN0aWxiZXJ0LWJhc2UtdW5jYXNlZCUyMG9ubnglMkY=",highlighted:"python -m transformers.onnx --model=distilbert-base-uncased onnx/"}}),Re=new T({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMEF1dG9Ub2tlbml6ZXIlMEFmcm9tJTIwb25ueHJ1bnRpbWUlMjBpbXBvcnQlMjBJbmZlcmVuY2VTZXNzaW9uJTBBJTBBdG9rZW5pemVyJTIwJTNEJTIwQXV0b1Rva2VuaXplci5mcm9tX3ByZXRyYWluZWQoJTIyZGlzdGlsYmVydC1iYXNlLXVuY2FzZWQlMjIpJTBBc2Vzc2lvbiUyMCUzRCUyMEluZmVyZW5jZVNlc3Npb24oJTIyb25ueCUyRm1vZGVsLm9ubnglMjIpJTBBJTIzJTIwT05OWCUyMFJ1bnRpbWUlMjBleHBlY3RzJTIwTnVtUHklMjBhcnJheXMlMjBhcyUyMGlucHV0JTBBaW5wdXRzJTIwJTNEJTIwdG9rZW5pemVyKCUyMlVzaW5nJTIwRGlzdGlsQkVSVCUyMHdpdGglMjBPTk5YJTIwUnVudGltZSElMjIlMkMlMjByZXR1cm5fdGVuc29ycyUzRCUyMm5wJTIyKSUwQW91dHB1dHMlMjAlM0QlMjBzZXNzaW9uLnJ1bihvdXRwdXRfbmFtZXMlM0QlNUIlMjJsYXN0X2hpZGRlbl9zdGF0ZSUyMiU1RCUyQyUyMGlucHV0X2ZlZWQlM0RkaWN0KGlucHV0cykp",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))`}}),Ce=new T({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycy5tb2RlbHMuZGlzdGlsYmVydCUyMGltcG9ydCUyMERpc3RpbEJlcnRDb25maWclMkMlMjBEaXN0aWxCZXJ0T25ueENvbmZpZyUwQSUwQWNvbmZpZyUyMCUzRCUyMERpc3RpbEJlcnRDb25maWcoKSUwQW9ubnhfY29uZmlnJTIwJTNEJTIwRGlzdGlsQmVydE9ubnhDb25maWcoY29uZmlnKSUwQXByaW50KGxpc3Qob25ueF9jb25maWcub3V0cHV0cy5rZXlzKCkpKQ==",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>]`}}),Be=new T({props:{code:"cHl0aG9uJTIwLW0lMjB0cmFuc2Zvcm1lcnMub25ueCUyMC0tbW9kZWwlM0RrZXJhcy1pbyUyRnRyYW5zZm9ybWVycy1xYSUyMG9ubnglMkY=",highlighted:"python -m transformers.onnx --model=keras-io/transformers-qa onnx/"}}),Ge=new T({props:{code:"cHl0aG9uJTIwLW0lMjB0cmFuc2Zvcm1lcnMub25ueCUyMC0tbW9kZWwlM0Rsb2NhbC1wdC1jaGVja3BvaW50JTIwb25ueCUyRg==",highlighted:"python -m transformers.onnx --model=local-pt-checkpoint onnx/"}}),{c(){v=a("meta"),$=m(),M=a("h1"),_=a("a"),J=a("span"),f(N.$$.fragment),Fe=m(),rt=a("span"),el=l("Export to ONNX"),zt=m(),Ve=a("p"),tl=l(`Deploying \u{1F917} Transformers models in production environments often requires, or can benefit from exporting the models into
a serialized format that can be loaded and executed on specialized runtimes and hardware.`),At=m(),V=a("p"),ol=l(`\u{1F917} Optimum is an extension of Transformers that enables exporting models from PyTorch or TensorFlow to serialized formats
such as ONNX and TFLite through its `),it=a("code"),ll=l("exporters"),nl=l(` module. \u{1F917} Optimum also provides a set of performance optimization tools to train
and run models on targeted hardware with maximum efficiency.`),St=m(),z=a("p"),sl=l(`This guide demonstrates how you can export \u{1F917} Transformers models to ONNX with \u{1F917} Optimum, for the guide on exporting models to TFLite,
please refer to the `),ze=a("a"),al=l("Export to TFLite page"),rl=l("."),Ht=m(),Z=a("h2"),A=a("a"),pt=a("span"),f(ie.$$.fragment),il=m(),mt=a("span"),pl=l("Export to ONNX"),Qt=m(),O=a("p"),pe=a("a"),ml=l("ONNX (Open Neural Network eXchange)"),cl=l(` 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 `),ct=a("em"),dl=l("intermediate representation"),fl=l(`) which
represents the flow of data through the neural network.`),Yt=m(),Ae=a("p"),hl=l(`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).`),qt=m(),Se=a("p"),ul=l("Once exported to ONNX format, a model can be:"),Pt=m(),X=a("ul"),W=a("li"),bl=l("optimized for inference via techniques such as "),me=a("a"),wl=l("graph optimization"),yl=l(" and "),ce=a("a"),gl=l("quantization"),vl=l("."),xl=m(),R=a("li"),Tl=l("run with ONNX Runtime via "),S=a("a"),dt=a("code"),Ml=l("ORTModelForXXX"),Nl=l(" classes"),_l=l(`,
which follow the same `),ft=a("code"),kl=l("AutoModel"),El=l(" API as the one you are used to in \u{1F917} Transformers."),Jl=m(),C=a("li"),$l=l("run with "),de=a("a"),Xl=l("optimized inference pipelines"),Ul=l(`,
which has the same API as the `),He=a("a"),jl=l("pipeline()"),Zl=l(" function in \u{1F917} Transformers."),Lt=m(),Qe=a("p"),Ol=l(`\u{1F917} Optimum provides support for the ONNX export 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.`),Dt=m(),H=a("p"),Wl=l("For the list of ready-made configurations, please refer to "),fe=a("a"),Rl=l("\u{1F917} Optimum documentation"),Cl=l("."),Kt=m(),Ye=a("p"),Bl=l("There are two ways to export a \u{1F917} Transformers model to ONNX, here we show both:"),eo=m(),Q=a("ul"),ht=a("li"),Gl=l("export with \u{1F917} Optimum via CLI."),Il=m(),he=a("li"),Fl=l("export with \u{1F917} Optimum with "),ut=a("code"),Vl=l("optimum.onnxruntime"),zl=l("."),to=m(),B=a("h3"),Y=a("a"),bt=a("span"),f(ue.$$.fragment),Al=m(),wt=a("span"),Sl=l("Exporting a \u{1F917} Transformers model to ONNX with CLI"),oo=m(),qe=a("p"),Hl=l("To export a \u{1F917} Transformers model to ONNX, first install an extra dependency:"),lo=m(),f(be.$$.fragment),no=m(),q=a("p"),Ql=l("To check out all available arguments, refer to the "),we=a("a"),Yl=l("\u{1F917} Optimum docs"),ql=l(`,
or view help in command line:`),so=m(),f(ye.$$.fragment),ao=m(),P=a("p"),Pl=l("To export a model\u2019s checkpoint from the \u{1F917} Hub, for example, "),yt=a("code"),Ll=l("distilbert-base-uncased-distilled-squad"),Dl=l(", run the following command:"),ro=m(),f(ge.$$.fragment),io=m(),L=a("p"),Kl=l("You should see the logs indicating progress and showing where the resulting "),gt=a("code"),en=l("model.onnx"),tn=l(" is saved, like this:"),po=m(),f(ve.$$.fragment),mo=m(),g=a("p"),on=l(`The example above illustrates exporting a checkpoint from \u{1F917} Hub. When exporting a local model, first make sure that you
saved both the model\u2019s weights and tokenizer files in the same directory (`),vt=a("code"),ln=l("local_path"),nn=l(`). When using CLI, pass the
`),xt=a("code"),sn=l("local_path"),an=l(" to the "),Tt=a("code"),rn=l("model"),pn=l(" argument instead of the checkpoint name on \u{1F917} Hub and provide the "),Mt=a("code"),mn=l("--task"),cn=l(` argument.
You can review the list of supported tasks in the `),xe=a("a"),dn=l("\u{1F917} Optimum documentation"),fn=l(`.
If `),Nt=a("code"),hn=l("task"),un=l(" argument is not provided, it will default to the model architecture without any task specific head."),co=m(),f(Te.$$.fragment),fo=m(),k=a("p"),bn=l("The resulting "),_t=a("code"),wn=l("model.onnx"),yn=l(" file can then be run on one of the "),Me=a("a"),gn=l(`many
accelerators`),vn=l(` that support the ONNX
standard. For example, we can load and run the model with `),Ne=a("a"),xn=l(`ONNX
Runtime`),Tn=l(" as follows:"),ho=m(),f(_e.$$.fragment),uo=m(),D=a("p"),Mn=l(`The process is identical for TensorFlow checkpoints on the Hub. For instance, here\u2019s how you would
export a pure TensorFlow checkpoint from the `),ke=a("a"),Nn=l("Keras organization"),_n=l(":"),bo=m(),f(Ee.$$.fragment),wo=m(),G=a("h3"),K=a("a"),kt=a("span"),f(Je.$$.fragment),kn=m(),Pe=a("span"),En=l("Exporting a \u{1F917} Transformers model to ONNX with "),Et=a("code"),Jn=l("optimum.onnxruntime"),yo=m(),Le=a("p"),$n=l("Alternative to CLI, you can export a \u{1F917} Transformers model to ONNX programmatically like so:"),go=m(),f($e.$$.fragment),vo=m(),I=a("h3"),ee=a("a"),Jt=a("span"),f(Xe.$$.fragment),Xn=m(),$t=a("span"),Un=l("Exporting a model for an unsupported architecture"),xo=m(),U=a("p"),jn=l(`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 `),Ue=a("a"),Xt=a("code"),Zn=l("optimum.exporters.onnx"),On=l(`,
and if it is not, `),je=a("a"),Wn=l("contribute to \u{1F917} Optimum"),Rn=l(`
directly.`),To=m(),F=a("h3"),te=a("a"),Ut=a("span"),f(Ze.$$.fragment),Cn=m(),De=a("span"),Bn=l("Exporting a model with "),jt=a("code"),Gn=l("transformers.onnx"),Mo=m(),f(oe.$$.fragment),No=m(),le=a("p"),In=l("To export a \u{1F917} Transformers model to ONNX with "),Zt=a("code"),Fn=l("tranformers.onnx"),Vn=l(", install extra dependencies:"),_o=m(),f(Oe.$$.fragment),ko=m(),ne=a("p"),zn=l("Use "),Ot=a("code"),An=l("transformers.onnx"),Sn=l(" package as a Python module to export a checkpoint using a ready-made configuration:"),Eo=m(),f(We.$$.fragment),Jo=m(),j=a("p"),Hn=l("This exports an ONNX graph of the checkpoint defined by the "),Wt=a("code"),Qn=l("--model"),Yn=l(` argument. Pass any checkpoint on the \u{1F917} Hub or one that\u2019s stored locally.
The resulting `),Rt=a("code"),qn=l("model.onnx"),Pn=l(` file can then be run on one of the many accelerators that support the ONNX standard. For example,
load and run the model with ONNX Runtime as follows:`),$o=m(),f(Re.$$.fragment),Xo=m(),se=a("p"),Ln=l("The required output names (like "),Ct=a("code"),Dn=l('["last_hidden_state"]'),Kn=l(`) can be obtained by taking a look at the ONNX configuration of
each model. For example, for DistilBERT we have:`),Uo=m(),f(Ce.$$.fragment),jo=m(),Ke=a("p"),es=l("The process is identical for TensorFlow checkpoints on the Hub. For example, export a pure TensorFlow checkpoint like so:"),Zo=m(),f(Be.$$.fragment),Oo=m(),E=a("p"),ts=l("To export a model that\u2019s stored locally, save the model\u2019s weights and tokenizer files in the same directory (e.g. "),Bt=a("code"),os=l("local-pt-checkpoint"),ls=l(`),
then export it to ONNX by pointing the `),Gt=a("code"),ns=l("--model"),ss=l(" argument of the "),It=a("code"),as=l("transformers.onnx"),rs=l(" package to the desired directory:"),Wo=m(),f(Ge.$$.fragment),this.h()},l(e){const s=Ma('[data-svelte="svelte-1phssyn"]',document.head);v=r(s,"META",{name:!0,content:!0}),s.forEach(o),$=c(e),M=r(e,"H1",{class:!0});var Ie=i(M);_=r(Ie,"A",{id:!0,class:!0,href:!0});var cs=i(_);J=r(cs,"SPAN",{});var ds=i(J);h(N.$$.fragment,ds),ds.forEach(o),cs.forEach(o),Fe=c(Ie),rt=r(Ie,"SPAN",{});var fs=i(rt);el=n(fs,"Export to ONNX"),fs.forEach(o),Ie.forEach(o),zt=c(e),Ve=r(e,"P",{});var hs=i(Ve);tl=n(hs,`Deploying \u{1F917} Transformers models in production environments often requires, or can benefit from exporting the models into
a serialized format that can be loaded and executed on specialized runtimes and hardware.`),hs.forEach(o),At=c(e),V=r(e,"P",{});var Co=i(V);ol=n(Co,`\u{1F917} Optimum is an extension of Transformers that enables exporting models from PyTorch or TensorFlow to serialized formats
such as ONNX and TFLite through its `),it=r(Co,"CODE",{});var us=i(it);ll=n(us,"exporters"),us.forEach(o),nl=n(Co,` module. \u{1F917} Optimum also provides a set of performance optimization tools to train
and run models on targeted hardware with maximum efficiency.`),Co.forEach(o),St=c(e),z=r(e,"P",{});var Bo=i(z);sl=n(Bo,`This guide demonstrates how you can export \u{1F917} Transformers models to ONNX with \u{1F917} Optimum, for the guide on exporting models to TFLite,
please refer to the `),ze=r(Bo,"A",{href:!0});var bs=i(ze);al=n(bs,"Export to TFLite page"),bs.forEach(o),rl=n(Bo,"."),Bo.forEach(o),Ht=c(e),Z=r(e,"H2",{class:!0});var Go=i(Z);A=r(Go,"A",{id:!0,class:!0,href:!0});var ws=i(A);pt=r(ws,"SPAN",{});var ys=i(pt);h(ie.$$.fragment,ys),ys.forEach(o),ws.forEach(o),il=c(Go),mt=r(Go,"SPAN",{});var gs=i(mt);pl=n(gs,"Export to ONNX"),gs.forEach(o),Go.forEach(o),Qt=c(e),O=r(e,"P",{});var Ft=i(O);pe=r(Ft,"A",{href:!0,rel:!0});var vs=i(pe);ml=n(vs,"ONNX (Open Neural Network eXchange)"),vs.forEach(o),cl=n(Ft,` 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 `),ct=r(Ft,"EM",{});var xs=i(ct);dl=n(xs,"intermediate representation"),xs.forEach(o),fl=n(Ft,`) which
represents the flow of data through the neural network.`),Ft.forEach(o),Yt=c(e),Ae=r(e,"P",{});var Ts=i(Ae);hl=n(Ts,`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).`),Ts.forEach(o),qt=c(e),Se=r(e,"P",{});var Ms=i(Se);ul=n(Ms,"Once exported to ONNX format, a model can be:"),Ms.forEach(o),Pt=c(e),X=r(e,"UL",{});var et=i(X);W=r(et,"LI",{});var tt=i(W);bl=n(tt,"optimized for inference via techniques such as "),me=r(tt,"A",{href:!0,rel:!0});var Ns=i(me);wl=n(Ns,"graph optimization"),Ns.forEach(o),yl=n(tt," and "),ce=r(tt,"A",{href:!0,rel:!0});var _s=i(ce);gl=n(_s,"quantization"),_s.forEach(o),vl=n(tt,"."),tt.forEach(o),xl=c(et),R=r(et,"LI",{});var ot=i(R);Tl=n(ot,"run with ONNX Runtime via "),S=r(ot,"A",{href:!0,rel:!0});var is=i(S);dt=r(is,"CODE",{});var ks=i(dt);Ml=n(ks,"ORTModelForXXX"),ks.forEach(o),Nl=n(is," classes"),is.forEach(o),_l=n(ot,`,
which follow the same `),ft=r(ot,"CODE",{});var Es=i(ft);kl=n(Es,"AutoModel"),Es.forEach(o),El=n(ot," API as the one you are used to in \u{1F917} Transformers."),ot.forEach(o),Jl=c(et),C=r(et,"LI",{});var lt=i(C);$l=n(lt,"run with "),de=r(lt,"A",{href:!0,rel:!0});var Js=i(de);Xl=n(Js,"optimized inference pipelines"),Js.forEach(o),Ul=n(lt,`,
which has the same API as the `),He=r(lt,"A",{href:!0});var $s=i(He);jl=n($s,"pipeline()"),$s.forEach(o),Zl=n(lt," function in \u{1F917} Transformers."),lt.forEach(o),et.forEach(o),Lt=c(e),Qe=r(e,"P",{});var Xs=i(Qe);Ol=n(Xs,`\u{1F917} Optimum provides support for the ONNX export 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.`),Xs.forEach(o),Dt=c(e),H=r(e,"P",{});var Io=i(H);Wl=n(Io,"For the list of ready-made configurations, please refer to "),fe=r(Io,"A",{href:!0,rel:!0});var Us=i(fe);Rl=n(Us,"\u{1F917} Optimum documentation"),Us.forEach(o),Cl=n(Io,"."),Io.forEach(o),Kt=c(e),Ye=r(e,"P",{});var js=i(Ye);Bl=n(js,"There are two ways to export a \u{1F917} Transformers model to ONNX, here we show both:"),js.forEach(o),eo=c(e),Q=r(e,"UL",{});var Fo=i(Q);ht=r(Fo,"LI",{});var Zs=i(ht);Gl=n(Zs,"export with \u{1F917} Optimum via CLI."),Zs.forEach(o),Il=c(Fo),he=r(Fo,"LI",{});var Vo=i(he);Fl=n(Vo,"export with \u{1F917} Optimum with "),ut=r(Vo,"CODE",{});var Os=i(ut);Vl=n(Os,"optimum.onnxruntime"),Os.forEach(o),zl=n(Vo,"."),Vo.forEach(o),Fo.forEach(o),to=c(e),B=r(e,"H3",{class:!0});var zo=i(B);Y=r(zo,"A",{id:!0,class:!0,href:!0});var Ws=i(Y);bt=r(Ws,"SPAN",{});var Rs=i(bt);h(ue.$$.fragment,Rs),Rs.forEach(o),Ws.forEach(o),Al=c(zo),wt=r(zo,"SPAN",{});var Cs=i(wt);Sl=n(Cs,"Exporting a \u{1F917} Transformers model to ONNX with CLI"),Cs.forEach(o),zo.forEach(o),oo=c(e),qe=r(e,"P",{});var Bs=i(qe);Hl=n(Bs,"To export a \u{1F917} Transformers model to ONNX, first install an extra dependency:"),Bs.forEach(o),lo=c(e),h(be.$$.fragment,e),no=c(e),q=r(e,"P",{});var Ao=i(q);Ql=n(Ao,"To check out all available arguments, refer to the "),we=r(Ao,"A",{href:!0,rel:!0});var Gs=i(we);Yl=n(Gs,"\u{1F917} Optimum docs"),Gs.forEach(o),ql=n(Ao,`,
or view help in command line:`),Ao.forEach(o),so=c(e),h(ye.$$.fragment,e),ao=c(e),P=r(e,"P",{});var So=i(P);Pl=n(So,"To export a model\u2019s checkpoint from the \u{1F917} Hub, for example, "),yt=r(So,"CODE",{});var Is=i(yt);Ll=n(Is,"distilbert-base-uncased-distilled-squad"),Is.forEach(o),Dl=n(So,", run the following command:"),So.forEach(o),ro=c(e),h(ge.$$.fragment,e),io=c(e),L=r(e,"P",{});var Ho=i(L);Kl=n(Ho,"You should see the logs indicating progress and showing where the resulting "),gt=r(Ho,"CODE",{});var Fs=i(gt);en=n(Fs,"model.onnx"),Fs.forEach(o),tn=n(Ho," is saved, like this:"),Ho.forEach(o),po=c(e),h(ve.$$.fragment,e),mo=c(e),g=r(e,"P",{});var x=i(g);on=n(x,`The example above illustrates exporting a checkpoint from \u{1F917} Hub. When exporting a local model, first make sure that you
saved both the model\u2019s weights and tokenizer files in the same directory (`),vt=r(x,"CODE",{});var Vs=i(vt);ln=n(Vs,"local_path"),Vs.forEach(o),nn=n(x,`). When using CLI, pass the
`),xt=r(x,"CODE",{});var zs=i(xt);sn=n(zs,"local_path"),zs.forEach(o),an=n(x," to the "),Tt=r(x,"CODE",{});var As=i(Tt);rn=n(As,"model"),As.forEach(o),pn=n(x," argument instead of the checkpoint name on \u{1F917} Hub and provide the "),Mt=r(x,"CODE",{});var Ss=i(Mt);mn=n(Ss,"--task"),Ss.forEach(o),cn=n(x,` argument.
You can review the list of supported tasks in the `),xe=r(x,"A",{href:!0,rel:!0});var Hs=i(xe);dn=n(Hs,"\u{1F917} Optimum documentation"),Hs.forEach(o),fn=n(x,`.
If `),Nt=r(x,"CODE",{});var Qs=i(Nt);hn=n(Qs,"task"),Qs.forEach(o),un=n(x," argument is not provided, it will default to the model architecture without any task specific head."),x.forEach(o),co=c(e),h(Te.$$.fragment,e),fo=c(e),k=r(e,"P",{});var ae=i(k);bn=n(ae,"The resulting "),_t=r(ae,"CODE",{});var Ys=i(_t);wn=n(Ys,"model.onnx"),Ys.forEach(o),yn=n(ae," file can then be run on one of the "),Me=r(ae,"A",{href:!0,rel:!0});var qs=i(Me);gn=n(qs,`many
accelerators`),qs.forEach(o),vn=n(ae,` that support the ONNX
standard. For example, we can load and run the model with `),Ne=r(ae,"A",{href:!0,rel:!0});var Ps=i(Ne);xn=n(Ps,`ONNX
Runtime`),Ps.forEach(o),Tn=n(ae," as follows:"),ae.forEach(o),ho=c(e),h(_e.$$.fragment,e),uo=c(e),D=r(e,"P",{});var Qo=i(D);Mn=n(Qo,`The process is identical for TensorFlow checkpoints on the Hub. For instance, here\u2019s how you would
export a pure TensorFlow checkpoint from the `),ke=r(Qo,"A",{href:!0,rel:!0});var Ls=i(ke);Nn=n(Ls,"Keras organization"),Ls.forEach(o),_n=n(Qo,":"),Qo.forEach(o),bo=c(e),h(Ee.$$.fragment,e),wo=c(e),G=r(e,"H3",{class:!0});var Yo=i(G);K=r(Yo,"A",{id:!0,class:!0,href:!0});var Ds=i(K);kt=r(Ds,"SPAN",{});var Ks=i(kt);h(Je.$$.fragment,Ks),Ks.forEach(o),Ds.forEach(o),kn=c(Yo),Pe=r(Yo,"SPAN",{});var ps=i(Pe);En=n(ps,"Exporting a \u{1F917} Transformers model to ONNX with "),Et=r(ps,"CODE",{});var ea=i(Et);Jn=n(ea,"optimum.onnxruntime"),ea.forEach(o),ps.forEach(o),Yo.forEach(o),yo=c(e),Le=r(e,"P",{});var ta=i(Le);$n=n(ta,"Alternative to CLI, you can export a \u{1F917} Transformers model to ONNX programmatically like so:"),ta.forEach(o),go=c(e),h($e.$$.fragment,e),vo=c(e),I=r(e,"H3",{class:!0});var qo=i(I);ee=r(qo,"A",{id:!0,class:!0,href:!0});var oa=i(ee);Jt=r(oa,"SPAN",{});var la=i(Jt);h(Xe.$$.fragment,la),la.forEach(o),oa.forEach(o),Xn=c(qo),$t=r(qo,"SPAN",{});var na=i($t);Un=n(na,"Exporting a model for an unsupported architecture"),na.forEach(o),qo.forEach(o),xo=c(e),U=r(e,"P",{});var nt=i(U);jn=n(nt,`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 `),Ue=r(nt,"A",{href:!0,rel:!0});var sa=i(Ue);Xt=r(sa,"CODE",{});var aa=i(Xt);Zn=n(aa,"optimum.exporters.onnx"),aa.forEach(o),sa.forEach(o),On=n(nt,`,
and if it is not, `),je=r(nt,"A",{href:!0,rel:!0});var ra=i(je);Wn=n(ra,"contribute to \u{1F917} Optimum"),ra.forEach(o),Rn=n(nt,`
directly.`),nt.forEach(o),To=c(e),F=r(e,"H3",{class:!0});var Po=i(F);te=r(Po,"A",{id:!0,class:!0,href:!0});var ia=i(te);Ut=r(ia,"SPAN",{});var pa=i(Ut);h(Ze.$$.fragment,pa),pa.forEach(o),ia.forEach(o),Cn=c(Po),De=r(Po,"SPAN",{});var ms=i(De);Bn=n(ms,"Exporting a model with "),jt=r(ms,"CODE",{});var ma=i(jt);Gn=n(ma,"transformers.onnx"),ma.forEach(o),ms.forEach(o),Po.forEach(o),Mo=c(e),h(oe.$$.fragment,e),No=c(e),le=r(e,"P",{});var Lo=i(le);In=n(Lo,"To export a \u{1F917} Transformers model to ONNX with "),Zt=r(Lo,"CODE",{});var ca=i(Zt);Fn=n(ca,"tranformers.onnx"),ca.forEach(o),Vn=n(Lo,", install extra dependencies:"),Lo.forEach(o),_o=c(e),h(Oe.$$.fragment,e),ko=c(e),ne=r(e,"P",{});var Do=i(ne);zn=n(Do,"Use "),Ot=r(Do,"CODE",{});var da=i(Ot);An=n(da,"transformers.onnx"),da.forEach(o),Sn=n(Do," package as a Python module to export a checkpoint using a ready-made configuration:"),Do.forEach(o),Eo=c(e),h(We.$$.fragment,e),Jo=c(e),j=r(e,"P",{});var st=i(j);Hn=n(st,"This exports an ONNX graph of the checkpoint defined by the "),Wt=r(st,"CODE",{});var fa=i(Wt);Qn=n(fa,"--model"),fa.forEach(o),Yn=n(st,` argument. Pass any checkpoint on the \u{1F917} Hub or one that\u2019s stored locally.
The resulting `),Rt=r(st,"CODE",{});var ha=i(Rt);qn=n(ha,"model.onnx"),ha.forEach(o),Pn=n(st,` file can then be run on one of the many accelerators that support the ONNX standard. For example,
load and run the model with ONNX Runtime as follows:`),st.forEach(o),$o=c(e),h(Re.$$.fragment,e),Xo=c(e),se=r(e,"P",{});var Ko=i(se);Ln=n(Ko,"The required output names (like "),Ct=r(Ko,"CODE",{});var ua=i(Ct);Dn=n(ua,'["last_hidden_state"]'),ua.forEach(o),Kn=n(Ko,`) can be obtained by taking a look at the ONNX configuration of
each model. For example, for DistilBERT we have:`),Ko.forEach(o),Uo=c(e),h(Ce.$$.fragment,e),jo=c(e),Ke=r(e,"P",{});var ba=i(Ke);es=n(ba,"The process is identical for TensorFlow checkpoints on the Hub. For example, export a pure TensorFlow checkpoint like so:"),ba.forEach(o),Zo=c(e),h(Be.$$.fragment,e),Oo=c(e),E=r(e,"P",{});var re=i(E);ts=n(re,"To export a model that\u2019s stored locally, save the model\u2019s weights and tokenizer files in the same directory (e.g. "),Bt=r(re,"CODE",{});var wa=i(Bt);os=n(wa,"local-pt-checkpoint"),wa.forEach(o),ls=n(re,`),
then export it to ONNX by pointing the `),Gt=r(re,"CODE",{});var ya=i(Gt);ns=n(ya,"--model"),ya.forEach(o),ss=n(re," argument of the "),It=r(re,"CODE",{});var ga=i(It);as=n(ga,"transformers.onnx"),ga.forEach(o),rs=n(re," package to the desired directory:"),re.forEach(o),Wo=c(e),h(Ge.$$.fragment,e),this.h()},h(){d(v,"name","hf:doc:metadata"),d(v,"content",JSON.stringify(Ja)),d(_,"id","export-to-onnx"),d(_,"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"),d(_,"href","#export-to-onnx"),d(M,"class","relative group"),d(ze,"href","tflite"),d(A,"id","export-to-onnx"),d(A,"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"),d(A,"href","#export-to-onnx"),d(Z,"class","relative group"),d(pe,"href","http://onnx.ai"),d(pe,"rel","nofollow"),d(me,"href","https://huggingface.co/docs/optimum/onnxruntime/usage_guides/optimization"),d(me,"rel","nofollow"),d(ce,"href","https://huggingface.co/docs/optimum/onnxruntime/usage_guides/quantization"),d(ce,"rel","nofollow"),d(S,"href","https://huggingface.co/docs/optimum/onnxruntime/package_reference/modeling_ort"),d(S,"rel","nofollow"),d(de,"href","https://huggingface.co/docs/optimum/main/en/onnxruntime/usage_guides/pipelines"),d(de,"rel","nofollow"),d(He,"href","/docs/transformers/v4.32.0/en/main_classes/pipelines#transformers.pipeline"),d(fe,"href","https://huggingface.co/docs/optimum/exporters/onnx/overview"),d(fe,"rel","nofollow"),d(Y,"id","exporting-a-transformers-model-to-onnx-with-cli"),d(Y,"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"),d(Y,"href","#exporting-a-transformers-model-to-onnx-with-cli"),d(B,"class","relative group"),d(we,"href","https://huggingface.co/docs/optimum/exporters/onnx/usage_guides/export_a_model#exporting-a-model-to-onnx-using-the-cli"),d(we,"rel","nofollow"),d(xe,"href","https://huggingface.co/docs/optimum/exporters/task_manager"),d(xe,"rel","nofollow"),d(Me,"href","https://onnx.ai/supported-tools.html#deployModel"),d(Me,"rel","nofollow"),d(Ne,"href","https://onnxruntime.ai/"),d(Ne,"rel","nofollow"),d(ke,"href","https://huggingface.co/keras-io"),d(ke,"rel","nofollow"),d(K,"id","exporting-a-transformers-model-to-onnx-with-optimumonnxruntime"),d(K,"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"),d(K,"href","#exporting-a-transformers-model-to-onnx-with-optimumonnxruntime"),d(G,"class","relative group"),d(ee,"id","exporting-a-model-for-an-unsupported-architecture"),d(ee,"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"),d(ee,"href","#exporting-a-model-for-an-unsupported-architecture"),d(I,"class","relative group"),d(Ue,"href","https://huggingface.co/docs/optimum/exporters/onnx/overview"),d(Ue,"rel","nofollow"),d(je,"href","https://huggingface.co/docs/optimum/exporters/onnx/usage_guides/contribute"),d(je,"rel","nofollow"),d(te,"id","exporting-a-model-with-transformersonnx"),d(te,"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"),d(te,"href","#exporting-a-model-with-transformersonnx"),d(F,"class","relative group")},m(e,s){t(document.head,v),p(e,$,s),p(e,M,s),t(M,_),t(_,J),u(N,J,null),t(M,Fe),t(M,rt),t(rt,el),p(e,zt,s),p(e,Ve,s),t(Ve,tl),p(e,At,s),p(e,V,s),t(V,ol),t(V,it),t(it,ll),t(V,nl),p(e,St,s),p(e,z,s),t(z,sl),t(z,ze),t(ze,al),t(z,rl),p(e,Ht,s),p(e,Z,s),t(Z,A),t(A,pt),u(ie,pt,null),t(Z,il),t(Z,mt),t(mt,pl),p(e,Qt,s),p(e,O,s),t(O,pe),t(pe,ml),t(O,cl),t(O,ct),t(ct,dl),t(O,fl),p(e,Yt,s),p(e,Ae,s),t(Ae,hl),p(e,qt,s),p(e,Se,s),t(Se,ul),p(e,Pt,s),p(e,X,s),t(X,W),t(W,bl),t(W,me),t(me,wl),t(W,yl),t(W,ce),t(ce,gl),t(W,vl),t(X,xl),t(X,R),t(R,Tl),t(R,S),t(S,dt),t(dt,Ml),t(S,Nl),t(R,_l),t(R,ft),t(ft,kl),t(R,El),t(X,Jl),t(X,C),t(C,$l),t(C,de),t(de,Xl),t(C,Ul),t(C,He),t(He,jl),t(C,Zl),p(e,Lt,s),p(e,Qe,s),t(Qe,Ol),p(e,Dt,s),p(e,H,s),t(H,Wl),t(H,fe),t(fe,Rl),t(H,Cl),p(e,Kt,s),p(e,Ye,s),t(Ye,Bl),p(e,eo,s),p(e,Q,s),t(Q,ht),t(ht,Gl),t(Q,Il),t(Q,he),t(he,Fl),t(he,ut),t(ut,Vl),t(he,zl),p(e,to,s),p(e,B,s),t(B,Y),t(Y,bt),u(ue,bt,null),t(B,Al),t(B,wt),t(wt,Sl),p(e,oo,s),p(e,qe,s),t(qe,Hl),p(e,lo,s),u(be,e,s),p(e,no,s),p(e,q,s),t(q,Ql),t(q,we),t(we,Yl),t(q,ql),p(e,so,s),u(ye,e,s),p(e,ao,s),p(e,P,s),t(P,Pl),t(P,yt),t(yt,Ll),t(P,Dl),p(e,ro,s),u(ge,e,s),p(e,io,s),p(e,L,s),t(L,Kl),t(L,gt),t(gt,en),t(L,tn),p(e,po,s),u(ve,e,s),p(e,mo,s),p(e,g,s),t(g,on),t(g,vt),t(vt,ln),t(g,nn),t(g,xt),t(xt,sn),t(g,an),t(g,Tt),t(Tt,rn),t(g,pn),t(g,Mt),t(Mt,mn),t(g,cn),t(g,xe),t(xe,dn),t(g,fn),t(g,Nt),t(Nt,hn),t(g,un),p(e,co,s),u(Te,e,s),p(e,fo,s),p(e,k,s),t(k,bn),t(k,_t),t(_t,wn),t(k,yn),t(k,Me),t(Me,gn),t(k,vn),t(k,Ne),t(Ne,xn),t(k,Tn),p(e,ho,s),u(_e,e,s),p(e,uo,s),p(e,D,s),t(D,Mn),t(D,ke),t(ke,Nn),t(D,_n),p(e,bo,s),u(Ee,e,s),p(e,wo,s),p(e,G,s),t(G,K),t(K,kt),u(Je,kt,null),t(G,kn),t(G,Pe),t(Pe,En),t(Pe,Et),t(Et,Jn),p(e,yo,s),p(e,Le,s),t(Le,$n),p(e,go,s),u($e,e,s),p(e,vo,s),p(e,I,s),t(I,ee),t(ee,Jt),u(Xe,Jt,null),t(I,Xn),t(I,$t),t($t,Un),p(e,xo,s),p(e,U,s),t(U,jn),t(U,Ue),t(Ue,Xt),t(Xt,Zn),t(U,On),t(U,je),t(je,Wn),t(U,Rn),p(e,To,s),p(e,F,s),t(F,te),t(te,Ut),u(Ze,Ut,null),t(F,Cn),t(F,De),t(De,Bn),t(De,jt),t(jt,Gn),p(e,Mo,s),u(oe,e,s),p(e,No,s),p(e,le,s),t(le,In),t(le,Zt),t(Zt,Fn),t(le,Vn),p(e,_o,s),u(Oe,e,s),p(e,ko,s),p(e,ne,s),t(ne,zn),t(ne,Ot),t(Ot,An),t(ne,Sn),p(e,Eo,s),u(We,e,s),p(e,Jo,s),p(e,j,s),t(j,Hn),t(j,Wt),t(Wt,Qn),t(j,Yn),t(j,Rt),t(Rt,qn),t(j,Pn),p(e,$o,s),u(Re,e,s),p(e,Xo,s),p(e,se,s),t(se,Ln),t(se,Ct),t(Ct,Dn),t(se,Kn),p(e,Uo,s),u(Ce,e,s),p(e,jo,s),p(e,Ke,s),t(Ke,es),p(e,Zo,s),u(Be,e,s),p(e,Oo,s),p(e,E,s),t(E,ts),t(E,Bt),t(Bt,os),t(E,ls),t(E,Gt),t(Gt,ns),t(E,ss),t(E,It),t(It,as),t(E,rs),p(e,Wo,s),u(Ge,e,s),Ro=!0},p(e,[s]){const Ie={};s&2&&(Ie.$$scope={dirty:s,ctx:e}),oe.$set(Ie)},i(e){Ro||(b(N.$$.fragment,e),b(ie.$$.fragment,e),b(ue.$$.fragment,e),b(be.$$.fragment,e),b(ye.$$.fragment,e),b(ge.$$.fragment,e),b(ve.$$.fragment,e),b(Te.$$.fragment,e),b(_e.$$.fragment,e),b(Ee.$$.fragment,e),b(Je.$$.fragment,e),b($e.$$.fragment,e),b(Xe.$$.fragment,e),b(Ze.$$.fragment,e),b(oe.$$.fragment,e),b(Oe.$$.fragment,e),b(We.$$.fragment,e),b(Re.$$.fragment,e),b(Ce.$$.fragment,e),b(Be.$$.fragment,e),b(Ge.$$.fragment,e),Ro=!0)},o(e){w(N.$$.fragment,e),w(ie.$$.fragment,e),w(ue.$$.fragment,e),w(be.$$.fragment,e),w(ye.$$.fragment,e),w(ge.$$.fragment,e),w(ve.$$.fragment,e),w(Te.$$.fragment,e),w(_e.$$.fragment,e),w(Ee.$$.fragment,e),w(Je.$$.fragment,e),w($e.$$.fragment,e),w(Xe.$$.fragment,e),w(Ze.$$.fragment,e),w(oe.$$.fragment,e),w(Oe.$$.fragment,e),w(We.$$.fragment,e),w(Re.$$.fragment,e),w(Ce.$$.fragment,e),w(Be.$$.fragment,e),w(Ge.$$.fragment,e),Ro=!1},d(e){o(v),e&&o($),e&&o(M),y(N),e&&o(zt),e&&o(Ve),e&&o(At),e&&o(V),e&&o(St),e&&o(z),e&&o(Ht),e&&o(Z),y(ie),e&&o(Qt),e&&o(O),e&&o(Yt),e&&o(Ae),e&&o(qt),e&&o(Se),e&&o(Pt),e&&o(X),e&&o(Lt),e&&o(Qe),e&&o(Dt),e&&o(H),e&&o(Kt),e&&o(Ye),e&&o(eo),e&&o(Q),e&&o(to),e&&o(B),y(ue),e&&o(oo),e&&o(qe),e&&o(lo),y(be,e),e&&o(no),e&&o(q),e&&o(so),y(ye,e),e&&o(ao),e&&o(P),e&&o(ro),y(ge,e),e&&o(io),e&&o(L),e&&o(po),y(ve,e),e&&o(mo),e&&o(g),e&&o(co),y(Te,e),e&&o(fo),e&&o(k),e&&o(ho),y(_e,e),e&&o(uo),e&&o(D),e&&o(bo),y(Ee,e),e&&o(wo),e&&o(G),y(Je),e&&o(yo),e&&o(Le),e&&o(go),y($e,e),e&&o(vo),e&&o(I),y(Xe),e&&o(xo),e&&o(U),e&&o(To),e&&o(F),y(Ze),e&&o(Mo),y(oe,e),e&&o(No),e&&o(le),e&&o(_o),y(Oe,e),e&&o(ko),e&&o(ne),e&&o(Eo),y(We,e),e&&o(Jo),e&&o(j),e&&o($o),y(Re,e),e&&o(Xo),e&&o(se),e&&o(Uo),y(Ce,e),e&&o(jo),e&&o(Ke),e&&o(Zo),y(Be,e),e&&o(Oo),e&&o(E),e&&o(Wo),y(Ge,e)}}}const Ja={local:"export-to-onnx",sections:[{local:"export-to-onnx",sections:[{local:"exporting-a-transformers-model-to-onnx-with-cli",title:"Exporting a \u{1F917} Transformers model to ONNX with CLI"},{local:"exporting-a-transformers-model-to-onnx-with-optimumonnxruntime",title:"Exporting a \u{1F917} Transformers model to ONNX with `optimum.onnxruntime`"},{local:"exporting-a-model-for-an-unsupported-architecture",title:"Exporting a model for an unsupported architecture"},{local:"exporting-a-model-with-transformersonnx",title:"Exporting a model with `transformers.onnx`"}],title:"Export to ONNX "}],title:"Export to ONNX"};function $a(Vt){return Na(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class Oa extends va{constructor(v){super();xa(this,v,$a,Ea,Ta,{})}}export{Oa as default,Ja as metadata};
