import{s as Ht,o as zt,n as It}from"../chunks/scheduler.9bc65507.js";import{S as Ft,i as Lt,g as a,s,r as p,A as Qt,h as i,f as n,c as o,j as Bt,u as m,x as r,k as Vt,y as Ot,a as l,v as d,d as c,t as u,w as f}from"../chunks/index.707bf1b6.js";import{T as Yt}from"../chunks/Tip.c2ecdbf4.js";import{C as g}from"../chunks/CodeBlock.54a9f38d.js";import{H as ue}from"../chunks/Heading.342b1fa6.js";function Et(he){let h,M="<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(){h=a("p"),h.innerHTML=M},l(b){h=i(b,"P",{"data-svelte-h":!0}),r(h)!=="svelte-1g5f3lj"&&(h.innerHTML=M)},m(b,ce){l(b,h,ce)},p:It,d(b){b&&n(h)}}}function qt(he){let h,M,b,ce,w,ge,T,mt=`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.`,be,x,dt=`🤗 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.`,ye,$,ct=`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>.`,Me,J,we,j,ut=`<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.`,Te,U,ft=`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).`,xe,v,ht="Once exported to ONNX format, a model can be:",$e,N,gt=`<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/main/en/main_classes/pipelines#transformers.pipeline">pipeline()</a> function in 🤗 Transformers.</li>`,Je,X,bt=`🤗 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.`,je,k,yt='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>.',Ue,Z,Mt="There are two ways to export a 🤗 Transformers model to ONNX, here we show both:",ve,C,wt="<li>export with 🤗 Optimum via CLI.</li> <li>export with 🤗 Optimum with <code>optimum.onnxruntime</code>.</li>",Ne,_,Xe,W,Tt="To export a 🤗 Transformers model to ONNX, first install an extra dependency:",ke,R,Ze,G,xt=`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:`,Ce,B,_e,V,$t="To export a model’s checkpoint from the 🤗 Hub, for example, <code>distilbert-base-uncased-distilled-squad</code>, run the following command:",We,H,Re,z,Jt="You should see the logs indicating progress and showing where the resulting <code>model.onnx</code> is saved, like this:",Ge,I,Be,F,jt=`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.`,Ve,L,He,Q,Ut=`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:`,ze,O,Ie,Y,vt=`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>:`,Fe,E,Le,q,Qe,S,Nt="Alternative to CLI, you can export a 🤗 Transformers model to ONNX programmatically like so:",Oe,P,Ye,A,Ee,D,Xt=`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.`,qe,K,Se,y,Pe,ee,kt="To export a 🤗 Transformers model to ONNX with <code>tranformers.onnx</code>, install extra dependencies:",Ae,te,De,ne,Zt="Use <code>transformers.onnx</code> package as a Python module to export a checkpoint using a ready-made configuration:",Ke,le,et,se,Ct=`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:`,tt,oe,nt,ae,_t=`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:`,lt,ie,st,re,Wt="The process is identical for TensorFlow checkpoints on the Hub. For example, export a pure TensorFlow checkpoint like so:",ot,pe,at,me,Rt=`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:`,it,de,rt,fe,pt;return w=new ue({props:{title:"Export to ONNX",local:"export-to-onnx",headingTag:"h1"}}),J=new ue({props:{title:"Export to ONNX",local:"export-to-onnx",headingTag:"h2"}}),_=new ue({props:{title:"Exporting a 🤗 Transformers model to ONNX with CLI",local:"exporting-a--transformers-model-to-onnx-with-cli",headingTag:"h3"}}),R=new g({props:{code:"cGlwJTIwaW5zdGFsbCUyMG9wdGltdW0lNUJleHBvcnRlcnMlNUQ=",highlighted:"pip install optimum[exporters]",wrap:!1}}),B=new g({props:{code:"b3B0aW11bS1jbGklMjBleHBvcnQlMjBvbm54JTIwLS1oZWxw",highlighted:'optimum-cli <span class="hljs-built_in">export</span> onnx --<span class="hljs-built_in">help</span>',wrap:!1}}),H=new g({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}}),I=new g({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}}),L=new g({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}}),O=new g({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}}),E=new g({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}}),q=new ue({props:{title:"Exporting a 🤗 Transformers model to ONNX with optimum.onnxruntime",local:"exporting-a--transformers-model-to-onnx-with-optimumonnxruntime",headingTag:"h3"}}),P=new g({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}}),A=new ue({props:{title:"Exporting a model for an unsupported architecture",local:"exporting-a-model-for-an-unsupported-architecture",headingTag:"h3"}}),K=new ue({props:{title:"Exporting a model with transformers.onnx",local:"exporting-a-model-with-transformersonnx",headingTag:"h3"}}),y=new Yt({props:{warning:!0,$$slots:{default:[Et]},$$scope:{ctx:he}}}),te=new g({props:{code:"cGlwJTIwaW5zdGFsbCUyMHRyYW5zZm9ybWVycyU1Qm9ubnglNUQ=",highlighted:"pip install transformers[onnx]",wrap:!1}}),le=new g({props:{code:"cHl0aG9uJTIwLW0lMjB0cmFuc2Zvcm1lcnMub25ueCUyMC0tbW9kZWwlM0RkaXN0aWxiZXJ0LWJhc2UtdW5jYXNlZCUyMG9ubnglMkY=",highlighted:"python -m transformers.onnx --model=distilbert-base-uncased onnx/",wrap:!1}}),oe=new g({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}}),ie=new g({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}}),pe=new g({props:{code:"cHl0aG9uJTIwLW0lMjB0cmFuc2Zvcm1lcnMub25ueCUyMC0tbW9kZWwlM0RrZXJhcy1pbyUyRnRyYW5zZm9ybWVycy1xYSUyMG9ubnglMkY=",highlighted:"python -m transformers.onnx --model=keras-io/transformers-qa onnx/",wrap:!1}}),de=new g({props:{code:"cHl0aG9uJTIwLW0lMjB0cmFuc2Zvcm1lcnMub25ueCUyMC0tbW9kZWwlM0Rsb2NhbC1wdC1jaGVja3BvaW50JTIwb25ueCUyRg==",highlighted:"python -m transformers.onnx --model=local-pt-checkpoint onnx/",wrap:!1}}),{c(){h=a("meta"),M=s(),b=a("p"),ce=s(),p(w.$$.fragment),ge=s(),T=a("p"),T.textContent=mt,be=s(),x=a("p"),x.innerHTML=dt,ye=s(),$=a("p"),$.innerHTML=ct,Me=s(),p(J.$$.fragment),we=s(),j=a("p"),j.innerHTML=ut,Te=s(),U=a("p"),U.textContent=ft,xe=s(),v=a("p"),v.textContent=ht,$e=s(),N=a("ul"),N.innerHTML=gt,Je=s(),X=a("p"),X.textContent=bt,je=s(),k=a("p"),k.innerHTML=yt,Ue=s(),Z=a("p"),Z.textContent=Mt,ve=s(),C=a("ul"),C.innerHTML=wt,Ne=s(),p(_.$$.fragment),Xe=s(),W=a("p"),W.textContent=Tt,ke=s(),p(R.$$.fragment),Ze=s(),G=a("p"),G.innerHTML=xt,Ce=s(),p(B.$$.fragment),_e=s(),V=a("p"),V.innerHTML=$t,We=s(),p(H.$$.fragment),Re=s(),z=a("p"),z.innerHTML=Jt,Ge=s(),p(I.$$.fragment),Be=s(),F=a("p"),F.innerHTML=jt,Ve=s(),p(L.$$.fragment),He=s(),Q=a("p"),Q.innerHTML=Ut,ze=s(),p(O.$$.fragment),Ie=s(),Y=a("p"),Y.innerHTML=vt,Fe=s(),p(E.$$.fragment),Le=s(),p(q.$$.fragment),Qe=s(),S=a("p"),S.textContent=Nt,Oe=s(),p(P.$$.fragment),Ye=s(),p(A.$$.fragment),Ee=s(),D=a("p"),D.innerHTML=Xt,qe=s(),p(K.$$.fragment),Se=s(),p(y.$$.fragment),Pe=s(),ee=a("p"),ee.innerHTML=kt,Ae=s(),p(te.$$.fragment),De=s(),ne=a("p"),ne.innerHTML=Zt,Ke=s(),p(le.$$.fragment),et=s(),se=a("p"),se.innerHTML=Ct,tt=s(),p(oe.$$.fragment),nt=s(),ae=a("p"),ae.innerHTML=_t,lt=s(),p(ie.$$.fragment),st=s(),re=a("p"),re.textContent=Wt,ot=s(),p(pe.$$.fragment),at=s(),me=a("p"),me.innerHTML=Rt,it=s(),p(de.$$.fragment),rt=s(),fe=a("p"),this.h()},l(e){const t=Qt("svelte-u9bgzb",document.head);h=i(t,"META",{name:!0,content:!0}),t.forEach(n),M=o(e),b=i(e,"P",{}),Bt(b).forEach(n),ce=o(e),m(w.$$.fragment,e),ge=o(e),T=i(e,"P",{"data-svelte-h":!0}),r(T)!=="svelte-lfqtzw"&&(T.textContent=mt),be=o(e),x=i(e,"P",{"data-svelte-h":!0}),r(x)!=="svelte-12k3xi1"&&(x.innerHTML=dt),ye=o(e),$=i(e,"P",{"data-svelte-h":!0}),r($)!=="svelte-7b8cpg"&&($.innerHTML=ct),Me=o(e),m(J.$$.fragment,e),we=o(e),j=i(e,"P",{"data-svelte-h":!0}),r(j)!=="svelte-8enoc5"&&(j.innerHTML=ut),Te=o(e),U=i(e,"P",{"data-svelte-h":!0}),r(U)!=="svelte-wn4m59"&&(U.textContent=ft),xe=o(e),v=i(e,"P",{"data-svelte-h":!0}),r(v)!=="svelte-148fbt4"&&(v.textContent=ht),$e=o(e),N=i(e,"UL",{"data-svelte-h":!0}),r(N)!=="svelte-1y26evw"&&(N.innerHTML=gt),Je=o(e),X=i(e,"P",{"data-svelte-h":!0}),r(X)!=="svelte-tylo0u"&&(X.textContent=bt),je=o(e),k=i(e,"P",{"data-svelte-h":!0}),r(k)!=="svelte-r6gv1"&&(k.innerHTML=yt),Ue=o(e),Z=i(e,"P",{"data-svelte-h":!0}),r(Z)!=="svelte-ksmizg"&&(Z.textContent=Mt),ve=o(e),C=i(e,"UL",{"data-svelte-h":!0}),r(C)!=="svelte-18tahix"&&(C.innerHTML=wt),Ne=o(e),m(_.$$.fragment,e),Xe=o(e),W=i(e,"P",{"data-svelte-h":!0}),r(W)!=="svelte-1sf999h"&&(W.textContent=Tt),ke=o(e),m(R.$$.fragment,e),Ze=o(e),G=i(e,"P",{"data-svelte-h":!0}),r(G)!=="svelte-lc1loi"&&(G.innerHTML=xt),Ce=o(e),m(B.$$.fragment,e),_e=o(e),V=i(e,"P",{"data-svelte-h":!0}),r(V)!=="svelte-1jzuy1q"&&(V.innerHTML=$t),We=o(e),m(H.$$.fragment,e),Re=o(e),z=i(e,"P",{"data-svelte-h":!0}),r(z)!=="svelte-1fffsri"&&(z.innerHTML=Jt),Ge=o(e),m(I.$$.fragment,e),Be=o(e),F=i(e,"P",{"data-svelte-h":!0}),r(F)!=="svelte-1n3pmj5"&&(F.innerHTML=jt),Ve=o(e),m(L.$$.fragment,e),He=o(e),Q=i(e,"P",{"data-svelte-h":!0}),r(Q)!=="svelte-1dzbxfz"&&(Q.innerHTML=Ut),ze=o(e),m(O.$$.fragment,e),Ie=o(e),Y=i(e,"P",{"data-svelte-h":!0}),r(Y)!=="svelte-zdo0u7"&&(Y.innerHTML=vt),Fe=o(e),m(E.$$.fragment,e),Le=o(e),m(q.$$.fragment,e),Qe=o(e),S=i(e,"P",{"data-svelte-h":!0}),r(S)!=="svelte-1doea45"&&(S.textContent=Nt),Oe=o(e),m(P.$$.fragment,e),Ye=o(e),m(A.$$.fragment,e),Ee=o(e),D=i(e,"P",{"data-svelte-h":!0}),r(D)!=="svelte-6bg99r"&&(D.innerHTML=Xt),qe=o(e),m(K.$$.fragment,e),Se=o(e),m(y.$$.fragment,e),Pe=o(e),ee=i(e,"P",{"data-svelte-h":!0}),r(ee)!=="svelte-pabw4f"&&(ee.innerHTML=kt),Ae=o(e),m(te.$$.fragment,e),De=o(e),ne=i(e,"P",{"data-svelte-h":!0}),r(ne)!=="svelte-1hq77cg"&&(ne.innerHTML=Zt),Ke=o(e),m(le.$$.fragment,e),et=o(e),se=i(e,"P",{"data-svelte-h":!0}),r(se)!=="svelte-tj8y7s"&&(se.innerHTML=Ct),tt=o(e),m(oe.$$.fragment,e),nt=o(e),ae=i(e,"P",{"data-svelte-h":!0}),r(ae)!=="svelte-8brdq3"&&(ae.innerHTML=_t),lt=o(e),m(ie.$$.fragment,e),st=o(e),re=i(e,"P",{"data-svelte-h":!0}),r(re)!=="svelte-9ykkz3"&&(re.textContent=Wt),ot=o(e),m(pe.$$.fragment,e),at=o(e),me=i(e,"P",{"data-svelte-h":!0}),r(me)!=="svelte-1trh1mg"&&(me.innerHTML=Rt),it=o(e),m(de.$$.fragment,e),rt=o(e),fe=i(e,"P",{}),Bt(fe).forEach(n),this.h()},h(){Vt(h,"name","hf:doc:metadata"),Vt(h,"content",St)},m(e,t){Ot(document.head,h),l(e,M,t),l(e,b,t),l(e,ce,t),d(w,e,t),l(e,ge,t),l(e,T,t),l(e,be,t),l(e,x,t),l(e,ye,t),l(e,$,t),l(e,Me,t),d(J,e,t),l(e,we,t),l(e,j,t),l(e,Te,t),l(e,U,t),l(e,xe,t),l(e,v,t),l(e,$e,t),l(e,N,t),l(e,Je,t),l(e,X,t),l(e,je,t),l(e,k,t),l(e,Ue,t),l(e,Z,t),l(e,ve,t),l(e,C,t),l(e,Ne,t),d(_,e,t),l(e,Xe,t),l(e,W,t),l(e,ke,t),d(R,e,t),l(e,Ze,t),l(e,G,t),l(e,Ce,t),d(B,e,t),l(e,_e,t),l(e,V,t),l(e,We,t),d(H,e,t),l(e,Re,t),l(e,z,t),l(e,Ge,t),d(I,e,t),l(e,Be,t),l(e,F,t),l(e,Ve,t),d(L,e,t),l(e,He,t),l(e,Q,t),l(e,ze,t),d(O,e,t),l(e,Ie,t),l(e,Y,t),l(e,Fe,t),d(E,e,t),l(e,Le,t),d(q,e,t),l(e,Qe,t),l(e,S,t),l(e,Oe,t),d(P,e,t),l(e,Ye,t),d(A,e,t),l(e,Ee,t),l(e,D,t),l(e,qe,t),d(K,e,t),l(e,Se,t),d(y,e,t),l(e,Pe,t),l(e,ee,t),l(e,Ae,t),d(te,e,t),l(e,De,t),l(e,ne,t),l(e,Ke,t),d(le,e,t),l(e,et,t),l(e,se,t),l(e,tt,t),d(oe,e,t),l(e,nt,t),l(e,ae,t),l(e,lt,t),d(ie,e,t),l(e,st,t),l(e,re,t),l(e,ot,t),d(pe,e,t),l(e,at,t),l(e,me,t),l(e,it,t),d(de,e,t),l(e,rt,t),l(e,fe,t),pt=!0},p(e,[t]){const Gt={};t&2&&(Gt.$$scope={dirty:t,ctx:e}),y.$set(Gt)},i(e){pt||(c(w.$$.fragment,e),c(J.$$.fragment,e),c(_.$$.fragment,e),c(R.$$.fragment,e),c(B.$$.fragment,e),c(H.$$.fragment,e),c(I.$$.fragment,e),c(L.$$.fragment,e),c(O.$$.fragment,e),c(E.$$.fragment,e),c(q.$$.fragment,e),c(P.$$.fragment,e),c(A.$$.fragment,e),c(K.$$.fragment,e),c(y.$$.fragment,e),c(te.$$.fragment,e),c(le.$$.fragment,e),c(oe.$$.fragment,e),c(ie.$$.fragment,e),c(pe.$$.fragment,e),c(de.$$.fragment,e),pt=!0)},o(e){u(w.$$.fragment,e),u(J.$$.fragment,e),u(_.$$.fragment,e),u(R.$$.fragment,e),u(B.$$.fragment,e),u(H.$$.fragment,e),u(I.$$.fragment,e),u(L.$$.fragment,e),u(O.$$.fragment,e),u(E.$$.fragment,e),u(q.$$.fragment,e),u(P.$$.fragment,e),u(A.$$.fragment,e),u(K.$$.fragment,e),u(y.$$.fragment,e),u(te.$$.fragment,e),u(le.$$.fragment,e),u(oe.$$.fragment,e),u(ie.$$.fragment,e),u(pe.$$.fragment,e),u(de.$$.fragment,e),pt=!1},d(e){e&&(n(M),n(b),n(ce),n(ge),n(T),n(be),n(x),n(ye),n($),n(Me),n(we),n(j),n(Te),n(U),n(xe),n(v),n($e),n(N),n(Je),n(X),n(je),n(k),n(Ue),n(Z),n(ve),n(C),n(Ne),n(Xe),n(W),n(ke),n(Ze),n(G),n(Ce),n(_e),n(V),n(We),n(Re),n(z),n(Ge),n(Be),n(F),n(Ve),n(He),n(Q),n(ze),n(Ie),n(Y),n(Fe),n(Le),n(Qe),n(S),n(Oe),n(Ye),n(Ee),n(D),n(qe),n(Se),n(Pe),n(ee),n(Ae),n(De),n(ne),n(Ke),n(et),n(se),n(tt),n(nt),n(ae),n(lt),n(st),n(re),n(ot),n(at),n(me),n(it),n(rt),n(fe)),n(h),f(w,e),f(J,e),f(_,e),f(R,e),f(B,e),f(H,e),f(I,e),f(L,e),f(O,e),f(E,e),f(q,e),f(P,e),f(A,e),f(K,e),f(y,e),f(te,e),f(le,e),f(oe,e),f(ie,e),f(pe,e),f(de,e)}}}const St='{"title":"Export to ONNX","local":"export-to-onnx","sections":[{"title":"Export to ONNX","local":"export-to-onnx","sections":[{"title":"Exporting a 🤗 Transformers model to ONNX with CLI","local":"exporting-a--transformers-model-to-onnx-with-cli","sections":[],"depth":3},{"title":"Exporting a 🤗 Transformers model to ONNX with optimum.onnxruntime","local":"exporting-a--transformers-model-to-onnx-with-optimumonnxruntime","sections":[],"depth":3},{"title":"Exporting a model for an unsupported architecture","local":"exporting-a-model-for-an-unsupported-architecture","sections":[],"depth":3},{"title":"Exporting a model with transformers.onnx","local":"exporting-a-model-with-transformersonnx","sections":[],"depth":3}],"depth":2}],"depth":1}';function Pt(he){return zt(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class nn extends Ft{constructor(h){super(),Lt(this,h,Pt,qt,Ht,{})}}export{nn as component};
