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