import{S as vi,i as xi,s as Ti,F as Oi,e as r,w as O,k as h,c as a,a as i,x as M,d as o,m as f,b as v,g as k,G as e,y,P as Mi,H as yi,I as ji,J as Ei,q as T,o as b,B as j,v as bi,Z as qi,_ as Ri,t as m,M as zi,h as p,L as Y}from"../../chunks/vendor-hf-doc-builder.js";import{T as Yo}from"../../chunks/Tip-hf-doc-builder.js";import{D as G}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:Fi}=qi;function Ci(E){let n,g,d,u,_,s,l,x,c;u=new le({props:{classNames:"text-smd"}});const w=E[4].default,q=Oi(w,E,E[3],null);return{c(){n=r("div"),g=r("a"),d=r("span"),O(u.$$.fragment),s=h(),q&&q.c(),this.h()},l(R){n=a(R,"DIV",{class:!0});var z=i(n);g=a(z,"A",{id:!0,class:!0,href:!0});var Ft=i(g);d=a(Ft,"SPAN",{});var Ct=i(d);M(u.$$.fragment,Ct),Ct.forEach(o),Ft.forEach(o),s=f(z),q&&q.l(z),z.forEach(o),this.h()},h(){v(g,"id",E[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",_=`#${E[0]}`),v(n,"class","relative group rounded-md")},m(R,z){k(R,n,z),e(n,g),e(g,d),y(u,d,null),e(n,s),q&&q.m(n,null),E[5](n),l=!0,x||(c=Mi(Fi,"hashchange",E[2]),x=!0)},p(R,[z]){(!l||z&1)&&v(g,"id",R[0]),(!l||z&1&&_!==(_=`#${R[0]}`))&&v(g,"href",_),q&&q.p&&(!l||z&8)&&yi(q,w,R,R[3],l?Ei(w,R[3],z,null):ji(R[3]),null)},i(R){l||(T(u.$$.fragment,R),T(q,R),l=!0)},o(R){b(u.$$.fragment,R),b(q,R),l=!1},d(R){R&&o(n),j(u),q&&q.d(R),E[5](null),x=!1,c()}}}const wi="bg-yellow-50 dark:bg-[#494a3d]";function Ai(E,n,g){let{$$slots:d={},$$scope:u}=n,{anchor:_}=n,s;function l(){const{hash:c}=window.location,w=c.substring(1);s&&s.classList.remove(...wi.split(" ")),w===_&&s.classList.add(...wi.split(" "))}bi(()=>{l()});function x(c){Ri[c?"unshift":"push"](()=>{s=c,g(1,s)})}return E.$$set=c=>{"anchor"in c&&g(0,_=c.anchor),"$$scope"in c&&g(3,u=c.$$scope)},[_,s,l,u,d,x]}class U extends vi{constructor(n){super();xi(this,n,Ai,Ci,Ti,{anchor:0})}}function Pi(E){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 l=i(n);g=p(l,"Although the recipe for forward pass needs to be defined within this function, one should call the "),d=a(l,"CODE",{});var x=i(d);u=p(x,"Module"),x.forEach(o),_=p(l,`
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.forEach(o)},m(s,l){k(s,n,l),e(n,g),e(n,d),e(d,u),e(n,_)},d(s){s&&o(n)}}}function Ni(E){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=h(),O(u.$$.fragment)},l(s){n=a(s,"P",{});var l=i(n);g=p(l,"Example of feature extraction:"),l.forEach(o),d=f(s),M(u.$$.fragment,s)},m(s,l){k(s,n,l),e(n,g),k(s,d,l),y(u,s,l),_=!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),j(u,s)}}}function Si(E){let n,g,d,u,_,s,l,x;return l=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=h(),O(l.$$.fragment)},l(c){n=a(c,"P",{});var w=i(n);g=p(w,"Example using "),d=a(w,"CODE",{});var q=i(d);u=p(q,"transformers.pipeline"),q.forEach(o),_=p(w,":"),w.forEach(o),s=f(c),M(l.$$.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(l,c,w),x=!0},p:Y,i(c){x||(T(l.$$.fragment,c),x=!0)},o(c){b(l.$$.fragment,c),x=!1},d(c){c&&o(n),c&&o(s),j(l,c)}}}function Ii(E){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 l=i(n);g=p(l,"Although the recipe for forward pass needs to be defined within this function, one should call the "),d=a(l,"CODE",{});var x=i(d);u=p(x,"Module"),x.forEach(o),_=p(l,`
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.forEach(o)},m(s,l){k(s,n,l),e(n,g),e(n,d),e(d,u),e(n,_)},d(s){s&&o(n)}}}function Di(E){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=h(),O(u.$$.fragment)},l(s){n=a(s,"P",{});var l=i(n);g=p(l,"Example of question answering:"),l.forEach(o),d=f(s),M(u.$$.fragment,s)},m(s,l){k(s,n,l),e(n,g),k(s,d,l),y(u,s,l),_=!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),j(u,s)}}}function Li(E){let n,g,d,u,_,s,l,x;return l=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=h(),O(l.$$.fragment)},l(c){n=a(c,"P",{});var w=i(n);g=p(w,"Example using "),d=a(w,"CODE",{});var q=i(d);u=p(q,"transformers.pipeline"),q.forEach(o),_=p(w,":"),w.forEach(o),s=f(c),M(l.$$.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(l,c,w),x=!0},p:Y,i(c){x||(T(l.$$.fragment,c),x=!0)},o(c){b(l.$$.fragment,c),x=!1},d(c){c&&o(n),c&&o(s),j(l,c)}}}function Hi(E){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 l=i(n);g=p(l,"Although the recipe for forward pass needs to be defined within this function, one should call the "),d=a(l,"CODE",{});var x=i(d);u=p(x,"Module"),x.forEach(o),_=p(l,`
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.forEach(o)},m(s,l){k(s,n,l),e(n,g),e(n,d),e(d,u),e(n,_)},d(s){s&&o(n)}}}function Qi(E){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=h(),O(u.$$.fragment)},l(s){n=a(s,"P",{});var l=i(n);g=p(l,"Example of single-label classification:"),l.forEach(o),d=f(s),M(u.$$.fragment,s)},m(s,l){k(s,n,l),e(n,g),k(s,d,l),y(u,s,l),_=!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),j(u,s)}}}function Xi(E){let n,g,d,u,_,s,l,x;return l=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=h(),O(l.$$.fragment)},l(c){n=a(c,"P",{});var w=i(n);g=p(w,"Example using "),d=a(w,"CODE",{});var q=i(d);u=p(q,"transformers.pipelines"),q.forEach(o),_=p(w,":"),w.forEach(o),s=f(c),M(l.$$.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(l,c,w),x=!0},p:Y,i(c){x||(T(l.$$.fragment,c),x=!0)},o(c){b(l.$$.fragment,c),x=!1},d(c){c&&o(n),c&&o(s),j(l,c)}}}function Wi(E){let n,g,d,u,_,s,l,x;return l=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=h(),O(l.$$.fragment)},l(c){n=a(c,"P",{});var w=i(n);g=p(w,"Example using zero-shot-classification "),d=a(w,"CODE",{});var q=i(d);u=p(q,"transformers.pipelines"),q.forEach(o),_=p(w,":"),w.forEach(o),s=f(c),M(l.$$.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(l,c,w),x=!0},p:Y,i(c){x||(T(l.$$.fragment,c),x=!0)},o(c){b(l.$$.fragment,c),x=!1},d(c){c&&o(n),c&&o(s),j(l,c)}}}function Bi(E){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 l=i(n);g=p(l,"Although the recipe for forward pass needs to be defined within this function, one should call the "),d=a(l,"CODE",{});var x=i(d);u=p(x,"Module"),x.forEach(o),_=p(l,`
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.forEach(o)},m(s,l){k(s,n,l),e(n,g),e(n,d),e(d,u),e(n,_)},d(s){s&&o(n)}}}function Gi(E){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=h(),O(u.$$.fragment)},l(s){n=a(s,"P",{});var l=i(n);g=p(l,"Example of token classification:"),l.forEach(o),d=f(s),M(u.$$.fragment,s)},m(s,l){k(s,n,l),e(n,g),k(s,d,l),y(u,s,l),_=!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),j(u,s)}}}function Vi(E){let n,g,d,u,_,s,l,x;return l=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=h(),O(l.$$.fragment)},l(c){n=a(c,"P",{});var w=i(n);g=p(w,"Example using "),d=a(w,"CODE",{});var q=i(d);u=p(q,"transformers.pipelines"),q.forEach(o),_=p(w,":"),w.forEach(o),s=f(c),M(l.$$.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(l,c,w),x=!0},p:Y,i(c){x||(T(l.$$.fragment,c),x=!0)},o(c){b(l.$$.fragment,c),x=!1},d(c){c&&o(n),c&&o(s),j(l,c)}}}function Ji(E){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 l=i(n);g=p(l,"Although the recipe for forward pass needs to be defined within this function, one should call the "),d=a(l,"CODE",{});var x=i(d);u=p(x,"Module"),x.forEach(o),_=p(l,`
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.forEach(o)},m(s,l){k(s,n,l),e(n,g),e(n,d),e(d,u),e(n,_)},d(s){s&&o(n)}}}function Ui(E){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=h(),O(u.$$.fragment)},l(s){n=a(s,"P",{});var l=i(n);g=p(l,"Example of text generation:"),l.forEach(o),d=f(s),M(u.$$.fragment,s)},m(s,l){k(s,n,l),e(n,g),k(s,d,l),y(u,s,l),_=!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),j(u,s)}}}function Yi(E){let n,g,d,u,_,s,l,x;return l=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=h(),O(l.$$.fragment)},l(c){n=a(c,"P",{});var w=i(n);g=p(w,"Example using "),d=a(w,"CODE",{});var q=i(d);u=p(q,"transformers.pipelines"),q.forEach(o),_=p(w,":"),w.forEach(o),s=f(c),M(l.$$.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(l,c,w),x=!0},p:Y,i(c){x||(T(l.$$.fragment,c),x=!0)},o(c){b(l.$$.fragment,c),x=!1},d(c){c&&o(n),c&&o(s),j(l,c)}}}function Zi(E){let n,g,d,u,_,s,l,x,c,w,q,R,z,Ft,Ct,Zo,me,Te,Ht,Ze,Sn,Qt,In,Ko,I,Dn,Xt,Ln,Hn,Wt,Qn,Xn,Bt,Wn,Bn,Gt,Gn,Vn,en,Ke,tn,Z,Jn,Vt,Un,Yn,Jt,Zn,Kn,on,et,nn,be,es,At,ts,os,sn,pe,Oe,Ut,tt,ns,Yt,ss,rn,V,rs,Pt,as,is,ot,ls,ms,Zt,ps,cs,an,nt,ln,ce,Me,Kt,st,ds,eo,us,mn,W,rt,hs,at,fs,to,gs,_s,$s,ye,it,ks,lt,ws,oo,vs,xs,Ts,je,mt,bs,no,Os,pn,de,Ee,so,pt,Ms,ro,ys,cn,C,ct,js,ao,Es,qs,dt,Rs,io,zs,Fs,Cs,lo,As,Ps,D,ut,Ns,ue,Ss,mo,Is,Ds,po,Ls,Hs,Qs,qe,Xs,Re,Ws,ze,dn,he,Fe,co,ht,Bs,uo,Gs,un,A,ft,Vs,ho,Js,Us,gt,Ys,fo,Zs,Ks,er,go,tr,or,L,_t,nr,fe,sr,_o,rr,ar,$o,ir,lr,mr,Ce,pr,Ae,cr,Pe,hn,ge,Ne,ko,$t,dr,wo,ur,fn,P,kt,hr,vo,fr,gr,wt,_r,xo,$r,kr,wr,To,vr,xr,F,vt,Tr,_e,br,bo,Or,Mr,Oo,yr,jr,Er,Se,qr,Ie,Rr,De,zr,Le,gn,$e,He,Mo,xt,Fr,yo,Cr,_n,N,Tt,Ar,jo,Pr,Nr,bt,Sr,Eo,Ir,Dr,Lr,qo,Hr,Qr,H,Ot,Xr,ke,Wr,Ro,Br,Gr,zo,Vr,Jr,Ur,Qe,Yr,Xe,Zr,We,$n,we,Be,Fo,Mt,Kr,Co,ea,kn,S,yt,ta,Ao,oa,na,jt,sa,Po,ra,aa,ia,No,la,ma,Q,Et,pa,ve,ca,So,da,ua,Io,ha,fa,ga,Ge,_a,Ve,$a,Je,wn;return s=new le({}),Ze=new le({}),Ke=new X({props:{code:`

`,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)`}}),et=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>}]`}}),tt=new le({}),nt=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>
                  )`}}),st=new le({}),rt=new G({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_203/src/optimum/onnxruntime/modeling_ort.py#L79"}}),it=new G({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 the model.`,name:"path"},{anchor:"optimum.onnxruntime.ORTModel.load_model.provider(str,",description:`<strong>provider(<code>str</code>,</strong> <em>optional</em>) &#x2014;
ONNX Runtime provider to use for loading the model. Defaults to <code>CPUExecutionProvider</code>.`,name:"provider(str,"}],source:"https://github.com/huggingface/optimum/blob/vr_203/src/optimum/onnxruntime/modeling_ort.py#L119"}}),mt=new G({props:{name:"to",anchor:"optimum.onnxruntime.ORTModel.to",parameters:[{name:"device",val:""}],source:"https://github.com/huggingface/optimum/blob/vr_203/src/optimum/onnxruntime/modeling_ort.py#L107"}}),pt=new le({}),ct=new G({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_203/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_203/src/optimum/onnxruntime/modeling_ort.py#L317"}}),ut=new G({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_203/src/optimum/onnxruntime/modeling_ort.py#L331"}}),qe=new Yo({props:{$$slots:{default:[Pi]},$$scope:{ctx:E}}}),Re=new U({props:{anchor:"optimum.onnxruntime.ORTModelForFeatureExtraction.forward.example",$$slots:{default:[Ni]},$$scope:{ctx:E}}}),ze=new U({props:{anchor:"optimum.onnxruntime.ORTModelForFeatureExtraction.forward.example-2",$$slots:{default:[Si]},$$scope:{ctx:E}}}),ht=new le({}),ft=new G({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_203/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_203/src/optimum/onnxruntime/modeling_ort.py#L402"}}),_t=new G({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_203/src/optimum/onnxruntime/modeling_ort.py#L416"}}),Ce=new Yo({props:{$$slots:{default:[Ii]},$$scope:{ctx:E}}}),Ae=new U({props:{anchor:"optimum.onnxruntime.ORTModelForQuestionAnswering.forward.example",$$slots:{default:[Di]},$$scope:{ctx:E}}}),Pe=new U({props:{anchor:"optimum.onnxruntime.ORTModelForQuestionAnswering.forward.example-2",$$slots:{default:[Li]},$$scope:{ctx:E}}}),$t=new le({}),kt=new G({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_203/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_203/src/optimum/onnxruntime/modeling_ort.py#L505"}}),vt=new G({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_203/src/optimum/onnxruntime/modeling_ort.py#L520"}}),Se=new Yo({props:{$$slots:{default:[Hi]},$$scope:{ctx:E}}}),Ie=new U({props:{anchor:"optimum.onnxruntime.ORTModelForSequenceClassification.forward.example",$$slots:{default:[Qi]},$$scope:{ctx:E}}}),De=new U({props:{anchor:"optimum.onnxruntime.ORTModelForSequenceClassification.forward.example-2",$$slots:{default:[Xi]},$$scope:{ctx:E}}}),Le=new U({props:{anchor:"optimum.onnxruntime.ORTModelForSequenceClassification.forward.example-3",$$slots:{default:[Wi]},$$scope:{ctx:E}}}),xt=new le({}),Tt=new G({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_203/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_203/src/optimum/onnxruntime/modeling_ort.py#L593"}}),Ot=new G({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_203/src/optimum/onnxruntime/modeling_ort.py#L607"}}),Qe=new Yo({props:{$$slots:{default:[Bi]},$$scope:{ctx:E}}}),Xe=new U({props:{anchor:"optimum.onnxruntime.ORTModelForTokenClassification.forward.example",$$slots:{default:[Gi]},$$scope:{ctx:E}}}),We=new U({props:{anchor:"optimum.onnxruntime.ORTModelForTokenClassification.forward.example-2",$$slots:{default:[Vi]},$$scope:{ctx:E}}}),Mt=new le({}),yt=new G({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_203/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_203/src/optimum/onnxruntime/modeling_ort.py#L678"}}),Et=new G({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_203/src/optimum/onnxruntime/modeling_ort.py#L702"}}),Ge=new Yo({props:{$$slots:{default:[Ji]},$$scope:{ctx:E}}}),Ve=new U({props:{anchor:"optimum.onnxruntime.ORTModelForCausalLM.forward.example",$$slots:{default:[Ui]},$$scope:{ctx:E}}}),Je=new U({props:{anchor:"optimum.onnxruntime.ORTModelForCausalLM.forward.example-2",$$slots:{default:[Yi]},$$scope:{ctx:E}}}),{c(){n=r("meta"),g=h(),d=r("h1"),u=r("a"),_=r("span"),O(s.$$.fragment),l=h(),x=r("span"),c=m("Optimum Inference with ONNX Runtime"),w=h(),q=r("p"),R=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 `),z=r("a"),Ft=m("Hugging Face Hub"),Ct=m(` and create pipelines
to run accelerated inference without rewriting your APIs.`),Zo=h(),me=r("h2"),Te=r("a"),Ht=r("span"),O(Ze.$$.fragment),Sn=h(),Qt=r("span"),In=m("Switching from Transformers to Optimum Inference"),Ko=h(),I=r("p"),Dn=m("The Optimum Inference models are API compatible with Hugging Face Transformers models. This means you can just replace your "),Xt=r("code"),Ln=m("AutoModelForXxx"),Hn=m(" class with the corresponding "),Wt=r("code"),Qn=m("ORTModelForXxx"),Xn=m(" class in "),Bt=r("code"),Wn=m("optimum"),Bn=m(". For example, this is how you can use a question answering model in "),Gt=r("code"),Gn=m("optimum"),Vn=m(":"),en=h(),O(Ke.$$.fragment),tn=h(),Z=r("p"),Jn=m("Optimum Inference also includes methods to convert vanilla Transformers models to optimized ones. Simply pass "),Vt=r("code"),Un=m("from_transformers=True"),Yn=m(" to the "),Jt=r("code"),Zn=m("from_pretrained()"),Kn=m(" method, and your model will be loaded and converted to ONNX on-the-fly:"),on=h(),O(et.$$.fragment),nn=h(),be=r("p"),es=m("You can find a complete walkhrough Optimum Inference for ONNX Runtime in this "),At=r("a"),ts=m("notebook"),os=m("."),sn=h(),pe=r("h3"),Oe=r("a"),Ut=r("span"),O(tt.$$.fragment),ns=h(),Yt=r("span"),ss=m("Working with the Hugging Face Model Hub"),rn=h(),V=r("p"),rs=m("The Optimum model classes like "),Pt=r("a"),as=m("ORTModelForSequenceClassification"),is=m(" are integrated with the "),ot=r("a"),ls=m("Hugging Face Model Hub"),ms=m(`, which means you can not only
load model from the Hub, but also push your models to the Hub with `),Zt=r("code"),ps=m("push_to_hub()"),cs=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.`),an=h(),O(nt.$$.fragment),ln=h(),ce=r("h2"),Me=r("a"),Kt=r("span"),O(st.$$.fragment),ds=h(),eo=r("span"),us=m("ORTModel"),mn=h(),W=r("div"),O(rt.$$.fragment),hs=h(),at=r("p"),fs=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 `),to=r("code"),gs=m("transformers.onnx"),_s=m(` toolchain.
The ORTModel implements additionally generic methods for optimizing and quantizing Onnx models.`),$s=h(),ye=r("div"),O(it.$$.fragment),ks=h(),lt=r("p"),ws=m("Loads an ONNX Inference session with a given provider. Default provider is "),oo=r("code"),vs=m("CPUExecutionProvider"),xs=m(" to match the default behaviour in PyTorch/TensorFlow/JAX."),Ts=h(),je=r("div"),O(mt.$$.fragment),bs=h(),no=r("p"),Os=m("Changes the ONNX Runtime provider according to the device."),pn=h(),de=r("h2"),Ee=r("a"),so=r("span"),O(pt.$$.fragment),Ms=h(),ro=r("span"),ys=m("ORTModelForFeatureExtraction"),cn=h(),C=r("div"),O(ct.$$.fragment),js=h(),ao=r("p"),Es=m("Onnx Model with a MaskedLMOutput for feature-extraction tasks."),qs=h(),dt=r("p"),Rs=m("This model inherits from [~"),io=r("code"),zs=m("onnxruntime.modeling_ort.ORTModel"),Fs=m(`]. Check the superclass documentation for the generic methods the
library implements for all its model (such as downloading or saving)`),Cs=h(),lo=r("p"),As=m("Feature Extraction model for ONNX."),Ps=h(),D=r("div"),O(ut.$$.fragment),Ns=h(),ue=r("p"),Ss=m("The "),mo=r("code"),Is=m("ORTModelForFeatureExtraction"),Ds=m(" forward method, overrides the "),po=r("code"),Ls=m("__call__"),Hs=m(" special method."),Qs=h(),O(qe.$$.fragment),Xs=h(),O(Re.$$.fragment),Ws=h(),O(ze.$$.fragment),dn=h(),he=r("h2"),Fe=r("a"),co=r("span"),O(ht.$$.fragment),Bs=h(),uo=r("span"),Gs=m("ORTModelForQuestionAnswering"),un=h(),A=r("div"),O(ft.$$.fragment),Vs=h(),ho=r("p"),Js=m("Onnx Model with a QuestionAnsweringModelOutput for extractive question-answering tasks like SQuAD."),Us=h(),gt=r("p"),Ys=m("This model inherits from [~"),fo=r("code"),Zs=m("onnxruntime.modeling_ort.ORTModel"),Ks=m(`]. Check the superclass documentation for the generic methods the
library implements for all its model (such as downloading or saving)`),er=h(),go=r("p"),tr=m("Question Answering model for ONNX."),or=h(),L=r("div"),O(_t.$$.fragment),nr=h(),fe=r("p"),sr=m("The "),_o=r("code"),rr=m("ORTModelForQuestionAnswering"),ar=m(" forward method, overrides the "),$o=r("code"),ir=m("__call__"),lr=m(" special method."),mr=h(),O(Ce.$$.fragment),pr=h(),O(Ae.$$.fragment),cr=h(),O(Pe.$$.fragment),hn=h(),ge=r("h2"),Ne=r("a"),ko=r("span"),O($t.$$.fragment),dr=h(),wo=r("span"),ur=m("ORTModelForSequenceClassification"),fn=h(),P=r("div"),O(kt.$$.fragment),hr=h(),vo=r("p"),fr=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.`),gr=h(),wt=r("p"),_r=m("This model inherits from [~"),xo=r("code"),$r=m("onnxruntime.modeling_ort.ORTModel"),kr=m(`]. Check the superclass documentation for the generic methods the
library implements for all its model (such as downloading or saving)`),wr=h(),To=r("p"),vr=m("Sequence Classification model for ONNX."),xr=h(),F=r("div"),O(vt.$$.fragment),Tr=h(),_e=r("p"),br=m("The "),bo=r("code"),Or=m("ORTModelForSequenceClassification"),Mr=m(" forward method, overrides the "),Oo=r("code"),yr=m("__call__"),jr=m(" special method."),Er=h(),O(Se.$$.fragment),qr=h(),O(Ie.$$.fragment),Rr=h(),O(De.$$.fragment),zr=h(),O(Le.$$.fragment),gn=h(),$e=r("h2"),He=r("a"),Mo=r("span"),O(xt.$$.fragment),Fr=h(),yo=r("span"),Cr=m("ORTModelForTokenClassification"),_n=h(),N=r("div"),O(Tt.$$.fragment),Ar=h(),jo=r("p"),Pr=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.`),Nr=h(),bt=r("p"),Sr=m("This model inherits from [~"),Eo=r("code"),Ir=m("onnxruntime.modeling_ort.ORTModel"),Dr=m(`]. Check the superclass documentation for the generic methods the
library implements for all its model (such as downloading or saving)`),Lr=h(),qo=r("p"),Hr=m("Token Classification model for ONNX."),Qr=h(),H=r("div"),O(Ot.$$.fragment),Xr=h(),ke=r("p"),Wr=m("The "),Ro=r("code"),Br=m("ORTModelForTokenClassification"),Gr=m(" forward method, overrides the "),zo=r("code"),Vr=m("__call__"),Jr=m(" special method."),Ur=h(),O(Qe.$$.fragment),Yr=h(),O(Xe.$$.fragment),Zr=h(),O(We.$$.fragment),$n=h(),we=r("h2"),Be=r("a"),Fo=r("span"),O(Mt.$$.fragment),Kr=h(),Co=r("span"),ea=m("ORTModelForCausalLM"),kn=h(),S=r("div"),O(yt.$$.fragment),ta=h(),Ao=r("p"),oa=m(`Onnx Model with a causal language modeling head on top (linear layer with weights tied to the input
embeddings).`),na=h(),jt=r("p"),sa=m("This model inherits from [~"),Po=r("code"),ra=m("onnxruntime.modeling_ort.ORTModel"),aa=m(`]. Check the superclass documentation for the generic methods the
library implements for all its model (such as downloading or saving)`),ia=h(),No=r("p"),la=m("Causal LM model for ONNX."),ma=h(),Q=r("div"),O(Et.$$.fragment),pa=h(),ve=r("p"),ca=m("The "),So=r("code"),da=m("ORTModelForCausalLM"),ua=m(" forward method, overrides the "),Io=r("code"),ha=m("__call__"),fa=m(" special method."),ga=h(),O(Ge.$$.fragment),_a=h(),O(Ve.$$.fragment),$a=h(),O(Je.$$.fragment),this.h()},l(t){const $=zi('[data-svelte="svelte-1phssyn"]',document.head);n=a($,"META",{name:!0,content:!0}),$.forEach(o),g=f(t),d=a(t,"H1",{class:!0});var qt=i(d);u=a(qt,"A",{id:!0,class:!0,href:!0});var Do=i(u);_=a(Do,"SPAN",{});var Lo=i(_);M(s.$$.fragment,Lo),Lo.forEach(o),Do.forEach(o),l=f(qt),x=a(qt,"SPAN",{});var Ho=i(x);c=p(Ho,"Optimum Inference with ONNX Runtime"),Ho.forEach(o),qt.forEach(o),w=f(t),q=a(t,"P",{});var Rt=i(q);R=p(Rt,`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 `),z=a(Rt,"A",{href:!0});var Qo=i(z);Ft=p(Qo,"Hugging Face Hub"),Qo.forEach(o),Ct=p(Rt,` and create pipelines
to run accelerated inference without rewriting your APIs.`),Rt.forEach(o),Zo=f(t),me=a(t,"H2",{class:!0});var zt=i(me);Te=a(zt,"A",{id:!0,class:!0,href:!0});var Xo=i(Te);Ht=a(Xo,"SPAN",{});var Wo=i(Ht);M(Ze.$$.fragment,Wo),Wo.forEach(o),Xo.forEach(o),Sn=f(zt),Qt=a(zt,"SPAN",{});var Bo=i(Qt);In=p(Bo,"Switching from Transformers to Optimum Inference"),Bo.forEach(o),zt.forEach(o),Ko=f(t),I=a(t,"P",{});var B=i(I);Dn=p(B,"The Optimum Inference models are API compatible with Hugging Face Transformers models. This means you can just replace your "),Xt=a(B,"CODE",{});var Go=i(Xt);Ln=p(Go,"AutoModelForXxx"),Go.forEach(o),Hn=p(B," class with the corresponding "),Wt=a(B,"CODE",{});var Vo=i(Wt);Qn=p(Vo,"ORTModelForXxx"),Vo.forEach(o),Xn=p(B," class in "),Bt=a(B,"CODE",{});var Jo=i(Bt);Wn=p(Jo,"optimum"),Jo.forEach(o),Bn=p(B,". For example, this is how you can use a question answering model in "),Gt=a(B,"CODE",{});var Uo=i(Gt);Gn=p(Uo,"optimum"),Uo.forEach(o),Vn=p(B,":"),B.forEach(o),en=f(t),M(Ke.$$.fragment,t),tn=f(t),Z=a(t,"P",{});var xe=i(Z);Jn=p(xe,"Optimum Inference also includes methods to convert vanilla Transformers models to optimized ones. Simply pass "),Vt=a(xe,"CODE",{});var ka=i(Vt);Un=p(ka,"from_transformers=True"),ka.forEach(o),Yn=p(xe," to the "),Jt=a(xe,"CODE",{});var wa=i(Jt);Zn=p(wa,"from_pretrained()"),wa.forEach(o),Kn=p(xe," method, and your model will be loaded and converted to ONNX on-the-fly:"),xe.forEach(o),on=f(t),M(et.$$.fragment,t),nn=f(t),be=a(t,"P",{});var vn=i(be);es=p(vn,"You can find a complete walkhrough Optimum Inference for ONNX Runtime in this "),At=a(vn,"A",{href:!0});var va=i(At);ts=p(va,"notebook"),va.forEach(o),os=p(vn,"."),vn.forEach(o),sn=f(t),pe=a(t,"H3",{class:!0});var xn=i(pe);Oe=a(xn,"A",{id:!0,class:!0,href:!0});var xa=i(Oe);Ut=a(xa,"SPAN",{});var Ta=i(Ut);M(tt.$$.fragment,Ta),Ta.forEach(o),xa.forEach(o),ns=f(xn),Yt=a(xn,"SPAN",{});var ba=i(Yt);ss=p(ba,"Working with the Hugging Face Model Hub"),ba.forEach(o),xn.forEach(o),rn=f(t),V=a(t,"P",{});var Ue=i(V);rs=p(Ue,"The Optimum model classes like "),Pt=a(Ue,"A",{href:!0});var Oa=i(Pt);as=p(Oa,"ORTModelForSequenceClassification"),Oa.forEach(o),is=p(Ue," are integrated with the "),ot=a(Ue,"A",{href:!0,rel:!0});var Ma=i(ot);ls=p(Ma,"Hugging Face Model Hub"),Ma.forEach(o),ms=p(Ue,`, which means you can not only
load model from the Hub, but also push your models to the Hub with `),Zt=a(Ue,"CODE",{});var ya=i(Zt);ps=p(ya,"push_to_hub()"),ya.forEach(o),cs=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),an=f(t),M(nt.$$.fragment,t),ln=f(t),ce=a(t,"H2",{class:!0});var Tn=i(ce);Me=a(Tn,"A",{id:!0,class:!0,href:!0});var ja=i(Me);Kt=a(ja,"SPAN",{});var Ea=i(Kt);M(st.$$.fragment,Ea),Ea.forEach(o),ja.forEach(o),ds=f(Tn),eo=a(Tn,"SPAN",{});var qa=i(eo);us=p(qa,"ORTModel"),qa.forEach(o),Tn.forEach(o),mn=f(t),W=a(t,"DIV",{class:!0});var Ye=i(W);M(rt.$$.fragment,Ye),hs=f(Ye),at=a(Ye,"P",{});var bn=i(at);fs=p(bn,`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 `),to=a(bn,"CODE",{});var Ra=i(to);gs=p(Ra,"transformers.onnx"),Ra.forEach(o),_s=p(bn,` toolchain.
The ORTModel implements additionally generic methods for optimizing and quantizing Onnx models.`),bn.forEach(o),$s=f(Ye),ye=a(Ye,"DIV",{class:!0});var On=i(ye);M(it.$$.fragment,On),ks=f(On),lt=a(On,"P",{});var Mn=i(lt);ws=p(Mn,"Loads an ONNX Inference session with a given provider. Default provider is "),oo=a(Mn,"CODE",{});var za=i(oo);vs=p(za,"CPUExecutionProvider"),za.forEach(o),xs=p(Mn," to match the default behaviour in PyTorch/TensorFlow/JAX."),Mn.forEach(o),On.forEach(o),Ts=f(Ye),je=a(Ye,"DIV",{class:!0});var yn=i(je);M(mt.$$.fragment,yn),bs=f(yn),no=a(yn,"P",{});var Fa=i(no);Os=p(Fa,"Changes the ONNX Runtime provider according to the device."),Fa.forEach(o),yn.forEach(o),Ye.forEach(o),pn=f(t),de=a(t,"H2",{class:!0});var jn=i(de);Ee=a(jn,"A",{id:!0,class:!0,href:!0});var Ca=i(Ee);so=a(Ca,"SPAN",{});var Aa=i(so);M(pt.$$.fragment,Aa),Aa.forEach(o),Ca.forEach(o),Ms=f(jn),ro=a(jn,"SPAN",{});var Pa=i(ro);ys=p(Pa,"ORTModelForFeatureExtraction"),Pa.forEach(o),jn.forEach(o),cn=f(t),C=a(t,"DIV",{class:!0});var K=i(C);M(ct.$$.fragment,K),js=f(K),ao=a(K,"P",{});var Na=i(ao);Es=p(Na,"Onnx Model with a MaskedLMOutput for feature-extraction tasks."),Na.forEach(o),qs=f(K),dt=a(K,"P",{});var En=i(dt);Rs=p(En,"This model inherits from [~"),io=a(En,"CODE",{});var Sa=i(io);zs=p(Sa,"onnxruntime.modeling_ort.ORTModel"),Sa.forEach(o),Fs=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),Cs=f(K),lo=a(K,"P",{});var Ia=i(lo);As=p(Ia,"Feature Extraction model for ONNX."),Ia.forEach(o),Ps=f(K),D=a(K,"DIV",{class:!0});var ee=i(D);M(ut.$$.fragment,ee),Ns=f(ee),ue=a(ee,"P",{});var Nt=i(ue);Ss=p(Nt,"The "),mo=a(Nt,"CODE",{});var Da=i(mo);Is=p(Da,"ORTModelForFeatureExtraction"),Da.forEach(o),Ds=p(Nt," forward method, overrides the "),po=a(Nt,"CODE",{});var La=i(po);Ls=p(La,"__call__"),La.forEach(o),Hs=p(Nt," special method."),Nt.forEach(o),Qs=f(ee),M(qe.$$.fragment,ee),Xs=f(ee),M(Re.$$.fragment,ee),Ws=f(ee),M(ze.$$.fragment,ee),ee.forEach(o),K.forEach(o),dn=f(t),he=a(t,"H2",{class:!0});var qn=i(he);Fe=a(qn,"A",{id:!0,class:!0,href:!0});var Ha=i(Fe);co=a(Ha,"SPAN",{});var Qa=i(co);M(ht.$$.fragment,Qa),Qa.forEach(o),Ha.forEach(o),Bs=f(qn),uo=a(qn,"SPAN",{});var Xa=i(uo);Gs=p(Xa,"ORTModelForQuestionAnswering"),Xa.forEach(o),qn.forEach(o),un=f(t),A=a(t,"DIV",{class:!0});var te=i(A);M(ft.$$.fragment,te),Vs=f(te),ho=a(te,"P",{});var Wa=i(ho);Js=p(Wa,"Onnx Model with a QuestionAnsweringModelOutput for extractive question-answering tasks like SQuAD."),Wa.forEach(o),Us=f(te),gt=a(te,"P",{});var Rn=i(gt);Ys=p(Rn,"This model inherits from [~"),fo=a(Rn,"CODE",{});var Ba=i(fo);Zs=p(Ba,"onnxruntime.modeling_ort.ORTModel"),Ba.forEach(o),Ks=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),er=f(te),go=a(te,"P",{});var Ga=i(go);tr=p(Ga,"Question Answering model for ONNX."),Ga.forEach(o),or=f(te),L=a(te,"DIV",{class:!0});var oe=i(L);M(_t.$$.fragment,oe),nr=f(oe),fe=a(oe,"P",{});var St=i(fe);sr=p(St,"The "),_o=a(St,"CODE",{});var Va=i(_o);rr=p(Va,"ORTModelForQuestionAnswering"),Va.forEach(o),ar=p(St," forward method, overrides the "),$o=a(St,"CODE",{});var Ja=i($o);ir=p(Ja,"__call__"),Ja.forEach(o),lr=p(St," special method."),St.forEach(o),mr=f(oe),M(Ce.$$.fragment,oe),pr=f(oe),M(Ae.$$.fragment,oe),cr=f(oe),M(Pe.$$.fragment,oe),oe.forEach(o),te.forEach(o),hn=f(t),ge=a(t,"H2",{class:!0});var zn=i(ge);Ne=a(zn,"A",{id:!0,class:!0,href:!0});var Ua=i(Ne);ko=a(Ua,"SPAN",{});var Ya=i(ko);M($t.$$.fragment,Ya),Ya.forEach(o),Ua.forEach(o),dr=f(zn),wo=a(zn,"SPAN",{});var Za=i(wo);ur=p(Za,"ORTModelForSequenceClassification"),Za.forEach(o),zn.forEach(o),fn=f(t),P=a(t,"DIV",{class:!0});var ne=i(P);M(kt.$$.fragment,ne),hr=f(ne),vo=a(ne,"P",{});var Ka=i(vo);fr=p(Ka,`Onnx Model with a sequence classification/regression head on top (a linear layer on top of the
pooled output) e.g. for GLUE tasks.`),Ka.forEach(o),gr=f(ne),wt=a(ne,"P",{});var Fn=i(wt);_r=p(Fn,"This model inherits from [~"),xo=a(Fn,"CODE",{});var ei=i(xo);$r=p(ei,"onnxruntime.modeling_ort.ORTModel"),ei.forEach(o),kr=p(Fn,`]. Check the superclass documentation for the generic methods the
library implements for all its model (such as downloading or saving)`),Fn.forEach(o),wr=f(ne),To=a(ne,"P",{});var ti=i(To);vr=p(ti,"Sequence Classification model for ONNX."),ti.forEach(o),xr=f(ne),F=a(ne,"DIV",{class:!0});var J=i(F);M(vt.$$.fragment,J),Tr=f(J),_e=a(J,"P",{});var It=i(_e);br=p(It,"The "),bo=a(It,"CODE",{});var oi=i(bo);Or=p(oi,"ORTModelForSequenceClassification"),oi.forEach(o),Mr=p(It," forward method, overrides the "),Oo=a(It,"CODE",{});var ni=i(Oo);yr=p(ni,"__call__"),ni.forEach(o),jr=p(It," special method."),It.forEach(o),Er=f(J),M(Se.$$.fragment,J),qr=f(J),M(Ie.$$.fragment,J),Rr=f(J),M(De.$$.fragment,J),zr=f(J),M(Le.$$.fragment,J),J.forEach(o),ne.forEach(o),gn=f(t),$e=a(t,"H2",{class:!0});var Cn=i($e);He=a(Cn,"A",{id:!0,class:!0,href:!0});var si=i(He);Mo=a(si,"SPAN",{});var ri=i(Mo);M(xt.$$.fragment,ri),ri.forEach(o),si.forEach(o),Fr=f(Cn),yo=a(Cn,"SPAN",{});var ai=i(yo);Cr=p(ai,"ORTModelForTokenClassification"),ai.forEach(o),Cn.forEach(o),_n=f(t),N=a(t,"DIV",{class:!0});var se=i(N);M(Tt.$$.fragment,se),Ar=f(se),jo=a(se,"P",{});var ii=i(jo);Pr=p(ii,`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.`),ii.forEach(o),Nr=f(se),bt=a(se,"P",{});var An=i(bt);Sr=p(An,"This model inherits from [~"),Eo=a(An,"CODE",{});var li=i(Eo);Ir=p(li,"onnxruntime.modeling_ort.ORTModel"),li.forEach(o),Dr=p(An,`]. Check the superclass documentation for the generic methods the
library implements for all its model (such as downloading or saving)`),An.forEach(o),Lr=f(se),qo=a(se,"P",{});var mi=i(qo);Hr=p(mi,"Token Classification model for ONNX."),mi.forEach(o),Qr=f(se),H=a(se,"DIV",{class:!0});var re=i(H);M(Ot.$$.fragment,re),Xr=f(re),ke=a(re,"P",{});var Dt=i(ke);Wr=p(Dt,"The "),Ro=a(Dt,"CODE",{});var pi=i(Ro);Br=p(pi,"ORTModelForTokenClassification"),pi.forEach(o),Gr=p(Dt," forward method, overrides the "),zo=a(Dt,"CODE",{});var ci=i(zo);Vr=p(ci,"__call__"),ci.forEach(o),Jr=p(Dt," special method."),Dt.forEach(o),Ur=f(re),M(Qe.$$.fragment,re),Yr=f(re),M(Xe.$$.fragment,re),Zr=f(re),M(We.$$.fragment,re),re.forEach(o),se.forEach(o),$n=f(t),we=a(t,"H2",{class:!0});var Pn=i(we);Be=a(Pn,"A",{id:!0,class:!0,href:!0});var di=i(Be);Fo=a(di,"SPAN",{});var ui=i(Fo);M(Mt.$$.fragment,ui),ui.forEach(o),di.forEach(o),Kr=f(Pn),Co=a(Pn,"SPAN",{});var hi=i(Co);ea=p(hi,"ORTModelForCausalLM"),hi.forEach(o),Pn.forEach(o),kn=f(t),S=a(t,"DIV",{class:!0});var ae=i(S);M(yt.$$.fragment,ae),ta=f(ae),Ao=a(ae,"P",{});var fi=i(Ao);oa=p(fi,`Onnx Model with a causal language modeling head on top (linear layer with weights tied to the input
embeddings).`),fi.forEach(o),na=f(ae),jt=a(ae,"P",{});var Nn=i(jt);sa=p(Nn,"This model inherits from [~"),Po=a(Nn,"CODE",{});var gi=i(Po);ra=p(gi,"onnxruntime.modeling_ort.ORTModel"),gi.forEach(o),aa=p(Nn,`]. Check the superclass documentation for the generic methods the
library implements for all its model (such as downloading or saving)`),Nn.forEach(o),ia=f(ae),No=a(ae,"P",{});var _i=i(No);la=p(_i,"Causal LM model for ONNX."),_i.forEach(o),ma=f(ae),Q=a(ae,"DIV",{class:!0});var ie=i(Q);M(Et.$$.fragment,ie),pa=f(ie),ve=a(ie,"P",{});var Lt=i(ve);ca=p(Lt,"The "),So=a(Lt,"CODE",{});var $i=i(So);da=p($i,"ORTModelForCausalLM"),$i.forEach(o),ua=p(Lt," forward method, overrides the "),Io=a(Lt,"CODE",{});var ki=i(Io);ha=p(ki,"__call__"),ki.forEach(o),fa=p(Lt," special method."),Lt.forEach(o),ga=f(ie),M(Ge.$$.fragment,ie),_a=f(ie),M(Ve.$$.fragment,ie),$a=f(ie),M(Je.$$.fragment,ie),ie.forEach(o),ae.forEach(o),this.h()},h(){v(n,"name","hf:doc:metadata"),v(n,"content",JSON.stringify(Ki)),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(z,"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(At,"href","todo:add-link"),v(Oe,"id","working-with-the-hugging-face-model-hub"),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","#working-with-the-hugging-face-model-hub"),v(pe,"class","relative group"),v(Pt,"href","/docs/optimum/pr_203/en/onnxruntime/modeling_ort#optimum.onnxruntime.ORTModelForSequenceClassification"),v(ot,"href","https://hf.co/models"),v(ot,"rel","nofollow"),v(Me,"id","optimum.onnxruntime.ORTModel"),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","#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(je,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),v(W,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),v(Ee,"id","optimum.onnxruntime.ORTModelForFeatureExtraction"),v(Ee,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),v(Ee,"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(Fe,"id","optimum.onnxruntime.ORTModelForQuestionAnswering"),v(Fe,"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(Fe,"href","#optimum.onnxruntime.ORTModelForQuestionAnswering"),v(he,"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(Ne,"id","optimum.onnxruntime.ORTModelForSequenceClassification"),v(Ne,"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(Ne,"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(He,"id","optimum.onnxruntime.ORTModelForTokenClassification"),v(He,"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(He,"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(Be,"id","optimum.onnxruntime.ORTModelForCausalLM"),v(Be,"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(Be,"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,l),e(d,x),e(x,c),k(t,w,$),k(t,q,$),e(q,R),e(q,z),e(z,Ft),e(q,Ct),k(t,Zo,$),k(t,me,$),e(me,Te),e(Te,Ht),y(Ze,Ht,null),e(me,Sn),e(me,Qt),e(Qt,In),k(t,Ko,$),k(t,I,$),e(I,Dn),e(I,Xt),e(Xt,Ln),e(I,Hn),e(I,Wt),e(Wt,Qn),e(I,Xn),e(I,Bt),e(Bt,Wn),e(I,Bn),e(I,Gt),e(Gt,Gn),e(I,Vn),k(t,en,$),y(Ke,t,$),k(t,tn,$),k(t,Z,$),e(Z,Jn),e(Z,Vt),e(Vt,Un),e(Z,Yn),e(Z,Jt),e(Jt,Zn),e(Z,Kn),k(t,on,$),y(et,t,$),k(t,nn,$),k(t,be,$),e(be,es),e(be,At),e(At,ts),e(be,os),k(t,sn,$),k(t,pe,$),e(pe,Oe),e(Oe,Ut),y(tt,Ut,null),e(pe,ns),e(pe,Yt),e(Yt,ss),k(t,rn,$),k(t,V,$),e(V,rs),e(V,Pt),e(Pt,as),e(V,is),e(V,ot),e(ot,ls),e(V,ms),e(V,Zt),e(Zt,ps),e(V,cs),k(t,an,$),y(nt,t,$),k(t,ln,$),k(t,ce,$),e(ce,Me),e(Me,Kt),y(st,Kt,null),e(ce,ds),e(ce,eo),e(eo,us),k(t,mn,$),k(t,W,$),y(rt,W,null),e(W,hs),e(W,at),e(at,fs),e(at,to),e(to,gs),e(at,_s),e(W,$s),e(W,ye),y(it,ye,null),e(ye,ks),e(ye,lt),e(lt,ws),e(lt,oo),e(oo,vs),e(lt,xs),e(W,Ts),e(W,je),y(mt,je,null),e(je,bs),e(je,no),e(no,Os),k(t,pn,$),k(t,de,$),e(de,Ee),e(Ee,so),y(pt,so,null),e(de,Ms),e(de,ro),e(ro,ys),k(t,cn,$),k(t,C,$),y(ct,C,null),e(C,js),e(C,ao),e(ao,Es),e(C,qs),e(C,dt),e(dt,Rs),e(dt,io),e(io,zs),e(dt,Fs),e(C,Cs),e(C,lo),e(lo,As),e(C,Ps),e(C,D),y(ut,D,null),e(D,Ns),e(D,ue),e(ue,Ss),e(ue,mo),e(mo,Is),e(ue,Ds),e(ue,po),e(po,Ls),e(ue,Hs),e(D,Qs),y(qe,D,null),e(D,Xs),y(Re,D,null),e(D,Ws),y(ze,D,null),k(t,dn,$),k(t,he,$),e(he,Fe),e(Fe,co),y(ht,co,null),e(he,Bs),e(he,uo),e(uo,Gs),k(t,un,$),k(t,A,$),y(ft,A,null),e(A,Vs),e(A,ho),e(ho,Js),e(A,Us),e(A,gt),e(gt,Ys),e(gt,fo),e(fo,Zs),e(gt,Ks),e(A,er),e(A,go),e(go,tr),e(A,or),e(A,L),y(_t,L,null),e(L,nr),e(L,fe),e(fe,sr),e(fe,_o),e(_o,rr),e(fe,ar),e(fe,$o),e($o,ir),e(fe,lr),e(L,mr),y(Ce,L,null),e(L,pr),y(Ae,L,null),e(L,cr),y(Pe,L,null),k(t,hn,$),k(t,ge,$),e(ge,Ne),e(Ne,ko),y($t,ko,null),e(ge,dr),e(ge,wo),e(wo,ur),k(t,fn,$),k(t,P,$),y(kt,P,null),e(P,hr),e(P,vo),e(vo,fr),e(P,gr),e(P,wt),e(wt,_r),e(wt,xo),e(xo,$r),e(wt,kr),e(P,wr),e(P,To),e(To,vr),e(P,xr),e(P,F),y(vt,F,null),e(F,Tr),e(F,_e),e(_e,br),e(_e,bo),e(bo,Or),e(_e,Mr),e(_e,Oo),e(Oo,yr),e(_e,jr),e(F,Er),y(Se,F,null),e(F,qr),y(Ie,F,null),e(F,Rr),y(De,F,null),e(F,zr),y(Le,F,null),k(t,gn,$),k(t,$e,$),e($e,He),e(He,Mo),y(xt,Mo,null),e($e,Fr),e($e,yo),e(yo,Cr),k(t,_n,$),k(t,N,$),y(Tt,N,null),e(N,Ar),e(N,jo),e(jo,Pr),e(N,Nr),e(N,bt),e(bt,Sr),e(bt,Eo),e(Eo,Ir),e(bt,Dr),e(N,Lr),e(N,qo),e(qo,Hr),e(N,Qr),e(N,H),y(Ot,H,null),e(H,Xr),e(H,ke),e(ke,Wr),e(ke,Ro),e(Ro,Br),e(ke,Gr),e(ke,zo),e(zo,Vr),e(ke,Jr),e(H,Ur),y(Qe,H,null),e(H,Yr),y(Xe,H,null),e(H,Zr),y(We,H,null),k(t,$n,$),k(t,we,$),e(we,Be),e(Be,Fo),y(Mt,Fo,null),e(we,Kr),e(we,Co),e(Co,ea),k(t,kn,$),k(t,S,$),y(yt,S,null),e(S,ta),e(S,Ao),e(Ao,oa),e(S,na),e(S,jt),e(jt,sa),e(jt,Po),e(Po,ra),e(jt,aa),e(S,ia),e(S,No),e(No,la),e(S,ma),e(S,Q),y(Et,Q,null),e(Q,pa),e(Q,ve),e(ve,ca),e(ve,So),e(So,da),e(ve,ua),e(ve,Io),e(Io,ha),e(ve,fa),e(Q,ga),y(Ge,Q,null),e(Q,_a),y(Ve,Q,null),e(Q,$a),y(Je,Q,null),wn=!0},p(t,[$]){const qt={};$&2&&(qt.$$scope={dirty:$,ctx:t}),qe.$set(qt);const Do={};$&2&&(Do.$$scope={dirty:$,ctx:t}),Re.$set(Do);const Lo={};$&2&&(Lo.$$scope={dirty:$,ctx:t}),ze.$set(Lo);const Ho={};$&2&&(Ho.$$scope={dirty:$,ctx:t}),Ce.$set(Ho);const Rt={};$&2&&(Rt.$$scope={dirty:$,ctx:t}),Ae.$set(Rt);const Qo={};$&2&&(Qo.$$scope={dirty:$,ctx:t}),Pe.$set(Qo);const zt={};$&2&&(zt.$$scope={dirty:$,ctx:t}),Se.$set(zt);const Xo={};$&2&&(Xo.$$scope={dirty:$,ctx:t}),Ie.$set(Xo);const Wo={};$&2&&(Wo.$$scope={dirty:$,ctx:t}),De.$set(Wo);const Bo={};$&2&&(Bo.$$scope={dirty:$,ctx:t}),Le.$set(Bo);const B={};$&2&&(B.$$scope={dirty:$,ctx:t}),Qe.$set(B);const Go={};$&2&&(Go.$$scope={dirty:$,ctx:t}),Xe.$set(Go);const Vo={};$&2&&(Vo.$$scope={dirty:$,ctx:t}),We.$set(Vo);const Jo={};$&2&&(Jo.$$scope={dirty:$,ctx:t}),Ge.$set(Jo);const Uo={};$&2&&(Uo.$$scope={dirty:$,ctx:t}),Ve.$set(Uo);const xe={};$&2&&(xe.$$scope={dirty:$,ctx:t}),Je.$set(xe)},i(t){wn||(T(s.$$.fragment,t),T(Ze.$$.fragment,t),T(Ke.$$.fragment,t),T(et.$$.fragment,t),T(tt.$$.fragment,t),T(nt.$$.fragment,t),T(st.$$.fragment,t),T(rt.$$.fragment,t),T(it.$$.fragment,t),T(mt.$$.fragment,t),T(pt.$$.fragment,t),T(ct.$$.fragment,t),T(ut.$$.fragment,t),T(qe.$$.fragment,t),T(Re.$$.fragment,t),T(ze.$$.fragment,t),T(ht.$$.fragment,t),T(ft.$$.fragment,t),T(_t.$$.fragment,t),T(Ce.$$.fragment,t),T(Ae.$$.fragment,t),T(Pe.$$.fragment,t),T($t.$$.fragment,t),T(kt.$$.fragment,t),T(vt.$$.fragment,t),T(Se.$$.fragment,t),T(Ie.$$.fragment,t),T(De.$$.fragment,t),T(Le.$$.fragment,t),T(xt.$$.fragment,t),T(Tt.$$.fragment,t),T(Ot.$$.fragment,t),T(Qe.$$.fragment,t),T(Xe.$$.fragment,t),T(We.$$.fragment,t),T(Mt.$$.fragment,t),T(yt.$$.fragment,t),T(Et.$$.fragment,t),T(Ge.$$.fragment,t),T(Ve.$$.fragment,t),T(Je.$$.fragment,t),wn=!0)},o(t){b(s.$$.fragment,t),b(Ze.$$.fragment,t),b(Ke.$$.fragment,t),b(et.$$.fragment,t),b(tt.$$.fragment,t),b(nt.$$.fragment,t),b(st.$$.fragment,t),b(rt.$$.fragment,t),b(it.$$.fragment,t),b(mt.$$.fragment,t),b(pt.$$.fragment,t),b(ct.$$.fragment,t),b(ut.$$.fragment,t),b(qe.$$.fragment,t),b(Re.$$.fragment,t),b(ze.$$.fragment,t),b(ht.$$.fragment,t),b(ft.$$.fragment,t),b(_t.$$.fragment,t),b(Ce.$$.fragment,t),b(Ae.$$.fragment,t),b(Pe.$$.fragment,t),b($t.$$.fragment,t),b(kt.$$.fragment,t),b(vt.$$.fragment,t),b(Se.$$.fragment,t),b(Ie.$$.fragment,t),b(De.$$.fragment,t),b(Le.$$.fragment,t),b(xt.$$.fragment,t),b(Tt.$$.fragment,t),b(Ot.$$.fragment,t),b(Qe.$$.fragment,t),b(Xe.$$.fragment,t),b(We.$$.fragment,t),b(Mt.$$.fragment,t),b(yt.$$.fragment,t),b(Et.$$.fragment,t),b(Ge.$$.fragment,t),b(Ve.$$.fragment,t),b(Je.$$.fragment,t),wn=!1},d(t){o(n),t&&o(g),t&&o(d),j(s),t&&o(w),t&&o(q),t&&o(Zo),t&&o(me),j(Ze),t&&o(Ko),t&&o(I),t&&o(en),j(Ke,t),t&&o(tn),t&&o(Z),t&&o(on),j(et,t),t&&o(nn),t&&o(be),t&&o(sn),t&&o(pe),j(tt),t&&o(rn),t&&o(V),t&&o(an),j(nt,t),t&&o(ln),t&&o(ce),j(st),t&&o(mn),t&&o(W),j(rt),j(it),j(mt),t&&o(pn),t&&o(de),j(pt),t&&o(cn),t&&o(C),j(ct),j(ut),j(qe),j(Re),j(ze),t&&o(dn),t&&o(he),j(ht),t&&o(un),t&&o(A),j(ft),j(_t),j(Ce),j(Ae),j(Pe),t&&o(hn),t&&o(ge),j($t),t&&o(fn),t&&o(P),j(kt),j(vt),j(Se),j(Ie),j(De),j(Le),t&&o(gn),t&&o($e),j(xt),t&&o(_n),t&&o(N),j(Tt),j(Ot),j(Qe),j(Xe),j(We),t&&o($n),t&&o(we),j(Mt),t&&o(kn),t&&o(S),j(yt),j(Et),j(Ge),j(Ve),j(Je)}}}const Ki={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 el(E){return bi(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class al extends vi{constructor(n){super();xi(this,n,el,Zi,Ti,{})}}export{al as default,Ki as metadata};
