import{s as se,n as ne,o as ae}from"../chunks/scheduler.9991993c.js";import{S as me,i as oe,g as a,s,r as G,A as pe,h as m,f as l,c as n,j as le,u as $,x as j,k as ie,y as Me,a as i,v as y,d as Z,t as x,w as g}from"../chunks/index.7fc9a5e7.js";import{C as N}from"../chunks/CodeBlock.e11cba92.js";import{H as fe,E as re}from"../chunks/EditOnGithub.84ab7f0e.js";function de(E){let o,I,B,L,p,V,M,P='<a href="https://www.tensorflow.org/lite/guide" rel="nofollow">TensorFlow Lite</a> 是一个轻量级框架，用于资源受限的设备上，如手机、嵌入式系统和物联网（IoT）设备，部署机器学习模型。TFLite 旨在在计算能力、内存和功耗有限的设备上优化和高效运行模型。模型以一种特殊的高效可移植格式表示，其文件扩展名为 <code>.tflite</code>。',_,f,D='🤗 Optimum 通过 <code>exporters.tflite</code> 模块提供将 🤗 Transformers 模型导出至 TFLite 格式的功能。请参考 <a href="https://huggingface.co/docs/optimum/exporters/tflite/overview" rel="nofollow">🤗 Optimum 文档</a> 以获取支持的模型架构列表。',H,r,q="要将模型导出为 TFLite 格式，请安装所需的依赖项：",C,d,F,T,O='请参阅 <a href="https://huggingface.co/docs/optimum/main/en/exporters/tflite/usage_guides/export_a_model" rel="nofollow">🤗 Optimum 文档</a> 以查看所有可用参数，或者在命令行中查看帮助：',S,c,W,u,K="运行以下命令，以从 🤗 Hub 导出模型的检查点（checkpoint），以 <code>google-bert/bert-base-uncased</code> 为例：",R,w,k,b,ee="你应该能在日志中看到导出进度以及生成的 <code>model.tflite</code> 文件的保存位置，如下所示：",Q,U,A,h,te="上面的示例说明了从 🤗 Hub 导出检查点的过程。导出本地模型时，首先需要确保将模型的权重和分词器文件保存在同一目录（<code>local_path</code>）中。在使用 CLI（命令行）时，将 <code>local_path</code> 传递给 <code>model</code> 参数，而不是 🤗 Hub 上的检查点名称。",X,J,Y,v,z;return p=new fe({props:{title:"导出为 TFLite",local:"导出为-tflite",headingTag:"h1"}}),d=new N({props:{code:"cGlwJTIwaW5zdGFsbCUyMG9wdGltdW0lNUJleHBvcnRlcnMtdGYlNUQ=",highlighted:"pip install optimum[exporters-tf]",wrap:!1}}),c=new N({props:{code:"b3B0aW11bS1jbGklMjBleHBvcnQlMjB0ZmxpdGUlMjAtLWhlbHA=",highlighted:'optimum-cli <span class="hljs-built_in">export</span> tflite --<span class="hljs-built_in">help</span>',wrap:!1}}),w=new N({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}}),U=new N({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}}),J=new re({props:{source:"https://github.com/huggingface/transformers/blob/main/docs/source/zh/tflite.md"}}),{c(){o=a("meta"),I=s(),B=a("p"),L=s(),G(p.$$.fragment),V=s(),M=a("p"),M.innerHTML=P,_=s(),f=a("p"),f.innerHTML=D,H=s(),r=a("p"),r.textContent=q,C=s(),G(d.$$.fragment),F=s(),T=a("p"),T.innerHTML=O,S=s(),G(c.$$.fragment),W=s(),u=a("p"),u.innerHTML=K,R=s(),G(w.$$.fragment),k=s(),b=a("p"),b.innerHTML=ee,Q=s(),G(U.$$.fragment),A=s(),h=a("p"),h.innerHTML=te,X=s(),G(J.$$.fragment),Y=s(),v=a("p"),this.h()},l(e){const t=pe("svelte-u9bgzb",document.head);o=m(t,"META",{name:!0,content:!0}),t.forEach(l),I=n(e),B=m(e,"P",{}),le(B).forEach(l),L=n(e),$(p.$$.fragment,e),V=n(e),M=m(e,"P",{"data-svelte-h":!0}),j(M)!=="svelte-mb0mc7"&&(M.innerHTML=P),_=n(e),f=m(e,"P",{"data-svelte-h":!0}),j(f)!=="svelte-1o6xu7v"&&(f.innerHTML=D),H=n(e),r=m(e,"P",{"data-svelte-h":!0}),j(r)!=="svelte-1o0dvm5"&&(r.textContent=q),C=n(e),$(d.$$.fragment,e),F=n(e),T=m(e,"P",{"data-svelte-h":!0}),j(T)!=="svelte-afi3po"&&(T.innerHTML=O),S=n(e),$(c.$$.fragment,e),W=n(e),u=m(e,"P",{"data-svelte-h":!0}),j(u)!=="svelte-1t4da3j"&&(u.innerHTML=K),R=n(e),$(w.$$.fragment,e),k=n(e),b=m(e,"P",{"data-svelte-h":!0}),j(b)!=="svelte-1db6oyf"&&(b.innerHTML=ee),Q=n(e),$(U.$$.fragment,e),A=n(e),h=m(e,"P",{"data-svelte-h":!0}),j(h)!=="svelte-cqegdm"&&(h.innerHTML=te),X=n(e),$(J.$$.fragment,e),Y=n(e),v=m(e,"P",{}),le(v).forEach(l),this.h()},h(){ie(o,"name","hf:doc:metadata"),ie(o,"content",Te)},m(e,t){Me(document.head,o),i(e,I,t),i(e,B,t),i(e,L,t),y(p,e,t),i(e,V,t),i(e,M,t),i(e,_,t),i(e,f,t),i(e,H,t),i(e,r,t),i(e,C,t),y(d,e,t),i(e,F,t),i(e,T,t),i(e,S,t),y(c,e,t),i(e,W,t),i(e,u,t),i(e,R,t),y(w,e,t),i(e,k,t),i(e,b,t),i(e,Q,t),y(U,e,t),i(e,A,t),i(e,h,t),i(e,X,t),y(J,e,t),i(e,Y,t),i(e,v,t),z=!0},p:ne,i(e){z||(Z(p.$$.fragment,e),Z(d.$$.fragment,e),Z(c.$$.fragment,e),Z(w.$$.fragment,e),Z(U.$$.fragment,e),Z(J.$$.fragment,e),z=!0)},o(e){x(p.$$.fragment,e),x(d.$$.fragment,e),x(c.$$.fragment,e),x(w.$$.fragment,e),x(U.$$.fragment,e),x(J.$$.fragment,e),z=!1},d(e){e&&(l(I),l(B),l(L),l(V),l(M),l(_),l(f),l(H),l(r),l(C),l(F),l(T),l(S),l(W),l(u),l(R),l(k),l(b),l(Q),l(A),l(h),l(X),l(Y),l(v)),l(o),g(p,e),g(d,e),g(c,e),g(w,e),g(U,e),g(J,e)}}}const Te='{"title":"导出为 TFLite","local":"导出为-tflite","sections":[],"depth":1}';function ce(E){return ae(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class he extends me{constructor(o){super(),oe(this,o,ce,de,se,{})}}export{he as component};
