import{S as Of,i as Cf,s as Lf,e as p,t as a,k as c,c as o,a as i,h as l,d as s,m as u,b as j,g as r,G as t,w as v,x as w,y as E,q as g,o as k,B as q,M as Nf,N as Lr,p as wl,v as Rf,n as El,L as Sf}from"../../chunks/vendor-hf-doc-builder.js";import{T as ua}from"../../chunks/Tip-hf-doc-builder.js";import{Y as fp}from"../../chunks/Youtube-hf-doc-builder.js";import{I as Mo}from"../../chunks/IconCopyLink-hf-doc-builder.js";import{C as S}from"../../chunks/CodeBlock-hf-doc-builder.js";import{D as Af}from"../../chunks/DocNotebookDropdown-hf-doc-builder.js";import{F as Ff}from"../../chunks/FrameworkSwitchCourse-hf-doc-builder.js";function Gf(B){let f,$;return f=new Af({props:{classNames:"absolute z-10 right-0 top-0",options:[{label:"Google Colab",value:"https://colab.research.google.com/github/huggingface/notebooks/blob/master/course/chapter7/section4_tf.ipynb"},{label:"Aws Studio",value:"https://studiolab.sagemaker.aws/import/github/huggingface/notebooks/blob/master/course/chapter7/section4_tf.ipynb"}]}}),{c(){v(f.$$.fragment)},l(d){w(f.$$.fragment,d)},m(d,b){E(f,d,b),$=!0},i(d){$||(g(f.$$.fragment,d),$=!0)},o(d){k(f.$$.fragment,d),$=!1},d(d){q(f,d)}}}function Hf(B){let f,$;return f=new Af({props:{classNames:"absolute z-10 right-0 top-0",options:[{label:"Google Colab",value:"https://colab.research.google.com/github/huggingface/notebooks/blob/master/course/chapter7/section4_pt.ipynb"},{label:"Aws Studio",value:"https://studiolab.sagemaker.aws/import/github/huggingface/notebooks/blob/master/course/chapter7/section4_pt.ipynb"}]}}),{c(){v(f.$$.fragment)},l(d){w(f.$$.fragment,d)},m(d,b){E(f,d,b),$=!0},i(d){$||(g(f.$$.fragment,d),$=!0)},o(d){k(f.$$.fragment,d),$=!1},d(d){q(f,d)}}}function Uf(B){let f,$,d,b,L;return{c(){f=p("p"),$=a("\u270F\uFE0F "),d=p("strong"),b=a("\u8F6E\u5230\u4F60\u4E86\uFF01"),L=a(" \u53E6\u4E00\u4E2A\u5728\u6CD5\u8BED\u4E2D\u7ECF\u5E38\u4F7F\u7528\u7684\u82F1\u8BED\u5355\u8BCD\u662F\u201Cemail\u201D\u3002\u5728\u8BAD\u7EC3\u6570\u636E\u96C6\u4E2D\u627E\u5230\u4F7F\u7528\u8FD9\u4E2A\u8BCD\u7684\u7B2C\u4E00\u4E2A\u6837\u672C\u3002\u5B83\u662F\u5982\u4F55\u7FFB\u8BD1\u7684\uFF1F\u9884\u8BAD\u7EC3\u6A21\u578B\u5982\u4F55\u7FFB\u8BD1\u540C\u4E00\u4E2A\u82F1\u6587\u53E5\u5B50\uFF1F")},l(T){f=o(T,"P",{});var C=i(f);$=l(C,"\u270F\uFE0F "),d=o(C,"STRONG",{});var D=i(d);b=l(D,"\u8F6E\u5230\u4F60\u4E86\uFF01"),D.forEach(s),L=l(C," \u53E6\u4E00\u4E2A\u5728\u6CD5\u8BED\u4E2D\u7ECF\u5E38\u4F7F\u7528\u7684\u82F1\u8BED\u5355\u8BCD\u662F\u201Cemail\u201D\u3002\u5728\u8BAD\u7EC3\u6570\u636E\u96C6\u4E2D\u627E\u5230\u4F7F\u7528\u8FD9\u4E2A\u8BCD\u7684\u7B2C\u4E00\u4E2A\u6837\u672C\u3002\u5B83\u662F\u5982\u4F55\u7FFB\u8BD1\u7684\uFF1F\u9884\u8BAD\u7EC3\u6A21\u578B\u5982\u4F55\u7FFB\u8BD1\u540C\u4E00\u4E2A\u82F1\u6587\u53E5\u5B50\uFF1F"),C.forEach(s)},m(T,C){r(T,f,C),t(f,$),t(f,d),t(d,b),t(f,L)},d(T){T&&s(f)}}}function If(B){let f,$;return{c(){f=p("p"),$=a("\u{1F4A1} \u5982\u679C\u6B63\u5728\u4F7F\u7528mart\u3001mBART-50\u6216M2 M100\u7B49\u591A\u8BED\u8A00\u6807\u8BB0\u5668\uFF0C\u5219\u9700\u8981\u5728tokenizer\u4E2D\u8BBE\u7F6Etokenizer.src_lang\u548Ctokenizer.tgt_lang\u4E3A\u6B63\u786E\u7684\u8F93\u5165\u548C\u76EE\u6807\u7684\u8BED\u8A00\u4EE3\u7801\u3002")},l(d){f=o(d,"P",{});var b=i(f);$=l(b,"\u{1F4A1} \u5982\u679C\u6B63\u5728\u4F7F\u7528mart\u3001mBART-50\u6216M2 M100\u7B49\u591A\u8BED\u8A00\u6807\u8BB0\u5668\uFF0C\u5219\u9700\u8981\u5728tokenizer\u4E2D\u8BBE\u7F6Etokenizer.src_lang\u548Ctokenizer.tgt_lang\u4E3A\u6B63\u786E\u7684\u8F93\u5165\u548C\u76EE\u6807\u7684\u8BED\u8A00\u4EE3\u7801\u3002"),b.forEach(s)},m(d,b){r(d,f,b),t(f,$)},d(d){d&&s(f)}}}function Mf(B){let f,$;return{c(){f=p("p"),$=a("\u{1F4A1}\u5982\u679C\u4F60\u4F7F\u7528\u7684\u662FT5\u6A21\u578B(\u66F4\u5177\u4F53\u5730\u8BF4\uFF0C\u662FT5 -xxx\u68C0\u67E5\u70B9\u4E4B\u4E00)\uFF0C\u6A21\u578B\u5C06\u9700\u8981\u6587\u672C\u8F93\u5165\u6709\u4E00\u4E2A\u524D\u7F00\u6765\u8868\u793A\u6B63\u5728\u8FDB\u884C\u7684\u4EFB\u52A1\uFF0C\u4F8B\u5982\u4ECE\u82F1\u8BED\u5230\u6CD5\u8BED\u7684\u7FFB\u8BD1")},l(d){f=o(d,"P",{});var b=i(f);$=l(b,"\u{1F4A1}\u5982\u679C\u4F60\u4F7F\u7528\u7684\u662FT5\u6A21\u578B(\u66F4\u5177\u4F53\u5730\u8BF4\uFF0C\u662FT5 -xxx\u68C0\u67E5\u70B9\u4E4B\u4E00)\uFF0C\u6A21\u578B\u5C06\u9700\u8981\u6587\u672C\u8F93\u5165\u6709\u4E00\u4E2A\u524D\u7F00\u6765\u8868\u793A\u6B63\u5728\u8FDB\u884C\u7684\u4EFB\u52A1\uFF0C\u4F8B\u5982\u4ECE\u82F1\u8BED\u5230\u6CD5\u8BED\u7684\u7FFB\u8BD1"),b.forEach(s)},m(d,b){r(d,f,b),t(f,$)},d(d){d&&s(f)}}}function Bf(B){let f,$;return{c(){f=p("p"),$=a("\u26A0\uFE0F \u6211\u4EEC\u4E0D\u5173\u6CE8\u76EE\u6807\u7684\u6CE8\u610F\u529B\u63A9\u7801\uFF0C\u56E0\u4E3A\u6A21\u578B\u4E0D\u4F1A\u9700\u8981\u5B83\u3002\u76F8\u53CD\uFF0C\u5BF9\u5E94\u4E8E\u586B\u5145\u6807\u8BB0\u7684\u6807\u7B7E\u5E94\u8BBE\u7F6E\u4E3A-100\uFF0C\u4EE5\u4FBF\u5728loss\u8BA1\u7B97\u4E2D\u5FFD\u7565\u5B83\u4EEC\u3002\u8FD9\u5C06\u5728\u7A0D\u540E\u7531\u6211\u4EEC\u7684\u6570\u636E\u6574\u7406\u5668\u5B8C\u6210\uFF0C\u56E0\u4E3A\u6211\u4EEC\u6B63\u5728\u5E94\u7528\u52A8\u6001\u586B\u5145\uFF0C\u4F46\u662F\u5982\u679C\u60A8\u5728\u6B64\u5904\u4F7F\u7528\u586B\u5145\uFF0C\u60A8\u5E94\u8BE5\u8C03\u6574\u9884\u5904\u7406\u51FD\u6570\u4EE5\u5C06\u4E0E\u586B\u5145\u6807\u8BB0\u5BF9\u5E94\u7684\u6240\u6709\u6807\u7B7E\u8BBE\u7F6E\u4E3A -100\u3002")},l(d){f=o(d,"P",{});var b=i(f);$=l(b,"\u26A0\uFE0F \u6211\u4EEC\u4E0D\u5173\u6CE8\u76EE\u6807\u7684\u6CE8\u610F\u529B\u63A9\u7801\uFF0C\u56E0\u4E3A\u6A21\u578B\u4E0D\u4F1A\u9700\u8981\u5B83\u3002\u76F8\u53CD\uFF0C\u5BF9\u5E94\u4E8E\u586B\u5145\u6807\u8BB0\u7684\u6807\u7B7E\u5E94\u8BBE\u7F6E\u4E3A-100\uFF0C\u4EE5\u4FBF\u5728loss\u8BA1\u7B97\u4E2D\u5FFD\u7565\u5B83\u4EEC\u3002\u8FD9\u5C06\u5728\u7A0D\u540E\u7531\u6211\u4EEC\u7684\u6570\u636E\u6574\u7406\u5668\u5B8C\u6210\uFF0C\u56E0\u4E3A\u6211\u4EEC\u6B63\u5728\u5E94\u7528\u52A8\u6001\u586B\u5145\uFF0C\u4F46\u662F\u5982\u679C\u60A8\u5728\u6B64\u5904\u4F7F\u7528\u586B\u5145\uFF0C\u60A8\u5E94\u8BE5\u8C03\u6574\u9884\u5904\u7406\u51FD\u6570\u4EE5\u5C06\u4E0E\u586B\u5145\u6807\u8BB0\u5BF9\u5E94\u7684\u6240\u6709\u6807\u7B7E\u8BBE\u7F6E\u4E3A -100\u3002"),b.forEach(s)},m(d,b){r(d,f,b),t(f,$)},d(d){d&&s(f)}}}function Kf(B){let f,$,d,b,L,T,C,D,y,A,N,x,P,H,U,F,J,K;return b=new Mo({}),U=new S({props:{code:`from transformers import TFAutoModelForSeq2SeqLM

model = TFAutoModelForSeq2SeqLM.from_pretrained(model_checkpoint, from_pt=True)`,highlighted:`<span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> TFAutoModelForSeq2SeqLM

model = TFAutoModelForSeq2SeqLM.from_pretrained(model_checkpoint, from_pt=<span class="hljs-literal">True</span>)`}}),J=new ua({props:{warning:!1,$$slots:{default:[Wf]},$$scope:{ctx:B}}}),{c(){f=p("h2"),$=p("a"),d=p("span"),v(b.$$.fragment),L=c(),T=p("span"),C=a("\u4F7F\u7528 Keras \u5FAE\u8C03\u6A21\u578B"),D=c(),y=p("p"),A=a("\u9996\u5148\uFF0C\u6211\u4EEC\u9700\u8981\u4E00\u4E2A\u5B9E\u9645\u7684\u6A21\u578B\u6765\u8FDB\u884C\u5FAE\u8C03\u3002 \u6211\u4EEC\u5C06\u4F7F\u7528\u901A\u5E38\u7684 "),N=p("code"),x=a("AutoModel"),P=a(" API\uFF1A"),H=c(),v(U.$$.fragment),F=c(),v(J.$$.fragment),this.h()},l(R){f=o(R,"H2",{class:!0});var I=i(f);$=o(I,"A",{id:!0,class:!0,href:!0});var X=i($);d=o(X,"SPAN",{});var Q=i(d);w(b.$$.fragment,Q),Q.forEach(s),X.forEach(s),L=u(I),T=o(I,"SPAN",{});var _e=i(T);C=l(_e,"\u4F7F\u7528 Keras \u5FAE\u8C03\u6A21\u578B"),_e.forEach(s),I.forEach(s),D=u(R),y=o(R,"P",{});var V=i(y);A=l(V,"\u9996\u5148\uFF0C\u6211\u4EEC\u9700\u8981\u4E00\u4E2A\u5B9E\u9645\u7684\u6A21\u578B\u6765\u8FDB\u884C\u5FAE\u8C03\u3002 \u6211\u4EEC\u5C06\u4F7F\u7528\u901A\u5E38\u7684 "),N=o(V,"CODE",{});var W=i(N);x=l(W,"AutoModel"),W.forEach(s),P=l(V," API\uFF1A"),V.forEach(s),H=u(R),w(U.$$.fragment,R),F=u(R),w(J.$$.fragment,R),this.h()},h(){j($,"id","keras"),j($,"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"),j($,"href","#keras"),j(f,"class","relative group")},m(R,I){r(R,f,I),t(f,$),t($,d),E(b,d,null),t(f,L),t(f,T),t(T,C),r(R,D,I),r(R,y,I),t(y,A),t(y,N),t(N,x),t(y,P),r(R,H,I),E(U,R,I),r(R,F,I),E(J,R,I),K=!0},i(R){K||(g(b.$$.fragment,R),g(U.$$.fragment,R),g(J.$$.fragment,R),K=!0)},o(R){k(b.$$.fragment,R),k(U.$$.fragment,R),k(J.$$.fragment,R),K=!1},d(R){R&&s(f),q(b),R&&s(D),R&&s(y),R&&s(H),q(U,R),R&&s(F),q(J,R)}}}function Xf(B){let f,$,d,b,L,T,C,D,y,A,N,x,P,H,U,F,J,K,R,I,X,Q,_e,V,W,ne,Y,Se,Te,me,Z,ee;return b=new Mo({}),Z=new S({props:{code:`from transformers import AutoModelForSeq2SeqLM

model = AutoModelForSeq2SeqLM.from_pretrained(model_checkpoint)`,highlighted:`<span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoModelForSeq2SeqLM

model = AutoModelForSeq2SeqLM.from_pretrained(model_checkpoint)`}}),{c(){f=p("h2"),$=p("a"),d=p("span"),v(b.$$.fragment),L=c(),T=p("span"),C=a("\u4F7F\u7528 Trainer API \u5FAE\u8C03\u6A21\u578B"),D=c(),y=p("p"),A=a("\u4F7F\u7528 "),N=p("code"),x=a("Trainer"),P=a(" \u7684\u5B9E\u9645\u4EE3\u7801\u5C06\u4E0E\u4EE5\u524D\u76F8\u540C\uFF0C\u53EA\u662F\u7A0D\u4F5C\u6539\u52A8\uFF1A\u6211\u4EEC\u5728\u8FD9\u91CC\u4F7F\u7528 "),H=p("a"),U=p("code"),F=a("Seq2SeqTrainer"),J=a("\uFF0C \u5B83\u662F "),K=p("code"),R=a("Trainer"),I=a(" \u7684\u5B50\u7C7B\uFF0C\u5B83\u53EF\u4EE5\u6B63\u786E\u5904\u7406\u8FD9\u79CD\u5E8F\u5217\u5230\u5E8F\u5217\u7684\u8BC4\u4F30\uFF0C\u5E76\u4F7F\u7528 "),X=p("code"),Q=a("generate()"),_e=a(" \u65B9\u6CD5\u6765\u9884\u6D4B\u8F93\u5165\u7684\u8F93\u51FA\u3002 \u5F53\u6211\u4EEC\u8BA8\u8BBA\u8BC4\u4F30\u6307\u6807\u65F6\uFF0C\u6211\u4EEC\u5C06\u66F4\u8BE6\u7EC6\u5730\u63A2\u8BA8\u8FD9\u4E00\u70B9\u3002"),V=c(),W=p("p"),ne=a("\u9996\u5148\uFF0C\u6211\u4EEC\u9700\u8981\u4E00\u4E2A\u5B9E\u9645\u7684\u6A21\u578B\u6765\u8FDB\u884C\u5FAE\u8C03\u3002 \u6211\u4EEC\u5C06\u4F7F\u7528\u901A\u5E38\u7684 "),Y=p("code"),Se=a("AutoModel"),Te=a(" API\uFF1A"),me=c(),v(Z.$$.fragment),this.h()},l(G){f=o(G,"H2",{class:!0});var se=i(f);$=o(se,"A",{id:!0,class:!0,href:!0});var de=i($);d=o(de,"SPAN",{});var $e=i(d);w(b.$$.fragment,$e),$e.forEach(s),de.forEach(s),L=u(se),T=o(se,"SPAN",{});var pe=i(T);C=l(pe,"\u4F7F\u7528 Trainer API \u5FAE\u8C03\u6A21\u578B"),pe.forEach(s),se.forEach(s),D=u(G),y=o(G,"P",{});var oe=i(y);A=l(oe,"\u4F7F\u7528 "),N=o(oe,"CODE",{});var te=i(N);x=l(te,"Trainer"),te.forEach(s),P=l(oe," \u7684\u5B9E\u9645\u4EE3\u7801\u5C06\u4E0E\u4EE5\u524D\u76F8\u540C\uFF0C\u53EA\u662F\u7A0D\u4F5C\u6539\u52A8\uFF1A\u6211\u4EEC\u5728\u8FD9\u91CC\u4F7F\u7528 "),H=o(oe,"A",{href:!0,rel:!0});var De=i(H);U=o(De,"CODE",{});var be=i(U);F=l(be,"Seq2SeqTrainer"),be.forEach(s),De.forEach(s),J=l(oe,"\uFF0C \u5B83\u662F "),K=o(oe,"CODE",{});var Ne=i(K);R=l(Ne,"Trainer"),Ne.forEach(s),I=l(oe," \u7684\u5B50\u7C7B\uFF0C\u5B83\u53EF\u4EE5\u6B63\u786E\u5904\u7406\u8FD9\u79CD\u5E8F\u5217\u5230\u5E8F\u5217\u7684\u8BC4\u4F30\uFF0C\u5E76\u4F7F\u7528 "),X=o(oe,"CODE",{});var ge=i(X);Q=l(ge,"generate()"),ge.forEach(s),_e=l(oe," \u65B9\u6CD5\u6765\u9884\u6D4B\u8F93\u5165\u7684\u8F93\u51FA\u3002 \u5F53\u6211\u4EEC\u8BA8\u8BBA\u8BC4\u4F30\u6307\u6807\u65F6\uFF0C\u6211\u4EEC\u5C06\u66F4\u8BE6\u7EC6\u5730\u63A2\u8BA8\u8FD9\u4E00\u70B9\u3002"),oe.forEach(s),V=u(G),W=o(G,"P",{});var ie=i(W);ne=l(ie,"\u9996\u5148\uFF0C\u6211\u4EEC\u9700\u8981\u4E00\u4E2A\u5B9E\u9645\u7684\u6A21\u578B\u6765\u8FDB\u884C\u5FAE\u8C03\u3002 \u6211\u4EEC\u5C06\u4F7F\u7528\u901A\u5E38\u7684 "),Y=o(ie,"CODE",{});var fe=i(Y);Se=l(fe,"AutoModel"),fe.forEach(s),Te=l(ie," API\uFF1A"),ie.forEach(s),me=u(G),w(Z.$$.fragment,G),this.h()},h(){j($,"id","trainer-api"),j($,"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"),j($,"href","#trainer-api"),j(f,"class","relative group"),j(H,"href","https://huggingface.co/transformers/main_classes/trainer.html#seq2seqtrainer"),j(H,"rel","nofollow")},m(G,se){r(G,f,se),t(f,$),t($,d),E(b,d,null),t(f,L),t(f,T),t(T,C),r(G,D,se),r(G,y,se),t(y,A),t(y,N),t(N,x),t(y,P),t(y,H),t(H,U),t(U,F),t(y,J),t(y,K),t(K,R),t(y,I),t(y,X),t(X,Q),t(y,_e),r(G,V,se),r(G,W,se),t(W,ne),t(W,Y),t(Y,Se),t(W,Te),r(G,me,se),E(Z,G,se),ee=!0},i(G){ee||(g(b.$$.fragment,G),g(Z.$$.fragment,G),ee=!0)},o(G){k(b.$$.fragment,G),k(Z.$$.fragment,G),ee=!1},d(G){G&&s(f),q(b),G&&s(D),G&&s(y),G&&s(V),G&&s(W),G&&s(me),q(Z,G)}}}function Wf(B){let f,$,d,b,L,T,C,D,y,A,N,x,P,H;return{c(){f=p("p"),$=a("\u{1F4A1} "),d=p("code"),b=a("Helsinki-NLP/opus-mt-en-fr"),L=a(" checkpoint\u53EA\u6709 PyTorch \u7684\u6743\u91CD\uFF0C\u6240\u4EE5\u5728\u4F7F\u7528"),T=p("code"),C=a("from_pretrained()"),D=a("\u65B9\u6CD5\u52A0\u8F7D\u6A21\u578B\u65F6\u4E0D\u4F1A\u4F7F\u7528 "),y=p("code"),A=a("from_pt=True"),N=a(" \u53C2\u6570\u3002 \u5F53\u60A8\u6307\u5B9A"),x=p("code"),P=a("from_pt=True"),H=a("\uFF0C\u5E93\u4F1A\u81EA\u52A8\u4E0B\u8F7D\u5E76\u8F6C\u6362PyTorch \u4E3A\u60A8\u63D0\u4F9B\u6743\u91CD\u3002 \u5982\u60A8\u6240\u89C1\uFF0C\u4F7F\u7528\u{1F917}transormer \u5728\u4E24\u8005\u4E4B\u95F4\u5207\u6362\u975E\u5E38\u7B80\u5355")},l(U){f=o(U,"P",{});var F=i(f);$=l(F,"\u{1F4A1} "),d=o(F,"CODE",{});var J=i(d);b=l(J,"Helsinki-NLP/opus-mt-en-fr"),J.forEach(s),L=l(F," checkpoint\u53EA\u6709 PyTorch \u7684\u6743\u91CD\uFF0C\u6240\u4EE5\u5728\u4F7F\u7528"),T=o(F,"CODE",{});var K=i(T);C=l(K,"from_pretrained()"),K.forEach(s),D=l(F,"\u65B9\u6CD5\u52A0\u8F7D\u6A21\u578B\u65F6\u4E0D\u4F1A\u4F7F\u7528 "),y=o(F,"CODE",{});var R=i(y);A=l(R,"from_pt=True"),R.forEach(s),N=l(F," \u53C2\u6570\u3002 \u5F53\u60A8\u6307\u5B9A"),x=o(F,"CODE",{});var I=i(x);P=l(I,"from_pt=True"),I.forEach(s),H=l(F,"\uFF0C\u5E93\u4F1A\u81EA\u52A8\u4E0B\u8F7D\u5E76\u8F6C\u6362PyTorch \u4E3A\u60A8\u63D0\u4F9B\u6743\u91CD\u3002 \u5982\u60A8\u6240\u89C1\uFF0C\u4F7F\u7528\u{1F917}transormer \u5728\u4E24\u8005\u4E4B\u95F4\u5207\u6362\u975E\u5E38\u7B80\u5355"),F.forEach(s)},m(U,F){r(U,f,F),t(f,$),t(f,d),t(d,b),t(f,L),t(f,T),t(T,C),t(f,D),t(f,y),t(y,A),t(f,N),t(f,x),t(x,P),t(f,H)},d(U){U&&s(f)}}}function Yf(B){let f,$;return f=new S({props:{code:`from transformers import DataCollatorForSeq2Seq

data_collator = DataCollatorForSeq2Seq(tokenizer, model=model, return_tensors="tf")`,highlighted:`<span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> DataCollatorForSeq2Seq

data_collator = DataCollatorForSeq2Seq(tokenizer, model=model, return_tensors=<span class="hljs-string">&quot;tf&quot;</span>)`}}),{c(){v(f.$$.fragment)},l(d){w(f.$$.fragment,d)},m(d,b){E(f,d,b),$=!0},i(d){$||(g(f.$$.fragment,d),$=!0)},o(d){k(f.$$.fragment,d),$=!1},d(d){q(f,d)}}}function Zf(B){let f,$;return f=new S({props:{code:`from transformers import DataCollatorForSeq2Seq

data_collator = DataCollatorForSeq2Seq(tokenizer, model=model)`,highlighted:`<span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> DataCollatorForSeq2Seq

data_collator = DataCollatorForSeq2Seq(tokenizer, model=model)`}}),{c(){v(f.$$.fragment)},l(d){w(f.$$.fragment,d)},m(d,b){E(f,d,b),$=!0},i(d){$||(g(f.$$.fragment,d),$=!0)},o(d){k(f.$$.fragment,d),$=!1},d(d){q(f,d)}}}function Jf(B){let f,$,d,b,L,T,C,D,y,A,N;return A=new S({props:{code:`tf_train_dataset = tokenized_datasets["train"].to_tf_dataset(
    columns=["input_ids", "attention_mask", "labels"],
    collate_fn=data_collator,
    shuffle=True,
    batch_size=32,
)
tf_eval_dataset = tokenized_datasets["validation"].to_tf_dataset(
    columns=["input_ids", "attention_mask", "labels"],
    collate_fn=data_collator,
    shuffle=False,
    batch_size=16,
)`,highlighted:`tf_train_dataset = tokenized_datasets[<span class="hljs-string">&quot;train&quot;</span>].to_tf_dataset(
    columns=[<span class="hljs-string">&quot;input_ids&quot;</span>, <span class="hljs-string">&quot;attention_mask&quot;</span>, <span class="hljs-string">&quot;labels&quot;</span>],
    collate_fn=data_collator,
    shuffle=<span class="hljs-literal">True</span>,
    batch_size=<span class="hljs-number">32</span>,
)
tf_eval_dataset = tokenized_datasets[<span class="hljs-string">&quot;validation&quot;</span>].to_tf_dataset(
    columns=[<span class="hljs-string">&quot;input_ids&quot;</span>, <span class="hljs-string">&quot;attention_mask&quot;</span>, <span class="hljs-string">&quot;labels&quot;</span>],
    collate_fn=data_collator,
    shuffle=<span class="hljs-literal">False</span>,
    batch_size=<span class="hljs-number">16</span>,
)`}}),{c(){f=p("p"),$=a("\u6211\u4EEC\u73B0\u5728\u53EF\u4EE5\u4F7F\u7528 "),d=p("code"),b=a("data_collator"),L=a(" \u5C06\u6211\u4EEC\u7684\u6BCF\u4E2A\u6570\u636E\u96C6\u8F6C\u6362\u4E3A "),T=p("code"),C=a("tf.data.Dataset"),D=a("\uFF0C\u51C6\u5907\u597D\u8FDB\u884C\u8BAD\u7EC3\uFF1A"),y=c(),v(A.$$.fragment)},l(x){f=o(x,"P",{});var P=i(f);$=l(P,"\u6211\u4EEC\u73B0\u5728\u53EF\u4EE5\u4F7F\u7528 "),d=o(P,"CODE",{});var H=i(d);b=l(H,"data_collator"),H.forEach(s),L=l(P," \u5C06\u6211\u4EEC\u7684\u6BCF\u4E2A\u6570\u636E\u96C6\u8F6C\u6362\u4E3A "),T=o(P,"CODE",{});var U=i(T);C=l(U,"tf.data.Dataset"),U.forEach(s),D=l(P,"\uFF0C\u51C6\u5907\u597D\u8FDB\u884C\u8BAD\u7EC3\uFF1A"),P.forEach(s),y=u(x),w(A.$$.fragment,x)},m(x,P){r(x,f,P),t(f,$),t(f,d),t(d,b),t(f,L),t(f,T),t(T,C),t(f,D),r(x,y,P),E(A,x,P),N=!0},i(x){N||(g(A.$$.fragment,x),N=!0)},o(x){k(A.$$.fragment,x),N=!1},d(x){x&&s(f),x&&s(y),q(A,x)}}}function Vf(B){let f,$,d,b,L,T,C,D;return{c(){f=p("p"),$=a("\u6211\u4EEC\u5C06\u628A\u8FD9\u4E2A "),d=p("code"),b=a("data_collator"),L=a(" \u4F20\u9012\u7ED9 "),T=p("code"),C=a("Seq2SeqTrainer"),D=a("\u3002 \u63A5\u4E0B\u6765\uFF0C\u8BA9\u6211\u4EEC\u770B\u4E00\u4E0B\u8BC4\u4F30\u6307\u6807\u3002")},l(y){f=o(y,"P",{});var A=i(f);$=l(A,"\u6211\u4EEC\u5C06\u628A\u8FD9\u4E2A "),d=o(A,"CODE",{});var N=i(d);b=l(N,"data_collator"),N.forEach(s),L=l(A," \u4F20\u9012\u7ED9 "),T=o(A,"CODE",{});var x=i(T);C=l(x,"Seq2SeqTrainer"),x.forEach(s),D=l(A,"\u3002 \u63A5\u4E0B\u6765\uFF0C\u8BA9\u6211\u4EEC\u770B\u4E00\u4E0B\u8BC4\u4F30\u6307\u6807\u3002"),A.forEach(s)},m(y,A){r(y,f,A),t(f,$),t(f,d),t(d,b),t(f,L),t(f,T),t(T,C),t(f,D)},i:Sf,o:Sf,d(y){y&&s(f)}}}function zf(B){let f,$,d,b,L,T,C,D,y,A,N,x,P,H,U,F,J,K,R;return{c(){f=p("p"),$=p("code"),d=a("Seq2SeqTrainer"),b=a(" \u6DFB\u52A0\u5230\u5176\u8D85\u7C7B "),L=p("code"),T=a("Trainer"),C=a(" \u7684\u529F\u80FD\u662F\u5728\u8BC4\u4F30\u6216\u9884\u6D4B\u671F\u95F4\u4F7F\u7528 "),D=p("code"),y=a("generate()"),A=a(" \u65B9\u6CD5\u7684\u80FD\u529B\u3002 \u5728\u8BAD\u7EC3\u671F\u95F4\uFF0C\u6A21\u578B\u5C06\u4F7F\u7528\u5E26\u6709\u6CE8\u610F\u63A9\u7801\u7684\u201Cdecoder_input_ids\u201D\uFF0C\u4EE5\u786E\u4FDD\u5B83\u4E0D\u4F7F\u7528\u9884\u6D4B\u7684\u6807\u8BB0\u4E4B\u540E\u7684\u6807\u8BB0\uFF0C\u4EE5\u52A0\u5FEB\u8BAD\u7EC3\u901F\u5EA6\u3002 \u5728\u63A8\u7406\u8FC7\u7A0B\u4E2D\uFF0C\u6211\u4EEC\u5C06\u65E0\u6CD5\u4F7F\u7528\u9884\u6D4B\u7684\u6807\u8BB0\u4E4B\u540E\u7684\u6807\u8BB0\uFF0C\u56E0\u4E3A\u6211\u4EEC\u6CA1\u6709\u6807\u7B7E\uFF0C\u56E0\u6B64\u4F7F\u7528\u76F8\u540C\u7684\u8BBE\u7F6E\u4F7F\u7528\u5E26\u6709\u6CE8\u610F\u63A9\u7801\u7684\u201Cdecoder_input_ids\u201D\uFF0C\u8BC4\u4F30\u6211\u4EEC\u7684\u6A21\u578B\u662F\u4E2A\u597D\u4E3B\u610F\u3002"),N=c(),x=p("p"),P=a("\u6B63\u5982\u6211\u4EEC\u5728"),H=p("a"),U=a("\u7B2C\u4E00\u7AE0"),F=a("\u770B\u5230\u7684\uFF0C\u89E3\u7801\u5668\u901A\u8FC7\u4E00\u4E2A\u4E00\u4E2A\u5730\u9884\u6D4B\u6807\u8BB0\u6765\u6267\u884C\u63A8\u7406\u2014\u2014\u8FD9\u662F\u{1F917} Transformers \u5728\u5E55\u540E\u901A\u8FC7 "),J=p("strong"),K=a("generate()"),R=a(" \u65B9\u6CD5\u5B9E\u73B0\u7684\u3002\u5982\u679C\u6211\u4EEC\u8BBE\u7F6E predict_with_generate=True\uFF0CSeq2 Seq Trainer \u5C06\u5141\u8BB8\u6211\u4EEC\u4F7F\u7528\u8BE5\u65B9\u6CD5\u8FDB\u884C\u8BC4\u4F30\u3002"),this.h()},l(I){f=o(I,"P",{});var X=i(f);$=o(X,"CODE",{});var Q=i($);d=l(Q,"Seq2SeqTrainer"),Q.forEach(s),b=l(X," \u6DFB\u52A0\u5230\u5176\u8D85\u7C7B "),L=o(X,"CODE",{});var _e=i(L);T=l(_e,"Trainer"),_e.forEach(s),C=l(X," \u7684\u529F\u80FD\u662F\u5728\u8BC4\u4F30\u6216\u9884\u6D4B\u671F\u95F4\u4F7F\u7528 "),D=o(X,"CODE",{});var V=i(D);y=l(V,"generate()"),V.forEach(s),A=l(X," \u65B9\u6CD5\u7684\u80FD\u529B\u3002 \u5728\u8BAD\u7EC3\u671F\u95F4\uFF0C\u6A21\u578B\u5C06\u4F7F\u7528\u5E26\u6709\u6CE8\u610F\u63A9\u7801\u7684\u201Cdecoder_input_ids\u201D\uFF0C\u4EE5\u786E\u4FDD\u5B83\u4E0D\u4F7F\u7528\u9884\u6D4B\u7684\u6807\u8BB0\u4E4B\u540E\u7684\u6807\u8BB0\uFF0C\u4EE5\u52A0\u5FEB\u8BAD\u7EC3\u901F\u5EA6\u3002 \u5728\u63A8\u7406\u8FC7\u7A0B\u4E2D\uFF0C\u6211\u4EEC\u5C06\u65E0\u6CD5\u4F7F\u7528\u9884\u6D4B\u7684\u6807\u8BB0\u4E4B\u540E\u7684\u6807\u8BB0\uFF0C\u56E0\u4E3A\u6211\u4EEC\u6CA1\u6709\u6807\u7B7E\uFF0C\u56E0\u6B64\u4F7F\u7528\u76F8\u540C\u7684\u8BBE\u7F6E\u4F7F\u7528\u5E26\u6709\u6CE8\u610F\u63A9\u7801\u7684\u201Cdecoder_input_ids\u201D\uFF0C\u8BC4\u4F30\u6211\u4EEC\u7684\u6A21\u578B\u662F\u4E2A\u597D\u4E3B\u610F\u3002"),X.forEach(s),N=u(I),x=o(I,"P",{});var W=i(x);P=l(W,"\u6B63\u5982\u6211\u4EEC\u5728"),H=o(W,"A",{href:!0});var ne=i(H);U=l(ne,"\u7B2C\u4E00\u7AE0"),ne.forEach(s),F=l(W,"\u770B\u5230\u7684\uFF0C\u89E3\u7801\u5668\u901A\u8FC7\u4E00\u4E2A\u4E00\u4E2A\u5730\u9884\u6D4B\u6807\u8BB0\u6765\u6267\u884C\u63A8\u7406\u2014\u2014\u8FD9\u662F\u{1F917} Transformers \u5728\u5E55\u540E\u901A\u8FC7 "),J=o(W,"STRONG",{});var Y=i(J);K=l(Y,"generate()"),Y.forEach(s),R=l(W," \u65B9\u6CD5\u5B9E\u73B0\u7684\u3002\u5982\u679C\u6211\u4EEC\u8BBE\u7F6E predict_with_generate=True\uFF0CSeq2 Seq Trainer \u5C06\u5141\u8BB8\u6211\u4EEC\u4F7F\u7528\u8BE5\u65B9\u6CD5\u8FDB\u884C\u8BC4\u4F30\u3002"),W.forEach(s),this.h()},h(){j(H,"href","/course/chapter1/6")},m(I,X){r(I,f,X),t(f,$),t($,d),t(f,b),t(f,L),t(L,T),t(f,C),t(f,D),t(D,y),t(f,A),r(I,N,X),r(I,x,X),t(x,P),t(x,H),t(H,U),t(x,F),t(x,J),t(J,K),t(x,R)},d(I){I&&s(f),I&&s(N),I&&s(x)}}}function Qf(B){let f,$,d,b,L,T,C,D,y,A,N;return A=new S({props:{code:`import numpy as np


def compute_metrics(eval_preds):
    preds, labels = eval_preds
    # In case the model returns more than the prediction logits
    if isinstance(preds, tuple):
        preds = preds[0]

    decoded_preds = tokenizer.batch_decode(preds, skip_special_tokens=True)

    # Replace -100s in the labels as we can't decode them
    labels = np.where(labels != -100, labels, tokenizer.pad_token_id)
    decoded_labels = tokenizer.batch_decode(labels, skip_special_tokens=True)

    # Some simple post-processing
    decoded_preds = [pred.strip() for pred in decoded_preds]
    decoded_labels = [[label.strip()] for label in decoded_labels]

    result = metric.compute(predictions=decoded_preds, references=decoded_labels)
    return {"bleu": result["score"]}`,highlighted:`<span class="hljs-keyword">import</span> numpy <span class="hljs-keyword">as</span> np


<span class="hljs-keyword">def</span> <span class="hljs-title function_">compute_metrics</span>(<span class="hljs-params">eval_preds</span>):
    preds, labels = eval_preds
    <span class="hljs-comment"># In case the model returns more than the prediction logits</span>
    <span class="hljs-keyword">if</span> <span class="hljs-built_in">isinstance</span>(preds, <span class="hljs-built_in">tuple</span>):
        preds = preds[<span class="hljs-number">0</span>]

    decoded_preds = tokenizer.batch_decode(preds, skip_special_tokens=<span class="hljs-literal">True</span>)

    <span class="hljs-comment"># Replace -100s in the labels as we can&#x27;t decode them</span>
    labels = np.where(labels != -<span class="hljs-number">100</span>, labels, tokenizer.pad_token_id)
    decoded_labels = tokenizer.batch_decode(labels, skip_special_tokens=<span class="hljs-literal">True</span>)

    <span class="hljs-comment"># Some simple post-processing</span>
    decoded_preds = [pred.strip() <span class="hljs-keyword">for</span> pred <span class="hljs-keyword">in</span> decoded_preds]
    decoded_labels = [[label.strip()] <span class="hljs-keyword">for</span> label <span class="hljs-keyword">in</span> decoded_labels]

    result = metric.compute(predictions=decoded_preds, references=decoded_labels)
    <span class="hljs-keyword">return</span> {<span class="hljs-string">&quot;bleu&quot;</span>: result[<span class="hljs-string">&quot;score&quot;</span>]}`}}),{c(){f=p("p"),$=a("\u4E3A\u4E86\u4ECE\u6A21\u578B\u8F93\u51FA\u5230\u5EA6\u91CF\u53EF\u4EE5\u4F7F\u7528\u7684\u6587\u672C\uFF0C\u6211\u4EEC\u5C06\u4F7F\u7528 "),d=p("code"),b=a("tokenizer.batch_decode()"),L=a(" \u65B9\u6CD5\u3002 \u6211\u4EEC\u53EA\u9700\u8981\u6E05\u7406\u6807\u7B7E\u4E2D\u7684\u6240\u6709 "),T=p("code"),C=a("-100"),D=a("\uFF08\u6807\u8BB0\u5668\u5C06\u81EA\u52A8\u5BF9\u586B\u5145\u6807\u8BB0\u6267\u884C\u76F8\u540C\u64CD\u4F5C\uFF09\uFF1A"),y=c(),v(A.$$.fragment)},l(x){f=o(x,"P",{});var P=i(f);$=l(P,"\u4E3A\u4E86\u4ECE\u6A21\u578B\u8F93\u51FA\u5230\u5EA6\u91CF\u53EF\u4EE5\u4F7F\u7528\u7684\u6587\u672C\uFF0C\u6211\u4EEC\u5C06\u4F7F\u7528 "),d=o(P,"CODE",{});var H=i(d);b=l(H,"tokenizer.batch_decode()"),H.forEach(s),L=l(P," \u65B9\u6CD5\u3002 \u6211\u4EEC\u53EA\u9700\u8981\u6E05\u7406\u6807\u7B7E\u4E2D\u7684\u6240\u6709 "),T=o(P,"CODE",{});var U=i(T);C=l(U,"-100"),U.forEach(s),D=l(P,"\uFF08\u6807\u8BB0\u5668\u5C06\u81EA\u52A8\u5BF9\u586B\u5145\u6807\u8BB0\u6267\u884C\u76F8\u540C\u64CD\u4F5C\uFF09\uFF1A"),P.forEach(s),y=u(x),w(A.$$.fragment,x)},m(x,P){r(x,f,P),t(f,$),t(f,d),t(d,b),t(f,L),t(f,T),t(T,C),t(f,D),r(x,y,P),E(A,x,P),N=!0},i(x){N||(g(A.$$.fragment,x),N=!0)},o(x){k(A.$$.fragment,x),N=!1},d(x){x&&s(f),x&&s(y),q(A,x)}}}function ec(B){let f,$,d,b,L,T,C,D,y,A,N;return A=new S({props:{code:`import numpy as np


def compute_metrics():
    all_preds = []
    all_labels = []
    sampled_dataset = tokenized_datasets["validation"].shuffle().select(range(200))
    tf_generate_dataset = sampled_dataset.to_tf_dataset(
        columns=["input_ids", "attention_mask", "labels"],
        collate_fn=data_collator,
        shuffle=False,
        batch_size=4,
    )
    for batch in tf_generate_dataset:
        predictions = model.generate(
            input_ids=batch["input_ids"], attention_mask=batch["attention_mask"]
        )
        decoded_preds = tokenizer.batch_decode(predictions, skip_special_tokens=True)
        labels = batch["labels"].numpy()
        labels = np.where(labels != -100, labels, tokenizer.pad_token_id)
        decoded_labels = tokenizer.batch_decode(labels, skip_special_tokens=True)
        decoded_preds = [pred.strip() for pred in decoded_preds]
        decoded_labels = [[label.strip()] for label in decoded_labels]
        all_preds.extend(decoded_preds)
        all_labels.extend(decoded_labels)

    result = metric.compute(predictions=all_preds, references=all_labels)
    return {"bleu": result["score"]}`,highlighted:`<span class="hljs-keyword">import</span> numpy <span class="hljs-keyword">as</span> np


<span class="hljs-keyword">def</span> <span class="hljs-title function_">compute_metrics</span>():
    all_preds = []
    all_labels = []
    sampled_dataset = tokenized_datasets[<span class="hljs-string">&quot;validation&quot;</span>].shuffle().select(<span class="hljs-built_in">range</span>(<span class="hljs-number">200</span>))
    tf_generate_dataset = sampled_dataset.to_tf_dataset(
        columns=[<span class="hljs-string">&quot;input_ids&quot;</span>, <span class="hljs-string">&quot;attention_mask&quot;</span>, <span class="hljs-string">&quot;labels&quot;</span>],
        collate_fn=data_collator,
        shuffle=<span class="hljs-literal">False</span>,
        batch_size=<span class="hljs-number">4</span>,
    )
    <span class="hljs-keyword">for</span> batch <span class="hljs-keyword">in</span> tf_generate_dataset:
        predictions = model.generate(
            input_ids=batch[<span class="hljs-string">&quot;input_ids&quot;</span>], attention_mask=batch[<span class="hljs-string">&quot;attention_mask&quot;</span>]
        )
        decoded_preds = tokenizer.batch_decode(predictions, skip_special_tokens=<span class="hljs-literal">True</span>)
        labels = batch[<span class="hljs-string">&quot;labels&quot;</span>].numpy()
        labels = np.where(labels != -<span class="hljs-number">100</span>, labels, tokenizer.pad_token_id)
        decoded_labels = tokenizer.batch_decode(labels, skip_special_tokens=<span class="hljs-literal">True</span>)
        decoded_preds = [pred.strip() <span class="hljs-keyword">for</span> pred <span class="hljs-keyword">in</span> decoded_preds]
        decoded_labels = [[label.strip()] <span class="hljs-keyword">for</span> label <span class="hljs-keyword">in</span> decoded_labels]
        all_preds.extend(decoded_preds)
        all_labels.extend(decoded_labels)

    result = metric.compute(predictions=all_preds, references=all_labels)
    <span class="hljs-keyword">return</span> {<span class="hljs-string">&quot;bleu&quot;</span>: result[<span class="hljs-string">&quot;score&quot;</span>]}`}}),{c(){f=p("p"),$=a("\u4E3A\u4E86\u4ECE\u6A21\u578B\u8F93\u51FA\u53EF\u4EE5\u88AB\u8BC4\u4F30\u57FA\u51C6\u53EF\u4EE5\u4F7F\u7528\u7684\u6587\u672C\uFF0C\u6211\u4EEC\u5C06\u4F7F\u7528 "),d=p("strong"),b=a("tokenizer.batch_decode()"),L=a(" \u65B9\u6CD5\u3002\u6211\u4EEC\u53EA\u9700\u8981\u6E05\u7406\u6807\u7B7E\u4E2D\u6240\u6709 "),T=p("strong"),C=a("-100"),D=a(" \uFF08\u6807\u8BB0\u5668\u4F1A\u81EA\u52A8\u4E3A\u586B\u5145\u6807\u8BB0\u505A\u540C\u6837\u7684\u4E8B\u60C5\uFF09\uFF1A"),y=c(),v(A.$$.fragment)},l(x){f=o(x,"P",{});var P=i(f);$=l(P,"\u4E3A\u4E86\u4ECE\u6A21\u578B\u8F93\u51FA\u53EF\u4EE5\u88AB\u8BC4\u4F30\u57FA\u51C6\u53EF\u4EE5\u4F7F\u7528\u7684\u6587\u672C\uFF0C\u6211\u4EEC\u5C06\u4F7F\u7528 "),d=o(P,"STRONG",{});var H=i(d);b=l(H,"tokenizer.batch_decode()"),H.forEach(s),L=l(P," \u65B9\u6CD5\u3002\u6211\u4EEC\u53EA\u9700\u8981\u6E05\u7406\u6807\u7B7E\u4E2D\u6240\u6709 "),T=o(P,"STRONG",{});var U=i(T);C=l(U,"-100"),U.forEach(s),D=l(P," \uFF08\u6807\u8BB0\u5668\u4F1A\u81EA\u52A8\u4E3A\u586B\u5145\u6807\u8BB0\u505A\u540C\u6837\u7684\u4E8B\u60C5\uFF09\uFF1A"),P.forEach(s),y=u(x),w(A.$$.fragment,x)},m(x,P){r(x,f,P),t(f,$),t(f,d),t(d,b),t(f,L),t(f,T),t(T,C),t(f,D),r(x,y,P),E(A,x,P),N=!0},i(x){N||(g(A.$$.fragment,x),N=!0)},o(x){k(A.$$.fragment,x),N=!1},d(x){x&&s(f),x&&s(y),q(A,x)}}}function sc(B){let f,$,d,b,L,T,C,D,y,A,N,x,P,H,U,F,J,K,R,I,X,Q,_e,V,W,ne,Y,Se,Te,me,Z,ee,G,se,de,$e,pe,oe,te,De,be,Ne,ge,ie,fe,os,ce,is,Be,Re,ve,Ae,ke,ae,Qe,Oe,le,es,h,M,he,Fs,Fe,je,xs,re,Pe,Ke,Xe,fs,ze,cs,we,Ge,us,Ee,Xs,Ce,hs,We,ys,ss,Ws,Ye,Ts,Ps,Ys,He,ue,Gs,Ze,Je,Hs,$s,Zs,ms,Ss,ts,Js,bs,_s,as,qe,ls,rs,gs,Vs,ns,Qs,ps;return P=new S({props:{code:`from transformers import Seq2SeqTrainingArguments

args = Seq2SeqTrainingArguments(
    f"marian-finetuned-kde4-en-to-fr",
    evaluation_strategy="no",
    save_strategy="epoch",
    learning_rate=2e-5,
    per_device_train_batch_size=32,
    per_device_eval_batch_size=64,
    weight_decay=0.01,
    save_total_limit=3,
    num_train_epochs=3,
    predict_with_generate=True,
    fp16=True,
    push_to_hub=True,
)`,highlighted:`<span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> Seq2SeqTrainingArguments

args = Seq2SeqTrainingArguments(
    <span class="hljs-string">f&quot;marian-finetuned-kde4-en-to-fr&quot;</span>,
    evaluation_strategy=<span class="hljs-string">&quot;no&quot;</span>,
    save_strategy=<span class="hljs-string">&quot;epoch&quot;</span>,
    learning_rate=<span class="hljs-number">2e-5</span>,
    per_device_train_batch_size=<span class="hljs-number">32</span>,
    per_device_eval_batch_size=<span class="hljs-number">64</span>,
    weight_decay=<span class="hljs-number">0.01</span>,
    save_total_limit=<span class="hljs-number">3</span>,
    num_train_epochs=<span class="hljs-number">3</span>,
    predict_with_generate=<span class="hljs-literal">True</span>,
    fp16=<span class="hljs-literal">True</span>,
    push_to_hub=<span class="hljs-literal">True</span>,
)`}}),ve=new ua({props:{$$slots:{default:[ac]},$$scope:{ctx:B}}}),h=new S({props:{code:`from transformers import Seq2SeqTrainer

trainer = Seq2SeqTrainer(
    model,
    args,
    train_dataset=tokenized_datasets["train"],
    eval_dataset=tokenized_datasets["validation"],
    data_collator=data_collator,
    tokenizer=tokenizer,
    compute_metrics=compute_metrics,
)`,highlighted:`<span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> Seq2SeqTrainer

trainer = Seq2SeqTrainer(
    model,
    args,
    train_dataset=tokenized_datasets[<span class="hljs-string">&quot;train&quot;</span>],
    eval_dataset=tokenized_datasets[<span class="hljs-string">&quot;validation&quot;</span>],
    data_collator=data_collator,
    tokenizer=tokenizer,
    compute_metrics=compute_metrics,
)`}}),je=new S({props:{code:"trainer.evaluate(max_length=max_target_length)",highlighted:"trainer.evaluate(max_length=max_target_length)"}}),re=new S({props:{code:`{'eval_loss': 1.6964408159255981,
 'eval_bleu': 39.26865061007616,
 'eval_runtime': 965.8884,
 'eval_samples_per_second': 21.76,
 'eval_steps_per_second': 0.341}`,highlighted:`{<span class="hljs-string">&#x27;eval_loss&#x27;</span>: <span class="hljs-number">1.6964408159255981</span>,
 <span class="hljs-string">&#x27;eval_bleu&#x27;</span>: <span class="hljs-number">39.26865061007616</span>,
 <span class="hljs-string">&#x27;eval_runtime&#x27;</span>: <span class="hljs-number">965.8884</span>,
 <span class="hljs-string">&#x27;eval_samples_per_second&#x27;</span>: <span class="hljs-number">21.76</span>,
 <span class="hljs-string">&#x27;eval_steps_per_second&#x27;</span>: <span class="hljs-number">0.341</span>}`}}),Ge=new S({props:{code:"trainer.train()",highlighted:"trainer.train()"}}),ss=new S({props:{code:"trainer.evaluate(max_length=max_target_length)",highlighted:"trainer.evaluate(max_length=max_target_length)"}}),Ye=new S({props:{code:`{'eval_loss': 0.8558505773544312,
 'eval_bleu': 52.94161337775576,
 'eval_runtime': 714.2576,
 'eval_samples_per_second': 29.426,
 'eval_steps_per_second': 0.461,
 'epoch': 3.0}`,highlighted:`{<span class="hljs-string">&#x27;eval_loss&#x27;</span>: <span class="hljs-number">0.8558505773544312</span>,
 <span class="hljs-string">&#x27;eval_bleu&#x27;</span>: <span class="hljs-number">52.94161337775576</span>,
 <span class="hljs-string">&#x27;eval_runtime&#x27;</span>: <span class="hljs-number">714.2576</span>,
 <span class="hljs-string">&#x27;eval_samples_per_second&#x27;</span>: <span class="hljs-number">29.426</span>,
 <span class="hljs-string">&#x27;eval_steps_per_second&#x27;</span>: <span class="hljs-number">0.461</span>,
 <span class="hljs-string">&#x27;epoch&#x27;</span>: <span class="hljs-number">3.0</span>}`}}),ts=new S({props:{code:'trainer.push_to_hub(tags="translation", commit_message="Training complete")',highlighted:'trainer.push_to_hub(tags=<span class="hljs-string">&quot;translation&quot;</span>, commit_message=<span class="hljs-string">&quot;Training complete&quot;</span>)'}}),qe=new S({props:{code:"'https://huggingface.co/sgugger/marian-finetuned-kde4-en-to-fr/commit/3601d621e3baae2bc63d3311452535f8f58f6ef3'",highlighted:'<span class="hljs-string">&#x27;https://huggingface.co/sgugger/marian-finetuned-kde4-en-to-fr/commit/3601d621e3baae2bc63d3311452535f8f58f6ef3&#x27;</span>'}}),{c(){f=p("p"),$=a("\u4E00\u65E6\u5B8C\u6210\uFF0C\u6211\u4EEC\u5C31\u53EF\u4EE5\u5B9A\u4E49\u6211\u4EEC\u7684 "),d=p("code"),b=a("Seq2SeqTrainingArguments"),L=a("\u3002 \u4E0E "),T=p("code"),C=a("Trainer"),D=a(" \u4E00\u6837\uFF0C\u6211\u4EEC\u4F7F\u7528 "),y=p("code"),A=a("TrainingArguments"),N=a(" \u7684\u5B50\u7C7B\uFF0C\u5176\u4E2D\u5305\u542B\u66F4\u591A\u53EF\u4EE5\u8BBE\u7F6E\u7684\u5B57\u6BB5\uFF1A"),x=c(),v(P.$$.fragment),H=c(),U=p("p"),F=a("\u9664\u4E86\u901A\u5E38\u7684\u8D85\u53C2\u6570\uFF08\u5982\u5B66\u4E60\u7387\u3001\u8BAD\u7EC3\u8F6E\u6570\u3001\u6279\u6B21\u5927\u5C0F\u548C\u4E00\u4E9B\u6743\u91CD\u8870\u51CF\uFF09\u4E4B\u5916\uFF0C\u4E0E\u6211\u4EEC\u5728\u524D\u51E0\u8282\u4E2D\u770B\u5230\u7684\u76F8\u6BD4\uFF0C\u8FD9\u91CC\u6709\u4E00\u4E9B\u53D8\u5316\uFF1A"),J=c(),K=p("ul"),R=p("li"),I=a("\u6211\u4EEC\u6CA1\u6709\u8BBE\u7F6E\u4EFB\u4F55\u5B9A\u671F\u8BC4\u4F30\uFF0C\u56E0\u4E3A\u8BC4\u4F30\u9700\u8981\u8017\u8D39\u4E00\u5B9A\u7684\u65F6\u95F4\uFF1B\u6211\u4EEC\u53EA\u4F1A\u5728\u8BAD\u7EC3\u5F00\u59CB\u4E4B\u524D\u548C\u7ED3\u675F\u4E4B\u540E\u8BC4\u4F30\u6211\u4EEC\u7684\u6A21\u578B\u4E00\u6B21\u3002"),X=c(),Q=p("li"),_e=a("\u6211\u4EEC\u8BBE\u7F6Efp16=True\uFF0C\u8FD9\u53EF\u4EE5\u52A0\u5FEB\u652F\u6301fp16\u7684 GPU \u4E0A\u7684\u8BAD\u7EC3\u901F\u5EA6\u3002"),V=c(),W=p("li"),ne=a("\u548C\u4E0A\u9762\u6211\u4EEC\u8BA8\u8BBA\u7684\u90A3\u6837\uFF0C\u6211\u4EEC\u8BBE\u7F6Epredict_with_generate=True"),Y=c(),Se=p("li"),Te=a("\u6211\u4EEC\u7528push_to_hub=True\u5728\u6BCF\u4E2A epoch \u7ED3\u675F\u65F6\u5C06\u6A21\u578B\u4E0A\u4F20\u5230 Hub\u3002"),me=c(),Z=p("p"),ee=a("\u8BF7\u6CE8\u610F\uFF0C\u60A8\u53EF\u4EE5\u4F7F\u7528 "),G=p("code"),se=a("hub_model_id"),de=a(" \u53C2\u6570\u6307\u5B9A\u8981\u63A8\u9001\u5230\u7684\u5B58\u50A8\u5E93\u7684\u540D\u79F0\uFF08\u5F53\u60A8\u60F3\u628A\u6A21\u578B\u63A8\u9001\u5230\u6307\u5B9A\u7684\u7EC4\u7EC7\u7684\u65F6\u5019\uFF0C\u60A8\u4E5F\u5FC5\u987B\u4F7F\u7528\u6B64\u53C2\u6570\uFF09\u3002 \u4F8B\u5982\uFF0C\u5F53\u6211\u4EEC\u5C06\u6A21\u578B\u63A8\u9001\u5230 "),$e=p("a"),pe=p("code"),oe=a("huggingface-course"),te=a(" \u7EC4\u7EC7"),De=a(" \u65F6\uFF0C\u6211\u4EEC\u6DFB\u52A0\u4E86 "),be=p("code"),Ne=a('hub_model_id="huggingface-course/marian-finetuned-kde4-en- to-fr"'),ge=a(" \u5230 "),ie=p("code"),fe=a("Seq2SeqTrainingArguments"),os=a("\u3002 \u9ED8\u8BA4\u60C5\u51B5\u4E0B\uFF0C\u4F7F\u7528\u7684\u5B58\u50A8\u5E93\u5C06\u5728\u60A8\u7684\u547D\u540D\u7A7A\u95F4\u4E2D\uFF0C\u5E76\u4EE5\u60A8\u8BBE\u7F6E\u7684\u8F93\u51FA\u76EE\u5F55\u547D\u540D\uFF0C\u56E0\u6B64\u8FD9\u91CC\u5C06\u662F "),ce=p("code"),is=a('"sgugger/marian-finetuned-kde4-en-to-fr"'),Be=a("\u3002"),Re=c(),v(ve.$$.fragment),Ae=c(),ke=p("p"),ae=a("\u6700\u540E\uFF0C\u6211\u4EEC\u9700\u8981\u5C06\u6240\u6709\u5185\u5BB9\u4F20\u9012\u7ED9 "),Qe=p("strong"),Oe=a("Seq2SeqTrainer"),le=a(" \uFF1A"),es=c(),v(h.$$.fragment),M=c(),he=p("p"),Fs=a("\u5728\u8BAD\u7EC3\u4E4B\u524D\uFF0C\u6211\u4EEC\u5C06\u9996\u5148\u67E5\u770B\u6211\u4EEC\u7684\u6A21\u578B\u83B7\u5F97\u7684\u5206\u6570\uFF0C\u4EE5\u4ED4\u7EC6\u68C0\u67E5\u6211\u4EEC\u7684\u5FAE\u8C03\u6CA1\u6709\u8BA9\u4E8B\u60C5\u53D8\u5F97\u66F4\u7CDF\u3002\u6B64\u547D\u4EE4\u9700\u8981\u4E00\u4E9B\u65F6\u95F4\uFF0C\u56E0\u6B64\u60A8\u53EF\u4EE5\u5728\u6267\u884C\u65F6\u559D\u676F\u5496\u5561\uFF1A"),Fe=c(),v(je.$$.fragment),xs=c(),v(re.$$.fragment),Pe=c(),Ke=p("p"),Xe=a("BLEU\u7684\u5206\u6570\u8FD8\u4E0D\u9519\uFF0C\u8FD9\u53CD\u6620\u4E86\u6211\u4EEC\u7684\u6A21\u578B\u5DF2\u7ECF\u64C5\u957F\u5C06\u82F1\u8BED\u53E5\u5B50\u7FFB\u8BD1\u6210\u6CD5\u8BED\u53E5\u5B50\u3002"),fs=c(),ze=p("p"),cs=a("\u63A5\u4E0B\u6765\u662F\u8BAD\u7EC3\uFF0C\u8FD9\u4E5F\u9700\u8981\u4E00\u4E9B\u65F6\u95F4\uFF1A"),we=c(),v(Ge.$$.fragment),us=c(),Ee=p("p"),Xs=a("\u8BF7\u6CE8\u610F\uFF0C\u5F53\u8BAD\u7EC3\u53D1\u751F\u65F6\uFF0C\u6BCF\u6B21\u4FDD\u5B58\u6A21\u578B\u65F6\uFF08\u8FD9\u91CC\u662F\u6BCF\u4E2A\u65F6\u671F\uFF09\uFF0C\u5B83\u90FD\u4F1A\u5728\u540E\u53F0\u4E0A\u4F20\u5230 Hub\u3002\u8FD9\u6837\uFF0C\u5982\u6709\u5FC5\u8981\uFF0C\u60A8\u5C06\u80FD\u591F\u5728\u53E6\u4E00\u53F0\u673A\u5668\u4E0A\u7EE7\u7EED\u60A8\u7684\u8BAD\u7EC3\u3002"),Ce=c(),hs=p("p"),We=a("\u8BAD\u7EC3\u5B8C\u6210\u540E\uFF0C\u6211\u4EEC\u518D\u6B21\u8BC4\u4F30\u6211\u4EEC\u7684\u6A21\u578B\u2014\u2014\u5E0C\u671B\u6211\u4EEC\u4F1A\u770B\u5230 BLEU \u5206\u6570\u6709\u6240\u6539\u5584\uFF01"),ys=c(),v(ss.$$.fragment),Ws=c(),v(Ye.$$.fragment),Ts=c(),Ps=p("p"),Ys=a("\u8FD9\u662F\u8FD1 14 \u70B9\u7684\u6539\u8FDB\uFF0C\u8FD9\u5F88\u68D2\u3002"),He=c(),ue=p("p"),Gs=a("\u6700\u540E\uFF0C\u6211\u4EEC\u4F7F\u7528 "),Ze=p("strong"),Je=a("push_to_hub()"),Hs=a(" \u65B9\u6CD5\u6765\u786E\u4FDD\u6211\u4EEC\u4E0A\u4F20\u6A21\u578B\u7684\u6700\u65B0\u7248\u672C\u3002\u8FD9 "),$s=p("strong"),Zs=a("Trainer"),ms=a(" \u8FD8\u521B\u5EFA\u4E86\u4E00\u5F20\u5305\u542B\u6240\u6709\u8BC4\u4F30\u7ED3\u679C\u7684\u6A21\u578B\u5361\u5E76\u4E0A\u4F20\u3002\u6B64\u6A21\u578B\u5361\u5305\u542B\u53EF\u5E2E\u52A9\u6A21\u578B\u4E2D\u5FC3\u4E3A\u63A8\u7406\u6F14\u793A\u9009\u62E9\u5C0F\u90E8\u4EF6\u7684\u5143\u6570\u636E\u3002\u901A\u5E38\u4E0D\u9700\u8981\u505A\u989D\u5916\u7684\u66F4\u6539\uFF0C\u56E0\u4E3A\u5B83\u53EF\u4EE5\u4ECE\u6A21\u578B\u7C7B\u4E2D\u63A8\u65AD\u51FA\u6B63\u786E\u7684\u5C0F\u90E8\u4EF6\uFF0C\u4F46\u5728\u8FD9\u79CD\u60C5\u51B5\u4E0B\uFF0C\u76F8\u540C\u7684\u6A21\u578B\u7C7B\u53EF\u4EE5\u7528\u4E8E\u6240\u6709\u7C7B\u578B\u7684\u5E8F\u5217\u5230\u5E8F\u5217\u95EE\u9898\uFF0C\u6240\u4EE5\u6211\u4EEC\u6307\u5B9A\u5B83\u662F\u4E00\u4E2A\u7FFB\u8BD1\u6A21\u578B\uFF1A"),Ss=c(),v(ts.$$.fragment),Js=c(),bs=p("p"),_s=a("\u5982\u679C\u60A8\u60F3\u68C0\u67E5\u547D\u4EE4\u6267\u884C\u7684\u7ED3\u679C\uFF0C\u6B64\u547D\u4EE4\u5C06\u8FD4\u56DE\u5B83\u521A\u521A\u6267\u884C\u7684\u63D0\u4EA4\u7684 URL\uFF0C\u53EF\u4EE5\u6253\u5F00url\u8FDB\u884C\u68C0\u67E5\uFF1A"),as=c(),v(qe.$$.fragment),ls=c(),rs=p("p"),gs=a("\u5728\u6B64\u9636\u6BB5\uFF0C\u60A8\u53EF\u4EE5\u4F7F\u7528\u6A21\u578B\u4E2D\u5FC3\u4E0A\u7684\u63A8\u7406\u5C0F\u90E8\u4EF6\u6765\u6D4B\u8BD5\u60A8\u7684\u6A21\u578B\u5E76\u4E0E\u60A8\u7684\u670B\u53CB\u5206\u4EAB\u3002\u60A8\u5DF2\u6210\u529F\u5FAE\u8C03\u7FFB\u8BD1\u4EFB\u52A1\u7684\u6A21\u578B - \u606D\u559C\uFF01"),Vs=c(),ns=p("p"),Qs=a("\u5982\u679C\u60A8\u60F3\u66F4\u6DF1\u5165\u5730\u4E86\u89E3\u8BAD\u7EC3\u5FAA\u73AF\uFF0C\u6211\u4EEC\u73B0\u5728\u5C06\u5411\u60A8\u5C55\u793A\u5982\u4F55\u4F7F\u7528 \u{1F917} Accelerate \u505A\u540C\u6837\u7684\u4E8B\u60C5\u3002"),this.h()},l(_){f=o(_,"P",{});var z=i(f);$=l(z,"\u4E00\u65E6\u5B8C\u6210\uFF0C\u6211\u4EEC\u5C31\u53EF\u4EE5\u5B9A\u4E49\u6211\u4EEC\u7684 "),d=o(z,"CODE",{});var Us=i(d);b=l(Us,"Seq2SeqTrainingArguments"),Us.forEach(s),L=l(z,"\u3002 \u4E0E "),T=o(z,"CODE",{});var et=i(T);C=l(et,"Trainer"),et.forEach(s),D=l(z," \u4E00\u6837\uFF0C\u6211\u4EEC\u4F7F\u7528 "),y=o(z,"CODE",{});var ft=i(y);A=l(ft,"TrainingArguments"),ft.forEach(s),N=l(z," \u7684\u5B50\u7C7B\uFF0C\u5176\u4E2D\u5305\u542B\u66F4\u591A\u53EF\u4EE5\u8BBE\u7F6E\u7684\u5B57\u6BB5\uFF1A"),z.forEach(s),x=u(_),w(P.$$.fragment,_),H=u(_),U=o(_,"P",{});var zs=i(U);F=l(zs,"\u9664\u4E86\u901A\u5E38\u7684\u8D85\u53C2\u6570\uFF08\u5982\u5B66\u4E60\u7387\u3001\u8BAD\u7EC3\u8F6E\u6570\u3001\u6279\u6B21\u5927\u5C0F\u548C\u4E00\u4E9B\u6743\u91CD\u8870\u51CF\uFF09\u4E4B\u5916\uFF0C\u4E0E\u6211\u4EEC\u5728\u524D\u51E0\u8282\u4E2D\u770B\u5230\u7684\u76F8\u6BD4\uFF0C\u8FD9\u91CC\u6709\u4E00\u4E9B\u53D8\u5316\uFF1A"),zs.forEach(s),J=u(_),K=o(_,"UL",{});var Ue=i(K);R=o(Ue,"LI",{});var Ds=i(R);I=l(Ds,"\u6211\u4EEC\u6CA1\u6709\u8BBE\u7F6E\u4EFB\u4F55\u5B9A\u671F\u8BC4\u4F30\uFF0C\u56E0\u4E3A\u8BC4\u4F30\u9700\u8981\u8017\u8D39\u4E00\u5B9A\u7684\u65F6\u95F4\uFF1B\u6211\u4EEC\u53EA\u4F1A\u5728\u8BAD\u7EC3\u5F00\u59CB\u4E4B\u524D\u548C\u7ED3\u675F\u4E4B\u540E\u8BC4\u4F30\u6211\u4EEC\u7684\u6A21\u578B\u4E00\u6B21\u3002"),Ds.forEach(s),X=u(Ue),Q=o(Ue,"LI",{});var ct=i(Q);_e=l(ct,"\u6211\u4EEC\u8BBE\u7F6Efp16=True\uFF0C\u8FD9\u53EF\u4EE5\u52A0\u5FEB\u652F\u6301fp16\u7684 GPU \u4E0A\u7684\u8BAD\u7EC3\u901F\u5EA6\u3002"),ct.forEach(s),V=u(Ue),W=o(Ue,"LI",{});var Le=i(W);ne=l(Le,"\u548C\u4E0A\u9762\u6211\u4EEC\u8BA8\u8BBA\u7684\u90A3\u6837\uFF0C\u6211\u4EEC\u8BBE\u7F6Epredict_with_generate=True"),Le.forEach(s),Y=u(Ue),Se=o(Ue,"LI",{});var Ie=i(Se);Te=l(Ie,"\u6211\u4EEC\u7528push_to_hub=True\u5728\u6BCF\u4E2A epoch \u7ED3\u675F\u65F6\u5C06\u6A21\u578B\u4E0A\u4F20\u5230 Hub\u3002"),Ie.forEach(s),Ue.forEach(s),me=u(_),Z=o(_,"P",{});var xe=i(Z);ee=l(xe,"\u8BF7\u6CE8\u610F\uFF0C\u60A8\u53EF\u4EE5\u4F7F\u7528 "),G=o(xe,"CODE",{});var Is=i(G);se=l(Is,"hub_model_id"),Is.forEach(s),de=l(xe," \u53C2\u6570\u6307\u5B9A\u8981\u63A8\u9001\u5230\u7684\u5B58\u50A8\u5E93\u7684\u540D\u79F0\uFF08\u5F53\u60A8\u60F3\u628A\u6A21\u578B\u63A8\u9001\u5230\u6307\u5B9A\u7684\u7EC4\u7EC7\u7684\u65F6\u5019\uFF0C\u60A8\u4E5F\u5FC5\u987B\u4F7F\u7528\u6B64\u53C2\u6570\uFF09\u3002 \u4F8B\u5982\uFF0C\u5F53\u6211\u4EEC\u5C06\u6A21\u578B\u63A8\u9001\u5230 "),$e=o(xe,"A",{href:!0,rel:!0});var ut=i($e);pe=o(ut,"CODE",{});var st=i(pe);oe=l(st,"huggingface-course"),st.forEach(s),te=l(ut," \u7EC4\u7EC7"),ut.forEach(s),De=l(xe," \u65F6\uFF0C\u6211\u4EEC\u6DFB\u52A0\u4E86 "),be=o(xe,"CODE",{});var tt=i(be);Ne=l(tt,'hub_model_id="huggingface-course/marian-finetuned-kde4-en- to-fr"'),tt.forEach(s),ge=l(xe," \u5230 "),ie=o(xe,"CODE",{});var Pt=i(ie);fe=l(Pt,"Seq2SeqTrainingArguments"),Pt.forEach(s),os=l(xe,"\u3002 \u9ED8\u8BA4\u60C5\u51B5\u4E0B\uFF0C\u4F7F\u7528\u7684\u5B58\u50A8\u5E93\u5C06\u5728\u60A8\u7684\u547D\u540D\u7A7A\u95F4\u4E2D\uFF0C\u5E76\u4EE5\u60A8\u8BBE\u7F6E\u7684\u8F93\u51FA\u76EE\u5F55\u547D\u540D\uFF0C\u56E0\u6B64\u8FD9\u91CC\u5C06\u662F "),ce=o(xe,"CODE",{});var at=i(ce);is=l(at,'"sgugger/marian-finetuned-kde4-en-to-fr"'),at.forEach(s),Be=l(xe,"\u3002"),xe.forEach(s),Re=u(_),w(ve.$$.fragment,_),Ae=u(_),ke=o(_,"P",{});var As=i(ke);ae=l(As,"\u6700\u540E\uFF0C\u6211\u4EEC\u9700\u8981\u5C06\u6240\u6709\u5185\u5BB9\u4F20\u9012\u7ED9 "),Qe=o(As,"STRONG",{});var St=i(Qe);Oe=l(St,"Seq2SeqTrainer"),St.forEach(s),le=l(As," \uFF1A"),As.forEach(s),es=u(_),w(h.$$.fragment,_),M=u(_),he=o(_,"P",{});var mt=i(he);Fs=l(mt,"\u5728\u8BAD\u7EC3\u4E4B\u524D\uFF0C\u6211\u4EEC\u5C06\u9996\u5148\u67E5\u770B\u6211\u4EEC\u7684\u6A21\u578B\u83B7\u5F97\u7684\u5206\u6570\uFF0C\u4EE5\u4ED4\u7EC6\u68C0\u67E5\u6211\u4EEC\u7684\u5FAE\u8C03\u6CA1\u6709\u8BA9\u4E8B\u60C5\u53D8\u5F97\u66F4\u7CDF\u3002\u6B64\u547D\u4EE4\u9700\u8981\u4E00\u4E9B\u65F6\u95F4\uFF0C\u56E0\u6B64\u60A8\u53EF\u4EE5\u5728\u6267\u884C\u65F6\u559D\u676F\u5496\u5561\uFF1A"),mt.forEach(s),Fe=u(_),w(je.$$.fragment,_),xs=u(_),w(re.$$.fragment,_),Pe=u(_),Ke=o(_,"P",{});var ks=i(Ke);Xe=l(ks,"BLEU\u7684\u5206\u6570\u8FD8\u4E0D\u9519\uFF0C\u8FD9\u53CD\u6620\u4E86\u6211\u4EEC\u7684\u6A21\u578B\u5DF2\u7ECF\u64C5\u957F\u5C06\u82F1\u8BED\u53E5\u5B50\u7FFB\u8BD1\u6210\u6CD5\u8BED\u53E5\u5B50\u3002"),ks.forEach(s),fs=u(_),ze=o(_,"P",{});var js=i(ze);cs=l(js,"\u63A5\u4E0B\u6765\u662F\u8BAD\u7EC3\uFF0C\u8FD9\u4E5F\u9700\u8981\u4E00\u4E9B\u65F6\u95F4\uFF1A"),js.forEach(s),we=u(_),w(Ge.$$.fragment,_),us=u(_),Ee=o(_,"P",{});var vs=i(Ee);Xs=l(vs,"\u8BF7\u6CE8\u610F\uFF0C\u5F53\u8BAD\u7EC3\u53D1\u751F\u65F6\uFF0C\u6BCF\u6B21\u4FDD\u5B58\u6A21\u578B\u65F6\uFF08\u8FD9\u91CC\u662F\u6BCF\u4E2A\u65F6\u671F\uFF09\uFF0C\u5B83\u90FD\u4F1A\u5728\u540E\u53F0\u4E0A\u4F20\u5230 Hub\u3002\u8FD9\u6837\uFF0C\u5982\u6709\u5FC5\u8981\uFF0C\u60A8\u5C06\u80FD\u591F\u5728\u53E6\u4E00\u53F0\u673A\u5668\u4E0A\u7EE7\u7EED\u60A8\u7684\u8BAD\u7EC3\u3002"),vs.forEach(s),Ce=u(_),hs=o(_,"P",{});var ws=i(hs);We=l(ws,"\u8BAD\u7EC3\u5B8C\u6210\u540E\uFF0C\u6211\u4EEC\u518D\u6B21\u8BC4\u4F30\u6211\u4EEC\u7684\u6A21\u578B\u2014\u2014\u5E0C\u671B\u6211\u4EEC\u4F1A\u770B\u5230 BLEU \u5206\u6570\u6709\u6240\u6539\u5584\uFF01"),ws.forEach(s),ys=u(_),w(ss.$$.fragment,_),Ws=u(_),w(Ye.$$.fragment,_),Ts=u(_),Ps=o(_,"P",{});var Ve=i(Ps);Ys=l(Ve,"\u8FD9\u662F\u8FD1 14 \u70B9\u7684\u6539\u8FDB\uFF0C\u8FD9\u5F88\u68D2\u3002"),Ve.forEach(s),He=u(_),ue=o(_,"P",{});var ye=i(ue);Gs=l(ye,"\u6700\u540E\uFF0C\u6211\u4EEC\u4F7F\u7528 "),Ze=o(ye,"STRONG",{});var lt=i(Ze);Je=l(lt,"push_to_hub()"),lt.forEach(s),Hs=l(ye," \u65B9\u6CD5\u6765\u786E\u4FDD\u6211\u4EEC\u4E0A\u4F20\u6A21\u578B\u7684\u6700\u65B0\u7248\u672C\u3002\u8FD9 "),$s=o(ye,"STRONG",{});var rt=i($s);Zs=l(rt,"Trainer"),rt.forEach(s),ms=l(ye," \u8FD8\u521B\u5EFA\u4E86\u4E00\u5F20\u5305\u542B\u6240\u6709\u8BC4\u4F30\u7ED3\u679C\u7684\u6A21\u578B\u5361\u5E76\u4E0A\u4F20\u3002\u6B64\u6A21\u578B\u5361\u5305\u542B\u53EF\u5E2E\u52A9\u6A21\u578B\u4E2D\u5FC3\u4E3A\u63A8\u7406\u6F14\u793A\u9009\u62E9\u5C0F\u90E8\u4EF6\u7684\u5143\u6570\u636E\u3002\u901A\u5E38\u4E0D\u9700\u8981\u505A\u989D\u5916\u7684\u66F4\u6539\uFF0C\u56E0\u4E3A\u5B83\u53EF\u4EE5\u4ECE\u6A21\u578B\u7C7B\u4E2D\u63A8\u65AD\u51FA\u6B63\u786E\u7684\u5C0F\u90E8\u4EF6\uFF0C\u4F46\u5728\u8FD9\u79CD\u60C5\u51B5\u4E0B\uFF0C\u76F8\u540C\u7684\u6A21\u578B\u7C7B\u53EF\u4EE5\u7528\u4E8E\u6240\u6709\u7C7B\u578B\u7684\u5E8F\u5217\u5230\u5E8F\u5217\u95EE\u9898\uFF0C\u6240\u4EE5\u6211\u4EEC\u6307\u5B9A\u5B83\u662F\u4E00\u4E2A\u7FFB\u8BD1\u6A21\u578B\uFF1A"),ye.forEach(s),Ss=u(_),w(ts.$$.fragment,_),Js=u(_),bs=o(_,"P",{});var zt=i(bs);_s=l(zt,"\u5982\u679C\u60A8\u60F3\u68C0\u67E5\u547D\u4EE4\u6267\u884C\u7684\u7ED3\u679C\uFF0C\u6B64\u547D\u4EE4\u5C06\u8FD4\u56DE\u5B83\u521A\u521A\u6267\u884C\u7684\u63D0\u4EA4\u7684 URL\uFF0C\u53EF\u4EE5\u6253\u5F00url\u8FDB\u884C\u68C0\u67E5\uFF1A"),zt.forEach(s),as=u(_),w(qe.$$.fragment,_),ls=u(_),rs=o(_,"P",{});var nt=i(rs);gs=l(nt,"\u5728\u6B64\u9636\u6BB5\uFF0C\u60A8\u53EF\u4EE5\u4F7F\u7528\u6A21\u578B\u4E2D\u5FC3\u4E0A\u7684\u63A8\u7406\u5C0F\u90E8\u4EF6\u6765\u6D4B\u8BD5\u60A8\u7684\u6A21\u578B\u5E76\u4E0E\u60A8\u7684\u670B\u53CB\u5206\u4EAB\u3002\u60A8\u5DF2\u6210\u529F\u5FAE\u8C03\u7FFB\u8BD1\u4EFB\u52A1\u7684\u6A21\u578B - \u606D\u559C\uFF01"),nt.forEach(s),Vs=u(_),ns=o(_,"P",{});var pt=i(ns);Qs=l(pt,"\u5982\u679C\u60A8\u60F3\u66F4\u6DF1\u5165\u5730\u4E86\u89E3\u8BAD\u7EC3\u5FAA\u73AF\uFF0C\u6211\u4EEC\u73B0\u5728\u5C06\u5411\u60A8\u5C55\u793A\u5982\u4F55\u4F7F\u7528 \u{1F917} Accelerate \u505A\u540C\u6837\u7684\u4E8B\u60C5\u3002"),pt.forEach(s),this.h()},h(){j($e,"href","https://huggingface.co/huggingface-course"),j($e,"rel","nofollow")},m(_,z){r(_,f,z),t(f,$),t(f,d),t(d,b),t(f,L),t(f,T),t(T,C),t(f,D),t(f,y),t(y,A),t(f,N),r(_,x,z),E(P,_,z),r(_,H,z),r(_,U,z),t(U,F),r(_,J,z),r(_,K,z),t(K,R),t(R,I),t(K,X),t(K,Q),t(Q,_e),t(K,V),t(K,W),t(W,ne),t(K,Y),t(K,Se),t(Se,Te),r(_,me,z),r(_,Z,z),t(Z,ee),t(Z,G),t(G,se),t(Z,de),t(Z,$e),t($e,pe),t(pe,oe),t($e,te),t(Z,De),t(Z,be),t(be,Ne),t(Z,ge),t(Z,ie),t(ie,fe),t(Z,os),t(Z,ce),t(ce,is),t(Z,Be),r(_,Re,z),E(ve,_,z),r(_,Ae,z),r(_,ke,z),t(ke,ae),t(ke,Qe),t(Qe,Oe),t(ke,le),r(_,es,z),E(h,_,z),r(_,M,z),r(_,he,z),t(he,Fs),r(_,Fe,z),E(je,_,z),r(_,xs,z),E(re,_,z),r(_,Pe,z),r(_,Ke,z),t(Ke,Xe),r(_,fs,z),r(_,ze,z),t(ze,cs),r(_,we,z),E(Ge,_,z),r(_,us,z),r(_,Ee,z),t(Ee,Xs),r(_,Ce,z),r(_,hs,z),t(hs,We),r(_,ys,z),E(ss,_,z),r(_,Ws,z),E(Ye,_,z),r(_,Ts,z),r(_,Ps,z),t(Ps,Ys),r(_,He,z),r(_,ue,z),t(ue,Gs),t(ue,Ze),t(Ze,Je),t(ue,Hs),t(ue,$s),t($s,Zs),t(ue,ms),r(_,Ss,z),E(ts,_,z),r(_,Js,z),r(_,bs,z),t(bs,_s),r(_,as,z),E(qe,_,z),r(_,ls,z),r(_,rs,z),t(rs,gs),r(_,Vs,z),r(_,ns,z),t(ns,Qs),ps=!0},i(_){ps||(g(P.$$.fragment,_),g(ve.$$.fragment,_),g(h.$$.fragment,_),g(je.$$.fragment,_),g(re.$$.fragment,_),g(Ge.$$.fragment,_),g(ss.$$.fragment,_),g(Ye.$$.fragment,_),g(ts.$$.fragment,_),g(qe.$$.fragment,_),ps=!0)},o(_){k(P.$$.fragment,_),k(ve.$$.fragment,_),k(h.$$.fragment,_),k(je.$$.fragment,_),k(re.$$.fragment,_),k(Ge.$$.fragment,_),k(ss.$$.fragment,_),k(Ye.$$.fragment,_),k(ts.$$.fragment,_),k(qe.$$.fragment,_),ps=!1},d(_){_&&s(f),_&&s(x),q(P,_),_&&s(H),_&&s(U),_&&s(J),_&&s(K),_&&s(me),_&&s(Z),_&&s(Re),q(ve,_),_&&s(Ae),_&&s(ke),_&&s(es),q(h,_),_&&s(M),_&&s(he),_&&s(Fe),q(je,_),_&&s(xs),q(re,_),_&&s(Pe),_&&s(Ke),_&&s(fs),_&&s(ze),_&&s(we),q(Ge,_),_&&s(us),_&&s(Ee),_&&s(Ce),_&&s(hs),_&&s(ys),q(ss,_),_&&s(Ws),q(Ye,_),_&&s(Ts),_&&s(Ps),_&&s(He),_&&s(ue),_&&s(Ss),q(ts,_),_&&s(Js),_&&s(bs),_&&s(as),q(qe,_),_&&s(ls),_&&s(rs),_&&s(Vs),_&&s(ns)}}}function tc(B){let f,$,d,b,L,T,C,D,y,A,N,x,P,H,U,F,J,K,R,I,X,Q,_e,V,W,ne,Y,Se,Te,me,Z,ee,G,se,de,$e,pe,oe,te,De,be,Ne,ge,ie,fe,os,ce,is,Be,Re,ve,Ae,ke,ae,Qe,Oe,le,es;return b=new S({props:{code:"print(compute_metrics())",highlighted:'<span class="hljs-built_in">print</span>(compute_metrics())'}}),T=new S({props:{code:"{'bleu': 33.26983701454733}",highlighted:'{&#x27;bleu&#x27;: <span class="hljs-number">33.26983701454733</span>}'}}),H=new S({props:{code:`from transformers import create_optimizer
from transformers.keras_callbacks import PushToHubCallback
import tensorflow as tf

# The number of training steps is the number of samples in the dataset, divided by the batch size then multiplied
# by the total number of epochs. Note that the tf_train_dataset here is a batched tf.data.Dataset,
# not the original Hugging Face Dataset, so its len() is already num_samples // batch_size.
num_epochs = 3
num_train_steps = len(tf_train_dataset) * num_epochs

optimizer, schedule = create_optimizer(
    init_lr=5e-5,
    num_warmup_steps=0,
    num_train_steps=num_train_steps,
    weight_decay_rate=0.01,
)
model.compile(optimizer=optimizer)

# Train in mixed-precision float16
tf.keras.mixed_precision.set_global_policy("mixed_float16")`,highlighted:`<span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> create_optimizer
<span class="hljs-keyword">from</span> transformers.keras_callbacks <span class="hljs-keyword">import</span> PushToHubCallback
<span class="hljs-keyword">import</span> tensorflow <span class="hljs-keyword">as</span> tf

<span class="hljs-comment"># The number of training steps is the number of samples in the dataset, divided by the batch size then multiplied</span>
<span class="hljs-comment"># by the total number of epochs. Note that the tf_train_dataset here is a batched tf.data.Dataset,</span>
<span class="hljs-comment"># not the original Hugging Face Dataset, so its len() is already num_samples // batch_size.</span>
num_epochs = <span class="hljs-number">3</span>
num_train_steps = <span class="hljs-built_in">len</span>(tf_train_dataset) * num_epochs

optimizer, schedule = create_optimizer(
    init_lr=<span class="hljs-number">5e-5</span>,
    num_warmup_steps=<span class="hljs-number">0</span>,
    num_train_steps=num_train_steps,
    weight_decay_rate=<span class="hljs-number">0.01</span>,
)
model.<span class="hljs-built_in">compile</span>(optimizer=optimizer)

<span class="hljs-comment"># Train in mixed-precision float16</span>
tf.keras.mixed_precision.set_global_policy(<span class="hljs-string">&quot;mixed_float16&quot;</span>)`}}),W=new S({props:{code:`from transformers.keras_callbacks import PushToHubCallback

callback = PushToHubCallback(
    output_dir="marian-finetuned-kde4-en-to-fr", tokenizer=tokenizer
)

model.fit(
    tf_train_dataset,
    validation_data=tf_eval_dataset,
    callbacks=[callback],
    epochs=num_epochs,
)`,highlighted:`<span class="hljs-keyword">from</span> transformers.keras_callbacks <span class="hljs-keyword">import</span> PushToHubCallback

callback = PushToHubCallback(
    output_dir=<span class="hljs-string">&quot;marian-finetuned-kde4-en-to-fr&quot;</span>, tokenizer=tokenizer
)

model.fit(
    tf_train_dataset,
    validation_data=tf_eval_dataset,
    callbacks=[callback],
    epochs=num_epochs,
)`}}),ce=new ua({props:{$$slots:{default:[lc]},$$scope:{ctx:B}}}),Ae=new S({props:{code:"print(compute_metrics())",highlighted:'<span class="hljs-built_in">print</span>(compute_metrics())'}}),ae=new S({props:{code:"{'bleu': 57.334066271545865}",highlighted:'{&#x27;bleu&#x27;: <span class="hljs-number">57.334066271545865</span>}'}}),{c(){f=p("p"),$=a("\u5728\u6211\u4EEC\u5F00\u59CB\u4E4B\u524D\uFF0C\u8BA9\u6211\u4EEC\u770B\u770B\u6211\u4EEC\u5728\u6CA1\u6709\u4EFB\u4F55\u8BAD\u7EC3\u7684\u60C5\u51B5\u4E0B\u4ECE\u6211\u4EEC\u7684\u6A21\u578B\u4E2D\u5F97\u5230\u4E86\u4EC0\u4E48\u6837\u7684\u7ED3\u679C\uFF1A"),d=c(),v(b.$$.fragment),L=c(),v(T.$$.fragment),C=c(),D=p("p"),y=a("\u4E00\u65E6\u5B8C\u6210\uFF0C\u6211\u4EEC\u5C31\u53EF\u4EE5\u51C6\u5907\u7F16\u8BD1\u548C\u8BAD\u7EC3\u6A21\u578B\u6240\u9700\u7684\u4E00\u5207\u3002 \u6CE8\u610F\u5F53\u4F7F\u7528 "),A=p("code"),N=a('tf.keras.mixed_precision.set_global_policy("mixed_float16")'),x=a("\u65F6\u2014\u2014\u8FD9\u5C06\u544A\u8BC9 Keras \u4F7F\u7528 float16 \u8FDB\u884C\u8BAD\u7EC3\uFF0C\u8FD9\u53EF\u4EE5\u663E\u7740\u63D0\u9AD8\u652F\u6301\u5B83\u7684 GPU\uFF08Nvidia 20xx/V100 \u6216\u66F4\u9AD8\u7248\u672C\uFF09\u7684\u901F\u5EA6\u3002"),P=c(),v(H.$$.fragment),U=c(),F=p("p"),J=a("\u63A5\u4E0B\u6765\uFF0C\u6211\u4EEC\u5B9A\u4E49\u4E00\u4E2A "),K=p("code"),R=a("PushToHubCallback"),I=a(" \u4EE5\u4FBF\u5728\u8BAD\u7EC3\u671F\u95F4\u5C06\u6211\u4EEC\u7684\u6A21\u578B\u4E0A\u4F20\u5230 Hub\uFF0C\u6B63\u5982\u6211\u4EEC\u5728 "),X=p("a"),Q=a("\u7B2C 2 \u8282"),_e=a(" \u4E2D\u770B\u5230\u7684\uFF0C\u7136\u540E\u6211\u4EEC\u53EA\u9700\u62DF\u5408\u6A21\u578B\u65F6\u6DFB\u52A0\u8BE5\u56DE\u8C03\u51FD\u6570\uFF1A"),V=c(),v(W.$$.fragment),ne=c(),Y=p("p"),Se=a("\u8BF7\u6CE8\u610F\uFF0C\u60A8\u53EF\u4EE5\u4F7F\u7528 "),Te=p("code"),me=a("hub_model_id"),Z=a(" \u53C2\u6570\u6307\u5B9A\u8981\u63A8\u9001\u5230\u7684\u5B58\u50A8\u5E93\u7684\u540D\u79F0\uFF08\u5F53\u60A8\u60F3\u628A\u6A21\u578B\u63A8\u9001\u5230\u6307\u5B9A\u7684\u7EC4\u7EC7\u7684\u65F6\u5019\uFF0C\u60A8\u4E5F\u5FC5\u987B\u4F7F\u7528\u6B64\u53C2\u6570\uFF09\u3002 \u4F8B\u5982\uFF0C\u5F53\u6211\u4EEC\u5C06\u6A21\u578B\u63A8\u9001\u5230 "),ee=p("a"),G=p("code"),se=a("huggingface-course"),de=a(" \u7EC4\u7EC7"),$e=a(" \u65F6\uFF0C\u6211\u4EEC\u6DFB\u52A0\u4E86 "),pe=p("code"),oe=a('hub_model_id="huggingface-course/marian-finetuned-kde4-en- to-fr"'),te=a(" \u5230 "),De=p("code"),be=a("Seq2SeqTrainingArguments"),Ne=a("\u3002 \u9ED8\u8BA4\u60C5\u51B5\u4E0B\uFF0C\u4F7F\u7528\u7684\u5B58\u50A8\u5E93\u5C06\u5728\u60A8\u7684\u547D\u540D\u7A7A\u95F4\u4E2D\uFF0C\u5E76\u4EE5\u60A8\u8BBE\u7F6E\u7684\u8F93\u51FA\u76EE\u5F55\u547D\u540D\uFF0C\u56E0\u6B64\u8FD9\u91CC\u5C06\u662F "),ge=p("code"),ie=a('"sgugger/marian-finetuned-kde4-en-to-fr"'),fe=a("\u3002"),os=c(),v(ce.$$.fragment),is=c(),Be=p("p"),Re=a("\u6700\u540E\uFF0C\u8BA9\u6211\u4EEC\u770B\u770B\u8BAD\u7EC3\u7ED3\u675F\u540E\u6211\u4EEC\u7684\u6307\u6807\u662F\u4EC0\u4E48\u6837\u7684\uFF1A"),ve=c(),v(Ae.$$.fragment),ke=c(),v(ae.$$.fragment),Qe=c(),Oe=p("p"),le=a("\u5728\u8FD9\u4E2A\u9636\u6BB5\uFF0C\u60A8\u53EF\u4EE5\u4F7F\u7528\u6A21\u578B\u4E2D\u5FC3\u4E0A\u7684\u63A8\u7406\u5C0F\u90E8\u4EF6\u6765\u6D4B\u8BD5\u60A8\u7684\u6A21\u578B\u5E76\u4E0E\u60A8\u7684\u670B\u53CB\u5206\u4EAB\u3002 \u60A8\u5DF2\u7ECF\u6210\u529F\u5730\u5FAE\u8C03\u4E86\u7FFB\u8BD1\u4EFB\u52A1\u4E2D\u7684\u6A21\u578B\u2014\u2014\u606D\u559C\uFF01"),this.h()},l(h){f=o(h,"P",{});var M=i(f);$=l(M,"\u5728\u6211\u4EEC\u5F00\u59CB\u4E4B\u524D\uFF0C\u8BA9\u6211\u4EEC\u770B\u770B\u6211\u4EEC\u5728\u6CA1\u6709\u4EFB\u4F55\u8BAD\u7EC3\u7684\u60C5\u51B5\u4E0B\u4ECE\u6211\u4EEC\u7684\u6A21\u578B\u4E2D\u5F97\u5230\u4E86\u4EC0\u4E48\u6837\u7684\u7ED3\u679C\uFF1A"),M.forEach(s),d=u(h),w(b.$$.fragment,h),L=u(h),w(T.$$.fragment,h),C=u(h),D=o(h,"P",{});var he=i(D);y=l(he,"\u4E00\u65E6\u5B8C\u6210\uFF0C\u6211\u4EEC\u5C31\u53EF\u4EE5\u51C6\u5907\u7F16\u8BD1\u548C\u8BAD\u7EC3\u6A21\u578B\u6240\u9700\u7684\u4E00\u5207\u3002 \u6CE8\u610F\u5F53\u4F7F\u7528 "),A=o(he,"CODE",{});var Fs=i(A);N=l(Fs,'tf.keras.mixed_precision.set_global_policy("mixed_float16")'),Fs.forEach(s),x=l(he,"\u65F6\u2014\u2014\u8FD9\u5C06\u544A\u8BC9 Keras \u4F7F\u7528 float16 \u8FDB\u884C\u8BAD\u7EC3\uFF0C\u8FD9\u53EF\u4EE5\u663E\u7740\u63D0\u9AD8\u652F\u6301\u5B83\u7684 GPU\uFF08Nvidia 20xx/V100 \u6216\u66F4\u9AD8\u7248\u672C\uFF09\u7684\u901F\u5EA6\u3002"),he.forEach(s),P=u(h),w(H.$$.fragment,h),U=u(h),F=o(h,"P",{});var Fe=i(F);J=l(Fe,"\u63A5\u4E0B\u6765\uFF0C\u6211\u4EEC\u5B9A\u4E49\u4E00\u4E2A "),K=o(Fe,"CODE",{});var je=i(K);R=l(je,"PushToHubCallback"),je.forEach(s),I=l(Fe," \u4EE5\u4FBF\u5728\u8BAD\u7EC3\u671F\u95F4\u5C06\u6211\u4EEC\u7684\u6A21\u578B\u4E0A\u4F20\u5230 Hub\uFF0C\u6B63\u5982\u6211\u4EEC\u5728 "),X=o(Fe,"A",{href:!0});var xs=i(X);Q=l(xs,"\u7B2C 2 \u8282"),xs.forEach(s),_e=l(Fe," \u4E2D\u770B\u5230\u7684\uFF0C\u7136\u540E\u6211\u4EEC\u53EA\u9700\u62DF\u5408\u6A21\u578B\u65F6\u6DFB\u52A0\u8BE5\u56DE\u8C03\u51FD\u6570\uFF1A"),Fe.forEach(s),V=u(h),w(W.$$.fragment,h),ne=u(h),Y=o(h,"P",{});var re=i(Y);Se=l(re,"\u8BF7\u6CE8\u610F\uFF0C\u60A8\u53EF\u4EE5\u4F7F\u7528 "),Te=o(re,"CODE",{});var Pe=i(Te);me=l(Pe,"hub_model_id"),Pe.forEach(s),Z=l(re," \u53C2\u6570\u6307\u5B9A\u8981\u63A8\u9001\u5230\u7684\u5B58\u50A8\u5E93\u7684\u540D\u79F0\uFF08\u5F53\u60A8\u60F3\u628A\u6A21\u578B\u63A8\u9001\u5230\u6307\u5B9A\u7684\u7EC4\u7EC7\u7684\u65F6\u5019\uFF0C\u60A8\u4E5F\u5FC5\u987B\u4F7F\u7528\u6B64\u53C2\u6570\uFF09\u3002 \u4F8B\u5982\uFF0C\u5F53\u6211\u4EEC\u5C06\u6A21\u578B\u63A8\u9001\u5230 "),ee=o(re,"A",{href:!0,rel:!0});var Ke=i(ee);G=o(Ke,"CODE",{});var Xe=i(G);se=l(Xe,"huggingface-course"),Xe.forEach(s),de=l(Ke," \u7EC4\u7EC7"),Ke.forEach(s),$e=l(re," \u65F6\uFF0C\u6211\u4EEC\u6DFB\u52A0\u4E86 "),pe=o(re,"CODE",{});var fs=i(pe);oe=l(fs,'hub_model_id="huggingface-course/marian-finetuned-kde4-en- to-fr"'),fs.forEach(s),te=l(re," \u5230 "),De=o(re,"CODE",{});var ze=i(De);be=l(ze,"Seq2SeqTrainingArguments"),ze.forEach(s),Ne=l(re,"\u3002 \u9ED8\u8BA4\u60C5\u51B5\u4E0B\uFF0C\u4F7F\u7528\u7684\u5B58\u50A8\u5E93\u5C06\u5728\u60A8\u7684\u547D\u540D\u7A7A\u95F4\u4E2D\uFF0C\u5E76\u4EE5\u60A8\u8BBE\u7F6E\u7684\u8F93\u51FA\u76EE\u5F55\u547D\u540D\uFF0C\u56E0\u6B64\u8FD9\u91CC\u5C06\u662F "),ge=o(re,"CODE",{});var cs=i(ge);ie=l(cs,'"sgugger/marian-finetuned-kde4-en-to-fr"'),cs.forEach(s),fe=l(re,"\u3002"),re.forEach(s),os=u(h),w(ce.$$.fragment,h),is=u(h),Be=o(h,"P",{});var we=i(Be);Re=l(we,"\u6700\u540E\uFF0C\u8BA9\u6211\u4EEC\u770B\u770B\u8BAD\u7EC3\u7ED3\u675F\u540E\u6211\u4EEC\u7684\u6307\u6807\u662F\u4EC0\u4E48\u6837\u7684\uFF1A"),we.forEach(s),ve=u(h),w(Ae.$$.fragment,h),ke=u(h),w(ae.$$.fragment,h),Qe=u(h),Oe=o(h,"P",{});var Ge=i(Oe);le=l(Ge,"\u5728\u8FD9\u4E2A\u9636\u6BB5\uFF0C\u60A8\u53EF\u4EE5\u4F7F\u7528\u6A21\u578B\u4E2D\u5FC3\u4E0A\u7684\u63A8\u7406\u5C0F\u90E8\u4EF6\u6765\u6D4B\u8BD5\u60A8\u7684\u6A21\u578B\u5E76\u4E0E\u60A8\u7684\u670B\u53CB\u5206\u4EAB\u3002 \u60A8\u5DF2\u7ECF\u6210\u529F\u5730\u5FAE\u8C03\u4E86\u7FFB\u8BD1\u4EFB\u52A1\u4E2D\u7684\u6A21\u578B\u2014\u2014\u606D\u559C\uFF01"),Ge.forEach(s),this.h()},h(){j(X,"href","(/course/chapter7/2)"),j(ee,"href","https://huggingface.co/huggingface-course"),j(ee,"rel","nofollow")},m(h,M){r(h,f,M),t(f,$),r(h,d,M),E(b,h,M),r(h,L,M),E(T,h,M),r(h,C,M),r(h,D,M),t(D,y),t(D,A),t(A,N),t(D,x),r(h,P,M),E(H,h,M),r(h,U,M),r(h,F,M),t(F,J),t(F,K),t(K,R),t(F,I),t(F,X),t(X,Q),t(F,_e),r(h,V,M),E(W,h,M),r(h,ne,M),r(h,Y,M),t(Y,Se),t(Y,Te),t(Te,me),t(Y,Z),t(Y,ee),t(ee,G),t(G,se),t(ee,de),t(Y,$e),t(Y,pe),t(pe,oe),t(Y,te),t(Y,De),t(De,be),t(Y,Ne),t(Y,ge),t(ge,ie),t(Y,fe),r(h,os,M),E(ce,h,M),r(h,is,M),r(h,Be,M),t(Be,Re),r(h,ve,M),E(Ae,h,M),r(h,ke,M),E(ae,h,M),r(h,Qe,M),r(h,Oe,M),t(Oe,le),es=!0},i(h){es||(g(b.$$.fragment,h),g(T.$$.fragment,h),g(H.$$.fragment,h),g(W.$$.fragment,h),g(ce.$$.fragment,h),g(Ae.$$.fragment,h),g(ae.$$.fragment,h),es=!0)},o(h){k(b.$$.fragment,h),k(T.$$.fragment,h),k(H.$$.fragment,h),k(W.$$.fragment,h),k(ce.$$.fragment,h),k(Ae.$$.fragment,h),k(ae.$$.fragment,h),es=!1},d(h){h&&s(f),h&&s(d),q(b,h),h&&s(L),q(T,h),h&&s(C),h&&s(D),h&&s(P),q(H,h),h&&s(U),h&&s(F),h&&s(V),q(W,h),h&&s(ne),h&&s(Y),h&&s(os),q(ce,h),h&&s(is),h&&s(Be),h&&s(ve),q(Ae,h),h&&s(ke),q(ae,h),h&&s(Qe),h&&s(Oe)}}}function ac(B){let f,$;return{c(){f=p("p"),$=a("\u{1F4A1}\u5982\u679C\u60A8\u4F7F\u7528\u7684\u8F93\u51FA\u76EE\u5F55\u5DF2\u7ECF\u5B58\u5728\uFF0C\u5219\u5B83\u9700\u8981\u662F\u60A8\u8981\u63A8\u9001\u5230\u7684\u5B58\u50A8\u5E93\u7684\u672C\u5730\u514B\u9686\u3002\u5982\u679C\u4E0D\u662F\uFF0C\u60A8\u5C06\u5728\u5B9A\u4E49\u60A8\u7684\u540D\u79F0\u65F6\u4F1A\u9047\u5230\u9519\u8BEF\uFF0C\u5E76\u4E14\u9700\u8981\u8BBE\u7F6E\u4E00\u4E2A\u65B0\u540D\u79F0\u3002")},l(d){f=o(d,"P",{});var b=i(f);$=l(b,"\u{1F4A1}\u5982\u679C\u60A8\u4F7F\u7528\u7684\u8F93\u51FA\u76EE\u5F55\u5DF2\u7ECF\u5B58\u5728\uFF0C\u5219\u5B83\u9700\u8981\u662F\u60A8\u8981\u63A8\u9001\u5230\u7684\u5B58\u50A8\u5E93\u7684\u672C\u5730\u514B\u9686\u3002\u5982\u679C\u4E0D\u662F\uFF0C\u60A8\u5C06\u5728\u5B9A\u4E49\u60A8\u7684\u540D\u79F0\u65F6\u4F1A\u9047\u5230\u9519\u8BEF\uFF0C\u5E76\u4E14\u9700\u8981\u8BBE\u7F6E\u4E00\u4E2A\u65B0\u540D\u79F0\u3002"),b.forEach(s)},m(d,b){r(d,f,b),t(f,$)},d(d){d&&s(f)}}}function lc(B){let f,$;return{c(){f=p("p"),$=a("\u{1F4A1}\u5982\u679C\u60A8\u4F7F\u7528\u7684\u8F93\u51FA\u76EE\u5F55\u5DF2\u7ECF\u5B58\u5728\uFF0C\u5219\u5B83\u9700\u8981\u662F\u60A8\u8981\u63A8\u9001\u5230\u7684\u5B58\u50A8\u5E93\u7684\u672C\u5730\u514B\u9686\u3002\u5982\u679C\u4E0D\u662F\uFF0C\u60A8\u5C06\u5728\u5B9A\u4E49\u60A8\u7684\u540D\u79F0\u65F6\u4F1A\u9047\u5230\u9519\u8BEF\uFF0C\u5E76\u4E14\u9700\u8981\u8BBE\u7F6E\u4E00\u4E2A\u65B0\u540D\u79F0\u3002")},l(d){f=o(d,"P",{});var b=i(f);$=l(b,"\u{1F4A1}\u5982\u679C\u60A8\u4F7F\u7528\u7684\u8F93\u51FA\u76EE\u5F55\u5DF2\u7ECF\u5B58\u5728\uFF0C\u5219\u5B83\u9700\u8981\u662F\u60A8\u8981\u63A8\u9001\u5230\u7684\u5B58\u50A8\u5E93\u7684\u672C\u5730\u514B\u9686\u3002\u5982\u679C\u4E0D\u662F\uFF0C\u60A8\u5C06\u5728\u5B9A\u4E49\u60A8\u7684\u540D\u79F0\u65F6\u4F1A\u9047\u5230\u9519\u8BEF\uFF0C\u5E76\u4E14\u9700\u8981\u8BBE\u7F6E\u4E00\u4E2A\u65B0\u540D\u79F0\u3002"),b.forEach(s)},m(d,b){r(d,f,b),t(f,$)},d(d){d&&s(f)}}}function Df(B){let f,$,d,b,L,T,C,D,y,A,N,x,P,H,U,F,J,K,R,I,X,Q,_e,V,W,ne,Y,Se,Te,me,Z,ee,G,se,de,$e,pe,oe,te,De,be,Ne,ge,ie,fe,os,ce,is,Be,Re,ve,Ae,ke,ae,Qe,Oe,le,es,h,M,he,Fs,Fe,je,xs,re,Pe,Ke,Xe,fs,ze,cs,we,Ge,us,Ee,Xs,Ce,hs,We,ys,ss,Ws,Ye,Ts,Ps,Ys,He,ue,Gs,Ze,Je,Hs,$s,Zs,ms,Ss,ts,Js,bs,_s,as,qe,ls,rs,gs,Vs,ns,Qs,ps,_,z,Us,et,ft,zs,Ue,Ds,ct,Le,Ie,xe,Is,ut,st,tt,Pt,at,As,St,mt,ks,js,vs,ws,Ve,ye,lt,rt,zt,nt,pt,ma,Vt,Es,Qt,Dt,ea;return W=new S({props:{code:`from torch.utils.data import DataLoader

tokenized_datasets.set_format("torch")
train_dataloader = DataLoader(
    tokenized_datasets["train"],
    shuffle=True,
    collate_fn=data_collator,
    batch_size=8,
)
eval_dataloader = DataLoader(
    tokenized_datasets["validation"], collate_fn=data_collator, batch_size=8
)`,highlighted:`<span class="hljs-keyword">from</span> torch.utils.data <span class="hljs-keyword">import</span> DataLoader

tokenized_datasets.set_format(<span class="hljs-string">&quot;torch&quot;</span>)
train_dataloader = DataLoader(
    tokenized_datasets[<span class="hljs-string">&quot;train&quot;</span>],
    shuffle=<span class="hljs-literal">True</span>,
    collate_fn=data_collator,
    batch_size=<span class="hljs-number">8</span>,
)
eval_dataloader = DataLoader(
    tokenized_datasets[<span class="hljs-string">&quot;validation&quot;</span>], collate_fn=data_collator, batch_size=<span class="hljs-number">8</span>
)`}}),me=new S({props:{code:"model = AutoModelForSeq2SeqLM.from_pretrained(model_checkpoint)",highlighted:"model = AutoModelForSeq2SeqLM.from_pretrained(model_checkpoint)"}}),de=new S({props:{code:`from transformers import AdamW

optimizer = AdamW(model.parameters(), lr=2e-5)`,highlighted:`<span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AdamW

optimizer = AdamW(model.parameters(), lr=<span class="hljs-number">2e-5</span>)`}}),ge=new S({props:{code:`from accelerate import Accelerator

accelerator = Accelerator()
model, optimizer, train_dataloader, eval_dataloader = accelerator.prepare(
    model, optimizer, train_dataloader, eval_dataloader
)`,highlighted:`<span class="hljs-keyword">from</span> accelerate <span class="hljs-keyword">import</span> Accelerator

accelerator = Accelerator()
model, optimizer, train_dataloader, eval_dataloader = accelerator.prepare(
    model, optimizer, train_dataloader, eval_dataloader
)`}}),le=new S({props:{code:`from transformers import get_scheduler

num_train_epochs = 3
num_update_steps_per_epoch = len(train_dataloader)
num_training_steps = num_train_epochs * num_update_steps_per_epoch

lr_scheduler = get_scheduler(
    "linear",
    optimizer=optimizer,
    num_warmup_steps=0,
    num_training_steps=num_training_steps,
)`,highlighted:`<span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> get_scheduler

num_train_epochs = <span class="hljs-number">3</span>
num_update_steps_per_epoch = <span class="hljs-built_in">len</span>(train_dataloader)
num_training_steps = num_train_epochs * num_update_steps_per_epoch

lr_scheduler = get_scheduler(
    <span class="hljs-string">&quot;linear&quot;</span>,
    optimizer=optimizer,
    num_warmup_steps=<span class="hljs-number">0</span>,
    num_training_steps=num_training_steps,
)`}}),ze=new S({props:{code:`from huggingface_hub import Repository, get_full_repo_name

model_name = "marian-finetuned-kde4-en-to-fr-accelerate"
repo_name = get_full_repo_name(model_name)
repo_name`,highlighted:`<span class="hljs-keyword">from</span> huggingface_hub <span class="hljs-keyword">import</span> Repository, get_full_repo_name

model_name = <span class="hljs-string">&quot;marian-finetuned-kde4-en-to-fr-accelerate&quot;</span>
repo_name = get_full_repo_name(model_name)
repo_name`}}),we=new S({props:{code:"'sgugger/marian-finetuned-kde4-en-to-fr-accelerate'",highlighted:'<span class="hljs-string">&#x27;sgugger/marian-finetuned-kde4-en-to-fr-accelerate&#x27;</span>'}}),Ce=new S({props:{code:`output_dir = "marian-finetuned-kde4-en-to-fr-accelerate"
repo = Repository(output_dir, clone_from=repo_name)`,highlighted:`output_dir = <span class="hljs-string">&quot;marian-finetuned-kde4-en-to-fr-accelerate&quot;</span>
repo = Repository(output_dir, clone_from=repo_name)`}}),_s=new S({props:{code:`def postprocess(predictions, labels):
    predictions = predictions.cpu().numpy()
    labels = labels.cpu().numpy()

    decoded_preds = tokenizer.batch_decode(predictions, skip_special_tokens=True)

    # Replace -100 in the labels as we can't decode them.
    labels = np.where(labels != -100, labels, tokenizer.pad_token_id)
    decoded_labels = tokenizer.batch_decode(labels, skip_special_tokens=True)

    # Some simple post-processing
    decoded_preds = [pred.strip() for pred in decoded_preds]
    decoded_labels = [[label.strip()] for label in decoded_labels]
    return decoded_preds, decoded_labels`,highlighted:`<span class="hljs-keyword">def</span> <span class="hljs-title function_">postprocess</span>(<span class="hljs-params">predictions, labels</span>):
    predictions = predictions.cpu().numpy()
    labels = labels.cpu().numpy()

    decoded_preds = tokenizer.batch_decode(predictions, skip_special_tokens=<span class="hljs-literal">True</span>)

    <span class="hljs-comment"># Replace -100 in the labels as we can&#x27;t decode them.</span>
    labels = np.where(labels != -<span class="hljs-number">100</span>, labels, tokenizer.pad_token_id)
    decoded_labels = tokenizer.batch_decode(labels, skip_special_tokens=<span class="hljs-literal">True</span>)

    <span class="hljs-comment"># Some simple post-processing</span>
    decoded_preds = [pred.strip() <span class="hljs-keyword">for</span> pred <span class="hljs-keyword">in</span> decoded_preds]
    decoded_labels = [[label.strip()] <span class="hljs-keyword">for</span> label <span class="hljs-keyword">in</span> decoded_labels]
    <span class="hljs-keyword">return</span> decoded_preds, decoded_labels`}}),js=new S({props:{code:`from tqdm.auto import tqdm
import torch

progress_bar = tqdm(range(num_training_steps))

for epoch in range(num_train_epochs):
    # Training
    model.train()
    for batch in train_dataloader:
        outputs = model(**batch)
        loss = outputs.loss
        accelerator.backward(loss)

        optimizer.step()
        lr_scheduler.step()
        optimizer.zero_grad()
        progress_bar.update(1)

    # Evaluation
    model.eval()
    for batch in tqdm(eval_dataloader):
        with torch.no_grad():
            generated_tokens = accelerator.unwrap_model(model).generate(
                batch["input_ids"],
                attention_mask=batch["attention_mask"],
                max_length=128,
            )
        labels = batch["labels"]

        # Necessary to pad predictions and labels for being gathered
        generated_tokens = accelerator.pad_across_processes(
            generated_tokens, dim=1, pad_index=tokenizer.pad_token_id
        )
        labels = accelerator.pad_across_processes(labels, dim=1, pad_index=-100)

        predictions_gathered = accelerator.gather(generated_tokens)
        labels_gathered = accelerator.gather(labels)

        decoded_preds, decoded_labels = postprocess(predictions_gathered, labels_gathered)
        metric.add_batch(predictions=decoded_preds, references=decoded_labels)

    results = metric.compute()
    print(f"epoch {epoch}, BLEU score: {results['score']:.2f}")

    # Save and upload
    accelerator.wait_for_everyone()
    unwrapped_model = accelerator.unwrap_model(model)
    unwrapped_model.save_pretrained(output_dir, save_function=accelerator.save)
    if accelerator.is_main_process:
        tokenizer.save_pretrained(output_dir)
        repo.push_to_hub(
            commit_message=f"Training in progress epoch {epoch}", blocking=False
        )`,highlighted:`<span class="hljs-keyword">from</span> tqdm.auto <span class="hljs-keyword">import</span> tqdm
<span class="hljs-keyword">import</span> torch

progress_bar = tqdm(<span class="hljs-built_in">range</span>(num_training_steps))

<span class="hljs-keyword">for</span> epoch <span class="hljs-keyword">in</span> <span class="hljs-built_in">range</span>(num_train_epochs):
    <span class="hljs-comment"># Training</span>
    model.train()
    <span class="hljs-keyword">for</span> batch <span class="hljs-keyword">in</span> train_dataloader:
        outputs = model(**batch)
        loss = outputs.loss
        accelerator.backward(loss)

        optimizer.step()
        lr_scheduler.step()
        optimizer.zero_grad()
        progress_bar.update(<span class="hljs-number">1</span>)

    <span class="hljs-comment"># Evaluation</span>
    model.<span class="hljs-built_in">eval</span>()
    <span class="hljs-keyword">for</span> batch <span class="hljs-keyword">in</span> tqdm(eval_dataloader):
        <span class="hljs-keyword">with</span> torch.no_grad():
            generated_tokens = accelerator.unwrap_model(model).generate(
                batch[<span class="hljs-string">&quot;input_ids&quot;</span>],
                attention_mask=batch[<span class="hljs-string">&quot;attention_mask&quot;</span>],
                max_length=<span class="hljs-number">128</span>,
            )
        labels = batch[<span class="hljs-string">&quot;labels&quot;</span>]

        <span class="hljs-comment"># Necessary to pad predictions and labels for being gathered</span>
        generated_tokens = accelerator.pad_across_processes(
            generated_tokens, dim=<span class="hljs-number">1</span>, pad_index=tokenizer.pad_token_id
        )
        labels = accelerator.pad_across_processes(labels, dim=<span class="hljs-number">1</span>, pad_index=-<span class="hljs-number">100</span>)

        predictions_gathered = accelerator.gather(generated_tokens)
        labels_gathered = accelerator.gather(labels)

        decoded_preds, decoded_labels = postprocess(predictions_gathered, labels_gathered)
        metric.add_batch(predictions=decoded_preds, references=decoded_labels)

    results = metric.compute()
    <span class="hljs-built_in">print</span>(<span class="hljs-string">f&quot;epoch <span class="hljs-subst">{epoch}</span>, BLEU score: <span class="hljs-subst">{results[<span class="hljs-string">&#x27;score&#x27;</span>]:<span class="hljs-number">.2</span>f}</span>&quot;</span>)

    <span class="hljs-comment"># Save and upload</span>
    accelerator.wait_for_everyone()
    unwrapped_model = accelerator.unwrap_model(model)
    unwrapped_model.save_pretrained(output_dir, save_function=accelerator.save)
    <span class="hljs-keyword">if</span> accelerator.is_main_process:
        tokenizer.save_pretrained(output_dir)
        repo.push_to_hub(
            commit_message=<span class="hljs-string">f&quot;Training in progress epoch <span class="hljs-subst">{epoch}</span>&quot;</span>, blocking=<span class="hljs-literal">False</span>
        )`}}),ws=new S({props:{code:`epoch 0, BLEU score: 53.47
epoch 1, BLEU score: 54.24
epoch 2, BLEU score: 54.44`,highlighted:`epoch <span class="hljs-number">0</span>, BLEU score: <span class="hljs-number">53.47</span>
epoch <span class="hljs-number">1</span>, BLEU score: <span class="hljs-number">54.24</span>
epoch <span class="hljs-number">2</span>, BLEU score: <span class="hljs-number">54.44</span>`}}),{c(){f=p("h2"),$=a("\u81EA\u5B9A\u4E49\u8BAD\u7EC3\u5FAA\u73AF"),d=c(),b=p("p"),L=a("\u73B0\u5728\u8BA9\u6211\u4EEC\u770B\u4E00\u4E0B\u5B8C\u6574\u7684\u8BAD\u7EC3\u5FAA\u73AF\uFF0C\u4EE5\u4FBF\u60A8\u53EF\u4EE5\u8F7B\u677E\u81EA\u5B9A\u4E49\u6240\u9700\u7684\u90E8\u5206\u3002\u5B83\u770B\u8D77\u6765\u5F88\u50CF\u6211\u4EEC\u5728"),T=p("a"),C=a("\u672C\u7AE0\u7B2C\u4E8C\u8282"),D=a("\u548C"),y=p("a"),A=a("\u7B2C\u4E09\u7AE0\u7B2C\u56DB\u5C0F\u8282"),N=a("\u6240\u505A\u7684\u3002"),x=c(),P=p("h3"),H=a("\u51C6\u5907\u8BAD\u7EC3\u6240\u9700\u7684\u4E00\u5207"),U=c(),F=p("p"),J=a("\u60A8\u5DF2\u7ECF\u591A\u6B21\u770B\u5230\u6240\u6709\u8FD9\u4E9B\uFF0C\u56E0\u6B64\u8FD9\u4E00\u5757\u4F1A\u7B80\u7565\u8FDB\u884C\u3002\u9996\u5148\u6211\u4EEC\u5C06\u6784\u5EFA\u6211\u4EEC\u7684\u6570\u636E\u96C6\u7684"),K=p("strong"),R=a("DataLoader"),I=a(" \uFF0C\u5728\u5C06\u6570\u636E\u96C6\u8BBE\u7F6E\u4E3A "),X=p("strong"),Q=a("torch"),_e=a(" \u683C\u5F0F\uFF0C\u6211\u4EEC\u5C31\u5F97\u5230\u4E86 PyTorch \u5F20\u91CF\uFF1A"),V=c(),v(W.$$.fragment),ne=c(),Y=p("p"),Se=a("\u63A5\u4E0B\u6765\u6211\u4EEC\u91CD\u65B0\u5B9E\u4F8B\u5316\u6211\u4EEC\u7684\u6A21\u578B\uFF0C\u4EE5\u786E\u4FDD\u6211\u4EEC\u4E0D\u4F1A\u7EE7\u7EED\u4E0A\u4E00\u8282\u7684\u5FAE\u8C03\uFF0C\u800C\u662F\u518D\u6B21\u4ECE\u9884\u8BAD\u7EC3\u6A21\u578B\u5F00\u59CB\u91CD\u65B0\u8BAD\u7EC3\uFF1A"),Te=c(),v(me.$$.fragment),Z=c(),ee=p("p"),G=a("\u7136\u540E\u6211\u4EEC\u9700\u8981\u4E00\u4E2A\u4F18\u5316\u5668\uFF1A"),se=c(),v(de.$$.fragment),$e=c(),pe=p("p"),oe=a("\u4E00\u65E6\u6211\u4EEC\u62E5\u6709\u6240\u6709\u8FD9\u4E9B\u5BF9\u8C61\uFF0C\u6211\u4EEC\u5C31\u53EF\u4EE5\u5C06\u5B83\u4EEC\u53D1\u9001\u5230 "),te=p("code"),De=a("accelerator.prepare()"),be=a(" \u65B9\u6CD5\u3002 \u8BF7\u8BB0\u4F4F\uFF0C\u5982\u679C\u60A8\u60F3\u5728 Colab \u7B14\u8BB0\u672C\u8BAD\u7EC3\u4E2D\u4F7F\u7528TPU\uFF0C\u5219\u9700\u8981\u5C06\u6240\u6709\u8FD9\u4E9B\u4EE3\u7801\u79FB\u52A8\u5230\u8BAD\u7EC3\u51FD\u6570\u4E2D\uFF0C\u5E76\u4E14\u4E0D\u5E94\u6267\u884C\u4EFB\u4F55\u5B9E\u4F8B\u5316\u201C\u52A0\u901F\u5668\u201D\u7684\u5BF9\u8C61\u3002"),Ne=c(),v(ge.$$.fragment),ie=c(),fe=p("p"),os=a("\u73B0\u5728\u6211\u4EEC\u5DF2\u7ECF\u53D1\u9001\u4E86\u6211\u4EEC\u7684 "),ce=p("strong"),is=a("train_dataloader"),Be=a(" \u5230 "),Re=p("strong"),ve=a("accelerator.prepare()"),Ae=a(" \uFF0C\u6211\u4EEC\u53EF\u4EE5\u4F7F\u7528\u5B83\u7684\u957F\u5EA6\u6765\u8BA1\u7B97\u8BAD\u7EC3\u6B65\u9AA4\u7684\u6570\u91CF\u3002\u8BF7\u8BB0\u4F4F\uFF0C\u6211\u4EEC\u5E94\u8BE5\u59CB\u7EC8\u5728\u51C6\u5907\u597D\u6570\u636E\u52A0\u8F7D\u5668\u540E\u6267\u884C\u6B64\u64CD\u4F5C\uFF0C\u56E0\u4E3A\u8BE5\u65B9\u6CD5\u4F1A\u66F4\u6539 "),ke=p("strong"),ae=a("DataLoader"),Qe=a(" .\u6211\u4EEC\u4F7F\u7528\u4ECE\u5B66\u4E60\u7387\u8870\u51CF\u5230 0 \u7684\u7ECF\u5178\u7EBF\u6027\u5B66\u4E60\u7387\u8C03\u5EA6\uFF1A"),Oe=c(),v(le.$$.fragment),es=c(),h=p("p"),M=a("\u6700\u540E\uFF0C\u8981\u5C06\u6211\u4EEC\u7684\u6A21\u578B\u63A8\u9001\u5230 Hub\uFF0C\u6211\u4EEC\u9700\u8981\u521B\u5EFA\u4E00\u4E2A "),he=p("strong"),Fs=a("Repository"),Fe=a(" \u5DE5\u4F5C\u6587\u4EF6\u5939\u4E2D\u7684\u5BF9\u8C61\u3002\u5982\u679C\u60A8\u5C1A\u672A\u767B\u5F55\uFF0C\u8BF7\u5148\u767B\u5F55 Hugging Face\u3002\u6211\u4EEC\u5C06\u4ECE\u6211\u4EEC\u60F3\u8981\u4E3A\u6A21\u578B\u63D0\u4F9B\u7684\u6A21\u578B ID \u4E2D\u786E\u5B9A\u5B58\u50A8\u5E93\u540D\u79F0\uFF08\u60A8\u53EF\u4EE5\u81EA\u7531\u5730\u7528\u81EA\u5DF1\u7684\u9009\u62E9\u66FF\u6362 "),je=p("strong"),xs=a("repo_name"),re=a(" \uFF1B\u5B83\u9700\u8981\u5305\u542B\u60A8\u7684\u7528\u6237\u540D\uFF0C\u53EF\u4EE5\u4F7F\u7528"),Pe=p("strong"),Ke=a("get_full_repo_name()"),Xe=a("\u51FD\u6570\u7684\u67E5\u770B\u76EE\u524D\u7684repo_name\uFF09\uFF1A"),fs=c(),v(ze.$$.fragment),cs=c(),v(we.$$.fragment),Ge=c(),us=p("p"),Ee=a("\u7136\u540E\u6211\u4EEC\u53EF\u4EE5\u5728\u672C\u5730\u6587\u4EF6\u5939\u4E2D\u514B\u9686\u8BE5\u5B58\u50A8\u5E93\u3002\u5982\u679C\u5B83\u5DF2\u7ECF\u5B58\u5728\uFF0C\u8FD9\u4E2A\u672C\u5730\u6587\u4EF6\u5939\u5E94\u8BE5\u662F\u6211\u4EEC\u6B63\u5728\u4F7F\u7528\u7684\u5B58\u50A8\u5E93\u7684\u514B\u9686\uFF1A"),Xs=c(),v(Ce.$$.fragment),hs=c(),We=p("p"),ys=a("\u6211\u4EEC\u73B0\u5728\u53EF\u4EE5\u901A\u8FC7\u8C03\u7528 "),ss=p("strong"),Ws=a("repo.push_to_hub()"),Ye=a(" \u65B9\u6CD5\u4E0A\u4F20\u6211\u4EEC\u4FDD\u5B58\u7684\u4EFB\u4F55\u5185\u5BB9 "),Ts=p("strong"),Ps=a("output_dir"),Ys=a(" \u3002\u8FD9\u5C06\u5E2E\u52A9\u6211\u4EEC\u5728\u6BCF\u4E2A epoch \u7ED3\u675F\u65F6\u4E0A\u4F20\u8FC7\u7A0B\u4E2D\u7684\u6A21\u578B\u3002"),He=c(),ue=p("h3"),Gs=a("\u8BAD\u7EC3\u5FAA\u73AF"),Ze=c(),Je=p("p"),Hs=a("\u6211\u4EEC\u73B0\u5728\u51C6\u5907\u7F16\u5199\u5B8C\u6574\u7684\u8BAD\u7EC3\u5FAA\u73AF\u3002\u4E3A\u4E86\u7B80\u5316\u5B83\u7684\u8BC4\u4F30\u90E8\u5206\uFF0C\u6211\u4EEC\u5B9A\u4E49\u4E86\u8FD9\u4E2A "),$s=p("strong"),Zs=a("postprocess()"),ms=a(" \u51FD\u6570\u63A5\u6536\u9884\u6D4B\u7ED3\u679C\u548C\u6B63\u786E\u6807\u7B7E\u5E76\u5C06\u5B83\u4EEC\u8F6C\u6362\u4E3A\u6211\u4EEC "),Ss=p("strong"),ts=a("metric"),Js=a(" \u5BF9\u8C61\u6240\u9700\u8981\u7684\u5B57\u7B26\u4E32\u5217\u8868\uFF1A"),bs=c(),v(_s.$$.fragment),as=c(),qe=p("p"),ls=a("\u8BAD\u7EC3\u5FAA\u73AF\u770B\u8D77\u6765\u548C"),rs=p("a"),gs=a("\u672C\u7AE0\u7B2C\u4E8C\u8282"),Vs=a("\u4E0E"),ns=p("a"),Qs=a("\u7B2C\u4E09\u7AE0"),ps=a("\u5F88\u50CF\uFF0C\u5728\u8BC4\u4F30\u90E8\u5206\u6709\u4E00\u4E9B\u4E0D\u540C - \u6240\u4EE5\u8BA9\u6211\u4EEC\u4E13\u6CE8\u4E8E\u8FD9\u4E00\u70B9\uFF01"),_=c(),z=p("p"),Us=a("\u9996\u5148\u8981\u6CE8\u610F\u7684\u662F\u6211\u4EEC\u4F7F\u7528 "),et=p("code"),ft=a("generate()"),zs=a(" \u65B9\u6CD5\u6765\u8BA1\u7B97\u9884\u6D4B\uFF0C\u4F46\u8FD9\u662F\u6211\u4EEC\u57FA\u7840\u6A21\u578B\u4E0A\u7684\u4E00\u4E2A\u65B9\u6CD5\uFF0C\u800C\u4E0D\u662F\u5305\u88C5\u6A21\u578B\u{1F917} Accelerate \u5728 "),Ue=p("code"),Ds=a("prepare()"),ct=a(" \u65B9\u6CD5\u4E2D\u521B\u5EFA\u3002 \u8FD9\u5C31\u662F\u4E3A\u4EC0\u4E48\u6211\u4EEC\u5148\u89E3\u5305\u6A21\u578B\uFF0C\u7136\u540E\u8C03\u7528\u8FD9\u4E2A\u65B9\u6CD5\u3002"),Le=c(),Ie=p("p"),xe=a("\u7B2C\u4E8C\u4EF6\u4E8B\u662F\uFF0C\u5C31\u50CF"),Is=p("a"),ut=a("token \u5206\u7C7B"),st=a("\uFF0C\u4E24\u4E2A\u8FDB\u7A0B\u53EF\u80FD\u5C06\u8F93\u5165\u548C\u6807\u7B7E\u586B\u5145\u4E3A\u4E0D\u540C\u7684\u5F62\u72B6\uFF0C\u56E0\u6B64\u6211\u4EEC\u5728\u8C03\u7528 "),tt=p("strong"),Pt=a("gather()"),at=a(" \u65B9\u6CD5\u4E4B\u524D\u4F7F\u7528 "),As=p("strong"),St=a("accelerator.pad_across_processes()"),mt=a(" \u4F7F\u9884\u6D4B\u548C\u6807\u7B7E\u5177\u6709\u76F8\u540C\u7684\u5F62\u72B6\u3002\u5982\u679C\u6211\u4EEC\u4E0D\u8FD9\u6837\u505A\uFF0C\u8BC4\u4F30\u8981\u4E48\u51FA\u9519\uFF0C\u8981\u4E48\u6C38\u8FDC\u5728\u963B\u585E\u3002"),ks=c(),v(js.$$.fragment),vs=c(),v(ws.$$.fragment),Ve=c(),ye=p("p"),lt=a("\u5B8C\u6210\u6B64\u64CD\u4F5C\u540E\uFF0C\u60A8\u5E94\u8BE5\u6709\u4E00\u4E2A\u6A21\u578B\uFF0C\u5176\u7ED3\u679C\u4E0E\u4F7F\u7528 "),rt=p("code"),zt=a("Seq2SeqTrainer"),nt=a(" \u8BAD\u7EC3\u7684\u6A21\u578B\u975E\u5E38\u76F8\u4F3C\u3002 \u60A8\u53EF\u4EE5\u5728 ["),pt=p("em"),ma=a("huggingface-course/marian-finetuned-kde4-en-to-fr-accelerate"),Vt=a("]("),Es=p("a"),Qt=a("https://huggingface.co/huggingface-course/marian-finetuned-kde4-en-to-fr-accelerate\uFF09\u67E5\u770B\u8BAD\u7EC3\u5B8C\u7684\u7ED3\u679C\u3002"),Dt=a(" \u5982\u679C\u60A8\u60F3\u6D4B\u8BD5\u5BF9\u8BAD\u7EC3\u5FAA\u73AF\u7684\u4EFB\u4F55\u8C03\u6574\uFF0C\u60A8\u53EF\u4EE5\u901A\u8FC7\u7F16\u8F91\u4E0A\u9762\u663E\u793A\u7684\u4EE3\u7801\u76F4\u63A5\u5B9E\u73B0\u5B83\u4EEC\uFF01"),this.h()},l(m){f=o(m,"H2",{id:!0});var O=i(f);$=l(O,"\u81EA\u5B9A\u4E49\u8BAD\u7EC3\u5FAA\u73AF"),O.forEach(s),d=u(m),b=o(m,"P",{});var _t=i(b);L=l(_t,"\u73B0\u5728\u8BA9\u6211\u4EEC\u770B\u4E00\u4E0B\u5B8C\u6574\u7684\u8BAD\u7EC3\u5FAA\u73AF\uFF0C\u4EE5\u4FBF\u60A8\u53EF\u4EE5\u8F7B\u677E\u81EA\u5B9A\u4E49\u6240\u9700\u7684\u90E8\u5206\u3002\u5B83\u770B\u8D77\u6765\u5F88\u50CF\u6211\u4EEC\u5728"),T=o(_t,"A",{href:!0});var At=i(T);C=l(At,"\u672C\u7AE0\u7B2C\u4E8C\u8282"),At.forEach(s),D=l(_t,"\u548C"),y=o(_t,"A",{href:!0});var _a=i(y);A=l(_a,"\u7B2C\u4E09\u7AE0\u7B2C\u56DB\u5C0F\u8282"),_a.forEach(s),N=l(_t,"\u6240\u505A\u7684\u3002"),_t.forEach(s),x=u(m),P=o(m,"H3",{id:!0});var Wt=i(P);H=l(Wt,"\u51C6\u5907\u8BAD\u7EC3\u6240\u9700\u7684\u4E00\u5207"),Wt.forEach(s),U=u(m),F=o(m,"P",{});var Ot=i(F);J=l(Ot,"\u60A8\u5DF2\u7ECF\u591A\u6B21\u770B\u5230\u6240\u6709\u8FD9\u4E9B\uFF0C\u56E0\u6B64\u8FD9\u4E00\u5757\u4F1A\u7B80\u7565\u8FDB\u884C\u3002\u9996\u5148\u6211\u4EEC\u5C06\u6784\u5EFA\u6211\u4EEC\u7684\u6570\u636E\u96C6\u7684"),K=o(Ot,"STRONG",{});var da=i(K);R=l(da,"DataLoader"),da.forEach(s),I=l(Ot," \uFF0C\u5728\u5C06\u6570\u636E\u96C6\u8BBE\u7F6E\u4E3A "),X=o(Ot,"STRONG",{});var Ct=i(X);Q=l(Ct,"torch"),Ct.forEach(s),_e=l(Ot," \u683C\u5F0F\uFF0C\u6211\u4EEC\u5C31\u5F97\u5230\u4E86 PyTorch \u5F20\u91CF\uFF1A"),Ot.forEach(s),V=u(m),w(W.$$.fragment,m),ne=u(m),Y=o(m,"P",{});var ha=i(Y);Se=l(ha,"\u63A5\u4E0B\u6765\u6211\u4EEC\u91CD\u65B0\u5B9E\u4F8B\u5316\u6211\u4EEC\u7684\u6A21\u578B\uFF0C\u4EE5\u786E\u4FDD\u6211\u4EEC\u4E0D\u4F1A\u7EE7\u7EED\u4E0A\u4E00\u8282\u7684\u5FAE\u8C03\uFF0C\u800C\u662F\u518D\u6B21\u4ECE\u9884\u8BAD\u7EC3\u6A21\u578B\u5F00\u59CB\u91CD\u65B0\u8BAD\u7EC3\uFF1A"),ha.forEach(s),Te=u(m),w(me.$$.fragment,m),Z=u(m),ee=o(m,"P",{});var Lt=i(ee);G=l(Lt,"\u7136\u540E\u6211\u4EEC\u9700\u8981\u4E00\u4E2A\u4F18\u5316\u5668\uFF1A"),Lt.forEach(s),se=u(m),w(de.$$.fragment,m),$e=u(m),pe=o(m,"P",{});var Yt=i(pe);oe=l(Yt,"\u4E00\u65E6\u6211\u4EEC\u62E5\u6709\u6240\u6709\u8FD9\u4E9B\u5BF9\u8C61\uFF0C\u6211\u4EEC\u5C31\u53EF\u4EE5\u5C06\u5B83\u4EEC\u53D1\u9001\u5230 "),te=o(Yt,"CODE",{});var Zt=i(te);De=l(Zt,"accelerator.prepare()"),Zt.forEach(s),be=l(Yt," \u65B9\u6CD5\u3002 \u8BF7\u8BB0\u4F4F\uFF0C\u5982\u679C\u60A8\u60F3\u5728 Colab \u7B14\u8BB0\u672C\u8BAD\u7EC3\u4E2D\u4F7F\u7528TPU\uFF0C\u5219\u9700\u8981\u5C06\u6240\u6709\u8FD9\u4E9B\u4EE3\u7801\u79FB\u52A8\u5230\u8BAD\u7EC3\u51FD\u6570\u4E2D\uFF0C\u5E76\u4E14\u4E0D\u5E94\u6267\u884C\u4EFB\u4F55\u5B9E\u4F8B\u5316\u201C\u52A0\u901F\u5668\u201D\u7684\u5BF9\u8C61\u3002"),Yt.forEach(s),Ne=u(m),w(ge.$$.fragment,m),ie=u(m),fe=o(m,"P",{});var ot=i(fe);os=l(ot,"\u73B0\u5728\u6211\u4EEC\u5DF2\u7ECF\u53D1\u9001\u4E86\u6211\u4EEC\u7684 "),ce=o(ot,"STRONG",{});var $a=i(ce);is=l($a,"train_dataloader"),$a.forEach(s),Be=l(ot," \u5230 "),Re=o(ot,"STRONG",{});var Nt=i(Re);ve=l(Nt,"accelerator.prepare()"),Nt.forEach(s),Ae=l(ot," \uFF0C\u6211\u4EEC\u53EF\u4EE5\u4F7F\u7528\u5B83\u7684\u957F\u5EA6\u6765\u8BA1\u7B97\u8BAD\u7EC3\u6B65\u9AA4\u7684\u6570\u91CF\u3002\u8BF7\u8BB0\u4F4F\uFF0C\u6211\u4EEC\u5E94\u8BE5\u59CB\u7EC8\u5728\u51C6\u5907\u597D\u6570\u636E\u52A0\u8F7D\u5668\u540E\u6267\u884C\u6B64\u64CD\u4F5C\uFF0C\u56E0\u4E3A\u8BE5\u65B9\u6CD5\u4F1A\u66F4\u6539 "),ke=o(ot,"STRONG",{});var ba=i(ke);ae=l(ba,"DataLoader"),ba.forEach(s),Qe=l(ot," .\u6211\u4EEC\u4F7F\u7528\u4ECE\u5B66\u4E60\u7387\u8870\u51CF\u5230 0 \u7684\u7ECF\u5178\u7EBF\u6027\u5B66\u4E60\u7387\u8C03\u5EA6\uFF1A"),ot.forEach(s),Oe=u(m),w(le.$$.fragment,m),es=u(m),h=o(m,"P",{});var ds=i(h);M=l(ds,"\u6700\u540E\uFF0C\u8981\u5C06\u6211\u4EEC\u7684\u6A21\u578B\u63A8\u9001\u5230 Hub\uFF0C\u6211\u4EEC\u9700\u8981\u521B\u5EFA\u4E00\u4E2A "),he=o(ds,"STRONG",{});var ga=i(he);Fs=l(ga,"Repository"),ga.forEach(s),Fe=l(ds," \u5DE5\u4F5C\u6587\u4EF6\u5939\u4E2D\u7684\u5BF9\u8C61\u3002\u5982\u679C\u60A8\u5C1A\u672A\u767B\u5F55\uFF0C\u8BF7\u5148\u767B\u5F55 Hugging Face\u3002\u6211\u4EEC\u5C06\u4ECE\u6211\u4EEC\u60F3\u8981\u4E3A\u6A21\u578B\u63D0\u4F9B\u7684\u6A21\u578B ID \u4E2D\u786E\u5B9A\u5B58\u50A8\u5E93\u540D\u79F0\uFF08\u60A8\u53EF\u4EE5\u81EA\u7531\u5730\u7528\u81EA\u5DF1\u7684\u9009\u62E9\u66FF\u6362 "),je=o(ds,"STRONG",{});var Jt=i(je);xs=l(Jt,"repo_name"),Jt.forEach(s),re=l(ds," \uFF1B\u5B83\u9700\u8981\u5305\u542B\u60A8\u7684\u7528\u6237\u540D\uFF0C\u53EF\u4EE5\u4F7F\u7528"),Pe=o(ds,"STRONG",{});var ql=i(Pe);Ke=l(ql,"get_full_repo_name()"),ql.forEach(s),Xe=l(ds,"\u51FD\u6570\u7684\u67E5\u770B\u76EE\u524D\u7684repo_name\uFF09\uFF1A"),ds.forEach(s),fs=u(m),w(ze.$$.fragment,m),cs=u(m),w(we.$$.fragment,m),Ge=u(m),us=o(m,"P",{});var ka=i(us);Ee=l(ka,"\u7136\u540E\u6211\u4EEC\u53EF\u4EE5\u5728\u672C\u5730\u6587\u4EF6\u5939\u4E2D\u514B\u9686\u8BE5\u5B58\u50A8\u5E93\u3002\u5982\u679C\u5B83\u5DF2\u7ECF\u5B58\u5728\uFF0C\u8FD9\u4E2A\u672C\u5730\u6587\u4EF6\u5939\u5E94\u8BE5\u662F\u6211\u4EEC\u6B63\u5728\u4F7F\u7528\u7684\u5B58\u50A8\u5E93\u7684\u514B\u9686\uFF1A"),ka.forEach(s),Xs=u(m),w(Ce.$$.fragment,m),hs=u(m),We=o(m,"P",{});var Os=i(We);ys=l(Os,"\u6211\u4EEC\u73B0\u5728\u53EF\u4EE5\u901A\u8FC7\u8C03\u7528 "),ss=o(Os,"STRONG",{});var ja=i(ss);Ws=l(ja,"repo.push_to_hub()"),ja.forEach(s),Ye=l(Os," \u65B9\u6CD5\u4E0A\u4F20\u6211\u4EEC\u4FDD\u5B58\u7684\u4EFB\u4F55\u5185\u5BB9 "),Ts=o(Os,"STRONG",{});var Rt=i(Ts);Ps=l(Rt,"output_dir"),Rt.forEach(s),Ys=l(Os," \u3002\u8FD9\u5C06\u5E2E\u52A9\u6211\u4EEC\u5728\u6BCF\u4E2A epoch \u7ED3\u675F\u65F6\u4E0A\u4F20\u8FC7\u7A0B\u4E2D\u7684\u6A21\u578B\u3002"),Os.forEach(s),He=u(m),ue=o(m,"H3",{id:!0});var va=i(ue);Gs=l(va,"\u8BAD\u7EC3\u5FAA\u73AF"),va.forEach(s),Ze=u(m),Je=o(m,"P",{});var Ms=i(Je);Hs=l(Ms,"\u6211\u4EEC\u73B0\u5728\u51C6\u5907\u7F16\u5199\u5B8C\u6574\u7684\u8BAD\u7EC3\u5FAA\u73AF\u3002\u4E3A\u4E86\u7B80\u5316\u5B83\u7684\u8BC4\u4F30\u90E8\u5206\uFF0C\u6211\u4EEC\u5B9A\u4E49\u4E86\u8FD9\u4E2A "),$s=o(Ms,"STRONG",{});var xl=i($s);Zs=l(xl,"postprocess()"),xl.forEach(s),ms=l(Ms," \u51FD\u6570\u63A5\u6536\u9884\u6D4B\u7ED3\u679C\u548C\u6B63\u786E\u6807\u7B7E\u5E76\u5C06\u5B83\u4EEC\u8F6C\u6362\u4E3A\u6211\u4EEC "),Ss=o(Ms,"STRONG",{});var wa=i(Ss);ts=l(wa,"metric"),wa.forEach(s),Js=l(Ms," \u5BF9\u8C61\u6240\u9700\u8981\u7684\u5B57\u7B26\u4E32\u5217\u8868\uFF1A"),Ms.forEach(s),bs=u(m),w(_s.$$.fragment,m),as=u(m),qe=o(m,"P",{});var Cs=i(qe);ls=l(Cs,"\u8BAD\u7EC3\u5FAA\u73AF\u770B\u8D77\u6765\u548C"),rs=o(Cs,"A",{href:!0});var Ea=i(rs);gs=l(Ea,"\u672C\u7AE0\u7B2C\u4E8C\u8282"),Ea.forEach(s),Vs=l(Cs,"\u4E0E"),ns=o(Cs,"A",{href:!0});var dt=i(ns);Qs=l(dt,"\u7B2C\u4E09\u7AE0"),dt.forEach(s),ps=l(Cs,"\u5F88\u50CF\uFF0C\u5728\u8BC4\u4F30\u90E8\u5206\u6709\u4E00\u4E9B\u4E0D\u540C - \u6240\u4EE5\u8BA9\u6211\u4EEC\u4E13\u6CE8\u4E8E\u8FD9\u4E00\u70B9\uFF01"),Cs.forEach(s),_=u(m),z=o(m,"P",{});var ht=i(z);Us=l(ht,"\u9996\u5148\u8981\u6CE8\u610F\u7684\u662F\u6211\u4EEC\u4F7F\u7528 "),et=o(ht,"CODE",{});var Ft=i(et);ft=l(Ft,"generate()"),Ft.forEach(s),zs=l(ht," \u65B9\u6CD5\u6765\u8BA1\u7B97\u9884\u6D4B\uFF0C\u4F46\u8FD9\u662F\u6211\u4EEC\u57FA\u7840\u6A21\u578B\u4E0A\u7684\u4E00\u4E2A\u65B9\u6CD5\uFF0C\u800C\u4E0D\u662F\u5305\u88C5\u6A21\u578B\u{1F917} Accelerate \u5728 "),Ue=o(ht,"CODE",{});var yl=i(Ue);Ds=l(yl,"prepare()"),yl.forEach(s),ct=l(ht," \u65B9\u6CD5\u4E2D\u521B\u5EFA\u3002 \u8FD9\u5C31\u662F\u4E3A\u4EC0\u4E48\u6211\u4EEC\u5148\u89E3\u5305\u6A21\u578B\uFF0C\u7136\u540E\u8C03\u7528\u8FD9\u4E2A\u65B9\u6CD5\u3002"),ht.forEach(s),Le=u(m),Ie=o(m,"P",{});var Bs=i(Ie);xe=l(Bs,"\u7B2C\u4E8C\u4EF6\u4E8B\u662F\uFF0C\u5C31\u50CF"),Is=o(Bs,"A",{href:!0});var Gt=i(Is);ut=l(Gt,"token \u5206\u7C7B"),Gt.forEach(s),st=l(Bs,"\uFF0C\u4E24\u4E2A\u8FDB\u7A0B\u53EF\u80FD\u5C06\u8F93\u5165\u548C\u6807\u7B7E\u586B\u5145\u4E3A\u4E0D\u540C\u7684\u5F62\u72B6\uFF0C\u56E0\u6B64\u6211\u4EEC\u5728\u8C03\u7528 "),tt=o(Bs,"STRONG",{});var qa=i(tt);Pt=l(qa,"gather()"),qa.forEach(s),at=l(Bs," \u65B9\u6CD5\u4E4B\u524D\u4F7F\u7528 "),As=o(Bs,"STRONG",{});var Ks=i(As);St=l(Ks,"accelerator.pad_across_processes()"),Ks.forEach(s),mt=l(Bs," \u4F7F\u9884\u6D4B\u548C\u6807\u7B7E\u5177\u6709\u76F8\u540C\u7684\u5F62\u72B6\u3002\u5982\u679C\u6211\u4EEC\u4E0D\u8FD9\u6837\u505A\uFF0C\u8BC4\u4F30\u8981\u4E48\u51FA\u9519\uFF0C\u8981\u4E48\u6C38\u8FDC\u5728\u963B\u585E\u3002"),Bs.forEach(s),ks=u(m),w(js.$$.fragment,m),vs=u(m),w(ws.$$.fragment,m),Ve=u(m),ye=o(m,"P",{});var it=i(ye);lt=l(it,"\u5B8C\u6210\u6B64\u64CD\u4F5C\u540E\uFF0C\u60A8\u5E94\u8BE5\u6709\u4E00\u4E2A\u6A21\u578B\uFF0C\u5176\u7ED3\u679C\u4E0E\u4F7F\u7528 "),rt=o(it,"CODE",{});var sa=i(rt);zt=l(sa,"Seq2SeqTrainer"),sa.forEach(s),nt=l(it," \u8BAD\u7EC3\u7684\u6A21\u578B\u975E\u5E38\u76F8\u4F3C\u3002 \u60A8\u53EF\u4EE5\u5728 ["),pt=o(it,"EM",{});var Tl=i(pt);ma=l(Tl,"huggingface-course/marian-finetuned-kde4-en-to-fr-accelerate"),Tl.forEach(s),Vt=l(it,"]("),Es=o(it,"A",{href:!0,rel:!0});var Pl=i(Es);Qt=l(Pl,"https://huggingface.co/huggingface-course/marian-finetuned-kde4-en-to-fr-accelerate\uFF09\u67E5\u770B\u8BAD\u7EC3\u5B8C\u7684\u7ED3\u679C\u3002"),Pl.forEach(s),Dt=l(it," \u5982\u679C\u60A8\u60F3\u6D4B\u8BD5\u5BF9\u8BAD\u7EC3\u5FAA\u73AF\u7684\u4EFB\u4F55\u8C03\u6574\uFF0C\u60A8\u53EF\u4EE5\u901A\u8FC7\u7F16\u8F91\u4E0A\u9762\u663E\u793A\u7684\u4EE3\u7801\u76F4\u63A5\u5B9E\u73B0\u5B83\u4EEC\uFF01"),it.forEach(s),this.h()},h(){j(f,"id",""),j(T,"href","/course/chapter7/2"),j(y,"href","/course/chapter3/4"),j(P,"id",""),j(ue,"id",""),j(rs,"href","/course/chapter7/2"),j(ns,"href","/course/chapter3"),j(Is,"href","/course/chapter7/2"),j(Es,"href","https://huggingface.co/huggingface-course/marian-finetuned-kde4-en-to-fr-accelerate%EF%BC%89%E6%9F%A5%E7%9C%8B%E8%AE%AD%E7%BB%83%E5%AE%8C%E7%9A%84%E7%BB%93%E6%9E%9C%E3%80%82"),j(Es,"rel","nofollow")},m(m,O){r(m,f,O),t(f,$),r(m,d,O),r(m,b,O),t(b,L),t(b,T),t(T,C),t(b,D),t(b,y),t(y,A),t(b,N),r(m,x,O),r(m,P,O),t(P,H),r(m,U,O),r(m,F,O),t(F,J),t(F,K),t(K,R),t(F,I),t(F,X),t(X,Q),t(F,_e),r(m,V,O),E(W,m,O),r(m,ne,O),r(m,Y,O),t(Y,Se),r(m,Te,O),E(me,m,O),r(m,Z,O),r(m,ee,O),t(ee,G),r(m,se,O),E(de,m,O),r(m,$e,O),r(m,pe,O),t(pe,oe),t(pe,te),t(te,De),t(pe,be),r(m,Ne,O),E(ge,m,O),r(m,ie,O),r(m,fe,O),t(fe,os),t(fe,ce),t(ce,is),t(fe,Be),t(fe,Re),t(Re,ve),t(fe,Ae),t(fe,ke),t(ke,ae),t(fe,Qe),r(m,Oe,O),E(le,m,O),r(m,es,O),r(m,h,O),t(h,M),t(h,he),t(he,Fs),t(h,Fe),t(h,je),t(je,xs),t(h,re),t(h,Pe),t(Pe,Ke),t(h,Xe),r(m,fs,O),E(ze,m,O),r(m,cs,O),E(we,m,O),r(m,Ge,O),r(m,us,O),t(us,Ee),r(m,Xs,O),E(Ce,m,O),r(m,hs,O),r(m,We,O),t(We,ys),t(We,ss),t(ss,Ws),t(We,Ye),t(We,Ts),t(Ts,Ps),t(We,Ys),r(m,He,O),r(m,ue,O),t(ue,Gs),r(m,Ze,O),r(m,Je,O),t(Je,Hs),t(Je,$s),t($s,Zs),t(Je,ms),t(Je,Ss),t(Ss,ts),t(Je,Js),r(m,bs,O),E(_s,m,O),r(m,as,O),r(m,qe,O),t(qe,ls),t(qe,rs),t(rs,gs),t(qe,Vs),t(qe,ns),t(ns,Qs),t(qe,ps),r(m,_,O),r(m,z,O),t(z,Us),t(z,et),t(et,ft),t(z,zs),t(z,Ue),t(Ue,Ds),t(z,ct),r(m,Le,O),r(m,Ie,O),t(Ie,xe),t(Ie,Is),t(Is,ut),t(Ie,st),t(Ie,tt),t(tt,Pt),t(Ie,at),t(Ie,As),t(As,St),t(Ie,mt),r(m,ks,O),E(js,m,O),r(m,vs,O),E(ws,m,O),r(m,Ve,O),r(m,ye,O),t(ye,lt),t(ye,rt),t(rt,zt),t(ye,nt),t(ye,pt),t(pt,ma),t(ye,Vt),t(ye,Es),t(Es,Qt),t(ye,Dt),ea=!0},i(m){ea||(g(W.$$.fragment,m),g(me.$$.fragment,m),g(de.$$.fragment,m),g(ge.$$.fragment,m),g(le.$$.fragment,m),g(ze.$$.fragment,m),g(we.$$.fragment,m),g(Ce.$$.fragment,m),g(_s.$$.fragment,m),g(js.$$.fragment,m),g(ws.$$.fragment,m),ea=!0)},o(m){k(W.$$.fragment,m),k(me.$$.fragment,m),k(de.$$.fragment,m),k(ge.$$.fragment,m),k(le.$$.fragment,m),k(ze.$$.fragment,m),k(we.$$.fragment,m),k(Ce.$$.fragment,m),k(_s.$$.fragment,m),k(js.$$.fragment,m),k(ws.$$.fragment,m),ea=!1},d(m){m&&s(f),m&&s(d),m&&s(b),m&&s(x),m&&s(P),m&&s(U),m&&s(F),m&&s(V),q(W,m),m&&s(ne),m&&s(Y),m&&s(Te),q(me,m),m&&s(Z),m&&s(ee),m&&s(se),q(de,m),m&&s($e),m&&s(pe),m&&s(Ne),q(ge,m),m&&s(ie),m&&s(fe),m&&s(Oe),q(le,m),m&&s(es),m&&s(h),m&&s(fs),q(ze,m),m&&s(cs),q(we,m),m&&s(Ge),m&&s(us),m&&s(Xs),q(Ce,m),m&&s(hs),m&&s(We),m&&s(He),m&&s(ue),m&&s(Ze),m&&s(Je),m&&s(bs),q(_s,m),m&&s(as),m&&s(qe),m&&s(_),m&&s(z),m&&s(Le),m&&s(Ie),m&&s(ks),q(js,m),m&&s(vs),q(ws,m),m&&s(Ve),m&&s(ye)}}}function rc(B){let f,$,d,b,L;return{c(){f=p("p"),$=a("\u270F\uFE0F "),d=p("strong"),b=a("\u8F6E\u5230\u4F60\u4E86\uFF01"),L=a(" \u201C\u7535\u5B50\u90AE\u4EF6\u201D\u8FD9\u4E2A\u8BCD\u5728\u6A21\u578B\u8FD4\u56DE\u4E86\u4EC0\u4E48\uFF1F")},l(T){f=o(T,"P",{});var C=i(f);$=l(C,"\u270F\uFE0F "),d=o(C,"STRONG",{});var D=i(d);b=l(D,"\u8F6E\u5230\u4F60\u4E86\uFF01"),D.forEach(s),L=l(C," \u201C\u7535\u5B50\u90AE\u4EF6\u201D\u8FD9\u4E2A\u8BCD\u5728\u6A21\u578B\u8FD4\u56DE\u4E86\u4EC0\u4E48\uFF1F"),C.forEach(s)},m(T,C){r(T,f,C),t(f,$),t(f,d),t(d,b),t(f,L)},d(T){T&&s(f)}}}function nc(B){let f,$,d,b,L,T,C,D,y,A,N,x,P,H,U,F,J,K,R,I,X,Q,_e,V,W,ne,Y,Se,Te,me,Z,ee,G,se,de,$e,pe,oe,te,De,be,Ne,ge,ie,fe,os,ce,is,Be,Re,ve,Ae,ke,ae,Qe,Oe,le,es,h,M,he,Fs,Fe,je,xs,re,Pe,Ke,Xe,fs,ze,cs,we,Ge,us,Ee,Xs,Ce,hs,We,ys,ss,Ws,Ye,Ts,Ps,Ys,He,ue,Gs,Ze,Je,Hs,$s,Zs,ms,Ss,ts,Js,bs,_s,as,qe,ls,rs,gs,Vs,ns,Qs,ps,_,z,Us,et,ft,zs,Ue,Ds,ct,Le,Ie,xe,Is,ut,st,tt,Pt,at,As,St,mt,ks,js,vs,ws,Ve,ye,lt,rt,zt,nt,pt,ma,Vt,Es,Qt,Dt,ea,m,O,_t,At,_a,Wt,Ot,da,Ct,ha,Lt,Yt,Zt,ot,$a,Nt,ba,ds,ga,Jt,ql,ka,Os,ja,Rt,va,Ms,xl,wa,Cs,Ea,dt,ht,Ft,yl,Bs,Gt,qa,Ks,it,sa,Tl,Pl,xa,cp,up,Nr,ya,Rr,Ht,mp,$r,_p,dp,Ta,hp,$p,Fr,ta,Gr,Sl,bp,Hr,aa,gp,br,kp,jp,Ur,Pa,Ir,zl,vp,Mr,Dl,wp,Br,Al,Ep,Kr,Sa,Xr,Ol,qp,Wr,za,Yr,Da,Zr,Cl,xp,Jr,$t,gr,yp,Tp,kr,Pp,Sp,jr,zp,Dp,Vr,Aa,Qr,Ll,Ap,en,la,sn,ra,tn,Nl,Op,an,Oa,ln,Rl,Cp,rn,bt,gt,Fl,Gl,Lp,nn,Ca,Np,pn,Ut,Rp,Hl,Fp,Gp,vr,Hp,Up,on,Ls,Ip,La,wr,Mp,Bp,Er,Kp,Xp,qr,Wp,Yp,xr,Zp,Jp,fn,kt,jt,Ul,Il,Vp,cn,Na,un,Ra,mn,na,Qp,yr,eo,so,_n,Fa,dn,Ga,hn,Ml,to,$n,Ha,bn,Ua,gn,Bl,ao,kn,Ia,jn,Ma,vn,vt,wt,Kl,Ba,lo,wn,Ka,En,Xl,Ns,ro,Xa,no,po,Wa,oo,io,Tr,fo,co,Pr,uo,mo,qn,pa,_o,Ya,ho,$o,xn,Za,yn,It,bo,Wl,go,ko,Sr,jo,vo,Tn,Ja,Pn,Yl,wo,Sn,Zl,Eo,zn,Va,Dn,Qa,An,Rs,qo,el,xo,yo,zr,To,Po,Dr,So,zo,sl,Do,Ao,On,tl,Cn,al,Ln,ll,Nn,rl,Rn,Jl,Oo,Fn,Et,qt,Vl,Ql,Co,Gn,nl,Lo,Hn,er,No,Un,pl,In,sr,Ro,Mn,tr,Fo,Bn,ol,Kn,xt,yt,ar,lr,il,Go,Xn,rr,Ho,Wn,fl,Yn,cl,Zn,nr,Uo,Jn,ul,Vn,ml,Qn,pr,Io,ep,oa,sp;d=new Ff({props:{fw:B[0]}});const Bo=[Hf,Gf],_l=[];function Ko(e,n){return e[0]==="pt"?0:1}D=Ko(B),y=_l[D]=Bo[D](B),Z=new fp({props:{id:"1JvfrvZgi6c"}}),Ze=new Mo({}),as=new S({props:{code:`from datasets import load_dataset, load_metric

raw_datasets = load_dataset("kde4", lang1="en", lang2="fr")`,highlighted:`<span class="hljs-keyword">from</span> datasets <span class="hljs-keyword">import</span> load_dataset, load_metric

raw_datasets = load_dataset(<span class="hljs-string">&quot;kde4&quot;</span>, lang1=<span class="hljs-string">&quot;en&quot;</span>, lang2=<span class="hljs-string">&quot;fr&quot;</span>)`}}),zs=new S({props:{code:"raw_datasets",highlighted:"raw_datasets"}}),Ds=new S({props:{code:`DatasetDict({
    train: Dataset({
        features: ['id', 'translation'],
        num_rows: 210173
    })
})`,highlighted:`DatasetDict({
    train: Dataset({
        features: [<span class="hljs-string">&#x27;id&#x27;</span>, <span class="hljs-string">&#x27;translation&#x27;</span>],
        num_rows: <span class="hljs-number">210173</span>
    })
})`}}),ks=new S({props:{code:`split_datasets = raw_datasets["train"].train_test_split(train_size=0.9, seed=20)
split_datasets`,highlighted:`split_datasets = raw_datasets[<span class="hljs-string">&quot;train&quot;</span>].train_test_split(train_size=<span class="hljs-number">0.9</span>, seed=<span class="hljs-number">20</span>)
split_datasets`}}),vs=new S({props:{code:`DatasetDict({
    train: Dataset({
        features: ['id', 'translation'],
        num_rows: 189155
    })
    test: Dataset({
        features: ['id', 'translation'],
        num_rows: 21018
    })
})`,highlighted:`DatasetDict({
    train: Dataset({
        features: [<span class="hljs-string">&#x27;id&#x27;</span>, <span class="hljs-string">&#x27;translation&#x27;</span>],
        num_rows: <span class="hljs-number">189155</span>
    })
    test: Dataset({
        features: [<span class="hljs-string">&#x27;id&#x27;</span>, <span class="hljs-string">&#x27;translation&#x27;</span>],
        num_rows: <span class="hljs-number">21018</span>
    })
})`}}),Es=new S({props:{code:'split_datasets["validation"] = split_datasets.pop("test")',highlighted:'split_datasets[<span class="hljs-string">&quot;validation&quot;</span>] = split_datasets.pop(<span class="hljs-string">&quot;test&quot;</span>)'}}),O=new S({props:{code:'split_datasets["train"][1]["translation"]',highlighted:'split_datasets[<span class="hljs-string">&quot;train&quot;</span>][<span class="hljs-number">1</span>][<span class="hljs-string">&quot;translation&quot;</span>]'}}),At=new S({props:{code:`{'en': 'Default to expanded threads',
 'fr': 'Par d\xE9faut, d\xE9velopper les fils de discussion'}`,highlighted:`{<span class="hljs-string">&#x27;en&#x27;</span>: <span class="hljs-string">&#x27;Default to expanded threads&#x27;</span>,
 <span class="hljs-string">&#x27;fr&#x27;</span>: <span class="hljs-string">&#x27;Par d\xE9faut, d\xE9velopper les fils de discussion&#x27;</span>}`}}),Ct=new S({props:{code:`from transformers import pipeline

model_checkpoint = "Helsinki-NLP/opus-mt-en-fr"
translator = pipeline("translation", model=model_checkpoint)
translator("Default to expanded threads")`,highlighted:`<span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> pipeline

model_checkpoint = <span class="hljs-string">&quot;Helsinki-NLP/opus-mt-en-fr&quot;</span>
translator = pipeline(<span class="hljs-string">&quot;translation&quot;</span>, model=model_checkpoint)
translator(<span class="hljs-string">&quot;Default to expanded threads&quot;</span>)`}}),Lt=new S({props:{code:"[{'translation_text': 'Par d\xE9faut pour les threads \xE9largis'}]",highlighted:'[{<span class="hljs-string">&#x27;translation_text&#x27;</span>: <span class="hljs-string">&#x27;Par d\xE9faut pour les threads \xE9largis&#x27;</span>}]'}}),Nt=new S({props:{code:'split_datasets["train"][172]["translation"]',highlighted:'split_datasets[<span class="hljs-string">&quot;train&quot;</span>][<span class="hljs-number">172</span>][<span class="hljs-string">&quot;translation&quot;</span>]'}}),ds=new S({props:{code:`{'en': 'Unable to import %1 using the OFX importer plugin. This file is not the correct format.',
 'fr': "Impossible d'importer %1 en utilisant le module d'extension d'importation OFX. Ce fichier n'a pas un format correct."}`,highlighted:`{<span class="hljs-string">&#x27;en&#x27;</span>: <span class="hljs-string">&#x27;Unable to import %1 using the OFX importer plugin. This file is not the correct format.&#x27;</span>,
 <span class="hljs-string">&#x27;fr&#x27;</span>: <span class="hljs-string">&quot;Impossible d&#x27;importer %1 en utilisant le module d&#x27;extension d&#x27;importation OFX. Ce fichier n&#x27;a pas un format correct.&quot;</span>}`}}),Os=new S({props:{code:`translator(
    "Unable to import %1 using the OFX importer plugin. This file is not the correct format."
)`,highlighted:`translator(
    <span class="hljs-string">&quot;Unable to import %1 using the OFX importer plugin. This file is not the correct format.&quot;</span>
)`}}),Rt=new S({props:{code:`[{'translation_text': "Impossible d'importer %1 en utilisant le plugin d'importateur OFX. Ce fichier n'est pas le bon format."}]`,highlighted:'[{<span class="hljs-string">&#x27;translation_text&#x27;</span>: <span class="hljs-string">&quot;Impossible d&#x27;importer %1 en utilisant le plugin d&#x27;importateur OFX. Ce fichier n&#x27;est pas le bon format.&quot;</span>}]'}}),Cs=new fp({props:{id:"0Oxphw4Q9fo"}}),dt=new ua({props:{$$slots:{default:[Uf]},$$scope:{ctx:B}}}),Gt=new fp({props:{id:"XAR8jnZZuUs"}}),ya=new S({props:{code:`from transformers import AutoTokenizer

model_checkpoint = "Helsinki-NLP/opus-mt-en-fr"
tokenizer = AutoTokenizer.from_pretrained(model_checkpoint, return_tensors="tf")`,highlighted:`<span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoTokenizer

model_checkpoint = <span class="hljs-string">&quot;Helsinki-NLP/opus-mt-en-fr&quot;</span>
tokenizer = AutoTokenizer.from_pretrained(model_checkpoint, return_tensors=<span class="hljs-string">&quot;tf&quot;</span>)`}}),ta=new ua({props:{$$slots:{default:[If]},$$scope:{ctx:B}}}),Pa=new S({props:{code:`with open(file_path) as f:
    content = f.read()`,highlighted:`<span class="hljs-keyword">with</span> <span class="hljs-built_in">open</span>(file_path) <span class="hljs-keyword">as</span> f:
    content = f.<span class="hljs-built_in">read</span>()`}}),Sa=new S({props:{code:`en_sentence = split_datasets["train"][1]["translation"]["en"]
fr_sentence = split_datasets["train"][1]["translation"]["fr"]

inputs = tokenizer(en_sentence)
with tokenizer.as_target_tokenizer():
    targets = tokenizer(fr_sentence)`,highlighted:`en_sentence = split_datasets[<span class="hljs-string">&quot;train&quot;</span>][<span class="hljs-number">1</span>][<span class="hljs-string">&quot;translation&quot;</span>][<span class="hljs-string">&quot;en&quot;</span>]
fr_sentence = split_datasets[<span class="hljs-string">&quot;train&quot;</span>][<span class="hljs-number">1</span>][<span class="hljs-string">&quot;translation&quot;</span>][<span class="hljs-string">&quot;fr&quot;</span>]

inputs = tokenizer(en_sentence)
<span class="hljs-keyword">with</span> tokenizer.as_target_tokenizer():
    targets = tokenizer(fr_sentence)`}}),za=new S({props:{code:`wrong_targets = tokenizer(fr_sentence)
print(tokenizer.convert_ids_to_tokens(wrong_targets["input_ids"]))
print(tokenizer.convert_ids_to_tokens(targets["input_ids"]))`,highlighted:`wrong_targets = tokenizer(fr_sentence)
<span class="hljs-built_in">print</span>(tokenizer.convert_ids_to_tokens(wrong_targets[<span class="hljs-string">&quot;input_ids&quot;</span>]))
<span class="hljs-built_in">print</span>(tokenizer.convert_ids_to_tokens(targets[<span class="hljs-string">&quot;input_ids&quot;</span>]))`}}),Da=new S({props:{code:`['\u2581Par', '\u2581d\xE9', 'f', 'aut', ',', '\u2581d\xE9', 've', 'lop', 'per', '\u2581les', '\u2581fil', 's', '\u2581de', '\u2581discussion', '</s>']
['\u2581Par', '\u2581d\xE9faut', ',', '\u2581d\xE9velopper', '\u2581les', '\u2581fils', '\u2581de', '\u2581discussion', '</s>']`,highlighted:`[<span class="hljs-string">&#x27;\u2581Par&#x27;</span>, <span class="hljs-string">&#x27;\u2581d\xE9&#x27;</span>, <span class="hljs-string">&#x27;f&#x27;</span>, <span class="hljs-string">&#x27;aut&#x27;</span>, <span class="hljs-string">&#x27;,&#x27;</span>, <span class="hljs-string">&#x27;\u2581d\xE9&#x27;</span>, <span class="hljs-string">&#x27;ve&#x27;</span>, <span class="hljs-string">&#x27;lop&#x27;</span>, <span class="hljs-string">&#x27;per&#x27;</span>, <span class="hljs-string">&#x27;\u2581les&#x27;</span>, <span class="hljs-string">&#x27;\u2581fil&#x27;</span>, <span class="hljs-string">&#x27;s&#x27;</span>, <span class="hljs-string">&#x27;\u2581de&#x27;</span>, <span class="hljs-string">&#x27;\u2581discussion&#x27;</span>, <span class="hljs-string">&#x27;&lt;/s&gt;&#x27;</span>]
[<span class="hljs-string">&#x27;\u2581Par&#x27;</span>, <span class="hljs-string">&#x27;\u2581d\xE9faut&#x27;</span>, <span class="hljs-string">&#x27;,&#x27;</span>, <span class="hljs-string">&#x27;\u2581d\xE9velopper&#x27;</span>, <span class="hljs-string">&#x27;\u2581les&#x27;</span>, <span class="hljs-string">&#x27;\u2581fils&#x27;</span>, <span class="hljs-string">&#x27;\u2581de&#x27;</span>, <span class="hljs-string">&#x27;\u2581discussion&#x27;</span>, <span class="hljs-string">&#x27;&lt;/s&gt;&#x27;</span>]`}}),Aa=new S({props:{code:`max_input_length = 128
max_target_length = 128


def preprocess_function(examples):
    inputs = [ex["en"] for ex in examples["translation"]]
    targets = [ex["fr"] for ex in examples["translation"]]
    model_inputs = tokenizer(inputs, max_length=max_input_length, truncation=True)

    # Set up the tokenizer for targets
    with tokenizer.as_target_tokenizer():
        labels = tokenizer(targets, max_length=max_target_length, truncation=True)

    model_inputs["labels"] = labels["input_ids"]
    return model_inputs`,highlighted:`max_input_length = <span class="hljs-number">128</span>
max_target_length = <span class="hljs-number">128</span>


<span class="hljs-keyword">def</span> <span class="hljs-title function_">preprocess_function</span>(<span class="hljs-params">examples</span>):
    inputs = [ex[<span class="hljs-string">&quot;en&quot;</span>] <span class="hljs-keyword">for</span> ex <span class="hljs-keyword">in</span> examples[<span class="hljs-string">&quot;translation&quot;</span>]]
    targets = [ex[<span class="hljs-string">&quot;fr&quot;</span>] <span class="hljs-keyword">for</span> ex <span class="hljs-keyword">in</span> examples[<span class="hljs-string">&quot;translation&quot;</span>]]
    model_inputs = tokenizer(inputs, max_length=max_input_length, truncation=<span class="hljs-literal">True</span>)

    <span class="hljs-comment"># Set up the tokenizer for targets</span>
    <span class="hljs-keyword">with</span> tokenizer.as_target_tokenizer():
        labels = tokenizer(targets, max_length=max_target_length, truncation=<span class="hljs-literal">True</span>)

    model_inputs[<span class="hljs-string">&quot;labels&quot;</span>] = labels[<span class="hljs-string">&quot;input_ids&quot;</span>]
    <span class="hljs-keyword">return</span> model_inputs`}}),la=new ua({props:{$$slots:{default:[Mf]},$$scope:{ctx:B}}}),ra=new ua({props:{warning:!0,$$slots:{default:[Bf]},$$scope:{ctx:B}}}),Oa=new S({props:{code:`tokenized_datasets = split_datasets.map(
    preprocess_function,
    batched=True,
    remove_columns=split_datasets["train"].column_names,
)`,highlighted:`tokenized_datasets = split_datasets.<span class="hljs-built_in">map</span>(
    preprocess_function,
    batched=<span class="hljs-literal">True</span>,
    remove_columns=split_datasets[<span class="hljs-string">&quot;train&quot;</span>].column_names,
)`}});const Xo=[Xf,Kf],dl=[];function Wo(e,n){return e[0]==="pt"?0:1}bt=Wo(B),gt=dl[bt]=Xo[bt](B);const Yo=[Zf,Yf],hl=[];function Zo(e,n){return e[0]==="pt"?0:1}kt=Zo(B),jt=hl[kt]=Yo[kt](B),Na=new S({props:{code:`batch = data_collator([tokenized_datasets["train"][i] for i in range(1, 3)])
batch.keys()`,highlighted:`batch = data_collator([tokenized_datasets[<span class="hljs-string">&quot;train&quot;</span>][i] <span class="hljs-keyword">for</span> i <span class="hljs-keyword">in</span> <span class="hljs-built_in">range</span>(<span class="hljs-number">1</span>, <span class="hljs-number">3</span>)])
batch.keys()`}}),Ra=new S({props:{code:"dict_keys(['attention_mask', 'input_ids', 'labels', 'decoder_input_ids'])",highlighted:'dict_keys([<span class="hljs-string">&#x27;attention_mask&#x27;</span>, <span class="hljs-string">&#x27;input_ids&#x27;</span>, <span class="hljs-string">&#x27;labels&#x27;</span>, <span class="hljs-string">&#x27;decoder_input_ids&#x27;</span>])'}}),Fa=new S({props:{code:'batch["labels"]',highlighted:'batch[<span class="hljs-string">&quot;labels&quot;</span>]'}}),Ga=new S({props:{code:`tensor([[  577,  5891,     2,  3184,    16,  2542,     5,  1710,     0,  -100,
          -100,  -100,  -100,  -100,  -100,  -100],
        [ 1211,     3,    49,  9409,  1211,     3, 29140,   817,  3124,   817,
           550,  7032,  5821,  7907, 12649,     0]])`,highlighted:`tensor([[  <span class="hljs-number">577</span>,  <span class="hljs-number">5891</span>,     <span class="hljs-number">2</span>,  <span class="hljs-number">3184</span>,    <span class="hljs-number">16</span>,  <span class="hljs-number">2542</span>,     <span class="hljs-number">5</span>,  <span class="hljs-number">1710</span>,     <span class="hljs-number">0</span>,  -<span class="hljs-number">100</span>,
          -<span class="hljs-number">100</span>,  -<span class="hljs-number">100</span>,  -<span class="hljs-number">100</span>,  -<span class="hljs-number">100</span>,  -<span class="hljs-number">100</span>,  -<span class="hljs-number">100</span>],
        [ <span class="hljs-number">1211</span>,     <span class="hljs-number">3</span>,    <span class="hljs-number">49</span>,  <span class="hljs-number">9409</span>,  <span class="hljs-number">1211</span>,     <span class="hljs-number">3</span>, <span class="hljs-number">29140</span>,   <span class="hljs-number">817</span>,  <span class="hljs-number">3124</span>,   <span class="hljs-number">817</span>,
           <span class="hljs-number">550</span>,  <span class="hljs-number">7032</span>,  <span class="hljs-number">5821</span>,  <span class="hljs-number">7907</span>, <span class="hljs-number">12649</span>,     <span class="hljs-number">0</span>]])`}}),Ha=new S({props:{code:'batch["decoder_input_ids"]',highlighted:'batch[<span class="hljs-string">&quot;decoder_input_ids&quot;</span>]'}}),Ua=new S({props:{code:`tensor([[59513,   577,  5891,     2,  3184,    16,  2542,     5,  1710,     0,
         59513, 59513, 59513, 59513, 59513, 59513],
        [59513,  1211,     3,    49,  9409,  1211,     3, 29140,   817,  3124,
           817,   550,  7032,  5821,  7907, 12649]])`,highlighted:`tensor([[<span class="hljs-number">59513</span>,   <span class="hljs-number">577</span>,  <span class="hljs-number">5891</span>,     <span class="hljs-number">2</span>,  <span class="hljs-number">3184</span>,    <span class="hljs-number">16</span>,  <span class="hljs-number">2542</span>,     <span class="hljs-number">5</span>,  <span class="hljs-number">1710</span>,     <span class="hljs-number">0</span>,
         <span class="hljs-number">59513</span>, <span class="hljs-number">59513</span>, <span class="hljs-number">59513</span>, <span class="hljs-number">59513</span>, <span class="hljs-number">59513</span>, <span class="hljs-number">59513</span>],
        [<span class="hljs-number">59513</span>,  <span class="hljs-number">1211</span>,     <span class="hljs-number">3</span>,    <span class="hljs-number">49</span>,  <span class="hljs-number">9409</span>,  <span class="hljs-number">1211</span>,     <span class="hljs-number">3</span>, <span class="hljs-number">29140</span>,   <span class="hljs-number">817</span>,  <span class="hljs-number">3124</span>,
           <span class="hljs-number">817</span>,   <span class="hljs-number">550</span>,  <span class="hljs-number">7032</span>,  <span class="hljs-number">5821</span>,  <span class="hljs-number">7907</span>, <span class="hljs-number">12649</span>]])`}}),Ia=new S({props:{code:`for i in range(1, 3):
    print(tokenized_datasets["train"][i]["labels"])`,highlighted:`<span class="hljs-keyword">for</span> i <span class="hljs-keyword">in</span> <span class="hljs-built_in">range</span>(<span class="hljs-number">1</span>, <span class="hljs-number">3</span>):
    <span class="hljs-built_in">print</span>(tokenized_datasets[<span class="hljs-string">&quot;train&quot;</span>][i][<span class="hljs-string">&quot;labels&quot;</span>])`}}),Ma=new S({props:{code:`[577, 5891, 2, 3184, 16, 2542, 5, 1710, 0]
[1211, 3, 49, 9409, 1211, 3, 29140, 817, 3124, 817, 550, 7032, 5821, 7907, 12649, 0]`,highlighted:`[<span class="hljs-number">577</span>, <span class="hljs-number">5891</span>, <span class="hljs-number">2</span>, <span class="hljs-number">3184</span>, <span class="hljs-number">16</span>, <span class="hljs-number">2542</span>, <span class="hljs-number">5</span>, <span class="hljs-number">1710</span>, <span class="hljs-number">0</span>]
[<span class="hljs-number">1211</span>, <span class="hljs-number">3</span>, <span class="hljs-number">49</span>, <span class="hljs-number">9409</span>, <span class="hljs-number">1211</span>, <span class="hljs-number">3</span>, <span class="hljs-number">29140</span>, <span class="hljs-number">817</span>, <span class="hljs-number">3124</span>, <span class="hljs-number">817</span>, <span class="hljs-number">550</span>, <span class="hljs-number">7032</span>, <span class="hljs-number">5821</span>, <span class="hljs-number">7907</span>, <span class="hljs-number">12649</span>, <span class="hljs-number">0</span>]`}});const Jo=[Vf,Jf],$l=[];function Vo(e,n){return e[0]==="pt"?0:1}vt=Vo(B),wt=$l[vt]=Jo[vt](B),Ka=new fp({props:{id:"M05L1DhFqcw"}});let qs=B[0]==="pt"&&zf();Za=new S({props:{code:"!pip install sacrebleu",highlighted:"!pip install sacrebleu"}}),Ja=new S({props:{code:`from datasets import load_metric

metric = load_metric("sacrebleu")`,highlighted:`<span class="hljs-keyword">from</span> datasets <span class="hljs-keyword">import</span> load_metric

metric = load_metric(<span class="hljs-string">&quot;sacrebleu&quot;</span>)`}}),Va=new S({props:{code:`predictions = [
    "This plugin lets you translate web pages between several languages automatically."
]
references = [
    [
        "This plugin allows you to automatically translate web pages between several languages."
    ]
]
metric.compute(predictions=predictions, references=references)`,highlighted:`predictions = [
    <span class="hljs-string">&quot;This plugin lets you translate web pages between several languages automatically.&quot;</span>
]
references = [
    [
        <span class="hljs-string">&quot;This plugin allows you to automatically translate web pages between several languages.&quot;</span>
    ]
]
metric.compute(predictions=predictions, references=references)`}}),Qa=new S({props:{code:`{'score': 46.750469682990165,
 'counts': [11, 6, 4, 3],
 'totals': [12, 11, 10, 9],
 'precisions': [91.67, 54.54, 40.0, 33.33],
 'bp': 0.9200444146293233,
 'sys_len': 12,
 'ref_len': 13}`,highlighted:`{<span class="hljs-string">&#x27;score&#x27;</span>: <span class="hljs-number">46.750469682990165</span>,
 <span class="hljs-string">&#x27;counts&#x27;</span>: [<span class="hljs-number">11</span>, <span class="hljs-number">6</span>, <span class="hljs-number">4</span>, <span class="hljs-number">3</span>],
 <span class="hljs-string">&#x27;totals&#x27;</span>: [<span class="hljs-number">12</span>, <span class="hljs-number">11</span>, <span class="hljs-number">10</span>, <span class="hljs-number">9</span>],
 <span class="hljs-string">&#x27;precisions&#x27;</span>: [<span class="hljs-number">91.67</span>, <span class="hljs-number">54.54</span>, <span class="hljs-number">40.0</span>, <span class="hljs-number">33.33</span>],
 <span class="hljs-string">&#x27;bp&#x27;</span>: <span class="hljs-number">0.9200444146293233</span>,
 <span class="hljs-string">&#x27;sys_len&#x27;</span>: <span class="hljs-number">12</span>,
 <span class="hljs-string">&#x27;ref_len&#x27;</span>: <span class="hljs-number">13</span>}`}}),tl=new S({props:{code:`predictions = ["This This This This"]
references = [
    [
        "This plugin allows you to automatically translate web pages between several languages."
    ]
]
metric.compute(predictions=predictions, references=references)`,highlighted:`predictions = [<span class="hljs-string">&quot;This This This This&quot;</span>]
references = [
    [
        <span class="hljs-string">&quot;This plugin allows you to automatically translate web pages between several languages.&quot;</span>
    ]
]
metric.compute(predictions=predictions, references=references)`}}),al=new S({props:{code:`{'score': 1.683602693167689,
 'counts': [1, 0, 0, 0],
 'totals': [4, 3, 2, 1],
 'precisions': [25.0, 16.67, 12.5, 12.5],
 'bp': 0.10539922456186433,
 'sys_len': 4,
 'ref_len': 13}`,highlighted:`{<span class="hljs-string">&#x27;score&#x27;</span>: <span class="hljs-number">1.683602693167689</span>,
 <span class="hljs-string">&#x27;counts&#x27;</span>: [<span class="hljs-number">1</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>],
 <span class="hljs-string">&#x27;totals&#x27;</span>: [<span class="hljs-number">4</span>, <span class="hljs-number">3</span>, <span class="hljs-number">2</span>, <span class="hljs-number">1</span>],
 <span class="hljs-string">&#x27;precisions&#x27;</span>: [<span class="hljs-number">25.0</span>, <span class="hljs-number">16.67</span>, <span class="hljs-number">12.5</span>, <span class="hljs-number">12.5</span>],
 <span class="hljs-string">&#x27;bp&#x27;</span>: <span class="hljs-number">0.10539922456186433</span>,
 <span class="hljs-string">&#x27;sys_len&#x27;</span>: <span class="hljs-number">4</span>,
 <span class="hljs-string">&#x27;ref_len&#x27;</span>: <span class="hljs-number">13</span>}`}}),ll=new S({props:{code:`predictions = ["This plugin"]
references = [
    [
        "This plugin allows you to automatically translate web pages between several languages."
    ]
]
metric.compute(predictions=predictions, references=references)`,highlighted:`predictions = [<span class="hljs-string">&quot;This plugin&quot;</span>]
references = [
    [
        <span class="hljs-string">&quot;This plugin allows you to automatically translate web pages between several languages.&quot;</span>
    ]
]
metric.compute(predictions=predictions, references=references)`}}),rl=new S({props:{code:`{'score': 0.0,
 'counts': [2, 1, 0, 0],
 'totals': [2, 1, 0, 0],
 'precisions': [100.0, 100.0, 0.0, 0.0],
 'bp': 0.004086771438464067,
 'sys_len': 2,
 'ref_len': 13}`,highlighted:`{<span class="hljs-string">&#x27;score&#x27;</span>: <span class="hljs-number">0.0</span>,
 <span class="hljs-string">&#x27;counts&#x27;</span>: [<span class="hljs-number">2</span>, <span class="hljs-number">1</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>],
 <span class="hljs-string">&#x27;totals&#x27;</span>: [<span class="hljs-number">2</span>, <span class="hljs-number">1</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>],
 <span class="hljs-string">&#x27;precisions&#x27;</span>: [<span class="hljs-number">100.0</span>, <span class="hljs-number">100.0</span>, <span class="hljs-number">0.0</span>, <span class="hljs-number">0.0</span>],
 <span class="hljs-string">&#x27;bp&#x27;</span>: <span class="hljs-number">0.004086771438464067</span>,
 <span class="hljs-string">&#x27;sys_len&#x27;</span>: <span class="hljs-number">2</span>,
 <span class="hljs-string">&#x27;ref_len&#x27;</span>: <span class="hljs-number">13</span>}`}});const Qo=[ec,Qf],bl=[];function ei(e,n){return e[0]==="tf"?0:1}Et=ei(B),qt=bl[Et]=Qo[Et](B),pl=new S({props:{code:`from huggingface_hub import notebook_login

notebook_login()`,highlighted:`<span class="hljs-keyword">from</span> huggingface_hub <span class="hljs-keyword">import</span> notebook_login

notebook_login()`}}),ol=new S({props:{code:"huggingface-cli login",highlighted:"huggingface-cli login"}});const si=[tc,sc],gl=[];function ti(e,n){return e[0]==="tf"?0:1}xt=ti(B),yt=gl[xt]=si[xt](B);let Me=B[0]==="pt"&&Df();return fl=new S({props:{code:`from transformers import pipeline

# Replace this with your own checkpoint
model_checkpoint = "huggingface-course/marian-finetuned-kde4-en-to-fr"
translator = pipeline("translation", model=model_checkpoint)
translator("Default to expanded threads")`,highlighted:`<span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> pipeline

<span class="hljs-comment"># Replace this with your own checkpoint</span>
model_checkpoint = <span class="hljs-string">&quot;huggingface-course/marian-finetuned-kde4-en-to-fr&quot;</span>
translator = pipeline(<span class="hljs-string">&quot;translation&quot;</span>, model=model_checkpoint)
translator(<span class="hljs-string">&quot;Default to expanded threads&quot;</span>)`}}),cl=new S({props:{code:"[{'translation_text': 'Par d\xE9faut, d\xE9velopper les fils de discussion'}]",highlighted:'[{<span class="hljs-string">&#x27;translation_text&#x27;</span>: <span class="hljs-string">&#x27;Par d\xE9faut, d\xE9velopper les fils de discussion&#x27;</span>}]'}}),ul=new S({props:{code:`translator(
    "Unable to import %1 using the OFX importer plugin. This file is not the correct format."
)`,highlighted:`translator(
    <span class="hljs-string">&quot;Unable to import %1 using the OFX importer plugin. This file is not the correct format.&quot;</span>
)`}}),ml=new S({props:{code:`[{'translation_text': "Impossible d'importer %1 en utilisant le module externe d'importation OFX. Ce fichier n'est pas le bon format."}]`,highlighted:'[{<span class="hljs-string">&#x27;translation_text&#x27;</span>: <span class="hljs-string">&quot;Impossible d&#x27;importer %1 en utilisant le module externe d&#x27;importation OFX. Ce fichier n&#x27;est pas le bon format.&quot;</span>}]'}}),oa=new ua({props:{$$slots:{default:[rc]},$$scope:{ctx:B}}}),{c(){f=p("meta"),$=c(),v(d.$$.fragment),b=c(),L=p("h1"),T=a("\u7FFB\u8BD1"),C=c(),y.c(),A=c(),N=p("p"),x=a("\u73B0\u5728\u8BA9\u6211\u4EEC\u6DF1\u5165\u7814\u7A76\u7FFB\u8BD1\u3002\u8FD9\u662F\u53E6\u4E00\u4E2A"),P=p("a"),H=a("sequence-to-sequence \u4EFB\u52A1"),U=a("\uFF0C\u8FD9\u610F\u5473\u7740\u8FD9\u662F\u4E00\u4E2A\u53EF\u4EE5\u8868\u8FF0\u4E3A\u4ECE\u4E00\u4E2A\u5E8F\u5217\u5230\u53E6\u4E00\u4E2A\u5E8F\u5217\u7684\u95EE\u9898\u3002\u4ECE\u8FD9\u4E2A\u610F\u4E49\u4E0A\u8BF4\uFF0C\u8FD9\u4E2A\u95EE\u9898\u975E\u5E38\u7C7B\u4F3C"),F=p("a"),J=a("\u6587\u672C\u6458\u8981"),K=a("\uFF0C\u5E76\u4E14\u60A8\u53EF\u4EE5\u5C06\u6211\u4EEC\u5C06\u5728\u6B64\u5904\u5B66\u4E60\u5230\u7684\u4E00\u4E9B\u5185\u5BB9\u8FC1\u79FB\u5230\u5176\u4ED6\u7684\u5E8F\u5217\u5230\u5E8F\u5217\u95EE\u9898\uFF0C\u4F8B\u5982\uFF1A"),R=c(),I=p("ul"),X=p("li"),Q=p("strong"),_e=a("\u98CE\u683C\u8FC1\u79FB"),V=a(" : \u521B\u5EFA\u4E00\u4E2A\u6A21\u578B\u5C06\u67D0\u79CD\u98CE\u683C\u8FC1\u79FB\u5230\u4E00\u6BB5\u6587\u672C\uFF08\u4F8B\u5982\uFF0C\u6B63\u5F0F\u7684\u98CE\u683C\u8FC1\u79FB\u5230\u4F11\u95F2\u7684\u98CE\u683C\u6216\u838E\u58EB\u6BD4\u4E9A\u82F1\u8BED\u5230\u73B0\u4EE3\u82F1\u8BED\uFF09"),W=c(),ne=p("li"),Y=p("strong"),Se=a("\u751F\u6210\u95EE\u9898\u7684\u56DE\u7B54"),Te=a(" \uFF1A\u521B\u5EFA\u4E00\u4E2A\u6A21\u578B\uFF0C\u5728\u7ED9\u5B9A\u4E0A\u4E0B\u6587\u7684\u60C5\u51B5\u4E0B\u751F\u6210\u95EE\u9898\u7684\u7B54\u6848"),me=c(),v(Z.$$.fragment),ee=c(),G=p("p"),se=a("\u5982\u679C\u60A8\u6709\u8DB3\u591F\u5927\u7684\u4E24\u79CD\uFF08\u6216\u66F4\u591A\uFF09\u8BED\u8A00\u7684\u6587\u672C\u8BED\u6599\u5E93\uFF0C\u60A8\u53EF\u4EE5\u4ECE\u5934\u5F00\u59CB\u8BAD\u7EC3\u4E00\u4E2A\u65B0\u7684\u7FFB\u8BD1\u6A21\u578B\uFF0C\u5C31\u50CF\u6211\u4EEC\u5728"),de=p("a"),$e=a("\u56E0\u679C\u8BED\u8A00\u5EFA\u6A21"),pe=a("\u90E8\u5206\u4E2D\u6240\u505A\u7684\u90A3\u6837\u3002\u7136\u800C\uFF0C\u5FAE\u8C03\u73B0\u6709\u7684\u7FFB\u8BD1\u6A21\u578B\u4F1A\u66F4\u5FEB\uFF0C\u65E0\u8BBA\u662F\u4ECE\u50CF mT5 \u6216 mBART \u8FD9\u6837\u7684\u591A\u8BED\u8A00\u6A21\u578B\u5FAE\u8C03\u5230\u7279\u5B9A\u7684\u8BED\u8A00\u5BF9\uFF0C\u6216\u8005\u662F\u4E13\u95E8\u7528\u4E8E\u4ECE\u4E00\u79CD\u8BED\u8A00\u7FFB\u8BD1\u6210\u53E6\u4E00\u79CD\u8BED\u8A00\u7684\u6A21\u578B\u3002"),oe=c(),te=p("p"),De=a("\u5728\u672C\u8282\u4E2D\uFF0C\u6211\u4EEC\u5C06\u5BF9"),be=p("a"),Ne=a("KDE4 \u6570\u636E\u96C6"),ge=a("\u4E0A\u7684Marian\u6A21\u578B\u8FDB\u884C\u5FAE\u8C03\uFF0C\u8BE5\u6A21\u578B\u7ECF\u8FC7\u4E86\u4ECE\u82F1\u8BED\u5230\u6CD5\u8BED\u7684\u7FFB\u8BD1\u9884\u8BAD\u7EC3(\u56E0\u4E3A\u5F88\u591A\u201C Hugging Face\u201D\u7684\u5458\u5DE5\u4F1A\u8BF4\u8FD9\u4E24\u79CD\u8BED\u8A00)\uFF0C\u5B83\u662F"),ie=p("a"),fe=a("KDE\u5E94\u7528\u7A0B\u5E8F"),os=a("\u672C\u5730\u5316\u6587\u4EF6\u7684\u6570\u636E\u96C6\u3002\u6211\u4EEC\u5C06\u4F7F\u7528\u7684\u6A21\u578B\u5DF2\u7ECF\u5728\u4ECE"),ce=p("a"),is=a("Opus \u6570\u636E\u96C6"),Be=a("(\u5B9E\u9645\u4E0A\u5305\u542BKDE4\u6570\u636E\u96C6)\u4E2D\u63D0\u53D6\u7684\u6CD5\u8BED\u548C\u82F1\u8BED\u6587\u672C\u7684\u5927\u578B\u8BED\u6599\u5E93\u4E0A\u8FDB\u884C\u4E86\u9884\u5148\u8BAD\u7EC3\u3002\u4F46\u662F\uFF0C\u5373\u4F7F\u6211\u4EEC\u4F7F\u7528\u7684\u9884\u8BAD\u7EC3\u6A21\u578B\u5728\u5176\u9884\u8BAD\u7EC3\u671F\u95F4\u4F7F\u7528\u4E86\u8FD9\u90E8\u5206\u6570\u636E\u96C6\uFF0C\u6211\u4EEC\u4E5F\u4F1A\u770B\u5230\uFF0C\u7ECF\u8FC7\u5FAE\u8C03\u540E\uFF0C\u6211\u4EEC\u53EF\u4EE5\u5F97\u5230\u4E00\u4E2A\u66F4\u597D\u7684\u7248\u672C\u3002"),Re=c(),ve=p("p"),Ae=a("\u5B8C\u6210\u540E\uFF0C\u6211\u4EEC\u5C06\u62E5\u6709\u4E00\u4E2A\u6A21\u578B\uFF0C\u53EF\u4EE5\u8FDB\u884C\u8FD9\u6837\u7684\u7FFB\u8BD1\uFF1A"),ke=c(),ae=p("iframe"),Oe=c(),le=p("iframe"),h=c(),M=p("a"),he=p("img"),Fe=c(),je=p("img"),re=c(),Pe=p("p"),Ke=a("\u4E0E\u524D\u9762\u7684\u90E8\u5206\u4E00\u6837\uFF0C\u60A8\u53EF\u4EE5\u4F7F\u7528\u4EE5\u4E0B\u4EE3\u7801\u627E\u5230\u6211\u4EEC\u5C06\u8BAD\u7EC3\u5E76\u4E0A\u4F20\u5230 Hub \u7684\u5B9E\u9645\u6A21\u578B\uFF0C\u5E76"),Xe=p("a"),fs=a("\u5728\u8FD9\u91CC"),ze=a("\u67E5\u770B\u6A21\u578B\u8F93\u51FA\u7684\u7ED3\u679C"),cs=c(),we=p("h2"),Ge=a("\u51C6\u5907\u6570\u636E"),us=c(),Ee=p("p"),Xs=a("\u4E3A\u4E86\u4ECE\u5934\u5F00\u59CB\u5FAE\u8C03\u6216\u8BAD\u7EC3\u7FFB\u8BD1\u6A21\u578B\uFF0C\u6211\u4EEC\u9700\u8981\u4E00\u4E2A\u9002\u5408\u8BE5\u4EFB\u52A1\u7684\u6570\u636E\u96C6\u3002\u5982\u524D\u6240\u8FF0\uFF0C\u6211\u4EEC\u5C06\u4F7F\u7528"),Ce=p("a"),hs=a("KDE4 \u6570\u636E\u96C6"),We=a("\u5728\u672C\u8282\u4E2D\uFF0C\u4F46\u60A8\u53EF\u4EE5\u5F88\u5BB9\u6613\u5730\u8C03\u6574\u4EE3\u7801\u4EE5\u4F7F\u7528\u60A8\u81EA\u5DF1\u7684\u6570\u636E\uFF0C\u53EA\u8981\u60A8\u6709\u8981\u4E92\u8BD1\u7684\u4E24\u79CD\u8BED\u8A00\u7684\u53E5\u5B50\u5BF9\u3002\u5982\u679C\u60A8\u9700\u8981\u590D\u4E60\u5982\u4F55\u5C06\u81EA\u5B9A\u4E49\u6570\u636E\u52A0\u8F7D\u5230 "),ys=p("strong"),ss=a("Dataset"),Ws=a(" \u53EF\u4EE5\u590D\u4E60\u4E00\u4E0B"),Ye=p("a"),Ts=a("\u7B2C\u4E94\u7AE0"),Ps=a("."),Ys=c(),He=p("h3"),ue=p("a"),Gs=p("span"),v(Ze.$$.fragment),Je=c(),Hs=p("span"),$s=a("KDE4 \u6570\u636E\u96C6"),Zs=c(),ms=p("p"),Ss=a("\u50CF\u5F80\u5E38\u4E00\u6837\uFF0C\u6211\u4EEC\u4F7F\u7528 "),ts=p("strong"),Js=a("load_dataset()"),bs=a(" \u51FD\u6570\uFF1A"),_s=c(),v(as.$$.fragment),qe=c(),ls=p("p"),rs=a("\u5982\u679C\u60A8\u60F3\u4F7F\u7528\u4E0D\u540C\u7684\u8BED\u8A00\u5BF9\uFF0C\u60A8\u53EF\u4EE5\u4F7F\u7528\u5B83\u4EEC\u7684\u4EE3\u7801\u6765\u6307\u5B9A\u5B83\u4EEC\u3002\u8BE5\u6570\u636E\u96C6\u5171\u6709 92 \u79CD\u8BED\u8A00\u53EF\u7528\uFF1B\u60A8\u53EF\u4EE5\u901A\u8FC7"),gs=p("a"),Vs=a("\u6570\u636E\u96C6\u5361\u7247"),ns=a("\u5C55\u5F00\u5176\u4E0A\u7684\u8BED\u8A00\u6807\u7B7E\u6765\u67E5\u770B\u5B83\u4EEC."),Qs=c(),ps=p("img"),z=c(),Us=p("p"),et=a("\u6211\u4EEC\u6765\u770B\u770B\u6570\u636E\u96C6\uFF1A"),ft=c(),v(zs.$$.fragment),Ue=c(),v(Ds.$$.fragment),ct=c(),Le=p("p"),Ie=a("\u6211\u4EEC\u6709 210,173 \u5BF9\u53E5\u5B50\uFF0C\u4F46\u5728\u4E00\u6B21\u8BAD\u7EC3\u8FC7\u7A0B\u4E2D\uFF0C\u6211\u4EEC\u9700\u8981\u521B\u5EFA\u81EA\u5DF1\u7684\u9A8C\u8BC1\u96C6\u3002\u6B63\u5982\u6211\u4EEC\u5728"),xe=p("a"),Is=a("\u7B2C\u4E94\u7AE0"),ut=a("\u5B66\u7684\u7684\u90A3\u6837, "),st=p("strong"),tt=a("Dataset"),Pt=a(" \u6709\u4E00\u4E2A "),at=p("strong"),As=a("train_test_split()"),St=a(" \u65B9\u6CD5,\u53EF\u4EE5\u5E2E\u6211\u4EEC\u62C6\u5206\u6570\u636E\u96C6\u3002\u6211\u4EEC\u5C06\u8BBE\u5B9A\u56FA\u5B9A\u7684\u968F\u673A\u6570\u79CD\u5B50\uFF1A"),mt=c(),v(ks.$$.fragment),js=c(),v(vs.$$.fragment),ws=c(),Ve=p("p"),ye=a("\u6211\u4EEC\u53EF\u4EE5\u5C06 "),lt=p("strong"),rt=a("test"),zt=a(" \u7684\u952E\u91CD\u547D\u540D\u4E3A "),nt=p("strong"),pt=a("validation"),ma=a(" \u50CF\u8FD9\u6837\uFF1A"),Vt=c(),v(Es.$$.fragment),Qt=c(),Dt=p("p"),ea=a("\u73B0\u5728\u8BA9\u6211\u4EEC\u770B\u4E00\u4E0B\u6570\u636E\u96C6\u7684\u4E00\u4E2A\u5143\u7D20\uFF1A"),m=c(),v(O.$$.fragment),_t=c(),v(At.$$.fragment),_a=c(),Wt=p("p"),Ot=a("\u6211\u4EEC\u5F97\u5230\u4E00\u4E2A\u5B57\u5178\uFF0C\u5176\u4E2D\u5305\u542B\u6211\u4EEC\u8BF7\u6C42\u7684\u4E24\u79CD\u8BED\u8A00\u7684\u4E24\u4E2A\u53E5\u5B50\u3002\u8FD9\u4E2A\u5145\u6EE1\u6280\u672F\u8BA1\u7B97\u673A\u79D1\u5B66\u672F\u8BED\u7684\u6570\u636E\u96C6\u7684\u4E00\u4E2A\u7279\u6B8A\u4E4B\u5904\u5728\u4E8E\u5B83\u4EEC\u90FD\u5B8C\u5168\u7528\u6CD5\u8BED\u7FFB\u8BD1\u3002\u7136\u800C\uFF0C\u6CD5\u56FD\u5DE5\u7A0B\u5E08\u901A\u5E38\u5F88\u61D2\u60F0\uFF0C\u5728\u4EA4\u8C08\u65F6\uFF0C\u5927\u591A\u6570\u8BA1\u7B97\u673A\u79D1\u5B66\u4E13\u7528\u8BCD\u6C47\u90FD\u7528\u82F1\u8BED\u8868\u8FF0\u3002\u4F8B\u5982\uFF0C\u201Cthreads\u201D\u8FD9\u4E2A\u8BCD\u5F88\u53EF\u80FD\u51FA\u73B0\u5728\u6CD5\u8BED\u53E5\u5B50\u4E2D\uFF0C\u5C24\u5176\u662F\u5728\u6280\u672F\u5BF9\u8BDD\u4E2D\uFF1B\u4F46\u5728\u8FD9\u4E2A\u6570\u636E\u96C6\u4E2D\uFF0C\u5B83\u88AB\u7FFB\u8BD1\u6210\u66F4\u6B63\u786E\u7684\u201Cfils de Discussion\u201D\u3002\u6211\u4EEC\u4F7F\u7528\u7684\u9884\u8BAD\u7EC3\u6A21\u578B\u5DF2\u7ECF\u5728\u4E00\u4E2A\u66F4\u5927\u7684\u6CD5\u8BED\u548C\u82F1\u8BED\u53E5\u5B50\u8BED\u6599\u5E93\u4E0A\u8FDB\u884C\u4E86\u9884\u8BAD\u7EC3\uFF0C\u91C7\u7528\u4E86\u66F4\u7B80\u5355\u7684\u9009\u62E9\uFF0C\u5373\u4FDD\u7559\u5355\u8BCD\u7684\u539F\u6837:"),da=c(),v(Ct.$$.fragment),ha=c(),v(Lt.$$.fragment),Yt=c(),Zt=p("p"),ot=a(`\u8FD9\u79CD\u60C5\u51B5\u7684\u53E6\u4E00\u4E2A\u4F8B\u5B50\u662F\u201Cplugin\u201D\u8FD9\u4E2A\u8BCD\uFF0C\u5B83\u4E0D\u662F\u6B63\u5F0F\u7684\u6CD5\u8BED\u8BCD\uFF0C\u4F46\u5927\u591A\u6570\u6BCD\u8BED\u4EBA\u58EB\u90FD\u80FD\u7406\u89E3\uFF0C\u4E5F\u4E0D\u4F1A\u8D39\u5FC3\u53BB\u7FFB\u8BD1\u3002
\u5728 KDE4 \u6570\u636E\u96C6\u4E2D\uFF0C\u8FD9\u4E2A\u8BCD\u5728\u6CD5\u8BED\u4E2D\u88AB\u7FFB\u8BD1\u6210\u66F4\u6B63\u5F0F\u7684\u201Cmodule d\u2019extension\u201D\uFF1A`),$a=c(),v(Nt.$$.fragment),ba=c(),v(ds.$$.fragment),ga=c(),Jt=p("p"),ql=a("\u7136\u800C\uFF0C\u6211\u4EEC\u7684\u9884\u8BAD\u7EC3\u6A21\u578B\u575A\u6301\u4F7F\u7528\u7B80\u7EC3\u800C\u719F\u6089\u7684\u82F1\u6587\u5355\u8BCD\uFF1A"),ka=c(),v(Os.$$.fragment),ja=c(),v(Rt.$$.fragment),va=c(),Ms=p("p"),xl=a("\u770B\u770B\u6211\u4EEC\u7684\u5FAE\u8C03\u6A21\u578B\u662F\u5426\u80FD\u8BC6\u522B\u6570\u636E\u96C6\u7684\u8FD9\u4E9B\u7279\u6B8A\u6027\u3002\uFF08\u5267\u900F\u8B66\u544A\uFF1A\u5B83\u4F1A\uFF09\u3002"),wa=c(),v(Cs.$$.fragment),Ea=c(),v(dt.$$.fragment),ht=c(),Ft=p("h3"),yl=a("\u5904\u7406\u6570\u636E"),Bs=c(),v(Gt.$$.fragment),qa=c(),Ks=p("p"),it=a("\u60A8\u73B0\u5728\u5E94\u8BE5\u77E5\u9053\u6211\u4EEC\u7684\u4E0B\u4E00\u6B65\u8BE5\u505A\u4E9B\u4EC0\u4E48\u4E86\uFF1A\u6240\u6709\u6587\u672C\u90FD\u9700\u8981\u8F6C\u6362\u4E3Atoken ID\uFF0C\u4EE5\u4FBF\u6A21\u578B\u80FD\u591F\u7406\u89E3\u5B83\u4EEC\u3002\u5BF9\u4E8E\u8FD9\u4E2A\u4EFB\u52A1\uFF0C\u6211\u4EEC\u9700\u8981\u540C\u65F6\u6807\u8BB0\u8F93\u5165\u548C\u76EE\u6807\u3002\u6211\u4EEC\u7684\u9996\u8981\u4EFB\u52A1\u662F\u521B\u5EFA\u6211\u4EEC\u7684 "),sa=p("strong"),Tl=a("tokenizer"),Pl=a(" \u5BF9\u8C61\u3002\u5982\u524D\u6240\u8FF0\uFF0C\u6211\u4EEC\u5C06\u4F7F\u7528 Marian \u82F1\u8BED\u5230\u6CD5\u8BED\u7684\u9884\u8BAD\u7EC3\u6A21\u578B\u3002\u5982\u679C\u60A8\u4F7F\u7528\u53E6\u4E00\u5BF9\u8BED\u8A00\u5C1D\u8BD5\u6B64\u4EE3\u7801\uFF0C\u8BF7\u786E\u4FDD\u8C03\u6574\u6A21\u578BCheckpoint\u3002"),xa=p("a"),cp=a("Helsinki-NLP"),up=a("\u7EC4\u7EC7\u63D0\u4F9B\u4E86\u591A\u79CD\u8BED\u8A00\u7684\u4E00\u5343\u591A\u79CD\u6A21\u578B\u3002"),Nr=c(),v(ya.$$.fragment),Rr=c(),Ht=p("p"),mp=a("\u60A8\u53EF\u4EE5\u5C06 "),$r=p("strong"),_p=a("model_checkpoint"),dp=a(" \u66F4\u6362\u4E3A"),Ta=p("a"),hp=a("Hub"),$p=a("\u4E0A\u4F60\u559C\u6B22\u7684\u4EFB\u4F55\u5176\u4ED6\u578B\u53F7\uFF0C\u6216\u672C\u5730\u4FDD\u5B58\u7684\u9884\u8BAD\u7EC3\u6A21\u578B\u548C\u6807\u8BB0\u5668\u3002"),Fr=c(),v(ta.$$.fragment),Gr=c(),Sl=p("p"),bp=a("\u6211\u4EEC\u7684\u6570\u636E\u51C6\u5907\u975E\u5E38\u7B80\u5355\u3002 \u53EA\u9700\u8981\u8BB0\u4F4F\u4E00\u4EF6\u4E8B\uFF1A\u60A8\u7167\u5E38\u5904\u7406\u8F93\u5165\uFF0C\u4F46\u5BF9\u4E8E\u8FD9\u6B21\u7684\u8F93\u51FA\u76EE\u6807\uFF0C\u60A8\u9700\u8981\u5C06\u6807\u8BB0\u5668\u5305\u88C5\u5728\u4E0A\u4E0B\u6587\u7BA1\u7406\u5668\u201Cas_target_tokenizer()\u201D\u4E2D\u3002"),Hr=c(),aa=p("p"),gp=a("Python \u4E2D\u7684\u4E0A\u4E0B\u6587\u7BA1\u7406\u5668\u5F15\u5165\u4E86 "),br=p("strong"),kp=a("with"),jp=a(" \u8BED\u53E5\uFF0C\u5F53\u60A8\u6709\u4E24\u4E2A\u76F8\u5173\u7684\u64CD\u4F5C\u8981\u6210\u5BF9\u6267\u884C\u65F6\u5F88\u6709\u7528\u3002\u6700\u5E38\u89C1\u7684\u4F8B\u5B50\u662F\u5F53\u60A8\u5199\u5165\u6216\u8BFB\u53D6\u6587\u4EF6\u65F6\uFF0C\u4E0B\u9762\u662F\u4E00\u4E2A\u4F8B\u5B50\uFF1A"),Ur=c(),v(Pa.$$.fragment),Ir=c(),zl=p("p"),vp=a("\u8FD9\u91CC\u6210\u5BF9\u6267\u884C\u7684\u4E24\u4E2A\u76F8\u5173\u64CD\u4F5C\u662F\u6253\u5F00\u548C\u5173\u95ED\u6587\u4EF6\u7684\u64CD\u4F5C\u3002\u6253\u5F00\u7684\u6587\u4EF6f\u5BF9\u5E94\u7684\u5BF9\u8C61\u53EA\u5728with\u4E0B\u7684\u7F29\u8FDB\u5757\u5185\u6709\u6548\uFF1B\u5728\u8BE5\u5757\u4E4B\u524D\u6253\u5F00\uFF0C\u5728\u8BE5\u5757\u7684\u672B\u5C3E\u5173\u95ED\u3002"),Mr=c(),Dl=p("p"),wp=a("\u5728\u672C\u4F8B\u4E2D\uFF0C\u4E0A\u4E0B\u6587\u7BA1\u7406\u5668 as_target_tokenizer() \u5C06\u5728\u6267\u884C\u7F29\u8FDB\u5757\u4E4B\u524D\u5C06\u6807\u8BB0\u5668\u8BBE\u7F6E\u4E3A\u8F93\u51FA\u8BED\u8A00\uFF08\u6B64\u5904\u4E3A\u6CD5\u8BED\uFF09\uFF0C\u7136\u540E\u5C06\u5176\u8BBE\u7F6E\u56DE\u8F93\u5165\u8BED\u8A00\uFF08\u6B64\u5904\u4E3A\u82F1\u8BED\uFF09\u3002"),Br=c(),Al=p("p"),Ep=a("\u56E0\u6B64\uFF0C\u9884\u5904\u7406\u4E00\u4E2A\u6837\u672C\u5982\u4E0B\u6240\u793A\uFF1A"),Kr=c(),v(Sa.$$.fragment),Xr=c(),Ol=p("p"),qp=a("\u5982\u679C\u6211\u4EEC\u5FD8\u8BB0\u5728\u4E0A\u4E0B\u6587\u7BA1\u7406\u5668\u4E2D\u6807\u8BB0\u76EE\u6807\uFF0C\u5B83\u4EEC\u5C06\u88AB\u8F93\u5165\u6807\u8BB0\u5668\u6807\u8BB0\uFF0C\u5728Marian\u6A21\u578B\u7684\u60C5\u51B5\u4E0B\uFF0C\u4F1A\u5BFC\u81F4\u8F93\u51FA\u7684\u5F02\u5E38\uFF1A"),Wr=c(),v(za.$$.fragment),Yr=c(),v(Da.$$.fragment),Zr=c(),Cl=p("p"),xp=a("\u6B63\u5982\u6211\u4EEC\u6240\u770B\u5230\u7684\uFF0C\u4F7F\u7528\u82F1\u8BED\u6807\u8BB0\u5668\u6765\u9884\u5904\u7406\u6CD5\u8BED\u53E5\u5B50\u4F1A\u4EA7\u751F\u66F4\u591A\u7684\u6807\u8BB0\uFF0C\u56E0\u4E3A\u6807\u8BB0\u5668\u4E0D\u77E5\u9053\u4EFB\u4F55\u6CD5\u8BED\u5355\u8BCD(\u9664\u4E86\u90A3\u4E9B\u4E5F\u51FA\u73B0\u5728\u82F1\u8BED\u8BED\u8A00\u4E2D\u7684\u5355\u8BCD\uFF0C\u6BD4\u5982\u201Cdiscussion\u201D)\u3002"),Jr=c(),$t=p("p"),gr=p("code"),yp=a("inputs"),Tp=a(" \u548C "),kr=p("code"),Pp=a("targets"),Sp=a(" \u90FD\u662F\u5E26\u6709\u6211\u4EEC\u5E38\u7528\u952E\uFF08\u8F93\u5165 ID\u3001\u6CE8\u610F\u63A9\u7801\u7B49\uFF09\u7684\u5B57\u5178\uFF0C\u6240\u4EE5\u6700\u540E\u4E00\u6B65\u662F\u5728\u8F93\u5165\u4E2D\u8BBE\u7F6E\u4E00\u4E2A "),jr=p("code"),zp=a('"labels"'),Dp=a(" \u952E\u3002 \u6211\u4EEC\u5728\u6570\u636E\u96C6\u7684\u9884\u5904\u7406\u51FD\u6570\u4E2D\u6267\u884C\u6B64\u64CD\u4F5C\uFF1A"),Vr=c(),v(Aa.$$.fragment),Qr=c(),Ll=p("p"),Ap=a("\u8BF7\u6CE8\u610F\uFF0C\u6211\u4EEC\u4E3A\u8F93\u5165\u548C\u8F93\u51FA\u8BBE\u7F6E\u4E86\u76F8\u540C\u7684\u6700\u5927\u957F\u5EA6\u3002\u7531\u4E8E\u6211\u4EEC\u5904\u7406\u7684\u6587\u672C\u770B\u8D77\u6765\u5F88\u77ED\uFF0C\u6211\u4EEC\u4F7F\u7528 128\u3002"),en=c(),v(la.$$.fragment),sn=c(),v(ra.$$.fragment),tn=c(),Nl=p("p"),Op=a("\u6211\u4EEC\u73B0\u5728\u53EF\u4EE5\u5BF9\u6570\u636E\u96C6\u7684\u6240\u6709\u6570\u636E\u4E00\u6B21\u6027\u5E94\u7528\u8BE5\u9884\u5904\u7406\uFF1A"),an=c(),v(Oa.$$.fragment),ln=c(),Rl=p("p"),Cp=a("\u73B0\u5728\u6570\u636E\u5DF2\u7ECF\u8FC7\u9884\u5904\u7406\uFF0C\u6211\u4EEC\u51C6\u5907\u597D\u5FAE\u8C03\u6211\u4EEC\u7684\u9884\u8BAD\u7EC3\u6A21\u578B\uFF01"),rn=c(),gt.c(),Fl=c(),Gl=p("p"),Lp=a("\u8BF7\u6CE8\u610F\uFF0C\u8FD9\u6B21\u6211\u4EEC\u4F7F\u7528\u7684\u662F\u5728\u7FFB\u8BD1\u4EFB\u52A1\u4E0A\u8BAD\u7EC3\u8FC7\u7684\u6A21\u578B\uFF0C\u5E76\u4E14\u5B9E\u9645\u4E0A\u5DF2\u7ECF\u53EF\u4EE5\u4F7F\u7528\uFF0C\u56E0\u6B64\u6CA1\u6709\u5173\u4E8E\u4E22\u5931\u6743\u91CD\u6216\u65B0\u521D\u59CB\u5316\u6743\u91CD\u7684\u8B66\u544A\u3002"),nn=c(),Ca=p("h3"),Np=a("\u6570\u636E\u6574\u7406"),pn=c(),Ut=p("p"),Rp=a("\u6211\u4EEC\u9700\u8981\u4E00\u4E2A\u6570\u636E\u6574\u7406\u5668\u6765\u5904\u7406\u52A8\u6001\u6279\u5904\u7406\u7684\u586B\u5145\u3002\u5728\u672C\u4F8B\u4E2D\uFF0C\u6211\u4EEC\u4E0D\u80FD\u50CF"),Hl=p("a"),Fp=a("\u7B2C3\u7AE0"),Gp=a("\u90A3\u6837\u4F7F\u7528\u5E26\u586B\u5145\u7684"),vr=p("strong"),Hp=a("DataCollatorWithPadding"),Up=a("\uFF0C\u56E0\u4E3A\u5B83\u53EA\u586B\u5145\u8F93\u5165\uFF08\u8F93\u5165ID\u3001\u6CE8\u610F\u63A9\u7801\u548C\u4EE4\u724C\u7C7B\u578BID\uFF09\u3002\u6211\u4EEC\u7684\u6807\u7B7E\u4E5F\u5E94\u8BE5\u586B\u5145\u5230\u6807\u7B7E\u4E2D\u9047\u5230\u7684\u6700\u5927\u957F\u5EA6\u3002\u800C\u4E14\uFF0C\u5982\u524D\u6240\u8FF0\uFF0C\u7528\u4E8E\u586B\u5145\u6807\u7B7E\u7684\u586B\u5145\u503C\u5E94\u4E3A-100\uFF0C\u800C\u4E0D\u662F\u6807\u8BB0\u5668\u7684\u586B\u5145\u6807\u8BB0\uFF0C\u4EE5\u786E\u4FDD\u5728\u635F\u5931\u8BA1\u7B97\u4E2D\u5FFD\u7565\u8FD9\u4E9B\u586B\u5145\u503C\u3002"),on=c(),Ls=p("p"),Ip=a("\u8FD9\u4E00\u5207\u90FD\u53EF\u4EE5\u7531 "),La=p("a"),wr=p("code"),Mp=a("DataCollatorForSeq2Seq"),Bp=a(" \u5B8C\u6210\u3002 \u4E0E "),Er=p("code"),Kp=a("DataCollatorWithPadding"),Xp=a(" \u4E00\u6837\uFF0C\u5B83\u91C7\u7528\u7528\u4E8E\u9884\u5904\u7406\u8F93\u5165\u7684"),qr=p("code"),Wp=a("tokenizer"),Yp=a("\uFF0C\u4F46\u5B83\u4E5F\u91C7\u7528"),xr=p("code"),Zp=a("model"),Jp=a("\u3002 \u8FD9\u662F\u56E0\u4E3A\u6570\u636E\u6574\u7406\u5668\u8FD8\u5C06\u8D1F\u8D23\u51C6\u5907\u89E3\u7801\u5668\u8F93\u5165 ID\uFF0C\u5B83\u4EEC\u662F\u6807\u7B7E\u504F\u79FB\u4E4B\u540E\u5F62\u6210\u7684\uFF0C\u5F00\u5934\u5E26\u6709\u7279\u6B8A\u6807\u8BB0\u3002 \u7531\u4E8E\u4E0D\u540C\u67B6\u6784\u7684\u8FD9\u79CD\u8F6C\u53D8\u7565\u6709\u4E0D\u540C\uFF0C\u56E0\u6B64\u201CDataCollatorForSeq2Seq\u201D\u9700\u8981\u77E5\u9053\u201C\u6A21\u578B\u201D\u5BF9\u8C61\uFF1A"),fn=c(),jt.c(),Ul=c(),Il=p("p"),Vp=a("\u4E3A\u4E86\u5728\u51E0\u4E2A\u6837\u672C\u4E0A\u8FDB\u884C\u6D4B\u8BD5\uFF0C\u6211\u4EEC\u53EA\u9700\u5728\u6211\u4EEC\u6807\u8BB0\u5316\u8BAD\u7EC3\u96C6\u4E2D\u7684\u90E8\u5206\u6570\u636E\u4E0A\u8C03\u7528\u5B83\uFF1A"),cn=c(),v(Na.$$.fragment),un=c(),v(Ra.$$.fragment),mn=c(),na=p("p"),Qp=a("\u6211\u4EEC\u53EF\u4EE5\u68C0\u67E5\u6211\u4EEC\u7684\u6807\u7B7E\u662F\u5426\u5DF2\u4F7F\u7528 "),yr=p("strong"),eo=a("-100"),so=a(" \u586B\u5145\u5230\u6279\u6B21\u7684\u6700\u5927\u957F\u5EA6\uFF1A"),_n=c(),v(Fa.$$.fragment),dn=c(),v(Ga.$$.fragment),hn=c(),Ml=p("p"),to=a("\u6211\u4EEC\u8FD8\u53EF\u4EE5\u67E5\u770B\u89E3\u7801\u5668\u8F93\u5165 ID\uFF0C\u770B\u770B\u5B83\u4EEC\u662F\u6807\u7B7E\u7684\u504F\u79FB\u5F62\u6210\u7684\u7248\u672C\uFF1A"),$n=c(),v(Ha.$$.fragment),bn=c(),v(Ua.$$.fragment),gn=c(),Bl=p("p"),ao=a("\u4EE5\u4E0B\u662F\u6211\u4EEC\u6570\u636E\u96C6\u4E2D\u7B2C\u4E00\u4E2A\u548C\u7B2C\u4E8C\u4E2A\u5143\u7D20\u7684\u6807\u7B7E\uFF1A"),kn=c(),v(Ia.$$.fragment),jn=c(),v(Ma.$$.fragment),vn=c(),wt.c(),Kl=c(),Ba=p("h3"),lo=a("\u8BC4\u4F30\u6307\u6807"),wn=c(),v(Ka.$$.fragment),En=c(),qs&&qs.c(),Xl=c(),Ns=p("p"),ro=a("\u7528\u4E8E\u7FFB\u8BD1\u7684\u4F20\u7EDF\u6307\u6807\u662F"),Xa=p("a"),no=a("BLEU \u5206\u6570"),po=a(", \u7531Kishore Papineni\u7B49\u4EBA\u5728"),Wa=p("a"),oo=a("2002\u5E74\u7684\u4E00\u7BC7\u6587\u7AE0"),io=a("\u4E2D\u5F15\u5165\u3002BLEU \u5206\u6570\u8BC4\u4F30\u7FFB\u8BD1\u4E0E\u5176\u6807\u7B7E\u7684\u63A5\u8FD1\u7A0B\u5EA6\u3002\u5B83\u4E0D\u8861\u91CF\u6A21\u578B\u751F\u6210\u8F93\u51FA\u7684\u53EF\u61C2\u5EA6\u6216\u8BED\u6CD5\u6B63\u786E\u6027\uFF0C\u800C\u662F\u4F7F\u7528\u7EDF\u8BA1\u89C4\u5219\u6765\u786E\u4FDD\u751F\u6210\u8F93\u51FA\u4E2D\u7684\u6240\u6709\u5355\u8BCD\u4E5F\u51FA\u73B0\u5728\u76EE\u6807\u4E2D\u3002\u6B64\u5916\uFF0C\u5982\u679C\u76F8\u540C\u5355\u8BCD\u5728\u76EE\u6807\u4E2D\u6CA1\u6709\u91CD\u590D\uFF0C\u5219\u6709\u89C4\u5219\u60E9\u7F5A\u76F8\u540C\u5355\u8BCD\u7684\u91CD\u590D\uFF08\u4EE5\u907F\u514D\u6A21\u578B\u8F93\u51FA\u7C7B\u4F3C "),Tr=p("strong"),fo=a("the the the the the"),co=a("\u7684\u53E5\u5B50 ) \u5E76\u8F93\u51FA\u6BD4\u76EE\u6807\u4E2D\u77ED\u7684\u53E5\u5B50\uFF08\u4EE5\u907F\u514D\u6A21\u578B\u8F93\u51FA\u50CF "),Pr=p("strong"),uo=a("the"),mo=a(" \u8FD9\u6837\u7684\u53E5\u5B50\uFF09\u3002"),qn=c(),pa=p("p"),_o=a("BLEU \u7684\u4E00\u4E2A\u7F3A\u70B9\u662F\u5B83\u9700\u8981\u6587\u672C\u5DF2\u7ECF\u88AB\u5206\u8BCD\uFF0C\u8FD9\u4F7F\u5F97\u6BD4\u8F83\u4F7F\u7528\u4E0D\u540C\u6807\u8BB0\u5668\u7684\u6A21\u578B\u4E4B\u95F4\u7684\u5206\u6570\u53D8\u5F97\u56F0\u96BE\u3002\u56E0\u6B64\uFF0C\u5F53\u4ECA\u7528\u4E8E\u57FA\u51C6\u7FFB\u8BD1\u6A21\u578B\u7684\u6700\u5E38\u7528\u6307\u6807\u662F"),Ya=p("a"),ho=a("SacreBLEU"),$o=a("\uFF0C\u5B83\u901A\u8FC7\u6807\u51C6\u5316\u6807\u8BB0\u5316\u6B65\u9AA4\u89E3\u51B3\u4E86\u8FD9\u4E2A\u7F3A\u70B9\uFF08\u548C\u5176\u4ED6\u7684\u4E00\u4E9B\u7F3A\u70B9\uFF09\u3002\u8981\u4F7F\u7528\u6B64\u6307\u6807\uFF0C\u6211\u4EEC\u9996\u5148\u9700\u8981\u5B89\u88C5 SacreBLEU \u5E93\uFF1A"),xn=c(),v(Za.$$.fragment),yn=c(),It=p("p"),bo=a("\u7136\u540E\u6211\u4EEC\u53EF\u4EE5\u5C31\u50CF\u6211\u4EEC\u5728"),Wl=p("a"),go=a("\u7B2C\u4E09\u7AE0"),ko=a("\u90A3\u6837\u901A\u8FC7 "),Sr=p("strong"),jo=a("load_metric()"),vo=a(" \u52A0\u8F7D\u5B83 \uFF1A"),Tn=c(),v(Ja.$$.fragment),Pn=c(),Yl=p("p"),wo=a("\u8BE5\u6307\u6807\u5C06\u6587\u672C\u4F5C\u4E3A\u8F93\u5165\u548C\u76EE\u6807\u7ED3\u679C\u3002\u5B83\u65E8\u5728\u63A5\u53D7\u591A\u4E2A\u53EF\u63A5\u53D7\u7684\u76EE\u6807\uFF0C\u56E0\u4E3A\u540C\u4E00\u4E2A\u53E5\u5B50\u901A\u5E38\u6709\u591A\u4E2A\u53EF\u63A5\u53D7\u7684\u7FFB\u8BD1\u2014\u2014\u6211\u4EEC\u4F7F\u7528\u7684\u6570\u636E\u96C6\u53EA\u63D0\u4F9B\u4E00\u4E2A\uFF0C\u4F46\u5728 NLP \u4E2D\u627E\u5230\u5C06\u591A\u4E2A\u53E5\u5B50\u4F5C\u4E3A\u6807\u7B7E\u7684\u6570\u636E\u96C6\u4E0D\u662F\u4E00\u4E2A\u96BE\u9898\u3002\u56E0\u6B64\uFF0C\u9884\u6D4B\u7ED3\u679C\u5E94\u8BE5\u662F\u4E00\u4E2A\u53E5\u5B50\u5217\u8868\uFF0C\u800C\u53C2\u8003\u5E94\u8BE5\u662F\u4E00\u4E2A\u53E5\u5B50\u5217\u8868\u7684\u5217\u8868\u3002"),Sn=c(),Zl=p("p"),Eo=a("\u8BA9\u6211\u4EEC\u5C1D\u8BD5\u4E00\u4E2A\u4F8B\u5B50\uFF1A"),zn=c(),v(Va.$$.fragment),Dn=c(),v(Qa.$$.fragment),An=c(),Rs=p("p"),qo=a("\u8FD9\u5F97\u5230\u4E86 46.75 \u7684 BLEU \u5206\u6570\uFF0C\u8FD9\u662F\u76F8\u5F53\u4E0D\u9519\u7684\u2014\u2014\u4F5C\u4E3A\u53C2\u8003\uFF0C\u539F\u59CB Transformer \u6A21\u578B\u5728"),el=p("a"),xo=a("\u201CAttention Is All You Need\u201D \u8BBA\u6587"),yo=a("\u7C7B\u4F3C\u7684\u82F1\u8BED\u548C\u6CD5\u8BED\u7FFB\u8BD1\u4EFB\u52A1\u4E2D\u83B7\u5F97\u4E86 41.8 \u7684 BLEU \u5206\u6570\uFF01 \uFF08\u6709\u5173\u5404\u4E2A\u6307\u6807\u7684\u66F4\u591A\u4FE1\u606F\uFF0C\u4F8B\u5982 "),zr=p("strong"),To=a("counts"),Po=a(" \u548C "),Dr=p("strong"),So=a("bp"),zo=a(" \uFF0C\u89C1"),sl=p("a"),Do=a("SacreBLEU \u4ED3\u5E93"),Ao=a(".) \u53E6\u4E00\u65B9\u9762\uFF0C\u5982\u679C\u6211\u4EEC\u5C1D\u8BD5\u4F7F\u7528\u7FFB\u8BD1\u6A21\u578B\u4E2D\u7ECF\u5E38\u51FA\u73B0\u7684\u4E24\u79CD\u7CDF\u7CD5\u7684\u9884\u6D4B\u7C7B\u578B\uFF08\u5927\u91CF\u91CD\u590D\u6216\u592A\u77ED\uFF09\uFF0C\u6211\u4EEC\u5C06\u5F97\u5230\u76F8\u5F53\u7CDF\u7CD5\u7684 BLEU \u5206\u6570\uFF1A"),On=c(),v(tl.$$.fragment),Cn=c(),v(al.$$.fragment),Ln=c(),v(ll.$$.fragment),Nn=c(),v(rl.$$.fragment),Rn=c(),Jl=p("p"),Oo=a("\u5206\u6570\u53EF\u4EE5\u4ECE 0 \u5230 100\uFF0C\u8D8A\u9AD8\u8D8A\u597D\u3002"),Fn=c(),qt.c(),Vl=c(),Ql=p("p"),Co=a("\u73B0\u5728\u8FD9\u5DF2\u7ECF\u5B8C\u6210\u4E86\uFF0C\u6211\u4EEC\u5DF2\u7ECF\u51C6\u5907\u597D\u5FAE\u8C03\u6211\u4EEC\u7684\u6A21\u578B\u4E86\uFF01"),Gn=c(),nl=p("h3"),Lo=a("\u5FAE\u8C03\u6A21\u578B"),Hn=c(),er=p("p"),No=a("\u7B2C\u4E00\u6B65\u662F\u767B\u5F55 Hugging Face\uFF0C\u8FD9\u6837\u60A8\u5C31\u53EF\u4EE5\u5C06\u7ED3\u679C\u4E0A\u4F20\u5230\u6A21\u578B\u4E2D\u5FC3\u3002\u6709\u4E00\u4E2A\u65B9\u4FBF\u7684\u529F\u80FD\u53EF\u4EE5\u5E2E\u52A9\u60A8\u5728notebook\u4E2D\u5B8C\u6210\u6B64\u64CD\u4F5C\uFF1A"),Un=c(),v(pl.$$.fragment),In=c(),sr=p("p"),Ro=a("\u8FD9\u5C06\u663E\u793A\u4E00\u4E2A\u5C0F\u90E8\u4EF6\uFF0C\u60A8\u53EF\u4EE5\u5728\u5176\u4E2D\u8F93\u5165\u60A8\u7684 Hugging Face \u767B\u5F55\u51ED\u636E\u3002"),Mn=c(),tr=p("p"),Fo=a("\u5982\u679C\u60A8\u4E0D\u662F\u5728notebook\u4E0A\u8FD0\u884C\u4EE3\u7801\uFF0C\u53EA\u9700\u5728\u7EC8\u7AEF\u4E2D\u8F93\u5165\u4EE5\u4E0B\u884C\uFF1A"),Bn=c(),v(ol.$$.fragment),Kn=c(),yt.c(),ar=c(),Me&&Me.c(),lr=c(),il=p("h2"),Go=a("\u4F7F\u7528\u5FAE\u8C03\u540E\u7684\u6A21\u578B"),Xn=c(),rr=p("p"),Ho=a("\u6211\u4EEC\u5DF2\u7ECF\u5411\u60A8\u5C55\u793A\u4E86\u5982\u4F55\u5C06\u6211\u4EEC\u5728\u6A21\u578B\u4E2D\u5FC3\u5FAE\u8C03\u7684\u6A21\u578B\u4E0E\u63A8\u7406\u5C0F\u90E8\u4EF6\u4E00\u8D77\u4F7F\u7528\u3002 \u8981\u5728\u201C\u7BA1\u9053\u201D\u4E2D\u672C\u5730\u4F7F\u7528\u5B83\uFF0C\u6211\u4EEC\u53EA\u9700\u8981\u6307\u5B9A\u6B63\u786E\u7684\u6A21\u578B\u6807\u8BC6\u7B26\uFF1A"),Wn=c(),v(fl.$$.fragment),Yn=c(),v(cl.$$.fragment),Zn=c(),nr=p("p"),Uo=a("\u6B63\u5982\u9884\u671F\u7684\u90A3\u6837\uFF0C\u6211\u4EEC\u7684\u9884\u8BAD\u7EC3\u6A21\u578B\u5C06\u5176\u77E5\u8BC6\u9002\u5E94\u4E86\u6211\u4EEC\u5BF9\u5176\u8FDB\u884C\u5FAE\u8C03\u7684\u8BED\u6599\u5E93\uFF0C\u800C\u4E0D\u662F\u5355\u72EC\u7559\u4E0B\u82F1\u6587\u5355\u8BCD\u201Cthreads\u201D\uFF0C\u800C\u662F\u5C06\u5176\u7FFB\u8BD1\u6210\u6CD5\u8BED\u5B98\u65B9\u7248\u672C\u3002 \u201C\u201D\u7684\u7FFB\u8BD1\u4E5F\u662F\u4E00\u6837\u7684\uFF1A"),Jn=c(),v(ul.$$.fragment),Vn=c(),v(ml.$$.fragment),Qn=c(),pr=p("p"),Io=a("\u98CE\u683C\u9002\u5E94\u7684\u53E6\u4E00\u4E2A\u5F88\u597D\u7684\u4F8B\u5B50\uFF01"),ep=c(),v(oa.$$.fragment),this.h()},l(e){const n=Nf('[data-svelte="svelte-1phssyn"]',document.head);f=o(n,"META",{name:!0,content:!0}),n.forEach(s),$=u(e),w(d.$$.fragment,e),b=u(e),L=o(e,"H1",{id:!0});var Ar=i(L);T=l(Ar,"\u7FFB\u8BD1"),Ar.forEach(s),C=u(e),y.l(e),A=u(e),N=o(e,"P",{});var Mt=i(N);x=l(Mt,"\u73B0\u5728\u8BA9\u6211\u4EEC\u6DF1\u5165\u7814\u7A76\u7FFB\u8BD1\u3002\u8FD9\u662F\u53E6\u4E00\u4E2A"),P=o(Mt,"A",{href:!0});var Or=i(P);H=l(Or,"sequence-to-sequence \u4EFB\u52A1"),Or.forEach(s),U=l(Mt,"\uFF0C\u8FD9\u610F\u5473\u7740\u8FD9\u662F\u4E00\u4E2A\u53EF\u4EE5\u8868\u8FF0\u4E3A\u4ECE\u4E00\u4E2A\u5E8F\u5217\u5230\u53E6\u4E00\u4E2A\u5E8F\u5217\u7684\u95EE\u9898\u3002\u4ECE\u8FD9\u4E2A\u610F\u4E49\u4E0A\u8BF4\uFF0C\u8FD9\u4E2A\u95EE\u9898\u975E\u5E38\u7C7B\u4F3C"),F=o(Mt,"A",{href:!0});var Cr=i(F);J=l(Cr,"\u6587\u672C\u6458\u8981"),Cr.forEach(s),K=l(Mt,"\uFF0C\u5E76\u4E14\u60A8\u53EF\u4EE5\u5C06\u6211\u4EEC\u5C06\u5728\u6B64\u5904\u5B66\u4E60\u5230\u7684\u4E00\u4E9B\u5185\u5BB9\u8FC1\u79FB\u5230\u5176\u4ED6\u7684\u5E8F\u5217\u5230\u5E8F\u5217\u95EE\u9898\uFF0C\u4F8B\u5982\uFF1A"),Mt.forEach(s),R=u(e),I=o(e,"UL",{});var kl=i(I);X=o(kl,"LI",{});var or=i(X);Q=o(or,"STRONG",{});var ir=i(Q);_e=l(ir,"\u98CE\u683C\u8FC1\u79FB"),ir.forEach(s),V=l(or," : \u521B\u5EFA\u4E00\u4E2A\u6A21\u578B\u5C06\u67D0\u79CD\u98CE\u683C\u8FC1\u79FB\u5230\u4E00\u6BB5\u6587\u672C\uFF08\u4F8B\u5982\uFF0C\u6B63\u5F0F\u7684\u98CE\u683C\u8FC1\u79FB\u5230\u4F11\u95F2\u7684\u98CE\u683C\u6216\u838E\u58EB\u6BD4\u4E9A\u82F1\u8BED\u5230\u73B0\u4EE3\u82F1\u8BED\uFF09"),or.forEach(s),W=u(kl),ne=o(kl,"LI",{});var jl=i(ne);Y=o(jl,"STRONG",{});var fr=i(Y);Se=l(fr,"\u751F\u6210\u95EE\u9898\u7684\u56DE\u7B54"),fr.forEach(s),Te=l(jl," \uFF1A\u521B\u5EFA\u4E00\u4E2A\u6A21\u578B\uFF0C\u5728\u7ED9\u5B9A\u4E0A\u4E0B\u6587\u7684\u60C5\u51B5\u4E0B\u751F\u6210\u95EE\u9898\u7684\u7B54\u6848"),jl.forEach(s),kl.forEach(s),me=u(e),w(Z.$$.fragment,e),ee=u(e),G=o(e,"P",{});var ia=i(G);se=l(ia,"\u5982\u679C\u60A8\u6709\u8DB3\u591F\u5927\u7684\u4E24\u79CD\uFF08\u6216\u66F4\u591A\uFF09\u8BED\u8A00\u7684\u6587\u672C\u8BED\u6599\u5E93\uFF0C\u60A8\u53EF\u4EE5\u4ECE\u5934\u5F00\u59CB\u8BAD\u7EC3\u4E00\u4E2A\u65B0\u7684\u7FFB\u8BD1\u6A21\u578B\uFF0C\u5C31\u50CF\u6211\u4EEC\u5728"),de=o(ia,"A",{href:!0});var cr=i(de);$e=l(cr,"\u56E0\u679C\u8BED\u8A00\u5EFA\u6A21"),cr.forEach(s),pe=l(ia,"\u90E8\u5206\u4E2D\u6240\u505A\u7684\u90A3\u6837\u3002\u7136\u800C\uFF0C\u5FAE\u8C03\u73B0\u6709\u7684\u7FFB\u8BD1\u6A21\u578B\u4F1A\u66F4\u5FEB\uFF0C\u65E0\u8BBA\u662F\u4ECE\u50CF mT5 \u6216 mBART \u8FD9\u6837\u7684\u591A\u8BED\u8A00\u6A21\u578B\u5FAE\u8C03\u5230\u7279\u5B9A\u7684\u8BED\u8A00\u5BF9\uFF0C\u6216\u8005\u662F\u4E13\u95E8\u7528\u4E8E\u4ECE\u4E00\u79CD\u8BED\u8A00\u7FFB\u8BD1\u6210\u53E6\u4E00\u79CD\u8BED\u8A00\u7684\u6A21\u578B\u3002"),ia.forEach(s),oe=u(e),te=o(e,"P",{});var Tt=i(te);De=l(Tt,"\u5728\u672C\u8282\u4E2D\uFF0C\u6211\u4EEC\u5C06\u5BF9"),be=o(Tt,"A",{href:!0,rel:!0});var ai=i(be);Ne=l(ai,"KDE4 \u6570\u636E\u96C6"),ai.forEach(s),ge=l(Tt,"\u4E0A\u7684Marian\u6A21\u578B\u8FDB\u884C\u5FAE\u8C03\uFF0C\u8BE5\u6A21\u578B\u7ECF\u8FC7\u4E86\u4ECE\u82F1\u8BED\u5230\u6CD5\u8BED\u7684\u7FFB\u8BD1\u9884\u8BAD\u7EC3(\u56E0\u4E3A\u5F88\u591A\u201C Hugging Face\u201D\u7684\u5458\u5DE5\u4F1A\u8BF4\u8FD9\u4E24\u79CD\u8BED\u8A00)\uFF0C\u5B83\u662F"),ie=o(Tt,"A",{href:!0,rel:!0});var li=i(ie);fe=l(li,"KDE\u5E94\u7528\u7A0B\u5E8F"),li.forEach(s),os=l(Tt,"\u672C\u5730\u5316\u6587\u4EF6\u7684\u6570\u636E\u96C6\u3002\u6211\u4EEC\u5C06\u4F7F\u7528\u7684\u6A21\u578B\u5DF2\u7ECF\u5728\u4ECE"),ce=o(Tt,"A",{href:!0,rel:!0});var ri=i(ce);is=l(ri,"Opus \u6570\u636E\u96C6"),ri.forEach(s),Be=l(Tt,"(\u5B9E\u9645\u4E0A\u5305\u542BKDE4\u6570\u636E\u96C6)\u4E2D\u63D0\u53D6\u7684\u6CD5\u8BED\u548C\u82F1\u8BED\u6587\u672C\u7684\u5927\u578B\u8BED\u6599\u5E93\u4E0A\u8FDB\u884C\u4E86\u9884\u5148\u8BAD\u7EC3\u3002\u4F46\u662F\uFF0C\u5373\u4F7F\u6211\u4EEC\u4F7F\u7528\u7684\u9884\u8BAD\u7EC3\u6A21\u578B\u5728\u5176\u9884\u8BAD\u7EC3\u671F\u95F4\u4F7F\u7528\u4E86\u8FD9\u90E8\u5206\u6570\u636E\u96C6\uFF0C\u6211\u4EEC\u4E5F\u4F1A\u770B\u5230\uFF0C\u7ECF\u8FC7\u5FAE\u8C03\u540E\uFF0C\u6211\u4EEC\u53EF\u4EE5\u5F97\u5230\u4E00\u4E2A\u66F4\u597D\u7684\u7248\u672C\u3002"),Tt.forEach(s),Re=u(e),ve=o(e,"P",{});var ni=i(ve);Ae=l(ni,"\u5B8C\u6210\u540E\uFF0C\u6211\u4EEC\u5C06\u62E5\u6709\u4E00\u4E2A\u6A21\u578B\uFF0C\u53EF\u4EE5\u8FDB\u884C\u8FD9\u6837\u7684\u7FFB\u8BD1\uFF1A"),ni.forEach(s),ke=u(e),ae=o(e,"IFRAME",{src:!0,frameborder:!0,height:!0,title:!0,class:!0,allow:!0,sandbox:!0}),i(ae).forEach(s),Oe=u(e),le=o(e,"IFRAME",{src:!0,frameborder:!0,height:!0,title:!0,class:!0,allow:!0,sandbox:!0}),i(le).forEach(s),h=u(e),M=o(e,"A",{class:!0,href:!0});var tp=i(M);he=o(tp,"IMG",{class:!0,src:!0,alt:!0}),Fe=u(tp),je=o(tp,"IMG",{class:!0,src:!0,alt:!0}),tp.forEach(s),re=u(e),Pe=o(e,"P",{});var ap=i(Pe);Ke=l(ap,"\u4E0E\u524D\u9762\u7684\u90E8\u5206\u4E00\u6837\uFF0C\u60A8\u53EF\u4EE5\u4F7F\u7528\u4EE5\u4E0B\u4EE3\u7801\u627E\u5230\u6211\u4EEC\u5C06\u8BAD\u7EC3\u5E76\u4E0A\u4F20\u5230 Hub \u7684\u5B9E\u9645\u6A21\u578B\uFF0C\u5E76"),Xe=o(ap,"A",{href:!0,rel:!0});var pi=i(Xe);fs=l(pi,"\u5728\u8FD9\u91CC"),pi.forEach(s),ze=l(ap,"\u67E5\u770B\u6A21\u578B\u8F93\u51FA\u7684\u7ED3\u679C"),ap.forEach(s),cs=u(e),we=o(e,"H2",{id:!0});var oi=i(we);Ge=l(oi,"\u51C6\u5907\u6570\u636E"),oi.forEach(s),us=u(e),Ee=o(e,"P",{});var fa=i(Ee);Xs=l(fa,"\u4E3A\u4E86\u4ECE\u5934\u5F00\u59CB\u5FAE\u8C03\u6216\u8BAD\u7EC3\u7FFB\u8BD1\u6A21\u578B\uFF0C\u6211\u4EEC\u9700\u8981\u4E00\u4E2A\u9002\u5408\u8BE5\u4EFB\u52A1\u7684\u6570\u636E\u96C6\u3002\u5982\u524D\u6240\u8FF0\uFF0C\u6211\u4EEC\u5C06\u4F7F\u7528"),Ce=o(fa,"A",{href:!0,rel:!0});var ii=i(Ce);hs=l(ii,"KDE4 \u6570\u636E\u96C6"),ii.forEach(s),We=l(fa,"\u5728\u672C\u8282\u4E2D\uFF0C\u4F46\u60A8\u53EF\u4EE5\u5F88\u5BB9\u6613\u5730\u8C03\u6574\u4EE3\u7801\u4EE5\u4F7F\u7528\u60A8\u81EA\u5DF1\u7684\u6570\u636E\uFF0C\u53EA\u8981\u60A8\u6709\u8981\u4E92\u8BD1\u7684\u4E24\u79CD\u8BED\u8A00\u7684\u53E5\u5B50\u5BF9\u3002\u5982\u679C\u60A8\u9700\u8981\u590D\u4E60\u5982\u4F55\u5C06\u81EA\u5B9A\u4E49\u6570\u636E\u52A0\u8F7D\u5230 "),ys=o(fa,"STRONG",{});var fi=i(ys);ss=l(fi,"Dataset"),fi.forEach(s),Ws=l(fa," \u53EF\u4EE5\u590D\u4E60\u4E00\u4E0B"),Ye=o(fa,"A",{href:!0});var ci=i(Ye);Ts=l(ci,"\u7B2C\u4E94\u7AE0"),ci.forEach(s),Ps=l(fa,"."),fa.forEach(s),Ys=u(e),He=o(e,"H3",{class:!0});var lp=i(He);ue=o(lp,"A",{id:!0,class:!0,href:!0});var ui=i(ue);Gs=o(ui,"SPAN",{});var mi=i(Gs);w(Ze.$$.fragment,mi),mi.forEach(s),ui.forEach(s),Je=u(lp),Hs=o(lp,"SPAN",{});var _i=i(Hs);$s=l(_i,"KDE4 \u6570\u636E\u96C6"),_i.forEach(s),lp.forEach(s),Zs=u(e),ms=o(e,"P",{});var rp=i(ms);Ss=l(rp,"\u50CF\u5F80\u5E38\u4E00\u6837\uFF0C\u6211\u4EEC\u4F7F\u7528 "),ts=o(rp,"STRONG",{});var di=i(ts);Js=l(di,"load_dataset()"),di.forEach(s),bs=l(rp," \u51FD\u6570\uFF1A"),rp.forEach(s),_s=u(e),w(as.$$.fragment,e),qe=u(e),ls=o(e,"P",{});var np=i(ls);rs=l(np,"\u5982\u679C\u60A8\u60F3\u4F7F\u7528\u4E0D\u540C\u7684\u8BED\u8A00\u5BF9\uFF0C\u60A8\u53EF\u4EE5\u4F7F\u7528\u5B83\u4EEC\u7684\u4EE3\u7801\u6765\u6307\u5B9A\u5B83\u4EEC\u3002\u8BE5\u6570\u636E\u96C6\u5171\u6709 92 \u79CD\u8BED\u8A00\u53EF\u7528\uFF1B\u60A8\u53EF\u4EE5\u901A\u8FC7"),gs=o(np,"A",{href:!0,rel:!0});var hi=i(gs);Vs=l(hi,"\u6570\u636E\u96C6\u5361\u7247"),hi.forEach(s),ns=l(np,"\u5C55\u5F00\u5176\u4E0A\u7684\u8BED\u8A00\u6807\u7B7E\u6765\u67E5\u770B\u5B83\u4EEC."),np.forEach(s),Qs=u(e),ps=o(e,"IMG",{src:!0,alt:!0,width:!0}),z=u(e),Us=o(e,"P",{});var $i=i(Us);et=l($i,"\u6211\u4EEC\u6765\u770B\u770B\u6570\u636E\u96C6\uFF1A"),$i.forEach(s),ft=u(e),w(zs.$$.fragment,e),Ue=u(e),w(Ds.$$.fragment,e),ct=u(e),Le=o(e,"P",{});var ca=i(Le);Ie=l(ca,"\u6211\u4EEC\u6709 210,173 \u5BF9\u53E5\u5B50\uFF0C\u4F46\u5728\u4E00\u6B21\u8BAD\u7EC3\u8FC7\u7A0B\u4E2D\uFF0C\u6211\u4EEC\u9700\u8981\u521B\u5EFA\u81EA\u5DF1\u7684\u9A8C\u8BC1\u96C6\u3002\u6B63\u5982\u6211\u4EEC\u5728"),xe=o(ca,"A",{href:!0});var bi=i(xe);Is=l(bi,"\u7B2C\u4E94\u7AE0"),bi.forEach(s),ut=l(ca,"\u5B66\u7684\u7684\u90A3\u6837, "),st=o(ca,"STRONG",{});var gi=i(st);tt=l(gi,"Dataset"),gi.forEach(s),Pt=l(ca," \u6709\u4E00\u4E2A "),at=o(ca,"STRONG",{});var ki=i(at);As=l(ki,"train_test_split()"),ki.forEach(s),St=l(ca," \u65B9\u6CD5,\u53EF\u4EE5\u5E2E\u6211\u4EEC\u62C6\u5206\u6570\u636E\u96C6\u3002\u6211\u4EEC\u5C06\u8BBE\u5B9A\u56FA\u5B9A\u7684\u968F\u673A\u6570\u79CD\u5B50\uFF1A"),ca.forEach(s),mt=u(e),w(ks.$$.fragment,e),js=u(e),w(vs.$$.fragment,e),ws=u(e),Ve=o(e,"P",{});var ur=i(Ve);ye=l(ur,"\u6211\u4EEC\u53EF\u4EE5\u5C06 "),lt=o(ur,"STRONG",{});var ji=i(lt);rt=l(ji,"test"),ji.forEach(s),zt=l(ur," \u7684\u952E\u91CD\u547D\u540D\u4E3A "),nt=o(ur,"STRONG",{});var vi=i(nt);pt=l(vi,"validation"),vi.forEach(s),ma=l(ur," \u50CF\u8FD9\u6837\uFF1A"),ur.forEach(s),Vt=u(e),w(Es.$$.fragment,e),Qt=u(e),Dt=o(e,"P",{});var wi=i(Dt);ea=l(wi,"\u73B0\u5728\u8BA9\u6211\u4EEC\u770B\u4E00\u4E0B\u6570\u636E\u96C6\u7684\u4E00\u4E2A\u5143\u7D20\uFF1A"),wi.forEach(s),m=u(e),w(O.$$.fragment,e),_t=u(e),w(At.$$.fragment,e),_a=u(e),Wt=o(e,"P",{});var Ei=i(Wt);Ot=l(Ei,"\u6211\u4EEC\u5F97\u5230\u4E00\u4E2A\u5B57\u5178\uFF0C\u5176\u4E2D\u5305\u542B\u6211\u4EEC\u8BF7\u6C42\u7684\u4E24\u79CD\u8BED\u8A00\u7684\u4E24\u4E2A\u53E5\u5B50\u3002\u8FD9\u4E2A\u5145\u6EE1\u6280\u672F\u8BA1\u7B97\u673A\u79D1\u5B66\u672F\u8BED\u7684\u6570\u636E\u96C6\u7684\u4E00\u4E2A\u7279\u6B8A\u4E4B\u5904\u5728\u4E8E\u5B83\u4EEC\u90FD\u5B8C\u5168\u7528\u6CD5\u8BED\u7FFB\u8BD1\u3002\u7136\u800C\uFF0C\u6CD5\u56FD\u5DE5\u7A0B\u5E08\u901A\u5E38\u5F88\u61D2\u60F0\uFF0C\u5728\u4EA4\u8C08\u65F6\uFF0C\u5927\u591A\u6570\u8BA1\u7B97\u673A\u79D1\u5B66\u4E13\u7528\u8BCD\u6C47\u90FD\u7528\u82F1\u8BED\u8868\u8FF0\u3002\u4F8B\u5982\uFF0C\u201Cthreads\u201D\u8FD9\u4E2A\u8BCD\u5F88\u53EF\u80FD\u51FA\u73B0\u5728\u6CD5\u8BED\u53E5\u5B50\u4E2D\uFF0C\u5C24\u5176\u662F\u5728\u6280\u672F\u5BF9\u8BDD\u4E2D\uFF1B\u4F46\u5728\u8FD9\u4E2A\u6570\u636E\u96C6\u4E2D\uFF0C\u5B83\u88AB\u7FFB\u8BD1\u6210\u66F4\u6B63\u786E\u7684\u201Cfils de Discussion\u201D\u3002\u6211\u4EEC\u4F7F\u7528\u7684\u9884\u8BAD\u7EC3\u6A21\u578B\u5DF2\u7ECF\u5728\u4E00\u4E2A\u66F4\u5927\u7684\u6CD5\u8BED\u548C\u82F1\u8BED\u53E5\u5B50\u8BED\u6599\u5E93\u4E0A\u8FDB\u884C\u4E86\u9884\u8BAD\u7EC3\uFF0C\u91C7\u7528\u4E86\u66F4\u7B80\u5355\u7684\u9009\u62E9\uFF0C\u5373\u4FDD\u7559\u5355\u8BCD\u7684\u539F\u6837:"),Ei.forEach(s),da=u(e),w(Ct.$$.fragment,e),ha=u(e),w(Lt.$$.fragment,e),Yt=u(e),Zt=o(e,"P",{});var qi=i(Zt);ot=l(qi,`\u8FD9\u79CD\u60C5\u51B5\u7684\u53E6\u4E00\u4E2A\u4F8B\u5B50\u662F\u201Cplugin\u201D\u8FD9\u4E2A\u8BCD\uFF0C\u5B83\u4E0D\u662F\u6B63\u5F0F\u7684\u6CD5\u8BED\u8BCD\uFF0C\u4F46\u5927\u591A\u6570\u6BCD\u8BED\u4EBA\u58EB\u90FD\u80FD\u7406\u89E3\uFF0C\u4E5F\u4E0D\u4F1A\u8D39\u5FC3\u53BB\u7FFB\u8BD1\u3002
\u5728 KDE4 \u6570\u636E\u96C6\u4E2D\uFF0C\u8FD9\u4E2A\u8BCD\u5728\u6CD5\u8BED\u4E2D\u88AB\u7FFB\u8BD1\u6210\u66F4\u6B63\u5F0F\u7684\u201Cmodule d\u2019extension\u201D\uFF1A`),qi.forEach(s),$a=u(e),w(Nt.$$.fragment,e),ba=u(e),w(ds.$$.fragment,e),ga=u(e),Jt=o(e,"P",{});var xi=i(Jt);ql=l(xi,"\u7136\u800C\uFF0C\u6211\u4EEC\u7684\u9884\u8BAD\u7EC3\u6A21\u578B\u575A\u6301\u4F7F\u7528\u7B80\u7EC3\u800C\u719F\u6089\u7684\u82F1\u6587\u5355\u8BCD\uFF1A"),xi.forEach(s),ka=u(e),w(Os.$$.fragment,e),ja=u(e),w(Rt.$$.fragment,e),va=u(e),Ms=o(e,"P",{});var yi=i(Ms);xl=l(yi,"\u770B\u770B\u6211\u4EEC\u7684\u5FAE\u8C03\u6A21\u578B\u662F\u5426\u80FD\u8BC6\u522B\u6570\u636E\u96C6\u7684\u8FD9\u4E9B\u7279\u6B8A\u6027\u3002\uFF08\u5267\u900F\u8B66\u544A\uFF1A\u5B83\u4F1A\uFF09\u3002"),yi.forEach(s),wa=u(e),w(Cs.$$.fragment,e),Ea=u(e),w(dt.$$.fragment,e),ht=u(e),Ft=o(e,"H3",{id:!0});var Ti=i(Ft);yl=l(Ti,"\u5904\u7406\u6570\u636E"),Ti.forEach(s),Bs=u(e),w(Gt.$$.fragment,e),qa=u(e),Ks=o(e,"P",{});var mr=i(Ks);it=l(mr,"\u60A8\u73B0\u5728\u5E94\u8BE5\u77E5\u9053\u6211\u4EEC\u7684\u4E0B\u4E00\u6B65\u8BE5\u505A\u4E9B\u4EC0\u4E48\u4E86\uFF1A\u6240\u6709\u6587\u672C\u90FD\u9700\u8981\u8F6C\u6362\u4E3Atoken ID\uFF0C\u4EE5\u4FBF\u6A21\u578B\u80FD\u591F\u7406\u89E3\u5B83\u4EEC\u3002\u5BF9\u4E8E\u8FD9\u4E2A\u4EFB\u52A1\uFF0C\u6211\u4EEC\u9700\u8981\u540C\u65F6\u6807\u8BB0\u8F93\u5165\u548C\u76EE\u6807\u3002\u6211\u4EEC\u7684\u9996\u8981\u4EFB\u52A1\u662F\u521B\u5EFA\u6211\u4EEC\u7684 "),sa=o(mr,"STRONG",{});var Pi=i(sa);Tl=l(Pi,"tokenizer"),Pi.forEach(s),Pl=l(mr," \u5BF9\u8C61\u3002\u5982\u524D\u6240\u8FF0\uFF0C\u6211\u4EEC\u5C06\u4F7F\u7528 Marian \u82F1\u8BED\u5230\u6CD5\u8BED\u7684\u9884\u8BAD\u7EC3\u6A21\u578B\u3002\u5982\u679C\u60A8\u4F7F\u7528\u53E6\u4E00\u5BF9\u8BED\u8A00\u5C1D\u8BD5\u6B64\u4EE3\u7801\uFF0C\u8BF7\u786E\u4FDD\u8C03\u6574\u6A21\u578BCheckpoint\u3002"),xa=o(mr,"A",{href:!0,rel:!0});var Si=i(xa);cp=l(Si,"Helsinki-NLP"),Si.forEach(s),up=l(mr,"\u7EC4\u7EC7\u63D0\u4F9B\u4E86\u591A\u79CD\u8BED\u8A00\u7684\u4E00\u5343\u591A\u79CD\u6A21\u578B\u3002"),mr.forEach(s),Nr=u(e),w(ya.$$.fragment,e),Rr=u(e),Ht=o(e,"P",{});var _r=i(Ht);mp=l(_r,"\u60A8\u53EF\u4EE5\u5C06 "),$r=o(_r,"STRONG",{});var zi=i($r);_p=l(zi,"model_checkpoint"),zi.forEach(s),dp=l(_r," \u66F4\u6362\u4E3A"),Ta=o(_r,"A",{href:!0,rel:!0});var Di=i(Ta);hp=l(Di,"Hub"),Di.forEach(s),$p=l(_r,"\u4E0A\u4F60\u559C\u6B22\u7684\u4EFB\u4F55\u5176\u4ED6\u578B\u53F7\uFF0C\u6216\u672C\u5730\u4FDD\u5B58\u7684\u9884\u8BAD\u7EC3\u6A21\u578B\u548C\u6807\u8BB0\u5668\u3002"),_r.forEach(s),Fr=u(e),w(ta.$$.fragment,e),Gr=u(e),Sl=o(e,"P",{});var Ai=i(Sl);bp=l(Ai,"\u6211\u4EEC\u7684\u6570\u636E\u51C6\u5907\u975E\u5E38\u7B80\u5355\u3002 \u53EA\u9700\u8981\u8BB0\u4F4F\u4E00\u4EF6\u4E8B\uFF1A\u60A8\u7167\u5E38\u5904\u7406\u8F93\u5165\uFF0C\u4F46\u5BF9\u4E8E\u8FD9\u6B21\u7684\u8F93\u51FA\u76EE\u6807\uFF0C\u60A8\u9700\u8981\u5C06\u6807\u8BB0\u5668\u5305\u88C5\u5728\u4E0A\u4E0B\u6587\u7BA1\u7406\u5668\u201Cas_target_tokenizer()\u201D\u4E2D\u3002"),Ai.forEach(s),Hr=u(e),aa=o(e,"P",{});var pp=i(aa);gp=l(pp,"Python \u4E2D\u7684\u4E0A\u4E0B\u6587\u7BA1\u7406\u5668\u5F15\u5165\u4E86 "),br=o(pp,"STRONG",{});var Oi=i(br);kp=l(Oi,"with"),Oi.forEach(s),jp=l(pp," \u8BED\u53E5\uFF0C\u5F53\u60A8\u6709\u4E24\u4E2A\u76F8\u5173\u7684\u64CD\u4F5C\u8981\u6210\u5BF9\u6267\u884C\u65F6\u5F88\u6709\u7528\u3002\u6700\u5E38\u89C1\u7684\u4F8B\u5B50\u662F\u5F53\u60A8\u5199\u5165\u6216\u8BFB\u53D6\u6587\u4EF6\u65F6\uFF0C\u4E0B\u9762\u662F\u4E00\u4E2A\u4F8B\u5B50\uFF1A"),pp.forEach(s),Ur=u(e),w(Pa.$$.fragment,e),Ir=u(e),zl=o(e,"P",{});var Ci=i(zl);vp=l(Ci,"\u8FD9\u91CC\u6210\u5BF9\u6267\u884C\u7684\u4E24\u4E2A\u76F8\u5173\u64CD\u4F5C\u662F\u6253\u5F00\u548C\u5173\u95ED\u6587\u4EF6\u7684\u64CD\u4F5C\u3002\u6253\u5F00\u7684\u6587\u4EF6f\u5BF9\u5E94\u7684\u5BF9\u8C61\u53EA\u5728with\u4E0B\u7684\u7F29\u8FDB\u5757\u5185\u6709\u6548\uFF1B\u5728\u8BE5\u5757\u4E4B\u524D\u6253\u5F00\uFF0C\u5728\u8BE5\u5757\u7684\u672B\u5C3E\u5173\u95ED\u3002"),Ci.forEach(s),Mr=u(e),Dl=o(e,"P",{});var Li=i(Dl);wp=l(Li,"\u5728\u672C\u4F8B\u4E2D\uFF0C\u4E0A\u4E0B\u6587\u7BA1\u7406\u5668 as_target_tokenizer() \u5C06\u5728\u6267\u884C\u7F29\u8FDB\u5757\u4E4B\u524D\u5C06\u6807\u8BB0\u5668\u8BBE\u7F6E\u4E3A\u8F93\u51FA\u8BED\u8A00\uFF08\u6B64\u5904\u4E3A\u6CD5\u8BED\uFF09\uFF0C\u7136\u540E\u5C06\u5176\u8BBE\u7F6E\u56DE\u8F93\u5165\u8BED\u8A00\uFF08\u6B64\u5904\u4E3A\u82F1\u8BED\uFF09\u3002"),Li.forEach(s),Br=u(e),Al=o(e,"P",{});var Ni=i(Al);Ep=l(Ni,"\u56E0\u6B64\uFF0C\u9884\u5904\u7406\u4E00\u4E2A\u6837\u672C\u5982\u4E0B\u6240\u793A\uFF1A"),Ni.forEach(s),Kr=u(e),w(Sa.$$.fragment,e),Xr=u(e),Ol=o(e,"P",{});var Ri=i(Ol);qp=l(Ri,"\u5982\u679C\u6211\u4EEC\u5FD8\u8BB0\u5728\u4E0A\u4E0B\u6587\u7BA1\u7406\u5668\u4E2D\u6807\u8BB0\u76EE\u6807\uFF0C\u5B83\u4EEC\u5C06\u88AB\u8F93\u5165\u6807\u8BB0\u5668\u6807\u8BB0\uFF0C\u5728Marian\u6A21\u578B\u7684\u60C5\u51B5\u4E0B\uFF0C\u4F1A\u5BFC\u81F4\u8F93\u51FA\u7684\u5F02\u5E38\uFF1A"),Ri.forEach(s),Wr=u(e),w(za.$$.fragment,e),Yr=u(e),w(Da.$$.fragment,e),Zr=u(e),Cl=o(e,"P",{});var Fi=i(Cl);xp=l(Fi,"\u6B63\u5982\u6211\u4EEC\u6240\u770B\u5230\u7684\uFF0C\u4F7F\u7528\u82F1\u8BED\u6807\u8BB0\u5668\u6765\u9884\u5904\u7406\u6CD5\u8BED\u53E5\u5B50\u4F1A\u4EA7\u751F\u66F4\u591A\u7684\u6807\u8BB0\uFF0C\u56E0\u4E3A\u6807\u8BB0\u5668\u4E0D\u77E5\u9053\u4EFB\u4F55\u6CD5\u8BED\u5355\u8BCD(\u9664\u4E86\u90A3\u4E9B\u4E5F\u51FA\u73B0\u5728\u82F1\u8BED\u8BED\u8A00\u4E2D\u7684\u5355\u8BCD\uFF0C\u6BD4\u5982\u201Cdiscussion\u201D)\u3002"),Fi.forEach(s),Jr=u(e),$t=o(e,"P",{});var vl=i($t);gr=o(vl,"CODE",{});var Gi=i(gr);yp=l(Gi,"inputs"),Gi.forEach(s),Tp=l(vl," \u548C "),kr=o(vl,"CODE",{});var Hi=i(kr);Pp=l(Hi,"targets"),Hi.forEach(s),Sp=l(vl," \u90FD\u662F\u5E26\u6709\u6211\u4EEC\u5E38\u7528\u952E\uFF08\u8F93\u5165 ID\u3001\u6CE8\u610F\u63A9\u7801\u7B49\uFF09\u7684\u5B57\u5178\uFF0C\u6240\u4EE5\u6700\u540E\u4E00\u6B65\u662F\u5728\u8F93\u5165\u4E2D\u8BBE\u7F6E\u4E00\u4E2A "),jr=o(vl,"CODE",{});var Ui=i(jr);zp=l(Ui,'"labels"'),Ui.forEach(s),Dp=l(vl," \u952E\u3002 \u6211\u4EEC\u5728\u6570\u636E\u96C6\u7684\u9884\u5904\u7406\u51FD\u6570\u4E2D\u6267\u884C\u6B64\u64CD\u4F5C\uFF1A"),vl.forEach(s),Vr=u(e),w(Aa.$$.fragment,e),Qr=u(e),Ll=o(e,"P",{});var Ii=i(Ll);Ap=l(Ii,"\u8BF7\u6CE8\u610F\uFF0C\u6211\u4EEC\u4E3A\u8F93\u5165\u548C\u8F93\u51FA\u8BBE\u7F6E\u4E86\u76F8\u540C\u7684\u6700\u5927\u957F\u5EA6\u3002\u7531\u4E8E\u6211\u4EEC\u5904\u7406\u7684\u6587\u672C\u770B\u8D77\u6765\u5F88\u77ED\uFF0C\u6211\u4EEC\u4F7F\u7528 128\u3002"),Ii.forEach(s),en=u(e),w(la.$$.fragment,e),sn=u(e),w(ra.$$.fragment,e),tn=u(e),Nl=o(e,"P",{});var Mi=i(Nl);Op=l(Mi,"\u6211\u4EEC\u73B0\u5728\u53EF\u4EE5\u5BF9\u6570\u636E\u96C6\u7684\u6240\u6709\u6570\u636E\u4E00\u6B21\u6027\u5E94\u7528\u8BE5\u9884\u5904\u7406\uFF1A"),Mi.forEach(s),an=u(e),w(Oa.$$.fragment,e),ln=u(e),Rl=o(e,"P",{});var Bi=i(Rl);Cp=l(Bi,"\u73B0\u5728\u6570\u636E\u5DF2\u7ECF\u8FC7\u9884\u5904\u7406\uFF0C\u6211\u4EEC\u51C6\u5907\u597D\u5FAE\u8C03\u6211\u4EEC\u7684\u9884\u8BAD\u7EC3\u6A21\u578B\uFF01"),Bi.forEach(s),rn=u(e),gt.l(e),Fl=u(e),Gl=o(e,"P",{});var Ki=i(Gl);Lp=l(Ki,"\u8BF7\u6CE8\u610F\uFF0C\u8FD9\u6B21\u6211\u4EEC\u4F7F\u7528\u7684\u662F\u5728\u7FFB\u8BD1\u4EFB\u52A1\u4E0A\u8BAD\u7EC3\u8FC7\u7684\u6A21\u578B\uFF0C\u5E76\u4E14\u5B9E\u9645\u4E0A\u5DF2\u7ECF\u53EF\u4EE5\u4F7F\u7528\uFF0C\u56E0\u6B64\u6CA1\u6709\u5173\u4E8E\u4E22\u5931\u6743\u91CD\u6216\u65B0\u521D\u59CB\u5316\u6743\u91CD\u7684\u8B66\u544A\u3002"),Ki.forEach(s),nn=u(e),Ca=o(e,"H3",{id:!0});var Xi=i(Ca);Np=l(Xi,"\u6570\u636E\u6574\u7406"),Xi.forEach(s),pn=u(e),Ut=o(e,"P",{});var dr=i(Ut);Rp=l(dr,"\u6211\u4EEC\u9700\u8981\u4E00\u4E2A\u6570\u636E\u6574\u7406\u5668\u6765\u5904\u7406\u52A8\u6001\u6279\u5904\u7406\u7684\u586B\u5145\u3002\u5728\u672C\u4F8B\u4E2D\uFF0C\u6211\u4EEC\u4E0D\u80FD\u50CF"),Hl=o(dr,"A",{href:!0});var Wi=i(Hl);Fp=l(Wi,"\u7B2C3\u7AE0"),Wi.forEach(s),Gp=l(dr,"\u90A3\u6837\u4F7F\u7528\u5E26\u586B\u5145\u7684"),vr=o(dr,"STRONG",{});var Yi=i(vr);Hp=l(Yi,"DataCollatorWithPadding"),Yi.forEach(s),Up=l(dr,"\uFF0C\u56E0\u4E3A\u5B83\u53EA\u586B\u5145\u8F93\u5165\uFF08\u8F93\u5165ID\u3001\u6CE8\u610F\u63A9\u7801\u548C\u4EE4\u724C\u7C7B\u578BID\uFF09\u3002\u6211\u4EEC\u7684\u6807\u7B7E\u4E5F\u5E94\u8BE5\u586B\u5145\u5230\u6807\u7B7E\u4E2D\u9047\u5230\u7684\u6700\u5927\u957F\u5EA6\u3002\u800C\u4E14\uFF0C\u5982\u524D\u6240\u8FF0\uFF0C\u7528\u4E8E\u586B\u5145\u6807\u7B7E\u7684\u586B\u5145\u503C\u5E94\u4E3A-100\uFF0C\u800C\u4E0D\u662F\u6807\u8BB0\u5668\u7684\u586B\u5145\u6807\u8BB0\uFF0C\u4EE5\u786E\u4FDD\u5728\u635F\u5931\u8BA1\u7B97\u4E2D\u5FFD\u7565\u8FD9\u4E9B\u586B\u5145\u503C\u3002"),dr.forEach(s),on=u(e),Ls=o(e,"P",{});var Bt=i(Ls);Ip=l(Bt,"\u8FD9\u4E00\u5207\u90FD\u53EF\u4EE5\u7531 "),La=o(Bt,"A",{href:!0,rel:!0});var Zi=i(La);wr=o(Zi,"CODE",{});var Ji=i(wr);Mp=l(Ji,"DataCollatorForSeq2Seq"),Ji.forEach(s),Zi.forEach(s),Bp=l(Bt," \u5B8C\u6210\u3002 \u4E0E "),Er=o(Bt,"CODE",{});var Vi=i(Er);Kp=l(Vi,"DataCollatorWithPadding"),Vi.forEach(s),Xp=l(Bt," \u4E00\u6837\uFF0C\u5B83\u91C7\u7528\u7528\u4E8E\u9884\u5904\u7406\u8F93\u5165\u7684"),qr=o(Bt,"CODE",{});var Qi=i(qr);Wp=l(Qi,"tokenizer"),Qi.forEach(s),Yp=l(Bt,"\uFF0C\u4F46\u5B83\u4E5F\u91C7\u7528"),xr=o(Bt,"CODE",{});var ef=i(xr);Zp=l(ef,"model"),ef.forEach(s),Jp=l(Bt,"\u3002 \u8FD9\u662F\u56E0\u4E3A\u6570\u636E\u6574\u7406\u5668\u8FD8\u5C06\u8D1F\u8D23\u51C6\u5907\u89E3\u7801\u5668\u8F93\u5165 ID\uFF0C\u5B83\u4EEC\u662F\u6807\u7B7E\u504F\u79FB\u4E4B\u540E\u5F62\u6210\u7684\uFF0C\u5F00\u5934\u5E26\u6709\u7279\u6B8A\u6807\u8BB0\u3002 \u7531\u4E8E\u4E0D\u540C\u67B6\u6784\u7684\u8FD9\u79CD\u8F6C\u53D8\u7565\u6709\u4E0D\u540C\uFF0C\u56E0\u6B64\u201CDataCollatorForSeq2Seq\u201D\u9700\u8981\u77E5\u9053\u201C\u6A21\u578B\u201D\u5BF9\u8C61\uFF1A"),Bt.forEach(s),fn=u(e),jt.l(e),Ul=u(e),Il=o(e,"P",{});var sf=i(Il);Vp=l(sf,"\u4E3A\u4E86\u5728\u51E0\u4E2A\u6837\u672C\u4E0A\u8FDB\u884C\u6D4B\u8BD5\uFF0C\u6211\u4EEC\u53EA\u9700\u5728\u6211\u4EEC\u6807\u8BB0\u5316\u8BAD\u7EC3\u96C6\u4E2D\u7684\u90E8\u5206\u6570\u636E\u4E0A\u8C03\u7528\u5B83\uFF1A"),sf.forEach(s),cn=u(e),w(Na.$$.fragment,e),un=u(e),w(Ra.$$.fragment,e),mn=u(e),na=o(e,"P",{});var op=i(na);Qp=l(op,"\u6211\u4EEC\u53EF\u4EE5\u68C0\u67E5\u6211\u4EEC\u7684\u6807\u7B7E\u662F\u5426\u5DF2\u4F7F\u7528 "),yr=o(op,"STRONG",{});var tf=i(yr);eo=l(tf,"-100"),tf.forEach(s),so=l(op," \u586B\u5145\u5230\u6279\u6B21\u7684\u6700\u5927\u957F\u5EA6\uFF1A"),op.forEach(s),_n=u(e),w(Fa.$$.fragment,e),dn=u(e),w(Ga.$$.fragment,e),hn=u(e),Ml=o(e,"P",{});var af=i(Ml);to=l(af,"\u6211\u4EEC\u8FD8\u53EF\u4EE5\u67E5\u770B\u89E3\u7801\u5668\u8F93\u5165 ID\uFF0C\u770B\u770B\u5B83\u4EEC\u662F\u6807\u7B7E\u7684\u504F\u79FB\u5F62\u6210\u7684\u7248\u672C\uFF1A"),af.forEach(s),$n=u(e),w(Ha.$$.fragment,e),bn=u(e),w(Ua.$$.fragment,e),gn=u(e),Bl=o(e,"P",{});var lf=i(Bl);ao=l(lf,"\u4EE5\u4E0B\u662F\u6211\u4EEC\u6570\u636E\u96C6\u4E2D\u7B2C\u4E00\u4E2A\u548C\u7B2C\u4E8C\u4E2A\u5143\u7D20\u7684\u6807\u7B7E\uFF1A"),lf.forEach(s),kn=u(e),w(Ia.$$.fragment,e),jn=u(e),w(Ma.$$.fragment,e),vn=u(e),wt.l(e),Kl=u(e),Ba=o(e,"H3",{id:!0});var rf=i(Ba);lo=l(rf,"\u8BC4\u4F30\u6307\u6807"),rf.forEach(s),wn=u(e),w(Ka.$$.fragment,e),En=u(e),qs&&qs.l(e),Xl=u(e),Ns=o(e,"P",{});var Kt=i(Ns);ro=l(Kt,"\u7528\u4E8E\u7FFB\u8BD1\u7684\u4F20\u7EDF\u6307\u6807\u662F"),Xa=o(Kt,"A",{href:!0,rel:!0});var nf=i(Xa);no=l(nf,"BLEU \u5206\u6570"),nf.forEach(s),po=l(Kt,", \u7531Kishore Papineni\u7B49\u4EBA\u5728"),Wa=o(Kt,"A",{href:!0,rel:!0});var pf=i(Wa);oo=l(pf,"2002\u5E74\u7684\u4E00\u7BC7\u6587\u7AE0"),pf.forEach(s),io=l(Kt,"\u4E2D\u5F15\u5165\u3002BLEU \u5206\u6570\u8BC4\u4F30\u7FFB\u8BD1\u4E0E\u5176\u6807\u7B7E\u7684\u63A5\u8FD1\u7A0B\u5EA6\u3002\u5B83\u4E0D\u8861\u91CF\u6A21\u578B\u751F\u6210\u8F93\u51FA\u7684\u53EF\u61C2\u5EA6\u6216\u8BED\u6CD5\u6B63\u786E\u6027\uFF0C\u800C\u662F\u4F7F\u7528\u7EDF\u8BA1\u89C4\u5219\u6765\u786E\u4FDD\u751F\u6210\u8F93\u51FA\u4E2D\u7684\u6240\u6709\u5355\u8BCD\u4E5F\u51FA\u73B0\u5728\u76EE\u6807\u4E2D\u3002\u6B64\u5916\uFF0C\u5982\u679C\u76F8\u540C\u5355\u8BCD\u5728\u76EE\u6807\u4E2D\u6CA1\u6709\u91CD\u590D\uFF0C\u5219\u6709\u89C4\u5219\u60E9\u7F5A\u76F8\u540C\u5355\u8BCD\u7684\u91CD\u590D\uFF08\u4EE5\u907F\u514D\u6A21\u578B\u8F93\u51FA\u7C7B\u4F3C "),Tr=o(Kt,"STRONG",{});var of=i(Tr);fo=l(of,"the the the the the"),of.forEach(s),co=l(Kt,"\u7684\u53E5\u5B50 ) \u5E76\u8F93\u51FA\u6BD4\u76EE\u6807\u4E2D\u77ED\u7684\u53E5\u5B50\uFF08\u4EE5\u907F\u514D\u6A21\u578B\u8F93\u51FA\u50CF "),Pr=o(Kt,"STRONG",{});var ff=i(Pr);uo=l(ff,"the"),ff.forEach(s),mo=l(Kt," \u8FD9\u6837\u7684\u53E5\u5B50\uFF09\u3002"),Kt.forEach(s),qn=u(e),pa=o(e,"P",{});var ip=i(pa);_o=l(ip,"BLEU \u7684\u4E00\u4E2A\u7F3A\u70B9\u662F\u5B83\u9700\u8981\u6587\u672C\u5DF2\u7ECF\u88AB\u5206\u8BCD\uFF0C\u8FD9\u4F7F\u5F97\u6BD4\u8F83\u4F7F\u7528\u4E0D\u540C\u6807\u8BB0\u5668\u7684\u6A21\u578B\u4E4B\u95F4\u7684\u5206\u6570\u53D8\u5F97\u56F0\u96BE\u3002\u56E0\u6B64\uFF0C\u5F53\u4ECA\u7528\u4E8E\u57FA\u51C6\u7FFB\u8BD1\u6A21\u578B\u7684\u6700\u5E38\u7528\u6307\u6807\u662F"),Ya=o(ip,"A",{href:!0,rel:!0});var cf=i(Ya);ho=l(cf,"SacreBLEU"),cf.forEach(s),$o=l(ip,"\uFF0C\u5B83\u901A\u8FC7\u6807\u51C6\u5316\u6807\u8BB0\u5316\u6B65\u9AA4\u89E3\u51B3\u4E86\u8FD9\u4E2A\u7F3A\u70B9\uFF08\u548C\u5176\u4ED6\u7684\u4E00\u4E9B\u7F3A\u70B9\uFF09\u3002\u8981\u4F7F\u7528\u6B64\u6307\u6807\uFF0C\u6211\u4EEC\u9996\u5148\u9700\u8981\u5B89\u88C5 SacreBLEU \u5E93\uFF1A"),ip.forEach(s),xn=u(e),w(Za.$$.fragment,e),yn=u(e),It=o(e,"P",{});var hr=i(It);bo=l(hr,"\u7136\u540E\u6211\u4EEC\u53EF\u4EE5\u5C31\u50CF\u6211\u4EEC\u5728"),Wl=o(hr,"A",{href:!0});var uf=i(Wl);go=l(uf,"\u7B2C\u4E09\u7AE0"),uf.forEach(s),ko=l(hr,"\u90A3\u6837\u901A\u8FC7 "),Sr=o(hr,"STRONG",{});var mf=i(Sr);jo=l(mf,"load_metric()"),mf.forEach(s),vo=l(hr," \u52A0\u8F7D\u5B83 \uFF1A"),hr.forEach(s),Tn=u(e),w(Ja.$$.fragment,e),Pn=u(e),Yl=o(e,"P",{});var _f=i(Yl);wo=l(_f,"\u8BE5\u6307\u6807\u5C06\u6587\u672C\u4F5C\u4E3A\u8F93\u5165\u548C\u76EE\u6807\u7ED3\u679C\u3002\u5B83\u65E8\u5728\u63A5\u53D7\u591A\u4E2A\u53EF\u63A5\u53D7\u7684\u76EE\u6807\uFF0C\u56E0\u4E3A\u540C\u4E00\u4E2A\u53E5\u5B50\u901A\u5E38\u6709\u591A\u4E2A\u53EF\u63A5\u53D7\u7684\u7FFB\u8BD1\u2014\u2014\u6211\u4EEC\u4F7F\u7528\u7684\u6570\u636E\u96C6\u53EA\u63D0\u4F9B\u4E00\u4E2A\uFF0C\u4F46\u5728 NLP \u4E2D\u627E\u5230\u5C06\u591A\u4E2A\u53E5\u5B50\u4F5C\u4E3A\u6807\u7B7E\u7684\u6570\u636E\u96C6\u4E0D\u662F\u4E00\u4E2A\u96BE\u9898\u3002\u56E0\u6B64\uFF0C\u9884\u6D4B\u7ED3\u679C\u5E94\u8BE5\u662F\u4E00\u4E2A\u53E5\u5B50\u5217\u8868\uFF0C\u800C\u53C2\u8003\u5E94\u8BE5\u662F\u4E00\u4E2A\u53E5\u5B50\u5217\u8868\u7684\u5217\u8868\u3002"),_f.forEach(s),Sn=u(e),Zl=o(e,"P",{});var df=i(Zl);Eo=l(df,"\u8BA9\u6211\u4EEC\u5C1D\u8BD5\u4E00\u4E2A\u4F8B\u5B50\uFF1A"),df.forEach(s),zn=u(e),w(Va.$$.fragment,e),Dn=u(e),w(Qa.$$.fragment,e),An=u(e),Rs=o(e,"P",{});var Xt=i(Rs);qo=l(Xt,"\u8FD9\u5F97\u5230\u4E86 46.75 \u7684 BLEU \u5206\u6570\uFF0C\u8FD9\u662F\u76F8\u5F53\u4E0D\u9519\u7684\u2014\u2014\u4F5C\u4E3A\u53C2\u8003\uFF0C\u539F\u59CB Transformer \u6A21\u578B\u5728"),el=o(Xt,"A",{href:!0,rel:!0});var hf=i(el);xo=l(hf,"\u201CAttention Is All You Need\u201D \u8BBA\u6587"),hf.forEach(s),yo=l(Xt,"\u7C7B\u4F3C\u7684\u82F1\u8BED\u548C\u6CD5\u8BED\u7FFB\u8BD1\u4EFB\u52A1\u4E2D\u83B7\u5F97\u4E86 41.8 \u7684 BLEU \u5206\u6570\uFF01 \uFF08\u6709\u5173\u5404\u4E2A\u6307\u6807\u7684\u66F4\u591A\u4FE1\u606F\uFF0C\u4F8B\u5982 "),zr=o(Xt,"STRONG",{});var $f=i(zr);To=l($f,"counts"),$f.forEach(s),Po=l(Xt," \u548C "),Dr=o(Xt,"STRONG",{});var bf=i(Dr);So=l(bf,"bp"),bf.forEach(s),zo=l(Xt," \uFF0C\u89C1"),sl=o(Xt,"A",{href:!0,rel:!0});var gf=i(sl);Do=l(gf,"SacreBLEU \u4ED3\u5E93"),gf.forEach(s),Ao=l(Xt,".) \u53E6\u4E00\u65B9\u9762\uFF0C\u5982\u679C\u6211\u4EEC\u5C1D\u8BD5\u4F7F\u7528\u7FFB\u8BD1\u6A21\u578B\u4E2D\u7ECF\u5E38\u51FA\u73B0\u7684\u4E24\u79CD\u7CDF\u7CD5\u7684\u9884\u6D4B\u7C7B\u578B\uFF08\u5927\u91CF\u91CD\u590D\u6216\u592A\u77ED\uFF09\uFF0C\u6211\u4EEC\u5C06\u5F97\u5230\u76F8\u5F53\u7CDF\u7CD5\u7684 BLEU \u5206\u6570\uFF1A"),Xt.forEach(s),On=u(e),w(tl.$$.fragment,e),Cn=u(e),w(al.$$.fragment,e),Ln=u(e),w(ll.$$.fragment,e),Nn=u(e),w(rl.$$.fragment,e),Rn=u(e),Jl=o(e,"P",{});var kf=i(Jl);Oo=l(kf,"\u5206\u6570\u53EF\u4EE5\u4ECE 0 \u5230 100\uFF0C\u8D8A\u9AD8\u8D8A\u597D\u3002"),kf.forEach(s),Fn=u(e),qt.l(e),Vl=u(e),Ql=o(e,"P",{});var jf=i(Ql);Co=l(jf,"\u73B0\u5728\u8FD9\u5DF2\u7ECF\u5B8C\u6210\u4E86\uFF0C\u6211\u4EEC\u5DF2\u7ECF\u51C6\u5907\u597D\u5FAE\u8C03\u6211\u4EEC\u7684\u6A21\u578B\u4E86\uFF01"),jf.forEach(s),Gn=u(e),nl=o(e,"H3",{id:!0});var vf=i(nl);Lo=l(vf,"\u5FAE\u8C03\u6A21\u578B"),vf.forEach(s),Hn=u(e),er=o(e,"P",{});var wf=i(er);No=l(wf,"\u7B2C\u4E00\u6B65\u662F\u767B\u5F55 Hugging Face\uFF0C\u8FD9\u6837\u60A8\u5C31\u53EF\u4EE5\u5C06\u7ED3\u679C\u4E0A\u4F20\u5230\u6A21\u578B\u4E2D\u5FC3\u3002\u6709\u4E00\u4E2A\u65B9\u4FBF\u7684\u529F\u80FD\u53EF\u4EE5\u5E2E\u52A9\u60A8\u5728notebook\u4E2D\u5B8C\u6210\u6B64\u64CD\u4F5C\uFF1A"),wf.forEach(s),Un=u(e),w(pl.$$.fragment,e),In=u(e),sr=o(e,"P",{});var Ef=i(sr);Ro=l(Ef,"\u8FD9\u5C06\u663E\u793A\u4E00\u4E2A\u5C0F\u90E8\u4EF6\uFF0C\u60A8\u53EF\u4EE5\u5728\u5176\u4E2D\u8F93\u5165\u60A8\u7684 Hugging Face \u767B\u5F55\u51ED\u636E\u3002"),Ef.forEach(s),Mn=u(e),tr=o(e,"P",{});var qf=i(tr);Fo=l(qf,"\u5982\u679C\u60A8\u4E0D\u662F\u5728notebook\u4E0A\u8FD0\u884C\u4EE3\u7801\uFF0C\u53EA\u9700\u5728\u7EC8\u7AEF\u4E2D\u8F93\u5165\u4EE5\u4E0B\u884C\uFF1A"),qf.forEach(s),Bn=u(e),w(ol.$$.fragment,e),Kn=u(e),yt.l(e),ar=u(e),Me&&Me.l(e),lr=u(e),il=o(e,"H2",{id:!0});var xf=i(il);Go=l(xf,"\u4F7F\u7528\u5FAE\u8C03\u540E\u7684\u6A21\u578B"),xf.forEach(s),Xn=u(e),rr=o(e,"P",{});var yf=i(rr);Ho=l(yf,"\u6211\u4EEC\u5DF2\u7ECF\u5411\u60A8\u5C55\u793A\u4E86\u5982\u4F55\u5C06\u6211\u4EEC\u5728\u6A21\u578B\u4E2D\u5FC3\u5FAE\u8C03\u7684\u6A21\u578B\u4E0E\u63A8\u7406\u5C0F\u90E8\u4EF6\u4E00\u8D77\u4F7F\u7528\u3002 \u8981\u5728\u201C\u7BA1\u9053\u201D\u4E2D\u672C\u5730\u4F7F\u7528\u5B83\uFF0C\u6211\u4EEC\u53EA\u9700\u8981\u6307\u5B9A\u6B63\u786E\u7684\u6A21\u578B\u6807\u8BC6\u7B26\uFF1A"),yf.forEach(s),Wn=u(e),w(fl.$$.fragment,e),Yn=u(e),w(cl.$$.fragment,e),Zn=u(e),nr=o(e,"P",{});var Tf=i(nr);Uo=l(Tf,"\u6B63\u5982\u9884\u671F\u7684\u90A3\u6837\uFF0C\u6211\u4EEC\u7684\u9884\u8BAD\u7EC3\u6A21\u578B\u5C06\u5176\u77E5\u8BC6\u9002\u5E94\u4E86\u6211\u4EEC\u5BF9\u5176\u8FDB\u884C\u5FAE\u8C03\u7684\u8BED\u6599\u5E93\uFF0C\u800C\u4E0D\u662F\u5355\u72EC\u7559\u4E0B\u82F1\u6587\u5355\u8BCD\u201Cthreads\u201D\uFF0C\u800C\u662F\u5C06\u5176\u7FFB\u8BD1\u6210\u6CD5\u8BED\u5B98\u65B9\u7248\u672C\u3002 \u201C\u201D\u7684\u7FFB\u8BD1\u4E5F\u662F\u4E00\u6837\u7684\uFF1A"),Tf.forEach(s),Jn=u(e),w(ul.$$.fragment,e),Vn=u(e),w(ml.$$.fragment,e),Qn=u(e),pr=o(e,"P",{});var Pf=i(pr);Io=l(Pf,"\u98CE\u683C\u9002\u5E94\u7684\u53E6\u4E00\u4E2A\u5F88\u597D\u7684\u4F8B\u5B50\uFF01"),Pf.forEach(s),ep=u(e),w(oa.$$.fragment,e),this.h()},h(){j(f,"name","hf:doc:metadata"),j(f,"content",JSON.stringify(pc)),j(L,"id",""),j(P,"href","/course/chapter1/7"),j(F,"href","/course/chapter7/6"),j(de,"href","/course/chapter7/6"),j(be,"href","https://huggingface.co/datasets/kde4"),j(be,"rel","nofollow"),j(ie,"href","https://apps.kde.org/"),j(ie,"rel","nofollow"),j(ce,"href","https://opus.nlpl.eu/"),j(ce,"rel","nofollow"),Lr(ae.src,Qe="https://hf.space/gradioiframe/course-demos/marian-finetuned-kde4-en-to-fr/+")||j(ae,"src",Qe),j(ae,"frameborder","0"),j(ae,"height","350"),j(ae,"title","Gradio app"),j(ae,"class","block dark:hidden container p-0 flex-grow space-iframe"),j(ae,"allow","accelerometer; ambient-light-sensor; autoplay; battery; camera; document-domain; encrypted-media; fullscreen; geolocation; gyroscope; layout-animations; legacy-image-formats; magnetometer; microphone; midi; oversized-images; payment; picture-in-picture; publickey-credentials-get; sync-xhr; usb; vr ; wake-lock; xr-spatial-tracking"),j(ae,"sandbox","allow-forms allow-modals allow-popups allow-popups-to-escape-sandbox allow-same-origin allow-scripts allow-downloads"),Lr(le.src,es="https://hf.space/gradioiframe/course-demos/marian-finetuned-kde4-en-to-fr-darkmode/+")||j(le,"src",es),j(le,"frameborder","0"),j(le,"height","350"),j(le,"title","Gradio app"),j(le,"class","hidden dark:block container p-0 flex-grow space-iframe"),j(le,"allow","accelerometer; ambient-light-sensor; autoplay; battery; camera; document-domain; encrypted-media; fullscreen; geolocation; gyroscope; layout-animations; legacy-image-formats; magnetometer; microphone; midi; oversized-images; payment; picture-in-picture; publickey-credentials-get; sync-xhr; usb; vr ; wake-lock; xr-spatial-tracking"),j(le,"sandbox","allow-forms allow-modals allow-popups allow-popups-to-escape-sandbox allow-same-origin allow-scripts allow-downloads"),j(he,"class","block dark:hidden lg:w-3/5"),Lr(he.src,Fs="https://huggingface.co/datasets/huggingface-course/documentation-images/resolve/main/en/chapter7/modeleval-marian-finetuned-kde4-en-to-fr.png")||j(he,"src",Fs),j(he,"alt","One-hot encoded labels for question answering."),j(je,"class","hidden dark:block lg:w-3/5"),Lr(je.src,xs="https://huggingface.co/datasets/huggingface-course/documentation-images/resolve/main/en/chapter7/modeleval-marian-finetuned-kde4-en-to-fr-dark.png")||j(je,"src",xs),j(je,"alt","One-hot encoded labels for question answering."),j(M,"class","flex justify-center"),j(M,"href","/huggingface-course/marian-finetuned-kde4-en-to-fr"),j(Xe,"href","https://huggingface.co/huggingface-course/marian-finetuned-kde4-en-to-fr?text=This+plugin+allows+you+to+automatically+translate+web+pages+between+several+languages."),j(Xe,"rel","nofollow"),j(we,"id",""),j(Ce,"href","https://huggingface.co/datasets/kde4"),j(Ce,"rel","nofollow"),j(Ye,"href","/course/chapter5"),j(ue,"id","kde4"),j(ue,"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"),j(ue,"href","#kde4"),j(He,"class","relative group"),j(gs,"href","https://huggingface.co/datasets/kde4"),j(gs,"rel","nofollow"),Lr(ps.src,_="https://huggingface.co/datasets/huggingface-course/documentation-images/resolve/main/en/chapter7/language_tags.png")||j(ps,"src",_),j(ps,"alt","Language available for the KDE4 dataset."),j(ps,"width","100%"),j(xe,"href","/course/chapter5"),j(Ft,"id",""),j(xa,"href","https://huggingface.co/Helsinki-NLP"),j(xa,"rel","nofollow"),j(Ta,"href","https://huggingface.co/models"),j(Ta,"rel","nofollow"),j(Ca,"id",""),j(Hl,"href","/course/chapter3"),j(La,"href","https://huggingface.co/transformers/main_classes/data_collator.html#datacollatorforseq2seq"),j(La,"rel","nofollow"),j(Ba,"id",""),j(Xa,"href","https://en.wikipedia.org/wiki/BLEU"),j(Xa,"rel","nofollow"),j(Wa,"href","https://aclanthology.org/P02-1040.pdf"),j(Wa,"rel","nofollow"),j(Ya,"href","https://github.com/mjpost/sacrebleu"),j(Ya,"rel","nofollow"),j(Wl,"href","/course/chapter3"),j(el,"href","https://arxiv.org/pdf/1706.03762.pdf"),j(el,"rel","nofollow"),j(sl,"href","https://github.com/mjpost/sacrebleu/blob/078c440168c6adc89ba75fe6d63f0d922d42bcfe/sacrebleu/metrics/bleu.py#L74"),j(sl,"rel","nofollow"),j(nl,"id",""),j(il,"id","")},m(e,n){t(document.head,f),r(e,$,n),E(d,e,n),r(e,b,n),r(e,L,n),t(L,T),r(e,C,n),_l[D].m(e,n),r(e,A,n),r(e,N,n),t(N,x),t(N,P),t(P,H),t(N,U),t(N,F),t(F,J),t(N,K),r(e,R,n),r(e,I,n),t(I,X),t(X,Q),t(Q,_e),t(X,V),t(I,W),t(I,ne),t(ne,Y),t(Y,Se),t(ne,Te),r(e,me,n),E(Z,e,n),r(e,ee,n),r(e,G,n),t(G,se),t(G,de),t(de,$e),t(G,pe),r(e,oe,n),r(e,te,n),t(te,De),t(te,be),t(be,Ne),t(te,ge),t(te,ie),t(ie,fe),t(te,os),t(te,ce),t(ce,is),t(te,Be),r(e,Re,n),r(e,ve,n),t(ve,Ae),r(e,ke,n),r(e,ae,n),r(e,Oe,n),r(e,le,n),r(e,h,n),r(e,M,n),t(M,he),t(M,Fe),t(M,je),r(e,re,n),r(e,Pe,n),t(Pe,Ke),t(Pe,Xe),t(Xe,fs),t(Pe,ze),r(e,cs,n),r(e,we,n),t(we,Ge),r(e,us,n),r(e,Ee,n),t(Ee,Xs),t(Ee,Ce),t(Ce,hs),t(Ee,We),t(Ee,ys),t(ys,ss),t(Ee,Ws),t(Ee,Ye),t(Ye,Ts),t(Ee,Ps),r(e,Ys,n),r(e,He,n),t(He,ue),t(ue,Gs),E(Ze,Gs,null),t(He,Je),t(He,Hs),t(Hs,$s),r(e,Zs,n),r(e,ms,n),t(ms,Ss),t(ms,ts),t(ts,Js),t(ms,bs),r(e,_s,n),E(as,e,n),r(e,qe,n),r(e,ls,n),t(ls,rs),t(ls,gs),t(gs,Vs),t(ls,ns),r(e,Qs,n),r(e,ps,n),r(e,z,n),r(e,Us,n),t(Us,et),r(e,ft,n),E(zs,e,n),r(e,Ue,n),E(Ds,e,n),r(e,ct,n),r(e,Le,n),t(Le,Ie),t(Le,xe),t(xe,Is),t(Le,ut),t(Le,st),t(st,tt),t(Le,Pt),t(Le,at),t(at,As),t(Le,St),r(e,mt,n),E(ks,e,n),r(e,js,n),E(vs,e,n),r(e,ws,n),r(e,Ve,n),t(Ve,ye),t(Ve,lt),t(lt,rt),t(Ve,zt),t(Ve,nt),t(nt,pt),t(Ve,ma),r(e,Vt,n),E(Es,e,n),r(e,Qt,n),r(e,Dt,n),t(Dt,ea),r(e,m,n),E(O,e,n),r(e,_t,n),E(At,e,n),r(e,_a,n),r(e,Wt,n),t(Wt,Ot),r(e,da,n),E(Ct,e,n),r(e,ha,n),E(Lt,e,n),r(e,Yt,n),r(e,Zt,n),t(Zt,ot),r(e,$a,n),E(Nt,e,n),r(e,ba,n),E(ds,e,n),r(e,ga,n),r(e,Jt,n),t(Jt,ql),r(e,ka,n),E(Os,e,n),r(e,ja,n),E(Rt,e,n),r(e,va,n),r(e,Ms,n),t(Ms,xl),r(e,wa,n),E(Cs,e,n),r(e,Ea,n),E(dt,e,n),r(e,ht,n),r(e,Ft,n),t(Ft,yl),r(e,Bs,n),E(Gt,e,n),r(e,qa,n),r(e,Ks,n),t(Ks,it),t(Ks,sa),t(sa,Tl),t(Ks,Pl),t(Ks,xa),t(xa,cp),t(Ks,up),r(e,Nr,n),E(ya,e,n),r(e,Rr,n),r(e,Ht,n),t(Ht,mp),t(Ht,$r),t($r,_p),t(Ht,dp),t(Ht,Ta),t(Ta,hp),t(Ht,$p),r(e,Fr,n),E(ta,e,n),r(e,Gr,n),r(e,Sl,n),t(Sl,bp),r(e,Hr,n),r(e,aa,n),t(aa,gp),t(aa,br),t(br,kp),t(aa,jp),r(e,Ur,n),E(Pa,e,n),r(e,Ir,n),r(e,zl,n),t(zl,vp),r(e,Mr,n),r(e,Dl,n),t(Dl,wp),r(e,Br,n),r(e,Al,n),t(Al,Ep),r(e,Kr,n),E(Sa,e,n),r(e,Xr,n),r(e,Ol,n),t(Ol,qp),r(e,Wr,n),E(za,e,n),r(e,Yr,n),E(Da,e,n),r(e,Zr,n),r(e,Cl,n),t(Cl,xp),r(e,Jr,n),r(e,$t,n),t($t,gr),t(gr,yp),t($t,Tp),t($t,kr),t(kr,Pp),t($t,Sp),t($t,jr),t(jr,zp),t($t,Dp),r(e,Vr,n),E(Aa,e,n),r(e,Qr,n),r(e,Ll,n),t(Ll,Ap),r(e,en,n),E(la,e,n),r(e,sn,n),E(ra,e,n),r(e,tn,n),r(e,Nl,n),t(Nl,Op),r(e,an,n),E(Oa,e,n),r(e,ln,n),r(e,Rl,n),t(Rl,Cp),r(e,rn,n),dl[bt].m(e,n),r(e,Fl,n),r(e,Gl,n),t(Gl,Lp),r(e,nn,n),r(e,Ca,n),t(Ca,Np),r(e,pn,n),r(e,Ut,n),t(Ut,Rp),t(Ut,Hl),t(Hl,Fp),t(Ut,Gp),t(Ut,vr),t(vr,Hp),t(Ut,Up),r(e,on,n),r(e,Ls,n),t(Ls,Ip),t(Ls,La),t(La,wr),t(wr,Mp),t(Ls,Bp),t(Ls,Er),t(Er,Kp),t(Ls,Xp),t(Ls,qr),t(qr,Wp),t(Ls,Yp),t(Ls,xr),t(xr,Zp),t(Ls,Jp),r(e,fn,n),hl[kt].m(e,n),r(e,Ul,n),r(e,Il,n),t(Il,Vp),r(e,cn,n),E(Na,e,n),r(e,un,n),E(Ra,e,n),r(e,mn,n),r(e,na,n),t(na,Qp),t(na,yr),t(yr,eo),t(na,so),r(e,_n,n),E(Fa,e,n),r(e,dn,n),E(Ga,e,n),r(e,hn,n),r(e,Ml,n),t(Ml,to),r(e,$n,n),E(Ha,e,n),r(e,bn,n),E(Ua,e,n),r(e,gn,n),r(e,Bl,n),t(Bl,ao),r(e,kn,n),E(Ia,e,n),r(e,jn,n),E(Ma,e,n),r(e,vn,n),$l[vt].m(e,n),r(e,Kl,n),r(e,Ba,n),t(Ba,lo),r(e,wn,n),E(Ka,e,n),r(e,En,n),qs&&qs.m(e,n),r(e,Xl,n),r(e,Ns,n),t(Ns,ro),t(Ns,Xa),t(Xa,no),t(Ns,po),t(Ns,Wa),t(Wa,oo),t(Ns,io),t(Ns,Tr),t(Tr,fo),t(Ns,co),t(Ns,Pr),t(Pr,uo),t(Ns,mo),r(e,qn,n),r(e,pa,n),t(pa,_o),t(pa,Ya),t(Ya,ho),t(pa,$o),r(e,xn,n),E(Za,e,n),r(e,yn,n),r(e,It,n),t(It,bo),t(It,Wl),t(Wl,go),t(It,ko),t(It,Sr),t(Sr,jo),t(It,vo),r(e,Tn,n),E(Ja,e,n),r(e,Pn,n),r(e,Yl,n),t(Yl,wo),r(e,Sn,n),r(e,Zl,n),t(Zl,Eo),r(e,zn,n),E(Va,e,n),r(e,Dn,n),E(Qa,e,n),r(e,An,n),r(e,Rs,n),t(Rs,qo),t(Rs,el),t(el,xo),t(Rs,yo),t(Rs,zr),t(zr,To),t(Rs,Po),t(Rs,Dr),t(Dr,So),t(Rs,zo),t(Rs,sl),t(sl,Do),t(Rs,Ao),r(e,On,n),E(tl,e,n),r(e,Cn,n),E(al,e,n),r(e,Ln,n),E(ll,e,n),r(e,Nn,n),E(rl,e,n),r(e,Rn,n),r(e,Jl,n),t(Jl,Oo),r(e,Fn,n),bl[Et].m(e,n),r(e,Vl,n),r(e,Ql,n),t(Ql,Co),r(e,Gn,n),r(e,nl,n),t(nl,Lo),r(e,Hn,n),r(e,er,n),t(er,No),r(e,Un,n),E(pl,e,n),r(e,In,n),r(e,sr,n),t(sr,Ro),r(e,Mn,n),r(e,tr,n),t(tr,Fo),r(e,Bn,n),E(ol,e,n),r(e,Kn,n),gl[xt].m(e,n),r(e,ar,n),Me&&Me.m(e,n),r(e,lr,n),r(e,il,n),t(il,Go),r(e,Xn,n),r(e,rr,n),t(rr,Ho),r(e,Wn,n),E(fl,e,n),r(e,Yn,n),E(cl,e,n),r(e,Zn,n),r(e,nr,n),t(nr,Uo),r(e,Jn,n),E(ul,e,n),r(e,Vn,n),E(ml,e,n),r(e,Qn,n),r(e,pr,n),t(pr,Io),r(e,ep,n),E(oa,e,n),sp=!0},p(e,[n]){const Ar={};n&1&&(Ar.fw=e[0]),d.$set(Ar);let Mt=D;D=Ko(e),D!==Mt&&(El(),k(_l[Mt],1,1,()=>{_l[Mt]=null}),wl(),y=_l[D],y||(y=_l[D]=Bo[D](e),y.c()),g(y,1),y.m(A.parentNode,A));const Or={};n&2&&(Or.$$scope={dirty:n,ctx:e}),dt.$set(Or);const Cr={};n&2&&(Cr.$$scope={dirty:n,ctx:e}),ta.$set(Cr);const kl={};n&2&&(kl.$$scope={dirty:n,ctx:e}),la.$set(kl);const or={};n&2&&(or.$$scope={dirty:n,ctx:e}),ra.$set(or);let ir=bt;bt=Wo(e),bt!==ir&&(El(),k(dl[ir],1,1,()=>{dl[ir]=null}),wl(),gt=dl[bt],gt||(gt=dl[bt]=Xo[bt](e),gt.c()),g(gt,1),gt.m(Fl.parentNode,Fl));let jl=kt;kt=Zo(e),kt!==jl&&(El(),k(hl[jl],1,1,()=>{hl[jl]=null}),wl(),jt=hl[kt],jt||(jt=hl[kt]=Yo[kt](e),jt.c()),g(jt,1),jt.m(Ul.parentNode,Ul));let fr=vt;vt=Vo(e),vt!==fr&&(El(),k($l[fr],1,1,()=>{$l[fr]=null}),wl(),wt=$l[vt],wt||(wt=$l[vt]=Jo[vt](e),wt.c()),g(wt,1),wt.m(Kl.parentNode,Kl)),e[0]==="pt"?qs||(qs=zf(),qs.c(),qs.m(Xl.parentNode,Xl)):qs&&(qs.d(1),qs=null);let ia=Et;Et=ei(e),Et!==ia&&(El(),k(bl[ia],1,1,()=>{bl[ia]=null}),wl(),qt=bl[Et],qt||(qt=bl[Et]=Qo[Et](e),qt.c()),g(qt,1),qt.m(Vl.parentNode,Vl));let cr=xt;xt=ti(e),xt!==cr&&(El(),k(gl[cr],1,1,()=>{gl[cr]=null}),wl(),yt=gl[xt],yt||(yt=gl[xt]=si[xt](e),yt.c()),g(yt,1),yt.m(ar.parentNode,ar)),e[0]==="pt"?Me?n&1&&g(Me,1):(Me=Df(),Me.c(),g(Me,1),Me.m(lr.parentNode,lr)):Me&&(El(),k(Me,1,1,()=>{Me=null}),wl());const Tt={};n&2&&(Tt.$$scope={dirty:n,ctx:e}),oa.$set(Tt)},i(e){sp||(g(d.$$.fragment,e),g(y),g(Z.$$.fragment,e),g(Ze.$$.fragment,e),g(as.$$.fragment,e),g(zs.$$.fragment,e),g(Ds.$$.fragment,e),g(ks.$$.fragment,e),g(vs.$$.fragment,e),g(Es.$$.fragment,e),g(O.$$.fragment,e),g(At.$$.fragment,e),g(Ct.$$.fragment,e),g(Lt.$$.fragment,e),g(Nt.$$.fragment,e),g(ds.$$.fragment,e),g(Os.$$.fragment,e),g(Rt.$$.fragment,e),g(Cs.$$.fragment,e),g(dt.$$.fragment,e),g(Gt.$$.fragment,e),g(ya.$$.fragment,e),g(ta.$$.fragment,e),g(Pa.$$.fragment,e),g(Sa.$$.fragment,e),g(za.$$.fragment,e),g(Da.$$.fragment,e),g(Aa.$$.fragment,e),g(la.$$.fragment,e),g(ra.$$.fragment,e),g(Oa.$$.fragment,e),g(gt),g(jt),g(Na.$$.fragment,e),g(Ra.$$.fragment,e),g(Fa.$$.fragment,e),g(Ga.$$.fragment,e),g(Ha.$$.fragment,e),g(Ua.$$.fragment,e),g(Ia.$$.fragment,e),g(Ma.$$.fragment,e),g(wt),g(Ka.$$.fragment,e),g(Za.$$.fragment,e),g(Ja.$$.fragment,e),g(Va.$$.fragment,e),g(Qa.$$.fragment,e),g(tl.$$.fragment,e),g(al.$$.fragment,e),g(ll.$$.fragment,e),g(rl.$$.fragment,e),g(qt),g(pl.$$.fragment,e),g(ol.$$.fragment,e),g(yt),g(Me),g(fl.$$.fragment,e),g(cl.$$.fragment,e),g(ul.$$.fragment,e),g(ml.$$.fragment,e),g(oa.$$.fragment,e),sp=!0)},o(e){k(d.$$.fragment,e),k(y),k(Z.$$.fragment,e),k(Ze.$$.fragment,e),k(as.$$.fragment,e),k(zs.$$.fragment,e),k(Ds.$$.fragment,e),k(ks.$$.fragment,e),k(vs.$$.fragment,e),k(Es.$$.fragment,e),k(O.$$.fragment,e),k(At.$$.fragment,e),k(Ct.$$.fragment,e),k(Lt.$$.fragment,e),k(Nt.$$.fragment,e),k(ds.$$.fragment,e),k(Os.$$.fragment,e),k(Rt.$$.fragment,e),k(Cs.$$.fragment,e),k(dt.$$.fragment,e),k(Gt.$$.fragment,e),k(ya.$$.fragment,e),k(ta.$$.fragment,e),k(Pa.$$.fragment,e),k(Sa.$$.fragment,e),k(za.$$.fragment,e),k(Da.$$.fragment,e),k(Aa.$$.fragment,e),k(la.$$.fragment,e),k(ra.$$.fragment,e),k(Oa.$$.fragment,e),k(gt),k(jt),k(Na.$$.fragment,e),k(Ra.$$.fragment,e),k(Fa.$$.fragment,e),k(Ga.$$.fragment,e),k(Ha.$$.fragment,e),k(Ua.$$.fragment,e),k(Ia.$$.fragment,e),k(Ma.$$.fragment,e),k(wt),k(Ka.$$.fragment,e),k(Za.$$.fragment,e),k(Ja.$$.fragment,e),k(Va.$$.fragment,e),k(Qa.$$.fragment,e),k(tl.$$.fragment,e),k(al.$$.fragment,e),k(ll.$$.fragment,e),k(rl.$$.fragment,e),k(qt),k(pl.$$.fragment,e),k(ol.$$.fragment,e),k(yt),k(Me),k(fl.$$.fragment,e),k(cl.$$.fragment,e),k(ul.$$.fragment,e),k(ml.$$.fragment,e),k(oa.$$.fragment,e),sp=!1},d(e){s(f),e&&s($),q(d,e),e&&s(b),e&&s(L),e&&s(C),_l[D].d(e),e&&s(A),e&&s(N),e&&s(R),e&&s(I),e&&s(me),q(Z,e),e&&s(ee),e&&s(G),e&&s(oe),e&&s(te),e&&s(Re),e&&s(ve),e&&s(ke),e&&s(ae),e&&s(Oe),e&&s(le),e&&s(h),e&&s(M),e&&s(re),e&&s(Pe),e&&s(cs),e&&s(we),e&&s(us),e&&s(Ee),e&&s(Ys),e&&s(He),q(Ze),e&&s(Zs),e&&s(ms),e&&s(_s),q(as,e),e&&s(qe),e&&s(ls),e&&s(Qs),e&&s(ps),e&&s(z),e&&s(Us),e&&s(ft),q(zs,e),e&&s(Ue),q(Ds,e),e&&s(ct),e&&s(Le),e&&s(mt),q(ks,e),e&&s(js),q(vs,e),e&&s(ws),e&&s(Ve),e&&s(Vt),q(Es,e),e&&s(Qt),e&&s(Dt),e&&s(m),q(O,e),e&&s(_t),q(At,e),e&&s(_a),e&&s(Wt),e&&s(da),q(Ct,e),e&&s(ha),q(Lt,e),e&&s(Yt),e&&s(Zt),e&&s($a),q(Nt,e),e&&s(ba),q(ds,e),e&&s(ga),e&&s(Jt),e&&s(ka),q(Os,e),e&&s(ja),q(Rt,e),e&&s(va),e&&s(Ms),e&&s(wa),q(Cs,e),e&&s(Ea),q(dt,e),e&&s(ht),e&&s(Ft),e&&s(Bs),q(Gt,e),e&&s(qa),e&&s(Ks),e&&s(Nr),q(ya,e),e&&s(Rr),e&&s(Ht),e&&s(Fr),q(ta,e),e&&s(Gr),e&&s(Sl),e&&s(Hr),e&&s(aa),e&&s(Ur),q(Pa,e),e&&s(Ir),e&&s(zl),e&&s(Mr),e&&s(Dl),e&&s(Br),e&&s(Al),e&&s(Kr),q(Sa,e),e&&s(Xr),e&&s(Ol),e&&s(Wr),q(za,e),e&&s(Yr),q(Da,e),e&&s(Zr),e&&s(Cl),e&&s(Jr),e&&s($t),e&&s(Vr),q(Aa,e),e&&s(Qr),e&&s(Ll),e&&s(en),q(la,e),e&&s(sn),q(ra,e),e&&s(tn),e&&s(Nl),e&&s(an),q(Oa,e),e&&s(ln),e&&s(Rl),e&&s(rn),dl[bt].d(e),e&&s(Fl),e&&s(Gl),e&&s(nn),e&&s(Ca),e&&s(pn),e&&s(Ut),e&&s(on),e&&s(Ls),e&&s(fn),hl[kt].d(e),e&&s(Ul),e&&s(Il),e&&s(cn),q(Na,e),e&&s(un),q(Ra,e),e&&s(mn),e&&s(na),e&&s(_n),q(Fa,e),e&&s(dn),q(Ga,e),e&&s(hn),e&&s(Ml),e&&s($n),q(Ha,e),e&&s(bn),q(Ua,e),e&&s(gn),e&&s(Bl),e&&s(kn),q(Ia,e),e&&s(jn),q(Ma,e),e&&s(vn),$l[vt].d(e),e&&s(Kl),e&&s(Ba),e&&s(wn),q(Ka,e),e&&s(En),qs&&qs.d(e),e&&s(Xl),e&&s(Ns),e&&s(qn),e&&s(pa),e&&s(xn),q(Za,e),e&&s(yn),e&&s(It),e&&s(Tn),q(Ja,e),e&&s(Pn),e&&s(Yl),e&&s(Sn),e&&s(Zl),e&&s(zn),q(Va,e),e&&s(Dn),q(Qa,e),e&&s(An),e&&s(Rs),e&&s(On),q(tl,e),e&&s(Cn),q(al,e),e&&s(Ln),q(ll,e),e&&s(Nn),q(rl,e),e&&s(Rn),e&&s(Jl),e&&s(Fn),bl[Et].d(e),e&&s(Vl),e&&s(Ql),e&&s(Gn),e&&s(nl),e&&s(Hn),e&&s(er),e&&s(Un),q(pl,e),e&&s(In),e&&s(sr),e&&s(Mn),e&&s(tr),e&&s(Bn),q(ol,e),e&&s(Kn),gl[xt].d(e),e&&s(ar),Me&&Me.d(e),e&&s(lr),e&&s(il),e&&s(Xn),e&&s(rr),e&&s(Wn),q(fl,e),e&&s(Yn),q(cl,e),e&&s(Zn),e&&s(nr),e&&s(Jn),q(ul,e),e&&s(Vn),q(ml,e),e&&s(Qn),e&&s(pr),e&&s(ep),q(oa,e)}}}const pc={local:"",sections:[{local:"",sections:[{local:"kde4",title:"KDE4 \u6570\u636E\u96C6"},{local:"",title:"\u5904\u7406\u6570\u636E"}],title:"\u51C6\u5907\u6570\u636E"},{local:"trainer-api",title:"\u4F7F\u7528 Trainer API \u5FAE\u8C03\u6A21\u578B"},{local:"keras",sections:[{local:"",title:"\u6570\u636E\u6574\u7406"},{local:"",title:"\u8BC4\u4F30\u6307\u6807"},{local:"",title:"\u5FAE\u8C03\u6A21\u578B"}],title:"\u4F7F\u7528 Keras \u5FAE\u8C03\u6A21\u578B"},{local:"",sections:[{local:"",title:"\u51C6\u5907\u8BAD\u7EC3\u6240\u9700\u7684\u4E00\u5207"},{local:"",title:"\u8BAD\u7EC3\u5FAA\u73AF"}],title:"\u81EA\u5B9A\u4E49\u8BAD\u7EC3\u5FAA\u73AF"},{local:"",title:"\u4F7F\u7528\u5FAE\u8C03\u540E\u7684\u6A21\u578B"}],title:"\u7FFB\u8BD1"};function oc(B,f,$){let d="pt";return Rf(()=>{const b=new URLSearchParams(window.location.search);$(0,d=b.get("fw")||"pt")}),[d]}class hc extends Of{constructor(f){super();Cf(this,f,oc,nc,Lf,{})}}export{hc as default,pc as metadata};
