import{S as da,i as ua,s as fa,H as ga,e as r,w as O,k as f,c as a,a as i,x as q,d as o,m as h,b as v,g as $,F as e,y as M,P as _a,I as ka,J as $a,K as wa,q as x,o as b,B as y,v as ha,Z as va,_ as Ta,t as p,M as xa,h as m,L as he}from"../../chunks/vendor-4918fc3c.js";import{T as nn}from"../../chunks/Tip-3d800dd6.js";import{D as te}from"../../chunks/Docstring-02f0cd65.js";import{C as W}from"../../chunks/CodeBlock-99419108.js";import{I as fe}from"../../chunks/IconCopyLink-21d338b1.js";const{window:ba}=va;function Oa(E){let n,_,d,u,k,s,l,T,c;u=new fe({props:{classNames:"text-smd"}});const w=E[4].default,j=ga(w,E,E[3],null);return{c(){n=r("div"),_=r("a"),d=r("span"),O(u.$$.fragment),s=f(),j&&j.c(),this.h()},l(F){n=a(F,"DIV",{class:!0});var R=i(n);_=a(R,"A",{id:!0,class:!0,href:!0});var ft=i(_);d=a(ft,"SPAN",{});var ht=i(d);q(u.$$.fragment,ht),ht.forEach(o),ft.forEach(o),s=h(R),j&&j.l(R),R.forEach(o),this.h()},h(){v(_,"id",E[0]),v(_,"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(_,"href",k=`#${E[0]}`),v(n,"class","relative group rounded-md")},m(F,R){$(F,n,R),e(n,_),e(_,d),M(u,d,null),e(n,s),j&&j.m(n,null),E[5](n),l=!0,T||(c=_a(ba,"hashchange",E[2]),T=!0)},p(F,[R]){(!l||R&1)&&v(_,"id",F[0]),(!l||R&1&&k!==(k=`#${F[0]}`))&&v(_,"href",k),j&&j.p&&(!l||R&8)&&ka(j,w,F,F[3],l?wa(w,F[3],R,null):$a(F[3]),null)},i(F){l||(x(u.$$.fragment,F),x(j,F),l=!0)},o(F){b(u.$$.fragment,F),b(j,F),l=!1},d(F){F&&o(n),y(u),j&&j.d(F),E[5](null),T=!1,c()}}}const ca="bg-yellow-50 dark:bg-[#494a3d]";function qa(E,n,_){let{$$slots:d={},$$scope:u}=n,{anchor:k}=n,s;function l(){const{hash:c}=window.location,w=c.substring(1);s&&s.classList.remove(...ca.split(" ")),w===k&&s.classList.add(...ca.split(" "))}ha(()=>{l()});function T(c){Ta[c?"unshift":"push"](()=>{s=c,_(1,s)})}return E.$$set=c=>{"anchor"in c&&_(0,k=c.anchor),"$$scope"in c&&_(3,u=c.$$scope)},[k,s,l,u,d,T]}class ue extends da{constructor(n){super();ua(this,n,qa,Oa,fa,{anchor:0})}}function Ma(E){let n,_,d,u,k;return{c(){n=r("p"),_=p("Although the recipe for forward pass needs to be defined within this function, one should call the "),d=r("code"),u=p("Module"),k=p(`
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);_=m(l,"Although the recipe for forward pass needs to be defined within this function, one should call the "),d=a(l,"CODE",{});var T=i(d);u=m(T,"Module"),T.forEach(o),k=m(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){$(s,n,l),e(n,_),e(n,d),e(d,u),e(n,k)},d(s){s&&o(n)}}}function ya(E){let n,_,d,u,k;return u=new W({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"),_=p("Example of feature extraction:"),d=f(),O(u.$$.fragment)},l(s){n=a(s,"P",{});var l=i(n);_=m(l,"Example of feature extraction:"),l.forEach(o),d=h(s),q(u.$$.fragment,s)},m(s,l){$(s,n,l),e(n,_),$(s,d,l),M(u,s,l),k=!0},p:he,i(s){k||(x(u.$$.fragment,s),k=!0)},o(s){b(u.$$.fragment,s),k=!1},d(s){s&&o(n),s&&o(d),y(u,s)}}}function Ea(E){let n,_,d,u,k,s,l,T;return l=new W({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"),_=p("Example using "),d=r("code"),u=p("transformers.pipeline"),k=p(":"),s=f(),O(l.$$.fragment)},l(c){n=a(c,"P",{});var w=i(n);_=m(w,"Example using "),d=a(w,"CODE",{});var j=i(d);u=m(j,"transformers.pipeline"),j.forEach(o),k=m(w,":"),w.forEach(o),s=h(c),q(l.$$.fragment,c)},m(c,w){$(c,n,w),e(n,_),e(n,d),e(d,u),e(n,k),$(c,s,w),M(l,c,w),T=!0},p:he,i(c){T||(x(l.$$.fragment,c),T=!0)},o(c){b(l.$$.fragment,c),T=!1},d(c){c&&o(n),c&&o(s),y(l,c)}}}function ja(E){let n,_,d,u,k;return{c(){n=r("p"),_=p("Although the recipe for forward pass needs to be defined within this function, one should call the "),d=r("code"),u=p("Module"),k=p(`
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);_=m(l,"Although the recipe for forward pass needs to be defined within this function, one should call the "),d=a(l,"CODE",{});var T=i(d);u=m(T,"Module"),T.forEach(o),k=m(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){$(s,n,l),e(n,_),e(n,d),e(d,u),e(n,k)},d(s){s&&o(n)}}}function Fa(E){let n,_,d,u,k;return u=new W({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"),_=p("Example of question answering:"),d=f(),O(u.$$.fragment)},l(s){n=a(s,"P",{});var l=i(n);_=m(l,"Example of question answering:"),l.forEach(o),d=h(s),q(u.$$.fragment,s)},m(s,l){$(s,n,l),e(n,_),$(s,d,l),M(u,s,l),k=!0},p:he,i(s){k||(x(u.$$.fragment,s),k=!0)},o(s){b(u.$$.fragment,s),k=!1},d(s){s&&o(n),s&&o(d),y(u,s)}}}function Ra(E){let n,_,d,u,k,s,l,T;return l=new W({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"),_=p("Example using "),d=r("code"),u=p("transformers.pipeline"),k=p(":"),s=f(),O(l.$$.fragment)},l(c){n=a(c,"P",{});var w=i(n);_=m(w,"Example using "),d=a(w,"CODE",{});var j=i(d);u=m(j,"transformers.pipeline"),j.forEach(o),k=m(w,":"),w.forEach(o),s=h(c),q(l.$$.fragment,c)},m(c,w){$(c,n,w),e(n,_),e(n,d),e(d,u),e(n,k),$(c,s,w),M(l,c,w),T=!0},p:he,i(c){T||(x(l.$$.fragment,c),T=!0)},o(c){b(l.$$.fragment,c),T=!1},d(c){c&&o(n),c&&o(s),y(l,c)}}}function za(E){let n,_,d,u,k;return{c(){n=r("p"),_=p("Although the recipe for forward pass needs to be defined within this function, one should call the "),d=r("code"),u=p("Module"),k=p(`
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);_=m(l,"Although the recipe for forward pass needs to be defined within this function, one should call the "),d=a(l,"CODE",{});var T=i(d);u=m(T,"Module"),T.forEach(o),k=m(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){$(s,n,l),e(n,_),e(n,d),e(d,u),e(n,k)},d(s){s&&o(n)}}}function Aa(E){let n,_,d,u,k;return u=new W({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"),_=p("Example of single-label classification:"),d=f(),O(u.$$.fragment)},l(s){n=a(s,"P",{});var l=i(n);_=m(l,"Example of single-label classification:"),l.forEach(o),d=h(s),q(u.$$.fragment,s)},m(s,l){$(s,n,l),e(n,_),$(s,d,l),M(u,s,l),k=!0},p:he,i(s){k||(x(u.$$.fragment,s),k=!0)},o(s){b(u.$$.fragment,s),k=!1},d(s){s&&o(n),s&&o(d),y(u,s)}}}function Ca(E){let n,_,d,u,k,s,l,T;return l=new W({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"),_=p("Example using "),d=r("code"),u=p("transformers.pipelines"),k=p(":"),s=f(),O(l.$$.fragment)},l(c){n=a(c,"P",{});var w=i(n);_=m(w,"Example using "),d=a(w,"CODE",{});var j=i(d);u=m(j,"transformers.pipelines"),j.forEach(o),k=m(w,":"),w.forEach(o),s=h(c),q(l.$$.fragment,c)},m(c,w){$(c,n,w),e(n,_),e(n,d),e(d,u),e(n,k),$(c,s,w),M(l,c,w),T=!0},p:he,i(c){T||(x(l.$$.fragment,c),T=!0)},o(c){b(l.$$.fragment,c),T=!1},d(c){c&&o(n),c&&o(s),y(l,c)}}}function Pa(E){let n,_,d,u,k,s,l,T;return l=new W({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"),_=p("Example using zero-shot-classification "),d=r("code"),u=p("transformers.pipelines"),k=p(":"),s=f(),O(l.$$.fragment)},l(c){n=a(c,"P",{});var w=i(n);_=m(w,"Example using zero-shot-classification "),d=a(w,"CODE",{});var j=i(d);u=m(j,"transformers.pipelines"),j.forEach(o),k=m(w,":"),w.forEach(o),s=h(c),q(l.$$.fragment,c)},m(c,w){$(c,n,w),e(n,_),e(n,d),e(d,u),e(n,k),$(c,s,w),M(l,c,w),T=!0},p:he,i(c){T||(x(l.$$.fragment,c),T=!0)},o(c){b(l.$$.fragment,c),T=!1},d(c){c&&o(n),c&&o(s),y(l,c)}}}function Na(E){let n,_,d,u,k;return{c(){n=r("p"),_=p("Although the recipe for forward pass needs to be defined within this function, one should call the "),d=r("code"),u=p("Module"),k=p(`
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);_=m(l,"Although the recipe for forward pass needs to be defined within this function, one should call the "),d=a(l,"CODE",{});var T=i(d);u=m(T,"Module"),T.forEach(o),k=m(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){$(s,n,l),e(n,_),e(n,d),e(d,u),e(n,k)},d(s){s&&o(n)}}}function Sa(E){let n,_,d,u,k;return u=new W({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"),_=p("Example of token classification:"),d=f(),O(u.$$.fragment)},l(s){n=a(s,"P",{});var l=i(n);_=m(l,"Example of token classification:"),l.forEach(o),d=h(s),q(u.$$.fragment,s)},m(s,l){$(s,n,l),e(n,_),$(s,d,l),M(u,s,l),k=!0},p:he,i(s){k||(x(u.$$.fragment,s),k=!0)},o(s){b(u.$$.fragment,s),k=!1},d(s){s&&o(n),s&&o(d),y(u,s)}}}function Ia(E){let n,_,d,u,k,s,l,T;return l=new W({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"),_=p("Example using "),d=r("code"),u=p("transformers.pipelines"),k=p(":"),s=f(),O(l.$$.fragment)},l(c){n=a(c,"P",{});var w=i(n);_=m(w,"Example using "),d=a(w,"CODE",{});var j=i(d);u=m(j,"transformers.pipelines"),j.forEach(o),k=m(w,":"),w.forEach(o),s=h(c),q(l.$$.fragment,c)},m(c,w){$(c,n,w),e(n,_),e(n,d),e(d,u),e(n,k),$(c,s,w),M(l,c,w),T=!0},p:he,i(c){T||(x(l.$$.fragment,c),T=!0)},o(c){b(l.$$.fragment,c),T=!1},d(c){c&&o(n),c&&o(s),y(l,c)}}}function Da(E){let n,_,d,u,k,s,l,T,c,w,j,F,R,ft,ht,bo,oe,ge,bt,Ie,sn,Ot,rn,Oo,S,an,qt,ln,pn,Mt,mn,cn,yt,dn,un,Et,fn,hn,qo,De,Mo,G,gn,jt,_n,kn,Ft,$n,wn,yo,He,Eo,_e,vn,gt,Tn,xn,jo,ne,ke,Rt,Qe,bn,zt,On,Fo,L,qn,At,Mn,yn,Le,En,jn,Ct,Fn,Rn,Ro,Xe,zo,se,$e,Pt,We,zn,Nt,An,Ao,B,Be,Cn,Ge,Pn,St,Nn,Sn,In,we,Ue,Dn,_t,Hn,It,Qn,Co,re,ve,Dt,Ve,Ln,Ht,Xn,Po,A,Je,Wn,Qt,Bn,Gn,Ye,Un,Lt,Vn,Jn,Yn,Xt,Kn,Zn,I,Ke,es,ae,ts,Wt,os,ns,Bt,ss,rs,as,Te,is,xe,ls,be,No,ie,Oe,Gt,Ze,ps,Ut,ms,So,C,et,cs,Vt,ds,us,tt,fs,Jt,hs,gs,_s,Yt,ks,$s,D,ot,ws,le,vs,Kt,Ts,xs,Zt,bs,Os,qs,qe,Ms,Me,ys,ye,Io,pe,Ee,eo,nt,Es,to,js,Do,P,st,Fs,oo,Rs,zs,rt,As,no,Cs,Ps,Ns,so,Ss,Is,z,at,Ds,me,Hs,ro,Qs,Ls,ao,Xs,Ws,Bs,je,Gs,Fe,Us,Re,Vs,ze,Ho,ce,Ae,io,it,Js,lo,Ys,Qo,N,lt,Ks,po,Zs,er,pt,tr,mo,or,nr,sr,co,rr,ar,H,mt,ir,de,lr,uo,pr,mr,fo,cr,dr,ur,Ce,fr,Pe,hr,Ne,Lo;return s=new fe({}),Ie=new fe({}),De=new W({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)`}}),He=new W({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>}]`}}),Qe=new fe({}),Xe=new W({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>
                  )`}}),We=new fe({}),Be=new te({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_166/src/optimum/onnxruntime/modeling_ort.py#L80"}}),Ue=new te({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
provider(<code>str</code>) &#x2014;
Onnxruntime provider to use for loading the model, defaults to <em>CUDAExecutionProvider</em> if GPU is
available else <em>CPUExecutionProvider</em>`,name:"path"}],source:"https://github.com/huggingface/optimum/blob/vr_166/src/optimum/onnxruntime/modeling_ort.py#L98"}}),Ve=new fe({}),Je=new te({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>PretrainedConfig</code>](https &#x2014;//huggingface.co/docs/transformers/main_classes/configuration#transformers.PretrainedConfig)): 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>](https &#x2014;//onnxruntime.ai/docs/api/python/api_summary.html#inferencesession)): This is the main class used to run a model. Check out the <code>load_model</code>",name:"model"},{anchor:"optimum.onnxruntime.ORTModelForFeatureExtraction.for",description:"<strong>for</strong> more information. &#x2014;",name:"for"}],source:"https://github.com/huggingface/optimum/blob/vr_166/src/optimum/onnxruntime/modeling_ort.py#L295"}}),Ke=new te({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_166/src/optimum/onnxruntime/modeling_ort.py#L309"}}),Te=new nn({props:{$$slots:{default:[Ma]},$$scope:{ctx:E}}}),xe=new ue({props:{anchor:"optimum.onnxruntime.ORTModelForFeatureExtraction.forward.example",$$slots:{default:[ya]},$$scope:{ctx:E}}}),be=new ue({props:{anchor:"optimum.onnxruntime.ORTModelForFeatureExtraction.forward.example-2",$$slots:{default:[Ea]},$$scope:{ctx:E}}}),Ze=new fe({}),et=new te({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>PretrainedConfig</code>](https &#x2014;//huggingface.co/docs/transformers/main_classes/configuration#transformers.PretrainedConfig)): 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>](https &#x2014;//onnxruntime.ai/docs/api/python/api_summary.html#inferencesession)): This is the main class used to run a model. Check out the <code>load_model</code>",name:"model"},{anchor:"optimum.onnxruntime.ORTModelForQuestionAnswering.for",description:"<strong>for</strong> more information. &#x2014;",name:"for"}],source:"https://github.com/huggingface/optimum/blob/vr_166/src/optimum/onnxruntime/modeling_ort.py#L381"}}),ot=new te({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_166/src/optimum/onnxruntime/modeling_ort.py#L395"}}),qe=new nn({props:{$$slots:{default:[ja]},$$scope:{ctx:E}}}),Me=new ue({props:{anchor:"optimum.onnxruntime.ORTModelForQuestionAnswering.forward.example",$$slots:{default:[Fa]},$$scope:{ctx:E}}}),ye=new ue({props:{anchor:"optimum.onnxruntime.ORTModelForQuestionAnswering.forward.example-2",$$slots:{default:[Ra]},$$scope:{ctx:E}}}),nt=new fe({}),st=new te({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>PretrainedConfig</code>](https &#x2014;//huggingface.co/docs/transformers/main_classes/configuration#transformers.PretrainedConfig)): 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>](https &#x2014;//onnxruntime.ai/docs/api/python/api_summary.html#inferencesession)): This is the main class used to run a model. Check out the <code>load_model</code>",name:"model"},{anchor:"optimum.onnxruntime.ORTModelForSequenceClassification.for",description:"<strong>for</strong> more information. &#x2014;",name:"for"}],source:"https://github.com/huggingface/optimum/blob/vr_166/src/optimum/onnxruntime/modeling_ort.py#L482"}}),at=new te({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_166/src/optimum/onnxruntime/modeling_ort.py#L497"}}),je=new nn({props:{$$slots:{default:[za]},$$scope:{ctx:E}}}),Fe=new ue({props:{anchor:"optimum.onnxruntime.ORTModelForSequenceClassification.forward.example",$$slots:{default:[Aa]},$$scope:{ctx:E}}}),Re=new ue({props:{anchor:"optimum.onnxruntime.ORTModelForSequenceClassification.forward.example-2",$$slots:{default:[Ca]},$$scope:{ctx:E}}}),ze=new ue({props:{anchor:"optimum.onnxruntime.ORTModelForSequenceClassification.forward.example-3",$$slots:{default:[Pa]},$$scope:{ctx:E}}}),it=new fe({}),lt=new te({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>PretrainedConfig</code>](https &#x2014;//huggingface.co/docs/transformers/main_classes/configuration#transformers.PretrainedConfig)): 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>](https &#x2014;//onnxruntime.ai/docs/api/python/api_summary.html#inferencesession)): This is the main class used to run a model. Check out the <code>load_model</code>",name:"model"},{anchor:"optimum.onnxruntime.ORTModelForTokenClassification.for",description:"<strong>for</strong> more information. &#x2014;",name:"for"}],source:"https://github.com/huggingface/optimum/blob/vr_166/src/optimum/onnxruntime/modeling_ort.py#L569"}}),mt=new te({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_166/src/optimum/onnxruntime/modeling_ort.py#L583"}}),Ce=new nn({props:{$$slots:{default:[Na]},$$scope:{ctx:E}}}),Pe=new ue({props:{anchor:"optimum.onnxruntime.ORTModelForTokenClassification.forward.example",$$slots:{default:[Sa]},$$scope:{ctx:E}}}),Ne=new ue({props:{anchor:"optimum.onnxruntime.ORTModelForTokenClassification.forward.example-2",$$slots:{default:[Ia]},$$scope:{ctx:E}}}),{c(){n=r("meta"),_=f(),d=r("h1"),u=r("a"),k=r("span"),O(s.$$.fragment),l=f(),T=r("span"),c=p("Optimum Inference with ONNX Runtime"),w=f(),j=r("p"),F=p(`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"),ft=p("Hugging Face Hub"),ht=p(` and create pipelines
to run accelerated inference without rewriting your APIs.`),bo=f(),oe=r("h2"),ge=r("a"),bt=r("span"),O(Ie.$$.fragment),sn=f(),Ot=r("span"),rn=p("Switching from Transformers to Optimum Inference"),Oo=f(),S=r("p"),an=p("The Optimum Inference models are API compatible with Hugging Face Transformers models. This means you can just replace your "),qt=r("code"),ln=p("AutoModelForXxx"),pn=p(" class with the corresponding "),Mt=r("code"),mn=p("ORTModelForXxx"),cn=p(" class in "),yt=r("code"),dn=p("optimum"),un=p(". For example, this is how you can use a question answering model in "),Et=r("code"),fn=p("optimum"),hn=p(":"),qo=f(),O(De.$$.fragment),Mo=f(),G=r("p"),gn=p("Optimum Inference also includes methods to convert vanilla Transformers models to optimized ones. Simply pass "),jt=r("code"),_n=p("from_transformers=True"),kn=p(" to the "),Ft=r("code"),$n=p("from_pretrained()"),wn=p(" method, and your model will be loaded and converted to ONNX on-the-fly:"),yo=f(),O(He.$$.fragment),Eo=f(),_e=r("p"),vn=p("You can find a complete walkhrough Optimum Inference for ONNX Runtime in this "),gt=r("a"),Tn=p("notebook"),xn=p("."),jo=f(),ne=r("h3"),ke=r("a"),Rt=r("span"),O(Qe.$$.fragment),bn=f(),zt=r("span"),On=p("Working with the [Hugging Face Model Hub](https://hf.co/models)"),Fo=f(),L=r("p"),qn=p("The Optimum model classes like "),At=r("code"),Mn=p("~ORTModelForSequenceClassification"),yn=p(" are integrated with the "),Le=r("a"),En=p("Hugging Face Model Hub"),jn=p(`), which means you can not only
load model from the Hub, but also push your models to the Hub with `),Ct=r("code"),Fn=p("push_to_hub()"),Rn=p(` 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.`),Ro=f(),O(Xe.$$.fragment),zo=f(),se=r("h2"),$e=r("a"),Pt=r("span"),O(We.$$.fragment),zn=f(),Nt=r("span"),An=p("ORTModel"),Ao=f(),B=r("div"),O(Be.$$.fragment),Cn=f(),Ge=r("p"),Pn=p(`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 `),St=r("code"),Nn=p("transformers.onnx"),Sn=p(` toolchain.
The ORTModel implements additionally generic methods for optimizing and quantizing Onnx models.`),In=f(),we=r("div"),O(Ue.$$.fragment),Dn=f(),_t=r("p"),Hn=p("loads ONNX Inference session with Provider. Default Provider is if CUDAExecutionProvider GPU available else "),It=r("em"),Qn=p("CPUExecutionProvider"),Co=f(),re=r("h2"),ve=r("a"),Dt=r("span"),O(Ve.$$.fragment),Ln=f(),Ht=r("span"),Xn=p("ORTModelForFeatureExtraction"),Po=f(),A=r("div"),O(Je.$$.fragment),Wn=f(),Qt=r("p"),Bn=p("Onnx Model with a MaskedLMOutput for feature-extraction tasks."),Gn=f(),Ye=r("p"),Un=p("This model inherits from "),Lt=r("code"),Vn=p("ORTModel"),Jn=p(`. Check the superclass documentation for the generic methods the
library implements for all its model (such as downloading or saving)`),Yn=f(),Xt=r("p"),Kn=p("Feature Extraction model for ONNX."),Zn=f(),I=r("div"),O(Ke.$$.fragment),es=f(),ae=r("p"),ts=p("The "),Wt=r("code"),os=p("ORTModelForFeatureExtraction"),ns=p(" forward method, overrides the "),Bt=r("code"),ss=p("__call__"),rs=p(" special method."),as=f(),O(Te.$$.fragment),is=f(),O(xe.$$.fragment),ls=f(),O(be.$$.fragment),No=f(),ie=r("h2"),Oe=r("a"),Gt=r("span"),O(Ze.$$.fragment),ps=f(),Ut=r("span"),ms=p("ORTModelForQuestionAnswering"),So=f(),C=r("div"),O(et.$$.fragment),cs=f(),Vt=r("p"),ds=p("Onnx Model with a QuestionAnsweringModelOutput for extractive question-answering tasks like SQuAD."),us=f(),tt=r("p"),fs=p("This model inherits from "),Jt=r("code"),hs=p("ORTModel"),gs=p(`. Check the superclass documentation for the generic methods the
library implements for all its model (such as downloading or saving)`),_s=f(),Yt=r("p"),ks=p("Question Answering model for ONNX."),$s=f(),D=r("div"),O(ot.$$.fragment),ws=f(),le=r("p"),vs=p("The "),Kt=r("code"),Ts=p("ORTModelForQuestionAnswering"),xs=p(" forward method, overrides the "),Zt=r("code"),bs=p("__call__"),Os=p(" special method."),qs=f(),O(qe.$$.fragment),Ms=f(),O(Me.$$.fragment),ys=f(),O(ye.$$.fragment),Io=f(),pe=r("h2"),Ee=r("a"),eo=r("span"),O(nt.$$.fragment),Es=f(),to=r("span"),js=p("ORTModelForSequenceClassification"),Do=f(),P=r("div"),O(st.$$.fragment),Fs=f(),oo=r("p"),Rs=p(`Onnx Model with a sequence classification/regression head on top (a linear layer on top of the
pooled output) e.g. for GLUE tasks.`),zs=f(),rt=r("p"),As=p("This model inherits from "),no=r("code"),Cs=p("ORTModel"),Ps=p(`. Check the superclass documentation for the generic methods the
library implements for all its model (such as downloading or saving)`),Ns=f(),so=r("p"),Ss=p("Sequence Classification model for ONNX."),Is=f(),z=r("div"),O(at.$$.fragment),Ds=f(),me=r("p"),Hs=p("The "),ro=r("code"),Qs=p("ORTModelForSequenceClassification"),Ls=p(" forward method, overrides the "),ao=r("code"),Xs=p("__call__"),Ws=p(" special method."),Bs=f(),O(je.$$.fragment),Gs=f(),O(Fe.$$.fragment),Us=f(),O(Re.$$.fragment),Vs=f(),O(ze.$$.fragment),Ho=f(),ce=r("h2"),Ae=r("a"),io=r("span"),O(it.$$.fragment),Js=f(),lo=r("span"),Ys=p("ORTModelForTokenClassification"),Qo=f(),N=r("div"),O(lt.$$.fragment),Ks=f(),po=r("p"),Zs=p(`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.`),er=f(),pt=r("p"),tr=p("This model inherits from "),mo=r("code"),or=p("ORTModel"),nr=p(`. Check the superclass documentation for the generic methods the
library implements for all its model (such as downloading or saving)`),sr=f(),co=r("p"),rr=p("Token Classification model for ONNX."),ar=f(),H=r("div"),O(mt.$$.fragment),ir=f(),de=r("p"),lr=p("The "),uo=r("code"),pr=p("ORTModelForTokenClassification"),mr=p(" forward method, overrides the "),fo=r("code"),cr=p("__call__"),dr=p(" special method."),ur=f(),O(Ce.$$.fragment),fr=f(),O(Pe.$$.fragment),hr=f(),O(Ne.$$.fragment),this.h()},l(t){const g=xa('[data-svelte="svelte-1phssyn"]',document.head);n=a(g,"META",{name:!0,content:!0}),g.forEach(o),_=h(t),d=a(t,"H1",{class:!0});var ct=i(d);u=a(ct,"A",{id:!0,class:!0,href:!0});var ho=i(u);k=a(ho,"SPAN",{});var go=i(k);q(s.$$.fragment,go),go.forEach(o),ho.forEach(o),l=h(ct),T=a(ct,"SPAN",{});var _o=i(T);c=m(_o,"Optimum Inference with ONNX Runtime"),_o.forEach(o),ct.forEach(o),w=h(t),j=a(t,"P",{});var dt=i(j);F=m(dt,`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(dt,"A",{href:!0});var ko=i(R);ft=m(ko,"Hugging Face Hub"),ko.forEach(o),ht=m(dt,` and create pipelines
to run accelerated inference without rewriting your APIs.`),dt.forEach(o),bo=h(t),oe=a(t,"H2",{class:!0});var ut=i(oe);ge=a(ut,"A",{id:!0,class:!0,href:!0});var $o=i(ge);bt=a($o,"SPAN",{});var wo=i(bt);q(Ie.$$.fragment,wo),wo.forEach(o),$o.forEach(o),sn=h(ut),Ot=a(ut,"SPAN",{});var vo=i(Ot);rn=m(vo,"Switching from Transformers to Optimum Inference"),vo.forEach(o),ut.forEach(o),Oo=h(t),S=a(t,"P",{});var Q=i(S);an=m(Q,"The Optimum Inference models are API compatible with Hugging Face Transformers models. This means you can just replace your "),qt=a(Q,"CODE",{});var To=i(qt);ln=m(To,"AutoModelForXxx"),To.forEach(o),pn=m(Q," class with the corresponding "),Mt=a(Q,"CODE",{});var xo=i(Mt);mn=m(xo,"ORTModelForXxx"),xo.forEach(o),cn=m(Q," class in "),yt=a(Q,"CODE",{});var _r=i(yt);dn=m(_r,"optimum"),_r.forEach(o),un=m(Q,". For example, this is how you can use a question answering model in "),Et=a(Q,"CODE",{});var kr=i(Et);fn=m(kr,"optimum"),kr.forEach(o),hn=m(Q,":"),Q.forEach(o),qo=h(t),q(De.$$.fragment,t),Mo=h(t),G=a(t,"P",{});var kt=i(G);gn=m(kt,"Optimum Inference also includes methods to convert vanilla Transformers models to optimized ones. Simply pass "),jt=a(kt,"CODE",{});var $r=i(jt);_n=m($r,"from_transformers=True"),$r.forEach(o),kn=m(kt," to the "),Ft=a(kt,"CODE",{});var wr=i(Ft);$n=m(wr,"from_pretrained()"),wr.forEach(o),wn=m(kt," method, and your model will be loaded and converted to ONNX on-the-fly:"),kt.forEach(o),yo=h(t),q(He.$$.fragment,t),Eo=h(t),_e=a(t,"P",{});var Xo=i(_e);vn=m(Xo,"You can find a complete walkhrough Optimum Inference for ONNX Runtime in this "),gt=a(Xo,"A",{href:!0});var vr=i(gt);Tn=m(vr,"notebook"),vr.forEach(o),xn=m(Xo,"."),Xo.forEach(o),jo=h(t),ne=a(t,"H3",{class:!0});var Wo=i(ne);ke=a(Wo,"A",{id:!0,class:!0,href:!0});var Tr=i(ke);Rt=a(Tr,"SPAN",{});var xr=i(Rt);q(Qe.$$.fragment,xr),xr.forEach(o),Tr.forEach(o),bn=h(Wo),zt=a(Wo,"SPAN",{});var br=i(zt);On=m(br,"Working with the [Hugging Face Model Hub](https://hf.co/models)"),br.forEach(o),Wo.forEach(o),Fo=h(t),L=a(t,"P",{});var Se=i(L);qn=m(Se,"The Optimum model classes like "),At=a(Se,"CODE",{});var Or=i(At);Mn=m(Or,"~ORTModelForSequenceClassification"),Or.forEach(o),yn=m(Se," are integrated with the "),Le=a(Se,"A",{href:!0,rel:!0});var qr=i(Le);En=m(qr,"Hugging Face Model Hub"),qr.forEach(o),jn=m(Se,`), which means you can not only
load model from the Hub, but also push your models to the Hub with `),Ct=a(Se,"CODE",{});var Mr=i(Ct);Fn=m(Mr,"push_to_hub()"),Mr.forEach(o),Rn=m(Se,` 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.`),Se.forEach(o),Ro=h(t),q(Xe.$$.fragment,t),zo=h(t),se=a(t,"H2",{class:!0});var Bo=i(se);$e=a(Bo,"A",{id:!0,class:!0,href:!0});var yr=i($e);Pt=a(yr,"SPAN",{});var Er=i(Pt);q(We.$$.fragment,Er),Er.forEach(o),yr.forEach(o),zn=h(Bo),Nt=a(Bo,"SPAN",{});var jr=i(Nt);An=m(jr,"ORTModel"),jr.forEach(o),Bo.forEach(o),Ao=h(t),B=a(t,"DIV",{class:!0});var $t=i(B);q(Be.$$.fragment,$t),Cn=h($t),Ge=a($t,"P",{});var Go=i(Ge);Pn=m(Go,`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 `),St=a(Go,"CODE",{});var Fr=i(St);Nn=m(Fr,"transformers.onnx"),Fr.forEach(o),Sn=m(Go,` toolchain.
The ORTModel implements additionally generic methods for optimizing and quantizing Onnx models.`),Go.forEach(o),In=h($t),we=a($t,"DIV",{class:!0});var Uo=i(we);q(Ue.$$.fragment,Uo),Dn=h(Uo),_t=a(Uo,"P",{});var gr=i(_t);Hn=m(gr,"loads ONNX Inference session with Provider. Default Provider is if CUDAExecutionProvider GPU available else "),It=a(gr,"EM",{});var Rr=i(It);Qn=m(Rr,"CPUExecutionProvider"),Rr.forEach(o),gr.forEach(o),Uo.forEach(o),$t.forEach(o),Co=h(t),re=a(t,"H2",{class:!0});var Vo=i(re);ve=a(Vo,"A",{id:!0,class:!0,href:!0});var zr=i(ve);Dt=a(zr,"SPAN",{});var Ar=i(Dt);q(Ve.$$.fragment,Ar),Ar.forEach(o),zr.forEach(o),Ln=h(Vo),Ht=a(Vo,"SPAN",{});var Cr=i(Ht);Xn=m(Cr,"ORTModelForFeatureExtraction"),Cr.forEach(o),Vo.forEach(o),Po=h(t),A=a(t,"DIV",{class:!0});var U=i(A);q(Je.$$.fragment,U),Wn=h(U),Qt=a(U,"P",{});var Pr=i(Qt);Bn=m(Pr,"Onnx Model with a MaskedLMOutput for feature-extraction tasks."),Pr.forEach(o),Gn=h(U),Ye=a(U,"P",{});var Jo=i(Ye);Un=m(Jo,"This model inherits from "),Lt=a(Jo,"CODE",{});var Nr=i(Lt);Vn=m(Nr,"ORTModel"),Nr.forEach(o),Jn=m(Jo,`. Check the superclass documentation for the generic methods the
library implements for all its model (such as downloading or saving)`),Jo.forEach(o),Yn=h(U),Xt=a(U,"P",{});var Sr=i(Xt);Kn=m(Sr,"Feature Extraction model for ONNX."),Sr.forEach(o),Zn=h(U),I=a(U,"DIV",{class:!0});var V=i(I);q(Ke.$$.fragment,V),es=h(V),ae=a(V,"P",{});var wt=i(ae);ts=m(wt,"The "),Wt=a(wt,"CODE",{});var Ir=i(Wt);os=m(Ir,"ORTModelForFeatureExtraction"),Ir.forEach(o),ns=m(wt," forward method, overrides the "),Bt=a(wt,"CODE",{});var Dr=i(Bt);ss=m(Dr,"__call__"),Dr.forEach(o),rs=m(wt," special method."),wt.forEach(o),as=h(V),q(Te.$$.fragment,V),is=h(V),q(xe.$$.fragment,V),ls=h(V),q(be.$$.fragment,V),V.forEach(o),U.forEach(o),No=h(t),ie=a(t,"H2",{class:!0});var Yo=i(ie);Oe=a(Yo,"A",{id:!0,class:!0,href:!0});var Hr=i(Oe);Gt=a(Hr,"SPAN",{});var Qr=i(Gt);q(Ze.$$.fragment,Qr),Qr.forEach(o),Hr.forEach(o),ps=h(Yo),Ut=a(Yo,"SPAN",{});var Lr=i(Ut);ms=m(Lr,"ORTModelForQuestionAnswering"),Lr.forEach(o),Yo.forEach(o),So=h(t),C=a(t,"DIV",{class:!0});var J=i(C);q(et.$$.fragment,J),cs=h(J),Vt=a(J,"P",{});var Xr=i(Vt);ds=m(Xr,"Onnx Model with a QuestionAnsweringModelOutput for extractive question-answering tasks like SQuAD."),Xr.forEach(o),us=h(J),tt=a(J,"P",{});var Ko=i(tt);fs=m(Ko,"This model inherits from "),Jt=a(Ko,"CODE",{});var Wr=i(Jt);hs=m(Wr,"ORTModel"),Wr.forEach(o),gs=m(Ko,`. Check the superclass documentation for the generic methods the
library implements for all its model (such as downloading or saving)`),Ko.forEach(o),_s=h(J),Yt=a(J,"P",{});var Br=i(Yt);ks=m(Br,"Question Answering model for ONNX."),Br.forEach(o),$s=h(J),D=a(J,"DIV",{class:!0});var Y=i(D);q(ot.$$.fragment,Y),ws=h(Y),le=a(Y,"P",{});var vt=i(le);vs=m(vt,"The "),Kt=a(vt,"CODE",{});var Gr=i(Kt);Ts=m(Gr,"ORTModelForQuestionAnswering"),Gr.forEach(o),xs=m(vt," forward method, overrides the "),Zt=a(vt,"CODE",{});var Ur=i(Zt);bs=m(Ur,"__call__"),Ur.forEach(o),Os=m(vt," special method."),vt.forEach(o),qs=h(Y),q(qe.$$.fragment,Y),Ms=h(Y),q(Me.$$.fragment,Y),ys=h(Y),q(ye.$$.fragment,Y),Y.forEach(o),J.forEach(o),Io=h(t),pe=a(t,"H2",{class:!0});var Zo=i(pe);Ee=a(Zo,"A",{id:!0,class:!0,href:!0});var Vr=i(Ee);eo=a(Vr,"SPAN",{});var Jr=i(eo);q(nt.$$.fragment,Jr),Jr.forEach(o),Vr.forEach(o),Es=h(Zo),to=a(Zo,"SPAN",{});var Yr=i(to);js=m(Yr,"ORTModelForSequenceClassification"),Yr.forEach(o),Zo.forEach(o),Do=h(t),P=a(t,"DIV",{class:!0});var K=i(P);q(st.$$.fragment,K),Fs=h(K),oo=a(K,"P",{});var Kr=i(oo);Rs=m(Kr,`Onnx Model with a sequence classification/regression head on top (a linear layer on top of the
pooled output) e.g. for GLUE tasks.`),Kr.forEach(o),zs=h(K),rt=a(K,"P",{});var en=i(rt);As=m(en,"This model inherits from "),no=a(en,"CODE",{});var Zr=i(no);Cs=m(Zr,"ORTModel"),Zr.forEach(o),Ps=m(en,`. Check the superclass documentation for the generic methods the
library implements for all its model (such as downloading or saving)`),en.forEach(o),Ns=h(K),so=a(K,"P",{});var ea=i(so);Ss=m(ea,"Sequence Classification model for ONNX."),ea.forEach(o),Is=h(K),z=a(K,"DIV",{class:!0});var X=i(z);q(at.$$.fragment,X),Ds=h(X),me=a(X,"P",{});var Tt=i(me);Hs=m(Tt,"The "),ro=a(Tt,"CODE",{});var ta=i(ro);Qs=m(ta,"ORTModelForSequenceClassification"),ta.forEach(o),Ls=m(Tt," forward method, overrides the "),ao=a(Tt,"CODE",{});var oa=i(ao);Xs=m(oa,"__call__"),oa.forEach(o),Ws=m(Tt," special method."),Tt.forEach(o),Bs=h(X),q(je.$$.fragment,X),Gs=h(X),q(Fe.$$.fragment,X),Us=h(X),q(Re.$$.fragment,X),Vs=h(X),q(ze.$$.fragment,X),X.forEach(o),K.forEach(o),Ho=h(t),ce=a(t,"H2",{class:!0});var tn=i(ce);Ae=a(tn,"A",{id:!0,class:!0,href:!0});var na=i(Ae);io=a(na,"SPAN",{});var sa=i(io);q(it.$$.fragment,sa),sa.forEach(o),na.forEach(o),Js=h(tn),lo=a(tn,"SPAN",{});var ra=i(lo);Ys=m(ra,"ORTModelForTokenClassification"),ra.forEach(o),tn.forEach(o),Qo=h(t),N=a(t,"DIV",{class:!0});var Z=i(N);q(lt.$$.fragment,Z),Ks=h(Z),po=a(Z,"P",{});var aa=i(po);Zs=m(aa,`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.`),aa.forEach(o),er=h(Z),pt=a(Z,"P",{});var on=i(pt);tr=m(on,"This model inherits from "),mo=a(on,"CODE",{});var ia=i(mo);or=m(ia,"ORTModel"),ia.forEach(o),nr=m(on,`. Check the superclass documentation for the generic methods the
library implements for all its model (such as downloading or saving)`),on.forEach(o),sr=h(Z),co=a(Z,"P",{});var la=i(co);rr=m(la,"Token Classification model for ONNX."),la.forEach(o),ar=h(Z),H=a(Z,"DIV",{class:!0});var ee=i(H);q(mt.$$.fragment,ee),ir=h(ee),de=a(ee,"P",{});var xt=i(de);lr=m(xt,"The "),uo=a(xt,"CODE",{});var pa=i(uo);pr=m(pa,"ORTModelForTokenClassification"),pa.forEach(o),mr=m(xt," forward method, overrides the "),fo=a(xt,"CODE",{});var ma=i(fo);cr=m(ma,"__call__"),ma.forEach(o),dr=m(xt," special method."),xt.forEach(o),ur=h(ee),q(Ce.$$.fragment,ee),fr=h(ee),q(Pe.$$.fragment,ee),hr=h(ee),q(Ne.$$.fragment,ee),ee.forEach(o),Z.forEach(o),this.h()},h(){v(n,"name","hf:doc:metadata"),v(n,"content",JSON.stringify(Ha)),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(ge,"id","switching-from-transformers-to-optimum-inference"),v(ge,"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(ge,"href","#switching-from-transformers-to-optimum-inference"),v(oe,"class","relative group"),v(gt,"href","xx"),v(ke,"id","working-with-the-hugging-face-model-hubhttpshfcomodels"),v(ke,"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(ke,"href","#working-with-the-hugging-face-model-hubhttpshfcomodels"),v(ne,"class","relative group"),v(Le,"href","https://hf.co/models"),v(Le,"rel","nofollow"),v($e,"id","optimum.onnxruntime.ORTModel"),v($e,"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($e,"href","#optimum.onnxruntime.ORTModel"),v(se,"class","relative group"),v(we,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),v(B,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),v(ve,"id","optimum.onnxruntime.ORTModelForFeatureExtraction"),v(ve,"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(ve,"href","#optimum.onnxruntime.ORTModelForFeatureExtraction"),v(re,"class","relative group"),v(I,"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(Oe,"id","optimum.onnxruntime.ORTModelForQuestionAnswering"),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.ORTModelForQuestionAnswering"),v(ie,"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(Ee,"id","optimum.onnxruntime.ORTModelForSequenceClassification"),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.ORTModelForSequenceClassification"),v(pe,"class","relative group"),v(z,"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(Ae,"id","optimum.onnxruntime.ORTModelForTokenClassification"),v(Ae,"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(Ae,"href","#optimum.onnxruntime.ORTModelForTokenClassification"),v(ce,"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")},m(t,g){e(document.head,n),$(t,_,g),$(t,d,g),e(d,u),e(u,k),M(s,k,null),e(d,l),e(d,T),e(T,c),$(t,w,g),$(t,j,g),e(j,F),e(j,R),e(R,ft),e(j,ht),$(t,bo,g),$(t,oe,g),e(oe,ge),e(ge,bt),M(Ie,bt,null),e(oe,sn),e(oe,Ot),e(Ot,rn),$(t,Oo,g),$(t,S,g),e(S,an),e(S,qt),e(qt,ln),e(S,pn),e(S,Mt),e(Mt,mn),e(S,cn),e(S,yt),e(yt,dn),e(S,un),e(S,Et),e(Et,fn),e(S,hn),$(t,qo,g),M(De,t,g),$(t,Mo,g),$(t,G,g),e(G,gn),e(G,jt),e(jt,_n),e(G,kn),e(G,Ft),e(Ft,$n),e(G,wn),$(t,yo,g),M(He,t,g),$(t,Eo,g),$(t,_e,g),e(_e,vn),e(_e,gt),e(gt,Tn),e(_e,xn),$(t,jo,g),$(t,ne,g),e(ne,ke),e(ke,Rt),M(Qe,Rt,null),e(ne,bn),e(ne,zt),e(zt,On),$(t,Fo,g),$(t,L,g),e(L,qn),e(L,At),e(At,Mn),e(L,yn),e(L,Le),e(Le,En),e(L,jn),e(L,Ct),e(Ct,Fn),e(L,Rn),$(t,Ro,g),M(Xe,t,g),$(t,zo,g),$(t,se,g),e(se,$e),e($e,Pt),M(We,Pt,null),e(se,zn),e(se,Nt),e(Nt,An),$(t,Ao,g),$(t,B,g),M(Be,B,null),e(B,Cn),e(B,Ge),e(Ge,Pn),e(Ge,St),e(St,Nn),e(Ge,Sn),e(B,In),e(B,we),M(Ue,we,null),e(we,Dn),e(we,_t),e(_t,Hn),e(_t,It),e(It,Qn),$(t,Co,g),$(t,re,g),e(re,ve),e(ve,Dt),M(Ve,Dt,null),e(re,Ln),e(re,Ht),e(Ht,Xn),$(t,Po,g),$(t,A,g),M(Je,A,null),e(A,Wn),e(A,Qt),e(Qt,Bn),e(A,Gn),e(A,Ye),e(Ye,Un),e(Ye,Lt),e(Lt,Vn),e(Ye,Jn),e(A,Yn),e(A,Xt),e(Xt,Kn),e(A,Zn),e(A,I),M(Ke,I,null),e(I,es),e(I,ae),e(ae,ts),e(ae,Wt),e(Wt,os),e(ae,ns),e(ae,Bt),e(Bt,ss),e(ae,rs),e(I,as),M(Te,I,null),e(I,is),M(xe,I,null),e(I,ls),M(be,I,null),$(t,No,g),$(t,ie,g),e(ie,Oe),e(Oe,Gt),M(Ze,Gt,null),e(ie,ps),e(ie,Ut),e(Ut,ms),$(t,So,g),$(t,C,g),M(et,C,null),e(C,cs),e(C,Vt),e(Vt,ds),e(C,us),e(C,tt),e(tt,fs),e(tt,Jt),e(Jt,hs),e(tt,gs),e(C,_s),e(C,Yt),e(Yt,ks),e(C,$s),e(C,D),M(ot,D,null),e(D,ws),e(D,le),e(le,vs),e(le,Kt),e(Kt,Ts),e(le,xs),e(le,Zt),e(Zt,bs),e(le,Os),e(D,qs),M(qe,D,null),e(D,Ms),M(Me,D,null),e(D,ys),M(ye,D,null),$(t,Io,g),$(t,pe,g),e(pe,Ee),e(Ee,eo),M(nt,eo,null),e(pe,Es),e(pe,to),e(to,js),$(t,Do,g),$(t,P,g),M(st,P,null),e(P,Fs),e(P,oo),e(oo,Rs),e(P,zs),e(P,rt),e(rt,As),e(rt,no),e(no,Cs),e(rt,Ps),e(P,Ns),e(P,so),e(so,Ss),e(P,Is),e(P,z),M(at,z,null),e(z,Ds),e(z,me),e(me,Hs),e(me,ro),e(ro,Qs),e(me,Ls),e(me,ao),e(ao,Xs),e(me,Ws),e(z,Bs),M(je,z,null),e(z,Gs),M(Fe,z,null),e(z,Us),M(Re,z,null),e(z,Vs),M(ze,z,null),$(t,Ho,g),$(t,ce,g),e(ce,Ae),e(Ae,io),M(it,io,null),e(ce,Js),e(ce,lo),e(lo,Ys),$(t,Qo,g),$(t,N,g),M(lt,N,null),e(N,Ks),e(N,po),e(po,Zs),e(N,er),e(N,pt),e(pt,tr),e(pt,mo),e(mo,or),e(pt,nr),e(N,sr),e(N,co),e(co,rr),e(N,ar),e(N,H),M(mt,H,null),e(H,ir),e(H,de),e(de,lr),e(de,uo),e(uo,pr),e(de,mr),e(de,fo),e(fo,cr),e(de,dr),e(H,ur),M(Ce,H,null),e(H,fr),M(Pe,H,null),e(H,hr),M(Ne,H,null),Lo=!0},p(t,[g]){const ct={};g&2&&(ct.$$scope={dirty:g,ctx:t}),Te.$set(ct);const ho={};g&2&&(ho.$$scope={dirty:g,ctx:t}),xe.$set(ho);const go={};g&2&&(go.$$scope={dirty:g,ctx:t}),be.$set(go);const _o={};g&2&&(_o.$$scope={dirty:g,ctx:t}),qe.$set(_o);const dt={};g&2&&(dt.$$scope={dirty:g,ctx:t}),Me.$set(dt);const ko={};g&2&&(ko.$$scope={dirty:g,ctx:t}),ye.$set(ko);const ut={};g&2&&(ut.$$scope={dirty:g,ctx:t}),je.$set(ut);const $o={};g&2&&($o.$$scope={dirty:g,ctx:t}),Fe.$set($o);const wo={};g&2&&(wo.$$scope={dirty:g,ctx:t}),Re.$set(wo);const vo={};g&2&&(vo.$$scope={dirty:g,ctx:t}),ze.$set(vo);const Q={};g&2&&(Q.$$scope={dirty:g,ctx:t}),Ce.$set(Q);const To={};g&2&&(To.$$scope={dirty:g,ctx:t}),Pe.$set(To);const xo={};g&2&&(xo.$$scope={dirty:g,ctx:t}),Ne.$set(xo)},i(t){Lo||(x(s.$$.fragment,t),x(Ie.$$.fragment,t),x(De.$$.fragment,t),x(He.$$.fragment,t),x(Qe.$$.fragment,t),x(Xe.$$.fragment,t),x(We.$$.fragment,t),x(Be.$$.fragment,t),x(Ue.$$.fragment,t),x(Ve.$$.fragment,t),x(Je.$$.fragment,t),x(Ke.$$.fragment,t),x(Te.$$.fragment,t),x(xe.$$.fragment,t),x(be.$$.fragment,t),x(Ze.$$.fragment,t),x(et.$$.fragment,t),x(ot.$$.fragment,t),x(qe.$$.fragment,t),x(Me.$$.fragment,t),x(ye.$$.fragment,t),x(nt.$$.fragment,t),x(st.$$.fragment,t),x(at.$$.fragment,t),x(je.$$.fragment,t),x(Fe.$$.fragment,t),x(Re.$$.fragment,t),x(ze.$$.fragment,t),x(it.$$.fragment,t),x(lt.$$.fragment,t),x(mt.$$.fragment,t),x(Ce.$$.fragment,t),x(Pe.$$.fragment,t),x(Ne.$$.fragment,t),Lo=!0)},o(t){b(s.$$.fragment,t),b(Ie.$$.fragment,t),b(De.$$.fragment,t),b(He.$$.fragment,t),b(Qe.$$.fragment,t),b(Xe.$$.fragment,t),b(We.$$.fragment,t),b(Be.$$.fragment,t),b(Ue.$$.fragment,t),b(Ve.$$.fragment,t),b(Je.$$.fragment,t),b(Ke.$$.fragment,t),b(Te.$$.fragment,t),b(xe.$$.fragment,t),b(be.$$.fragment,t),b(Ze.$$.fragment,t),b(et.$$.fragment,t),b(ot.$$.fragment,t),b(qe.$$.fragment,t),b(Me.$$.fragment,t),b(ye.$$.fragment,t),b(nt.$$.fragment,t),b(st.$$.fragment,t),b(at.$$.fragment,t),b(je.$$.fragment,t),b(Fe.$$.fragment,t),b(Re.$$.fragment,t),b(ze.$$.fragment,t),b(it.$$.fragment,t),b(lt.$$.fragment,t),b(mt.$$.fragment,t),b(Ce.$$.fragment,t),b(Pe.$$.fragment,t),b(Ne.$$.fragment,t),Lo=!1},d(t){o(n),t&&o(_),t&&o(d),y(s),t&&o(w),t&&o(j),t&&o(bo),t&&o(oe),y(Ie),t&&o(Oo),t&&o(S),t&&o(qo),y(De,t),t&&o(Mo),t&&o(G),t&&o(yo),y(He,t),t&&o(Eo),t&&o(_e),t&&o(jo),t&&o(ne),y(Qe),t&&o(Fo),t&&o(L),t&&o(Ro),y(Xe,t),t&&o(zo),t&&o(se),y(We),t&&o(Ao),t&&o(B),y(Be),y(Ue),t&&o(Co),t&&o(re),y(Ve),t&&o(Po),t&&o(A),y(Je),y(Ke),y(Te),y(xe),y(be),t&&o(No),t&&o(ie),y(Ze),t&&o(So),t&&o(C),y(et),y(ot),y(qe),y(Me),y(ye),t&&o(Io),t&&o(pe),y(nt),t&&o(Do),t&&o(P),y(st),y(at),y(je),y(Fe),y(Re),y(ze),t&&o(Ho),t&&o(ce),y(it),t&&o(Qo),t&&o(N),y(lt),y(mt),y(Ce),y(Pe),y(Ne)}}}const Ha={local:"optimum-inference-with-onnx-runtime",sections:[{local:"switching-from-transformers-to-optimum-inference",sections:[{local:"working-with-the-hugging-face-model-hubhttpshfcomodels",title:"Working with the [Hugging Face Model Hub](https://hf.co/models)"}],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"}],title:"Optimum Inference with ONNX Runtime"};function Qa(E){return ha(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class Ua extends da{constructor(n){super();ua(this,n,Qa,Da,fa,{})}}export{Ua as default,Ha as metadata};
