import{S as ne,i as ie,s as de,e as a,k as v,w as S,t as M,M as se,c as n,d as t,m as y,a as i,x as A,h as O,b as d,G as o,g as F,y as U,L as le,q,o as V,B as W,v as me}from"../../chunks/vendor-hf-doc-builder.js";import{D as Y}from"../../chunks/Docstring-hf-doc-builder.js";import{I as ce}from"../../chunks/IconCopyLink-hf-doc-builder.js";function pe(Z){let s,P,l,m,k,h,C,z,H,E,r,u,B,c,g,G,x,J,R,p,f,j,_,K,w,Q,X,T;return h=new ce({}),u=new Y({props:{name:"class optimum.modeling_base.OptimizedModel",anchor:"optimum.modeling_base.OptimizedModel",parameters:[{name:"model",val:" = None"},{name:"config",val:" = None"},{name:"**kwargs",val:""}],source:"https://github.com/huggingface/optimum/blob/vr_412/optimum/modeling_base.py#L46"}}),g=new Y({props:{name:"from_pretrained",anchor:"optimum.modeling_base.OptimizedModel.from_pretrained",parameters:[{name:"model_id",val:": typing.Union[str, pathlib.Path]"},{name:"from_transformers",val:": bool = False"},{name:"force_download",val:": bool = False"},{name:"use_auth_token",val:": typing.Optional[str] = None"},{name:"cache_dir",val:": typing.Optional[str] = None"},{name:"**model_kwargs",val:""}],parametersDescription:[{anchor:"optimum.modeling_base.OptimizedModel.from_pretrained.model_id",description:`<strong>model_id</strong> (<code>Union[str, Path]</code>) &#x2014;
Can be either:<ul>
<li>A string, the <em>model id</em> of a pretrained model hosted inside a model repo on huggingface.co.
Valid model ids can be located at the root-level, like <code>bert-base-uncased</code>, or namespaced under a
user or organization name, like <code>dbmdz/bert-base-german-cased</code>.</li>
<li>A path to a <em>directory</em> containing a model saved using <code>~OptimizedModel.save_pretrained</code>,
e.g., <code>./my_model_directory/</code>.</li>
</ul>`,name:"model_id"},{anchor:"optimum.modeling_base.OptimizedModel.from_pretrained.from_transformers",description:`<strong>from_transformers</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>False</code>) &#x2014;
Defines whether the provided <code>model_id</code> contains a vanilla Transformers checkpoint.`,name:"from_transformers"},{anchor:"optimum.modeling_base.OptimizedModel.from_pretrained.force_download",description:`<strong>force_download</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>True</code>) &#x2014;
Whether or not to force the (re-)download of the model weights and configuration files, overriding the
cached versions if they exist.`,name:"force_download"},{anchor:"optimum.modeling_base.OptimizedModel.from_pretrained.use_auth_token",description:`<strong>use_auth_token</strong> (<code>str</code>, <em>optional</em>, defaults to <code>None</code>) &#x2014;
The token to use as HTTP bearer authorization for remote files. If <code>True</code>, will use the token generated
when running <code>transformers-cli login</code> (stored in <code>~/.huggingface</code>).`,name:"use_auth_token"},{anchor:"optimum.modeling_base.OptimizedModel.from_pretrained.cache_dir",description:`<strong>cache_dir</strong> (<code>str</code>, <em>optional</em>, defaults to <code>None</code>) &#x2014;
Path to a directory in which a downloaded pretrained model configuration should be cached if the
standard cache should not be used.`,name:"cache_dir"},{anchor:"optimum.modeling_base.OptimizedModel.from_pretrained.local_files_only(bool,",description:`<strong>local_files_only(<code>bool</code>,</strong> <em>optional</em>, defaults to <code>False</code>) &#x2014;
Whether or not to only look at local files (i.e., do not try to download the model).`,name:"local_files_only(bool,"}],source:"https://github.com/huggingface/optimum/blob/vr_412/optimum/modeling_base.py#L191",returnDescription:`
<p>The loaded optimized model.</p>
`,returnType:`
<p><code>OptimizedModel</code></p>
`}}),f=new Y({props:{name:"save_pretrained",anchor:"optimum.modeling_base.OptimizedModel.save_pretrained",parameters:[{name:"save_directory",val:": typing.Union[str, os.PathLike]"},{name:"push_to_hub",val:": bool = False"},{name:"**kwargs",val:""}],parametersDescription:[{anchor:"optimum.modeling_base.OptimizedModel.save_pretrained.save_directory",description:`<strong>save_directory</strong> (<code>str</code> or <code>os.PathLike</code>) &#x2014;
Directory to which to save. Will be created if it doesn&#x2019;t exist.`,name:"save_directory"},{anchor:"optimum.modeling_base.OptimizedModel.save_pretrained.push_to_hub",description:`<strong>push_to_hub</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>False</code>) &#x2014;
Whether or not to push your model to the Hugging Face model hub after saving it.</p>
<div class="course-tip course-tip-orange bg-gradient-to-br dark:bg-gradient-to-r before:border-orange-500 dark:before:border-orange-800 from-orange-50 dark:from-gray-900 to-white dark:to-gray-950 border border-orange-50 text-orange-700 dark:text-gray-400">
						
<p>Using <code>push_to_hub=True</code> will synchronize the repository you are pushing to with <code>save_directory</code>,
which requires <code>save_directory</code> to be a local clone of the repo you are pushing to if it&#x2019;s an existing
folder. Pass along <code>temp_dir=True</code> to use a temporary directory instead.</p>

					</div>`,name:"push_to_hub"}],source:"https://github.com/huggingface/optimum/blob/vr_412/optimum/modeling_base.py#L66"}}),{c(){s=a("meta"),P=v(),l=a("h1"),m=a("a"),k=a("span"),S(h.$$.fragment),C=v(),z=a("span"),H=M("OptimizedModel"),E=v(),r=a("div"),S(u.$$.fragment),B=v(),c=a("div"),S(g.$$.fragment),G=v(),x=a("p"),J=M("Instantiate a pretrained model from a pre-trained model configuration."),R=v(),p=a("div"),S(f.$$.fragment),j=v(),_=a("p"),K=M(`Save a model and its configuration file to a directory, so that it can be re-loaded using the
`),w=a("a"),Q=M("from_pretrained()"),X=M(" class method."),this.h()},l(e){const b=se('[data-svelte="svelte-1phssyn"]',document.head);s=n(b,"META",{name:!0,content:!0}),b.forEach(t),P=y(e),l=n(e,"H1",{class:!0});var D=i(l);m=n(D,"A",{id:!0,class:!0,href:!0});var ee=i(m);k=n(ee,"SPAN",{});var oe=i(k);A(h.$$.fragment,oe),oe.forEach(t),ee.forEach(t),C=y(D),z=n(D,"SPAN",{});var te=i(z);H=O(te,"OptimizedModel"),te.forEach(t),D.forEach(t),E=y(e),r=n(e,"DIV",{class:!0});var $=i(r);A(u.$$.fragment,$),B=y($),c=n($,"DIV",{class:!0});var N=i(c);A(g.$$.fragment,N),G=y(N),x=n(N,"P",{});var re=i(x);J=O(re,"Instantiate a pretrained model from a pre-trained model configuration."),re.forEach(t),N.forEach(t),R=y($),p=n($,"DIV",{class:!0});var I=i(p);A(f.$$.fragment,I),j=y(I),_=n(I,"P",{});var L=i(_);K=O(L,`Save a model and its configuration file to a directory, so that it can be re-loaded using the
`),w=n(L,"A",{href:!0});var ae=i(w);Q=O(ae,"from_pretrained()"),ae.forEach(t),X=O(L," class method."),L.forEach(t),I.forEach(t),$.forEach(t),this.h()},h(){d(s,"name","hf:doc:metadata"),d(s,"content",JSON.stringify(he)),d(m,"id","optimum.modeling_base.OptimizedModel"),d(m,"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"),d(m,"href","#optimum.modeling_base.OptimizedModel"),d(l,"class","relative group"),d(c,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),d(w,"href","/docs/optimum/pr_412/en/package_reference/modeling_base#optimum.modeling_base.OptimizedModel.from_pretrained"),d(p,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),d(r,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8")},m(e,b){o(document.head,s),F(e,P,b),F(e,l,b),o(l,m),o(m,k),U(h,k,null),o(l,C),o(l,z),o(z,H),F(e,E,b),F(e,r,b),U(u,r,null),o(r,B),o(r,c),U(g,c,null),o(c,G),o(c,x),o(x,J),o(r,R),o(r,p),U(f,p,null),o(p,j),o(p,_),o(_,K),o(_,w),o(w,Q),o(_,X),T=!0},p:le,i(e){T||(q(h.$$.fragment,e),q(u.$$.fragment,e),q(g.$$.fragment,e),q(f.$$.fragment,e),T=!0)},o(e){V(h.$$.fragment,e),V(u.$$.fragment,e),V(g.$$.fragment,e),V(f.$$.fragment,e),T=!1},d(e){t(s),e&&t(P),e&&t(l),W(h),e&&t(E),e&&t(r),W(u),W(g),W(f)}}}const he={local:"optimum.modeling_base.OptimizedModel",title:"OptimizedModel"};function ue(Z){return me(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class be extends ne{constructor(s){super();ie(this,s,ue,pe,de,{})}}export{be as default,he as metadata};
