import{s as oe,n as ne,o as se}from"../chunks/scheduler.25b97de1.js";import{S as ae,i as me,g as s,s as o,r as x,A as re,h as a,f as l,c as n,j as le,u as y,x as J,k as ie,y as pe,a as i,v as G,d as $,t as j,w as Z}from"../chunks/index.d9030fc9.js";import{C as E}from"../chunks/CodeBlock.e6cd0d95.js";import{H as de,E as ce}from"../chunks/EditOnGithub.91d95064.js";function fe(N){let m,I,v,L,r,V,p,P=`<a href="https://www.tensorflow.org/lite/guide" rel="nofollow">TensorFlow Lite</a> is a lightweight framework for deploying machine learning models
on resource-constrained devices, such as mobile phones, embedded systems, and Internet of Things (IoT) devices.
TFLite is designed to optimize and run models efficiently on these devices with limited computational power, memory, and
power consumption.
A TensorFlow Lite model is represented in a special efficient portable format identified by the <code>.tflite</code> file extension.`,_,d,D=`🤗 Optimum offers functionality to export 🤗 Transformers models to TFLite through the <code>exporters.tflite</code> module.
For the list of supported model architectures, please refer to <a href="https://huggingface.co/docs/optimum/exporters/tflite/overview" rel="nofollow">🤗 Optimum documentation</a>.`,F,c,q="To export a model to TFLite, install the required dependencies:",H,f,k,M,O=`To check out all available arguments, refer to the <a href="https://huggingface.co/docs/optimum/main/en/exporters/tflite/usage_guides/export_a_model" rel="nofollow">🤗 Optimum docs</a>,
or view help in command line:`,C,u,W,h,K="To export a model’s checkpoint from the 🤗 Hub, for example, <code>google-bert/bert-base-uncased</code>, run the following command:",S,T,R,w,ee="You should see the logs indicating progress and showing where the resulting <code>model.tflite</code> is saved, like this:",Q,b,A,g,te=`The example above illustrates exporting a checkpoint from 🤗 Hub. When exporting a local model, first make sure that you
saved both the model’s weights and tokenizer files in the same directory (<code>local_path</code>). When using CLI, pass the
<code>local_path</code> to the <code>model</code> argument instead of the checkpoint name on 🤗 Hub.`,Y,U,z,B,X;return r=new de({props:{title:"Export to TFLite",local:"export-to-tflite",headingTag:"h1"}}),f=new E({props:{code:"cGlwJTIwaW5zdGFsbCUyMG9wdGltdW0lNUJleHBvcnRlcnMtdGYlNUQ=",highlighted:"pip install optimum[exporters-tf]",wrap:!1}}),u=new E({props:{code:"b3B0aW11bS1jbGklMjBleHBvcnQlMjB0ZmxpdGUlMjAtLWhlbHA=",highlighted:'optimum-cli <span class="hljs-built_in">export</span> tflite --<span class="hljs-built_in">help</span>',wrap:!1}}),T=new E({props:{code:"b3B0aW11bS1jbGklMjBleHBvcnQlMjB0ZmxpdGUlMjAtLW1vZGVsJTIwZ29vZ2xlLWJlcnQlMkZiZXJ0LWJhc2UtdW5jYXNlZCUyMC0tc2VxdWVuY2VfbGVuZ3RoJTIwMTI4JTIwYmVydF90ZmxpdGUlMkY=",highlighted:'optimum-cli <span class="hljs-built_in">export</span> tflite --model google-bert/bert-base-uncased --sequence_length 128 bert_tflite/',wrap:!1}}),b=new E({props:{code:"VmFsaWRhdGluZyUyMFRGTGl0ZSUyMG1vZGVsLi4uJTBBJTA5LSU1QiVFMiU5QyU5MyU1RCUyMFRGTGl0ZSUyMG1vZGVsJTIwb3V0cHV0JTIwbmFtZXMlMjBtYXRjaCUyMHJlZmVyZW5jZSUyMG1vZGVsJTIwKGxvZ2l0cyklMEElMDktJTIwVmFsaWRhdGluZyUyMFRGTGl0ZSUyME1vZGVsJTIwb3V0cHV0JTIwJTIybG9naXRzJTIyJTNBJTBBJTA5JTA5LSU1QiVFMiU5QyU5MyU1RCUyMCgxJTJDJTIwMTI4JTJDJTIwMzA1MjIpJTIwbWF0Y2hlcyUyMCgxJTJDJTIwMTI4JTJDJTIwMzA1MjIpJTBBJTA5JTA5LSU1QnglNUQlMjB2YWx1ZXMlMjBub3QlMjBjbG9zZSUyMGVub3VnaCUyQyUyMG1heCUyMGRpZmYlM0ElMjA1LjgxNzQxMzMzMDA3ODEyNWUtMDUlMjAoYXRvbCUzQSUyMDFlLTA1KSUwQVRoZSUyMFRlbnNvckZsb3clMjBMaXRlJTIwZXhwb3J0JTIwc3VjY2VlZGVkJTIwd2l0aCUyMHRoZSUyMHdhcm5pbmclM0ElMjBUaGUlMjBtYXhpbXVtJTIwYWJzb2x1dGUlMjBkaWZmZXJlbmNlJTIwYmV0d2VlbiUyMHRoZSUyMG91dHB1dCUyMG9mJTIwdGhlJTIwcmVmZXJlbmNlJTIwbW9kZWwlMjBhbmQlMjB0aGUlMjBURkxpdGUlMjBleHBvcnRlZCUyMG1vZGVsJTIwaXMlMjBub3QlMjB3aXRoaW4lMjB0aGUlMjBzZXQlMjB0b2xlcmFuY2UlMjAxZS0wNSUzQSUwQS0lMjBsb2dpdHMlM0ElMjBtYXglMjBkaWZmJTIwJTNEJTIwNS44MTc0MTMzMzAwNzgxMjVlLTA1LiUwQSUyMFRoZSUyMGV4cG9ydGVkJTIwbW9kZWwlMjB3YXMlMjBzYXZlZCUyMGF0JTNBJTIwYmVydF90ZmxpdGU=",highlighted:`Validating TFLite model...
	-[✓] TFLite model output names match reference model (logits)
	- Validating TFLite Model output <span class="hljs-string">&quot;logits&quot;</span>:
		-[✓] (1, 128, 30522) matches (1, 128, 30522)
		-[x] values not close enough, max diff: 5.817413330078125e-05 (atol: 1e-05)
The TensorFlow Lite <span class="hljs-built_in">export</span> succeeded with the warning: The maximum absolute difference between the output of the reference model and the TFLite exported model is not within the <span class="hljs-built_in">set</span> tolerance 1e-05:
- logits: max diff = 5.817413330078125e-05.
 The exported model was saved at: bert_tflite`,wrap:!1}}),U=new ce({props:{source:"https://github.com/huggingface/transformers/blob/main/docs/source/en/tflite.md"}}),{c(){m=s("meta"),I=o(),v=s("p"),L=o(),x(r.$$.fragment),V=o(),p=s("p"),p.innerHTML=P,_=o(),d=s("p"),d.innerHTML=D,F=o(),c=s("p"),c.textContent=q,H=o(),x(f.$$.fragment),k=o(),M=s("p"),M.innerHTML=O,C=o(),x(u.$$.fragment),W=o(),h=s("p"),h.innerHTML=K,S=o(),x(T.$$.fragment),R=o(),w=s("p"),w.innerHTML=ee,Q=o(),x(b.$$.fragment),A=o(),g=s("p"),g.innerHTML=te,Y=o(),x(U.$$.fragment),z=o(),B=s("p"),this.h()},l(e){const t=re("svelte-u9bgzb",document.head);m=a(t,"META",{name:!0,content:!0}),t.forEach(l),I=n(e),v=a(e,"P",{}),le(v).forEach(l),L=n(e),y(r.$$.fragment,e),V=n(e),p=a(e,"P",{"data-svelte-h":!0}),J(p)!=="svelte-1btfcc4"&&(p.innerHTML=P),_=n(e),d=a(e,"P",{"data-svelte-h":!0}),J(d)!=="svelte-m0va7t"&&(d.innerHTML=D),F=n(e),c=a(e,"P",{"data-svelte-h":!0}),J(c)!=="svelte-fibc5e"&&(c.textContent=q),H=n(e),y(f.$$.fragment,e),k=n(e),M=a(e,"P",{"data-svelte-h":!0}),J(M)!=="svelte-1ebb3ag"&&(M.innerHTML=O),C=n(e),y(u.$$.fragment,e),W=n(e),h=a(e,"P",{"data-svelte-h":!0}),J(h)!=="svelte-1qhuwrl"&&(h.innerHTML=K),S=n(e),y(T.$$.fragment,e),R=n(e),w=a(e,"P",{"data-svelte-h":!0}),J(w)!=="svelte-ptkmnx"&&(w.innerHTML=ee),Q=n(e),y(b.$$.fragment,e),A=n(e),g=a(e,"P",{"data-svelte-h":!0}),J(g)!=="svelte-1a6s6im"&&(g.innerHTML=te),Y=n(e),y(U.$$.fragment,e),z=n(e),B=a(e,"P",{}),le(B).forEach(l),this.h()},h(){ie(m,"name","hf:doc:metadata"),ie(m,"content",Me)},m(e,t){pe(document.head,m),i(e,I,t),i(e,v,t),i(e,L,t),G(r,e,t),i(e,V,t),i(e,p,t),i(e,_,t),i(e,d,t),i(e,F,t),i(e,c,t),i(e,H,t),G(f,e,t),i(e,k,t),i(e,M,t),i(e,C,t),G(u,e,t),i(e,W,t),i(e,h,t),i(e,S,t),G(T,e,t),i(e,R,t),i(e,w,t),i(e,Q,t),G(b,e,t),i(e,A,t),i(e,g,t),i(e,Y,t),G(U,e,t),i(e,z,t),i(e,B,t),X=!0},p:ne,i(e){X||($(r.$$.fragment,e),$(f.$$.fragment,e),$(u.$$.fragment,e),$(T.$$.fragment,e),$(b.$$.fragment,e),$(U.$$.fragment,e),X=!0)},o(e){j(r.$$.fragment,e),j(f.$$.fragment,e),j(u.$$.fragment,e),j(T.$$.fragment,e),j(b.$$.fragment,e),j(U.$$.fragment,e),X=!1},d(e){e&&(l(I),l(v),l(L),l(V),l(p),l(_),l(d),l(F),l(c),l(H),l(k),l(M),l(C),l(W),l(h),l(S),l(R),l(w),l(Q),l(A),l(g),l(Y),l(z),l(B)),l(m),Z(r,e),Z(f,e),Z(u,e),Z(T,e),Z(b,e),Z(U,e)}}}const Me='{"title":"Export to TFLite","local":"export-to-tflite","sections":[],"depth":1}';function ue(N){return se(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class ge extends ae{constructor(m){super(),me(this,m,ue,fe,oe,{})}}export{ge as component};
