import{S as di,i as ui,s as fi,F as gi,e as r,w as M,k as f,c as a,a as l,x as O,d as o,m as h,b as v,g as k,G as e,y,P as _i,H as $i,I as ki,J as wi,q as T,o as b,B as q,v as hi,Z as vi,_ as xi,t as m,M as Ti,h as p,L as Y}from"../../chunks/vendor-hf-doc-builder.js";import{T as Vo}from"../../chunks/Tip-hf-doc-builder.js";import{D as V}from"../../chunks/Docstring-hf-doc-builder.js";import{C as X}from"../../chunks/CodeBlock-hf-doc-builder.js";import{I as le}from"../../chunks/IconCopyLink-hf-doc-builder.js";const{window:bi}=vi;function Mi(j){let n,g,d,u,_,s,i,x,c;u=new le({props:{classNames:"text-smd"}});const w=j[4].default,E=gi(w,j,j[3],null);return{c(){n=r("div"),g=r("a"),d=r("span"),M(u.$$.fragment),s=f(),E&&E.c(),this.h()},l(z){n=a(z,"DIV",{class:!0});var R=l(n);g=a(R,"A",{id:!0,class:!0,href:!0});var jt=l(g);d=a(jt,"SPAN",{});var Et=l(d);O(u.$$.fragment,Et),Et.forEach(o),jt.forEach(o),s=h(R),E&&E.l(R),R.forEach(o),this.h()},h(){v(g,"id",j[0]),v(g,"class","header-link block pr-0.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),v(g,"href",_=`#${j[0]}`),v(n,"class","relative group rounded-md")},m(z,R){k(z,n,R),e(n,g),e(g,d),y(u,d,null),e(n,s),E&&E.m(n,null),j[5](n),i=!0,x||(c=_i(bi,"hashchange",j[2]),x=!0)},p(z,[R]){(!i||R&1)&&v(g,"id",z[0]),(!i||R&1&&_!==(_=`#${z[0]}`))&&v(g,"href",_),E&&E.p&&(!i||R&8)&&$i(E,w,z,z[3],i?wi(w,z[3],R,null):ki(z[3]),null)},i(z){i||(T(u.$$.fragment,z),T(E,z),i=!0)},o(z){b(u.$$.fragment,z),b(E,z),i=!1},d(z){z&&o(n),q(u),E&&E.d(z),j[5](null),x=!1,c()}}}const ci="bg-yellow-50 dark:bg-[#494a3d]";function Oi(j,n,g){let{$$slots:d={},$$scope:u}=n,{anchor:_}=n,s;function i(){const{hash:c}=window.location,w=c.substring(1);s&&s.classList.remove(...ci.split(" ")),w===_&&s.classList.add(...ci.split(" "))}hi(()=>{i()});function x(c){xi[c?"unshift":"push"](()=>{s=c,g(1,s)})}return j.$$set=c=>{"anchor"in c&&g(0,_=c.anchor),"$$scope"in c&&g(3,u=c.$$scope)},[_,s,i,u,d,x]}class J extends di{constructor(n){super();ui(this,n,Oi,Mi,fi,{anchor:0})}}function yi(j){let n,g,d,u,_;return{c(){n=r("p"),g=m("Although the recipe for forward pass needs to be defined within this function, one should call the "),d=r("code"),u=m("Module"),_=m(`
instance afterwards instead of this since the former takes care of running the pre and post processing steps while
the latter silently ignores them.`)},l(s){n=a(s,"P",{});var i=l(n);g=p(i,"Although the recipe for forward pass needs to be defined within this function, one should call the "),d=a(i,"CODE",{});var x=l(d);u=p(x,"Module"),x.forEach(o),_=p(i,`
instance afterwards instead of this since the former takes care of running the pre and post processing steps while
the latter silently ignores them.`),i.forEach(o)},m(s,i){k(s,n,i),e(n,g),e(n,d),e(d,u),e(n,_)},d(s){s&&o(n)}}}function qi(j){let n,g,d,u,_;return u=new X({props:{code:`from transformers import AutoTokenizer
from optimum.onnxruntime import ORTModelForFeatureExtraction
import torch

tokenizer = AutoTokenizer.from_pretrained("optimum/all-MiniLM-L6-v2")
model = ORTModelForFeatureExtraction.from_pretrained("optimum/all-MiniLM-L6-v2")

inputs = tokenizer("My name is Philipp and I live in Germany.", return_tensors="pt")

outputs = model(**inputs)
logits = outputs.logits
list(logits.shape)`,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> ORTModelForFeatureExtraction
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">import</span> torch

<span class="hljs-meta">&gt;&gt;&gt; </span>tokenizer = AutoTokenizer.from_pretrained(<span class="hljs-string">&quot;optimum/all-MiniLM-L6-v2&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>model = ORTModelForFeatureExtraction.from_pretrained(<span class="hljs-string">&quot;optimum/all-MiniLM-L6-v2&quot;</span>)

<span class="hljs-meta">&gt;&gt;&gt; </span>inputs = tokenizer(<span class="hljs-string">&quot;My name is Philipp and I live in Germany.&quot;</span>, return_tensors=<span class="hljs-string">&quot;pt&quot;</span>)

<span class="hljs-meta">&gt;&gt;&gt; </span>outputs = model(**inputs)
<span class="hljs-meta">&gt;&gt;&gt; </span>logits = outputs.logits
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-built_in">list</span>(logits.shape)`}}),{c(){n=r("p"),g=m("Example of feature extraction:"),d=f(),M(u.$$.fragment)},l(s){n=a(s,"P",{});var i=l(n);g=p(i,"Example of feature extraction:"),i.forEach(o),d=h(s),O(u.$$.fragment,s)},m(s,i){k(s,n,i),e(n,g),k(s,d,i),y(u,s,i),_=!0},p:Y,i(s){_||(T(u.$$.fragment,s),_=!0)},o(s){b(u.$$.fragment,s),_=!1},d(s){s&&o(n),s&&o(d),q(u,s)}}}function ji(j){let n,g,d,u,_,s,i,x;return i=new X({props:{code:`from transformers import AutoTokenizer, pipeline
from optimum.onnxruntime import ORTModelForFeatureExtraction

tokenizer = AutoTokenizer.from_pretrained("optimum/all-MiniLM-L6-v2")
model = ORTModelForFeatureExtraction.from_pretrained("optimum/all-MiniLM-L6-v2")
onnx_extractor = pipeline("feature-extraction", model=model, tokenizer=tokenizer)

text = "My name is Philipp and I live in Germany."
pred = onnx_extractor(text)`,highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoTokenizer, pipeline
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> optimum.onnxruntime <span class="hljs-keyword">import</span> ORTModelForFeatureExtraction

<span class="hljs-meta">&gt;&gt;&gt; </span>tokenizer = AutoTokenizer.from_pretrained(<span class="hljs-string">&quot;optimum/all-MiniLM-L6-v2&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>model = ORTModelForFeatureExtraction.from_pretrained(<span class="hljs-string">&quot;optimum/all-MiniLM-L6-v2&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>onnx_extractor = pipeline(<span class="hljs-string">&quot;feature-extraction&quot;</span>, model=model, tokenizer=tokenizer)

<span class="hljs-meta">&gt;&gt;&gt; </span>text = <span class="hljs-string">&quot;My name is Philipp and I live in Germany.&quot;</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>pred = onnx_extractor(text)`}}),{c(){n=r("p"),g=m("Example using "),d=r("code"),u=m("transformers.pipeline"),_=m(":"),s=f(),M(i.$$.fragment)},l(c){n=a(c,"P",{});var w=l(n);g=p(w,"Example using "),d=a(w,"CODE",{});var E=l(d);u=p(E,"transformers.pipeline"),E.forEach(o),_=p(w,":"),w.forEach(o),s=h(c),O(i.$$.fragment,c)},m(c,w){k(c,n,w),e(n,g),e(n,d),e(d,u),e(n,_),k(c,s,w),y(i,c,w),x=!0},p:Y,i(c){x||(T(i.$$.fragment,c),x=!0)},o(c){b(i.$$.fragment,c),x=!1},d(c){c&&o(n),c&&o(s),q(i,c)}}}function Ei(j){let n,g,d,u,_;return{c(){n=r("p"),g=m("Although the recipe for forward pass needs to be defined within this function, one should call the "),d=r("code"),u=m("Module"),_=m(`
instance afterwards instead of this since the former takes care of running the pre and post processing steps while
the latter silently ignores them.`)},l(s){n=a(s,"P",{});var i=l(n);g=p(i,"Although the recipe for forward pass needs to be defined within this function, one should call the "),d=a(i,"CODE",{});var x=l(d);u=p(x,"Module"),x.forEach(o),_=p(i,`
instance afterwards instead of this since the former takes care of running the pre and post processing steps while
the latter silently ignores them.`),i.forEach(o)},m(s,i){k(s,n,i),e(n,g),e(n,d),e(d,u),e(n,_)},d(s){s&&o(n)}}}function zi(j){let n,g,d,u,_;return u=new X({props:{code:`from transformers import AutoTokenizer
from optimum.onnxruntime import ORTModelForQuestionAnswering
import torch

tokenizer = AutoTokenizer.from_pretrained("optimum/roberta-base-squad2")
model = ORTModelForQuestionAnswering.from_pretrained("optimum/roberta-base-squad2")

question, text = "Who was Jim Henson?", "Jim Henson was a nice puppet"
inputs = tokenizer(question, text, return_tensors="pt")
start_positions = torch.tensor([1])
end_positions = torch.tensor([3])

outputs = model(**inputs, start_positions=start_positions, end_positions=end_positions)
start_scores = outputs.start_logits
end_scores = outputs.end_logits`,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><span class="hljs-keyword">import</span> torch

<span class="hljs-meta">&gt;&gt;&gt; </span>tokenizer = AutoTokenizer.from_pretrained(<span class="hljs-string">&quot;optimum/roberta-base-squad2&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>model = ORTModelForQuestionAnswering.from_pretrained(<span class="hljs-string">&quot;optimum/roberta-base-squad2&quot;</span>)

<span class="hljs-meta">&gt;&gt;&gt; </span>question, text = <span class="hljs-string">&quot;Who was Jim Henson?&quot;</span>, <span class="hljs-string">&quot;Jim Henson was a nice puppet&quot;</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>inputs = tokenizer(question, text, return_tensors=<span class="hljs-string">&quot;pt&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>start_positions = torch.tensor([<span class="hljs-number">1</span>])
<span class="hljs-meta">&gt;&gt;&gt; </span>end_positions = torch.tensor([<span class="hljs-number">3</span>])

<span class="hljs-meta">&gt;&gt;&gt; </span>outputs = model(**inputs, start_positions=start_positions, end_positions=end_positions)
<span class="hljs-meta">&gt;&gt;&gt; </span>start_scores = outputs.start_logits
<span class="hljs-meta">&gt;&gt;&gt; </span>end_scores = outputs.end_logits`}}),{c(){n=r("p"),g=m("Example of question answering:"),d=f(),M(u.$$.fragment)},l(s){n=a(s,"P",{});var i=l(n);g=p(i,"Example of question answering:"),i.forEach(o),d=h(s),O(u.$$.fragment,s)},m(s,i){k(s,n,i),e(n,g),k(s,d,i),y(u,s,i),_=!0},p:Y,i(s){_||(T(u.$$.fragment,s),_=!0)},o(s){b(u.$$.fragment,s),_=!1},d(s){s&&o(n),s&&o(d),q(u,s)}}}function Ri(j){let n,g,d,u,_,s,i,x;return i=new X({props:{code:`from transformers import AutoTokenizer, pipeline
from optimum.onnxruntime import ORTModelForQuestionAnswering

tokenizer = AutoTokenizer.from_pretrained("optimum/roberta-base-squad2")
model = ORTModelForQuestionAnswering.from_pretrained("optimum/roberta-base-squad2")
onnx_qa = pipeline("question-answering", model=model, tokenizer=tokenizer)

question, text = "Who was Jim Henson?", "Jim Henson was a nice puppet"
pred = onnx_qa(question, text)`,highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoTokenizer, pipeline
<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;optimum/roberta-base-squad2&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>model = ORTModelForQuestionAnswering.from_pretrained(<span class="hljs-string">&quot;optimum/roberta-base-squad2&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>onnx_qa = pipeline(<span class="hljs-string">&quot;question-answering&quot;</span>, model=model, tokenizer=tokenizer)

<span class="hljs-meta">&gt;&gt;&gt; </span>question, text = <span class="hljs-string">&quot;Who was Jim Henson?&quot;</span>, <span class="hljs-string">&quot;Jim Henson was a nice puppet&quot;</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>pred = onnx_qa(question, text)`}}),{c(){n=r("p"),g=m("Example using "),d=r("code"),u=m("transformers.pipeline"),_=m(":"),s=f(),M(i.$$.fragment)},l(c){n=a(c,"P",{});var w=l(n);g=p(w,"Example using "),d=a(w,"CODE",{});var E=l(d);u=p(E,"transformers.pipeline"),E.forEach(o),_=p(w,":"),w.forEach(o),s=h(c),O(i.$$.fragment,c)},m(c,w){k(c,n,w),e(n,g),e(n,d),e(d,u),e(n,_),k(c,s,w),y(i,c,w),x=!0},p:Y,i(c){x||(T(i.$$.fragment,c),x=!0)},o(c){b(i.$$.fragment,c),x=!1},d(c){c&&o(n),c&&o(s),q(i,c)}}}function Fi(j){let n,g,d,u,_;return{c(){n=r("p"),g=m("Although the recipe for forward pass needs to be defined within this function, one should call the "),d=r("code"),u=m("Module"),_=m(`
instance afterwards instead of this since the former takes care of running the pre and post processing steps while
the latter silently ignores them.`)},l(s){n=a(s,"P",{});var i=l(n);g=p(i,"Although the recipe for forward pass needs to be defined within this function, one should call the "),d=a(i,"CODE",{});var x=l(d);u=p(x,"Module"),x.forEach(o),_=p(i,`
instance afterwards instead of this since the former takes care of running the pre and post processing steps while
the latter silently ignores them.`),i.forEach(o)},m(s,i){k(s,n,i),e(n,g),e(n,d),e(d,u),e(n,_)},d(s){s&&o(n)}}}function Ci(j){let n,g,d,u,_;return u=new X({props:{code:`from transformers import AutoTokenizer
from optimum.onnxruntime import ORTModelForSequenceClassification
import torch

tokenizer = AutoTokenizer.from_pretrained("optimum/distilbert-base-uncased-finetuned-sst-2-english")
model = ORTModelForSequenceClassification.from_pretrained("optimum/distilbert-base-uncased-finetuned-sst-2-english")

inputs = tokenizer("Hello, my dog is cute", return_tensors="pt")

outputs = model(**inputs)
logits = outputs.logits
list(logits.shape)`,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> ORTModelForSequenceClassification
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">import</span> torch

<span class="hljs-meta">&gt;&gt;&gt; </span>tokenizer = AutoTokenizer.from_pretrained(<span class="hljs-string">&quot;optimum/distilbert-base-uncased-finetuned-sst-2-english&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>model = ORTModelForSequenceClassification.from_pretrained(<span class="hljs-string">&quot;optimum/distilbert-base-uncased-finetuned-sst-2-english&quot;</span>)

<span class="hljs-meta">&gt;&gt;&gt; </span>inputs = tokenizer(<span class="hljs-string">&quot;Hello, my dog is cute&quot;</span>, return_tensors=<span class="hljs-string">&quot;pt&quot;</span>)

<span class="hljs-meta">&gt;&gt;&gt; </span>outputs = model(**inputs)
<span class="hljs-meta">&gt;&gt;&gt; </span>logits = outputs.logits
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-built_in">list</span>(logits.shape)`}}),{c(){n=r("p"),g=m("Example of single-label classification:"),d=f(),M(u.$$.fragment)},l(s){n=a(s,"P",{});var i=l(n);g=p(i,"Example of single-label classification:"),i.forEach(o),d=h(s),O(u.$$.fragment,s)},m(s,i){k(s,n,i),e(n,g),k(s,d,i),y(u,s,i),_=!0},p:Y,i(s){_||(T(u.$$.fragment,s),_=!0)},o(s){b(u.$$.fragment,s),_=!1},d(s){s&&o(n),s&&o(d),q(u,s)}}}function Ai(j){let n,g,d,u,_,s,i,x;return i=new X({props:{code:`from transformers import AutoTokenizer, pipeline
from optimum.onnxruntime import ORTModelForSequenceClassification

tokenizer = AutoTokenizer.from_pretrained("optimum/distilbert-base-uncased-finetuned-sst-2-english")
model = ORTModelForSequenceClassification.from_pretrained("optimum/distilbert-base-uncased-finetuned-sst-2-english")
onnx_classifier = pipeline("text-classification", model=model, tokenizer=tokenizer)

text = "Hello, my dog is cute"
pred = onnx_classifier(text)`,highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoTokenizer, pipeline
<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>tokenizer = AutoTokenizer.from_pretrained(<span class="hljs-string">&quot;optimum/distilbert-base-uncased-finetuned-sst-2-english&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>model = ORTModelForSequenceClassification.from_pretrained(<span class="hljs-string">&quot;optimum/distilbert-base-uncased-finetuned-sst-2-english&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>onnx_classifier = pipeline(<span class="hljs-string">&quot;text-classification&quot;</span>, model=model, tokenizer=tokenizer)

<span class="hljs-meta">&gt;&gt;&gt; </span>text = <span class="hljs-string">&quot;Hello, my dog is cute&quot;</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>pred = onnx_classifier(text)`}}),{c(){n=r("p"),g=m("Example using "),d=r("code"),u=m("transformers.pipelines"),_=m(":"),s=f(),M(i.$$.fragment)},l(c){n=a(c,"P",{});var w=l(n);g=p(w,"Example using "),d=a(w,"CODE",{});var E=l(d);u=p(E,"transformers.pipelines"),E.forEach(o),_=p(w,":"),w.forEach(o),s=h(c),O(i.$$.fragment,c)},m(c,w){k(c,n,w),e(n,g),e(n,d),e(d,u),e(n,_),k(c,s,w),y(i,c,w),x=!0},p:Y,i(c){x||(T(i.$$.fragment,c),x=!0)},o(c){b(i.$$.fragment,c),x=!1},d(c){c&&o(n),c&&o(s),q(i,c)}}}function Pi(j){let n,g,d,u,_,s,i,x;return i=new X({props:{code:`from transformers import AutoTokenizer, pipeline
from optimum.onnxruntime import ORTModelForSequenceClassification

tokenizer = AutoTokenizer.from_pretrained("optimum/distilbert-base-uncased-mnli")
model = ORTModelForSequenceClassification.from_pretrained("optimum/distilbert-base-uncased-mnli")
onnx_z0 = pipeline("zero-shot-classification", model=model, tokenizer=tokenizer)

sequence_to_classify = "Who are you voting for in 2020?"
candidate_labels = ["Europe", "public health", "politics", "elections"]
pred = onnx_z0(sequence_to_classify, candidate_labels, multi_class=True)`,highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoTokenizer, pipeline
<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>tokenizer = AutoTokenizer.from_pretrained(<span class="hljs-string">&quot;optimum/distilbert-base-uncased-mnli&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>model = ORTModelForSequenceClassification.from_pretrained(<span class="hljs-string">&quot;optimum/distilbert-base-uncased-mnli&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>onnx_z0 = pipeline(<span class="hljs-string">&quot;zero-shot-classification&quot;</span>, model=model, tokenizer=tokenizer)

<span class="hljs-meta">&gt;&gt;&gt; </span>sequence_to_classify = <span class="hljs-string">&quot;Who are you voting for in 2020?&quot;</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>candidate_labels = [<span class="hljs-string">&quot;Europe&quot;</span>, <span class="hljs-string">&quot;public health&quot;</span>, <span class="hljs-string">&quot;politics&quot;</span>, <span class="hljs-string">&quot;elections&quot;</span>]
<span class="hljs-meta">&gt;&gt;&gt; </span>pred = onnx_z0(sequence_to_classify, candidate_labels, multi_class=<span class="hljs-literal">True</span>)`}}),{c(){n=r("p"),g=m("Example using zero-shot-classification "),d=r("code"),u=m("transformers.pipelines"),_=m(":"),s=f(),M(i.$$.fragment)},l(c){n=a(c,"P",{});var w=l(n);g=p(w,"Example using zero-shot-classification "),d=a(w,"CODE",{});var E=l(d);u=p(E,"transformers.pipelines"),E.forEach(o),_=p(w,":"),w.forEach(o),s=h(c),O(i.$$.fragment,c)},m(c,w){k(c,n,w),e(n,g),e(n,d),e(d,u),e(n,_),k(c,s,w),y(i,c,w),x=!0},p:Y,i(c){x||(T(i.$$.fragment,c),x=!0)},o(c){b(i.$$.fragment,c),x=!1},d(c){c&&o(n),c&&o(s),q(i,c)}}}function Ni(j){let n,g,d,u,_;return{c(){n=r("p"),g=m("Although the recipe for forward pass needs to be defined within this function, one should call the "),d=r("code"),u=m("Module"),_=m(`
instance afterwards instead of this since the former takes care of running the pre and post processing steps while
the latter silently ignores them.`)},l(s){n=a(s,"P",{});var i=l(n);g=p(i,"Although the recipe for forward pass needs to be defined within this function, one should call the "),d=a(i,"CODE",{});var x=l(d);u=p(x,"Module"),x.forEach(o),_=p(i,`
instance afterwards instead of this since the former takes care of running the pre and post processing steps while
the latter silently ignores them.`),i.forEach(o)},m(s,i){k(s,n,i),e(n,g),e(n,d),e(d,u),e(n,_)},d(s){s&&o(n)}}}function Si(j){let n,g,d,u,_;return u=new X({props:{code:`from transformers import AutoTokenizer
from optimum.onnxruntime import ORTModelForTokenClassification
import torch

tokenizer = AutoTokenizer.from_pretrained("optimum/bert-base-NER")
model = ORTModelForTokenClassification.from_pretrained("optimum/bert-base-NER")

inputs = tokenizer("My name is Philipp and I live in Germany.", return_tensors="pt")

outputs = model(**inputs)
logits = outputs.logits
list(logits.shape)`,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> ORTModelForTokenClassification
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">import</span> torch

<span class="hljs-meta">&gt;&gt;&gt; </span>tokenizer = AutoTokenizer.from_pretrained(<span class="hljs-string">&quot;optimum/bert-base-NER&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>model = ORTModelForTokenClassification.from_pretrained(<span class="hljs-string">&quot;optimum/bert-base-NER&quot;</span>)

<span class="hljs-meta">&gt;&gt;&gt; </span>inputs = tokenizer(<span class="hljs-string">&quot;My name is Philipp and I live in Germany.&quot;</span>, return_tensors=<span class="hljs-string">&quot;pt&quot;</span>)

<span class="hljs-meta">&gt;&gt;&gt; </span>outputs = model(**inputs)
<span class="hljs-meta">&gt;&gt;&gt; </span>logits = outputs.logits
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-built_in">list</span>(logits.shape)`}}),{c(){n=r("p"),g=m("Example of token classification:"),d=f(),M(u.$$.fragment)},l(s){n=a(s,"P",{});var i=l(n);g=p(i,"Example of token classification:"),i.forEach(o),d=h(s),O(u.$$.fragment,s)},m(s,i){k(s,n,i),e(n,g),k(s,d,i),y(u,s,i),_=!0},p:Y,i(s){_||(T(u.$$.fragment,s),_=!0)},o(s){b(u.$$.fragment,s),_=!1},d(s){s&&o(n),s&&o(d),q(u,s)}}}function Ii(j){let n,g,d,u,_,s,i,x;return i=new X({props:{code:`from transformers import AutoTokenizer, pipeline
from optimum.onnxruntime import ORTModelForTokenClassification

tokenizer = AutoTokenizer.from_pretrained("optimum/bert-base-NER")
model = ORTModelForTokenClassification.from_pretrained("optimum/bert-base-NER")
onnx_ner = pipeline("token-classification", model=model, tokenizer=tokenizer)

text = "My name is Philipp and I live in Germany."
pred = onnx_ner(text)`,highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoTokenizer, pipeline
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> optimum.onnxruntime <span class="hljs-keyword">import</span> ORTModelForTokenClassification

<span class="hljs-meta">&gt;&gt;&gt; </span>tokenizer = AutoTokenizer.from_pretrained(<span class="hljs-string">&quot;optimum/bert-base-NER&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>model = ORTModelForTokenClassification.from_pretrained(<span class="hljs-string">&quot;optimum/bert-base-NER&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>onnx_ner = pipeline(<span class="hljs-string">&quot;token-classification&quot;</span>, model=model, tokenizer=tokenizer)

<span class="hljs-meta">&gt;&gt;&gt; </span>text = <span class="hljs-string">&quot;My name is Philipp and I live in Germany.&quot;</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>pred = onnx_ner(text)`}}),{c(){n=r("p"),g=m("Example using "),d=r("code"),u=m("transformers.pipelines"),_=m(":"),s=f(),M(i.$$.fragment)},l(c){n=a(c,"P",{});var w=l(n);g=p(w,"Example using "),d=a(w,"CODE",{});var E=l(d);u=p(E,"transformers.pipelines"),E.forEach(o),_=p(w,":"),w.forEach(o),s=h(c),O(i.$$.fragment,c)},m(c,w){k(c,n,w),e(n,g),e(n,d),e(d,u),e(n,_),k(c,s,w),y(i,c,w),x=!0},p:Y,i(c){x||(T(i.$$.fragment,c),x=!0)},o(c){b(i.$$.fragment,c),x=!1},d(c){c&&o(n),c&&o(s),q(i,c)}}}function Di(j){let n,g,d,u,_;return{c(){n=r("p"),g=m("Although the recipe for forward pass needs to be defined within this function, one should call the "),d=r("code"),u=m("Module"),_=m(`
instance afterwards instead of this since the former takes care of running the pre and post processing steps while
the latter silently ignores them.`)},l(s){n=a(s,"P",{});var i=l(n);g=p(i,"Although the recipe for forward pass needs to be defined within this function, one should call the "),d=a(i,"CODE",{});var x=l(d);u=p(x,"Module"),x.forEach(o),_=p(i,`
instance afterwards instead of this since the former takes care of running the pre and post processing steps while
the latter silently ignores them.`),i.forEach(o)},m(s,i){k(s,n,i),e(n,g),e(n,d),e(d,u),e(n,_)},d(s){s&&o(n)}}}function Li(j){let n,g,d,u,_;return u=new X({props:{code:`from transformers import AutoTokenizer
from optimum.onnxruntime import ORTModelForCausalLM
import torch

tokenizer = AutoTokenizer.from_pretrained("optimum/gpt2")
model = ORTModelForCausalLM.from_pretrained("optimum/gpt2")

inputs = tokenizer("My name is Philipp and I live in Germany.", return_tensors="pt")

gen_tokens = model.generate(**inputs,do_sample=True,temperature=0.9, min_length=20,max_length=20)
tokenizer.batch_decode(gen_tokens)`,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> ORTModelForCausalLM
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">import</span> torch

<span class="hljs-meta">&gt;&gt;&gt; </span>tokenizer = AutoTokenizer.from_pretrained(<span class="hljs-string">&quot;optimum/gpt2&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>model = ORTModelForCausalLM.from_pretrained(<span class="hljs-string">&quot;optimum/gpt2&quot;</span>)

<span class="hljs-meta">&gt;&gt;&gt; </span>inputs = tokenizer(<span class="hljs-string">&quot;My name is Philipp and I live in Germany.&quot;</span>, return_tensors=<span class="hljs-string">&quot;pt&quot;</span>)

<span class="hljs-meta">&gt;&gt;&gt; </span>gen_tokens = model.generate(**inputs,do_sample=<span class="hljs-literal">True</span>,temperature=<span class="hljs-number">0.9</span>, min_length=<span class="hljs-number">20</span>,max_length=<span class="hljs-number">20</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>tokenizer.batch_decode(gen_tokens)`}}),{c(){n=r("p"),g=m("Example of text generation:"),d=f(),M(u.$$.fragment)},l(s){n=a(s,"P",{});var i=l(n);g=p(i,"Example of text generation:"),i.forEach(o),d=h(s),O(u.$$.fragment,s)},m(s,i){k(s,n,i),e(n,g),k(s,d,i),y(u,s,i),_=!0},p:Y,i(s){_||(T(u.$$.fragment,s),_=!0)},o(s){b(u.$$.fragment,s),_=!1},d(s){s&&o(n),s&&o(d),q(u,s)}}}function Hi(j){let n,g,d,u,_,s,i,x;return i=new X({props:{code:`from transformers import AutoTokenizer, pipeline
from optimum.onnxruntime import ORTModelForCausalLM

tokenizer = AutoTokenizer.from_pretrained("optimum/gpt2")
model = ORTModelForCausalLM.from_pretrained("optimum/gpt2")
onnx_gen = pipeline("text-generation", model=model, tokenizer=tokenizer)

text = "My name is Philipp and I live in Germany."
gen = onnx_gen(text)`,highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoTokenizer, pipeline
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> optimum.onnxruntime <span class="hljs-keyword">import</span> ORTModelForCausalLM

<span class="hljs-meta">&gt;&gt;&gt; </span>tokenizer = AutoTokenizer.from_pretrained(<span class="hljs-string">&quot;optimum/gpt2&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>model = ORTModelForCausalLM.from_pretrained(<span class="hljs-string">&quot;optimum/gpt2&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>onnx_gen = pipeline(<span class="hljs-string">&quot;text-generation&quot;</span>, model=model, tokenizer=tokenizer)

<span class="hljs-meta">&gt;&gt;&gt; </span>text = <span class="hljs-string">&quot;My name is Philipp and I live in Germany.&quot;</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>gen = onnx_gen(text)`}}),{c(){n=r("p"),g=m("Example using "),d=r("code"),u=m("transformers.pipelines"),_=m(":"),s=f(),M(i.$$.fragment)},l(c){n=a(c,"P",{});var w=l(n);g=p(w,"Example using "),d=a(w,"CODE",{});var E=l(d);u=p(E,"transformers.pipelines"),E.forEach(o),_=p(w,":"),w.forEach(o),s=h(c),O(i.$$.fragment,c)},m(c,w){k(c,n,w),e(n,g),e(n,d),e(d,u),e(n,_),k(c,s,w),y(i,c,w),x=!0},p:Y,i(c){x||(T(i.$$.fragment,c),x=!0)},o(c){b(i.$$.fragment,c),x=!1},d(c){c&&o(n),c&&o(s),q(i,c)}}}function Qi(j){let n,g,d,u,_,s,i,x,c,w,E,z,R,jt,Et,Uo,me,Te,Dt,Je,Fn,Lt,Cn,Jo,I,An,Ht,Pn,Nn,Qt,Sn,In,Xt,Dn,Ln,Wt,Hn,Qn,Yo,Ye,Zo,Z,Xn,Bt,Wn,Bn,Gt,Gn,Vn,Ko,Ze,en,be,Un,zt,Jn,Yn,tn,pe,Me,Vt,Ke,Zn,Ut,Kn,on,B,es,Rt,ts,os,et,ns,ss,Jt,rs,as,nn,tt,sn,ce,Oe,Yt,ot,is,Zt,ls,rn,U,nt,ms,st,ps,Kt,cs,ds,us,ye,rt,fs,Ft,hs,eo,gs,an,de,qe,to,at,_s,oo,$s,ln,C,it,ks,no,ws,vs,lt,xs,so,Ts,bs,Ms,ro,Os,ys,D,mt,qs,ue,js,ao,Es,zs,io,Rs,Fs,Cs,je,As,Ee,Ps,ze,mn,fe,Re,lo,pt,Ns,mo,Ss,pn,A,ct,Is,po,Ds,Ls,dt,Hs,co,Qs,Xs,Ws,uo,Bs,Gs,L,ut,Vs,he,Us,fo,Js,Ys,ho,Zs,Ks,er,Fe,tr,Ce,or,Ae,cn,ge,Pe,go,ft,nr,_o,sr,dn,P,ht,rr,$o,ar,ir,gt,lr,ko,mr,pr,cr,wo,dr,ur,F,_t,fr,_e,hr,vo,gr,_r,xo,$r,kr,wr,Ne,vr,Se,xr,Ie,Tr,De,un,$e,Le,To,$t,br,bo,Mr,fn,N,kt,Or,Mo,yr,qr,wt,jr,Oo,Er,zr,Rr,yo,Fr,Cr,H,vt,Ar,ke,Pr,qo,Nr,Sr,jo,Ir,Dr,Lr,He,Hr,Qe,Qr,Xe,hn,we,We,Eo,xt,Xr,zo,Wr,gn,S,Tt,Br,Ro,Gr,Vr,bt,Ur,Fo,Jr,Yr,Zr,Co,Kr,ea,Q,Mt,ta,ve,oa,Ao,na,sa,Po,ra,aa,ia,Be,la,Ge,ma,Ve,_n;return s=new le({}),Je=new le({}),Ye=new X({props:{code:`from transformers import AutoTokenizer, pipeline
-from transformers import AutoModelForQuestionAnswering
+from optimum.onnxruntime import ORTModelForQuestionAnswering

-model = AutoModelForQuestionAnswering.from_pretrained("deepset/roberta-base-squad2") # pytorch checkpoint
+model = ORTModelForQuestionAnswering.from_pretrained("optimum/roberta-base-squad2") # onnx checkpoint
tokenizer = AutoTokenizer.from_pretrained("deepset/roberta-base-squad2")

onnx_qa = pipeline("question-answering",model=model,tokenizer=tokenizer)

question = "What's my name?"
context = "My name is Philipp and I live in Nuremberg."
pred = onnx_qa(question, context)`,highlighted:`from transformers import AutoTokenizer, pipeline
<span class="hljs-deletion">-from transformers import AutoModelForQuestionAnswering</span>
<span class="hljs-addition">+from optimum.onnxruntime import ORTModelForQuestionAnswering</span>

<span class="hljs-deletion">-model = AutoModelForQuestionAnswering.from_pretrained(&quot;deepset/roberta-base-squad2&quot;) # pytorch checkpoint</span>
<span class="hljs-addition">+model = ORTModelForQuestionAnswering.from_pretrained(&quot;optimum/roberta-base-squad2&quot;) # onnx checkpoint</span>
tokenizer = AutoTokenizer.from_pretrained(&quot;deepset/roberta-base-squad2&quot;)

onnx_qa = pipeline(&quot;question-answering&quot;,model=model,tokenizer=tokenizer)

question = &quot;What&#x27;s my name?&quot;
context = &quot;My name is Philipp and I live in Nuremberg.&quot;
pred = onnx_qa(question, context)`}}),Ze=new X({props:{code:`from transformers import AutoTokenizer, pipeline
from optimum.onnxruntime import ORTModelForSequenceClassification

model = ORTModelForSequenceClassification.from_pretrained("distilbert-base-uncased-finetuned-sst-2-english",from_transformers=True)
tokenizer = AutoTokenizer.from_pretrained("distilbert-base-uncased-finetuned-sst-2-english")

onnx_classifier = pipeline("text-classification",model=model,tokenizer=tokenizer)

result = onnx_classifier(text="This is a great model")`,highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoTokenizer, pipeline
<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-comment"># load model from hub and convert</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>model = ORTModelForSequenceClassification.from_pretrained(<span class="hljs-string">&quot;distilbert-base-uncased-finetuned-sst-2-english&quot;</span>,from_transformers=<span class="hljs-literal">True</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>tokenizer = AutoTokenizer.from_pretrained(<span class="hljs-string">&quot;distilbert-base-uncased-finetuned-sst-2-english&quot;</span>)

<span class="hljs-comment"># create pipeline</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>onnx_classifier = pipeline(<span class="hljs-string">&quot;text-classification&quot;</span>,model=model,tokenizer=tokenizer)

<span class="hljs-meta">&gt;&gt;&gt; </span>result = onnx_classifier(text=<span class="hljs-string">&quot;This is a great model&quot;</span>)
[{<span class="hljs-string">&#x27;label&#x27;</span>: <span class="hljs-string">&#x27;POSITIVE&#x27;</span>, <span class="hljs-string">&#x27;score&#x27;</span>: <span class="hljs-number">0.9998838901519775</span>}]`}}),Ke=new le({}),tt=new X({props:{code:`from transformers import AutoTokenizer
from optimum.onnxruntime import ORTModelForSequenceClassification

model = ORTModelForSequenceClassification.from_pretrained("distilbert-base-uncased-finetuned-sst-2-english",from_transformers=True)
tokenizer = AutoTokenizer.from_pretrained("distilbert-base-uncased-finetuned-sst-2-english")

model.save_pretrained("a_local_path_for_convert_onnx_model")
tokenizer.save_pretrained("a_local_path_for_convert_onnx_model")

model.push_to_hub("a_local_path_for_convert_onnx_model",`,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> ORTModelForSequenceClassification

<span class="hljs-comment"># load model from hub and convert</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>model = ORTModelForSequenceClassification.from_pretrained(<span class="hljs-string">&quot;distilbert-base-uncased-finetuned-sst-2-english&quot;</span>,from_transformers=<span class="hljs-literal">True</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>tokenizer = AutoTokenizer.from_pretrained(<span class="hljs-string">&quot;distilbert-base-uncased-finetuned-sst-2-english&quot;</span>)

<span class="hljs-comment"># save converted model</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>model.save_pretrained(<span class="hljs-string">&quot;a_local_path_for_convert_onnx_model&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>tokenizer.save_pretrained(<span class="hljs-string">&quot;a_local_path_for_convert_onnx_model&quot;</span>)

<span class="hljs-comment"># push model onnx model to HF Hub</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>model.push_to_hub(<span class="hljs-string">&quot;a_local_path_for_convert_onnx_model&quot;</span>,
                  repository_id=<span class="hljs-string">&quot;my-onnx-repo&quot;</span>,
                  use_auth_token=<span class="hljs-literal">True</span>
                  )`}}),ot=new le({}),nt=new V({props:{name:"class optimum.onnxruntime.ORTModel",anchor:"optimum.onnxruntime.ORTModel",parameters:[{name:"model",val:" = None"},{name:"config",val:" = None"},{name:"**kwargs",val:""}],source:"https://github.com/huggingface/optimum/blob/vr_200/src/optimum/onnxruntime/modeling_ort.py#L79"}}),rt=new V({props:{name:"load_model",anchor:"optimum.onnxruntime.ORTModel.load_model",parameters:[{name:"path",val:": typing.Union[str, pathlib.Path]"},{name:"provider",val:" = None"}],parametersDescription:[{anchor:"optimum.onnxruntime.ORTModel.load_model.path",description:`<strong>path</strong> (<code>str</code> or <code>Path</code>) &#x2014;
Directory from which to load`,name:"path"},{anchor:"optimum.onnxruntime.ORTModel.load_model.provider(str,",description:`<strong>provider(<code>str</code>,</strong> <em>optional</em>) &#x2014;
Onnxruntime provider to use for loading the model, defaults to <code>CUDAExecutionProvider</code> if GPU is
available else <code>CPUExecutionProvider</code>`,name:"provider(str,"}],source:"https://github.com/huggingface/optimum/blob/vr_200/src/optimum/onnxruntime/modeling_ort.py#L97"}}),at=new le({}),it=new V({props:{name:"class optimum.onnxruntime.ORTModelForFeatureExtraction",anchor:"optimum.onnxruntime.ORTModelForFeatureExtraction",parameters:[{name:"*args",val:""},{name:"**kwargs",val:""}],parametersDescription:[{anchor:"optimum.onnxruntime.ORTModelForFeatureExtraction.config",description:`<strong>config</strong> (<code>transformers.PretrainedConfig</code>) &#x2014; <a href="https://huggingface.co/docs/transformers/main_classes/configuration#transformers.PretrainedConfig" rel="nofollow">PretrainedConfig</a> is the Model configuration class with all the parameters of the model.
Initializing with a config file does not load the weights associated with the model, only the
configuration. Check out the <code>from_pretrained()</code> method to load the model weights.`,name:"config"},{anchor:"optimum.onnxruntime.ORTModelForFeatureExtraction.model",description:'<strong>model</strong> (<code>onnxruntime.InferenceSession</code>) &#x2014; <a href="https://onnxruntime.ai/docs/api/python/api_summary.html#inferencesession" rel="nofollow">onnxruntime.InferenceSession</a> is the main class used to run a model. Check out the <a href="/docs/optimum/pr_200/en/onnxruntime/modeling_ort#optimum.onnxruntime.ORTModel.load_model">load_model()</a> method for more information.',name:"model"}],source:"https://github.com/huggingface/optimum/blob/vr_200/src/optimum/onnxruntime/modeling_ort.py#L294"}}),mt=new V({props:{name:"forward",anchor:"optimum.onnxruntime.ORTModelForFeatureExtraction.forward",parameters:[{name:"input_ids",val:": typing.Optional[torch.Tensor] = None"},{name:"attention_mask",val:": typing.Optional[torch.Tensor] = None"},{name:"token_type_ids",val:": typing.Optional[torch.Tensor] = None"},{name:"**kwargs",val:""}],parametersDescription:[{anchor:"optimum.onnxruntime.ORTModelForFeatureExtraction.forward.input_ids",description:`<strong>input_ids</strong> (<code>torch.Tensor</code> of shape <code>(batch_size, sequence_length)</code>) &#x2014;
Indices of input sequence tokens in the vocabulary.
Indices can be obtained using <a href="https://huggingface.co/docs/transformers/autoclass_tutorial#autotokenizer" rel="nofollow"><code>AutoTokenizer</code></a>.
See <a href="https://huggingface.co/docs/transformers/main_classes/tokenizer#transformers.PreTrainedTokenizerBase.encode" rel="nofollow"><code>PreTrainedTokenizer.encode</code></a> and
<a href="https://huggingface.co/docs/transformers/main_classes/tokenizer#transformers.PreTrainedTokenizerBase.__call__" rel="nofollow"><code>PreTrainedTokenizer.__call__</code></a> for details.
<a href="https://huggingface.co/docs/transformers/glossary#input-ids" rel="nofollow">What are input IDs?</a>`,name:"input_ids"},{anchor:"optimum.onnxruntime.ORTModelForFeatureExtraction.forward.attention_mask",description:`<strong>attention_mask</strong> (<code>torch.Tensor</code> of shape <code>(batch_size, sequence_length)</code>, <em>optional</em>) &#x2014;
Mask to avoid performing attention on padding token indices. Mask values selected in <code>[0, 1]</code>:<ul>
<li>1 for tokens that are <strong>not masked</strong>,</li>
<li>0 for tokens that are <strong>masked</strong>.
<a href="https://huggingface.co/docs/transformers/glossary#attention-mask" rel="nofollow">What are attention masks?</a></li>
</ul>`,name:"attention_mask"},{anchor:"optimum.onnxruntime.ORTModelForFeatureExtraction.forward.token_type_ids",description:`<strong>token_type_ids</strong> (<code>torch.Tensor</code> of shape <code>(batch_size, sequence_length)</code>, <em>optional</em>) &#x2014;
Segment token indices to indicate first and second portions of the inputs. Indices are selected in <code>[0, 1]</code>:<ul>
<li>1 for tokens that are <strong>sentence A</strong>,</li>
<li>0 for tokens that are <strong>sentence B</strong>.
<a href="https://huggingface.co/docs/transformers/glossary#token-type-ids" rel="nofollow">What are token type IDs?</a></li>
</ul>`,name:"token_type_ids"}],source:"https://github.com/huggingface/optimum/blob/vr_200/src/optimum/onnxruntime/modeling_ort.py#L308"}}),je=new Vo({props:{$$slots:{default:[yi]},$$scope:{ctx:j}}}),Ee=new J({props:{anchor:"optimum.onnxruntime.ORTModelForFeatureExtraction.forward.example",$$slots:{default:[qi]},$$scope:{ctx:j}}}),ze=new J({props:{anchor:"optimum.onnxruntime.ORTModelForFeatureExtraction.forward.example-2",$$slots:{default:[ji]},$$scope:{ctx:j}}}),pt=new le({}),ct=new V({props:{name:"class optimum.onnxruntime.ORTModelForQuestionAnswering",anchor:"optimum.onnxruntime.ORTModelForQuestionAnswering",parameters:[{name:"*args",val:""},{name:"**kwargs",val:""}],parametersDescription:[{anchor:"optimum.onnxruntime.ORTModelForQuestionAnswering.config",description:`<strong>config</strong> (<code>transformers.PretrainedConfig</code>) &#x2014; <a href="https://huggingface.co/docs/transformers/main_classes/configuration#transformers.PretrainedConfig" rel="nofollow">PretrainedConfig</a> is the Model configuration class with all the parameters of the model.
Initializing with a config file does not load the weights associated with the model, only the
configuration. Check out the <code>from_pretrained()</code> method to load the model weights.`,name:"config"},{anchor:"optimum.onnxruntime.ORTModelForQuestionAnswering.model",description:'<strong>model</strong> (<code>onnxruntime.InferenceSession</code>) &#x2014; <a href="https://onnxruntime.ai/docs/api/python/api_summary.html#inferencesession" rel="nofollow">onnxruntime.InferenceSession</a> is the main class used to run a model. Check out the <a href="/docs/optimum/pr_200/en/onnxruntime/modeling_ort#optimum.onnxruntime.ORTModel.load_model">load_model()</a> method for more information.',name:"model"}],source:"https://github.com/huggingface/optimum/blob/vr_200/src/optimum/onnxruntime/modeling_ort.py#L380"}}),ut=new V({props:{name:"forward",anchor:"optimum.onnxruntime.ORTModelForQuestionAnswering.forward",parameters:[{name:"input_ids",val:": typing.Optional[torch.Tensor] = None"},{name:"attention_mask",val:": typing.Optional[torch.Tensor] = None"},{name:"token_type_ids",val:": typing.Optional[torch.Tensor] = None"},{name:"**kwargs",val:""}],parametersDescription:[{anchor:"optimum.onnxruntime.ORTModelForQuestionAnswering.forward.input_ids",description:`<strong>input_ids</strong> (<code>torch.Tensor</code> of shape <code>(batch_size, sequence_length)</code>) &#x2014;
Indices of input sequence tokens in the vocabulary.
Indices can be obtained using <a href="https://huggingface.co/docs/transformers/autoclass_tutorial#autotokenizer" rel="nofollow"><code>AutoTokenizer</code></a>.
See <a href="https://huggingface.co/docs/transformers/main_classes/tokenizer#transformers.PreTrainedTokenizerBase.encode" rel="nofollow"><code>PreTrainedTokenizer.encode</code></a> and
<a href="https://huggingface.co/docs/transformers/main_classes/tokenizer#transformers.PreTrainedTokenizerBase.__call__" rel="nofollow"><code>PreTrainedTokenizer.__call__</code></a> for details.
<a href="https://huggingface.co/docs/transformers/glossary#input-ids" rel="nofollow">What are input IDs?</a>`,name:"input_ids"},{anchor:"optimum.onnxruntime.ORTModelForQuestionAnswering.forward.attention_mask",description:`<strong>attention_mask</strong> (<code>torch.Tensor</code> of shape <code>(batch_size, sequence_length)</code>, <em>optional</em>) &#x2014;
Mask to avoid performing attention on padding token indices. Mask values selected in <code>[0, 1]</code>:<ul>
<li>1 for tokens that are <strong>not masked</strong>,</li>
<li>0 for tokens that are <strong>masked</strong>.
<a href="https://huggingface.co/docs/transformers/glossary#attention-mask" rel="nofollow">What are attention masks?</a></li>
</ul>`,name:"attention_mask"},{anchor:"optimum.onnxruntime.ORTModelForQuestionAnswering.forward.token_type_ids",description:`<strong>token_type_ids</strong> (<code>torch.Tensor</code> of shape <code>(batch_size, sequence_length)</code>, <em>optional</em>) &#x2014;
Segment token indices to indicate first and second portions of the inputs. Indices are selected in <code>[0, 1]</code>:<ul>
<li>1 for tokens that are <strong>sentence A</strong>,</li>
<li>0 for tokens that are <strong>sentence B</strong>.
<a href="https://huggingface.co/docs/transformers/glossary#token-type-ids" rel="nofollow">What are token type IDs?</a></li>
</ul>`,name:"token_type_ids"}],source:"https://github.com/huggingface/optimum/blob/vr_200/src/optimum/onnxruntime/modeling_ort.py#L394"}}),Fe=new Vo({props:{$$slots:{default:[Ei]},$$scope:{ctx:j}}}),Ce=new J({props:{anchor:"optimum.onnxruntime.ORTModelForQuestionAnswering.forward.example",$$slots:{default:[zi]},$$scope:{ctx:j}}}),Ae=new J({props:{anchor:"optimum.onnxruntime.ORTModelForQuestionAnswering.forward.example-2",$$slots:{default:[Ri]},$$scope:{ctx:j}}}),ft=new le({}),ht=new V({props:{name:"class optimum.onnxruntime.ORTModelForSequenceClassification",anchor:"optimum.onnxruntime.ORTModelForSequenceClassification",parameters:[{name:"*args",val:""},{name:"**kwargs",val:""}],parametersDescription:[{anchor:"optimum.onnxruntime.ORTModelForSequenceClassification.config",description:`<strong>config</strong> (<code>transformers.PretrainedConfig</code>) &#x2014; <a href="https://huggingface.co/docs/transformers/main_classes/configuration#transformers.PretrainedConfig" rel="nofollow">PretrainedConfig</a> is the Model configuration class with all the parameters of the model.
Initializing with a config file does not load the weights associated with the model, only the
configuration. Check out the <code>from_pretrained()</code> method to load the model weights.`,name:"config"},{anchor:"optimum.onnxruntime.ORTModelForSequenceClassification.model",description:'<strong>model</strong> (<code>onnxruntime.InferenceSession</code>) &#x2014; <a href="https://onnxruntime.ai/docs/api/python/api_summary.html#inferencesession" rel="nofollow">onnxruntime.InferenceSession</a> is the main class used to run a model. Check out the <a href="/docs/optimum/pr_200/en/onnxruntime/modeling_ort#optimum.onnxruntime.ORTModel.load_model">load_model()</a> method for more information.',name:"model"}],source:"https://github.com/huggingface/optimum/blob/vr_200/src/optimum/onnxruntime/modeling_ort.py#L481"}}),_t=new V({props:{name:"forward",anchor:"optimum.onnxruntime.ORTModelForSequenceClassification.forward",parameters:[{name:"input_ids",val:": typing.Optional[torch.Tensor] = None"},{name:"attention_mask",val:": typing.Optional[torch.Tensor] = None"},{name:"token_type_ids",val:": typing.Optional[torch.Tensor] = None"},{name:"**kwargs",val:""}],parametersDescription:[{anchor:"optimum.onnxruntime.ORTModelForSequenceClassification.forward.input_ids",description:`<strong>input_ids</strong> (<code>torch.Tensor</code> of shape <code>(batch_size, sequence_length)</code>) &#x2014;
Indices of input sequence tokens in the vocabulary.
Indices can be obtained using <a href="https://huggingface.co/docs/transformers/autoclass_tutorial#autotokenizer" rel="nofollow"><code>AutoTokenizer</code></a>.
See <a href="https://huggingface.co/docs/transformers/main_classes/tokenizer#transformers.PreTrainedTokenizerBase.encode" rel="nofollow"><code>PreTrainedTokenizer.encode</code></a> and
<a href="https://huggingface.co/docs/transformers/main_classes/tokenizer#transformers.PreTrainedTokenizerBase.__call__" rel="nofollow"><code>PreTrainedTokenizer.__call__</code></a> for details.
<a href="https://huggingface.co/docs/transformers/glossary#input-ids" rel="nofollow">What are input IDs?</a>`,name:"input_ids"},{anchor:"optimum.onnxruntime.ORTModelForSequenceClassification.forward.attention_mask",description:`<strong>attention_mask</strong> (<code>torch.Tensor</code> of shape <code>(batch_size, sequence_length)</code>, <em>optional</em>) &#x2014;
Mask to avoid performing attention on padding token indices. Mask values selected in <code>[0, 1]</code>:<ul>
<li>1 for tokens that are <strong>not masked</strong>,</li>
<li>0 for tokens that are <strong>masked</strong>.
<a href="https://huggingface.co/docs/transformers/glossary#attention-mask" rel="nofollow">What are attention masks?</a></li>
</ul>`,name:"attention_mask"},{anchor:"optimum.onnxruntime.ORTModelForSequenceClassification.forward.token_type_ids",description:`<strong>token_type_ids</strong> (<code>torch.Tensor</code> of shape <code>(batch_size, sequence_length)</code>, <em>optional</em>) &#x2014;
Segment token indices to indicate first and second portions of the inputs. Indices are selected in <code>[0, 1]</code>:<ul>
<li>1 for tokens that are <strong>sentence A</strong>,</li>
<li>0 for tokens that are <strong>sentence B</strong>.
<a href="https://huggingface.co/docs/transformers/glossary#token-type-ids" rel="nofollow">What are token type IDs?</a></li>
</ul>`,name:"token_type_ids"}],source:"https://github.com/huggingface/optimum/blob/vr_200/src/optimum/onnxruntime/modeling_ort.py#L496"}}),Ne=new Vo({props:{$$slots:{default:[Fi]},$$scope:{ctx:j}}}),Se=new J({props:{anchor:"optimum.onnxruntime.ORTModelForSequenceClassification.forward.example",$$slots:{default:[Ci]},$$scope:{ctx:j}}}),Ie=new J({props:{anchor:"optimum.onnxruntime.ORTModelForSequenceClassification.forward.example-2",$$slots:{default:[Ai]},$$scope:{ctx:j}}}),De=new J({props:{anchor:"optimum.onnxruntime.ORTModelForSequenceClassification.forward.example-3",$$slots:{default:[Pi]},$$scope:{ctx:j}}}),$t=new le({}),kt=new V({props:{name:"class optimum.onnxruntime.ORTModelForTokenClassification",anchor:"optimum.onnxruntime.ORTModelForTokenClassification",parameters:[{name:"*args",val:""},{name:"**kwargs",val:""}],parametersDescription:[{anchor:"optimum.onnxruntime.ORTModelForTokenClassification.config",description:`<strong>config</strong> (<code>transformers.PretrainedConfig</code>) &#x2014; <a href="https://huggingface.co/docs/transformers/main_classes/configuration#transformers.PretrainedConfig" rel="nofollow">PretrainedConfig</a> is the Model configuration class with all the parameters of the model.
Initializing with a config file does not load the weights associated with the model, only the
configuration. Check out the <code>from_pretrained()</code> method to load the model weights.`,name:"config"},{anchor:"optimum.onnxruntime.ORTModelForTokenClassification.model",description:'<strong>model</strong> (<code>onnxruntime.InferenceSession</code>) &#x2014; <a href="https://onnxruntime.ai/docs/api/python/api_summary.html#inferencesession" rel="nofollow">onnxruntime.InferenceSession</a> is the main class used to run a model. Check out the <a href="/docs/optimum/pr_200/en/onnxruntime/modeling_ort#optimum.onnxruntime.ORTModel.load_model">load_model()</a> method for more information.',name:"model"}],source:"https://github.com/huggingface/optimum/blob/vr_200/src/optimum/onnxruntime/modeling_ort.py#L568"}}),vt=new V({props:{name:"forward",anchor:"optimum.onnxruntime.ORTModelForTokenClassification.forward",parameters:[{name:"input_ids",val:": typing.Optional[torch.Tensor] = None"},{name:"attention_mask",val:": typing.Optional[torch.Tensor] = None"},{name:"token_type_ids",val:": typing.Optional[torch.Tensor] = None"},{name:"**kwargs",val:""}],parametersDescription:[{anchor:"optimum.onnxruntime.ORTModelForTokenClassification.forward.input_ids",description:`<strong>input_ids</strong> (<code>torch.Tensor</code> of shape <code>(batch_size, sequence_length)</code>) &#x2014;
Indices of input sequence tokens in the vocabulary.
Indices can be obtained using <a href="https://huggingface.co/docs/transformers/autoclass_tutorial#autotokenizer" rel="nofollow"><code>AutoTokenizer</code></a>.
See <a href="https://huggingface.co/docs/transformers/main_classes/tokenizer#transformers.PreTrainedTokenizerBase.encode" rel="nofollow"><code>PreTrainedTokenizer.encode</code></a> and
<a href="https://huggingface.co/docs/transformers/main_classes/tokenizer#transformers.PreTrainedTokenizerBase.__call__" rel="nofollow"><code>PreTrainedTokenizer.__call__</code></a> for details.
<a href="https://huggingface.co/docs/transformers/glossary#input-ids" rel="nofollow">What are input IDs?</a>`,name:"input_ids"},{anchor:"optimum.onnxruntime.ORTModelForTokenClassification.forward.attention_mask",description:`<strong>attention_mask</strong> (<code>torch.Tensor</code> of shape <code>(batch_size, sequence_length)</code>, <em>optional</em>) &#x2014;
Mask to avoid performing attention on padding token indices. Mask values selected in <code>[0, 1]</code>:<ul>
<li>1 for tokens that are <strong>not masked</strong>,</li>
<li>0 for tokens that are <strong>masked</strong>.
<a href="https://huggingface.co/docs/transformers/glossary#attention-mask" rel="nofollow">What are attention masks?</a></li>
</ul>`,name:"attention_mask"},{anchor:"optimum.onnxruntime.ORTModelForTokenClassification.forward.token_type_ids",description:`<strong>token_type_ids</strong> (<code>torch.Tensor</code> of shape <code>(batch_size, sequence_length)</code>, <em>optional</em>) &#x2014;
Segment token indices to indicate first and second portions of the inputs. Indices are selected in <code>[0, 1]</code>:<ul>
<li>1 for tokens that are <strong>sentence A</strong>,</li>
<li>0 for tokens that are <strong>sentence B</strong>.
<a href="https://huggingface.co/docs/transformers/glossary#token-type-ids" rel="nofollow">What are token type IDs?</a></li>
</ul>`,name:"token_type_ids"}],source:"https://github.com/huggingface/optimum/blob/vr_200/src/optimum/onnxruntime/modeling_ort.py#L582"}}),He=new Vo({props:{$$slots:{default:[Ni]},$$scope:{ctx:j}}}),Qe=new J({props:{anchor:"optimum.onnxruntime.ORTModelForTokenClassification.forward.example",$$slots:{default:[Si]},$$scope:{ctx:j}}}),Xe=new J({props:{anchor:"optimum.onnxruntime.ORTModelForTokenClassification.forward.example-2",$$slots:{default:[Ii]},$$scope:{ctx:j}}}),xt=new le({}),Tt=new V({props:{name:"class optimum.onnxruntime.ORTModelForCausalLM",anchor:"optimum.onnxruntime.ORTModelForCausalLM",parameters:[{name:"*args",val:""},{name:"**kwargs",val:""}],parametersDescription:[{anchor:"optimum.onnxruntime.ORTModelForCausalLM.config",description:`<strong>config</strong> (<code>transformers.PretrainedConfig</code>) &#x2014; <a href="https://huggingface.co/docs/transformers/main_classes/configuration#transformers.PretrainedConfig" rel="nofollow">PretrainedConfig</a> is the Model configuration class with all the parameters of the model.
Initializing with a config file does not load the weights associated with the model, only the
configuration. Check out the <code>from_pretrained()</code> method to load the model weights.`,name:"config"},{anchor:"optimum.onnxruntime.ORTModelForCausalLM.model",description:'<strong>model</strong> (<code>onnxruntime.InferenceSession</code>) &#x2014; <a href="https://onnxruntime.ai/docs/api/python/api_summary.html#inferencesession" rel="nofollow">onnxruntime.InferenceSession</a> is the main class used to run a model. Check out the <a href="/docs/optimum/pr_200/en/onnxruntime/modeling_ort#optimum.onnxruntime.ORTModel.load_model">load_model()</a> method for more information.',name:"model"}],source:"https://github.com/huggingface/optimum/blob/vr_200/src/optimum/onnxruntime/modeling_ort.py#L652"}}),Mt=new V({props:{name:"forward",anchor:"optimum.onnxruntime.ORTModelForCausalLM.forward",parameters:[{name:"input_ids",val:": typing.Optional[torch.Tensor] = None"},{name:"attention_mask",val:": typing.Optional[torch.Tensor] = None"},{name:"**kwargs",val:""}],parametersDescription:[{anchor:"optimum.onnxruntime.ORTModelForCausalLM.forward.input_ids",description:`<strong>input_ids</strong> (<code>torch.Tensor</code> of shape <code>(batch_size, sequence_length)</code>) &#x2014;
Indices of input sequence tokens in the vocabulary.
Indices can be obtained using <a href="https://huggingface.co/docs/transformers/autoclass_tutorial#autotokenizer" rel="nofollow"><code>AutoTokenizer</code></a>.
See <a href="https://huggingface.co/docs/transformers/main_classes/tokenizer#transformers.PreTrainedTokenizerBase.encode" rel="nofollow"><code>PreTrainedTokenizer.encode</code></a> and
<a href="https://huggingface.co/docs/transformers/main_classes/tokenizer#transformers.PreTrainedTokenizerBase.__call__" rel="nofollow"><code>PreTrainedTokenizer.__call__</code></a> for details.
<a href="https://huggingface.co/docs/transformers/glossary#input-ids" rel="nofollow">What are input IDs?</a>`,name:"input_ids"},{anchor:"optimum.onnxruntime.ORTModelForCausalLM.forward.attention_mask",description:`<strong>attention_mask</strong> (<code>torch.Tensor</code> of shape <code>(batch_size, sequence_length)</code>, <em>optional</em>) &#x2014;
Mask to avoid performing attention on padding token indices. Mask values selected in <code>[0, 1]</code>:<ul>
<li>1 for tokens that are <strong>not masked</strong>,</li>
<li>0 for tokens that are <strong>masked</strong>.
<a href="https://huggingface.co/docs/transformers/glossary#attention-mask" rel="nofollow">What are attention masks?</a></li>
</ul>`,name:"attention_mask"},{anchor:"optimum.onnxruntime.ORTModelForCausalLM.forward.token_type_ids",description:`<strong>token_type_ids</strong> (<code>torch.Tensor</code> of shape <code>(batch_size, sequence_length)</code>, <em>optional</em>) &#x2014;
Segment token indices to indicate first and second portions of the inputs. Indices are selected in <code>[0, 1]</code>:<ul>
<li>1 for tokens that are <strong>sentence A</strong>,</li>
<li>0 for tokens that are <strong>sentence B</strong>.
<a href="https://huggingface.co/docs/transformers/glossary#token-type-ids" rel="nofollow">What are token type IDs?</a></li>
</ul>`,name:"token_type_ids"}],source:"https://github.com/huggingface/optimum/blob/vr_200/src/optimum/onnxruntime/modeling_ort.py#L684"}}),Be=new Vo({props:{$$slots:{default:[Di]},$$scope:{ctx:j}}}),Ge=new J({props:{anchor:"optimum.onnxruntime.ORTModelForCausalLM.forward.example",$$slots:{default:[Li]},$$scope:{ctx:j}}}),Ve=new J({props:{anchor:"optimum.onnxruntime.ORTModelForCausalLM.forward.example-2",$$slots:{default:[Hi]},$$scope:{ctx:j}}}),{c(){n=r("meta"),g=f(),d=r("h1"),u=r("a"),_=r("span"),M(s.$$.fragment),i=f(),x=r("span"),c=m("Optimum Inference with ONNX Runtime"),w=f(),E=r("p"),z=m(`Optimum is a utility package for building and running inference with accelerated runtime like ONNX Runtime.
Optimum can be used to load optimized models from the `),R=r("a"),jt=m("Hugging Face Hub"),Et=m(` and create pipelines
to run accelerated inference without rewriting your APIs.`),Uo=f(),me=r("h2"),Te=r("a"),Dt=r("span"),M(Je.$$.fragment),Fn=f(),Lt=r("span"),Cn=m("Switching from Transformers to Optimum Inference"),Jo=f(),I=r("p"),An=m("The Optimum Inference models are API compatible with Hugging Face Transformers models. This means you can just replace your "),Ht=r("code"),Pn=m("AutoModelForXxx"),Nn=m(" class with the corresponding "),Qt=r("code"),Sn=m("ORTModelForXxx"),In=m(" class in "),Xt=r("code"),Dn=m("optimum"),Ln=m(". For example, this is how you can use a question answering model in "),Wt=r("code"),Hn=m("optimum"),Qn=m(":"),Yo=f(),M(Ye.$$.fragment),Zo=f(),Z=r("p"),Xn=m("Optimum Inference also includes methods to convert vanilla Transformers models to optimized ones. Simply pass "),Bt=r("code"),Wn=m("from_transformers=True"),Bn=m(" to the "),Gt=r("code"),Gn=m("from_pretrained()"),Vn=m(" method, and your model will be loaded and converted to ONNX on-the-fly:"),Ko=f(),M(Ze.$$.fragment),en=f(),be=r("p"),Un=m("You can find a complete walkhrough Optimum Inference for ONNX Runtime in this "),zt=r("a"),Jn=m("notebook"),Yn=m("."),tn=f(),pe=r("h3"),Me=r("a"),Vt=r("span"),M(Ke.$$.fragment),Zn=f(),Ut=r("span"),Kn=m("Working with the Hugging Face Model Hub"),on=f(),B=r("p"),es=m("The Optimum model classes like "),Rt=r("a"),ts=m("ORTModelForSequenceClassification"),os=m(" are integrated with the "),et=r("a"),ns=m("Hugging Face Model Hub"),ss=m(`, which means you can not only
load model from the Hub, but also push your models to the Hub with `),Jt=r("code"),rs=m("push_to_hub()"),as=m(` method. Below is an example which downloads a vanilla Transformers model
from the Hub and converts it to an optimum onnxruntime model and pushes it back into a new repository.`),nn=f(),M(tt.$$.fragment),sn=f(),ce=r("h2"),Oe=r("a"),Yt=r("span"),M(ot.$$.fragment),is=f(),Zt=r("span"),ls=m("ORTModel"),rn=f(),U=r("div"),M(nt.$$.fragment),ms=f(),st=r("p"),ps=m(`Base ORTModel class for implementing models using ONNX Runtime. The ORTModel implements generic methods for interacting
with the Hugging Face Hub as well as exporting vanilla transformers models to ONNX using `),Kt=r("code"),cs=m("transformers.onnx"),ds=m(` toolchain.
The ORTModel implements additionally generic methods for optimizing and quantizing Onnx models.`),us=f(),ye=r("div"),M(rt.$$.fragment),fs=f(),Ft=r("p"),hs=m("loads ONNX Inference session with Provider. Default Provider is if CUDAExecutionProvider GPU available else "),eo=r("code"),gs=m("CPUExecutionProvider"),an=f(),de=r("h2"),qe=r("a"),to=r("span"),M(at.$$.fragment),_s=f(),oo=r("span"),$s=m("ORTModelForFeatureExtraction"),ln=f(),C=r("div"),M(it.$$.fragment),ks=f(),no=r("p"),ws=m("Onnx Model with a MaskedLMOutput for feature-extraction tasks."),vs=f(),lt=r("p"),xs=m("This model inherits from [~"),so=r("code"),Ts=m("onnxruntime.modeling_ort.ORTModel"),bs=m(`]. Check the superclass documentation for the generic methods the
library implements for all its model (such as downloading or saving)`),Ms=f(),ro=r("p"),Os=m("Feature Extraction model for ONNX."),ys=f(),D=r("div"),M(mt.$$.fragment),qs=f(),ue=r("p"),js=m("The "),ao=r("code"),Es=m("ORTModelForFeatureExtraction"),zs=m(" forward method, overrides the "),io=r("code"),Rs=m("__call__"),Fs=m(" special method."),Cs=f(),M(je.$$.fragment),As=f(),M(Ee.$$.fragment),Ps=f(),M(ze.$$.fragment),mn=f(),fe=r("h2"),Re=r("a"),lo=r("span"),M(pt.$$.fragment),Ns=f(),mo=r("span"),Ss=m("ORTModelForQuestionAnswering"),pn=f(),A=r("div"),M(ct.$$.fragment),Is=f(),po=r("p"),Ds=m("Onnx Model with a QuestionAnsweringModelOutput for extractive question-answering tasks like SQuAD."),Ls=f(),dt=r("p"),Hs=m("This model inherits from [~"),co=r("code"),Qs=m("onnxruntime.modeling_ort.ORTModel"),Xs=m(`]. Check the superclass documentation for the generic methods the
library implements for all its model (such as downloading or saving)`),Ws=f(),uo=r("p"),Bs=m("Question Answering model for ONNX."),Gs=f(),L=r("div"),M(ut.$$.fragment),Vs=f(),he=r("p"),Us=m("The "),fo=r("code"),Js=m("ORTModelForQuestionAnswering"),Ys=m(" forward method, overrides the "),ho=r("code"),Zs=m("__call__"),Ks=m(" special method."),er=f(),M(Fe.$$.fragment),tr=f(),M(Ce.$$.fragment),or=f(),M(Ae.$$.fragment),cn=f(),ge=r("h2"),Pe=r("a"),go=r("span"),M(ft.$$.fragment),nr=f(),_o=r("span"),sr=m("ORTModelForSequenceClassification"),dn=f(),P=r("div"),M(ht.$$.fragment),rr=f(),$o=r("p"),ar=m(`Onnx Model with a sequence classification/regression head on top (a linear layer on top of the
pooled output) e.g. for GLUE tasks.`),ir=f(),gt=r("p"),lr=m("This model inherits from [~"),ko=r("code"),mr=m("onnxruntime.modeling_ort.ORTModel"),pr=m(`]. Check the superclass documentation for the generic methods the
library implements for all its model (such as downloading or saving)`),cr=f(),wo=r("p"),dr=m("Sequence Classification model for ONNX."),ur=f(),F=r("div"),M(_t.$$.fragment),fr=f(),_e=r("p"),hr=m("The "),vo=r("code"),gr=m("ORTModelForSequenceClassification"),_r=m(" forward method, overrides the "),xo=r("code"),$r=m("__call__"),kr=m(" special method."),wr=f(),M(Ne.$$.fragment),vr=f(),M(Se.$$.fragment),xr=f(),M(Ie.$$.fragment),Tr=f(),M(De.$$.fragment),un=f(),$e=r("h2"),Le=r("a"),To=r("span"),M($t.$$.fragment),br=f(),bo=r("span"),Mr=m("ORTModelForTokenClassification"),fn=f(),N=r("div"),M(kt.$$.fragment),Or=f(),Mo=r("p"),yr=m(`Onnx Model with a token classification head on top (a linear layer on top of the hidden-states output) e.g.
for Named-Entity-Recognition (NER) tasks.`),qr=f(),wt=r("p"),jr=m("This model inherits from [~"),Oo=r("code"),Er=m("onnxruntime.modeling_ort.ORTModel"),zr=m(`]. Check the superclass documentation for the generic methods the
library implements for all its model (such as downloading or saving)`),Rr=f(),yo=r("p"),Fr=m("Token Classification model for ONNX."),Cr=f(),H=r("div"),M(vt.$$.fragment),Ar=f(),ke=r("p"),Pr=m("The "),qo=r("code"),Nr=m("ORTModelForTokenClassification"),Sr=m(" forward method, overrides the "),jo=r("code"),Ir=m("__call__"),Dr=m(" special method."),Lr=f(),M(He.$$.fragment),Hr=f(),M(Qe.$$.fragment),Qr=f(),M(Xe.$$.fragment),hn=f(),we=r("h2"),We=r("a"),Eo=r("span"),M(xt.$$.fragment),Xr=f(),zo=r("span"),Wr=m("ORTModelForCausalLM"),gn=f(),S=r("div"),M(Tt.$$.fragment),Br=f(),Ro=r("p"),Gr=m(`Onnx Model with a causal language modeling head on top (linear layer with weights tied to the input
embeddings).`),Vr=f(),bt=r("p"),Ur=m("This model inherits from [~"),Fo=r("code"),Jr=m("onnxruntime.modeling_ort.ORTModel"),Yr=m(`]. Check the superclass documentation for the generic methods the
library implements for all its model (such as downloading or saving)`),Zr=f(),Co=r("p"),Kr=m("Causal LM model for ONNX."),ea=f(),Q=r("div"),M(Mt.$$.fragment),ta=f(),ve=r("p"),oa=m("The "),Ao=r("code"),na=m("ORTModelForCausalLM"),sa=m(" forward method, overrides the "),Po=r("code"),ra=m("__call__"),aa=m(" special method."),ia=f(),M(Be.$$.fragment),la=f(),M(Ge.$$.fragment),ma=f(),M(Ve.$$.fragment),this.h()},l(t){const $=Ti('[data-svelte="svelte-1phssyn"]',document.head);n=a($,"META",{name:!0,content:!0}),$.forEach(o),g=h(t),d=a(t,"H1",{class:!0});var Ot=l(d);u=a(Ot,"A",{id:!0,class:!0,href:!0});var No=l(u);_=a(No,"SPAN",{});var So=l(_);O(s.$$.fragment,So),So.forEach(o),No.forEach(o),i=h(Ot),x=a(Ot,"SPAN",{});var Io=l(x);c=p(Io,"Optimum Inference with ONNX Runtime"),Io.forEach(o),Ot.forEach(o),w=h(t),E=a(t,"P",{});var yt=l(E);z=p(yt,`Optimum is a utility package for building and running inference with accelerated runtime like ONNX Runtime.
Optimum can be used to load optimized models from the `),R=a(yt,"A",{href:!0});var Do=l(R);jt=p(Do,"Hugging Face Hub"),Do.forEach(o),Et=p(yt,` and create pipelines
to run accelerated inference without rewriting your APIs.`),yt.forEach(o),Uo=h(t),me=a(t,"H2",{class:!0});var qt=l(me);Te=a(qt,"A",{id:!0,class:!0,href:!0});var Lo=l(Te);Dt=a(Lo,"SPAN",{});var Ho=l(Dt);O(Je.$$.fragment,Ho),Ho.forEach(o),Lo.forEach(o),Fn=h(qt),Lt=a(qt,"SPAN",{});var Qo=l(Lt);Cn=p(Qo,"Switching from Transformers to Optimum Inference"),Qo.forEach(o),qt.forEach(o),Jo=h(t),I=a(t,"P",{});var W=l(I);An=p(W,"The Optimum Inference models are API compatible with Hugging Face Transformers models. This means you can just replace your "),Ht=a(W,"CODE",{});var Xo=l(Ht);Pn=p(Xo,"AutoModelForXxx"),Xo.forEach(o),Nn=p(W," class with the corresponding "),Qt=a(W,"CODE",{});var Wo=l(Qt);Sn=p(Wo,"ORTModelForXxx"),Wo.forEach(o),In=p(W," class in "),Xt=a(W,"CODE",{});var Bo=l(Xt);Dn=p(Bo,"optimum"),Bo.forEach(o),Ln=p(W,". For example, this is how you can use a question answering model in "),Wt=a(W,"CODE",{});var Go=l(Wt);Hn=p(Go,"optimum"),Go.forEach(o),Qn=p(W,":"),W.forEach(o),Yo=h(t),O(Ye.$$.fragment,t),Zo=h(t),Z=a(t,"P",{});var xe=l(Z);Xn=p(xe,"Optimum Inference also includes methods to convert vanilla Transformers models to optimized ones. Simply pass "),Bt=a(xe,"CODE",{});var ca=l(Bt);Wn=p(ca,"from_transformers=True"),ca.forEach(o),Bn=p(xe," to the "),Gt=a(xe,"CODE",{});var da=l(Gt);Gn=p(da,"from_pretrained()"),da.forEach(o),Vn=p(xe," method, and your model will be loaded and converted to ONNX on-the-fly:"),xe.forEach(o),Ko=h(t),O(Ze.$$.fragment,t),en=h(t),be=a(t,"P",{});var $n=l(be);Un=p($n,"You can find a complete walkhrough Optimum Inference for ONNX Runtime in this "),zt=a($n,"A",{href:!0});var ua=l(zt);Jn=p(ua,"notebook"),ua.forEach(o),Yn=p($n,"."),$n.forEach(o),tn=h(t),pe=a(t,"H3",{class:!0});var kn=l(pe);Me=a(kn,"A",{id:!0,class:!0,href:!0});var fa=l(Me);Vt=a(fa,"SPAN",{});var ha=l(Vt);O(Ke.$$.fragment,ha),ha.forEach(o),fa.forEach(o),Zn=h(kn),Ut=a(kn,"SPAN",{});var ga=l(Ut);Kn=p(ga,"Working with the Hugging Face Model Hub"),ga.forEach(o),kn.forEach(o),on=h(t),B=a(t,"P",{});var Ue=l(B);es=p(Ue,"The Optimum model classes like "),Rt=a(Ue,"A",{href:!0});var _a=l(Rt);ts=p(_a,"ORTModelForSequenceClassification"),_a.forEach(o),os=p(Ue," are integrated with the "),et=a(Ue,"A",{href:!0,rel:!0});var $a=l(et);ns=p($a,"Hugging Face Model Hub"),$a.forEach(o),ss=p(Ue,`, which means you can not only
load model from the Hub, but also push your models to the Hub with `),Jt=a(Ue,"CODE",{});var ka=l(Jt);rs=p(ka,"push_to_hub()"),ka.forEach(o),as=p(Ue,` method. Below is an example which downloads a vanilla Transformers model
from the Hub and converts it to an optimum onnxruntime model and pushes it back into a new repository.`),Ue.forEach(o),nn=h(t),O(tt.$$.fragment,t),sn=h(t),ce=a(t,"H2",{class:!0});var wn=l(ce);Oe=a(wn,"A",{id:!0,class:!0,href:!0});var wa=l(Oe);Yt=a(wa,"SPAN",{});var va=l(Yt);O(ot.$$.fragment,va),va.forEach(o),wa.forEach(o),is=h(wn),Zt=a(wn,"SPAN",{});var xa=l(Zt);ls=p(xa,"ORTModel"),xa.forEach(o),wn.forEach(o),rn=h(t),U=a(t,"DIV",{class:!0});var Ct=l(U);O(nt.$$.fragment,Ct),ms=h(Ct),st=a(Ct,"P",{});var vn=l(st);ps=p(vn,`Base ORTModel class for implementing models using ONNX Runtime. The ORTModel implements generic methods for interacting
with the Hugging Face Hub as well as exporting vanilla transformers models to ONNX using `),Kt=a(vn,"CODE",{});var Ta=l(Kt);cs=p(Ta,"transformers.onnx"),Ta.forEach(o),ds=p(vn,` toolchain.
The ORTModel implements additionally generic methods for optimizing and quantizing Onnx models.`),vn.forEach(o),us=h(Ct),ye=a(Ct,"DIV",{class:!0});var xn=l(ye);O(rt.$$.fragment,xn),fs=h(xn),Ft=a(xn,"P",{});var pa=l(Ft);hs=p(pa,"loads ONNX Inference session with Provider. Default Provider is if CUDAExecutionProvider GPU available else "),eo=a(pa,"CODE",{});var ba=l(eo);gs=p(ba,"CPUExecutionProvider"),ba.forEach(o),pa.forEach(o),xn.forEach(o),Ct.forEach(o),an=h(t),de=a(t,"H2",{class:!0});var Tn=l(de);qe=a(Tn,"A",{id:!0,class:!0,href:!0});var Ma=l(qe);to=a(Ma,"SPAN",{});var Oa=l(to);O(at.$$.fragment,Oa),Oa.forEach(o),Ma.forEach(o),_s=h(Tn),oo=a(Tn,"SPAN",{});var ya=l(oo);$s=p(ya,"ORTModelForFeatureExtraction"),ya.forEach(o),Tn.forEach(o),ln=h(t),C=a(t,"DIV",{class:!0});var K=l(C);O(it.$$.fragment,K),ks=h(K),no=a(K,"P",{});var qa=l(no);ws=p(qa,"Onnx Model with a MaskedLMOutput for feature-extraction tasks."),qa.forEach(o),vs=h(K),lt=a(K,"P",{});var bn=l(lt);xs=p(bn,"This model inherits from [~"),so=a(bn,"CODE",{});var ja=l(so);Ts=p(ja,"onnxruntime.modeling_ort.ORTModel"),ja.forEach(o),bs=p(bn,`]. Check the superclass documentation for the generic methods the
library implements for all its model (such as downloading or saving)`),bn.forEach(o),Ms=h(K),ro=a(K,"P",{});var Ea=l(ro);Os=p(Ea,"Feature Extraction model for ONNX."),Ea.forEach(o),ys=h(K),D=a(K,"DIV",{class:!0});var ee=l(D);O(mt.$$.fragment,ee),qs=h(ee),ue=a(ee,"P",{});var At=l(ue);js=p(At,"The "),ao=a(At,"CODE",{});var za=l(ao);Es=p(za,"ORTModelForFeatureExtraction"),za.forEach(o),zs=p(At," forward method, overrides the "),io=a(At,"CODE",{});var Ra=l(io);Rs=p(Ra,"__call__"),Ra.forEach(o),Fs=p(At," special method."),At.forEach(o),Cs=h(ee),O(je.$$.fragment,ee),As=h(ee),O(Ee.$$.fragment,ee),Ps=h(ee),O(ze.$$.fragment,ee),ee.forEach(o),K.forEach(o),mn=h(t),fe=a(t,"H2",{class:!0});var Mn=l(fe);Re=a(Mn,"A",{id:!0,class:!0,href:!0});var Fa=l(Re);lo=a(Fa,"SPAN",{});var Ca=l(lo);O(pt.$$.fragment,Ca),Ca.forEach(o),Fa.forEach(o),Ns=h(Mn),mo=a(Mn,"SPAN",{});var Aa=l(mo);Ss=p(Aa,"ORTModelForQuestionAnswering"),Aa.forEach(o),Mn.forEach(o),pn=h(t),A=a(t,"DIV",{class:!0});var te=l(A);O(ct.$$.fragment,te),Is=h(te),po=a(te,"P",{});var Pa=l(po);Ds=p(Pa,"Onnx Model with a QuestionAnsweringModelOutput for extractive question-answering tasks like SQuAD."),Pa.forEach(o),Ls=h(te),dt=a(te,"P",{});var On=l(dt);Hs=p(On,"This model inherits from [~"),co=a(On,"CODE",{});var Na=l(co);Qs=p(Na,"onnxruntime.modeling_ort.ORTModel"),Na.forEach(o),Xs=p(On,`]. Check the superclass documentation for the generic methods the
library implements for all its model (such as downloading or saving)`),On.forEach(o),Ws=h(te),uo=a(te,"P",{});var Sa=l(uo);Bs=p(Sa,"Question Answering model for ONNX."),Sa.forEach(o),Gs=h(te),L=a(te,"DIV",{class:!0});var oe=l(L);O(ut.$$.fragment,oe),Vs=h(oe),he=a(oe,"P",{});var Pt=l(he);Us=p(Pt,"The "),fo=a(Pt,"CODE",{});var Ia=l(fo);Js=p(Ia,"ORTModelForQuestionAnswering"),Ia.forEach(o),Ys=p(Pt," forward method, overrides the "),ho=a(Pt,"CODE",{});var Da=l(ho);Zs=p(Da,"__call__"),Da.forEach(o),Ks=p(Pt," special method."),Pt.forEach(o),er=h(oe),O(Fe.$$.fragment,oe),tr=h(oe),O(Ce.$$.fragment,oe),or=h(oe),O(Ae.$$.fragment,oe),oe.forEach(o),te.forEach(o),cn=h(t),ge=a(t,"H2",{class:!0});var yn=l(ge);Pe=a(yn,"A",{id:!0,class:!0,href:!0});var La=l(Pe);go=a(La,"SPAN",{});var Ha=l(go);O(ft.$$.fragment,Ha),Ha.forEach(o),La.forEach(o),nr=h(yn),_o=a(yn,"SPAN",{});var Qa=l(_o);sr=p(Qa,"ORTModelForSequenceClassification"),Qa.forEach(o),yn.forEach(o),dn=h(t),P=a(t,"DIV",{class:!0});var ne=l(P);O(ht.$$.fragment,ne),rr=h(ne),$o=a(ne,"P",{});var Xa=l($o);ar=p(Xa,`Onnx Model with a sequence classification/regression head on top (a linear layer on top of the
pooled output) e.g. for GLUE tasks.`),Xa.forEach(o),ir=h(ne),gt=a(ne,"P",{});var qn=l(gt);lr=p(qn,"This model inherits from [~"),ko=a(qn,"CODE",{});var Wa=l(ko);mr=p(Wa,"onnxruntime.modeling_ort.ORTModel"),Wa.forEach(o),pr=p(qn,`]. Check the superclass documentation for the generic methods the
library implements for all its model (such as downloading or saving)`),qn.forEach(o),cr=h(ne),wo=a(ne,"P",{});var Ba=l(wo);dr=p(Ba,"Sequence Classification model for ONNX."),Ba.forEach(o),ur=h(ne),F=a(ne,"DIV",{class:!0});var G=l(F);O(_t.$$.fragment,G),fr=h(G),_e=a(G,"P",{});var Nt=l(_e);hr=p(Nt,"The "),vo=a(Nt,"CODE",{});var Ga=l(vo);gr=p(Ga,"ORTModelForSequenceClassification"),Ga.forEach(o),_r=p(Nt," forward method, overrides the "),xo=a(Nt,"CODE",{});var Va=l(xo);$r=p(Va,"__call__"),Va.forEach(o),kr=p(Nt," special method."),Nt.forEach(o),wr=h(G),O(Ne.$$.fragment,G),vr=h(G),O(Se.$$.fragment,G),xr=h(G),O(Ie.$$.fragment,G),Tr=h(G),O(De.$$.fragment,G),G.forEach(o),ne.forEach(o),un=h(t),$e=a(t,"H2",{class:!0});var jn=l($e);Le=a(jn,"A",{id:!0,class:!0,href:!0});var Ua=l(Le);To=a(Ua,"SPAN",{});var Ja=l(To);O($t.$$.fragment,Ja),Ja.forEach(o),Ua.forEach(o),br=h(jn),bo=a(jn,"SPAN",{});var Ya=l(bo);Mr=p(Ya,"ORTModelForTokenClassification"),Ya.forEach(o),jn.forEach(o),fn=h(t),N=a(t,"DIV",{class:!0});var se=l(N);O(kt.$$.fragment,se),Or=h(se),Mo=a(se,"P",{});var Za=l(Mo);yr=p(Za,`Onnx Model with a token classification head on top (a linear layer on top of the hidden-states output) e.g.
for Named-Entity-Recognition (NER) tasks.`),Za.forEach(o),qr=h(se),wt=a(se,"P",{});var En=l(wt);jr=p(En,"This model inherits from [~"),Oo=a(En,"CODE",{});var Ka=l(Oo);Er=p(Ka,"onnxruntime.modeling_ort.ORTModel"),Ka.forEach(o),zr=p(En,`]. Check the superclass documentation for the generic methods the
library implements for all its model (such as downloading or saving)`),En.forEach(o),Rr=h(se),yo=a(se,"P",{});var ei=l(yo);Fr=p(ei,"Token Classification model for ONNX."),ei.forEach(o),Cr=h(se),H=a(se,"DIV",{class:!0});var re=l(H);O(vt.$$.fragment,re),Ar=h(re),ke=a(re,"P",{});var St=l(ke);Pr=p(St,"The "),qo=a(St,"CODE",{});var ti=l(qo);Nr=p(ti,"ORTModelForTokenClassification"),ti.forEach(o),Sr=p(St," forward method, overrides the "),jo=a(St,"CODE",{});var oi=l(jo);Ir=p(oi,"__call__"),oi.forEach(o),Dr=p(St," special method."),St.forEach(o),Lr=h(re),O(He.$$.fragment,re),Hr=h(re),O(Qe.$$.fragment,re),Qr=h(re),O(Xe.$$.fragment,re),re.forEach(o),se.forEach(o),hn=h(t),we=a(t,"H2",{class:!0});var zn=l(we);We=a(zn,"A",{id:!0,class:!0,href:!0});var ni=l(We);Eo=a(ni,"SPAN",{});var si=l(Eo);O(xt.$$.fragment,si),si.forEach(o),ni.forEach(o),Xr=h(zn),zo=a(zn,"SPAN",{});var ri=l(zo);Wr=p(ri,"ORTModelForCausalLM"),ri.forEach(o),zn.forEach(o),gn=h(t),S=a(t,"DIV",{class:!0});var ae=l(S);O(Tt.$$.fragment,ae),Br=h(ae),Ro=a(ae,"P",{});var ai=l(Ro);Gr=p(ai,`Onnx Model with a causal language modeling head on top (linear layer with weights tied to the input
embeddings).`),ai.forEach(o),Vr=h(ae),bt=a(ae,"P",{});var Rn=l(bt);Ur=p(Rn,"This model inherits from [~"),Fo=a(Rn,"CODE",{});var ii=l(Fo);Jr=p(ii,"onnxruntime.modeling_ort.ORTModel"),ii.forEach(o),Yr=p(Rn,`]. Check the superclass documentation for the generic methods the
library implements for all its model (such as downloading or saving)`),Rn.forEach(o),Zr=h(ae),Co=a(ae,"P",{});var li=l(Co);Kr=p(li,"Causal LM model for ONNX."),li.forEach(o),ea=h(ae),Q=a(ae,"DIV",{class:!0});var ie=l(Q);O(Mt.$$.fragment,ie),ta=h(ie),ve=a(ie,"P",{});var It=l(ve);oa=p(It,"The "),Ao=a(It,"CODE",{});var mi=l(Ao);na=p(mi,"ORTModelForCausalLM"),mi.forEach(o),sa=p(It," forward method, overrides the "),Po=a(It,"CODE",{});var pi=l(Po);ra=p(pi,"__call__"),pi.forEach(o),aa=p(It," special method."),It.forEach(o),ia=h(ie),O(Be.$$.fragment,ie),la=h(ie),O(Ge.$$.fragment,ie),ma=h(ie),O(Ve.$$.fragment,ie),ie.forEach(o),ae.forEach(o),this.h()},h(){v(n,"name","hf:doc:metadata"),v(n,"content",JSON.stringify(Xi)),v(u,"id","optimum-inference-with-onnx-runtime"),v(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"),v(u,"href","#optimum-inference-with-onnx-runtime"),v(d,"class","relative group"),v(R,"href","hf.co/models"),v(Te,"id","switching-from-transformers-to-optimum-inference"),v(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"),v(Te,"href","#switching-from-transformers-to-optimum-inference"),v(me,"class","relative group"),v(zt,"href","todo:add-link"),v(Me,"id","working-with-the-hugging-face-model-hub"),v(Me,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),v(Me,"href","#working-with-the-hugging-face-model-hub"),v(pe,"class","relative group"),v(Rt,"href","/docs/optimum/pr_200/en/onnxruntime/modeling_ort#optimum.onnxruntime.ORTModelForSequenceClassification"),v(et,"href","https://hf.co/models"),v(et,"rel","nofollow"),v(Oe,"id","optimum.onnxruntime.ORTModel"),v(Oe,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),v(Oe,"href","#optimum.onnxruntime.ORTModel"),v(ce,"class","relative group"),v(ye,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),v(U,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),v(qe,"id","optimum.onnxruntime.ORTModelForFeatureExtraction"),v(qe,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),v(qe,"href","#optimum.onnxruntime.ORTModelForFeatureExtraction"),v(de,"class","relative group"),v(D,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),v(C,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),v(Re,"id","optimum.onnxruntime.ORTModelForQuestionAnswering"),v(Re,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),v(Re,"href","#optimum.onnxruntime.ORTModelForQuestionAnswering"),v(fe,"class","relative group"),v(L,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),v(A,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),v(Pe,"id","optimum.onnxruntime.ORTModelForSequenceClassification"),v(Pe,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),v(Pe,"href","#optimum.onnxruntime.ORTModelForSequenceClassification"),v(ge,"class","relative group"),v(F,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),v(P,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),v(Le,"id","optimum.onnxruntime.ORTModelForTokenClassification"),v(Le,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),v(Le,"href","#optimum.onnxruntime.ORTModelForTokenClassification"),v($e,"class","relative group"),v(H,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),v(N,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),v(We,"id","optimum.onnxruntime.ORTModelForCausalLM"),v(We,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),v(We,"href","#optimum.onnxruntime.ORTModelForCausalLM"),v(we,"class","relative group"),v(Q,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),v(S,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8")},m(t,$){e(document.head,n),k(t,g,$),k(t,d,$),e(d,u),e(u,_),y(s,_,null),e(d,i),e(d,x),e(x,c),k(t,w,$),k(t,E,$),e(E,z),e(E,R),e(R,jt),e(E,Et),k(t,Uo,$),k(t,me,$),e(me,Te),e(Te,Dt),y(Je,Dt,null),e(me,Fn),e(me,Lt),e(Lt,Cn),k(t,Jo,$),k(t,I,$),e(I,An),e(I,Ht),e(Ht,Pn),e(I,Nn),e(I,Qt),e(Qt,Sn),e(I,In),e(I,Xt),e(Xt,Dn),e(I,Ln),e(I,Wt),e(Wt,Hn),e(I,Qn),k(t,Yo,$),y(Ye,t,$),k(t,Zo,$),k(t,Z,$),e(Z,Xn),e(Z,Bt),e(Bt,Wn),e(Z,Bn),e(Z,Gt),e(Gt,Gn),e(Z,Vn),k(t,Ko,$),y(Ze,t,$),k(t,en,$),k(t,be,$),e(be,Un),e(be,zt),e(zt,Jn),e(be,Yn),k(t,tn,$),k(t,pe,$),e(pe,Me),e(Me,Vt),y(Ke,Vt,null),e(pe,Zn),e(pe,Ut),e(Ut,Kn),k(t,on,$),k(t,B,$),e(B,es),e(B,Rt),e(Rt,ts),e(B,os),e(B,et),e(et,ns),e(B,ss),e(B,Jt),e(Jt,rs),e(B,as),k(t,nn,$),y(tt,t,$),k(t,sn,$),k(t,ce,$),e(ce,Oe),e(Oe,Yt),y(ot,Yt,null),e(ce,is),e(ce,Zt),e(Zt,ls),k(t,rn,$),k(t,U,$),y(nt,U,null),e(U,ms),e(U,st),e(st,ps),e(st,Kt),e(Kt,cs),e(st,ds),e(U,us),e(U,ye),y(rt,ye,null),e(ye,fs),e(ye,Ft),e(Ft,hs),e(Ft,eo),e(eo,gs),k(t,an,$),k(t,de,$),e(de,qe),e(qe,to),y(at,to,null),e(de,_s),e(de,oo),e(oo,$s),k(t,ln,$),k(t,C,$),y(it,C,null),e(C,ks),e(C,no),e(no,ws),e(C,vs),e(C,lt),e(lt,xs),e(lt,so),e(so,Ts),e(lt,bs),e(C,Ms),e(C,ro),e(ro,Os),e(C,ys),e(C,D),y(mt,D,null),e(D,qs),e(D,ue),e(ue,js),e(ue,ao),e(ao,Es),e(ue,zs),e(ue,io),e(io,Rs),e(ue,Fs),e(D,Cs),y(je,D,null),e(D,As),y(Ee,D,null),e(D,Ps),y(ze,D,null),k(t,mn,$),k(t,fe,$),e(fe,Re),e(Re,lo),y(pt,lo,null),e(fe,Ns),e(fe,mo),e(mo,Ss),k(t,pn,$),k(t,A,$),y(ct,A,null),e(A,Is),e(A,po),e(po,Ds),e(A,Ls),e(A,dt),e(dt,Hs),e(dt,co),e(co,Qs),e(dt,Xs),e(A,Ws),e(A,uo),e(uo,Bs),e(A,Gs),e(A,L),y(ut,L,null),e(L,Vs),e(L,he),e(he,Us),e(he,fo),e(fo,Js),e(he,Ys),e(he,ho),e(ho,Zs),e(he,Ks),e(L,er),y(Fe,L,null),e(L,tr),y(Ce,L,null),e(L,or),y(Ae,L,null),k(t,cn,$),k(t,ge,$),e(ge,Pe),e(Pe,go),y(ft,go,null),e(ge,nr),e(ge,_o),e(_o,sr),k(t,dn,$),k(t,P,$),y(ht,P,null),e(P,rr),e(P,$o),e($o,ar),e(P,ir),e(P,gt),e(gt,lr),e(gt,ko),e(ko,mr),e(gt,pr),e(P,cr),e(P,wo),e(wo,dr),e(P,ur),e(P,F),y(_t,F,null),e(F,fr),e(F,_e),e(_e,hr),e(_e,vo),e(vo,gr),e(_e,_r),e(_e,xo),e(xo,$r),e(_e,kr),e(F,wr),y(Ne,F,null),e(F,vr),y(Se,F,null),e(F,xr),y(Ie,F,null),e(F,Tr),y(De,F,null),k(t,un,$),k(t,$e,$),e($e,Le),e(Le,To),y($t,To,null),e($e,br),e($e,bo),e(bo,Mr),k(t,fn,$),k(t,N,$),y(kt,N,null),e(N,Or),e(N,Mo),e(Mo,yr),e(N,qr),e(N,wt),e(wt,jr),e(wt,Oo),e(Oo,Er),e(wt,zr),e(N,Rr),e(N,yo),e(yo,Fr),e(N,Cr),e(N,H),y(vt,H,null),e(H,Ar),e(H,ke),e(ke,Pr),e(ke,qo),e(qo,Nr),e(ke,Sr),e(ke,jo),e(jo,Ir),e(ke,Dr),e(H,Lr),y(He,H,null),e(H,Hr),y(Qe,H,null),e(H,Qr),y(Xe,H,null),k(t,hn,$),k(t,we,$),e(we,We),e(We,Eo),y(xt,Eo,null),e(we,Xr),e(we,zo),e(zo,Wr),k(t,gn,$),k(t,S,$),y(Tt,S,null),e(S,Br),e(S,Ro),e(Ro,Gr),e(S,Vr),e(S,bt),e(bt,Ur),e(bt,Fo),e(Fo,Jr),e(bt,Yr),e(S,Zr),e(S,Co),e(Co,Kr),e(S,ea),e(S,Q),y(Mt,Q,null),e(Q,ta),e(Q,ve),e(ve,oa),e(ve,Ao),e(Ao,na),e(ve,sa),e(ve,Po),e(Po,ra),e(ve,aa),e(Q,ia),y(Be,Q,null),e(Q,la),y(Ge,Q,null),e(Q,ma),y(Ve,Q,null),_n=!0},p(t,[$]){const Ot={};$&2&&(Ot.$$scope={dirty:$,ctx:t}),je.$set(Ot);const No={};$&2&&(No.$$scope={dirty:$,ctx:t}),Ee.$set(No);const So={};$&2&&(So.$$scope={dirty:$,ctx:t}),ze.$set(So);const Io={};$&2&&(Io.$$scope={dirty:$,ctx:t}),Fe.$set(Io);const yt={};$&2&&(yt.$$scope={dirty:$,ctx:t}),Ce.$set(yt);const Do={};$&2&&(Do.$$scope={dirty:$,ctx:t}),Ae.$set(Do);const qt={};$&2&&(qt.$$scope={dirty:$,ctx:t}),Ne.$set(qt);const Lo={};$&2&&(Lo.$$scope={dirty:$,ctx:t}),Se.$set(Lo);const Ho={};$&2&&(Ho.$$scope={dirty:$,ctx:t}),Ie.$set(Ho);const Qo={};$&2&&(Qo.$$scope={dirty:$,ctx:t}),De.$set(Qo);const W={};$&2&&(W.$$scope={dirty:$,ctx:t}),He.$set(W);const Xo={};$&2&&(Xo.$$scope={dirty:$,ctx:t}),Qe.$set(Xo);const Wo={};$&2&&(Wo.$$scope={dirty:$,ctx:t}),Xe.$set(Wo);const Bo={};$&2&&(Bo.$$scope={dirty:$,ctx:t}),Be.$set(Bo);const Go={};$&2&&(Go.$$scope={dirty:$,ctx:t}),Ge.$set(Go);const xe={};$&2&&(xe.$$scope={dirty:$,ctx:t}),Ve.$set(xe)},i(t){_n||(T(s.$$.fragment,t),T(Je.$$.fragment,t),T(Ye.$$.fragment,t),T(Ze.$$.fragment,t),T(Ke.$$.fragment,t),T(tt.$$.fragment,t),T(ot.$$.fragment,t),T(nt.$$.fragment,t),T(rt.$$.fragment,t),T(at.$$.fragment,t),T(it.$$.fragment,t),T(mt.$$.fragment,t),T(je.$$.fragment,t),T(Ee.$$.fragment,t),T(ze.$$.fragment,t),T(pt.$$.fragment,t),T(ct.$$.fragment,t),T(ut.$$.fragment,t),T(Fe.$$.fragment,t),T(Ce.$$.fragment,t),T(Ae.$$.fragment,t),T(ft.$$.fragment,t),T(ht.$$.fragment,t),T(_t.$$.fragment,t),T(Ne.$$.fragment,t),T(Se.$$.fragment,t),T(Ie.$$.fragment,t),T(De.$$.fragment,t),T($t.$$.fragment,t),T(kt.$$.fragment,t),T(vt.$$.fragment,t),T(He.$$.fragment,t),T(Qe.$$.fragment,t),T(Xe.$$.fragment,t),T(xt.$$.fragment,t),T(Tt.$$.fragment,t),T(Mt.$$.fragment,t),T(Be.$$.fragment,t),T(Ge.$$.fragment,t),T(Ve.$$.fragment,t),_n=!0)},o(t){b(s.$$.fragment,t),b(Je.$$.fragment,t),b(Ye.$$.fragment,t),b(Ze.$$.fragment,t),b(Ke.$$.fragment,t),b(tt.$$.fragment,t),b(ot.$$.fragment,t),b(nt.$$.fragment,t),b(rt.$$.fragment,t),b(at.$$.fragment,t),b(it.$$.fragment,t),b(mt.$$.fragment,t),b(je.$$.fragment,t),b(Ee.$$.fragment,t),b(ze.$$.fragment,t),b(pt.$$.fragment,t),b(ct.$$.fragment,t),b(ut.$$.fragment,t),b(Fe.$$.fragment,t),b(Ce.$$.fragment,t),b(Ae.$$.fragment,t),b(ft.$$.fragment,t),b(ht.$$.fragment,t),b(_t.$$.fragment,t),b(Ne.$$.fragment,t),b(Se.$$.fragment,t),b(Ie.$$.fragment,t),b(De.$$.fragment,t),b($t.$$.fragment,t),b(kt.$$.fragment,t),b(vt.$$.fragment,t),b(He.$$.fragment,t),b(Qe.$$.fragment,t),b(Xe.$$.fragment,t),b(xt.$$.fragment,t),b(Tt.$$.fragment,t),b(Mt.$$.fragment,t),b(Be.$$.fragment,t),b(Ge.$$.fragment,t),b(Ve.$$.fragment,t),_n=!1},d(t){o(n),t&&o(g),t&&o(d),q(s),t&&o(w),t&&o(E),t&&o(Uo),t&&o(me),q(Je),t&&o(Jo),t&&o(I),t&&o(Yo),q(Ye,t),t&&o(Zo),t&&o(Z),t&&o(Ko),q(Ze,t),t&&o(en),t&&o(be),t&&o(tn),t&&o(pe),q(Ke),t&&o(on),t&&o(B),t&&o(nn),q(tt,t),t&&o(sn),t&&o(ce),q(ot),t&&o(rn),t&&o(U),q(nt),q(rt),t&&o(an),t&&o(de),q(at),t&&o(ln),t&&o(C),q(it),q(mt),q(je),q(Ee),q(ze),t&&o(mn),t&&o(fe),q(pt),t&&o(pn),t&&o(A),q(ct),q(ut),q(Fe),q(Ce),q(Ae),t&&o(cn),t&&o(ge),q(ft),t&&o(dn),t&&o(P),q(ht),q(_t),q(Ne),q(Se),q(Ie),q(De),t&&o(un),t&&o($e),q($t),t&&o(fn),t&&o(N),q(kt),q(vt),q(He),q(Qe),q(Xe),t&&o(hn),t&&o(we),q(xt),t&&o(gn),t&&o(S),q(Tt),q(Mt),q(Be),q(Ge),q(Ve)}}}const Xi={local:"optimum-inference-with-onnx-runtime",sections:[{local:"switching-from-transformers-to-optimum-inference",sections:[{local:"working-with-the-hugging-face-model-hub",title:"Working with the Hugging Face Model Hub"}],title:"Switching from Transformers to Optimum Inference"},{local:"optimum.onnxruntime.ORTModel",title:"ORTModel"},{local:"optimum.onnxruntime.ORTModelForFeatureExtraction",title:"ORTModelForFeatureExtraction"},{local:"optimum.onnxruntime.ORTModelForQuestionAnswering",title:"ORTModelForQuestionAnswering"},{local:"optimum.onnxruntime.ORTModelForSequenceClassification",title:"ORTModelForSequenceClassification"},{local:"optimum.onnxruntime.ORTModelForTokenClassification",title:"ORTModelForTokenClassification"},{local:"optimum.onnxruntime.ORTModelForCausalLM",title:"ORTModelForCausalLM"}],title:"Optimum Inference with ONNX Runtime"};function Wi(j){return hi(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class Yi extends di{constructor(n){super();ui(this,n,Wi,Qi,fi,{})}}export{Yi as default,Xi as metadata};
