import{s as z,n as A,o as Q}from"../chunks/scheduler.c90a44b2.js";import{S as q,i as Y,e as M,s as a,c as Z,h as N,a as w,d as o,b as n,f as G,g as k,j,k as S,l as D,m as l,n as W,t as F,o as _,p as B}from"../chunks/index.66c3f415.js";import{C as K,H}from"../chunks/MermaidChart.svelte_svelte_type_style_lang.36aee93a.js";import{C as O}from"../chunks/CodeBlock.e8de8a4d.js";function tt(P){let i,y,h,T,d,I,s,J,r,R='Optimum Intel can be used to load models from the <a href="https://huggingface.co/models" rel="nofollow">Hub</a> and create pipelines to run inference with IPEX optimizations (including patching with custom operators, weight prepacking and graph mode) on a variety of Intel processors. For now support is only enabled for CPUs.',E,c,g,m,U=`You can load your model and apply IPEX optimizations (apply torch.compile except text-generation tasks). For supported architectures like LLaMA, BERT and ViT, further optimizations will be applied by patching the model to use custom operators.
For now, support is enabled for Intel CPU/GPU. Previous models converted to TorchScript will be deprecated in v1.22.`,v,p,C,u,L="As shown in the table below, each task is associated with a class enabling to automatically load your model.",$,f,V="<thead><tr><th>Auto Class</th> <th>Task</th></tr></thead> <tbody><tr><td><code>IPEXModelForSequenceClassification</code></td> <td><code>text-classification</code></td></tr> <tr><td><code>IPEXModelForTokenClassification</code></td> <td><code>token-classification</code></td></tr> <tr><td><code>IPEXModelForQuestionAnswering</code></td> <td><code>question-answering</code></td></tr> <tr><td><code>IPEXModelForImageClassification</code></td> <td><code>image-classification</code></td></tr> <tr><td><code>IPEXModel</code></td> <td><code>feature-extraction</code></td></tr> <tr><td><code>IPEXModelForMaskedLM</code></td> <td><code>fill-mask</code></td></tr> <tr><td><code>IPEXModelForAudioClassification</code></td> <td><code>audio-classification</code></td></tr> <tr><td><code>IPEXModelForCausalLM</code></td> <td><code>text-generation</code></td></tr> <tr><td><code>IPEXModelForSeq2SeqLM</code></td> <td><code>text2text-generation</code></td></tr></tbody>",x,b,X;return d=new K({props:{containerStyle:"float: right; margin-left: 10px; display: inline-flex; position: relative; z-index: 10;"}}),s=new H({props:{title:"Inference",local:"inference",headingTag:"h1"}}),c=new H({props:{title:"Loading",local:"loading",headingTag:"h2"}}),p=new O({props:{code:"JTIwJTIwaW1wb3J0JTIwdG9yY2glMEElMjAlMjBmcm9tJTIwdHJhbnNmb3JtZXJzJTIwaW1wb3J0JTIwQXV0b1Rva2VuaXplciUyQyUyMHBpcGVsaW5lJTBBLSUyMGZyb20lMjB0cmFuc2Zvcm1lcnMlMjBpbXBvcnQlMjBBdXRvTW9kZWxGb3JDYXVzYWxMTSUwQSUyQiUyMGZyb20lMjBvcHRpbXVtLmludGVsJTIwaW1wb3J0JTIwSVBFWE1vZGVsRm9yQ2F1c2FsTE0lMEElMEElMjAlMjBtb2RlbF9pZCUyMCUzRCUyMCUyMmdwdDIlMjIlMEEtJTIwbW9kZWwlMjAlM0QlMjBBdXRvTW9kZWxGb3JDYXVzYWxMTS5mcm9tX3ByZXRyYWluZWQobW9kZWxfaWQlMkMlMjB0b3JjaF9kdHlwZSUzRHRvcmNoLmJmbG9hdDE2KSUwQSUyQiUyMG1vZGVsJTIwJTNEJTIwSVBFWE1vZGVsRm9yQ2F1c2FsTE0uZnJvbV9wcmV0cmFpbmVkKG1vZGVsX2lkJTJDJTIwdG9yY2hfZHR5cGUlM0R0b3JjaC5iZmxvYXQxNiklMEElMjAlMjB0b2tlbml6ZXIlMjAlM0QlMjBBdXRvVG9rZW5pemVyLmZyb21fcHJldHJhaW5lZChtb2RlbF9pZCklMEElMjAlMjBwaXBlJTIwJTNEJTIwcGlwZWxpbmUoJTIydGV4dC1nZW5lcmF0aW9uJTIyJTJDJTIwbW9kZWwlM0Rtb2RlbCUyQyUyMHRva2VuaXplciUzRHRva2VuaXplciklMEElMjAlMjByZXN1bHRzJTIwJTNEJTIwcGlwZSglMjJIZSdzJTIwYSUyMGRyZWFkZnVsJTIwbWFnaWNpYW4lMjBhbmQlMjIp",highlighted:`  import torch
  from transformers import AutoTokenizer, pipeline
<span class="hljs-deletion">- from transformers import AutoModelForCausalLM</span>
<span class="hljs-addition">+ from optimum.intel import IPEXModelForCausalLM</span>

  model_id = &quot;gpt2&quot;
<span class="hljs-deletion">- model = AutoModelForCausalLM.from_pretrained(model_id, torch_dtype=torch.bfloat16)</span>
<span class="hljs-addition">+ model = IPEXModelForCausalLM.from_pretrained(model_id, torch_dtype=torch.bfloat16)</span>
  tokenizer = AutoTokenizer.from_pretrained(model_id)
  pipe = pipeline(&quot;text-generation&quot;, model=model, tokenizer=tokenizer)
  results = pipe(&quot;He&#x27;s a dreadful magician and&quot;)`,wrap:!1}}),{c(){i=M("meta"),y=a(),h=M("p"),T=a(),Z(d.$$.fragment),I=a(),Z(s.$$.fragment),J=a(),r=M("p"),r.innerHTML=R,E=a(),Z(c.$$.fragment),g=a(),m=M("p"),m.textContent=U,v=a(),Z(p.$$.fragment),C=a(),u=M("p"),u.textContent=L,$=a(),f=M("table"),f.innerHTML=V,x=a(),b=M("p"),this.h()},l(t){const e=N("svelte-u9bgzb",document.head);i=w(e,"META",{name:!0,content:!0}),e.forEach(o),y=n(t),h=w(t,"P",{}),G(h).forEach(o),T=n(t),k(d.$$.fragment,t),I=n(t),k(s.$$.fragment,t),J=n(t),r=w(t,"P",{"data-svelte-h":!0}),j(r)!=="svelte-3t5r71"&&(r.innerHTML=R),E=n(t),k(c.$$.fragment,t),g=n(t),m=w(t,"P",{"data-svelte-h":!0}),j(m)!=="svelte-vwwa0u"&&(m.textContent=U),v=n(t),k(p.$$.fragment,t),C=n(t),u=w(t,"P",{"data-svelte-h":!0}),j(u)!=="svelte-sgii55"&&(u.textContent=L),$=n(t),f=w(t,"TABLE",{"data-svelte-h":!0}),j(f)!=="svelte-1wvyvke"&&(f.innerHTML=V),x=n(t),b=w(t,"P",{}),G(b).forEach(o),this.h()},h(){S(i,"name","hf:doc:metadata"),S(i,"content",et)},m(t,e){D(document.head,i),l(t,y,e),l(t,h,e),l(t,T,e),W(d,t,e),l(t,I,e),W(s,t,e),l(t,J,e),l(t,r,e),l(t,E,e),W(c,t,e),l(t,g,e),l(t,m,e),l(t,v,e),W(p,t,e),l(t,C,e),l(t,u,e),l(t,$,e),l(t,f,e),l(t,x,e),l(t,b,e),X=!0},p:A,i(t){X||(F(d.$$.fragment,t),F(s.$$.fragment,t),F(c.$$.fragment,t),F(p.$$.fragment,t),X=!0)},o(t){_(d.$$.fragment,t),_(s.$$.fragment,t),_(c.$$.fragment,t),_(p.$$.fragment,t),X=!1},d(t){t&&(o(y),o(h),o(T),o(I),o(J),o(r),o(E),o(g),o(m),o(v),o(C),o(u),o($),o(f),o(x),o(b)),o(i),B(d,t),B(s,t),B(c,t),B(p,t)}}}const et='{"title":"Inference","local":"inference","sections":[{"title":"Loading","local":"loading","sections":[],"depth":2}],"depth":1}';function ot(P){return Q(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class dt extends q{constructor(i){super(),Y(this,i,ot,tt,z,{})}}export{dt as component};
