import{S as lt,i as ot,s as it,e as a,k as p,w as X,t as i,M as st,c as n,d as t,m as d,a as r,x as z,h as s,b as c,G as l,g as m,y as Q,L as at,q as H,o as N,B as Y,v as nt}from"../chunks/vendor-hf-doc-builder.js";import{I as rt}from"../chunks/IconCopyLink-hf-doc-builder.js";import{C as fe}from"../chunks/CodeBlock-hf-doc-builder.js";function mt(We){let u,D,M,w,I,U,ce,k,he,O,T,J,ue,Me,F,Te,we,P,h,be,L,ye,ve,g,xe,Ue,q,Z,Je,K,_,ee,b,ge,G,_e,Ge,te,j,le,y,je,V,Be,Ee,oe,B,ie,v,Ze,C,$e,Ie,se,E,ae,f,ke,S,Fe,Le,A,Ve,Ce,W,Se,Ae,ne;return U=new rt({}),_=new fe({props:{code:"cGlwJTIwaW5zdGFsbCUyMG9wdGltdW0lNUJleHBvcnRlcnMtdGYlNUQ=",highlighted:"pip install optimum[exporters-tf]"}}),j=new fe({props:{code:"b3B0aW11bS1jbGklMjBleHBvcnQlMjB0ZmxpdGUlMjAtLWhlbHA=",highlighted:'optimum-cli <span class="hljs-built_in">export</span> tflite --<span class="hljs-built_in">help</span>'}}),B=new fe({props:{code:"b3B0aW11bS1jbGklMjBleHBvcnQlMjB0ZmxpdGUlMjAtLW1vZGVsJTIwYmVydC1iYXNlLXVuY2FzZWQlMjAtLXNlcXVlbmNlX2xlbmd0aCUyMDEyOCUyMGJlcnRfdGZsaXRlJTJG",highlighted:'optimum-cli <span class="hljs-built_in">export</span> tflite --model bert-base-uncased --sequence_length 128 bert_tflite/'}}),E=new fe({props:{code:"VmFsaWRhdGluZyUyMFRGTGl0ZSUyMG1vZGVsLi4uJTBBJTA5LSU1QiVFMiU5QyU5MyU1RCUyMFRGTGl0ZSUyMG1vZGVsJTIwb3V0cHV0JTIwbmFtZXMlMjBtYXRjaCUyMHJlZmVyZW5jZSUyMG1vZGVsJTIwKGxvZ2l0cyklMEElMDktJTIwVmFsaWRhdGluZyUyMFRGTGl0ZSUyME1vZGVsJTIwb3V0cHV0JTIwJTIybG9naXRzJTIyJTNBJTBBJTA5JTA5LSU1QiVFMiU5QyU5MyU1RCUyMCgxJTJDJTIwMTI4JTJDJTIwMzA1MjIpJTIwbWF0Y2hlcyUyMCgxJTJDJTIwMTI4JTJDJTIwMzA1MjIpJTBBJTA5JTA5LSU1QnglNUQlMjB2YWx1ZXMlMjBub3QlMjBjbG9zZSUyMGVub3VnaCUyQyUyMG1heCUyMGRpZmYlM0ElMjA1LjgxNzQxMzMzMDA3ODEyNWUtMDUlMjAoYXRvbCUzQSUyMDFlLTA1KSUwQVRoZSUyMFRlbnNvckZsb3clMjBMaXRlJTIwZXhwb3J0JTIwc3VjY2VlZGVkJTIwd2l0aCUyMHRoZSUyMHdhcm5pbmclM0ElMjBUaGUlMjBtYXhpbXVtJTIwYWJzb2x1dGUlMjBkaWZmZXJlbmNlJTIwYmV0d2VlbiUyMHRoZSUyMG91dHB1dCUyMG9mJTIwdGhlJTIwcmVmZXJlbmNlJTIwbW9kZWwlMjBhbmQlMjB0aGUlMjBURkxpdGUlMjBleHBvcnRlZCUyMG1vZGVsJTIwaXMlMjBub3QlMjB3aXRoaW4lMjB0aGUlMjBzZXQlMjB0b2xlcmFuY2UlMjAxZS0wNSUzQSUwQS0lMjBsb2dpdHMlM0ElMjBtYXglMjBkaWZmJTIwJTNEJTIwNS44MTc0MTMzMzAwNzgxMjVlLTA1LiUwQSUyMFRoZSUyMGV4cG9ydGVkJTIwbW9kZWwlMjB3YXMlMjBzYXZlZCUyMGF0JTNBJTIwYmVydF90ZmxpdGU=",highlighted:`Validating TFLite model...
	-[\u2713] TFLite model output names match reference model (logits)
	- Validating TFLite Model output <span class="hljs-string">&quot;logits&quot;</span>:
		-[\u2713] (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`}}),{c(){u=a("meta"),D=p(),M=a("h1"),w=a("a"),I=a("span"),X(U.$$.fragment),ce=p(),k=a("span"),he=i("Export to TFLite"),O=p(),T=a("p"),J=a("a"),ue=i("TensorFlow Lite"),Me=i(` 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 `),F=a("code"),Te=i(".tflite"),we=i(" file extension."),P=p(),h=a("p"),be=i("\u{1F917} Optimum offers functionality to export \u{1F917} Transformers models to TFLite through the "),L=a("code"),ye=i("exporters.tflite"),ve=i(` module.
For the list of supported model architectures, please refer to `),g=a("a"),xe=i("\u{1F917} Optimum documentation"),Ue=i("."),q=p(),Z=a("p"),Je=i("To export a model to TFLite, install the required dependencies:"),K=p(),X(_.$$.fragment),ee=p(),b=a("p"),ge=i("To check out all available arguments, refer to the "),G=a("a"),_e=i("\u{1F917} Optimum docs"),Ge=i(`,
or view help in command line:`),te=p(),X(j.$$.fragment),le=p(),y=a("p"),je=i("To export a model\u2019s checkpoint from the \u{1F917} Hub, for example, "),V=a("code"),Be=i("bert-base-uncased"),Ee=i(", run the following command:"),oe=p(),X(B.$$.fragment),ie=p(),v=a("p"),Ze=i("You should see the logs indicating progress and showing where the resulting "),C=a("code"),$e=i("model.tflite"),Ie=i(" is saved, like this:"),se=p(),X(E.$$.fragment),ae=p(),f=a("p"),ke=i(`The example above illustrates exporting a checkpoint from \u{1F917} Hub. When exporting a local model, first make sure that you
saved both the model\u2019s weights and tokenizer files in the same directory (`),S=a("code"),Fe=i("local_path"),Le=i(`). When using CLI, pass the
`),A=a("code"),Ve=i("local_path"),Ce=i(" to the "),W=a("code"),Se=i("model"),Ae=i(" argument instead of the checkpoint name on \u{1F917} Hub."),this.h()},l(e){const o=st('[data-svelte="svelte-1phssyn"]',document.head);u=n(o,"META",{name:!0,content:!0}),o.forEach(t),D=d(e),M=n(e,"H1",{class:!0});var re=r(M);w=n(re,"A",{id:!0,class:!0,href:!0});var Re=r(w);I=n(Re,"SPAN",{});var Xe=r(I);z(U.$$.fragment,Xe),Xe.forEach(t),Re.forEach(t),ce=d(re),k=n(re,"SPAN",{});var ze=r(k);he=s(ze,"Export to TFLite"),ze.forEach(t),re.forEach(t),O=d(e),T=n(e,"P",{});var R=r(T);J=n(R,"A",{href:!0,rel:!0});var Qe=r(J);ue=s(Qe,"TensorFlow Lite"),Qe.forEach(t),Me=s(R,` 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 `),F=n(R,"CODE",{});var He=r(F);Te=s(He,".tflite"),He.forEach(t),we=s(R," file extension."),R.forEach(t),P=d(e),h=n(e,"P",{});var $=r(h);be=s($,"\u{1F917} Optimum offers functionality to export \u{1F917} Transformers models to TFLite through the "),L=n($,"CODE",{});var Ne=r(L);ye=s(Ne,"exporters.tflite"),Ne.forEach(t),ve=s($,` module.
For the list of supported model architectures, please refer to `),g=n($,"A",{href:!0,rel:!0});var Ye=r(g);xe=s(Ye,"\u{1F917} Optimum documentation"),Ye.forEach(t),Ue=s($,"."),$.forEach(t),q=d(e),Z=n(e,"P",{});var De=r(Z);Je=s(De,"To export a model to TFLite, install the required dependencies:"),De.forEach(t),K=d(e),z(_.$$.fragment,e),ee=d(e),b=n(e,"P",{});var me=r(b);ge=s(me,"To check out all available arguments, refer to the "),G=n(me,"A",{href:!0,rel:!0});var Oe=r(G);_e=s(Oe,"\u{1F917} Optimum docs"),Oe.forEach(t),Ge=s(me,`,
or view help in command line:`),me.forEach(t),te=d(e),z(j.$$.fragment,e),le=d(e),y=n(e,"P",{});var pe=r(y);je=s(pe,"To export a model\u2019s checkpoint from the \u{1F917} Hub, for example, "),V=n(pe,"CODE",{});var Pe=r(V);Be=s(Pe,"bert-base-uncased"),Pe.forEach(t),Ee=s(pe,", run the following command:"),pe.forEach(t),oe=d(e),z(B.$$.fragment,e),ie=d(e),v=n(e,"P",{});var de=r(v);Ze=s(de,"You should see the logs indicating progress and showing where the resulting "),C=n(de,"CODE",{});var qe=r(C);$e=s(qe,"model.tflite"),qe.forEach(t),Ie=s(de," is saved, like this:"),de.forEach(t),se=d(e),z(E.$$.fragment,e),ae=d(e),f=n(e,"P",{});var x=r(f);ke=s(x,`The example above illustrates exporting a checkpoint from \u{1F917} Hub. When exporting a local model, first make sure that you
saved both the model\u2019s weights and tokenizer files in the same directory (`),S=n(x,"CODE",{});var Ke=r(S);Fe=s(Ke,"local_path"),Ke.forEach(t),Le=s(x,`). When using CLI, pass the
`),A=n(x,"CODE",{});var et=r(A);Ve=s(et,"local_path"),et.forEach(t),Ce=s(x," to the "),W=n(x,"CODE",{});var tt=r(W);Se=s(tt,"model"),tt.forEach(t),Ae=s(x," argument instead of the checkpoint name on \u{1F917} Hub."),x.forEach(t),this.h()},h(){c(u,"name","hf:doc:metadata"),c(u,"content",JSON.stringify(pt)),c(w,"id","export-to-tflite"),c(w,"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"),c(w,"href","#export-to-tflite"),c(M,"class","relative group"),c(J,"href","https://www.tensorflow.org/lite/guide"),c(J,"rel","nofollow"),c(g,"href","https://huggingface.co/docs/optimum/exporters/tflite/overview"),c(g,"rel","nofollow"),c(G,"href","https://huggingface.co/docs/optimum/main/en/exporters/tflite/usage_guides/export_a_model"),c(G,"rel","nofollow")},m(e,o){l(document.head,u),m(e,D,o),m(e,M,o),l(M,w),l(w,I),Q(U,I,null),l(M,ce),l(M,k),l(k,he),m(e,O,o),m(e,T,o),l(T,J),l(J,ue),l(T,Me),l(T,F),l(F,Te),l(T,we),m(e,P,o),m(e,h,o),l(h,be),l(h,L),l(L,ye),l(h,ve),l(h,g),l(g,xe),l(h,Ue),m(e,q,o),m(e,Z,o),l(Z,Je),m(e,K,o),Q(_,e,o),m(e,ee,o),m(e,b,o),l(b,ge),l(b,G),l(G,_e),l(b,Ge),m(e,te,o),Q(j,e,o),m(e,le,o),m(e,y,o),l(y,je),l(y,V),l(V,Be),l(y,Ee),m(e,oe,o),Q(B,e,o),m(e,ie,o),m(e,v,o),l(v,Ze),l(v,C),l(C,$e),l(v,Ie),m(e,se,o),Q(E,e,o),m(e,ae,o),m(e,f,o),l(f,ke),l(f,S),l(S,Fe),l(f,Le),l(f,A),l(A,Ve),l(f,Ce),l(f,W),l(W,Se),l(f,Ae),ne=!0},p:at,i(e){ne||(H(U.$$.fragment,e),H(_.$$.fragment,e),H(j.$$.fragment,e),H(B.$$.fragment,e),H(E.$$.fragment,e),ne=!0)},o(e){N(U.$$.fragment,e),N(_.$$.fragment,e),N(j.$$.fragment,e),N(B.$$.fragment,e),N(E.$$.fragment,e),ne=!1},d(e){t(u),e&&t(D),e&&t(M),Y(U),e&&t(O),e&&t(T),e&&t(P),e&&t(h),e&&t(q),e&&t(Z),e&&t(K),Y(_,e),e&&t(ee),e&&t(b),e&&t(te),Y(j,e),e&&t(le),e&&t(y),e&&t(oe),Y(B,e),e&&t(ie),e&&t(v),e&&t(se),Y(E,e),e&&t(ae),e&&t(f)}}}const pt={local:"export-to-tflite",title:"Export to TFLite"};function dt(We){return nt(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class ut extends lt{constructor(u){super();ot(this,u,dt,mt,it,{})}}export{ut as default,pt as metadata};
