import{s as In,o as zn,n as Fn}from"../chunks/scheduler.9bc65507.js";import{S as Ln,i as En,g as a,s,u as c,A as Sn,h as r,f as t,c as o,j as b,v as h,y as i,k as p,o as m,a as l,w as d,d as u,t as f,x as g}from"../chunks/index.78c82d43.js";import{T as On}from"../chunks/Tip.87d55b76.js";import{I as Re}from"../chunks/IconCopyLink.bedaa44d.js";import{C as y}from"../chunks/CodeBlock.73e038be.js";function Qn(Le){let w,W="<code>tranformers.onnx</code> is no longer maintained, please export models with 🤗 Optimum as described above. This section will be removed in the future versions.";return{c(){w=a("p"),w.innerHTML=W},l(x){w=r(x,"P",{"data-svelte-h":!0}),i(w)!=="svelte-1g5f3lj"&&(w.innerHTML=W)},m(x,je){l(x,w,je)},p:Fn,d(x){x&&t(w)}}}function Yn(Le){let w,W,x,je,M,k,Ge,R,Lt,_e,qt="Export to ONNX",Ee,G,At=`Deploying 🤗 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.`,Se,B,Pt=`🤗 Optimum is an extension of Transformers that enables exporting models from PyTorch or TensorFlow to serialized formats
such as ONNX and TFLite through its <code>exporters</code> module. 🤗 Optimum also provides a set of performance optimization tools to train
and run models on targeted hardware with maximum efficiency.`,Oe,V,Dt=`This guide demonstrates how you can export 🤗 Transformers models to ONNX with 🤗 Optimum, for the guide on exporting models to TFLite,
please refer to the <a href="tflite">Export to TFLite page</a>.`,Qe,T,j,Be,H,Et,Ue,Kt="Export to ONNX",Ye,I,en=`<a href="http://onnx.ai" rel="nofollow">ONNX (Open Neural Network eXchange)</a> 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 <em>intermediate representation</em>) which
represents the flow of data through the neural network.`,qe,z,tn=`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).`,Ae,F,nn="Once exported to ONNX format, a model can be:",Pe,L,ln=`<li>optimized for inference via techniques such as <a href="https://huggingface.co/docs/optimum/onnxruntime/usage_guides/optimization" rel="nofollow">graph optimization</a> and <a href="https://huggingface.co/docs/optimum/onnxruntime/usage_guides/quantization" rel="nofollow">quantization</a>.</li> <li>run with ONNX Runtime via <a href="https://huggingface.co/docs/optimum/onnxruntime/package_reference/modeling_ort" rel="nofollow"><code>ORTModelForXXX</code> classes</a>,
which follow the same <code>AutoModel</code> API as the one you are used to in 🤗 Transformers.</li> <li>run with <a href="https://huggingface.co/docs/optimum/main/en/onnxruntime/usage_guides/pipelines" rel="nofollow">optimized inference pipelines</a>,
which has the same API as the <a href="/docs/transformers/v4.34.0/en/main_classes/pipelines#transformers.pipeline">pipeline()</a> function in 🤗 Transformers.</li>`,De,E,sn=`🤗 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.`,Ke,S,on='For the list of ready-made configurations, please refer to <a href="https://huggingface.co/docs/optimum/exporters/onnx/overview" rel="nofollow">🤗 Optimum documentation</a>.',et,O,an="There are two ways to export a 🤗 Transformers model to ONNX, here we show both:",tt,Q,rn="<li>export with 🤗 Optimum via CLI.</li> <li>export with 🤗 Optimum with <code>optimum.onnxruntime</code>.</li>",nt,v,_,Ve,Y,St,Ce,pn="Exporting a 🤗 Transformers model to ONNX with CLI",lt,q,mn="To export a 🤗 Transformers model to ONNX, first install an extra dependency:",st,A,ot,P,cn=`To check out all available arguments, refer to the <a href="https://huggingface.co/docs/optimum/exporters/onnx/usage_guides/export_a_model#exporting-a-model-to-onnx-using-the-cli" rel="nofollow">🤗 Optimum docs</a>,
or view help in command line:`,at,D,rt,K,hn="To export a model’s checkpoint from the 🤗 Hub, for example, <code>distilbert-base-uncased-distilled-squad</code>, run the following command:",it,ee,pt,te,dn="You should see the logs indicating progress and showing where the resulting <code>model.onnx</code> is saved, like this:",mt,ne,ct,le,un=`The example above illustrates exporting a checkpoint from 🤗 Hub. When exporting a local model, first make sure that you
saved both the model’s weights and tokenizer files in the same directory (<code>local_path</code>). When using CLI, pass the
<code>local_path</code> to the <code>model</code> argument instead of the checkpoint name on 🤗 Hub and provide the <code>--task</code> argument.
You can review the list of supported tasks in the <a href="https://huggingface.co/docs/optimum/exporters/task_manager" rel="nofollow">🤗 Optimum documentation</a>.
If <code>task</code> argument is not provided, it will default to the model architecture without any task specific head.`,ht,se,dt,oe,fn=`The resulting <code>model.onnx</code> file can then be run on one of the <a href="https://onnx.ai/supported-tools.html#deployModel" rel="nofollow">many
accelerators</a> that support the ONNX
standard. For example, we can load and run the model with <a href="https://onnxruntime.ai/" rel="nofollow">ONNX
Runtime</a> as follows:`,ut,ae,ft,re,gn=`The process is identical for TensorFlow checkpoints on the Hub. For instance, here’s how you would
export a pure TensorFlow checkpoint from the <a href="https://huggingface.co/keras-io" rel="nofollow">Keras organization</a>:`,gt,ie,bt,J,U,He,pe,Ot,Xe,bn="Exporting a 🤗 Transformers model to ONNX with <code>optimum.onnxruntime</code>",wt,me,wn="Alternative to CLI, you can export a 🤗 Transformers model to ONNX programmatically like so:",yt,ce,xt,$,C,Ie,he,Qt,Ze,yn="Exporting a model for an unsupported architecture",Mt,de,xn=`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 <a href="https://huggingface.co/docs/optimum/exporters/onnx/overview" rel="nofollow"><code>optimum.exporters.onnx</code></a>,
and if it is not, <a href="https://huggingface.co/docs/optimum/exporters/onnx/usage_guides/contribute" rel="nofollow">contribute to 🤗 Optimum</a>
directly.`,Tt,N,X,ze,ue,Yt,We,Mn="Exporting a model with <code>transformers.onnx</code>",vt,Z,Jt,fe,Tn="To export a 🤗 Transformers model to ONNX with <code>tranformers.onnx</code>, install extra dependencies:",$t,ge,Nt,be,vn="Use <code>transformers.onnx</code> package as a Python module to export a checkpoint using a ready-made configuration:",kt,we,jt,ye,Jn=`This exports an ONNX graph of the checkpoint defined by the <code>--model</code> argument. Pass any checkpoint on the 🤗 Hub or one that’s stored locally.
The resulting <code>model.onnx</code> 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:`,_t,xe,Ut,Me,$n=`The required output names (like <code>[&quot;last_hidden_state&quot;]</code>) can be obtained by taking a look at the ONNX configuration of
each model. For example, for DistilBERT we have:`,Ct,Te,Xt,ve,Nn="The process is identical for TensorFlow checkpoints on the Hub. For example, export a pure TensorFlow checkpoint like so:",Zt,Je,Wt,$e,kn=`To export a model that’s stored locally, save the model’s weights and tokenizer files in the same directory (e.g. <code>local-pt-checkpoint</code>),
then export it to ONNX by pointing the <code>--model</code> argument of the <code>transformers.onnx</code> package to the desired directory:`,Rt,Ne,Gt,Fe,Bt;return R=new Re({}),H=new Re({}),Y=new Re({}),A=new y({props:{code:"cGlwJTIwaW5zdGFsbCUyMG9wdGltdW0lNUJleHBvcnRlcnMlNUQ=",highlighted:"pip install optimum[exporters]",wrap:!1}}),D=new y({props:{code:"b3B0aW11bS1jbGklMjBleHBvcnQlMjBvbm54JTIwLS1oZWxw",highlighted:'optimum-cli <span class="hljs-built_in">export</span> onnx --<span class="hljs-built_in">help</span>',wrap:!1}}),ee=new y({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/',wrap:!1}}),ne=new y({props:{code:"VmFsaWRhdGluZyUyME9OTlglMjBtb2RlbCUyMGRpc3RpbGJlcnRfYmFzZV91bmNhc2VkX3NxdWFkX29ubnglMkZtb2RlbC5vbm54Li4uJTBBJTA5LSU1QiVFMiU5QyU5MyU1RCUyME9OTlglMjBtb2RlbCUyMG91dHB1dCUyMG5hbWVzJTIwbWF0Y2glMjByZWZlcmVuY2UlMjBtb2RlbCUyMChzdGFydF9sb2dpdHMlMkMlMjBlbmRfbG9naXRzKSUwQSUwOS0lMjBWYWxpZGF0aW5nJTIwT05OWCUyME1vZGVsJTIwb3V0cHV0JTIwJTIyc3RhcnRfbG9naXRzJTIyJTNBJTBBJTA5JTA5LSU1QiVFMiU5QyU5MyU1RCUyMCgyJTJDJTIwMTYpJTIwbWF0Y2hlcyUyMCgyJTJDJTIwMTYpJTBBJTA5JTA5LSU1QiVFMiU5QyU5MyU1RCUyMGFsbCUyMHZhbHVlcyUyMGNsb3NlJTIwKGF0b2wlM0ElMjAwLjAwMDEpJTBBJTA5LSUyMFZhbGlkYXRpbmclMjBPTk5YJTIwTW9kZWwlMjBvdXRwdXQlMjAlMjJlbmRfbG9naXRzJTIyJTNBJTBBJTA5JTA5LSU1QiVFMiU5QyU5MyU1RCUyMCgyJTJDJTIwMTYpJTIwbWF0Y2hlcyUyMCgyJTJDJTIwMTYpJTBBJTA5JTA5LSU1QiVFMiU5QyU5MyU1RCUyMGFsbCUyMHZhbHVlcyUyMGNsb3NlJTIwKGF0b2wlM0ElMjAwLjAwMDEpJTBBVGhlJTIwT05OWCUyMGV4cG9ydCUyMHN1Y2NlZWRlZCUyMGFuZCUyMHRoZSUyMGV4cG9ydGVkJTIwbW9kZWwlMjB3YXMlMjBzYXZlZCUyMGF0JTNBJTIwZGlzdGlsYmVydF9iYXNlX3VuY2FzZWRfc3F1YWRfb25ueA==",highlighted:`Validating ONNX model distilbert_base_uncased_squad_onnx/model.onnx...
	-[✓] ONNX model output names match reference model (start_logits, end_logits)
	- Validating ONNX Model output <span class="hljs-string">&quot;start_logits&quot;</span>:
		-[✓] (2, 16) matches (2, 16)
		-[✓] all values close (atol: 0.0001)
	- Validating ONNX Model output <span class="hljs-string">&quot;end_logits&quot;</span>:
		-[✓] (2, 16) matches (2, 16)
		-[✓] 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`,wrap:!1}}),se=new y({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/',wrap:!1}}),ae=new y({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)`,wrap:!1}}),ie=new y({props:{code:"b3B0aW11bS1jbGklMjBleHBvcnQlMjBvbm54JTIwLS1tb2RlbCUyMGtlcmFzLWlvJTJGdHJhbnNmb3JtZXJzLXFhJTIwZGlzdGlsYmVydF9iYXNlX2Nhc2VkX3NxdWFkX29ubnglMkY=",highlighted:'optimum-cli <span class="hljs-built_in">export</span> onnx --model keras-io/transformers-qa distilbert_base_cased_squad_onnx/',wrap:!1}}),pe=new Re({}),ce=new y({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)`,wrap:!1}}),he=new Re({}),ue=new Re({}),Z=new On({props:{warning:!0,$$slots:{default:[Qn]},$$scope:{ctx:Le}}}),ge=new y({props:{code:"cGlwJTIwaW5zdGFsbCUyMHRyYW5zZm9ybWVycyU1Qm9ubnglNUQ=",highlighted:"pip install transformers[onnx]",wrap:!1}}),we=new y({props:{code:"cHl0aG9uJTIwLW0lMjB0cmFuc2Zvcm1lcnMub25ueCUyMC0tbW9kZWwlM0RkaXN0aWxiZXJ0LWJhc2UtdW5jYXNlZCUyMG9ubnglMkY=",highlighted:"python -m transformers.onnx --model=distilbert-base-uncased onnx/",wrap:!1}}),xe=new y({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))`,wrap:!1}}),Te=new y({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>]`,wrap:!1}}),Je=new y({props:{code:"cHl0aG9uJTIwLW0lMjB0cmFuc2Zvcm1lcnMub25ueCUyMC0tbW9kZWwlM0RrZXJhcy1pbyUyRnRyYW5zZm9ybWVycy1xYSUyMG9ubnglMkY=",highlighted:"python -m transformers.onnx --model=keras-io/transformers-qa onnx/",wrap:!1}}),Ne=new y({props:{code:"cHl0aG9uJTIwLW0lMjB0cmFuc2Zvcm1lcnMub25ueCUyMC0tbW9kZWwlM0Rsb2NhbC1wdC1jaGVja3BvaW50JTIwb25ueCUyRg==",highlighted:"python -m transformers.onnx --model=local-pt-checkpoint onnx/",wrap:!1}}),{c(){w=a("meta"),W=s(),x=a("p"),je=s(),M=a("h1"),k=a("a"),Ge=a("span"),c(R.$$.fragment),Lt=s(),_e=a("span"),_e.textContent=qt,Ee=s(),G=a("p"),G.textContent=At,Se=s(),B=a("p"),B.innerHTML=Pt,Oe=s(),V=a("p"),V.innerHTML=Dt,Qe=s(),T=a("h2"),j=a("a"),Be=a("span"),c(H.$$.fragment),Et=s(),Ue=a("span"),Ue.textContent=Kt,Ye=s(),I=a("p"),I.innerHTML=en,qe=s(),z=a("p"),z.textContent=tn,Ae=s(),F=a("p"),F.textContent=nn,Pe=s(),L=a("ul"),L.innerHTML=ln,De=s(),E=a("p"),E.textContent=sn,Ke=s(),S=a("p"),S.innerHTML=on,et=s(),O=a("p"),O.textContent=an,tt=s(),Q=a("ul"),Q.innerHTML=rn,nt=s(),v=a("h3"),_=a("a"),Ve=a("span"),c(Y.$$.fragment),St=s(),Ce=a("span"),Ce.textContent=pn,lt=s(),q=a("p"),q.textContent=mn,st=s(),c(A.$$.fragment),ot=s(),P=a("p"),P.innerHTML=cn,at=s(),c(D.$$.fragment),rt=s(),K=a("p"),K.innerHTML=hn,it=s(),c(ee.$$.fragment),pt=s(),te=a("p"),te.innerHTML=dn,mt=s(),c(ne.$$.fragment),ct=s(),le=a("p"),le.innerHTML=un,ht=s(),c(se.$$.fragment),dt=s(),oe=a("p"),oe.innerHTML=fn,ut=s(),c(ae.$$.fragment),ft=s(),re=a("p"),re.innerHTML=gn,gt=s(),c(ie.$$.fragment),bt=s(),J=a("h3"),U=a("a"),He=a("span"),c(pe.$$.fragment),Ot=s(),Xe=a("span"),Xe.innerHTML=bn,wt=s(),me=a("p"),me.textContent=wn,yt=s(),c(ce.$$.fragment),xt=s(),$=a("h3"),C=a("a"),Ie=a("span"),c(he.$$.fragment),Qt=s(),Ze=a("span"),Ze.textContent=yn,Mt=s(),de=a("p"),de.innerHTML=xn,Tt=s(),N=a("h3"),X=a("a"),ze=a("span"),c(ue.$$.fragment),Yt=s(),We=a("span"),We.innerHTML=Mn,vt=s(),c(Z.$$.fragment),Jt=s(),fe=a("p"),fe.innerHTML=Tn,$t=s(),c(ge.$$.fragment),Nt=s(),be=a("p"),be.innerHTML=vn,kt=s(),c(we.$$.fragment),jt=s(),ye=a("p"),ye.innerHTML=Jn,_t=s(),c(xe.$$.fragment),Ut=s(),Me=a("p"),Me.innerHTML=$n,Ct=s(),c(Te.$$.fragment),Xt=s(),ve=a("p"),ve.textContent=Nn,Zt=s(),c(Je.$$.fragment),Wt=s(),$e=a("p"),$e.innerHTML=kn,Rt=s(),c(Ne.$$.fragment),Gt=s(),Fe=a("p"),this.h()},l(e){const n=Sn("svelte-1phssyn",document.head);w=r(n,"META",{name:!0,content:!0}),n.forEach(t),W=o(e),x=r(e,"P",{}),b(x).forEach(t),je=o(e),M=r(e,"H1",{class:!0});var ke=b(M);k=r(ke,"A",{id:!0,class:!0,href:!0});var jn=b(k);Ge=r(jn,"SPAN",{});var _n=b(Ge);h(R.$$.fragment,_n),_n.forEach(t),jn.forEach(t),Lt=o(ke),_e=r(ke,"SPAN",{"data-svelte-h":!0}),i(_e)!=="svelte-16yuitj"&&(_e.textContent=qt),ke.forEach(t),Ee=o(e),G=r(e,"P",{"data-svelte-h":!0}),i(G)!=="svelte-lfqtzw"&&(G.textContent=At),Se=o(e),B=r(e,"P",{"data-svelte-h":!0}),i(B)!=="svelte-12k3xi1"&&(B.innerHTML=Pt),Oe=o(e),V=r(e,"P",{"data-svelte-h":!0}),i(V)!=="svelte-7b8cpg"&&(V.innerHTML=Dt),Qe=o(e),T=r(e,"H2",{class:!0});var Vt=b(T);j=r(Vt,"A",{id:!0,class:!0,href:!0});var Un=b(j);Be=r(Un,"SPAN",{});var Cn=b(Be);h(H.$$.fragment,Cn),Cn.forEach(t),Un.forEach(t),Et=o(Vt),Ue=r(Vt,"SPAN",{"data-svelte-h":!0}),i(Ue)!=="svelte-6oanjt"&&(Ue.textContent=Kt),Vt.forEach(t),Ye=o(e),I=r(e,"P",{"data-svelte-h":!0}),i(I)!=="svelte-8enoc5"&&(I.innerHTML=en),qe=o(e),z=r(e,"P",{"data-svelte-h":!0}),i(z)!=="svelte-wn4m59"&&(z.textContent=tn),Ae=o(e),F=r(e,"P",{"data-svelte-h":!0}),i(F)!=="svelte-148fbt4"&&(F.textContent=nn),Pe=o(e),L=r(e,"UL",{"data-svelte-h":!0}),i(L)!=="svelte-10dsoii"&&(L.innerHTML=ln),De=o(e),E=r(e,"P",{"data-svelte-h":!0}),i(E)!=="svelte-tylo0u"&&(E.textContent=sn),Ke=o(e),S=r(e,"P",{"data-svelte-h":!0}),i(S)!=="svelte-r6gv1"&&(S.innerHTML=on),et=o(e),O=r(e,"P",{"data-svelte-h":!0}),i(O)!=="svelte-ksmizg"&&(O.textContent=an),tt=o(e),Q=r(e,"UL",{"data-svelte-h":!0}),i(Q)!=="svelte-18tahix"&&(Q.innerHTML=rn),nt=o(e),v=r(e,"H3",{class:!0});var Ht=b(v);_=r(Ht,"A",{id:!0,class:!0,href:!0});var Xn=b(_);Ve=r(Xn,"SPAN",{});var Zn=b(Ve);h(Y.$$.fragment,Zn),Zn.forEach(t),Xn.forEach(t),St=o(Ht),Ce=r(Ht,"SPAN",{"data-svelte-h":!0}),i(Ce)!=="svelte-1pqpogi"&&(Ce.textContent=pn),Ht.forEach(t),lt=o(e),q=r(e,"P",{"data-svelte-h":!0}),i(q)!=="svelte-1sf999h"&&(q.textContent=mn),st=o(e),h(A.$$.fragment,e),ot=o(e),P=r(e,"P",{"data-svelte-h":!0}),i(P)!=="svelte-lc1loi"&&(P.innerHTML=cn),at=o(e),h(D.$$.fragment,e),rt=o(e),K=r(e,"P",{"data-svelte-h":!0}),i(K)!=="svelte-1jzuy1q"&&(K.innerHTML=hn),it=o(e),h(ee.$$.fragment,e),pt=o(e),te=r(e,"P",{"data-svelte-h":!0}),i(te)!=="svelte-1fffsri"&&(te.innerHTML=dn),mt=o(e),h(ne.$$.fragment,e),ct=o(e),le=r(e,"P",{"data-svelte-h":!0}),i(le)!=="svelte-1n3pmj5"&&(le.innerHTML=un),ht=o(e),h(se.$$.fragment,e),dt=o(e),oe=r(e,"P",{"data-svelte-h":!0}),i(oe)!=="svelte-1dzbxfz"&&(oe.innerHTML=fn),ut=o(e),h(ae.$$.fragment,e),ft=o(e),re=r(e,"P",{"data-svelte-h":!0}),i(re)!=="svelte-zdo0u7"&&(re.innerHTML=gn),gt=o(e),h(ie.$$.fragment,e),bt=o(e),J=r(e,"H3",{class:!0});var It=b(J);U=r(It,"A",{id:!0,class:!0,href:!0});var Wn=b(U);He=r(Wn,"SPAN",{});var Rn=b(He);h(pe.$$.fragment,Rn),Rn.forEach(t),Wn.forEach(t),Ot=o(It),Xe=r(It,"SPAN",{"data-svelte-h":!0}),i(Xe)!=="svelte-ylxtcj"&&(Xe.innerHTML=bn),It.forEach(t),wt=o(e),me=r(e,"P",{"data-svelte-h":!0}),i(me)!=="svelte-1doea45"&&(me.textContent=wn),yt=o(e),h(ce.$$.fragment,e),xt=o(e),$=r(e,"H3",{class:!0});var zt=b($);C=r(zt,"A",{id:!0,class:!0,href:!0});var Gn=b(C);Ie=r(Gn,"SPAN",{});var Bn=b(Ie);h(he.$$.fragment,Bn),Bn.forEach(t),Gn.forEach(t),Qt=o(zt),Ze=r(zt,"SPAN",{"data-svelte-h":!0}),i(Ze)!=="svelte-nxhb0z"&&(Ze.textContent=yn),zt.forEach(t),Mt=o(e),de=r(e,"P",{"data-svelte-h":!0}),i(de)!=="svelte-6bg99r"&&(de.innerHTML=xn),Tt=o(e),N=r(e,"H3",{class:!0});var Ft=b(N);X=r(Ft,"A",{id:!0,class:!0,href:!0});var Vn=b(X);ze=r(Vn,"SPAN",{});var Hn=b(ze);h(ue.$$.fragment,Hn),Hn.forEach(t),Vn.forEach(t),Yt=o(Ft),We=r(Ft,"SPAN",{"data-svelte-h":!0}),i(We)!=="svelte-1exih8b"&&(We.innerHTML=Mn),Ft.forEach(t),vt=o(e),h(Z.$$.fragment,e),Jt=o(e),fe=r(e,"P",{"data-svelte-h":!0}),i(fe)!=="svelte-pabw4f"&&(fe.innerHTML=Tn),$t=o(e),h(ge.$$.fragment,e),Nt=o(e),be=r(e,"P",{"data-svelte-h":!0}),i(be)!=="svelte-1hq77cg"&&(be.innerHTML=vn),kt=o(e),h(we.$$.fragment,e),jt=o(e),ye=r(e,"P",{"data-svelte-h":!0}),i(ye)!=="svelte-tj8y7s"&&(ye.innerHTML=Jn),_t=o(e),h(xe.$$.fragment,e),Ut=o(e),Me=r(e,"P",{"data-svelte-h":!0}),i(Me)!=="svelte-8brdq3"&&(Me.innerHTML=$n),Ct=o(e),h(Te.$$.fragment,e),Xt=o(e),ve=r(e,"P",{"data-svelte-h":!0}),i(ve)!=="svelte-9ykkz3"&&(ve.textContent=Nn),Zt=o(e),h(Je.$$.fragment,e),Wt=o(e),$e=r(e,"P",{"data-svelte-h":!0}),i($e)!=="svelte-1trh1mg"&&($e.innerHTML=kn),Rt=o(e),h(Ne.$$.fragment,e),Gt=o(e),Fe=r(e,"P",{}),b(Fe).forEach(t),this.h()},h(){p(w,"name","hf:doc:metadata"),p(w,"content",JSON.stringify(qn)),p(k,"id","export-to-onnx"),p(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"),p(k,"href","#export-to-onnx"),p(M,"class","relative group"),p(j,"id","export-to-onnx"),p(j,"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"),p(j,"href","#export-to-onnx"),p(T,"class","relative group"),p(_,"id","exporting-a-transformers-model-to-onnx-with-cli"),p(_,"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"),p(_,"href","#exporting-a-transformers-model-to-onnx-with-cli"),p(v,"class","relative group"),p(U,"id","exporting-a-transformers-model-to-onnx-with-optimumonnxruntime"),p(U,"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"),p(U,"href","#exporting-a-transformers-model-to-onnx-with-optimumonnxruntime"),p(J,"class","relative group"),p(C,"id","exporting-a-model-for-an-unsupported-architecture"),p(C,"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"),p(C,"href","#exporting-a-model-for-an-unsupported-architecture"),p($,"class","relative group"),p(X,"id","exporting-a-model-with-transformersonnx"),p(X,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),p(X,"href","#exporting-a-model-with-transformersonnx"),p(N,"class","relative group")},m(e,n){m(document.head,w),l(e,W,n),l(e,x,n),l(e,je,n),l(e,M,n),m(M,k),m(k,Ge),d(R,Ge,null),m(M,Lt),m(M,_e),l(e,Ee,n),l(e,G,n),l(e,Se,n),l(e,B,n),l(e,Oe,n),l(e,V,n),l(e,Qe,n),l(e,T,n),m(T,j),m(j,Be),d(H,Be,null),m(T,Et),m(T,Ue),l(e,Ye,n),l(e,I,n),l(e,qe,n),l(e,z,n),l(e,Ae,n),l(e,F,n),l(e,Pe,n),l(e,L,n),l(e,De,n),l(e,E,n),l(e,Ke,n),l(e,S,n),l(e,et,n),l(e,O,n),l(e,tt,n),l(e,Q,n),l(e,nt,n),l(e,v,n),m(v,_),m(_,Ve),d(Y,Ve,null),m(v,St),m(v,Ce),l(e,lt,n),l(e,q,n),l(e,st,n),d(A,e,n),l(e,ot,n),l(e,P,n),l(e,at,n),d(D,e,n),l(e,rt,n),l(e,K,n),l(e,it,n),d(ee,e,n),l(e,pt,n),l(e,te,n),l(e,mt,n),d(ne,e,n),l(e,ct,n),l(e,le,n),l(e,ht,n),d(se,e,n),l(e,dt,n),l(e,oe,n),l(e,ut,n),d(ae,e,n),l(e,ft,n),l(e,re,n),l(e,gt,n),d(ie,e,n),l(e,bt,n),l(e,J,n),m(J,U),m(U,He),d(pe,He,null),m(J,Ot),m(J,Xe),l(e,wt,n),l(e,me,n),l(e,yt,n),d(ce,e,n),l(e,xt,n),l(e,$,n),m($,C),m(C,Ie),d(he,Ie,null),m($,Qt),m($,Ze),l(e,Mt,n),l(e,de,n),l(e,Tt,n),l(e,N,n),m(N,X),m(X,ze),d(ue,ze,null),m(N,Yt),m(N,We),l(e,vt,n),d(Z,e,n),l(e,Jt,n),l(e,fe,n),l(e,$t,n),d(ge,e,n),l(e,Nt,n),l(e,be,n),l(e,kt,n),d(we,e,n),l(e,jt,n),l(e,ye,n),l(e,_t,n),d(xe,e,n),l(e,Ut,n),l(e,Me,n),l(e,Ct,n),d(Te,e,n),l(e,Xt,n),l(e,ve,n),l(e,Zt,n),d(Je,e,n),l(e,Wt,n),l(e,$e,n),l(e,Rt,n),d(Ne,e,n),l(e,Gt,n),l(e,Fe,n),Bt=!0},p(e,[n]){const ke={};n&2&&(ke.$$scope={dirty:n,ctx:e}),Z.$set(ke)},i(e){Bt||(u(R.$$.fragment,e),u(H.$$.fragment,e),u(Y.$$.fragment,e),u(A.$$.fragment,e),u(D.$$.fragment,e),u(ee.$$.fragment,e),u(ne.$$.fragment,e),u(se.$$.fragment,e),u(ae.$$.fragment,e),u(ie.$$.fragment,e),u(pe.$$.fragment,e),u(ce.$$.fragment,e),u(he.$$.fragment,e),u(ue.$$.fragment,e),u(Z.$$.fragment,e),u(ge.$$.fragment,e),u(we.$$.fragment,e),u(xe.$$.fragment,e),u(Te.$$.fragment,e),u(Je.$$.fragment,e),u(Ne.$$.fragment,e),Bt=!0)},o(e){f(R.$$.fragment,e),f(H.$$.fragment,e),f(Y.$$.fragment,e),f(A.$$.fragment,e),f(D.$$.fragment,e),f(ee.$$.fragment,e),f(ne.$$.fragment,e),f(se.$$.fragment,e),f(ae.$$.fragment,e),f(ie.$$.fragment,e),f(pe.$$.fragment,e),f(ce.$$.fragment,e),f(he.$$.fragment,e),f(ue.$$.fragment,e),f(Z.$$.fragment,e),f(ge.$$.fragment,e),f(we.$$.fragment,e),f(xe.$$.fragment,e),f(Te.$$.fragment,e),f(Je.$$.fragment,e),f(Ne.$$.fragment,e),Bt=!1},d(e){e&&(t(W),t(x),t(je),t(M),t(Ee),t(G),t(Se),t(B),t(Oe),t(V),t(Qe),t(T),t(Ye),t(I),t(qe),t(z),t(Ae),t(F),t(Pe),t(L),t(De),t(E),t(Ke),t(S),t(et),t(O),t(tt),t(Q),t(nt),t(v),t(lt),t(q),t(st),t(ot),t(P),t(at),t(rt),t(K),t(it),t(pt),t(te),t(mt),t(ct),t(le),t(ht),t(dt),t(oe),t(ut),t(ft),t(re),t(gt),t(bt),t(J),t(wt),t(me),t(yt),t(xt),t($),t(Mt),t(de),t(Tt),t(N),t(vt),t(Jt),t(fe),t($t),t(Nt),t(be),t(kt),t(jt),t(ye),t(_t),t(Ut),t(Me),t(Ct),t(Xt),t(ve),t(Zt),t(Wt),t($e),t(Rt),t(Gt),t(Fe)),t(w),g(R),g(H),g(Y),g(A,e),g(D,e),g(ee,e),g(ne,e),g(se,e),g(ae,e),g(ie,e),g(pe),g(ce,e),g(he),g(ue),g(Z,e),g(ge,e),g(we,e),g(xe,e),g(Te,e),g(Je,e),g(Ne,e)}}}const qn={local:"export-to-onnx",sections:[{local:"export-to-onnx",sections:[{local:"exporting-a-transformers-model-to-onnx-with-cli",title:"Exporting a 🤗 Transformers model to ONNX with CLI"},{local:"exporting-a-transformers-model-to-onnx-with-optimumonnxruntime",title:"Exporting a 🤗 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 An(Le){return zn(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class nl extends Ln{constructor(w){super(),En(this,w,An,Yn,In,{})}}export{nl as component};
