import{S as pu,i as uu,s as mu,e as l,t as s,k as p,c,a as r,h as a,d as t,m as u,b as f,g as h,G as e,w as y,x as j,y as E,q as b,o as v,B as w,M as gu,N as pr,p as Qa,v as du,n as nh,L as cu}from"../../chunks/vendor-hf-doc-builder.js";import{T as Ys}from"../../chunks/Tip-hf-doc-builder.js";import{Y as ur}from"../../chunks/Youtube-hf-doc-builder.js";import{I as pe}from"../../chunks/IconCopyLink-hf-doc-builder.js";import{C as A}from"../../chunks/CodeBlock-hf-doc-builder.js";import{D as ou}from"../../chunks/DocNotebookDropdown-hf-doc-builder.js";import{F as fu}from"../../chunks/FrameworkSwitchCourse-hf-doc-builder.js";function _u(V){let o,$;return o=new ou({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/vi/chapter7/section4_tf.ipynb"},{label:"Aws Studio",value:"https://studiolab.sagemaker.aws/import/github/huggingface/notebooks/blob/master/course/vi/chapter7/section4_tf.ipynb"}]}}),{c(){y(o.$$.fragment)},l(d){j(o.$$.fragment,d)},m(d,x){E(o,d,x),$=!0},i(d){$||(b(o.$$.fragment,d),$=!0)},o(d){v(o.$$.fragment,d),$=!1},d(d){w(o,d)}}}function bu(V){let o,$;return o=new ou({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/vi/chapter7/section4_pt.ipynb"},{label:"Aws Studio",value:"https://studiolab.sagemaker.aws/import/github/huggingface/notebooks/blob/master/course/vi/chapter7/section4_pt.ipynb"}]}}),{c(){y(o.$$.fragment)},l(d){j(o.$$.fragment,d)},m(d,x){E(o,d,x),$=!0},i(d){$||(b(o.$$.fragment,d),$=!0)},o(d){v(o.$$.fragment,d),$=!1},d(d){w(o,d)}}}function vu(V){let o,$,d,x,z;return{c(){o=l("p"),$=s("\u270F\uFE0F "),d=l("strong"),x=s("\u0110\u1EBFn l\u01B0\u1EE3t b\u1EA1n!"),z=s(" M\u1ED9t t\u1EEB ti\u1EBFng Anh kh\xE1c th\u01B0\u1EDDng \u0111\u01B0\u1EE3c s\u1EED d\u1EE5ng trong ti\u1EBFng Ph\xE1p l\xE0 \u201Cemail\u201D. T\xECm m\u1EABu \u0111\u1EA7u ti\xEAn trong t\u1EADp d\u1EEF li\u1EC7u hu\u1EA5n luy\u1EC7n s\u1EED d\u1EE5ng t\u1EEB n\xE0y. N\xF3 \u0111\u01B0\u1EE3c d\u1ECBch nh\u01B0 th\u1EBF n\xE0o? L\xE0m th\u1EBF n\xE0o \u0111\u1EC3 m\xF4 h\xECnh hu\u1EA5n luy\u1EC7n tr\u01B0\u1EDBc d\u1ECBch c\xF9ng m\u1ED9t c\xE2u ti\u1EBFng Anh?")},l(_){o=c(_,"P",{});var C=r(o);$=a(C,"\u270F\uFE0F "),d=c(C,"STRONG",{});var D=r(d);x=a(D,"\u0110\u1EBFn l\u01B0\u1EE3t b\u1EA1n!"),D.forEach(t),z=a(C," M\u1ED9t t\u1EEB ti\u1EBFng Anh kh\xE1c th\u01B0\u1EDDng \u0111\u01B0\u1EE3c s\u1EED d\u1EE5ng trong ti\u1EBFng Ph\xE1p l\xE0 \u201Cemail\u201D. T\xECm m\u1EABu \u0111\u1EA7u ti\xEAn trong t\u1EADp d\u1EEF li\u1EC7u hu\u1EA5n luy\u1EC7n s\u1EED d\u1EE5ng t\u1EEB n\xE0y. N\xF3 \u0111\u01B0\u1EE3c d\u1ECBch nh\u01B0 th\u1EBF n\xE0o? L\xE0m th\u1EBF n\xE0o \u0111\u1EC3 m\xF4 h\xECnh hu\u1EA5n luy\u1EC7n tr\u01B0\u1EDBc d\u1ECBch c\xF9ng m\u1ED9t c\xE2u ti\u1EBFng Anh?"),C.forEach(t)},m(_,C){h(_,o,C),e(o,$),e(o,d),e(d,x),e(o,z)},d(_){_&&t(o)}}}function ku(V){let o,$,d,x,z,_,C,D;return{c(){o=l("p"),$=s("\u{1F4A1} N\u1EBFu b\u1EA1n \u0111ang s\u1EED d\u1EE5ng tr\xECnh tokenize \u0111a ng\xF4n ng\u1EEF nh\u01B0 mBART, mBART-50 ho\u1EB7c M2M100, b\u1EA1n s\u1EBD c\u1EA7n \u0111\u1EB7t m\xE3 ng\xF4n ng\u1EEF c\u1EE7a \u0111\u1EA7u v\xE0o v\xE0 nh\xE3n c\u1EE7a m\xECnh trong tr\xECnh tokenize b\u1EB1ng c\xE1ch \u0111\u1EB7t "),d=l("code"),x=s("tokenizer.src_lang"),z=s(" v\xE0 "),_=l("code"),C=s("tokenizer.tgt_lang"),D=s(" \u1EDF b\xEAn ph\u1EA3i c\xE1c gi\xE1 tr\u1ECB.")},l(P){o=c(P,"P",{});var q=r(o);$=a(q,"\u{1F4A1} N\u1EBFu b\u1EA1n \u0111ang s\u1EED d\u1EE5ng tr\xECnh tokenize \u0111a ng\xF4n ng\u1EEF nh\u01B0 mBART, mBART-50 ho\u1EB7c M2M100, b\u1EA1n s\u1EBD c\u1EA7n \u0111\u1EB7t m\xE3 ng\xF4n ng\u1EEF c\u1EE7a \u0111\u1EA7u v\xE0o v\xE0 nh\xE3n c\u1EE7a m\xECnh trong tr\xECnh tokenize b\u1EB1ng c\xE1ch \u0111\u1EB7t "),d=c(q,"CODE",{});var O=r(d);x=a(O,"tokenizer.src_lang"),O.forEach(t),z=a(q," v\xE0 "),_=c(q,"CODE",{});var T=r(_);C=a(T,"tokenizer.tgt_lang"),T.forEach(t),D=a(q," \u1EDF b\xEAn ph\u1EA3i c\xE1c gi\xE1 tr\u1ECB."),q.forEach(t)},m(P,q){h(P,o,q),e(o,$),e(o,d),e(d,x),e(o,z),e(o,_),e(_,C),e(o,D)},d(P){P&&t(o)}}}function $u(V){let o,$,d,x,z,_,C,D;return{c(){o=l("p"),$=s("\u{1F4A1} N\u1EBFu b\u1EA1n \u0111ang s\u1EED d\u1EE5ng m\xF4 h\xECnh T5 (c\u1EE5 th\u1EC3 h\u01A1n l\xE0 m\u1ED9t trong c\xE1c checkpoint "),d=l("code"),x=s("t5-xxx"),z=s("), m\xF4 h\xECnh s\u1EBD mong \u0111\u1EE3i c\xE1c \u0111\u1EA7u v\xE0o v\u0103n b\u1EA3n c\xF3 ti\u1EC1n t\u1ED1 cho bi\u1EBFt t\xE1c v\u1EE5 \u0111ang th\u1EF1c hi\u1EC7n, ch\u1EB3ng h\u1EA1n nh\u01B0 "),_=l("code"),C=s("translate: English to French:"),D=s(".")},l(P){o=c(P,"P",{});var q=r(o);$=a(q,"\u{1F4A1} N\u1EBFu b\u1EA1n \u0111ang s\u1EED d\u1EE5ng m\xF4 h\xECnh T5 (c\u1EE5 th\u1EC3 h\u01A1n l\xE0 m\u1ED9t trong c\xE1c checkpoint "),d=c(q,"CODE",{});var O=r(d);x=a(O,"t5-xxx"),O.forEach(t),z=a(q,"), m\xF4 h\xECnh s\u1EBD mong \u0111\u1EE3i c\xE1c \u0111\u1EA7u v\xE0o v\u0103n b\u1EA3n c\xF3 ti\u1EC1n t\u1ED1 cho bi\u1EBFt t\xE1c v\u1EE5 \u0111ang th\u1EF1c hi\u1EC7n, ch\u1EB3ng h\u1EA1n nh\u01B0 "),_=c(q,"CODE",{});var T=r(_);C=a(T,"translate: English to French:"),T.forEach(t),D=a(q,"."),q.forEach(t)},m(P,q){h(P,o,q),e(o,$),e(o,d),e(d,x),e(o,z),e(o,_),e(_,C),e(o,D)},d(P){P&&t(o)}}}function yu(V){let o,$,d,x,z,_,C,D;return{c(){o=l("p"),$=s("\u26A0\uFE0F Ch\xFAng ta kh\xF4ng ch\xFA \xFD \u0111\u1EBFn attention mask c\u1EE7a c\xE1c nh\xE3n, v\xEC m\xF4 h\xECnh s\u1EBD kh\xF4ng mong \u0111\u1EE3i \u0111i\u1EC1u \u0111\xF3. Thay v\xE0o \u0111\xF3, c\xE1c nh\xE3n t\u01B0\u01A1ng \u1EE9ng v\u1EDBi token \u0111\u1EC7m ph\u1EA3i \u0111\u01B0\u1EE3c \u0111\u1EB7t th\xE0nh "),d=l("code"),x=s("-100"),z=s(" \u0111\u1EC3 ch\xFAng b\u1ECB b\u1ECF qua trong t\xEDnh to\xE1n m\u1EA5t m\xE1t. \u0110i\u1EC1u n\xE0y s\u1EBD \u0111\u01B0\u1EE3c th\u1EF1c hi\u1EC7n b\u1EDFi tr\xECnh \u0111\u1ED1i chi\u1EBFu d\u1EEF li\u1EC7u c\u1EE7a ch\xFAng ta sau n\xE0y v\xEC ch\xFAng ta \u0111ang \xE1p d\u1EE5ng \u0111\u1EC7m \u0111\u1ED9ng, nh\u01B0ng n\u1EBFu b\u1EA1n s\u1EED d\u1EE5ng \u0111\u1EC7m \u1EDF \u0111\xE2y, b\u1EA1n n\xEAn \u0111i\u1EC1u ch\u1EC9nh ch\u1EE9c n\u0103ng ti\u1EC1n x\u1EED l\xFD \u0111\u1EC3 \u0111\u1EB7t t\u1EA5t c\u1EA3 c\xE1c nh\xE3n t\u01B0\u01A1ng \u1EE9ng v\u1EDBi token \u0111\u1EC7m th\xE0nh "),_=l("code"),C=s("-100"),D=s(".")},l(P){o=c(P,"P",{});var q=r(o);$=a(q,"\u26A0\uFE0F Ch\xFAng ta kh\xF4ng ch\xFA \xFD \u0111\u1EBFn attention mask c\u1EE7a c\xE1c nh\xE3n, v\xEC m\xF4 h\xECnh s\u1EBD kh\xF4ng mong \u0111\u1EE3i \u0111i\u1EC1u \u0111\xF3. Thay v\xE0o \u0111\xF3, c\xE1c nh\xE3n t\u01B0\u01A1ng \u1EE9ng v\u1EDBi token \u0111\u1EC7m ph\u1EA3i \u0111\u01B0\u1EE3c \u0111\u1EB7t th\xE0nh "),d=c(q,"CODE",{});var O=r(d);x=a(O,"-100"),O.forEach(t),z=a(q," \u0111\u1EC3 ch\xFAng b\u1ECB b\u1ECF qua trong t\xEDnh to\xE1n m\u1EA5t m\xE1t. \u0110i\u1EC1u n\xE0y s\u1EBD \u0111\u01B0\u1EE3c th\u1EF1c hi\u1EC7n b\u1EDFi tr\xECnh \u0111\u1ED1i chi\u1EBFu d\u1EEF li\u1EC7u c\u1EE7a ch\xFAng ta sau n\xE0y v\xEC ch\xFAng ta \u0111ang \xE1p d\u1EE5ng \u0111\u1EC7m \u0111\u1ED9ng, nh\u01B0ng n\u1EBFu b\u1EA1n s\u1EED d\u1EE5ng \u0111\u1EC7m \u1EDF \u0111\xE2y, b\u1EA1n n\xEAn \u0111i\u1EC1u ch\u1EC9nh ch\u1EE9c n\u0103ng ti\u1EC1n x\u1EED l\xFD \u0111\u1EC3 \u0111\u1EB7t t\u1EA5t c\u1EA3 c\xE1c nh\xE3n t\u01B0\u01A1ng \u1EE9ng v\u1EDBi token \u0111\u1EC7m th\xE0nh "),_=c(q,"CODE",{});var T=r(_);C=a(T,"-100"),T.forEach(t),D=a(q,"."),q.forEach(t)},m(P,q){h(P,o,q),e(o,$),e(o,d),e(d,x),e(o,z),e(o,_),e(_,C),e(o,D)},d(P){P&&t(o)}}}function ju(V){let o,$,d,x,z,_,C,D,P,q,O,T,S,F,I,B,tn,U;return x=new pe({}),I=new A({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>)`}}),tn=new Ys({props:{warning:!1,$$slots:{default:[wu]},$$scope:{ctx:V}}}),{c(){o=l("h2"),$=l("a"),d=l("span"),y(x.$$.fragment),z=p(),_=l("span"),C=s("Tinh ch\u1EC9nh m\xF4 h\xECnh v\u1EDBi Keras"),D=p(),P=l("p"),q=s("\u0110i\u1EC1u \u0111\u1EA7u ti\xEAn, ch\xFAng ta c\u1EA7n m\u1ED9t m\xF4 h\xECnh th\u1EF1c t\u1EBF \u0111\u1EC3 tinh ch\u1EC9nh. Ch\xFAng ta s\u1EBD s\u1EED d\u1EE5ng API "),O=l("code"),T=s("AutoModel"),S=s(":"),F=p(),y(I.$$.fragment),B=p(),y(tn.$$.fragment),this.h()},l(H){o=c(H,"H2",{class:!0});var X=r(o);$=c(X,"A",{id:!0,class:!0,href:!0});var Y=r($);d=c(Y,"SPAN",{});var rn=r(d);j(x.$$.fragment,rn),rn.forEach(t),Y.forEach(t),z=u(X),_=c(X,"SPAN",{});var on=r(_);C=a(on,"Tinh ch\u1EC9nh m\xF4 h\xECnh v\u1EDBi Keras"),on.forEach(t),X.forEach(t),D=u(H),P=c(H,"P",{});var sn=r(P);q=a(sn,"\u0110i\u1EC1u \u0111\u1EA7u ti\xEAn, ch\xFAng ta c\u1EA7n m\u1ED9t m\xF4 h\xECnh th\u1EF1c t\u1EBF \u0111\u1EC3 tinh ch\u1EC9nh. Ch\xFAng ta s\u1EBD s\u1EED d\u1EE5ng API "),O=c(sn,"CODE",{});var Q=r(O);T=a(Q,"AutoModel"),Q.forEach(t),S=a(sn,":"),sn.forEach(t),F=u(H),j(I.$$.fragment,H),B=u(H),j(tn.$$.fragment,H),this.h()},h(){f($,"id","tinh-chnh-m-hnh-vi-keras"),f($,"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"),f($,"href","#tinh-chnh-m-hnh-vi-keras"),f(o,"class","relative group")},m(H,X){h(H,o,X),e(o,$),e($,d),E(x,d,null),e(o,z),e(o,_),e(_,C),h(H,D,X),h(H,P,X),e(P,q),e(P,O),e(O,T),e(P,S),h(H,F,X),E(I,H,X),h(H,B,X),E(tn,H,X),U=!0},i(H){U||(b(x.$$.fragment,H),b(I.$$.fragment,H),b(tn.$$.fragment,H),U=!0)},o(H){v(x.$$.fragment,H),v(I.$$.fragment,H),v(tn.$$.fragment,H),U=!1},d(H){H&&t(o),w(x),H&&t(D),H&&t(P),H&&t(F),w(I,H),H&&t(B),w(tn,H)}}}function Eu(V){let o,$,d,x,z,_,C,D,P,q,O,T,S,F,I,B,tn,U,H,X,Y,rn,on,sn,Q,Z,R,un,dn,en,nn,fn,mn,ln;return x=new pe({}),mn=new A({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(){o=l("h2"),$=l("a"),d=l("span"),y(x.$$.fragment),z=p(),_=l("span"),C=s("Tinh ch\u1EC9nh m\xF4 h\xECnh v\u1EDBi API "),D=l("code"),P=s("Trainer"),q=p(),O=l("p"),T=s("\u0110o\u1EA1n m\xE3 th\u1EF1c s\u1EED d\u1EE5ng "),S=l("code"),F=s("Trainer"),I=s(" s\u1EBD gi\u1ED1ng nh\u01B0 tr\u01B0\u1EDBc \u0111\xE2y, ch\u1EC9 v\u1EDBi m\u1ED9t thay \u0111\u1ED5i nh\u1ECF: ch\xFAng ta s\u1EED d\u1EE5ng "),B=l("a"),tn=l("code"),U=s("Seq2SeqTrainer"),H=s(" t\u1EA1i \u0111\xE2y, l\xE0 m\u1ED9t l\u1EDBp con c\u1EE7a "),X=l("code"),Y=s("Trainer"),rn=s(" s\u1EBD cho ph\xE9p ch\xFAng ta x\u1EED l\xFD t\u1ED1t vi\u1EC7c \u0111\xE1nh gi\xE1, s\u1EED d\u1EE5ng ph\u01B0\u01A1ng th\u1EE9c "),on=l("code"),sn=s("generate()"),Q=s(" \u0111\u1EC3 d\u1EF1 \u0111o\xE1n k\u1EBFt qu\u1EA3 \u0111\u1EA7u ra t\u1EEB c\xE1c \u0111\u1EA7u v\xE0o. Ch\xFAng ta s\u1EBD \u0111i s\xE2u v\xE0o v\u1EA5n \u0111\u1EC1 \u0111\xF3 chi ti\u1EBFt h\u01A1n khi ta n\xF3i v\u1EC1 t\xEDnh to\xE1n s\u1ED1 li\u1EC7u."),Z=p(),R=l("p"),un=s("\u0110i\u1EC1u \u0111\u1EA7u ti\xEAn, ch\xFAng ta c\u1EA7n m\u1ED9t m\xF4 h\xECnh th\u1EF1c t\u1EBF \u0111\u1EC3 tinh ch\u1EC9nh. Ch\xFAng ta s\u1EBD s\u1EED d\u1EE5ng API "),dn=l("code"),en=s("AutoModel"),nn=s(":"),fn=p(),y(mn.$$.fragment),this.h()},l(M){o=c(M,"H2",{class:!0});var G=r(o);$=c(G,"A",{id:!0,class:!0,href:!0});var jn=r($);d=c(jn,"SPAN",{});var xn=r(d);j(x.$$.fragment,xn),xn.forEach(t),jn.forEach(t),z=u(G),_=c(G,"SPAN",{});var pn=r(_);C=a(pn,"Tinh ch\u1EC9nh m\xF4 h\xECnh v\u1EDBi API "),D=c(pn,"CODE",{});var W=r(D);P=a(W,"Trainer"),W.forEach(t),pn.forEach(t),G.forEach(t),q=u(M),O=c(M,"P",{});var an=r(O);T=a(an,"\u0110o\u1EA1n m\xE3 th\u1EF1c s\u1EED d\u1EE5ng "),S=c(an,"CODE",{});var kn=r(S);F=a(kn,"Trainer"),kn.forEach(t),I=a(an," s\u1EBD gi\u1ED1ng nh\u01B0 tr\u01B0\u1EDBc \u0111\xE2y, ch\u1EC9 v\u1EDBi m\u1ED9t thay \u0111\u1ED5i nh\u1ECF: ch\xFAng ta s\u1EED d\u1EE5ng "),B=c(an,"A",{href:!0,rel:!0});var Tn=r(B);tn=c(Tn,"CODE",{});var On=r(tn);U=a(On,"Seq2SeqTrainer"),On.forEach(t),Tn.forEach(t),H=a(an," t\u1EA1i \u0111\xE2y, l\xE0 m\u1ED9t l\u1EDBp con c\u1EE7a "),X=c(an,"CODE",{});var _n=r(X);Y=a(_n,"Trainer"),_n.forEach(t),rn=a(an," s\u1EBD cho ph\xE9p ch\xFAng ta x\u1EED l\xFD t\u1ED1t vi\u1EC7c \u0111\xE1nh gi\xE1, s\u1EED d\u1EE5ng ph\u01B0\u01A1ng th\u1EE9c "),on=c(an,"CODE",{});var bn=r(on);sn=a(bn,"generate()"),bn.forEach(t),Q=a(an," \u0111\u1EC3 d\u1EF1 \u0111o\xE1n k\u1EBFt qu\u1EA3 \u0111\u1EA7u ra t\u1EEB c\xE1c \u0111\u1EA7u v\xE0o. Ch\xFAng ta s\u1EBD \u0111i s\xE2u v\xE0o v\u1EA5n \u0111\u1EC1 \u0111\xF3 chi ti\u1EBFt h\u01A1n khi ta n\xF3i v\u1EC1 t\xEDnh to\xE1n s\u1ED1 li\u1EC7u."),an.forEach(t),Z=u(M),R=c(M,"P",{});var J=r(R);un=a(J,"\u0110i\u1EC1u \u0111\u1EA7u ti\xEAn, ch\xFAng ta c\u1EA7n m\u1ED9t m\xF4 h\xECnh th\u1EF1c t\u1EBF \u0111\u1EC3 tinh ch\u1EC9nh. Ch\xFAng ta s\u1EBD s\u1EED d\u1EE5ng API "),dn=c(J,"CODE",{});var Cn=r(dn);en=a(Cn,"AutoModel"),Cn.forEach(t),nn=a(J,":"),J.forEach(t),fn=u(M),j(mn.$$.fragment,M),this.h()},h(){f($,"id","tinh-chnh-m-hnh-vi-api-trainer"),f($,"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"),f($,"href","#tinh-chnh-m-hnh-vi-api-trainer"),f(o,"class","relative group"),f(B,"href","https://huggingface.co/transformers/main_classes/trainer.html#seq2seqtrainer"),f(B,"rel","nofollow")},m(M,G){h(M,o,G),e(o,$),e($,d),E(x,d,null),e(o,z),e(o,_),e(_,C),e(_,D),e(D,P),h(M,q,G),h(M,O,G),e(O,T),e(O,S),e(S,F),e(O,I),e(O,B),e(B,tn),e(tn,U),e(O,H),e(O,X),e(X,Y),e(O,rn),e(O,on),e(on,sn),e(O,Q),h(M,Z,G),h(M,R,G),e(R,un),e(R,dn),e(dn,en),e(R,nn),h(M,fn,G),E(mn,M,G),ln=!0},i(M){ln||(b(x.$$.fragment,M),b(mn.$$.fragment,M),ln=!0)},o(M){v(x.$$.fragment,M),v(mn.$$.fragment,M),ln=!1},d(M){M&&t(o),w(x),M&&t(q),M&&t(O),M&&t(Z),M&&t(R),M&&t(fn),w(mn,M)}}}function wu(V){let o,$,d,x,z,_,C,D;return{c(){o=l("p"),$=s("\u{1F4A1} Checkpoint "),d=l("code"),x=s("Helsinki-NLP/opus-mt-en-fr"),z=s(" ch\u1EC9 c\xF3 tr\u1ECDng s\u1ED1 PyTorch, n\xEAn b\u1EA1n s\u1EBD nh\u1EADn \u0111\u01B0\u1EE3c l\u1ED7i n\u1EBFu b\u1EA1n c\u1ED1 t\u1EA3i m\xF4 h\xECnh m\xE0 kh\xF4ng s\u1EED d\u1EE5ng tham s\u1ED1 "),_=l("code"),C=s("from_pt=True"),D=s(", th\u01B0 vi\u1EC7n s\u1EBD t\u1EF1 \u0111\u1ED9ng t\u1EA3i v\xE0 chuy\u1EC3n c\xE1c tr\u1ECDng s\u1ED1 Pytorch cho b\u1EA1n. Nh\u01B0 b\u1EA1n c\xF3 th\u1EC3 th\u1EA5y, r\u1EA5t \u0111\u01A1n gi\u1EA3n \u0111\u1EC3 chuy\u1EC3n gi\u1EEFa c\xE1c khung trong \u{1F917} Transformers!")},l(P){o=c(P,"P",{});var q=r(o);$=a(q,"\u{1F4A1} Checkpoint "),d=c(q,"CODE",{});var O=r(d);x=a(O,"Helsinki-NLP/opus-mt-en-fr"),O.forEach(t),z=a(q," ch\u1EC9 c\xF3 tr\u1ECDng s\u1ED1 PyTorch, n\xEAn b\u1EA1n s\u1EBD nh\u1EADn \u0111\u01B0\u1EE3c l\u1ED7i n\u1EBFu b\u1EA1n c\u1ED1 t\u1EA3i m\xF4 h\xECnh m\xE0 kh\xF4ng s\u1EED d\u1EE5ng tham s\u1ED1 "),_=c(q,"CODE",{});var T=r(_);C=a(T,"from_pt=True"),T.forEach(t),D=a(q,", th\u01B0 vi\u1EC7n s\u1EBD t\u1EF1 \u0111\u1ED9ng t\u1EA3i v\xE0 chuy\u1EC3n c\xE1c tr\u1ECDng s\u1ED1 Pytorch cho b\u1EA1n. Nh\u01B0 b\u1EA1n c\xF3 th\u1EC3 th\u1EA5y, r\u1EA5t \u0111\u01A1n gi\u1EA3n \u0111\u1EC3 chuy\u1EC3n gi\u1EEFa c\xE1c khung trong \u{1F917} Transformers!"),q.forEach(t)},m(P,q){h(P,o,q),e(o,$),e(o,d),e(d,x),e(o,z),e(o,_),e(_,C),e(o,D)},d(P){P&&t(o)}}}function xu(V){let o,$;return o=new A({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(){y(o.$$.fragment)},l(d){j(o.$$.fragment,d)},m(d,x){E(o,d,x),$=!0},i(d){$||(b(o.$$.fragment,d),$=!0)},o(d){v(o.$$.fragment,d),$=!1},d(d){w(o,d)}}}function qu(V){let o,$;return o=new A({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(){y(o.$$.fragment)},l(d){j(o.$$.fragment,d)},m(d,x){E(o,d,x),$=!0},i(d){$||(b(o.$$.fragment,d),$=!0)},o(d){v(o.$$.fragment,d),$=!1},d(d){w(o,d)}}}function Tu(V){let o,$,d,x,z,_,C,D,P,q,O;return q=new A({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(){o=l("p"),$=s("Ta c\xF3 th\u1EC3 s\u1EED d\u1EE5ng "),d=l("code"),x=s("data_collator"),z=s(" \u0111\u1EC3 chuy\u1EC3n m\u1ED7i ph\u1EA7n d\u1EEF li\u1EC7u th\xE0nh "),_=l("code"),C=s("tf.data.Dataset"),D=s(", s\u1EB5n s\xE0ng \u0111\u1EC3 hu\u1EA5n luy\u1EC7n:"),P=p(),y(q.$$.fragment)},l(T){o=c(T,"P",{});var S=r(o);$=a(S,"Ta c\xF3 th\u1EC3 s\u1EED d\u1EE5ng "),d=c(S,"CODE",{});var F=r(d);x=a(F,"data_collator"),F.forEach(t),z=a(S," \u0111\u1EC3 chuy\u1EC3n m\u1ED7i ph\u1EA7n d\u1EEF li\u1EC7u th\xE0nh "),_=c(S,"CODE",{});var I=r(_);C=a(I,"tf.data.Dataset"),I.forEach(t),D=a(S,", s\u1EB5n s\xE0ng \u0111\u1EC3 hu\u1EA5n luy\u1EC7n:"),S.forEach(t),P=u(T),j(q.$$.fragment,T)},m(T,S){h(T,o,S),e(o,$),e(o,d),e(d,x),e(o,z),e(o,_),e(_,C),e(o,D),h(T,P,S),E(q,T,S),O=!0},i(T){O||(b(q.$$.fragment,T),O=!0)},o(T){v(q.$$.fragment,T),O=!1},d(T){T&&t(o),T&&t(P),w(q,T)}}}function Cu(V){let o,$,d,x,z,_,C,D;return{c(){o=l("p"),$=s("Ch\xFAng ta s\u1EBD truy\u1EC1n "),d=l("code"),x=s("data_collator"),z=s(" v\xE0o "),_=l("code"),C=s("Seq2SeqTrainer"),D=s(". Ti\u1EBFp theo, ch\xFAng ta h\xE3y xem x\xE9t ch\u1EC9 s\u1ED1.")},l(P){o=c(P,"P",{});var q=r(o);$=a(q,"Ch\xFAng ta s\u1EBD truy\u1EC1n "),d=c(q,"CODE",{});var O=r(d);x=a(O,"data_collator"),O.forEach(t),z=a(q," v\xE0o "),_=c(q,"CODE",{});var T=r(_);C=a(T,"Seq2SeqTrainer"),T.forEach(t),D=a(q,". Ti\u1EBFp theo, ch\xFAng ta h\xE3y xem x\xE9t ch\u1EC9 s\u1ED1."),q.forEach(t)},m(P,q){h(P,o,q),e(o,$),e(o,d),e(d,x),e(o,z),e(o,_),e(_,C),e(o,D)},i:cu,o:cu,d(P){P&&t(o)}}}function ru(V){let o,$,d,x,z,_,C,D,P,q,O,T,S,F,I,B,tn,U,H,X,Y,rn,on,sn,Q,Z,R,un,dn;return{c(){o=l("p"),$=s("T\xEDnh n\u0103ng m\xE0 "),d=l("code"),x=s("Seq2SeqTrainer"),z=s(" th\xEAm v\xE0o l\u1EDBp cha "),_=l("code"),C=s("Trainer"),D=s(" c\u1EE7a n\xF3 l\xE0 kh\u1EA3 n\u0103ng s\u1EED d\u1EE5ng ph\u01B0\u01A1ng th\u1EE9c "),P=l("code"),q=s("generate()"),O=s(" trong qu\xE1 tr\xECnh \u0111\xE1nh gi\xE1 ho\u1EB7c d\u1EF1 \u0111o\xE1n. Trong qu\xE1 tr\xECnh hu\u1EA5n luy\u1EC7n, m\xF4 h\xECnh s\u1EBD s\u1EED d\u1EE5ng "),T=l("code"),S=s("decoder_input_ids"),F=s(" v\u1EDBi attention mask \u0111\u1EA3m b\u1EA3o n\xF3 kh\xF4ng s\u1EED d\u1EE5ng c\xE1c token sau token m\xE0 n\xF3 \u0111ang c\u1ED1 g\u1EAFng d\u1EF1 \u0111o\xE1n, \u0111\u1EC3 t\u0103ng t\u1ED1c \u0111\u1ED9 hu\u1EA5n luy\u1EC7n. Trong qu\xE1 tr\xECnh lu\u1EADn suy, ch\xFAng ta s\u1EBD kh\xF4ng th\u1EC3 s\u1EED d\u1EE5ng nh\u1EEFng th\u1EE9 \u0111\xF3 v\xEC ch\xFAng ta s\u1EBD kh\xF4ng c\xF3 nh\xE3n, v\xEC v\u1EADy, b\u1EA1n n\xEAn \u0111\xE1nh gi\xE1 m\xF4 h\xECnh c\u1EE7a m\xECnh v\u1EDBi c\xF9ng m\u1ED9t thi\u1EBFt l\u1EADp."),I=p(),B=l("p"),tn=s("Nh\u01B0 ch\xFAng ta \u0111\xE3 th\u1EA5y trong "),U=l("a"),H=s("Ch\u01B0\u01A1ng 1"),X=s(", b\u1ED9 gi\u1EA3i m\xE3 th\u1EF1c hi\u1EC7n lu\u1EADn suy b\u1EB1ng c\xE1ch d\u1EF1 \u0111o\xE1n t\u1EEBng token - m\u1ED9t th\u1EE9 \u0111\u01B0\u1EE3c tri\u1EC3n khai ph\xEDa sau trong \u{1F917} Transformers b\u1EB1ng ph\u01B0\u01A1ng th\u1EE9c "),Y=l("code"),rn=s("generate()"),on=s(". "),sn=l("code"),Q=s("Seq2SeqTrainer"),Z=s(" s\u1EBD cho ph\xE9p ch\xFAng ta s\u1EED d\u1EE5ng ph\u01B0\u01A1ng ph\xE1p \u0111\xF3 \u0111\u1EC3 \u0111\xE1nh gi\xE1 n\u1EBFu ch\xFAng ta \u0111\u1EB7t "),R=l("code"),un=s("predict_with_generate=True"),dn=s("."),this.h()},l(en){o=c(en,"P",{});var nn=r(o);$=a(nn,"T\xEDnh n\u0103ng m\xE0 "),d=c(nn,"CODE",{});var fn=r(d);x=a(fn,"Seq2SeqTrainer"),fn.forEach(t),z=a(nn," th\xEAm v\xE0o l\u1EDBp cha "),_=c(nn,"CODE",{});var mn=r(_);C=a(mn,"Trainer"),mn.forEach(t),D=a(nn," c\u1EE7a n\xF3 l\xE0 kh\u1EA3 n\u0103ng s\u1EED d\u1EE5ng ph\u01B0\u01A1ng th\u1EE9c "),P=c(nn,"CODE",{});var ln=r(P);q=a(ln,"generate()"),ln.forEach(t),O=a(nn," trong qu\xE1 tr\xECnh \u0111\xE1nh gi\xE1 ho\u1EB7c d\u1EF1 \u0111o\xE1n. Trong qu\xE1 tr\xECnh hu\u1EA5n luy\u1EC7n, m\xF4 h\xECnh s\u1EBD s\u1EED d\u1EE5ng "),T=c(nn,"CODE",{});var M=r(T);S=a(M,"decoder_input_ids"),M.forEach(t),F=a(nn," v\u1EDBi attention mask \u0111\u1EA3m b\u1EA3o n\xF3 kh\xF4ng s\u1EED d\u1EE5ng c\xE1c token sau token m\xE0 n\xF3 \u0111ang c\u1ED1 g\u1EAFng d\u1EF1 \u0111o\xE1n, \u0111\u1EC3 t\u0103ng t\u1ED1c \u0111\u1ED9 hu\u1EA5n luy\u1EC7n. Trong qu\xE1 tr\xECnh lu\u1EADn suy, ch\xFAng ta s\u1EBD kh\xF4ng th\u1EC3 s\u1EED d\u1EE5ng nh\u1EEFng th\u1EE9 \u0111\xF3 v\xEC ch\xFAng ta s\u1EBD kh\xF4ng c\xF3 nh\xE3n, v\xEC v\u1EADy, b\u1EA1n n\xEAn \u0111\xE1nh gi\xE1 m\xF4 h\xECnh c\u1EE7a m\xECnh v\u1EDBi c\xF9ng m\u1ED9t thi\u1EBFt l\u1EADp."),nn.forEach(t),I=u(en),B=c(en,"P",{});var G=r(B);tn=a(G,"Nh\u01B0 ch\xFAng ta \u0111\xE3 th\u1EA5y trong "),U=c(G,"A",{href:!0});var jn=r(U);H=a(jn,"Ch\u01B0\u01A1ng 1"),jn.forEach(t),X=a(G,", b\u1ED9 gi\u1EA3i m\xE3 th\u1EF1c hi\u1EC7n lu\u1EADn suy b\u1EB1ng c\xE1ch d\u1EF1 \u0111o\xE1n t\u1EEBng token - m\u1ED9t th\u1EE9 \u0111\u01B0\u1EE3c tri\u1EC3n khai ph\xEDa sau trong \u{1F917} Transformers b\u1EB1ng ph\u01B0\u01A1ng th\u1EE9c "),Y=c(G,"CODE",{});var xn=r(Y);rn=a(xn,"generate()"),xn.forEach(t),on=a(G,". "),sn=c(G,"CODE",{});var pn=r(sn);Q=a(pn,"Seq2SeqTrainer"),pn.forEach(t),Z=a(G," s\u1EBD cho ph\xE9p ch\xFAng ta s\u1EED d\u1EE5ng ph\u01B0\u01A1ng ph\xE1p \u0111\xF3 \u0111\u1EC3 \u0111\xE1nh gi\xE1 n\u1EBFu ch\xFAng ta \u0111\u1EB7t "),R=c(G,"CODE",{});var W=r(R);un=a(W,"predict_with_generate=True"),W.forEach(t),dn=a(G,"."),G.forEach(t),this.h()},h(){f(U,"href","/course/chapter1/6")},m(en,nn){h(en,o,nn),e(o,$),e(o,d),e(d,x),e(o,z),e(o,_),e(_,C),e(o,D),e(o,P),e(P,q),e(o,O),e(o,T),e(T,S),e(o,F),h(en,I,nn),h(en,B,nn),e(B,tn),e(B,U),e(U,H),e(B,X),e(B,Y),e(Y,rn),e(B,on),e(B,sn),e(sn,Q),e(B,Z),e(B,R),e(R,un),e(B,dn)},d(en){en&&t(o),en&&t(I),en&&t(B)}}}function Pu(V){let o,$,d,x,z,_,C,D,P,q,O;return q=new A({props:{code:`import numpy as np


def compute_metrics(eval_preds):
    preds, labels = eval_preds
    # Trong tr\u01B0\u1EDDng h\u1EE3p m\xF4 h\xECnh tr\u1EA3 v\u1EC1 nhi\u1EC1u h\u01A1n logit d\u1EF1 \u0111o\xE1n
    if isinstance(preds, tuple):
        preds = preds[0]

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

    # Thay c\xE1c g\xEDa tr\u1ECB -100 trong nh\xE3n v\xEC ta kh\xF4ng gi\u1EA3i m\xE3 ch\xFAng
    labels = np.where(labels != -100, labels, tokenizer.pad_token_id)
    decoded_labels = tokenizer.batch_decode(labels, skip_special_tokens=True)

    # Th\u1EF1c m\u1ED9t m\u1ED9t x\u1ED1 h\u1EADu x\u1EE7 l\xFD \u0111\u01A1n gi\u1EA3n
    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"># Trong tr\u01B0\u1EDDng h\u1EE3p m\xF4 h\xECnh tr\u1EA3 v\u1EC1 nhi\u1EC1u h\u01A1n logit d\u1EF1 \u0111o\xE1n</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"># Thay c\xE1c g\xEDa tr\u1ECB -100 trong nh\xE3n v\xEC ta kh\xF4ng gi\u1EA3i m\xE3 ch\xFAng</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"># Th\u1EF1c m\u1ED9t m\u1ED9t x\u1ED1 h\u1EADu x\u1EE7 l\xFD \u0111\u01A1n gi\u1EA3n</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(){o=l("p"),$=s("To get from the model outputs to texts the metric can use, we will use the "),d=l("code"),x=s("tokenizer.batch_decode()"),z=s(" method. We just have to clean up all the "),_=l("code"),C=s("-100"),D=s("s in the labels (the tokenizer will automatically do the same for the padding token):"),P=p(),y(q.$$.fragment)},l(T){o=c(T,"P",{});var S=r(o);$=a(S,"To get from the model outputs to texts the metric can use, we will use the "),d=c(S,"CODE",{});var F=r(d);x=a(F,"tokenizer.batch_decode()"),F.forEach(t),z=a(S," method. We just have to clean up all the "),_=c(S,"CODE",{});var I=r(_);C=a(I,"-100"),I.forEach(t),D=a(S,"s in the labels (the tokenizer will automatically do the same for the padding token):"),S.forEach(t),P=u(T),j(q.$$.fragment,T)},m(T,S){h(T,o,S),e(o,$),e(o,d),e(d,x),e(o,z),e(o,_),e(_,C),e(o,D),h(T,P,S),E(q,T,S),O=!0},i(T){O||(b(q.$$.fragment,T),O=!0)},o(T){v(q.$$.fragment,T),O=!1},d(T){T&&t(o),T&&t(P),w(q,T)}}}function Du(V){let o,$,d,x,z,_,C,D,P,q,O;return q=new A({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(){o=l("p"),$=s("\u0110\u1EC3 chuy\u1EC3n t\u1EEB k\u1EBFt qu\u1EA3 \u0111\u1EA7u ra c\u1EE7a m\xF4 h\xECnh th\xE0nh v\u0103n b\u1EA3n m\xE0 ch\u1EC9 s\u1ED1 c\xF3 th\u1EC3 s\u1EED d\u1EE5ng, ch\xFAng ta s\u1EBD s\u1EED d\u1EE5ng ph\u01B0\u01A1ng th\u1EE9c "),d=l("code"),x=s("tokenizer.batch_decode()"),z=s(". Ch\xFAng ta ch\u1EC9 c\u1EA7n x\xF3a t\u1EA5t c\u1EA3 c\xE1c "),_=l("code"),C=s("-100"),D=s(" trong c\xE1c nh\xE3n; tokenizer s\u1EBD t\u1EF1 \u0111\u1ED9ng l\xE0m \u0111i\u1EC1u t\u01B0\u01A1ng t\u1EF1 \u0111\u1ED1i v\u1EDBi token \u0111\u1EC7m. H\xE3y x\xE1c \u0111\u1ECBnh m\u1ED9t h\xE0m s\u1EED d\u1EE5ng m\xF4 h\xECnh v\xE0 t\u1EADp d\u1EEF li\u1EC7u c\u1EE7a ch\xFAng ta v\xE0 t\xEDnh to\xE1n c\xE1c s\u1ED1 li\u1EC7u tr\xEAn \u0111\xF3. V\xEC vi\u1EC7c t\u1EA1o chu\u1ED7i d\xE0i c\xF3 th\u1EC3 ch\u1EADm, ch\xFAng ta l\u1EA5y m\u1EABu thay th\u1EBF b\u1ED9 ki\u1EC3m \u0111\u1ECBnh \u0111\u1EC3 \u0111\u1EA3m b\u1EA3o \u0111i\u1EC1u n\xE0y kh\xF4ng ch\u1EA1y m\xE3i m\xE3i:"),P=p(),y(q.$$.fragment)},l(T){o=c(T,"P",{});var S=r(o);$=a(S,"\u0110\u1EC3 chuy\u1EC3n t\u1EEB k\u1EBFt qu\u1EA3 \u0111\u1EA7u ra c\u1EE7a m\xF4 h\xECnh th\xE0nh v\u0103n b\u1EA3n m\xE0 ch\u1EC9 s\u1ED1 c\xF3 th\u1EC3 s\u1EED d\u1EE5ng, ch\xFAng ta s\u1EBD s\u1EED d\u1EE5ng ph\u01B0\u01A1ng th\u1EE9c "),d=c(S,"CODE",{});var F=r(d);x=a(F,"tokenizer.batch_decode()"),F.forEach(t),z=a(S,". Ch\xFAng ta ch\u1EC9 c\u1EA7n x\xF3a t\u1EA5t c\u1EA3 c\xE1c "),_=c(S,"CODE",{});var I=r(_);C=a(I,"-100"),I.forEach(t),D=a(S," trong c\xE1c nh\xE3n; tokenizer s\u1EBD t\u1EF1 \u0111\u1ED9ng l\xE0m \u0111i\u1EC1u t\u01B0\u01A1ng t\u1EF1 \u0111\u1ED1i v\u1EDBi token \u0111\u1EC7m. H\xE3y x\xE1c \u0111\u1ECBnh m\u1ED9t h\xE0m s\u1EED d\u1EE5ng m\xF4 h\xECnh v\xE0 t\u1EADp d\u1EEF li\u1EC7u c\u1EE7a ch\xFAng ta v\xE0 t\xEDnh to\xE1n c\xE1c s\u1ED1 li\u1EC7u tr\xEAn \u0111\xF3. V\xEC vi\u1EC7c t\u1EA1o chu\u1ED7i d\xE0i c\xF3 th\u1EC3 ch\u1EADm, ch\xFAng ta l\u1EA5y m\u1EABu thay th\u1EBF b\u1ED9 ki\u1EC3m \u0111\u1ECBnh \u0111\u1EC3 \u0111\u1EA3m b\u1EA3o \u0111i\u1EC1u n\xE0y kh\xF4ng ch\u1EA1y m\xE3i m\xE3i:"),S.forEach(t),P=u(T),j(q.$$.fragment,T)},m(T,S){h(T,o,S),e(o,$),e(o,d),e(d,x),e(o,z),e(o,_),e(_,C),e(o,D),h(T,P,S),E(q,T,S),O=!0},i(T){O||(b(q.$$.fragment,T),O=!0)},o(T){v(q.$$.fragment,T),O=!1},d(T){T&&t(o),T&&t(P),w(q,T)}}}function zu(V){let o,$,d,x,z,_,C,D,P,q,O,T,S,F,I,B,tn,U,H,X,Y,rn,on,sn,Q,Z,R,un,dn,en,nn,fn,mn,ln,M,G,jn,xn,pn,W,an,kn,Tn,On,_n,bn,J,Cn,wn,mt,Nn,En,Ln,gt,$n,Hn,at,k,K,Bn,zn,gn,ht,Tt,cn,Pn,lt,Ct,qn,ct,rt,hn,Pt,Dn,ue,Mt,Ft,Wn,Mn,Dt,dt,zt,At,Yn,ne,yn,St,Zn,me,ft,Fn,_t,Un,bt,te,ge,In,Vn,Jn,ee,vt,Kn,Qn,se,it,An,Ut,kt,de,Rn,$t,nt,Ot,yt,It,tt,Ee,ae;return S=new A({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>,
)`}}),K=new Ys({props:{$$slots:{default:[Su]},$$scope:{ctx:V}}}),lt=new A({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,
)`}}),hn=new A({props:{code:"trainer.evaluate(max_length=max_target_length)",highlighted:"trainer.evaluate(max_length=max_target_length)"}}),Dn=new A({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>}`}}),zt=new A({props:{code:"trainer.train()",highlighted:"trainer.train()"}}),ft=new A({props:{code:"trainer.evaluate(max_length=max_target_length)",highlighted:"trainer.evaluate(max_length=max_target_length)"}}),_t=new A({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>}`}}),An=new A({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>)'}}),$t=new A({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(){o=l("p"),$=s("Khi \u0111i\u1EC1u n\xE0y \u0111\u01B0\u1EE3c th\u1EF1c hi\u1EC7n, ch\xFAng ta c\xF3 th\u1EC3 x\xE1c \u0111\u1ECBnh "),d=l("code"),x=s("Seq2SeqTrainingArguments"),z=s(". Gi\u1ED1ng nh\u01B0 \u0111\u1ED1i v\u1EDBi "),_=l("code"),C=s("Trainer"),D=s(", ch\xFAng ta s\u1EED d\u1EE5ng m\u1ED9t l\u1EDBp con c\u1EE7a "),P=l("code"),q=s("TrainingArguments"),O=s(" ch\u1EE9a th\xEAm m\u1ED9t s\u1ED1 tr\u01B0\u1EDDng:"),T=p(),y(S.$$.fragment),F=p(),I=l("p"),B=s("Ngo\xE0i c\xE1c si\xEAu tham s\u1ED1 th\xF4ng th\u01B0\u1EDDng (nh\u01B0 t\u1ED1c \u0111\u1ED9 h\u1ECDc, s\u1ED1 epoch, k\xEDch th\u01B0\u1EDBc l\xF4 v\xE0 m\u1ED9t s\u1ED1 ph\xE2n r\xE3 tr\u1ECDng s\u1ED1), \u0111\xE2y l\xE0 m\u1ED9t s\u1ED1 thay \u0111\u1ED5i so v\u1EDBi nh\u1EEFng g\xEC ch\xFAng ta \u0111\xE3 th\u1EA5y trong c\xE1c ph\u1EA7n tr\u01B0\u1EDBc:"),tn=p(),U=l("ul"),H=l("li"),X=s("Ch\xFAng ta kh\xF4ng \u0111\u1EB7t b\u1EA5t k\u1EF3 \u0111\xE1nh gi\xE1 th\u01B0\u1EDDng xuy\xEAn n\xE0o, v\xEC qu\xE1 tr\xECnh \u0111\xE1nh gi\xE1 s\u1EBD m\u1EA5t m\u1ED9t kho\u1EA3ng th\u1EDDi gian; ch\xFAng ta s\u1EBD ch\u1EC9 \u0111\xE1nh gi\xE1 m\xF4 h\xECnh c\u1EE7a m\xECnh m\u1ED9t l\u1EA7n tr\u01B0\u1EDBc khi hu\u1EA5n luy\u1EC7n v\xE0 sau \u0111\xF3."),Y=p(),rn=l("li"),on=s("Ch\xFAng ta \u0111\u1EB7t "),sn=l("code"),Q=s("fp16=True"),Z=s(", gi\xFAp t\u0103ng t\u1ED1c qu\xE1 tr\xECnh hu\u1EA5n luy\u1EC7n tr\xEAn c\xE1c GPU hi\u1EC7n \u0111\u1EA1i."),R=p(),un=l("li"),dn=s("Ch\xFAng ta \u0111\u1EB7t "),en=l("code"),nn=s("predict_with_generate=True"),fn=s(", nh\u01B0 \u0111\xE3 th\u1EA3o lu\u1EADn \u1EDF tr\xEAn."),mn=p(),ln=l("li"),M=s("Ch\xFAng ta s\u1EED d\u1EE5ng "),G=l("code"),jn=s("push_to_hub=True"),xn=s(" \u0111\u1EC3 t\u1EA3i m\xF4 h\xECnh l\xEAn Hub v\xE0o cu\u1ED1i m\u1ED7i epoch."),pn=p(),W=l("p"),an=s("L\u01B0u \xFD r\u1EB1ng b\u1EA1n c\xF3 th\u1EC3 ch\u1EC9 \u0111\u1ECBnh t\xEAn \u0111\u1EA7y \u0111\u1EE7 c\u1EE7a kho l\u01B0u tr\u1EEF m\xE0 b\u1EA1n mu\u1ED1n \u0111\u1EA9y \u0111\u1EBFn b\u1EB1ng tham s\u1ED1 "),kn=l("code"),Tn=s("hub_model_id"),On=s(" (\u0111\u1EB7c bi\u1EC7t, b\u1EA1n s\u1EBD ph\u1EA3i s\u1EED d\u1EE5ng tham s\u1ED1 n\xE0y \u0111\u1EC3 \u0111\u1EA9y \u0111\u1EBFn m\u1ED9t t\u1ED5 ch\u1EE9c). V\xED d\u1EE5: khi ch\xFAng ta \u0111\u1EA9y m\xF4 h\xECnh v\xE0o t\u1ED5 ch\u1EE9c "),_n=l("a"),bn=l("code"),J=s("huggingface-course"),Cn=s(", ch\xFAng ta \u0111\xE3 th\xEAm "),wn=l("code"),mt=s('hub_model_id="huggingface-course/marian-finetuned-kde4-en-to-fr"'),Nn=s(" th\xE0nh "),En=l("code"),Ln=s("Seq2SeqTrainingArguments"),gt=s(". Theo m\u1EB7c \u0111\u1ECBnh, kho l\u01B0u tr\u1EEF \u0111\u01B0\u1EE3c s\u1EED d\u1EE5ng s\u1EBD n\u1EB1m trong kh\xF4ng gian t\xEAn c\u1EE7a b\u1EA1n v\xE0 \u0111\u01B0\u1EE3c \u0111\u1EB7t t\xEAn theo th\u01B0 m\u1EE5c \u0111\u1EA7u ra m\xE0 b\u1EA1n \u0111\xE3 \u0111\u1EB7t, v\xEC v\u1EADy trong tr\u01B0\u1EDDng h\u1EE3p c\u1EE7a ch\xFAng t\xF4i, n\xF3 s\u1EBD l\xE0 "),$n=l("code"),Hn=s('"sgugger/marian-finetuned-kde4-en-to-fr"'),at=s(" (l\xE0 m\xF4 h\xECnh ch\xFAng t\xF4i li\xEAn k\u1EBFt \u0111\u1EBFn \u1EDF \u0111\u1EA7u ph\u1EA7n n\xE0y)."),k=p(),y(K.$$.fragment),Bn=p(),zn=l("p"),gn=s("Cu\u1ED1i c\xF9ng, ta ch\u1EC9 c\u1EA7n truy\u1EC1n m\u1ECDi th\u1EE9 cho "),ht=l("code"),Tt=s("Seq2SeqTrainer"),cn=s(":"),Pn=p(),y(lt.$$.fragment),Ct=p(),qn=l("p"),ct=s("Tr\u01B0\u1EDBc khi hu\u1EA5n luy\u1EC7n, tr\u01B0\u1EDBc ti\xEAn ch\xFAng ta s\u1EBD xem x\xE9t \u0111i\u1EC3m m\xE0 m\xF4 h\xECnh c\u1EE7a ch\xFAng ta nh\u1EADn \u0111\u01B0\u1EE3c, \u0111\u1EC3 ki\u1EC3m tra k\u1EF9 xem ch\xFAng ta c\xF3 \u0111ang kh\xF4ng l\xE0m m\u1ECDi th\u1EE9 t\u1ED3i t\u1EC7 h\u01A1n v\u1EDBi vi\u1EC7c tinh ch\u1EC9nh c\u1EE7a ch\xFAng ta hay kh\xF4ng. L\u1EC7nh n\xE0y s\u1EBD m\u1EA5t m\u1ED9t ch\xFAt th\u1EDDi gian, v\xEC v\u1EADy b\u1EA1n c\xF3 th\u1EC3 u\u1ED1ng m\u1ED9t ly c\xE0 ph\xEA trong khi n\xF3 th\u1EF1c thi:"),rt=p(),y(hn.$$.fragment),Pt=p(),y(Dn.$$.fragment),ue=p(),Mt=l("p"),Ft=s("\u0110i\u1EC3m BLEU l\xE0 39 kh\xF4ng qu\xE1 t\u1EC7, \u0111i\u1EC1u n\xE0y ph\u1EA3n \xE1nh th\u1EF1c t\u1EBF l\xE0 m\xF4 h\xECnh c\u1EE7a ch\xFAng ta \u0111\xE3 r\u1EA5t gi\u1ECFi trong vi\u1EC7c d\u1ECBch c\xE1c c\xE2u ti\u1EBFng Anh sang ti\u1EBFng Ph\xE1p."),Wn=p(),Mn=l("p"),Dt=s("Ti\u1EBFp theo l\xE0 hu\u1EA5n luy\u1EC7n, c\u0169ng s\u1EBD m\u1EA5t m\u1ED9t ch\xFAt th\u1EDDi gian:"),dt=p(),y(zt.$$.fragment),At=p(),Yn=l("p"),ne=s("L\u01B0u \xFD r\u1EB1ng trong khi qu\xE1 tr\xECnh hu\u1EA5n luy\u1EC7n di\u1EC5n ra, m\u1ED7i khi m\xF4 h\xECnh \u0111\u01B0\u1EE3c l\u01B0u (\u1EDF \u0111\xE2y, m\u1ED7i epoch), n\xF3 s\u1EBD \u0111\u01B0\u1EE3c t\u1EA3i l\xEAn Hub \u1EDF ch\u1EBF \u0111\u1ED9 n\u1EC1n. B\u1EB1ng c\xE1ch n\xE0y, b\u1EA1n s\u1EBD c\xF3 th\u1EC3 ti\u1EBFp t\u1EE5c hu\u1EA5n luy\u1EC7n c\u1EE7a m\xECnh tr\xEAn m\u1ED9t m\xE1y kh\xE1c n\u1EBFu c\u1EA7n."),yn=p(),St=l("p"),Zn=s("Sau khi hu\u1EA5n luy\u1EC7n xong, ch\xFAng ta \u0111\xE1nh gi\xE1 l\u1EA1i m\xF4 h\xECnh c\u1EE7a m\xECnh - hy v\u1ECDng ch\xFAng ta s\u1EBD th\u1EA5y m\u1ED9t s\u1ED1 c\u1EA3i thi\u1EC7n trong \u0111i\u1EC3m BLEU!"),me=p(),y(ft.$$.fragment),Fn=p(),y(_t.$$.fragment),Un=p(),bt=l("p"),te=s("\u0110\xF3 l\xE0 m\u1ED9t c\u1EA3i ti\u1EBFn h\u01A1n g\u1EA7n 14 \u0111i\u1EC3m, th\u1EADt tuy\u1EC7t v\u1EDDi."),ge=p(),In=l("p"),Vn=s("Cu\u1ED1i c\xF9ng, ch\xFAng ta s\u1EED d\u1EE5ng ph\u01B0\u01A1ng th\u1EE9c "),Jn=l("code"),ee=s("push_to_hub()"),vt=s(" \u0111\u1EC3 \u0111\u1EA3m b\u1EA3o t\u1EA3i l\xEAn phi\xEAn b\u1EA3n m\u1EDBi nh\u1EA5t c\u1EE7a m\xF4 h\xECnh. "),Kn=l("code"),Qn=s("Trainer"),se=s(" c\u0169ng so\u1EA1n th\u1EA3o m\u1ED9t th\u1EBB m\xF4 h\xECnh v\u1EDBi t\u1EA5t c\u1EA3 c\xE1c k\u1EBFt qu\u1EA3 \u0111\xE1nh gi\xE1 v\xE0 t\u1EA3i n\xF3 l\xEAn. Th\u1EBB m\xF4 h\xECnh n\xE0y ch\u1EE9a si\xEAu d\u1EEF li\u1EC7u gi\xFAp Model Hub ch\u1ECDn ti\u1EC7n \xEDch con cho b\u1EA3n tr\xECnh di\u1EC5n lu\u1EADn suy. Th\xF4ng th\u01B0\u1EDDng, kh\xF4ng c\u1EA7n ph\u1EA3i n\xF3i b\u1EA5t c\u1EE9 \u0111i\u1EC1u g\xEC v\xEC n\xF3 c\xF3 th\u1EC3 suy ra ti\u1EC7n \xEDch con ph\xF9 h\u1EE3p t\u1EEB l\u1EDBp m\xF4 h\xECnh, nh\u01B0ng trong tr\u01B0\u1EDDng h\u1EE3p n\xE0y, c\xF9ng m\u1ED9t l\u1EDBp m\xF4 h\xECnh c\xF3 th\u1EC3 \u0111\u01B0\u1EE3c s\u1EED d\u1EE5ng cho t\u1EA5t c\u1EA3 c\xE1c lo\u1EA1i v\u1EA5n \u0111\u1EC1 chu\u1ED7i sang chu\u1ED7i, v\xEC v\u1EADy ch\xFAng ta ch\u1EC9 \u0111\u1ECBnh \u0111\xF3 l\xE0 m\u1ED9t m\xF4 h\xECnh d\u1ECBch:"),it=p(),y(An.$$.fragment),Ut=p(),kt=l("p"),de=s("L\u1EC7nh n\xE0y tr\u1EA3 v\u1EC1 URL c\u1EE7a cam k\u1EBFt m\xE0 n\xF3 v\u1EEBa th\u1EF1c hi\u1EC7n, n\u1EBFu b\u1EA1n mu\u1ED1n ki\u1EC3m tra n\xF3:"),Rn=p(),y($t.$$.fragment),nt=p(),Ot=l("p"),yt=s("\u1EDE giai \u0111o\u1EA1n n\xE0y, b\u1EA1n c\xF3 th\u1EC3 s\u1EED d\u1EE5ng ti\u1EC7n \xEDch lu\u1EADn suy tr\xEAn Model Hub \u0111\u1EC3 ki\u1EC3m tra m\xF4 h\xECnh c\u1EE7a m\xECnh v\xE0 chia s\u1EBB v\u1EDBi b\u1EA1n b\xE8. B\u1EA1n \u0111\xE3 tinh ch\u1EC9nh th\xE0nh c\xF4ng m\u1ED9t m\xF4 h\xECnh trong t\xE1c v\u1EE5 d\u1ECBch - xin ch\xFAc m\u1EEBng!"),It=p(),tt=l("p"),Ee=s("N\u1EBFu b\u1EA1n mu\u1ED1n t\xECm hi\u1EC3u s\xE2u h\u01A1n m\u1ED9t ch\xFAt v\u1EC1 v\xF2ng l\u1EB7p hu\u1EA5n luy\u1EC7n, b\xE2y gi\u1EDD ch\xFAng t\xF4i s\u1EBD h\u01B0\u1EDBng d\u1EABn b\u1EA1n c\xE1ch th\u1EF1c hi\u1EC7n \u0111i\u1EC1u t\u01B0\u01A1ng t\u1EF1 b\u1EB1ng c\xE1ch s\u1EED d\u1EE5ng \u{1F917} Accelerate."),this.h()},l(g){o=c(g,"P",{});var N=r(o);$=a(N,"Khi \u0111i\u1EC1u n\xE0y \u0111\u01B0\u1EE3c th\u1EF1c hi\u1EC7n, ch\xFAng ta c\xF3 th\u1EC3 x\xE1c \u0111\u1ECBnh "),d=c(N,"CODE",{});var jt=r(d);x=a(jt,"Seq2SeqTrainingArguments"),jt.forEach(t),z=a(N,". Gi\u1ED1ng nh\u01B0 \u0111\u1ED1i v\u1EDBi "),_=c(N,"CODE",{});var we=r(_);C=a(we,"Trainer"),we.forEach(t),D=a(N,", ch\xFAng ta s\u1EED d\u1EE5ng m\u1ED9t l\u1EDBp con c\u1EE7a "),P=c(N,"CODE",{});var Et=r(P);q=a(Et,"TrainingArguments"),Et.forEach(t),O=a(N," ch\u1EE9a th\xEAm m\u1ED9t s\u1ED1 tr\u01B0\u1EDDng:"),N.forEach(t),T=u(g),j(S.$$.fragment,g),F=u(g),I=c(g,"P",{});var Xe=r(I);B=a(Xe,"Ngo\xE0i c\xE1c si\xEAu tham s\u1ED1 th\xF4ng th\u01B0\u1EDDng (nh\u01B0 t\u1ED1c \u0111\u1ED9 h\u1ECDc, s\u1ED1 epoch, k\xEDch th\u01B0\u1EDBc l\xF4 v\xE0 m\u1ED9t s\u1ED1 ph\xE2n r\xE3 tr\u1ECDng s\u1ED1), \u0111\xE2y l\xE0 m\u1ED9t s\u1ED1 thay \u0111\u1ED5i so v\u1EDBi nh\u1EEFng g\xEC ch\xFAng ta \u0111\xE3 th\u1EA5y trong c\xE1c ph\u1EA7n tr\u01B0\u1EDBc:"),Xe.forEach(t),tn=u(g),U=c(g,"UL",{});var ot=r(U);H=c(ot,"LI",{});var pt=r(H);X=a(pt,"Ch\xFAng ta kh\xF4ng \u0111\u1EB7t b\u1EA5t k\u1EF3 \u0111\xE1nh gi\xE1 th\u01B0\u1EDDng xuy\xEAn n\xE0o, v\xEC qu\xE1 tr\xECnh \u0111\xE1nh gi\xE1 s\u1EBD m\u1EA5t m\u1ED9t kho\u1EA3ng th\u1EDDi gian; ch\xFAng ta s\u1EBD ch\u1EC9 \u0111\xE1nh gi\xE1 m\xF4 h\xECnh c\u1EE7a m\xECnh m\u1ED9t l\u1EA7n tr\u01B0\u1EDBc khi hu\u1EA5n luy\u1EC7n v\xE0 sau \u0111\xF3."),pt.forEach(t),Y=u(ot),rn=c(ot,"LI",{});var he=r(rn);on=a(he,"Ch\xFAng ta \u0111\u1EB7t "),sn=c(he,"CODE",{});var Vt=r(sn);Q=a(Vt,"fp16=True"),Vt.forEach(t),Z=a(he,", gi\xFAp t\u0103ng t\u1ED1c qu\xE1 tr\xECnh hu\u1EA5n luy\u1EC7n tr\xEAn c\xE1c GPU hi\u1EC7n \u0111\u1EA1i."),he.forEach(t),R=u(ot),un=c(ot,"LI",{});var Kt=r(un);dn=a(Kt,"Ch\xFAng ta \u0111\u1EB7t "),en=c(Kt,"CODE",{});var vn=r(en);nn=a(vn,"predict_with_generate=True"),vn.forEach(t),fn=a(Kt,", nh\u01B0 \u0111\xE3 th\u1EA3o lu\u1EADn \u1EDF tr\xEAn."),Kt.forEach(t),mn=u(ot),ln=c(ot,"LI",{});var fe=r(ln);M=a(fe,"Ch\xFAng ta s\u1EED d\u1EE5ng "),G=c(fe,"CODE",{});var Nt=r(G);jn=a(Nt,"push_to_hub=True"),Nt.forEach(t),xn=a(fe," \u0111\u1EC3 t\u1EA3i m\xF4 h\xECnh l\xEAn Hub v\xE0o cu\u1ED1i m\u1ED7i epoch."),fe.forEach(t),ot.forEach(t),pn=u(g),W=c(g,"P",{});var Sn=r(W);an=a(Sn,"L\u01B0u \xFD r\u1EB1ng b\u1EA1n c\xF3 th\u1EC3 ch\u1EC9 \u0111\u1ECBnh t\xEAn \u0111\u1EA7y \u0111\u1EE7 c\u1EE7a kho l\u01B0u tr\u1EEF m\xE0 b\u1EA1n mu\u1ED1n \u0111\u1EA9y \u0111\u1EBFn b\u1EB1ng tham s\u1ED1 "),kn=c(Sn,"CODE",{});var We=r(kn);Tn=a(We,"hub_model_id"),We.forEach(t),On=a(Sn," (\u0111\u1EB7c bi\u1EC7t, b\u1EA1n s\u1EBD ph\u1EA3i s\u1EED d\u1EE5ng tham s\u1ED1 n\xE0y \u0111\u1EC3 \u0111\u1EA9y \u0111\u1EBFn m\u1ED9t t\u1ED5 ch\u1EE9c). V\xED d\u1EE5: khi ch\xFAng ta \u0111\u1EA9y m\xF4 h\xECnh v\xE0o t\u1ED5 ch\u1EE9c "),_n=c(Sn,"A",{href:!0,rel:!0});var Rt=r(_n);bn=c(Rt,"CODE",{});var Ye=r(bn);J=a(Ye,"huggingface-course"),Ye.forEach(t),Rt.forEach(t),Cn=a(Sn,", ch\xFAng ta \u0111\xE3 th\xEAm "),wn=c(Sn,"CODE",{});var Ze=r(wn);mt=a(Ze,'hub_model_id="huggingface-course/marian-finetuned-kde4-en-to-fr"'),Ze.forEach(t),Nn=a(Sn," th\xE0nh "),En=c(Sn,"CODE",{});var le=r(En);Ln=a(le,"Seq2SeqTrainingArguments"),le.forEach(t),gt=a(Sn,". Theo m\u1EB7c \u0111\u1ECBnh, kho l\u01B0u tr\u1EEF \u0111\u01B0\u1EE3c s\u1EED d\u1EE5ng s\u1EBD n\u1EB1m trong kh\xF4ng gian t\xEAn c\u1EE7a b\u1EA1n v\xE0 \u0111\u01B0\u1EE3c \u0111\u1EB7t t\xEAn theo th\u01B0 m\u1EE5c \u0111\u1EA7u ra m\xE0 b\u1EA1n \u0111\xE3 \u0111\u1EB7t, v\xEC v\u1EADy trong tr\u01B0\u1EDDng h\u1EE3p c\u1EE7a ch\xFAng t\xF4i, n\xF3 s\u1EBD l\xE0 "),$n=c(Sn,"CODE",{});var Gn=r($n);Hn=a(Gn,'"sgugger/marian-finetuned-kde4-en-to-fr"'),Gn.forEach(t),at=a(Sn," (l\xE0 m\xF4 h\xECnh ch\xFAng t\xF4i li\xEAn k\u1EBFt \u0111\u1EBFn \u1EDF \u0111\u1EA7u ph\u1EA7n n\xE0y)."),Sn.forEach(t),k=u(g),j(K.$$.fragment,g),Bn=u(g),zn=c(g,"P",{});var _e=r(zn);gn=a(_e,"Cu\u1ED1i c\xF9ng, ta ch\u1EC9 c\u1EA7n truy\u1EC1n m\u1ECDi th\u1EE9 cho "),ht=c(_e,"CODE",{});var Gt=r(ht);Tt=a(Gt,"Seq2SeqTrainer"),Gt.forEach(t),cn=a(_e,":"),_e.forEach(t),Pn=u(g),j(lt.$$.fragment,g),Ct=u(g),qn=c(g,"P",{});var Xt=r(qn);ct=a(Xt,"Tr\u01B0\u1EDBc khi hu\u1EA5n luy\u1EC7n, tr\u01B0\u1EDBc ti\xEAn ch\xFAng ta s\u1EBD xem x\xE9t \u0111i\u1EC3m m\xE0 m\xF4 h\xECnh c\u1EE7a ch\xFAng ta nh\u1EADn \u0111\u01B0\u1EE3c, \u0111\u1EC3 ki\u1EC3m tra k\u1EF9 xem ch\xFAng ta c\xF3 \u0111ang kh\xF4ng l\xE0m m\u1ECDi th\u1EE9 t\u1ED3i t\u1EC7 h\u01A1n v\u1EDBi vi\u1EC7c tinh ch\u1EC9nh c\u1EE7a ch\xFAng ta hay kh\xF4ng. L\u1EC7nh n\xE0y s\u1EBD m\u1EA5t m\u1ED9t ch\xFAt th\u1EDDi gian, v\xEC v\u1EADy b\u1EA1n c\xF3 th\u1EC3 u\u1ED1ng m\u1ED9t ly c\xE0 ph\xEA trong khi n\xF3 th\u1EF1c thi:"),Xt.forEach(t),rt=u(g),j(hn.$$.fragment,g),Pt=u(g),j(Dn.$$.fragment,g),ue=u(g),Mt=c(g,"P",{});var xe=r(Mt);Ft=a(xe,"\u0110i\u1EC3m BLEU l\xE0 39 kh\xF4ng qu\xE1 t\u1EC7, \u0111i\u1EC1u n\xE0y ph\u1EA3n \xE1nh th\u1EF1c t\u1EBF l\xE0 m\xF4 h\xECnh c\u1EE7a ch\xFAng ta \u0111\xE3 r\u1EA5t gi\u1ECFi trong vi\u1EC7c d\u1ECBch c\xE1c c\xE2u ti\u1EBFng Anh sang ti\u1EBFng Ph\xE1p."),xe.forEach(t),Wn=u(g),Mn=c(g,"P",{});var wt=r(Mn);Dt=a(wt,"Ti\u1EBFp theo l\xE0 hu\u1EA5n luy\u1EC7n, c\u0169ng s\u1EBD m\u1EA5t m\u1ED9t ch\xFAt th\u1EDDi gian:"),wt.forEach(t),dt=u(g),j(zt.$$.fragment,g),At=u(g),Yn=c(g,"P",{});var qe=r(Yn);ne=a(qe,"L\u01B0u \xFD r\u1EB1ng trong khi qu\xE1 tr\xECnh hu\u1EA5n luy\u1EC7n di\u1EC5n ra, m\u1ED7i khi m\xF4 h\xECnh \u0111\u01B0\u1EE3c l\u01B0u (\u1EDF \u0111\xE2y, m\u1ED7i epoch), n\xF3 s\u1EBD \u0111\u01B0\u1EE3c t\u1EA3i l\xEAn Hub \u1EDF ch\u1EBF \u0111\u1ED9 n\u1EC1n. B\u1EB1ng c\xE1ch n\xE0y, b\u1EA1n s\u1EBD c\xF3 th\u1EC3 ti\u1EBFp t\u1EE5c hu\u1EA5n luy\u1EC7n c\u1EE7a m\xECnh tr\xEAn m\u1ED9t m\xE1y kh\xE1c n\u1EBFu c\u1EA7n."),qe.forEach(t),yn=u(g),St=c(g,"P",{});var ut=r(St);Zn=a(ut,"Sau khi hu\u1EA5n luy\u1EC7n xong, ch\xFAng ta \u0111\xE1nh gi\xE1 l\u1EA1i m\xF4 h\xECnh c\u1EE7a m\xECnh - hy v\u1ECDng ch\xFAng ta s\u1EBD th\u1EA5y m\u1ED9t s\u1ED1 c\u1EA3i thi\u1EC7n trong \u0111i\u1EC3m BLEU!"),ut.forEach(t),me=u(g),j(ft.$$.fragment,g),Fn=u(g),j(_t.$$.fragment,g),Un=u(g),bt=c(g,"P",{});var be=r(bt);te=a(be,"\u0110\xF3 l\xE0 m\u1ED9t c\u1EA3i ti\u1EBFn h\u01A1n g\u1EA7n 14 \u0111i\u1EC3m, th\u1EADt tuy\u1EC7t v\u1EDDi."),be.forEach(t),ge=u(g),In=c(g,"P",{});var xt=r(In);Vn=a(xt,"Cu\u1ED1i c\xF9ng, ch\xFAng ta s\u1EED d\u1EE5ng ph\u01B0\u01A1ng th\u1EE9c "),Jn=c(xt,"CODE",{});var Je=r(Jn);ee=a(Je,"push_to_hub()"),Je.forEach(t),vt=a(xt," \u0111\u1EC3 \u0111\u1EA3m b\u1EA3o t\u1EA3i l\xEAn phi\xEAn b\u1EA3n m\u1EDBi nh\u1EA5t c\u1EE7a m\xF4 h\xECnh. "),Kn=c(xt,"CODE",{});var Te=r(Kn);Qn=a(Te,"Trainer"),Te.forEach(t),se=a(xt," c\u0169ng so\u1EA1n th\u1EA3o m\u1ED9t th\u1EBB m\xF4 h\xECnh v\u1EDBi t\u1EA5t c\u1EA3 c\xE1c k\u1EBFt qu\u1EA3 \u0111\xE1nh gi\xE1 v\xE0 t\u1EA3i n\xF3 l\xEAn. Th\u1EBB m\xF4 h\xECnh n\xE0y ch\u1EE9a si\xEAu d\u1EEF li\u1EC7u gi\xFAp Model Hub ch\u1ECDn ti\u1EC7n \xEDch con cho b\u1EA3n tr\xECnh di\u1EC5n lu\u1EADn suy. Th\xF4ng th\u01B0\u1EDDng, kh\xF4ng c\u1EA7n ph\u1EA3i n\xF3i b\u1EA5t c\u1EE9 \u0111i\u1EC1u g\xEC v\xEC n\xF3 c\xF3 th\u1EC3 suy ra ti\u1EC7n \xEDch con ph\xF9 h\u1EE3p t\u1EEB l\u1EDBp m\xF4 h\xECnh, nh\u01B0ng trong tr\u01B0\u1EDDng h\u1EE3p n\xE0y, c\xF9ng m\u1ED9t l\u1EDBp m\xF4 h\xECnh c\xF3 th\u1EC3 \u0111\u01B0\u1EE3c s\u1EED d\u1EE5ng cho t\u1EA5t c\u1EA3 c\xE1c lo\u1EA1i v\u1EA5n \u0111\u1EC1 chu\u1ED7i sang chu\u1ED7i, v\xEC v\u1EADy ch\xFAng ta ch\u1EC9 \u0111\u1ECBnh \u0111\xF3 l\xE0 m\u1ED9t m\xF4 h\xECnh d\u1ECBch:"),xt.forEach(t),it=u(g),j(An.$$.fragment,g),Ut=u(g),kt=c(g,"P",{});var qt=r(kt);de=a(qt,"L\u1EC7nh n\xE0y tr\u1EA3 v\u1EC1 URL c\u1EE7a cam k\u1EBFt m\xE0 n\xF3 v\u1EEBa th\u1EF1c hi\u1EC7n, n\u1EBFu b\u1EA1n mu\u1ED1n ki\u1EC3m tra n\xF3:"),qt.forEach(t),Rn=u(g),j($t.$$.fragment,g),nt=u(g),Ot=c(g,"P",{});var Ce=r(Ot);yt=a(Ce,"\u1EDE giai \u0111o\u1EA1n n\xE0y, b\u1EA1n c\xF3 th\u1EC3 s\u1EED d\u1EE5ng ti\u1EC7n \xEDch lu\u1EADn suy tr\xEAn Model Hub \u0111\u1EC3 ki\u1EC3m tra m\xF4 h\xECnh c\u1EE7a m\xECnh v\xE0 chia s\u1EBB v\u1EDBi b\u1EA1n b\xE8. B\u1EA1n \u0111\xE3 tinh ch\u1EC9nh th\xE0nh c\xF4ng m\u1ED9t m\xF4 h\xECnh trong t\xE1c v\u1EE5 d\u1ECBch - xin ch\xFAc m\u1EEBng!"),Ce.forEach(t),It=u(g),tt=c(g,"P",{});var Wt=r(tt);Ee=a(Wt,"N\u1EBFu b\u1EA1n mu\u1ED1n t\xECm hi\u1EC3u s\xE2u h\u01A1n m\u1ED9t ch\xFAt v\u1EC1 v\xF2ng l\u1EB7p hu\u1EA5n luy\u1EC7n, b\xE2y gi\u1EDD ch\xFAng t\xF4i s\u1EBD h\u01B0\u1EDBng d\u1EABn b\u1EA1n c\xE1ch th\u1EF1c hi\u1EC7n \u0111i\u1EC1u t\u01B0\u01A1ng t\u1EF1 b\u1EB1ng c\xE1ch s\u1EED d\u1EE5ng \u{1F917} Accelerate."),Wt.forEach(t),this.h()},h(){f(_n,"href","https://huggingface.co/huggingface-course"),f(_n,"rel","nofollow")},m(g,N){h(g,o,N),e(o,$),e(o,d),e(d,x),e(o,z),e(o,_),e(_,C),e(o,D),e(o,P),e(P,q),e(o,O),h(g,T,N),E(S,g,N),h(g,F,N),h(g,I,N),e(I,B),h(g,tn,N),h(g,U,N),e(U,H),e(H,X),e(U,Y),e(U,rn),e(rn,on),e(rn,sn),e(sn,Q),e(rn,Z),e(U,R),e(U,un),e(un,dn),e(un,en),e(en,nn),e(un,fn),e(U,mn),e(U,ln),e(ln,M),e(ln,G),e(G,jn),e(ln,xn),h(g,pn,N),h(g,W,N),e(W,an),e(W,kn),e(kn,Tn),e(W,On),e(W,_n),e(_n,bn),e(bn,J),e(W,Cn),e(W,wn),e(wn,mt),e(W,Nn),e(W,En),e(En,Ln),e(W,gt),e(W,$n),e($n,Hn),e(W,at),h(g,k,N),E(K,g,N),h(g,Bn,N),h(g,zn,N),e(zn,gn),e(zn,ht),e(ht,Tt),e(zn,cn),h(g,Pn,N),E(lt,g,N),h(g,Ct,N),h(g,qn,N),e(qn,ct),h(g,rt,N),E(hn,g,N),h(g,Pt,N),E(Dn,g,N),h(g,ue,N),h(g,Mt,N),e(Mt,Ft),h(g,Wn,N),h(g,Mn,N),e(Mn,Dt),h(g,dt,N),E(zt,g,N),h(g,At,N),h(g,Yn,N),e(Yn,ne),h(g,yn,N),h(g,St,N),e(St,Zn),h(g,me,N),E(ft,g,N),h(g,Fn,N),E(_t,g,N),h(g,Un,N),h(g,bt,N),e(bt,te),h(g,ge,N),h(g,In,N),e(In,Vn),e(In,Jn),e(Jn,ee),e(In,vt),e(In,Kn),e(Kn,Qn),e(In,se),h(g,it,N),E(An,g,N),h(g,Ut,N),h(g,kt,N),e(kt,de),h(g,Rn,N),E($t,g,N),h(g,nt,N),h(g,Ot,N),e(Ot,yt),h(g,It,N),h(g,tt,N),e(tt,Ee),ae=!0},i(g){ae||(b(S.$$.fragment,g),b(K.$$.fragment,g),b(lt.$$.fragment,g),b(hn.$$.fragment,g),b(Dn.$$.fragment,g),b(zt.$$.fragment,g),b(ft.$$.fragment,g),b(_t.$$.fragment,g),b(An.$$.fragment,g),b($t.$$.fragment,g),ae=!0)},o(g){v(S.$$.fragment,g),v(K.$$.fragment,g),v(lt.$$.fragment,g),v(hn.$$.fragment,g),v(Dn.$$.fragment,g),v(zt.$$.fragment,g),v(ft.$$.fragment,g),v(_t.$$.fragment,g),v(An.$$.fragment,g),v($t.$$.fragment,g),ae=!1},d(g){g&&t(o),g&&t(T),w(S,g),g&&t(F),g&&t(I),g&&t(tn),g&&t(U),g&&t(pn),g&&t(W),g&&t(k),w(K,g),g&&t(Bn),g&&t(zn),g&&t(Pn),w(lt,g),g&&t(Ct),g&&t(qn),g&&t(rt),w(hn,g),g&&t(Pt),w(Dn,g),g&&t(ue),g&&t(Mt),g&&t(Wn),g&&t(Mn),g&&t(dt),w(zt,g),g&&t(At),g&&t(Yn),g&&t(yn),g&&t(St),g&&t(me),w(ft,g),g&&t(Fn),w(_t,g),g&&t(Un),g&&t(bt),g&&t(ge),g&&t(In),g&&t(it),w(An,g),g&&t(Ut),g&&t(kt),g&&t(Rn),w($t,g),g&&t(nt),g&&t(Ot),g&&t(It),g&&t(tt)}}}function Au(V){let o,$,d,x,z,_,C,D,P,q,O,T,S,F,I,B,tn,U,H,X,Y,rn,on,sn,Q,Z,R,un,dn,en,nn,fn,mn,ln,M,G,jn,xn,pn,W,an,kn,Tn,On,_n,bn,J,Cn,wn,mt,Nn,En,Ln,gt,$n,Hn,at;return x=new A({props:{code:"print(compute_metrics())",highlighted:'<span class="hljs-built_in">print</span>(compute_metrics())'}}),_=new A({props:{code:"{'bleu': 33.26983701454733}",highlighted:'{&#x27;bleu&#x27;: <span class="hljs-number">33.26983701454733</span>}'}}),F=new A({props:{code:`from transformers import create_optimizer
from transformers.keras_callbacks import PushToHubCallback
import tensorflow as tf

# S\u1ED1 b\u01B0\u1EDBc hu\u1EA5n luy\u1EC7n l\xE0 s\u1ED1 l\u01B0\u1EE3ng m\u1EABu trong t\u1EADp d\u1EEF li\u1EC7u, chia cho k\xEDch th\u01B0\u1EDBc l\xF4 sau \u0111\xF3 nh\xE2n
# v\u1EDBi t\u1ED5ng s\u1ED1 epoch. L\u01B0u \xFD r\u1EB1ng tf_train_dataset \u1EDF \u0111\xE2y l\xE0 tf.data.Dataset theo l\xF4,
# kh\xF4ng ph\u1EA3i l\xE0 Hugging Face Dataset ban \u0111\u1EA7u, v\xEC v\u1EADy len() c\u1EE7a n\xF3 v\u1ED1n l\xE0 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)

# Hu\u1EA5n luy\u1EC7n trong 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"># S\u1ED1 b\u01B0\u1EDBc hu\u1EA5n luy\u1EC7n l\xE0 s\u1ED1 l\u01B0\u1EE3ng m\u1EABu trong t\u1EADp d\u1EEF li\u1EC7u, chia cho k\xEDch th\u01B0\u1EDBc l\xF4 sau \u0111\xF3 nh\xE2n</span>
<span class="hljs-comment"># v\u1EDBi t\u1ED5ng s\u1ED1 epoch. L\u01B0u \xFD r\u1EB1ng tf_train_dataset \u1EDF \u0111\xE2y l\xE0 tf.data.Dataset theo l\xF4,</span>
<span class="hljs-comment"># kh\xF4ng ph\u1EA3i l\xE0 Hugging Face Dataset ban \u0111\u1EA7u, v\xEC v\u1EADy len() c\u1EE7a n\xF3 v\u1ED1n l\xE0 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"># Hu\u1EA5n luy\u1EC7n trong mixed-precision float16</span>
tf.keras.mixed_precision.set_global_policy(<span class="hljs-string">&quot;mixed_float16&quot;</span>)`}}),Q=new A({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,
)`}}),bn=new Ys({props:{$$slots:{default:[Ou]},$$scope:{ctx:V}}}),Nn=new A({props:{code:"print(compute_metrics())",highlighted:'<span class="hljs-built_in">print</span>(compute_metrics())'}}),Ln=new A({props:{code:"{'bleu': 57.334066271545865}",highlighted:'{&#x27;bleu&#x27;: <span class="hljs-number">57.334066271545865</span>}'}}),{c(){o=l("p"),$=s("Tr\u01B0\u1EDBc khi b\u1EAFt \u0111\u1EA7u, h\xE3y xem lo\u1EA1i k\u1EBFt qu\u1EA3 n\xE0o ch\xFAng t\xF4i nh\u1EADn \u0111\u01B0\u1EE3c t\u1EEB m\xF4 h\xECnh c\u1EE7a m\xECnh m\xE0 kh\xF4ng c\u1EA7n hu\u1EA5n luy\u1EC7n:"),d=p(),y(x.$$.fragment),z=p(),y(_.$$.fragment),C=p(),D=l("p"),P=s("Khi \u0111i\u1EC1u n\xE0y \u0111\u01B0\u1EE3c th\u1EF1c hi\u1EC7n, ch\xFAng ta c\xF3 th\u1EC3 chu\u1EA9n b\u1ECB m\u1ECDi th\u1EE9 c\u1EA7n \u0111\u1EC3 bi\xEAn d\u1ECBch v\xE0 hu\u1EA5n luy\u1EC7n m\xF4 h\xECnh c\u1EE7a m\xECnh. L\u01B0u \xFD vi\u1EC7c s\u1EED d\u1EE5ng "),q=l("code"),O=s('tf.keras.mixed_precision.set_global_policy("mixed_float16")'),T=s(" - \u0111i\u1EC1u n\xE0y s\u1EBD y\xEAu c\u1EA7u Keras hu\u1EA5n luy\u1EC7n b\u1EB1ng c\xE1ch s\u1EED d\u1EE5ng float16, \u0111i\u1EC1u c\xF3 th\u1EC3 gi\xFAp t\u0103ng t\u1ED1c \u0111\xE1ng k\u1EC3 tr\xEAn c\xE1c GPU h\u1ED7 tr\u1EE3 n\xF3 (Nvidia 20xx/V100 ho\u1EB7c m\u1EDBi h\u01A1n)."),S=p(),y(F.$$.fragment),I=p(),B=l("p"),tn=s("Ti\u1EBFp theo, ch\xFAng ta x\xE1c \u0111\u1ECBnh m\u1ED9t "),U=l("code"),H=s("PushToHubCallback"),X=s(" \u0111\u1EC3 t\u1EA3i m\xF4 h\xECnh l\xEAn Hub trong qu\xE1 tr\xECnh hu\u1EA5n luy\u1EC7n, nh\u01B0 ch\xFAng ta \u0111\xE3 th\u1EA5y trong "),Y=l("a"),rn=s("ph\u1EA7n 2"),on=s(", v\xE0 sau \u0111\xF3 ch\xFAng ta ch\u1EC9 c\u1EA7n \u0111i\u1EC1u ch\u1EC9nh m\xF4 h\xECnh v\u1EDBi l\u1EC7nh g\u1ECDi l\u1EA1i \u0111\xF3:"),sn=p(),y(Q.$$.fragment),Z=p(),R=l("p"),un=s("L\u01B0u \xFD r\u1EB1ng b\u1EA1n c\xF3 th\u1EC3 ch\u1EC9 \u0111\u1ECBnh t\xEAn c\u1EE7a kho l\u01B0u tr\u1EEF m\xE0 b\u1EA1n mu\u1ED1n \u0111\u1EA9y l\xEAn b\u1EB1ng tham s\u1ED1 "),dn=l("code"),en=s("hub_model_id"),nn=s(" (c\u1EE5 th\u1EC3 l\xE0 b\u1EA1n s\u1EBD ph\u1EA3i s\u1EED d\u1EE5ng tham s\u1ED1 n\xE0y \u0111\u1EC3 \u0111\u1EA9y l\xEAn m\u1ED9t t\u1ED5 ch\u1EE9c). V\xED d\u1EE5: khi ch\xFAng t\xF4i \u0111\u1EA9y m\xF4 h\xECnh v\xE0o t\u1ED5 ch\u1EE9c "),fn=l("a"),mn=l("code"),ln=s("huggingface-course"),M=s(", ch\xFAng ta \u0111\xE3 th\xEAm "),G=l("code"),jn=s('hub_model_id="huggingface-course/marian-finetuned-kde4-en-to-fr"'),xn=s(" th\xE0nh "),pn=l("code"),W=s("Seq2SeqTrainingArguments"),an=s(". Theo m\u1EB7c \u0111\u1ECBnh, kho l\u01B0u tr\u1EEF \u0111\u01B0\u1EE3c s\u1EED d\u1EE5ng s\u1EBD n\u1EB1m trong kh\xF4ng gian t\xEAn c\u1EE7a b\u1EA1n v\xE0 \u0111\u01B0\u1EE3c \u0111\u1EB7t t\xEAn theo th\u01B0 m\u1EE5c \u0111\u1EA7u ra m\xE0 b\u1EA1n \u0111\xE3 \u0111\u1EB7t, v\xEC v\u1EADy \u1EDF \u0111\xE2y n\xF3 s\u1EBD l\xE0 "),kn=l("code"),Tn=s('"sgugger/marian-finetuned-kde4-en-to-fr"'),On=s(" (l\xE0 m\xF4 h\xECnh m\xE0 ch\xFAng t\xF4i \u0111\xE3 li\xEAn k\u1EBFt v\u1EDBi \u1EDF \u0111\u1EA7u ph\u1EA7n n\xE0y)."),_n=p(),y(bn.$$.fragment),J=p(),Cn=l("p"),wn=s("Cu\u1ED1i c\xF9ng, h\xE3y xem c\xE1c ch\u1EC9 s\u1ED1 c\u1EE7a ch\xFAng ta tr\xF4ng nh\u01B0 th\u1EBF n\xE0o khi qu\xE1 tr\xECnh hu\u1EA5n luy\u1EC7n \u0111\xE3 k\u1EBFt th\xFAc:"),mt=p(),y(Nn.$$.fragment),En=p(),y(Ln.$$.fragment),gt=p(),$n=l("p"),Hn=s("\u1EDE giai \u0111o\u1EA1n n\xE0y, b\u1EA1n c\xF3 th\u1EC3 s\u1EED d\u1EE5ng ti\u1EC7n \xEDch lu\u1EADn suy tr\xEAn Model Hub \u0111\u1EC3 ki\u1EC3m tra m\xF4 h\xECnh c\u1EE7a m\xECnh v\xE0 chia s\u1EBB v\u1EDBi b\u1EA1n b\xE8. B\u1EA1n \u0111\xE3 tinh ch\u1EC9nh th\xE0nh c\xF4ng m\u1ED9t m\xF4 h\xECnh trong t\xE1c v\u1EE5 d\u1ECBch - xin ch\xFAc m\u1EEBng!"),this.h()},l(k){o=c(k,"P",{});var K=r(o);$=a(K,"Tr\u01B0\u1EDBc khi b\u1EAFt \u0111\u1EA7u, h\xE3y xem lo\u1EA1i k\u1EBFt qu\u1EA3 n\xE0o ch\xFAng t\xF4i nh\u1EADn \u0111\u01B0\u1EE3c t\u1EEB m\xF4 h\xECnh c\u1EE7a m\xECnh m\xE0 kh\xF4ng c\u1EA7n hu\u1EA5n luy\u1EC7n:"),K.forEach(t),d=u(k),j(x.$$.fragment,k),z=u(k),j(_.$$.fragment,k),C=u(k),D=c(k,"P",{});var Bn=r(D);P=a(Bn,"Khi \u0111i\u1EC1u n\xE0y \u0111\u01B0\u1EE3c th\u1EF1c hi\u1EC7n, ch\xFAng ta c\xF3 th\u1EC3 chu\u1EA9n b\u1ECB m\u1ECDi th\u1EE9 c\u1EA7n \u0111\u1EC3 bi\xEAn d\u1ECBch v\xE0 hu\u1EA5n luy\u1EC7n m\xF4 h\xECnh c\u1EE7a m\xECnh. L\u01B0u \xFD vi\u1EC7c s\u1EED d\u1EE5ng "),q=c(Bn,"CODE",{});var zn=r(q);O=a(zn,'tf.keras.mixed_precision.set_global_policy("mixed_float16")'),zn.forEach(t),T=a(Bn," - \u0111i\u1EC1u n\xE0y s\u1EBD y\xEAu c\u1EA7u Keras hu\u1EA5n luy\u1EC7n b\u1EB1ng c\xE1ch s\u1EED d\u1EE5ng float16, \u0111i\u1EC1u c\xF3 th\u1EC3 gi\xFAp t\u0103ng t\u1ED1c \u0111\xE1ng k\u1EC3 tr\xEAn c\xE1c GPU h\u1ED7 tr\u1EE3 n\xF3 (Nvidia 20xx/V100 ho\u1EB7c m\u1EDBi h\u01A1n)."),Bn.forEach(t),S=u(k),j(F.$$.fragment,k),I=u(k),B=c(k,"P",{});var gn=r(B);tn=a(gn,"Ti\u1EBFp theo, ch\xFAng ta x\xE1c \u0111\u1ECBnh m\u1ED9t "),U=c(gn,"CODE",{});var ht=r(U);H=a(ht,"PushToHubCallback"),ht.forEach(t),X=a(gn," \u0111\u1EC3 t\u1EA3i m\xF4 h\xECnh l\xEAn Hub trong qu\xE1 tr\xECnh hu\u1EA5n luy\u1EC7n, nh\u01B0 ch\xFAng ta \u0111\xE3 th\u1EA5y trong "),Y=c(gn,"A",{href:!0});var Tt=r(Y);rn=a(Tt,"ph\u1EA7n 2"),Tt.forEach(t),on=a(gn,", v\xE0 sau \u0111\xF3 ch\xFAng ta ch\u1EC9 c\u1EA7n \u0111i\u1EC1u ch\u1EC9nh m\xF4 h\xECnh v\u1EDBi l\u1EC7nh g\u1ECDi l\u1EA1i \u0111\xF3:"),gn.forEach(t),sn=u(k),j(Q.$$.fragment,k),Z=u(k),R=c(k,"P",{});var cn=r(R);un=a(cn,"L\u01B0u \xFD r\u1EB1ng b\u1EA1n c\xF3 th\u1EC3 ch\u1EC9 \u0111\u1ECBnh t\xEAn c\u1EE7a kho l\u01B0u tr\u1EEF m\xE0 b\u1EA1n mu\u1ED1n \u0111\u1EA9y l\xEAn b\u1EB1ng tham s\u1ED1 "),dn=c(cn,"CODE",{});var Pn=r(dn);en=a(Pn,"hub_model_id"),Pn.forEach(t),nn=a(cn," (c\u1EE5 th\u1EC3 l\xE0 b\u1EA1n s\u1EBD ph\u1EA3i s\u1EED d\u1EE5ng tham s\u1ED1 n\xE0y \u0111\u1EC3 \u0111\u1EA9y l\xEAn m\u1ED9t t\u1ED5 ch\u1EE9c). V\xED d\u1EE5: khi ch\xFAng t\xF4i \u0111\u1EA9y m\xF4 h\xECnh v\xE0o t\u1ED5 ch\u1EE9c "),fn=c(cn,"A",{href:!0,rel:!0});var lt=r(fn);mn=c(lt,"CODE",{});var Ct=r(mn);ln=a(Ct,"huggingface-course"),Ct.forEach(t),lt.forEach(t),M=a(cn,", ch\xFAng ta \u0111\xE3 th\xEAm "),G=c(cn,"CODE",{});var qn=r(G);jn=a(qn,'hub_model_id="huggingface-course/marian-finetuned-kde4-en-to-fr"'),qn.forEach(t),xn=a(cn," th\xE0nh "),pn=c(cn,"CODE",{});var ct=r(pn);W=a(ct,"Seq2SeqTrainingArguments"),ct.forEach(t),an=a(cn,". Theo m\u1EB7c \u0111\u1ECBnh, kho l\u01B0u tr\u1EEF \u0111\u01B0\u1EE3c s\u1EED d\u1EE5ng s\u1EBD n\u1EB1m trong kh\xF4ng gian t\xEAn c\u1EE7a b\u1EA1n v\xE0 \u0111\u01B0\u1EE3c \u0111\u1EB7t t\xEAn theo th\u01B0 m\u1EE5c \u0111\u1EA7u ra m\xE0 b\u1EA1n \u0111\xE3 \u0111\u1EB7t, v\xEC v\u1EADy \u1EDF \u0111\xE2y n\xF3 s\u1EBD l\xE0 "),kn=c(cn,"CODE",{});var rt=r(kn);Tn=a(rt,'"sgugger/marian-finetuned-kde4-en-to-fr"'),rt.forEach(t),On=a(cn," (l\xE0 m\xF4 h\xECnh m\xE0 ch\xFAng t\xF4i \u0111\xE3 li\xEAn k\u1EBFt v\u1EDBi \u1EDF \u0111\u1EA7u ph\u1EA7n n\xE0y)."),cn.forEach(t),_n=u(k),j(bn.$$.fragment,k),J=u(k),Cn=c(k,"P",{});var hn=r(Cn);wn=a(hn,"Cu\u1ED1i c\xF9ng, h\xE3y xem c\xE1c ch\u1EC9 s\u1ED1 c\u1EE7a ch\xFAng ta tr\xF4ng nh\u01B0 th\u1EBF n\xE0o khi qu\xE1 tr\xECnh hu\u1EA5n luy\u1EC7n \u0111\xE3 k\u1EBFt th\xFAc:"),hn.forEach(t),mt=u(k),j(Nn.$$.fragment,k),En=u(k),j(Ln.$$.fragment,k),gt=u(k),$n=c(k,"P",{});var Pt=r($n);Hn=a(Pt,"\u1EDE giai \u0111o\u1EA1n n\xE0y, b\u1EA1n c\xF3 th\u1EC3 s\u1EED d\u1EE5ng ti\u1EC7n \xEDch lu\u1EADn suy tr\xEAn Model Hub \u0111\u1EC3 ki\u1EC3m tra m\xF4 h\xECnh c\u1EE7a m\xECnh v\xE0 chia s\u1EBB v\u1EDBi b\u1EA1n b\xE8. B\u1EA1n \u0111\xE3 tinh ch\u1EC9nh th\xE0nh c\xF4ng m\u1ED9t m\xF4 h\xECnh trong t\xE1c v\u1EE5 d\u1ECBch - xin ch\xFAc m\u1EEBng!"),Pt.forEach(t),this.h()},h(){f(Y,"href","(/course/chapter7/2)"),f(fn,"href","https://huggingface.co/huggingface-course"),f(fn,"rel","nofollow")},m(k,K){h(k,o,K),e(o,$),h(k,d,K),E(x,k,K),h(k,z,K),E(_,k,K),h(k,C,K),h(k,D,K),e(D,P),e(D,q),e(q,O),e(D,T),h(k,S,K),E(F,k,K),h(k,I,K),h(k,B,K),e(B,tn),e(B,U),e(U,H),e(B,X),e(B,Y),e(Y,rn),e(B,on),h(k,sn,K),E(Q,k,K),h(k,Z,K),h(k,R,K),e(R,un),e(R,dn),e(dn,en),e(R,nn),e(R,fn),e(fn,mn),e(mn,ln),e(R,M),e(R,G),e(G,jn),e(R,xn),e(R,pn),e(pn,W),e(R,an),e(R,kn),e(kn,Tn),e(R,On),h(k,_n,K),E(bn,k,K),h(k,J,K),h(k,Cn,K),e(Cn,wn),h(k,mt,K),E(Nn,k,K),h(k,En,K),E(Ln,k,K),h(k,gt,K),h(k,$n,K),e($n,Hn),at=!0},i(k){at||(b(x.$$.fragment,k),b(_.$$.fragment,k),b(F.$$.fragment,k),b(Q.$$.fragment,k),b(bn.$$.fragment,k),b(Nn.$$.fragment,k),b(Ln.$$.fragment,k),at=!0)},o(k){v(x.$$.fragment,k),v(_.$$.fragment,k),v(F.$$.fragment,k),v(Q.$$.fragment,k),v(bn.$$.fragment,k),v(Nn.$$.fragment,k),v(Ln.$$.fragment,k),at=!1},d(k){k&&t(o),k&&t(d),w(x,k),k&&t(z),w(_,k),k&&t(C),k&&t(D),k&&t(S),w(F,k),k&&t(I),k&&t(B),k&&t(sn),w(Q,k),k&&t(Z),k&&t(R),k&&t(_n),w(bn,k),k&&t(J),k&&t(Cn),k&&t(mt),w(Nn,k),k&&t(En),w(Ln,k),k&&t(gt),k&&t($n)}}}function Su(V){let o,$,d,x,z;return{c(){o=l("p"),$=s("\u{1F4A1} N\u1EBFu th\u01B0 m\u1EE5c \u0111\u1EA7u ra b\u1EA1n \u0111ang s\u1EED d\u1EE5ng \u0111\xE3 t\u1ED3n t\u1EA1i, n\xF3 c\u1EA7n ph\u1EA3i l\xE0 b\u1EA3n sao c\u1EE5c b\u1ED9 c\u1EE7a kho l\u01B0u tr\u1EEF m\xE0 b\u1EA1n mu\u1ED1n \u0111\u1EA9y \u0111\u1EBFn. N\u1EBFu kh\xF4ng, b\u1EA1n s\u1EBD g\u1EB7p l\u1ED7i khi x\xE1c \u0111\u1ECBnh "),d=l("code"),x=s("Seq2SeqTrainer"),z=s(" c\u1EE7a m\xECnh v\xE0 s\u1EBD c\u1EA7n \u0111\u1EB7t t\xEAn m\u1EDBi.")},l(_){o=c(_,"P",{});var C=r(o);$=a(C,"\u{1F4A1} N\u1EBFu th\u01B0 m\u1EE5c \u0111\u1EA7u ra b\u1EA1n \u0111ang s\u1EED d\u1EE5ng \u0111\xE3 t\u1ED3n t\u1EA1i, n\xF3 c\u1EA7n ph\u1EA3i l\xE0 b\u1EA3n sao c\u1EE5c b\u1ED9 c\u1EE7a kho l\u01B0u tr\u1EEF m\xE0 b\u1EA1n mu\u1ED1n \u0111\u1EA9y \u0111\u1EBFn. N\u1EBFu kh\xF4ng, b\u1EA1n s\u1EBD g\u1EB7p l\u1ED7i khi x\xE1c \u0111\u1ECBnh "),d=c(C,"CODE",{});var D=r(d);x=a(D,"Seq2SeqTrainer"),D.forEach(t),z=a(C," c\u1EE7a m\xECnh v\xE0 s\u1EBD c\u1EA7n \u0111\u1EB7t t\xEAn m\u1EDBi."),C.forEach(t)},m(_,C){h(_,o,C),e(o,$),e(o,d),e(d,x),e(o,z)},d(_){_&&t(o)}}}function Ou(V){let o,$,d,x,z;return{c(){o=l("p"),$=s("\u{1F4A1} N\u1EBFu th\u01B0 m\u1EE5c \u0111\u1EA7u ra b\u1EA1n \u0111ang s\u1EED d\u1EE5ng \u0111\xE3 t\u1ED3n t\u1EA1i, n\xF3 c\u1EA7n ph\u1EA3i l\xE0 b\u1EA3n sao c\u1EE5c b\u1ED9 c\u1EE7a kho l\u01B0u tr\u1EEF m\xE0 b\u1EA1n mu\u1ED1n \u0111\u1EA9y \u0111\u1EBFn. N\u1EBFu kh\xF4ng, b\u1EA1n s\u1EBD g\u1EB7p l\u1ED7i khi g\u1ECDi "),d=l("code"),x=s("model.fit()"),z=s(" v\xE0 s\u1EBD c\u1EA7n \u0111\u1EB7t t\xEAn m\u1EDBi.")},l(_){o=c(_,"P",{});var C=r(o);$=a(C,"\u{1F4A1} N\u1EBFu th\u01B0 m\u1EE5c \u0111\u1EA7u ra b\u1EA1n \u0111ang s\u1EED d\u1EE5ng \u0111\xE3 t\u1ED3n t\u1EA1i, n\xF3 c\u1EA7n ph\u1EA3i l\xE0 b\u1EA3n sao c\u1EE5c b\u1ED9 c\u1EE7a kho l\u01B0u tr\u1EEF m\xE0 b\u1EA1n mu\u1ED1n \u0111\u1EA9y \u0111\u1EBFn. N\u1EBFu kh\xF4ng, b\u1EA1n s\u1EBD g\u1EB7p l\u1ED7i khi g\u1ECDi "),d=c(C,"CODE",{});var D=r(d);x=a(D,"model.fit()"),D.forEach(t),z=a(C," v\xE0 s\u1EBD c\u1EA7n \u0111\u1EB7t t\xEAn m\u1EDBi."),C.forEach(t)},m(_,C){h(_,o,C),e(o,$),e(o,d),e(d,x),e(o,z)},d(_){_&&t(o)}}}function iu(V){let o,$,d,x,z,_,C,D,P,q,O,T,S,F,I,B,tn,U,H,X,Y,rn,on,sn,Q,Z,R,un,dn,en,nn,fn,mn,ln,M,G,jn,xn,pn,W,an,kn,Tn,On,_n,bn,J,Cn,wn,mt,Nn,En,Ln,gt,$n,Hn,at,k,K,Bn,zn,gn,ht,Tt,cn,Pn,lt,Ct,qn,ct,rt,hn,Pt,Dn,ue,Mt,Ft,Wn,Mn,Dt,dt,zt,At,Yn,ne,yn,St,Zn,me,ft,Fn,_t,Un,bt,te,ge,In,Vn,Jn,ee,vt,Kn,Qn,se,it,An,Ut,kt,de,Rn,$t,nt,Ot,yt,It,tt,Ee,ae,g,N,jt,we,Et,Xe,ot,pt,he,Vt,Kt,vn,fe,Nt,Sn,We,Rt,Ye,Ze,le,Gn,_e,Gt,Xt,xe,wt,qe,ut,be,xt,Je,Te,qt,Ce,Wt,_s,et,qs,ve,Zs,Ts,Lt,Qe,Pe,Cs,De;return x=new pe({}),Y=new pe({}),M=new A({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>
)`}}),W=new A({props:{code:"model = AutoModelForSeq2SeqLM.from_pretrained(model_checkpoint)",highlighted:"model = AutoModelForSeq2SeqLM.from_pretrained(model_checkpoint)"}}),_n=new A({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>)`}}),Hn=new A({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
)`}}),ct=new A({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,
)`}}),Yn=new A({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`}}),yn=new A({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>'}}),Fn=new A({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)`}}),it=new pe({}),g=new A({props:{code:`def postprocess(predictions, labels):
    predictions = predictions.cpu().numpy()
    labels = labels.cpu().numpy()

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

    # Thay -100 trong nh\xE3n v\xEC ta kh\xF4ng th\u1EBF gi\u1EA3i m\xE3 ch\xFAng.
    labels = np.where(labels != -100, labels, tokenizer.pad_token_id)
    decoded_labels = tokenizer.batch_decode(labels, skip_special_tokens=True)

    # Th\u1EF1c hi\u1EC7n m\u1ED9t s\u1ED1 h\u1EADu x\u1EED l\xFD \u0111\u01A1n gi\u1EA3n
    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"># Thay -100 trong nh\xE3n v\xEC ta kh\xF4ng th\u1EBF gi\u1EA3i m\xE3 ch\xFAng.</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"># Th\u1EF1c hi\u1EC7n m\u1ED9t s\u1ED1 h\u1EADu x\u1EED l\xFD \u0111\u01A1n gi\u1EA3n</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`}}),qt=new A({props:{code:`from tqdm.auto import tqdm
import torch

progress_bar = tqdm(range(num_training_steps))

for epoch in range(num_train_epochs):
    # Hu\u1EA5n luy\u1EC7n
    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)

    # \u0110\xE1nh gi\xE1
    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"]

        # C\u1EA7n \u0111\u1EC7m d\u1EF1 \u0111o\xE1n v\xE0 nh\xE3n \u0111\u1EC3 d\u1EC5 gom l\u1EA1i
        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}")

    # L\u01B0u v\xE0 t\u1EA3i
    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"># Hu\u1EA5n luy\u1EC7n</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"># \u0110\xE1nh gi\xE1</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"># C\u1EA7n \u0111\u1EC7m d\u1EF1 \u0111o\xE1n v\xE0 nh\xE3n \u0111\u1EC3 d\u1EC5 gom l\u1EA1i</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"># L\u01B0u v\xE0 t\u1EA3i</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>
        )`}}),Wt=new A({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(){o=l("h2"),$=l("a"),d=l("span"),y(x.$$.fragment),z=p(),_=l("span"),C=s("M\u1ED9t v\xF2ng hu\u1EA5n luy\u1EC7n t\xF9y ch\u1EC9nh"),D=p(),P=l("p"),q=s("B\xE2y gi\u1EDD ch\xFAng ta h\xE3y xem to\xE0n b\u1ED9 v\xF2ng l\u1EB7p hu\u1EA5n luy\u1EC7n, v\xEC v\u1EADy b\u1EA1n c\xF3 th\u1EC3 d\u1EC5 d\xE0ng t\xF9y ch\u1EC9nh c\xE1c ph\u1EA7n b\u1EA1n c\u1EA7n. N\xF3 s\u1EBD tr\xF4ng r\u1EA5t gi\u1ED1ng nh\u1EEFng g\xEC ch\xFAng ta \u0111\xE3 l\xE0m trong "),O=l("a"),T=s("ph\u1EA7n 2"),S=s(" v\xE0 "),F=l("a"),I=s("Ch\u01B0\u01A1ng 3"),B=s("."),tn=p(),U=l("h3"),H=l("a"),X=l("span"),y(Y.$$.fragment),rn=p(),on=l("span"),sn=s("Chu\u1EA9n b\u1ECB m\u1ECDi th\u1EE9 cho qua tr\xECnh hu\u1EA5n luy\u1EC7n"),Q=p(),Z=l("p"),R=s("B\u1EA1n \u0111\xE3 th\u1EA5y t\u1EA5t c\u1EA3 \u0111i\u1EC1u n\xE0y m\u1ED9t v\xE0i l\u1EA7n r\u1ED3i, v\xEC v\u1EADy ch\xFAng ta s\u1EBD xem qua \u0111o\u1EA1n m\xE3 kh\xE1 nhanh. \u0110\u1EA7u ti\xEAn, ch\xFAng ta s\u1EBD x\xE2y d\u1EF1ng c\xE1c "),un=l("code"),dn=s("DataLoader"),en=s(" t\u1EEB c\xE1c t\u1EADp d\u1EEF li\u1EC7u c\u1EE7a m\xECnh, sau khi \u0111\u1EB7t c\xE1c t\u1EADp d\u1EEF li\u1EC7u th\xE0nh \u0111\u1ECBnh d\u1EA1ng"),nn=l("code"),fn=s('"torch"'),mn=s("\u0111\u1EC3 ch\xFAng ta nh\u1EADn \u0111\u01B0\u1EE3c c\xE1c tensor PyTorch:"),ln=p(),y(M.$$.fragment),G=p(),jn=l("p"),xn=s("Ti\u1EBFp theo, ch\xFAng ta kh\xF4i ph\u1EE5c m\xF4 h\xECnh c\u1EE7a m\xECnh, \u0111\u1EC3 \u0111\u1EA3m b\u1EA3o r\u1EB1ng ch\xFAng ta kh\xF4ng ti\u1EBFp t\u1EE5c tinh ch\u1EC9nh t\u1EEB tr\u01B0\u1EDBc m\xE0 b\u1EAFt \u0111\u1EA7u l\u1EA1i t\u1EEB m\xF4 h\xECnh \u0111\xE3 \u0111\u01B0\u1EE3c hu\u1EA5n luy\u1EC7n tr\u01B0\u1EDBc:"),pn=p(),y(W.$$.fragment),an=p(),kn=l("p"),Tn=s("Then we will need an optimizer:"),On=p(),y(_n.$$.fragment),bn=p(),J=l("p"),Cn=s("Khi ch\xFAng ta c\xF3 t\u1EA5t c\u1EA3 c\xE1c \u0111\u1ED1i t\u01B0\u1EE3ng \u0111\xF3, ch\xFAng ta c\xF3 th\u1EC3 g\u1EEDi ch\xFAng \u0111\u1EBFn ph\u01B0\u01A1ng th\u1EE9c "),wn=l("code"),mt=s("accelerator.prepare()"),Nn=s(". H\xE3y nh\u1EDB r\u1EB1ng n\u1EBFu b\u1EA1n mu\u1ED1n hu\u1EA5n luy\u1EC7n v\u1EC1 TPU trong notebook Colab, b\u1EA1n s\u1EBD c\u1EA7n chuy\u1EC3n t\u1EA5t c\u1EA3 m\xE3 n\xE0y v\xE0o m\u1ED9t h\xE0m hu\u1EA5n luy\u1EC7n v\xE0 \u0111i\u1EC1u \u0111\xF3 s\u1EBD kh\xF4ng th\u1EF1c thi b\u1EA5t k\u1EF3 \xF4 n\xE0o kh\u1EDFi t\u1EA1o m\u1ED9t "),En=l("code"),Ln=s("Accelerator"),gt=s("."),$n=p(),y(Hn.$$.fragment),at=p(),k=l("p"),K=s("B\xE2y gi\u1EDD, ch\xFAng ta \u0111\xE3 g\u1EEDi "),Bn=l("code"),zn=s("train_dataloader"),gn=s(" c\u1EE7a m\xECnh t\u1EDBi "),ht=l("code"),Tt=s("accelerator.prepare()"),cn=s(", ch\xFAng ta c\xF3 th\u1EC3 s\u1EED d\u1EE5ng \u0111\u1ED9 d\xE0i c\u1EE7a n\xF3 \u0111\u1EC3 t\xEDnh s\u1ED1 b\u01B0\u1EDBc hu\u1EA5n luy\u1EC7n. H\xE3y nh\u1EDB r\u1EB1ng ch\xFAng ta ph\u1EA3i lu\xF4n l\xE0m \u0111i\u1EC1u n\xE0y sau khi chu\u1EA9n b\u1ECB dataloader, v\xEC ph\u01B0\u01A1ng th\u1EE9c \u0111\xF3 s\u1EBD thay \u0111\u1ED5i \u0111\u1ED9 d\xE0i c\u1EE7a "),Pn=l("code"),lt=s("DataLoader"),Ct=s(". Ch\xFAng ta s\u1EED d\u1EE5ng m\u1ED9t l\u1ECBch tr\xECnh tuy\u1EBFn t\xEDnh c\u1ED5 \u0111i\u1EC3n t\u1EEB t\u1ED1c \u0111\u1ED9 h\u1ECDc \u0111\u1EBFn 0:"),qn=p(),y(ct.$$.fragment),rt=p(),hn=l("p"),Pt=s("Cu\u1ED1i c\xF9ng, \u0111\u1EC3 \u0111\u1EA9y m\xF4 h\xECnh c\u1EE7a m\xECnh l\xEAn Hub, ch\xFAng ta s\u1EBD c\u1EA7n t\u1EA1o m\u1ED9t \u0111\u1ED1i t\u01B0\u1EE3ng "),Dn=l("code"),ue=s("Repository"),Mt=s(" trong m\u1ED9t th\u01B0 m\u1EE5c \u0111ang l\xE0m vi\u1EC7c. \u0110\u1EA7u ti\xEAn h\xE3y \u0111\u0103ng nh\u1EADp v\xE0o Hugging Face Hub, n\u1EBFu b\u1EA1n ch\u01B0a \u0111\u0103ng nh\u1EADp. Ch\xFAng ta s\u1EBD x\xE1c \u0111\u1ECBnh t\xEAn kho l\u01B0u tr\u1EEF t\u1EEB ID m\xF4 h\xECnh m\xE0 ch\xFAng ta mu\u1ED1n cung c\u1EA5p cho m\xF4 h\xECnh c\u1EE7a m\xECnh (vui l\xF2ng thay th\u1EBF "),Ft=l("code"),Wn=s("repo_name"),Mn=s(" b\u1EB1ng s\u1EF1 l\u1EF1a ch\u1ECDn c\u1EE7a ri\xEAng b\u1EA1n; n\xF3 ch\u1EC9 c\u1EA7n ch\u1EE9a t\xEAn ng\u01B0\u1EDDi d\xF9ng c\u1EE7a b\u1EA1n, \u0111\xF3 l\xE0 nh\u1EEFng g\xEC h\xE0m "),Dt=l("code"),dt=s("get_full_repo_name()"),zt=s(" th\u1EF1c hi\u1EC7n):"),At=p(),y(Yn.$$.fragment),ne=p(),y(yn.$$.fragment),St=p(),Zn=l("p"),me=s("Sau \u0111\xF3, ch\xFAng ta c\xF3 th\u1EC3 sao ch\xE9p kho l\u01B0u tr\u1EEF \u0111\xF3 trong m\u1ED9t th\u01B0 m\u1EE5c c\u1EE5c b\u1ED9. N\u1EBFu n\xF3 \u0111\xE3 t\u1ED3n t\u1EA1i, th\u01B0 m\u1EE5c c\u1EE5c b\u1ED9 n\xE0y ph\u1EA3i l\xE0 b\u1EA3n sao c\u1EE7a kho l\u01B0u tr\u1EEF m\xE0 ch\xFAng ta \u0111ang l\xE0m vi\u1EC7c:"),ft=p(),y(Fn.$$.fragment),_t=p(),Un=l("p"),bt=s("B\xE2y gi\u1EDD ch\xFAng ta c\xF3 th\u1EC3 t\u1EA3i l\xEAn b\u1EA5t c\u1EE9 th\u1EE9 g\xEC ch\xFAng ta l\u01B0u trong "),te=l("code"),ge=s("output_dir"),In=s(" b\u1EB1ng c\xE1ch g\u1ECDi ph\u01B0\u01A1ng th\u1EE9c "),Vn=l("code"),Jn=s("repo.push_to_hub()"),ee=s(". \u0110i\u1EC1u n\xE0y s\u1EBD gi\xFAp ch\xFAng ta t\u1EA3i l\xEAn c\xE1c m\xF4 h\xECnh trung gian \u1EDF cu\u1ED1i m\u1ED7i epoch."),vt=p(),Kn=l("h3"),Qn=l("a"),se=l("span"),y(it.$$.fragment),An=p(),Ut=l("span"),kt=s("V\xF2ng l\u1EB7p hu\u1EA5n luy\u1EC7n"),de=p(),Rn=l("p"),$t=s("B\xE2y gi\u1EDD ch\xFAng ta \u0111\xE3 s\u1EB5n s\xE0ng \u0111\u1EC3 vi\u1EBFt v\xF2ng l\u1EB7p hu\u1EA5n luy\u1EC7n \u0111\u1EA7y \u0111\u1EE7. \u0110\u1EC3 \u0111\u01A1n gi\u1EA3n h\xF3a ph\u1EA7n \u0111\xE1nh gi\xE1 c\u1EE7a n\xF3, ch\xFAng ta \u0111\u1ECBnh ngh\u0129a h\xE0m "),nt=l("code"),Ot=s("postprocess()"),yt=s(" n\xE0y l\u1EA5y c\xE1c d\u1EF1 \u0111o\xE1n v\xE0 nh\xE3n v\xE0 chuy\u1EC3n \u0111\u1ED5i ch\xFAng th\xE0nh danh s\xE1ch c\xE1c chu\u1ED7i m\xE0 \u0111\u1ED1i t\u01B0\u1EE3ng "),It=l("code"),tt=s("metric"),Ee=s(" k\xEC v\u1ECDng:"),ae=p(),y(g.$$.fragment),N=p(),jt=l("p"),we=s("V\xF2ng l\u1EB7p hu\u1EA5n luy\u1EC7n tr\xF4ng r\u1EA5t gi\u1ED1ng v\u1EDBi c\xE1c v\xF2ng l\u1EB7p trong "),Et=l("a"),Xe=s("ph\u1EA7n 2"),ot=s(" v\xE0 "),pt=l("a"),he=s("Ch\u01B0\u01A1ng 3"),Vt=s(", v\u1EDBi m\u1ED9t v\xE0i \u0111i\u1EC3m kh\xE1c bi\u1EC7t trong ph\u1EA7n \u0111\xE1nh gi\xE1 - v\xEC v\u1EADy h\xE3y t\u1EADp trung v\xE0o \u0111i\u1EC1u \u0111\xF3!"),Kt=p(),vn=l("p"),fe=s("\u0110i\u1EC1u \u0111\u1EA7u ti\xEAn c\u1EA7n l\u01B0u \xFD l\xE0 ch\xFAng ta s\u1EED d\u1EE5ng ph\u01B0\u01A1ng th\u1EE9c "),Nt=l("code"),Sn=s("generate()"),We=s(" \u0111\u1EC3 t\xEDnh to\xE1n c\xE1c d\u1EF1 \u0111o\xE1n, nh\u01B0ng \u0111\xE2y l\xE0 m\u1ED9t ph\u01B0\u01A1ng th\u1EE9c tr\xEAn m\xF4 h\xECnh c\u01A1 s\u1EDF, kh\xF4ng ph\u1EA3i m\xF4 h\xECnh \u0111\u01B0\u1EE3c bao b\u1ECDc \u{1F917} Accelerate \u0111\u01B0\u1EE3c t\u1EA1o trong ph\u01B0\u01A1ng th\u1EE9c "),Rt=l("code"),Ye=s("prepare()"),Ze=s(" . \u0110\xF3 l\xE0 l\xFD do t\u1EA1i sao ch\xFAng ta m\u1EDF m\xF4 h\xECnh tr\u01B0\u1EDBc, sau \u0111\xF3 g\u1ECDi ph\u01B0\u01A1ng th\u1EE9c n\xE0y."),le=p(),Gn=l("p"),_e=s("\u0110i\u1EC1u th\u1EE9 hai l\xE0, gi\u1ED1ng nh\u01B0 v\u1EDBi "),Gt=l("a"),Xt=s("ph\xE2n lo\u1EA1i token"),xe=s(", hai quy tr\xECnh c\xF3 th\u1EC3 \u0111\xE3 \u0111\xEAm c\xE1c \u0111\u1EA7u v\xE0o v\xE0 nh\xE3n th\xE0nh c\xE1c h\xECnh d\u1EA1ng kh\xE1c nhau, v\xEC v\u1EADy ch\xFAng t\xF4i s\u1EED d\u1EE5ng "),wt=l("code"),qe=s("accelerator.pad_across_processes()"),ut=s(" \u0111\u1EC3 \u0111\u01B0a ra c\xE1c d\u1EF1 \u0111o\xE1n v\xE0 nh\xE3n c\xF9ng m\u1ED9t h\xECnh d\u1EA1ng tr\u01B0\u1EDBc khi g\u1ECDi ph\u01B0\u01A1ng th\u1EE9c "),be=l("code"),xt=s("gather()"),Je=s(" . N\u1EBFu ch\xFAng ta kh\xF4ng l\xE0m \u0111i\u1EC1u n\xE0y, \u0111\xE1nh gi\xE1 s\u1EBD b\u1ECB l\u1ED7i ho\u1EB7c b\u1ECB treo v\u0129nh vi\u1EC5n."),Te=p(),y(qt.$$.fragment),Ce=p(),y(Wt.$$.fragment),_s=p(),et=l("p"),qs=s("Khi \u0111i\u1EC1u n\xE0y \u0111\u01B0\u1EE3c th\u1EF1c hi\u1EC7n, b\u1EA1n s\u1EBD c\xF3 m\u1ED9t m\xF4 h\xECnh c\xF3 k\u1EBFt qu\u1EA3 kh\xE1 gi\u1ED1ng v\u1EDBi m\xF4 h\xECnh \u0111\u01B0\u1EE3c hu\u1EA5n luy\u1EC7n v\u1EDBi "),ve=l("code"),Zs=s("Seq2SeqTrainer"),Ts=s(". B\u1EA1n c\xF3 th\u1EC3 ki\u1EC3m tra \u0111o\u1EA1n m\xE3 m\xE0 ch\xFAng ta \u0111\xE3 hu\u1EA5n luy\u1EC7n b\u1EB1ng c\xE1ch s\u1EED d\u1EE5ng m\xE3 n\xE0y t\u1EA1i "),Lt=l("a"),Qe=l("em"),Pe=s("huggingface-course/marian-finetuned-kde4-en-to-fr-accelerate"),Cs=s(". V\xE0 n\u1EBFu b\u1EA1n mu\u1ED1n ki\u1EC3m tra b\u1EA5t k\u1EF3 tinh ch\u1EC9nh n\xE0o \u0111\u1ED1i v\u1EDBi v\xF2ng l\u1EB7p hu\u1EA5n luy\u1EC7n, b\u1EA1n c\xF3 th\u1EC3 tr\u1EF1c ti\u1EBFp th\u1EF1c hi\u1EC7n ch\xFAng b\u1EB1ng c\xE1ch ch\u1EC9nh s\u1EEDa \u0111o\u1EA1n m\xE3 \u0111\u01B0\u1EE3c hi\u1EC3n th\u1ECB \u1EDF tr\xEAn!"),this.h()},l(m){o=c(m,"H2",{class:!0});var L=r(o);$=c(L,"A",{id:!0,class:!0,href:!0});var ns=r($);d=c(ns,"SPAN",{});var Js=r(d);j(x.$$.fragment,Js),Js.forEach(t),ns.forEach(t),z=u(L),_=c(L,"SPAN",{});var ts=r(_);C=a(ts,"M\u1ED9t v\xF2ng hu\u1EA5n luy\u1EC7n t\xF9y ch\u1EC9nh"),ts.forEach(t),L.forEach(t),D=u(m),P=c(m,"P",{});var ze=r(P);q=a(ze,"B\xE2y gi\u1EDD ch\xFAng ta h\xE3y xem to\xE0n b\u1ED9 v\xF2ng l\u1EB7p hu\u1EA5n luy\u1EC7n, v\xEC v\u1EADy b\u1EA1n c\xF3 th\u1EC3 d\u1EC5 d\xE0ng t\xF9y ch\u1EC9nh c\xE1c ph\u1EA7n b\u1EA1n c\u1EA7n. N\xF3 s\u1EBD tr\xF4ng r\u1EA5t gi\u1ED1ng nh\u1EEFng g\xEC ch\xFAng ta \u0111\xE3 l\xE0m trong "),O=c(ze,"A",{href:!0});var bs=r(O);T=a(bs,"ph\u1EA7n 2"),bs.forEach(t),S=a(ze," v\xE0 "),F=c(ze,"A",{href:!0});var th=r(F);I=a(th,"Ch\u01B0\u01A1ng 3"),th.forEach(t),B=a(ze,"."),ze.forEach(t),tn=u(m),U=c(m,"H3",{class:!0});var vs=r(U);H=c(vs,"A",{id:!0,class:!0,href:!0});var es=r(H);X=c(es,"SPAN",{});var Qs=r(X);j(Y.$$.fragment,Qs),Qs.forEach(t),es.forEach(t),rn=u(vs),on=c(vs,"SPAN",{});var ss=r(on);sn=a(ss,"Chu\u1EA9n b\u1ECB m\u1ECDi th\u1EE9 cho qua tr\xECnh hu\u1EA5n luy\u1EC7n"),ss.forEach(t),vs.forEach(t),Q=u(m),Z=c(m,"P",{});var Ae=r(Z);R=a(Ae,"B\u1EA1n \u0111\xE3 th\u1EA5y t\u1EA5t c\u1EA3 \u0111i\u1EC1u n\xE0y m\u1ED9t v\xE0i l\u1EA7n r\u1ED3i, v\xEC v\u1EADy ch\xFAng ta s\u1EBD xem qua \u0111o\u1EA1n m\xE3 kh\xE1 nhanh. \u0110\u1EA7u ti\xEAn, ch\xFAng ta s\u1EBD x\xE2y d\u1EF1ng c\xE1c "),un=c(Ae,"CODE",{});var ks=r(un);dn=a(ks,"DataLoader"),ks.forEach(t),en=a(Ae," t\u1EEB c\xE1c t\u1EADp d\u1EEF li\u1EC7u c\u1EE7a m\xECnh, sau khi \u0111\u1EB7t c\xE1c t\u1EADp d\u1EEF li\u1EC7u th\xE0nh \u0111\u1ECBnh d\u1EA1ng"),nn=c(Ae,"CODE",{});var eh=r(nn);fn=a(eh,'"torch"'),eh.forEach(t),mn=a(Ae,"\u0111\u1EC3 ch\xFAng ta nh\u1EADn \u0111\u01B0\u1EE3c c\xE1c tensor PyTorch:"),Ae.forEach(t),ln=u(m),j(M.$$.fragment,m),G=u(m),jn=c(m,"P",{});var na=r(jn);xn=a(na,"Ti\u1EBFp theo, ch\xFAng ta kh\xF4i ph\u1EE5c m\xF4 h\xECnh c\u1EE7a m\xECnh, \u0111\u1EC3 \u0111\u1EA3m b\u1EA3o r\u1EB1ng ch\xFAng ta kh\xF4ng ti\u1EBFp t\u1EE5c tinh ch\u1EC9nh t\u1EEB tr\u01B0\u1EDBc m\xE0 b\u1EAFt \u0111\u1EA7u l\u1EA1i t\u1EEB m\xF4 h\xECnh \u0111\xE3 \u0111\u01B0\u1EE3c hu\u1EA5n luy\u1EC7n tr\u01B0\u1EDBc:"),na.forEach(t),pn=u(m),j(W.$$.fragment,m),an=u(m),kn=c(m,"P",{});var as=r(kn);Tn=a(as,"Then we will need an optimizer:"),as.forEach(t),On=u(m),j(_n.$$.fragment,m),bn=u(m),J=c(m,"P",{});var Se=r(J);Cn=a(Se,"Khi ch\xFAng ta c\xF3 t\u1EA5t c\u1EA3 c\xE1c \u0111\u1ED1i t\u01B0\u1EE3ng \u0111\xF3, ch\xFAng ta c\xF3 th\u1EC3 g\u1EEDi ch\xFAng \u0111\u1EBFn ph\u01B0\u01A1ng th\u1EE9c "),wn=c(Se,"CODE",{});var hs=r(wn);mt=a(hs,"accelerator.prepare()"),hs.forEach(t),Nn=a(Se,". H\xE3y nh\u1EDB r\u1EB1ng n\u1EBFu b\u1EA1n mu\u1ED1n hu\u1EA5n luy\u1EC7n v\u1EC1 TPU trong notebook Colab, b\u1EA1n s\u1EBD c\u1EA7n chuy\u1EC3n t\u1EA5t c\u1EA3 m\xE3 n\xE0y v\xE0o m\u1ED9t h\xE0m hu\u1EA5n luy\u1EC7n v\xE0 \u0111i\u1EC1u \u0111\xF3 s\u1EBD kh\xF4ng th\u1EF1c thi b\u1EA5t k\u1EF3 \xF4 n\xE0o kh\u1EDFi t\u1EA1o m\u1ED9t "),En=c(Se,"CODE",{});var ta=r(En);Ln=a(ta,"Accelerator"),ta.forEach(t),gt=a(Se,"."),Se.forEach(t),$n=u(m),j(Hn.$$.fragment,m),at=u(m),k=c(m,"P",{});var Ht=r(k);K=a(Ht,"B\xE2y gi\u1EDD, ch\xFAng ta \u0111\xE3 g\u1EEDi "),Bn=c(Ht,"CODE",{});var sh=r(Bn);zn=a(sh,"train_dataloader"),sh.forEach(t),gn=a(Ht," c\u1EE7a m\xECnh t\u1EDBi "),ht=c(Ht,"CODE",{});var ea=r(ht);Tt=a(ea,"accelerator.prepare()"),ea.forEach(t),cn=a(Ht,", ch\xFAng ta c\xF3 th\u1EC3 s\u1EED d\u1EE5ng \u0111\u1ED9 d\xE0i c\u1EE7a n\xF3 \u0111\u1EC3 t\xEDnh s\u1ED1 b\u01B0\u1EDBc hu\u1EA5n luy\u1EC7n. H\xE3y nh\u1EDB r\u1EB1ng ch\xFAng ta ph\u1EA3i lu\xF4n l\xE0m \u0111i\u1EC1u n\xE0y sau khi chu\u1EA9n b\u1ECB dataloader, v\xEC ph\u01B0\u01A1ng th\u1EE9c \u0111\xF3 s\u1EBD thay \u0111\u1ED5i \u0111\u1ED9 d\xE0i c\u1EE7a "),Pn=c(Ht,"CODE",{});var ls=r(Pn);lt=a(ls,"DataLoader"),ls.forEach(t),Ct=a(Ht,". Ch\xFAng ta s\u1EED d\u1EE5ng m\u1ED9t l\u1ECBch tr\xECnh tuy\u1EBFn t\xEDnh c\u1ED5 \u0111i\u1EC3n t\u1EEB t\u1ED1c \u0111\u1ED9 h\u1ECDc \u0111\u1EBFn 0:"),Ht.forEach(t),qn=u(m),j(ct.$$.fragment,m),rt=u(m),hn=c(m,"P",{});var ce=r(hn);Pt=a(ce,"Cu\u1ED1i c\xF9ng, \u0111\u1EC3 \u0111\u1EA9y m\xF4 h\xECnh c\u1EE7a m\xECnh l\xEAn Hub, ch\xFAng ta s\u1EBD c\u1EA7n t\u1EA1o m\u1ED9t \u0111\u1ED1i t\u01B0\u1EE3ng "),Dn=c(ce,"CODE",{});var Oe=r(Dn);ue=a(Oe,"Repository"),Oe.forEach(t),Mt=a(ce," trong m\u1ED9t th\u01B0 m\u1EE5c \u0111ang l\xE0m vi\u1EC7c. \u0110\u1EA7u ti\xEAn h\xE3y \u0111\u0103ng nh\u1EADp v\xE0o Hugging Face Hub, n\u1EBFu b\u1EA1n ch\u01B0a \u0111\u0103ng nh\u1EADp. Ch\xFAng ta s\u1EBD x\xE1c \u0111\u1ECBnh t\xEAn kho l\u01B0u tr\u1EEF t\u1EEB ID m\xF4 h\xECnh m\xE0 ch\xFAng ta mu\u1ED1n cung c\u1EA5p cho m\xF4 h\xECnh c\u1EE7a m\xECnh (vui l\xF2ng thay th\u1EBF "),Ft=c(ce,"CODE",{});var sa=r(Ft);Wn=a(sa,"repo_name"),sa.forEach(t),Mn=a(ce," b\u1EB1ng s\u1EF1 l\u1EF1a ch\u1ECDn c\u1EE7a ri\xEAng b\u1EA1n; n\xF3 ch\u1EC9 c\u1EA7n ch\u1EE9a t\xEAn ng\u01B0\u1EDDi d\xF9ng c\u1EE7a b\u1EA1n, \u0111\xF3 l\xE0 nh\u1EEFng g\xEC h\xE0m "),Dt=c(ce,"CODE",{});var ke=r(Dt);dt=a(ke,"get_full_repo_name()"),ke.forEach(t),zt=a(ce," th\u1EF1c hi\u1EC7n):"),ce.forEach(t),At=u(m),j(Yn.$$.fragment,m),ne=u(m),j(yn.$$.fragment,m),St=u(m),Zn=c(m,"P",{});var Ne=r(Zn);me=a(Ne,"Sau \u0111\xF3, ch\xFAng ta c\xF3 th\u1EC3 sao ch\xE9p kho l\u01B0u tr\u1EEF \u0111\xF3 trong m\u1ED9t th\u01B0 m\u1EE5c c\u1EE5c b\u1ED9. N\u1EBFu n\xF3 \u0111\xE3 t\u1ED3n t\u1EA1i, th\u01B0 m\u1EE5c c\u1EE5c b\u1ED9 n\xE0y ph\u1EA3i l\xE0 b\u1EA3n sao c\u1EE7a kho l\u01B0u tr\u1EEF m\xE0 ch\xFAng ta \u0111ang l\xE0m vi\u1EC7c:"),Ne.forEach(t),ft=u(m),j(Fn.$$.fragment,m),_t=u(m),Un=c(m,"P",{});var $e=r(Un);bt=a($e,"B\xE2y gi\u1EDD ch\xFAng ta c\xF3 th\u1EC3 t\u1EA3i l\xEAn b\u1EA5t c\u1EE9 th\u1EE9 g\xEC ch\xFAng ta l\u01B0u trong "),te=c($e,"CODE",{});var cs=r(te);ge=a(cs,"output_dir"),cs.forEach(t),In=a($e," b\u1EB1ng c\xE1ch g\u1ECDi ph\u01B0\u01A1ng th\u1EE9c "),Vn=c($e,"CODE",{});var ah=r(Vn);Jn=a(ah,"repo.push_to_hub()"),ah.forEach(t),ee=a($e,". \u0110i\u1EC1u n\xE0y s\u1EBD gi\xFAp ch\xFAng ta t\u1EA3i l\xEAn c\xE1c m\xF4 h\xECnh trung gian \u1EDF cu\u1ED1i m\u1ED7i epoch."),$e.forEach(t),vt=u(m),Kn=c(m,"H3",{class:!0});var rs=r(Kn);Qn=c(rs,"A",{id:!0,class:!0,href:!0});var hh=r(Qn);se=c(hh,"SPAN",{});var aa=r(se);j(it.$$.fragment,aa),aa.forEach(t),hh.forEach(t),An=u(rs),Ut=c(rs,"SPAN",{});var is=r(Ut);kt=a(is,"V\xF2ng l\u1EB7p hu\u1EA5n luy\u1EC7n"),is.forEach(t),rs.forEach(t),de=u(m),Rn=c(m,"P",{});var Le=r(Rn);$t=a(Le,"B\xE2y gi\u1EDD ch\xFAng ta \u0111\xE3 s\u1EB5n s\xE0ng \u0111\u1EC3 vi\u1EBFt v\xF2ng l\u1EB7p hu\u1EA5n luy\u1EC7n \u0111\u1EA7y \u0111\u1EE7. \u0110\u1EC3 \u0111\u01A1n gi\u1EA3n h\xF3a ph\u1EA7n \u0111\xE1nh gi\xE1 c\u1EE7a n\xF3, ch\xFAng ta \u0111\u1ECBnh ngh\u0129a h\xE0m "),nt=c(Le,"CODE",{});var re=r(nt);Ot=a(re,"postprocess()"),re.forEach(t),yt=a(Le," n\xE0y l\u1EA5y c\xE1c d\u1EF1 \u0111o\xE1n v\xE0 nh\xE3n v\xE0 chuy\u1EC3n \u0111\u1ED5i ch\xFAng th\xE0nh danh s\xE1ch c\xE1c chu\u1ED7i m\xE0 \u0111\u1ED1i t\u01B0\u1EE3ng "),It=c(Le,"CODE",{});var lh=r(It);tt=a(lh,"metric"),lh.forEach(t),Ee=a(Le," k\xEC v\u1ECDng:"),Le.forEach(t),ae=u(m),j(g.$$.fragment,m),N=u(m),jt=c(m,"P",{});var ye=r(jt);we=a(ye,"V\xF2ng l\u1EB7p hu\u1EA5n luy\u1EC7n tr\xF4ng r\u1EA5t gi\u1ED1ng v\u1EDBi c\xE1c v\xF2ng l\u1EB7p trong "),Et=c(ye,"A",{href:!0});var ch=r(Et);Xe=a(ch,"ph\u1EA7n 2"),ch.forEach(t),ot=a(ye," v\xE0 "),pt=c(ye,"A",{href:!0});var rh=r(pt);he=a(rh,"Ch\u01B0\u01A1ng 3"),rh.forEach(t),Vt=a(ye,", v\u1EDBi m\u1ED9t v\xE0i \u0111i\u1EC3m kh\xE1c bi\u1EC7t trong ph\u1EA7n \u0111\xE1nh gi\xE1 - v\xEC v\u1EADy h\xE3y t\u1EADp trung v\xE0o \u0111i\u1EC1u \u0111\xF3!"),ye.forEach(t),Kt=u(m),vn=c(m,"P",{});var Yt=r(vn);fe=a(Yt,"\u0110i\u1EC1u \u0111\u1EA7u ti\xEAn c\u1EA7n l\u01B0u \xFD l\xE0 ch\xFAng ta s\u1EED d\u1EE5ng ph\u01B0\u01A1ng th\u1EE9c "),Nt=c(Yt,"CODE",{});var ih=r(Nt);Sn=a(ih,"generate()"),ih.forEach(t),We=a(Yt," \u0111\u1EC3 t\xEDnh to\xE1n c\xE1c d\u1EF1 \u0111o\xE1n, nh\u01B0ng \u0111\xE2y l\xE0 m\u1ED9t ph\u01B0\u01A1ng th\u1EE9c tr\xEAn m\xF4 h\xECnh c\u01A1 s\u1EDF, kh\xF4ng ph\u1EA3i m\xF4 h\xECnh \u0111\u01B0\u1EE3c bao b\u1ECDc \u{1F917} Accelerate \u0111\u01B0\u1EE3c t\u1EA1o trong ph\u01B0\u01A1ng th\u1EE9c "),Rt=c(Yt,"CODE",{});var oh=r(Rt);Ye=a(oh,"prepare()"),oh.forEach(t),Ze=a(Yt," . \u0110\xF3 l\xE0 l\xFD do t\u1EA1i sao ch\xFAng ta m\u1EDF m\xF4 h\xECnh tr\u01B0\u1EDBc, sau \u0111\xF3 g\u1ECDi ph\u01B0\u01A1ng th\u1EE9c n\xE0y."),Yt.forEach(t),le=u(m),Gn=c(m,"P",{});var ie=r(Gn);_e=a(ie,"\u0110i\u1EC1u th\u1EE9 hai l\xE0, gi\u1ED1ng nh\u01B0 v\u1EDBi "),Gt=c(ie,"A",{href:!0});var os=r(Gt);Xt=a(os,"ph\xE2n lo\u1EA1i token"),os.forEach(t),xe=a(ie,", hai quy tr\xECnh c\xF3 th\u1EC3 \u0111\xE3 \u0111\xEAm c\xE1c \u0111\u1EA7u v\xE0o v\xE0 nh\xE3n th\xE0nh c\xE1c h\xECnh d\u1EA1ng kh\xE1c nhau, v\xEC v\u1EADy ch\xFAng t\xF4i s\u1EED d\u1EE5ng "),wt=c(ie,"CODE",{});var ha=r(wt);qe=a(ha,"accelerator.pad_across_processes()"),ha.forEach(t),ut=a(ie," \u0111\u1EC3 \u0111\u01B0a ra c\xE1c d\u1EF1 \u0111o\xE1n v\xE0 nh\xE3n c\xF9ng m\u1ED9t h\xECnh d\u1EA1ng tr\u01B0\u1EDBc khi g\u1ECDi ph\u01B0\u01A1ng th\u1EE9c "),be=c(ie,"CODE",{});var oe=r(be);xt=a(oe,"gather()"),oe.forEach(t),Je=a(ie," . N\u1EBFu ch\xFAng ta kh\xF4ng l\xE0m \u0111i\u1EC1u n\xE0y, \u0111\xE1nh gi\xE1 s\u1EBD b\u1ECB l\u1ED7i ho\u1EB7c b\u1ECB treo v\u0129nh vi\u1EC5n."),ie.forEach(t),Te=u(m),j(qt.$$.fragment,m),Ce=u(m),j(Wt.$$.fragment,m),_s=u(m),et=c(m,"P",{});var ps=r(et);qs=a(ps,"Khi \u0111i\u1EC1u n\xE0y \u0111\u01B0\u1EE3c th\u1EF1c hi\u1EC7n, b\u1EA1n s\u1EBD c\xF3 m\u1ED9t m\xF4 h\xECnh c\xF3 k\u1EBFt qu\u1EA3 kh\xE1 gi\u1ED1ng v\u1EDBi m\xF4 h\xECnh \u0111\u01B0\u1EE3c hu\u1EA5n luy\u1EC7n v\u1EDBi "),ve=c(ps,"CODE",{});var Ps=r(ve);Zs=a(Ps,"Seq2SeqTrainer"),Ps.forEach(t),Ts=a(ps,". B\u1EA1n c\xF3 th\u1EC3 ki\u1EC3m tra \u0111o\u1EA1n m\xE3 m\xE0 ch\xFAng ta \u0111\xE3 hu\u1EA5n luy\u1EC7n b\u1EB1ng c\xE1ch s\u1EED d\u1EE5ng m\xE3 n\xE0y t\u1EA1i "),Lt=c(ps,"A",{href:!0,rel:!0});var ph=r(Lt);Qe=c(ph,"EM",{});var uh=r(Qe);Pe=a(uh,"huggingface-course/marian-finetuned-kde4-en-to-fr-accelerate"),uh.forEach(t),ph.forEach(t),Cs=a(ps,". V\xE0 n\u1EBFu b\u1EA1n mu\u1ED1n ki\u1EC3m tra b\u1EA5t k\u1EF3 tinh ch\u1EC9nh n\xE0o \u0111\u1ED1i v\u1EDBi v\xF2ng l\u1EB7p hu\u1EA5n luy\u1EC7n, b\u1EA1n c\xF3 th\u1EC3 tr\u1EF1c ti\u1EBFp th\u1EF1c hi\u1EC7n ch\xFAng b\u1EB1ng c\xE1ch ch\u1EC9nh s\u1EEDa \u0111o\u1EA1n m\xE3 \u0111\u01B0\u1EE3c hi\u1EC3n th\u1ECB \u1EDF tr\xEAn!"),ps.forEach(t),this.h()},h(){f($,"id","mt-vng-hun-luyn-ty-chnh"),f($,"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"),f($,"href","#mt-vng-hun-luyn-ty-chnh"),f(o,"class","relative group"),f(O,"href","/course/chapter7/2"),f(F,"href","/course/chapter3/4"),f(H,"id","chun-b-mi-th-cho-qua-trnh-hun-luyn"),f(H,"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"),f(H,"href","#chun-b-mi-th-cho-qua-trnh-hun-luyn"),f(U,"class","relative group"),f(Qn,"id","vng-lp-hun-luyn"),f(Qn,"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"),f(Qn,"href","#vng-lp-hun-luyn"),f(Kn,"class","relative group"),f(Et,"href","/course/chapter7/2"),f(pt,"href","/course/chapter3"),f(Gt,"href","/course/chapter7/2"),f(Lt,"href","https://huggingface.co/huggingface-course/marian-finetuned-kde4-en-to-fr-accelerate"),f(Lt,"rel","nofollow")},m(m,L){h(m,o,L),e(o,$),e($,d),E(x,d,null),e(o,z),e(o,_),e(_,C),h(m,D,L),h(m,P,L),e(P,q),e(P,O),e(O,T),e(P,S),e(P,F),e(F,I),e(P,B),h(m,tn,L),h(m,U,L),e(U,H),e(H,X),E(Y,X,null),e(U,rn),e(U,on),e(on,sn),h(m,Q,L),h(m,Z,L),e(Z,R),e(Z,un),e(un,dn),e(Z,en),e(Z,nn),e(nn,fn),e(Z,mn),h(m,ln,L),E(M,m,L),h(m,G,L),h(m,jn,L),e(jn,xn),h(m,pn,L),E(W,m,L),h(m,an,L),h(m,kn,L),e(kn,Tn),h(m,On,L),E(_n,m,L),h(m,bn,L),h(m,J,L),e(J,Cn),e(J,wn),e(wn,mt),e(J,Nn),e(J,En),e(En,Ln),e(J,gt),h(m,$n,L),E(Hn,m,L),h(m,at,L),h(m,k,L),e(k,K),e(k,Bn),e(Bn,zn),e(k,gn),e(k,ht),e(ht,Tt),e(k,cn),e(k,Pn),e(Pn,lt),e(k,Ct),h(m,qn,L),E(ct,m,L),h(m,rt,L),h(m,hn,L),e(hn,Pt),e(hn,Dn),e(Dn,ue),e(hn,Mt),e(hn,Ft),e(Ft,Wn),e(hn,Mn),e(hn,Dt),e(Dt,dt),e(hn,zt),h(m,At,L),E(Yn,m,L),h(m,ne,L),E(yn,m,L),h(m,St,L),h(m,Zn,L),e(Zn,me),h(m,ft,L),E(Fn,m,L),h(m,_t,L),h(m,Un,L),e(Un,bt),e(Un,te),e(te,ge),e(Un,In),e(Un,Vn),e(Vn,Jn),e(Un,ee),h(m,vt,L),h(m,Kn,L),e(Kn,Qn),e(Qn,se),E(it,se,null),e(Kn,An),e(Kn,Ut),e(Ut,kt),h(m,de,L),h(m,Rn,L),e(Rn,$t),e(Rn,nt),e(nt,Ot),e(Rn,yt),e(Rn,It),e(It,tt),e(Rn,Ee),h(m,ae,L),E(g,m,L),h(m,N,L),h(m,jt,L),e(jt,we),e(jt,Et),e(Et,Xe),e(jt,ot),e(jt,pt),e(pt,he),e(jt,Vt),h(m,Kt,L),h(m,vn,L),e(vn,fe),e(vn,Nt),e(Nt,Sn),e(vn,We),e(vn,Rt),e(Rt,Ye),e(vn,Ze),h(m,le,L),h(m,Gn,L),e(Gn,_e),e(Gn,Gt),e(Gt,Xt),e(Gn,xe),e(Gn,wt),e(wt,qe),e(Gn,ut),e(Gn,be),e(be,xt),e(Gn,Je),h(m,Te,L),E(qt,m,L),h(m,Ce,L),E(Wt,m,L),h(m,_s,L),h(m,et,L),e(et,qs),e(et,ve),e(ve,Zs),e(et,Ts),e(et,Lt),e(Lt,Qe),e(Qe,Pe),e(et,Cs),De=!0},i(m){De||(b(x.$$.fragment,m),b(Y.$$.fragment,m),b(M.$$.fragment,m),b(W.$$.fragment,m),b(_n.$$.fragment,m),b(Hn.$$.fragment,m),b(ct.$$.fragment,m),b(Yn.$$.fragment,m),b(yn.$$.fragment,m),b(Fn.$$.fragment,m),b(it.$$.fragment,m),b(g.$$.fragment,m),b(qt.$$.fragment,m),b(Wt.$$.fragment,m),De=!0)},o(m){v(x.$$.fragment,m),v(Y.$$.fragment,m),v(M.$$.fragment,m),v(W.$$.fragment,m),v(_n.$$.fragment,m),v(Hn.$$.fragment,m),v(ct.$$.fragment,m),v(Yn.$$.fragment,m),v(yn.$$.fragment,m),v(Fn.$$.fragment,m),v(it.$$.fragment,m),v(g.$$.fragment,m),v(qt.$$.fragment,m),v(Wt.$$.fragment,m),De=!1},d(m){m&&t(o),w(x),m&&t(D),m&&t(P),m&&t(tn),m&&t(U),w(Y),m&&t(Q),m&&t(Z),m&&t(ln),w(M,m),m&&t(G),m&&t(jn),m&&t(pn),w(W,m),m&&t(an),m&&t(kn),m&&t(On),w(_n,m),m&&t(bn),m&&t(J),m&&t($n),w(Hn,m),m&&t(at),m&&t(k),m&&t(qn),w(ct,m),m&&t(rt),m&&t(hn),m&&t(At),w(Yn,m),m&&t(ne),w(yn,m),m&&t(St),m&&t(Zn),m&&t(ft),w(Fn,m),m&&t(_t),m&&t(Un),m&&t(vt),m&&t(Kn),w(it),m&&t(de),m&&t(Rn),m&&t(ae),w(g,m),m&&t(N),m&&t(jt),m&&t(Kt),m&&t(vn),m&&t(le),m&&t(Gn),m&&t(Te),w(qt,m),m&&t(Ce),w(Wt,m),m&&t(_s),m&&t(et)}}}function Nu(V){let o,$,d,x,z;return{c(){o=l("p"),$=s("\u270F\uFE0F "),d=l("strong"),x=s("\u0110\u1EBFn l\u01B0\u1EE3t b\u1EA1n!"),z=s(" M\xF4 h\xECnh tr\u1EA3 v\u1EC1 c\xE1i g\xEC v\u1EDBi t\u1EEB \u201Cemail\u201D b\u1EA1n x\xE1c \u0111\u1ECBnh tr\u01B0\u1EDBc \u0111\xF3?")},l(_){o=c(_,"P",{});var C=r(o);$=a(C,"\u270F\uFE0F "),d=c(C,"STRONG",{});var D=r(d);x=a(D,"\u0110\u1EBFn l\u01B0\u1EE3t b\u1EA1n!"),D.forEach(t),z=a(C," M\xF4 h\xECnh tr\u1EA3 v\u1EC1 c\xE1i g\xEC v\u1EDBi t\u1EEB \u201Cemail\u201D b\u1EA1n x\xE1c \u0111\u1ECBnh tr\u01B0\u1EDBc \u0111\xF3?"),C.forEach(t)},m(_,C){h(_,o,C),e(o,$),e(o,d),e(d,x),e(o,z)},d(_){_&&t(o)}}}function Lu(V){let o,$,d,x,z,_,C,D,P,q,O,T,S,F,I,B,tn,U,H,X,Y,rn,on,sn,Q,Z,R,un,dn,en,nn,fn,mn,ln,M,G,jn,xn,pn,W,an,kn,Tn,On,_n,bn,J,Cn,wn,mt,Nn,En,Ln,gt,$n,Hn,at,k,K,Bn,zn,gn,ht,Tt,cn,Pn,lt,Ct,qn,ct,rt,hn,Pt,Dn,ue,Mt,Ft,Wn,Mn,Dt,dt,zt,At,Yn,ne,yn,St,Zn,me,ft,Fn,_t,Un,bt,te,ge,In,Vn,Jn,ee,vt,Kn,Qn,se,it,An,Ut,kt,de,Rn,$t,nt,Ot,yt,It,tt,Ee,ae,g,N,jt,we,Et,Xe,ot,pt,he,Vt,Kt,vn,fe,Nt,Sn,We,Rt,Ye,Ze,le,Gn,_e,Gt,Xt,xe,wt,qe,ut,be,xt,Je,Te,qt,Ce,Wt,_s,et,qs,ve,Zs,Ts,Lt,Qe,Pe,Cs,De,m,L,ns,Js,ts,ze,bs,th,vs,es,Qs,ss,Ae,ks,eh,na,as,Se,hs,ta,Ht,sh,ea,ls,ce,Oe,sa,ke,Ne,$e,cs,ah,rs,hh,aa,is,Le,re,lh,ye,ch,rh,Yt,ih,oh,ie,os,ha,oe,ps,Ps,ph,uh,la,mr,gr,Dl,Ds,zl,zs,dr,Zh,fr,_r,Al,As,br,Jh,vr,kr,Sl,ca,Ol,us,$r,Qh,yr,jr,nl,Er,wr,Nl,Ss,xr,tl,qr,Tr,Ll,mh,Cr,Hl,ra,Bl,gh,Pr,Ml,ia,Fl,oa,Ul,dh,Dr,Il,je,zr,el,Ar,Sr,sl,Or,Nr,al,Lr,Hr,Vl,pa,Kl,fh,Br,Rl,Os,Gl,Ns,Xl,_h,Mr,Wl,ua,Yl,bh,Fr,Zl,He,Be,vh,kh,Ur,Jl,$s,Ls,hl,ma,Ir,ll,Vr,Ql,ms,Kr,cl,Rr,Gr,rl,Xr,Wr,nc,st,Yr,ga,il,Zr,Jr,ol,Qr,ni,pl,ti,ei,ul,si,ai,ml,hi,li,gl,ci,ri,tc,Me,Fe,$h,yh,ii,ec,da,sc,fa,ac,Hs,oi,dl,pi,ui,hc,_a,lc,ba,cc,jh,mi,rc,va,ic,ka,oc,Eh,gi,pc,$a,uc,ya,mc,Ue,Ie,wh,ys,Bs,fl,ja,di,_l,fi,gc,Ea,dc,xh,Zt,_i,wa,bi,vi,xa,ki,$i,bl,yi,ji,vl,Ei,wi,fc,Ms,xi,qa,qi,Ti,_c,Ta,bc,gs,Ci,kl,Pi,Di,qh,zi,Ai,vc,Ca,kc,Th,Si,$c,Ch,Oi,yc,Pa,jc,Da,Ec,Jt,Ni,za,Li,Hi,$l,Bi,Mi,yl,Fi,Ui,Aa,Ii,Vi,wc,Sa,xc,Oa,qc,Na,Tc,La,Cc,Ph,Ki,Pc,Ve,Ke,Dh,zh,Ri,Dc,js,Fs,jl,Ha,Gi,El,Xi,zc,Ah,Wi,Ac,Ba,Sc,Sh,Yi,Oc,Oh,Zi,Nc,Ma,Lc,Re,Ge,Nh,Lh,Es,Us,wl,Fa,Ji,xl,Qi,Hc,Is,no,ql,to,eo,Bc,Ua,Mc,Ia,Fc,Hh,so,Uc,Va,Ic,Ka,Vc,Bh,ao,Kc,Vs,Rc;d=new fu({props:{fw:V[0]}}),D=new pe({});const ho=[bu,_u],Ra=[];function lo(n,i){return n[0]==="pt"?0:1}S=lo(V),F=Ra[S]=ho[S](V),pn=new ur({props:{id:"1JvfrvZgi6c"}}),dt=new pe({}),vt=new pe({}),nt=new A({props:{code:`from datasets import load_dataset

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

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>)`}}),pt=new A({props:{code:"raw_datasets",highlighted:"raw_datasets"}}),Vt=new A({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>
    })
})`}}),Xt=new A({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`}}),wt=new A({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>
    })
})`}}),et=new A({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>)'}}),Lt=new A({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>]'}}),Pe=new A({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>}`}}),ns=new A({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>)`}}),ts=new A({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>}]'}}),es=new A({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>]'}}),ss=new A({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>}`}}),as=new A({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>
)`}}),hs=new A({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>}]'}}),ls=new ur({props:{id:"0Oxphw4Q9fo"}}),Oe=new Ys({props:{$$slots:{default:[vu]},$$scope:{ctx:V}}}),cs=new pe({}),is=new ur({props:{id:"XAR8jnZZuUs"}}),os=new A({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>)`}}),Ds=new Ys({props:{$$slots:{default:[ku]},$$scope:{ctx:V}}}),ca=new A({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>()`}}),ra=new A({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)`}}),ia=new A({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>]))`}}),oa=new A({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>]`}}),pa=new A({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)

    # Thi\u1EBFt l\u1EADp tokenizer cho nh\xE3n
    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"># Thi\u1EBFt l\u1EADp tokenizer cho nh\xE3n</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`}}),Os=new Ys({props:{$$slots:{default:[$u]},$$scope:{ctx:V}}}),Ns=new Ys({props:{warning:!0,$$slots:{default:[yu]},$$scope:{ctx:V}}}),ua=new A({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 co=[Eu,ju],Ga=[];function ro(n,i){return n[0]==="pt"?0:1}He=ro(V),Be=Ga[He]=co[He](V),ma=new pe({});const io=[qu,xu],Xa=[];function oo(n,i){return n[0]==="pt"?0:1}Me=oo(V),Fe=Xa[Me]=io[Me](V),da=new A({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()`}}),fa=new A({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>])'}}),_a=new A({props:{code:'batch["labels"]',highlighted:'batch[<span class="hljs-string">&quot;labels&quot;</span>]'}}),ba=new A({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>]])`}}),va=new A({props:{code:'batch["decoder_input_ids"]',highlighted:'batch[<span class="hljs-string">&quot;decoder_input_ids&quot;</span>]'}}),ka=new A({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>]])`}}),$a=new A({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>])`}}),ya=new A({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 po=[Cu,Tu],Wa=[];function uo(n,i){return n[0]==="pt"?0:1}Ue=uo(V),Ie=Wa[Ue]=po[Ue](V),ja=new pe({}),Ea=new ur({props:{id:"M05L1DhFqcw"}});let Bt=V[0]==="pt"&&ru();Ta=new A({props:{code:"!pip install sacrebleu",highlighted:"!pip install sacrebleu"}}),Ca=new A({props:{code:`import evaluate

metric = evaluate.load("sacrebleu")`,highlighted:`<span class="hljs-keyword">import</span> evaluate

metric = evaluate.load(<span class="hljs-string">&quot;sacrebleu&quot;</span>)`}}),Pa=new A({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)`}}),Da=new A({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>}`}}),Sa=new A({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)`}}),Oa=new A({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>}`}}),Na=new A({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)`}}),La=new A({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 mo=[Du,Pu],Ya=[];function go(n,i){return n[0]==="tf"?0:1}Ve=go(V),Ke=Ya[Ve]=mo[Ve](V),Ha=new pe({}),Ba=new A({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()`}}),Ma=new A({props:{code:"huggingface-cli login",highlighted:"huggingface-cli login"}});const fo=[Au,zu],Za=[];function _o(n,i){return n[0]==="tf"?0:1}Re=_o(V),Ge=Za[Re]=fo[Re](V);let Xn=V[0]==="pt"&&iu();return Fa=new pe({}),Ua=new A({props:{code:`from transformers import pipeline

# Thay n\xF3 v\u1EDBi checkpoint c\u1EE7a b\u1EA1n
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"># Thay n\xF3 v\u1EDBi checkpoint c\u1EE7a b\u1EA1n</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>)`}}),Ia=new A({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>}]'}}),Va=new A({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>
)`}}),Ka=new A({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>}]'}}),Vs=new Ys({props:{$$slots:{default:[Nu]},$$scope:{ctx:V}}}),{c(){o=l("meta"),$=p(),y(d.$$.fragment),x=p(),z=l("h1"),_=l("a"),C=l("span"),y(D.$$.fragment),P=p(),q=l("span"),O=s("D\u1ECBch m\xE1y"),T=p(),F.c(),I=p(),B=l("p"),tn=s("B\xE2y gi\u1EDD ch\xFAng ta h\xE3y \u0111i s\xE2u v\xE0o d\u1ECBch m\xE1y. \u0110\xE2y l\xE0 m\u1ED9t "),U=l("a"),H=s("t\xE1c v\u1EE5 chu\u1ED7i sang chu\u1ED7i"),X=s(", c\xF3 ngh\u0129a l\xE0 \u0111\xE2y l\xE0 m\u1ED9t v\u1EA5n \u0111\u1EC1 c\xF3 th\u1EC3 \u0111\u01B0\u1EE3c h\xECnh th\xE0nh nh\u01B0 \u0111i t\u1EEB m\u1ED9t chu\u1ED7i n\xE0y sang chu\u1ED7i kh\xE1c. Theo ngh\u0129a \u0111\xF3, v\u1EA5n \u0111\u1EC1 kh\xE1 gi\u1ED1ng v\u1EDBi "),Y=l("a"),rn=s("t\xF3m t\u1EAFt"),on=s(" v\xE0 b\u1EA1n c\xF3 th\u1EC3 \u0111i\u1EC1u ch\u1EC9nh nh\u1EEFng g\xEC ch\xFAng ta s\u1EBD th\u1EA5y \u1EDF \u0111\xE2y th\xE0nh c\xE1c v\u1EA5n \u0111\u1EC1 chu\u1ED7i sang chu\u1ED7i kh\xE1c nh\u01B0:"),sn=p(),Q=l("ul"),Z=l("li"),R=l("strong"),un=s("Chuy\u1EC3n v\u0103n phong"),dn=s(": T\u1EA1o m\xF4 h\xECnh "),en=l("em"),nn=s("d\u1ECBch"),fn=s(" v\u0103n b\u1EA3n \u0111\u01B0\u1EE3c vi\u1EBFt theo m\u1ED9t phong c\xE1ch nh\u1EA5t \u0111\u1ECBnh sang m\u1ED9t phong c\xE1ch kh\xE1c (v\xED d\u1EE5: t\u1EEB trang tr\u1ECDng sang th\xF4ng th\u01B0\u1EDDng ho\u1EB7c ti\u1EBFng Anh Shakespearean sang ti\u1EBFng Anh hi\u1EC7n \u0111\u1EA1i)"),mn=p(),ln=l("li"),M=l("strong"),G=s("H\u1ECFi \u0111\xE1p chung"),jn=s(": T\u1EA1o m\u1ED9t m\xF4 h\xECnh t\u1EA1o c\xE2u tr\u1EA3 l\u1EDDi cho c\xE1c c\xE2u h\u1ECFi, d\u1EF1a tr\xEAn ng\u1EEF c\u1EA3nh"),xn=p(),y(pn.$$.fragment),W=p(),an=l("p"),kn=s("N\u1EBFu b\u1EA1n c\xF3 m\u1ED9t kho v\u0103n b\u1EA3n \u0111\u1EE7 l\u1EDBn v\u1EDBi hai (ho\u1EB7c nhi\u1EC1u) ng\xF4n ng\u1EEF, b\u1EA1n c\xF3 th\u1EC3 hu\u1EA5n luy\u1EC7n m\u1ED9t m\xF4 h\xECnh d\u1ECBch m\u1EDBi t\u1EEB \u0111\u1EA7u gi\u1ED1ng nh\u01B0 ch\xFAng ta s\u1EBD l\xE0m trong ph\u1EA7n "),Tn=l("a"),On=s("l\u1EADp m\xF4 h\xECnh ng\xF4n ng\u1EEF nh\xE2n qu\u1EA3"),_n=s(". Tuy nhi\xEAn, s\u1EBD nhanh h\u01A1n n\u1EBFu tinh ch\u1EC9nh m\xF4 h\xECnh d\u1ECBch hi\u1EC7n c\xF3, c\xF3 th\u1EC3 l\xE0 m\xF4 h\xECnh \u0111a ng\xF4n ng\u1EEF nh\u01B0 mT5 ho\u1EB7c mBART m\xE0 b\u1EA1n mu\u1ED1n tinh ch\u1EC9nh cho ph\xF9 h\u1EE3p v\u1EDBi m\u1ED9t c\u1EB7p ng\xF4n ng\u1EEF c\u1EE5 th\u1EC3 ho\u1EB7c th\u1EADm ch\xED l\xE0 m\u1ED9t m\xF4 h\xECnh chuy\xEAn d\u1EE5ng \u0111\u1EC3 d\u1ECBch t\u1EEB ng\xF4n ng\u1EEF n\xE0y sang ng\xF4n ng\u1EEF kh\xE1c m\xE0 b\u1EA1n mu\u1ED1n tinh ch\u1EC9nh \u0111\u1EC3 ph\xF9 h\u1EE3p v\u1EDBi kho d\u1EEF li\u1EC7u c\u1EE5 th\u1EC3 c\u1EE7a m\xECnh."),bn=p(),J=l("p"),Cn=s("Trong ph\u1EA7n n\xE0y, ch\xFAng ta s\u1EBD tinh ch\u1EC9nh m\xF4 h\xECnh Marian \u0111\u01B0\u1EE3c hu\u1EA5n luy\u1EC7n tr\u01B0\u1EDBc \u0111\u1EC3 d\u1ECBch t\u1EEB ti\u1EBFng Anh sang ti\u1EBFng Ph\xE1p (v\xEC r\u1EA5t nhi\u1EC1u nh\xE2n vi\xEAn c\u1EE7a Hugging Face n\xF3i c\u1EA3 hai ng\xF4n ng\u1EEF \u0111\xF3) tr\xEAn "),wn=l("a"),mt=s("t\u1EADp d\u1EEF li\u1EC7u KDE4"),Nn=s(", l\xE0 t\u1EADp d\u1EEF li\u1EC7u c\xE1c t\u1EC7p \u0111\u01B0\u1EE3c b\u1EA3n \u0111\u1ECBa h\xF3a cho "),En=l("a"),Ln=s("\u1EE9ng d\u1EE5ng KDE"),gt=s(". M\xF4 h\xECnh ch\xFAng ta s\u1EBD s\u1EED d\u1EE5ng \u0111\xE3 \u0111\u01B0\u1EE3c hu\u1EA5n luy\u1EC7n tr\u01B0\u1EDBc tr\xEAn m\u1ED9t kho d\u1EEF li\u1EC7u l\u1EDBn g\u1ED3m c\xE1c v\u0103n b\u1EA3n ti\u1EBFng Ph\xE1p v\xE0 ti\u1EBFng Anh \u0111\u01B0\u1EE3c l\u1EA5y t\u1EEB "),$n=l("a"),Hn=s("T\u1EADp d\u1EEF li\u1EC7u Opus"),at=s(", th\u1EF1c s\u1EF1 ch\u1EE9a t\u1EADp d\u1EEF li\u1EC7u KDE4. Nh\u01B0ng ngay c\u1EA3 khi m\xF4 h\xECnh hu\u1EA5n luy\u1EC7n tr\u01B0\u1EDBc m\xE0 ch\xFAng ta s\u1EED d\u1EE5ng \u0111\xE3 nh\xECn th\u1EA5y d\u1EEF li\u1EC7u \u0111\xF3 trong qu\xE1 tr\xECnh hu\u1EA5n luy\u1EC7n tr\u01B0\u1EDBc c\u1EE7a n\xF3, ch\xFAng ta s\u1EBD th\u1EA5y r\u1EB1ng ta c\xF3 th\u1EC3 nh\u1EADn \u0111\u01B0\u1EE3c phi\xEAn b\u1EA3n t\u1ED1t h\u01A1n c\u1EE7a n\xF3 sau khi tinh ch\u1EC9nh."),k=p(),K=l("p"),Bn=s("Sau khi ho\xE0n th\xE0nh, ch\xFAng ta s\u1EBD c\xF3 m\u1ED9t m\xF4 h\xECnh c\xF3 th\u1EC3 \u0111\u01B0a ra c\xE1c d\u1EF1 \u0111o\xE1n nh\u01B0 sau:"),zn=p(),gn=l("iframe"),Tt=p(),cn=l("a"),Pn=l("img"),Ct=p(),qn=l("img"),rt=p(),hn=l("p"),Pt=s("Nh\u01B0 trong c\xE1c ph\u1EA7n tr\u01B0\u1EDBc, b\u1EA1n c\xF3 th\u1EC3 t\xECm th\u1EA5y m\xF4 h\xECnh th\u1EF1c t\u1EBF m\xE0 ch\xFAng ta s\u1EBD hu\u1EA5n luy\u1EC7n v\xE0 t\u1EA3i l\xEAn Hub b\u1EB1ng c\xE1ch s\u1EED d\u1EE5ng \u0111o\u1EA1n m\xE3 b\xEAn d\u01B0\u1EDBi v\xE0 ki\u1EC3m tra k\u1EF9 c\xE1c d\u1EF1 \u0111o\xE1n c\u1EE7a n\xF3 "),Dn=l("a"),ue=s("t\u1EA1i \u0111\xE2y"),Mt=s("."),Ft=p(),Wn=l("h2"),Mn=l("a"),Dt=l("span"),y(dt.$$.fragment),zt=p(),At=l("span"),Yn=s("Chu\u1EA9n b\u1ECB d\u1EEF li\u1EC7u"),ne=p(),yn=l("p"),St=s("\u0110\u1EC3 tinh ch\u1EC9nh ho\u1EB7c hu\u1EA5n luy\u1EC7n m\u1ED9t m\xF4 h\xECnh d\u1ECBch t\u1EEB \u0111\u1EA7u, ch\xFAng ta s\u1EBD c\u1EA7n m\u1ED9t t\u1EADp d\u1EEF li\u1EC7u ph\xF9 h\u1EE3p v\u1EDBi t\xE1c v\u1EE5. Nh\u01B0 \u0111\xE3 \u0111\u1EC1 c\u1EADp tr\u01B0\u1EDBc \u0111\xE2y, ch\xFAng ta s\u1EBD s\u1EED d\u1EE5ng "),Zn=l("a"),me=s("t\u1EADp d\u1EEF li\u1EC7u KDE4"),ft=s(" trong ph\u1EA7n n\xE0y, nh\u01B0ng b\u1EA1n c\xF3 th\u1EC3 \u0111i\u1EC1u ch\u1EC9nh \u0111o\u1EA1n m\xE3 \u0111\u1EC3 s\u1EED d\u1EE5ng d\u1EEF li\u1EC7u c\u1EE7a ri\xEAng m\xECnh kh\xE1 d\u1EC5 d\xE0ng, mi\u1EC5n l\xE0 b\u1EA1n c\xF3 c\xE1c c\u1EB7p c\u1EE7a c\xE1c c\xE2u b\u1EB1ng hai ng\xF4n ng\u1EEF m\xE0 b\u1EA1n mu\u1ED1n d\u1ECBch t\u1EEB v\xE0 t\u1EDBi. Tham kh\u1EA3o l\u1EA1i "),Fn=l("a"),_t=s("Ch\u01B0\u01A1ng 5"),Un=s(" n\u1EBFu b\u1EA1n c\u1EA7n l\u1EDDi nh\u1EAFc v\u1EC1 c\xE1ch t\u1EA3i d\u1EEF li\u1EC7u t\xF9y ch\u1EC9nh c\u1EE7a m\xECnh trong "),bt=l("code"),te=s("Dataset"),ge=s("."),In=p(),Vn=l("h3"),Jn=l("a"),ee=l("span"),y(vt.$$.fragment),Kn=p(),Qn=l("span"),se=s("B\u1ED9 d\u1EEF li\u1EC7u KDE4"),it=p(),An=l("p"),Ut=s("Nh\u01B0 th\u01B0\u1EDDng l\u1EC7, ch\xFAng ta t\u1EA3i xu\u1ED1ng t\u1EADp d\u1EEF li\u1EC7u c\u1EE7a m\xECnh b\u1EB1ng c\xE1ch s\u1EED d\u1EE5ng h\xE0m "),kt=l("code"),de=s("load_dataset()"),Rn=s(":"),$t=p(),y(nt.$$.fragment),Ot=p(),yt=l("p"),It=s("N\u1EBFu b\u1EA1n mu\u1ED1n l\xE0m vi\u1EC7c v\u1EDBi m\u1ED9t c\u1EB7p ng\xF4n ng\u1EEF kh\xE1c, b\u1EA1n c\xF3 th\u1EC3 ch\u1EC9 \u0111\u1ECBnh ch\xFAng b\u1EB1ng \u0111o\u1EA1n m\xE3 c\u1EE7a ch\xFAng. C\xF3 t\u1ED5ng s\u1ED1 92 ng\xF4n ng\u1EEF c\xF3 s\u1EB5n cho b\u1ED9 d\u1EEF li\u1EC7u n\xE0y; b\u1EA1n c\xF3 th\u1EC3 th\u1EA5y t\u1EA5t c\u1EA3 ch\xFAng b\u1EB1ng c\xE1ch m\u1EDF r\u1ED9ng c\xE1c th\u1EBB ng\xF4n ng\u1EEF tr\xEAn "),tt=l("a"),Ee=s("th\u1EBB d\u1EEF li\u1EC7u"),ae=s(" c\u1EE7a n\xF3."),g=p(),N=l("img"),we=p(),Et=l("p"),Xe=s("H\xE3y xem t\u1EADp d\u1EEF li\u1EC7u:"),ot=p(),y(pt.$$.fragment),he=p(),y(Vt.$$.fragment),Kt=p(),vn=l("p"),fe=s("Ch\xFAng ta c\xF3 210,173 c\u1EB7p c\xE2u, nh\u01B0ng ch\u1EC9 trong m\u1ED9t l\u1EA7n t\xE1ch, v\xEC v\u1EADy ch\xFAng ta s\u1EBD c\u1EA7n t\u1EA1o b\u1ED9 ki\u1EC3m \u0111\u1ECBnh c\u1EE7a ri\xEAng m\xECnh. Nh\u01B0 ch\xFAng ta \u0111\xE3 th\u1EA5y trong "),Nt=l("a"),Sn=s("Ch\u01B0\u01A1ng 5"),We=s(", "),Rt=l("code"),Ye=s("Dataset"),Ze=s(" c\xF3 ph\u01B0\u01A1ng th\u1EE9c "),le=l("code"),Gn=s("train_test_split()"),_e=s(" c\xF3 th\u1EC3 gi\xFAp ch\xFAng ta. Ch\xFAng ta s\u1EBD cung c\u1EA5p m\u1ED9t h\u1EA1t gi\u1ED1ng (seed) cho kh\u1EA3 n\u0103ng t\xE1i t\u1EA1o:"),Gt=p(),y(Xt.$$.fragment),xe=p(),y(wt.$$.fragment),qe=p(),ut=l("p"),be=s("B\u1EA1n c\xF3 th\u1EC3 \u0111\u1ED5i "),xt=l("code"),Je=s('"test"'),Te=s(" th\xE0nh "),qt=l("code"),Ce=s('"validation"'),Wt=s(" nh\u01B0 sau:"),_s=p(),y(et.$$.fragment),qs=p(),ve=l("p"),Zs=s("B\xE2y gi\u1EDD ch\xFAng ta h\xE3y xem x\xE9t m\u1ED9t ph\u1EA7n t\u1EED c\u1EE7a t\u1EADp d\u1EEF li\u1EC7u:"),Ts=p(),y(Lt.$$.fragment),Qe=p(),y(Pe.$$.fragment),Cs=p(),De=l("p"),m=s("Ch\xFAng ta nh\u1EADn \u0111\u01B0\u1EE3c m\u1ED9t t\u1EEB \u0111i\u1EC3n c\xF3 hai c\xE2u b\u1EB1ng c\u1EB7p ng\xF4n ng\u1EEF m\xE0 ta y\xEAu c\u1EA7u. M\u1ED9t \u0111i\u1EC3m \u0111\u1EB7c bi\u1EC7t c\u1EE7a b\u1ED9 d\u1EEF li\u1EC7u \u0111\u1EA7y \u0111\u1EE7 c\xE1c thu\u1EADt ng\u1EEF khoa h\u1ECDc m\xE1y t\xEDnh k\u1EF9 thu\u1EADt n\xE0y l\xE0 ch\xFAng \u0111\u1EC1u \u0111\u01B0\u1EE3c d\u1ECBch ho\xE0n to\xE0n b\u1EB1ng ti\u1EBFng Ph\xE1p. Tuy nhi\xEAn, c\xE1c k\u1EF9 s\u01B0 Ph\xE1p th\u01B0\u1EDDng l\u01B0\u1EDDi bi\u1EBFng v\xE0 \u0111\u1EC3 l\u1EA1i h\u1EA7u h\u1EBFt c\xE1c t\u1EEB chuy\xEAn ng\xE0nh khoa h\u1ECDc m\xE1y t\xEDnh b\u1EB1ng ti\u1EBFng Anh khi h\u1ECD n\xF3i chuy\u1EC7n. V\xED d\u1EE5, \u1EDF \u0111\xE2y, t\u1EEB \u201Cthreads\u201D c\xF3 th\u1EC3 xu\u1EA5t hi\u1EC7n trong m\u1ED9t c\xE2u ti\u1EBFng Ph\xE1p, \u0111\u1EB7c bi\u1EC7t l\xE0 trong m\u1ED9t cu\u1ED9c tr\xF2 chuy\u1EC7n k\u1EF9 thu\u1EADt; nh\u01B0ng trong t\u1EADp d\u1EEF li\u1EC7u n\xE0y, n\xF3 \u0111\xE3 \u0111\u01B0\u1EE3c d\u1ECBch th\xE0nh \u0111\xFAng h\u01A1n l\xE0 \u201Cfils de discussion\u201D. M\xF4 h\xECnh hu\u1EA5n luy\u1EC7n tr\u01B0\u1EDBc m\xE0 ch\xFAng ta s\u1EED d\u1EE5ng, \u0111\xE3 \u0111\u01B0\u1EE3c hu\u1EA5n luy\u1EC7n tr\u01B0\u1EDBc tr\xEAn m\u1ED9t kho ng\u1EEF li\u1EC7u l\u1EDBn h\u01A1n c\u1EE7a c\xE1c c\xE2u ti\u1EBFng Ph\xE1p v\xE0 ti\u1EBFng Anh, c\xF3 t\xF9y ch\u1ECDn d\u1EC5 d\xE0ng h\u01A1n l\xE0 \u0111\u1EC3 nguy\xEAn t\u1EEB nh\u01B0 sau:"),L=p(),y(ns.$$.fragment),Js=p(),y(ts.$$.fragment),ze=p(),bs=l("p"),th=s(`M\u1ED9t v\xED d\u1EE5 kh\xE1c v\u1EC1 h\xE0nh vi n\xE0y c\xF3 th\u1EC3 \u0111\u01B0\u1EE3c nh\xECn th\u1EA5y v\u1EDBi t\u1EEB \u201Cplugin\u201D, \u0111\xE2y kh\xF4ng ph\u1EA3i l\xE0 m\u1ED9t t\u1EEB ch\xEDnh th\u1EE9c trong ti\u1EBFng Ph\xE1p nh\u01B0ng h\u1EA7u h\u1EBFt ng\u01B0\u1EDDi b\u1EA3n ng\u1EEF s\u1EBD hi\u1EC3u v\xE0 kh\xF4ng b\u1EADn t\xE2m \u0111\u1EBFn vi\u1EC7c d\u1ECBch.
Trong t\u1EADp d\u1EEF li\u1EC7u KDE4, t\u1EEB n\xE0y \u0111\xE3 \u0111\u01B0\u1EE3c d\u1ECBch b\u1EB1ng ti\u1EBFng Ph\xE1p m\u1ED9t c\xE1ch ch\xEDnh th\u1ED1ng h\u01A1n th\xE0nh \u201Cmodule d\u2019extension\u201D:`),vs=p(),y(es.$$.fragment),Qs=p(),y(ss.$$.fragment),Ae=p(),ks=l("p"),eh=s("Tuy nhi\xEAn, m\xF4 h\xECnh \u0111\u01B0\u1EE3c hu\u1EA5n luy\u1EC7n tr\u01B0\u1EDBc c\u1EE7a ch\xFAng ta g\u1EAFn v\u1EDBi t\u1EEB ti\u1EBFng Anh nh\u1ECF g\u1ECDn v\xE0 quen thu\u1ED9c:"),na=p(),y(as.$$.fragment),Se=p(),y(hs.$$.fragment),ta=p(),Ht=l("p"),sh=s("S\u1EBD r\u1EA5t th\xFA v\u1ECB khi xem li\u1EC7u m\xF4 h\xECnh tinh ch\u1EC9nh c\u1EE7a m\xECnh c\xF3 ti\u1EBFp thu nh\u1EEFng \u0111\u1EB7c \u0111i\u1EC3m \u0111\xF3 c\u1EE7a t\u1EADp d\u1EEF li\u1EC7u hay kh\xF4ng (c\u1EA3nh b\xE1o spoiler: n\xF3 s\u1EBD x\u1EA3y ra)."),ea=p(),y(ls.$$.fragment),ce=p(),y(Oe.$$.fragment),sa=p(),ke=l("h3"),Ne=l("a"),$e=l("span"),y(cs.$$.fragment),ah=p(),rs=l("span"),hh=s("Chu\u1EA9n b\u1ECB d\u1EEF li\u1EC7u"),aa=p(),y(is.$$.fragment),Le=p(),re=l("p"),lh=s("B\xE2y gi\u1EDD b\u1EA1n n\xEAn bi\u1EBFt \u0111i\u1EC1u n\xE0y: t\u1EA5t c\u1EA3 c\xE1c v\u0103n b\u1EA3n c\u1EA7n \u0111\u01B0\u1EE3c chuy\u1EC3n \u0111\u1ED5i th\xE0nh t\u1EADp h\u1EE3p c\xE1c token ID \u0111\u1EC3 m\xF4 h\xECnh c\xF3 th\u1EC3 hi\u1EC3u \u0111\u01B0\u1EE3c ch\xFAng. \u0110\u1ED1i v\u1EDBi t\xE1c v\u1EE5 n\xE0y, ch\xFAng ta s\u1EBD c\u1EA7n tokenize c\u1EA3 \u0111\u1EA7u v\xE0o v\xE0 nh\xE3n. T\xE1c v\u1EE5 \u0111\u1EA7u ti\xEAn c\u1EE7a ch\xFAng ta l\xE0 t\u1EA1o \u0111\u1ED1i t\u01B0\u1EE3ng "),ye=l("code"),ch=s("tokenizer"),rh=s(". Nh\u01B0 \u0111\xE3 l\u01B0u \xFD tr\u01B0\u1EDBc \u0111\xF3, ch\xFAng ta s\u1EBD s\u1EED d\u1EE5ng m\xF4 h\xECnh hu\u1EA5n luy\u1EC7n tr\u01B0\u1EDBc t\u1EEB ti\u1EBFng Anh sang ti\u1EBFng Ph\xE1p c\u1EE7a Marian. N\u1EBFu b\u1EA1n \u0111ang th\u1EED \u0111o\u1EA1n m\xE3 n\xE0y v\u1EDBi m\u1ED9t c\u1EB7p ng\xF4n ng\u1EEF kh\xE1c, h\xE3y \u0111\u1EA3m b\u1EA3o \u0111i\u1EC1u ch\u1EC9nh checkpoint c\u1EE7a m\xF4 h\xECnh. T\u1ED5 ch\u1EE9c "),Yt=l("a"),ih=s("Helsinki-NLP"),oh=s(" cung c\u1EA5p h\u01A1n m\u1ED9t ngh\xECn m\xF4 h\xECnh b\u1EB1ng nhi\u1EC1u ng\xF4n ng\u1EEF."),ie=p(),y(os.$$.fragment),ha=p(),oe=l("p"),ps=s("You can also replace the "),Ps=l("code"),ph=s("model_checkpoint"),uh=s(" with any other model you prefer from the "),la=l("a"),mr=s("Hub"),gr=s(", or a local folder where you\u2019ve saved a pretrained model and a tokenizer."),Dl=p(),y(Ds.$$.fragment),zl=p(),zs=l("p"),dr=s("Vi\u1EC7c chu\u1EA9n b\u1ECB d\u1EEF li\u1EC7u c\u1EE7a ch\xFAng ta kh\xE1 \u0111\u01A1n gi\u1EA3n. Ch\u1EC9 c\xF3 m\u1ED9t \u0111i\u1EC1u c\u1EA7n nh\u1EDB: b\u1EA1n x\u1EED l\xFD c\xE1c \u0111\u1EA7u v\xE0o nh\u01B0 b\xECnh th\u01B0\u1EDDng, nh\u01B0ng \u0111\u1ED1i v\u1EDBi c\xE1c nh\xE3n, b\u1EA1n c\u1EA7n ph\u1EA3i b\u1ECDc tokenizer b\xEAn trong tr\xECnh qu\u1EA3n l\xFD ng\u1EEF c\u1EA3nh "),Zh=l("code"),fr=s("as_target_tokenizer()"),_r=s("."),Al=p(),As=l("p"),br=s("Tr\xECnh qu\u1EA3n l\xFD ng\u1EEF c\u1EA3nh trong Python \u0111\u01B0\u1EE3c gi\u1EDBi thi\u1EC7u v\u1EDBi c\xE2u l\u1EC7nh "),Jh=l("code"),vr=s("with"),kr=s(" v\xE0 r\u1EA5t h\u1EEFu \xEDch khi b\u1EA1n c\xF3 hai ho\u1EA1t \u0111\u1ED9ng li\xEAn quan \u0111\u1EC3 th\u1EF1c thi nh\u01B0 m\u1ED9t c\u1EB7p. V\xED d\u1EE5 ph\u1ED5 bi\u1EBFn nh\u1EA5t v\u1EC1 \u0111i\u1EC1u n\xE0y l\xE0 khi b\u1EA1n vi\u1EBFt ho\u1EB7c \u0111\u1ECDc m\u1ED9t t\u1EC7p, th\u01B0\u1EDDng \u0111\u01B0\u1EE3c th\u1EF1c hi\u1EC7n b\xEAn trong m\u1ED9t l\u1EC7nh nh\u01B0:"),Sl=p(),y(ca.$$.fragment),Ol=p(),us=l("p"),$r=s("\u1EDE \u0111\xE2y, hai ho\u1EA1t \u0111\u1ED9ng li\xEAn quan \u0111\u01B0\u1EE3c th\u1EF1c hi\u1EC7n nh\u01B0 m\u1ED9t c\u1EB7p l\xE0 c\xE1c h\xE0nh \u0111\u1ED9ng m\u1EDF v\xE0 \u0111\xF3ng t\u1EC7p. \u0110\u1ED1i t\u01B0\u1EE3ng t\u01B0\u01A1ng \u1EE9ng v\u1EDBi t\u1EC7p \u0111\xE3 m\u1EDF "),Qh=l("code"),yr=s("f"),jr=s(" ch\u1EC9 t\u1ED3n t\u1EA1i b\xEAn trong kh\u1ED1i \u0111\u01B0\u1EE3c th\u1EE5t l\u1EC1 d\u01B0\u1EDBi d\u1EA5u "),nl=l("code"),Er=s("with"),wr=s("; s\u1EF1 m\u1EDF \u0111\u1EA7u x\u1EA3y ra tr\u01B0\u1EDBc kh\u1ED1i \u0111\xF3 v\xE0 \u0111\xF3ng \u1EDF cu\u1ED1i kh\u1ED1i."),Nl=p(),Ss=l("p"),xr=s("Trong tr\u01B0\u1EDDng h\u1EE3p n\xE0y, tr\xECnh qu\u1EA3n l\xFD ng\u1EEF c\u1EA3nh "),tl=l("code"),qr=s("as_target_tokenizer()"),Tr=s(" s\u1EBD \u0111\u1EB7t tokenizer \u1EDF ng\xF4n ng\u1EEF \u0111\u1EA7u ra (\u1EDF \u0111\xE2y, ti\u1EBFng Ph\xE1p) tr\u01B0\u1EDBc khi kh\u1ED1i \u0111\u01B0\u1EE3c th\u1EE5t l\u1EC1 \u0111\u01B0\u1EE3c th\u1EF1c thi, sau \u0111\xF3 \u0111\u1EB7t n\xF3 tr\u1EDF l\u1EA1i b\u1EB1ng ng\xF4n ng\u1EEF \u0111\u1EA7u v\xE0o (\u1EDF \u0111\xE2y, ti\u1EBFng Anh)."),Ll=p(),mh=l("p"),Cr=s("V\xEC v\u1EADy, vi\u1EC7c x\u1EED l\xFD tr\u01B0\u1EDBc m\u1ED9t m\u1EABu tr\xF4ng nh\u01B0 th\u1EBF n\xE0y:"),Hl=p(),y(ra.$$.fragment),Bl=p(),gh=l("p"),Pr=s("N\u1EBFu ch\xFAng ta qu\xEAn tokenize c\xE1c nh\xE3n b\xEAn trong tr\xECnh qu\u1EA3n l\xFD ng\u1EEF c\u1EA3nh, ch\xFAng s\u1EBD \u0111\u01B0\u1EE3c tokenize b\u1EDFi tr\xECnh tokenize \u0111\u1EA7u v\xE0o, trong tr\u01B0\u1EDDng h\u1EE3p m\xF4 h\xECnh Marian s\u1EBD kh\xF4ng ho\u1EA1t \u0111\u1ED9ng t\u1ED1t ch\xFAt n\xE0o:"),Ml=p(),y(ia.$$.fragment),Fl=p(),y(oa.$$.fragment),Ul=p(),dh=l("p"),Dr=s("Nh\u01B0 ch\xFAng ta c\xF3 th\u1EC3 th\u1EA5y, vi\u1EC7c s\u1EED d\u1EE5ng tr\xECnh tokenize ti\u1EBFng Anh \u0111\u1EC3 x\u1EED l\xFD tr\u01B0\u1EDBc m\u1ED9t c\xE2u ti\u1EBFng Ph\xE1p d\u1EABn \u0111\u1EBFn nhi\u1EC1u token h\u01A1n, v\xEC tr\xECnh tokenize kh\xF4ng bi\u1EBFt b\u1EA5t k\u1EF3 t\u1EEB ti\u1EBFng Ph\xE1p n\xE0o (ngo\u1EA1i tr\u1EEB nh\u1EEFng t\u1EEB c\u0169ng xu\u1EA5t hi\u1EC7n trong ti\u1EBFng Anh, nh\u01B0 \u201Cdiscussion\u201D)."),Il=p(),je=l("p"),zr=s("C\u1EA3 "),el=l("code"),Ar=s("inputs"),Sr=s(" v\xE0 "),sl=l("code"),Or=s("targets"),Nr=s(" \u0111\u1EC1u l\xE0 t\u1EEB \u0111i\u1EC3n v\u1EDBi c\xE1c kh\xF3a th\xF4ng th\u01B0\u1EDDng c\u1EE7a ch\xFAng ta (ID \u0111\u1EA7u v\xE0o, attention mask, v.v.), v\xEC v\u1EADy b\u01B0\u1EDBc cu\u1ED1i c\xF9ng l\xE0 \u0111\u1EB7t "),al=l("code"),Lr=s('"labels"'),Hr=s(" b\xEAn trong c\xE1c \u0111\u1EA7u v\xE0o. Ch\xFAng ta th\u1EF1c hi\u1EC7n \u0111i\u1EC1u n\xE0y trong ch\u1EE9c n\u0103ng ti\u1EC1n x\u1EED l\xFD m\xE0 ta s\u1EBD \xE1p d\u1EE5ng tr\xEAn c\xE1c t\u1EADp d\u1EEF li\u1EC7u:"),Vl=p(),y(pa.$$.fragment),Kl=p(),fh=l("p"),Br=s("Note that we set similar maximum lengths for our inputs and outputs. Since the texts we\u2019re dealing with seem pretty short, we use 128."),Rl=p(),y(Os.$$.fragment),Gl=p(),y(Ns.$$.fragment),Xl=p(),_h=l("p"),Mr=s("B\xE2y gi\u1EDD ch\xFAng ta c\xF3 th\u1EC3 \xE1p d\u1EE5ng ti\u1EC1n x\u1EED l\xFD \u0111\xF3 trong m\u1ED9t l\u1EA7n tr\xEAn t\u1EA5t c\u1EA3 c\xE1c ph\u1EA7n c\u1EE7a t\u1EADp d\u1EEF li\u1EC7u c\u1EE7a m\xECnh:"),Wl=p(),y(ua.$$.fragment),Yl=p(),bh=l("p"),Fr=s("B\xE2y gi\u1EDD d\u1EEF li\u1EC7u \u0111\xE3 \u0111\u01B0\u1EE3c ti\u1EC1n x\u1EED l\xFD, ch\xFAng ta \u0111\xE3 s\u1EB5n s\xE0ng \u0111\u1EC3 tinh ch\u1EC9nh m\xF4 h\xECnh ti\u1EC1n x\u1EED l\xFD c\u1EE7a m\xECnh!"),Zl=p(),Be.c(),vh=p(),kh=l("p"),Ur=s("L\u01B0u \xFD r\u1EB1ng l\u1EA7n n\xE0y ch\xFAng ta \u0111ang s\u1EED d\u1EE5ng m\u1ED9t m\xF4 h\xECnh \u0111\xE3 \u0111\u01B0\u1EE3c hu\u1EA5n luy\u1EC7n v\u1EC1 t\xE1c v\u1EE5 d\u1ECBch v\xE0 th\u1EF1c s\u1EF1 c\xF3 th\u1EC3 \u0111\u01B0\u1EE3c s\u1EED d\u1EE5ng, v\xEC v\u1EADy kh\xF4ng c\xF3 c\u1EA3nh b\xE1o n\xE0o v\u1EC1 vi\u1EC7c thi\u1EBFu c\xE1c tr\u1ECDng s\u1ED1 ho\u1EB7c nh\u1EEFng tr\u1ECDng s\u1ED1 m\u1EDBi \u0111\u01B0\u1EE3c kh\u1EDFi t\u1EA1o."),Jl=p(),$s=l("h3"),Ls=l("a"),hl=l("span"),y(ma.$$.fragment),Ir=p(),ll=l("span"),Vr=s("\u0110\u1ED1i chi\u1EBFu d\u1EEF li\u1EC7u"),Ql=p(),ms=l("p"),Kr=s("Ch\xFAng ta s\u1EBD c\u1EA7n m\u1ED9t c\xF4ng c\u1EE5 \u0111\u1ED1i chi\u1EBFu d\u1EEF li\u1EC7u \u0111\u1EC3 x\u1EED l\xFD ph\u1EA7n \u0111\u1EC7m cho ph\xE2n ph\u1ED1i \u0111\u1ED9ng. Ch\xFAng ta kh\xF4ng th\u1EC3 ch\u1EC9 s\u1EED d\u1EE5ng m\u1ED9t "),cl=l("code"),Rr=s("DataCollatorWithPadding"),Gr=s(" nh\u01B0 [Ch\u01B0\u01A1ng 3](/course/ chapter3) trong tr\u01B0\u1EDDng h\u1EE3p n\xE0y, b\u1EDFi v\xEC \u0111i\u1EC1u \u0111\xF3 ch\u1EC9 \u0111\u1EC7m c\xE1c \u0111\u1EA7u v\xE0o (ID \u0111\u1EA7u v\xE0o, attention mask, v\xE0 lo\u1EA1i token ID). C\xE1c nh\xE3n c\u1EE7a ch\xFAng ta c\u0169ng ph\u1EA3i \u0111\u01B0\u1EE3c \u0111\u1EC7m theo chi\u1EC1u d\xE0i t\u1ED1i \u0111a c\xF3 trong nh\xE3n. V\xE0, nh\u01B0 \u0111\xE3 \u0111\u1EC1 c\u1EADp tr\u01B0\u1EDBc \u0111\xE2y, gi\xE1 tr\u1ECB \u0111\u1EC7m \u0111\u01B0\u1EE3c s\u1EED d\u1EE5ng \u0111\u1EC3 \u0111\u1EC7m c\xE1c nh\xE3n ph\u1EA3i l\xE0 "),rl=l("code"),Xr=s("-100"),Wr=s(" ch\u1EE9 kh\xF4ng ph\u1EA3i token \u0111\u1EC7m c\u1EE7a tr\xECnh tokenize, \u0111\u1EC3 \u0111\u1EA3m b\u1EA3o c\xE1c gi\xE1 tr\u1ECB \u0111\u1EC7m \u0111\xF3 b\u1ECB b\u1ECF qua trong t\xEDnh to\xE1n m\u1EA5t m\xE1t."),nc=p(),st=l("p"),Yr=s("T\u1EA5t c\u1EA3 \u0111i\u1EC1u n\xE0y \u0111\u01B0\u1EE3c th\u1EF1c hi\u1EC7n b\u1EDFi "),ga=l("a"),il=l("code"),Zr=s("DataCollatorForSeq2Seq"),Jr=s(". Gi\u1ED1ng nh\u01B0 "),ol=l("code"),Qr=s("DataCollatorWithPadding"),ni=s(", n\xF3 s\u1EED d\u1EE5ng "),pl=l("code"),ti=s("tokenizer"),ei=s(" \u0111\u01B0\u1EE3c s\u1EED d\u1EE5ng \u0111\u1EC3 x\u1EED l\xFD tr\u01B0\u1EDBc c\xE1c \u0111\u1EA7u v\xE0o, nh\u01B0ng n\xF3 c\u0169ng l\u1EA5y "),ul=l("code"),si=s("model"),ai=s(". \u0110i\u1EC1u n\xE0y l\xE0 do tr\xECnh \u0111\u1ED1i chi\u1EBFu d\u1EEF li\u1EC7u n\xE0y c\u0169ng s\u1EBD ch\u1ECBu tr\xE1ch nhi\u1EC7m chu\u1EA9n b\u1ECB c\xE1c ID \u0111\u1EA7u v\xE0o c\u1EE7a b\u1ED9 gi\u1EA3i m\xE3, l\xE0 c\xE1c phi\xEAn b\u1EA3n \u0111\u01B0\u1EE3c d\u1ECBch chuy\u1EC3n c\u1EE7a c\xE1c nh\xE3n v\u1EDBi m\u1ED9t token \u0111\u1EB7c bi\u1EC7t \u1EDF \u0111\u1EA7u. V\xEC s\u1EF1 thay \u0111\u1ED5i n\xE0y \u0111\u01B0\u1EE3c th\u1EF1c hi\u1EC7n h\u01A1i kh\xE1c \u0111\u1ED1i v\u1EDBi c\xE1c ki\u1EBFn \u200B\u200Btr\xFAc kh\xE1c nhau, n\xEAn "),ml=l("code"),hi=s("DataCollatorForSeq2Seq"),li=s(" c\u1EA7n bi\u1EBFt \u0111\u1ED1i t\u01B0\u1EE3ng "),gl=l("code"),ci=s("model"),ri=s(":"),tc=p(),Fe.c(),$h=p(),yh=l("p"),ii=s("\u0110\u1EC3 ki\u1EC3m tra \u0111i\u1EC1u n\xE0y tr\xEAn m\u1ED9t s\u1ED1 m\u1EABu, ch\xFAng ta ch\u1EC9 c\u1EA7n g\u1ECDi n\xF3 trong danh s\xE1ch c\xE1c v\xED d\u1EE5 t\u1EEB b\u1ED9 hu\u1EA5n luy\u1EC7n \u0111\u01B0\u1EE3c tokenize c\u1EE7a m\xECnh:"),ec=p(),y(da.$$.fragment),sc=p(),y(fa.$$.fragment),ac=p(),Hs=l("p"),oi=s("Ch\xFAng t\xF4i c\xF3 th\u1EC3 ki\u1EC3m tra nh\xE3n \u0111\xE3 \u0111\u01B0\u1EE3c \u0111\u1EC7m \u0111\u1EBFn \u0111\u1ED9 d\xE0i t\u1ED1i \u0111a c\u1EE7a l\xF4 hay ch\u01B0a, b\u1EB1ng c\xE1ch s\u1EED d\u1EE5ng "),dl=l("code"),pi=s("-100"),ui=s(":"),hc=p(),y(_a.$$.fragment),lc=p(),y(ba.$$.fragment),cc=p(),jh=l("p"),mi=s("V\xE0 ch\xFAng t\xF4i c\u0169ng c\xF3 th\u1EC3 xem x\xE9t c\xE1c ID \u0111\u1EA7u v\xE0o c\u1EE7a b\u1ED9 gi\u1EA3i m\xE3, \u0111\u1EC3 bi\u1EBFt r\u1EB1ng ch\xFAng l\xE0 c\xE1c phi\xEAn b\u1EA3n \u0111\u01B0\u1EE3c thay \u0111\u1ED5i c\u1EE7a nh\xE3n:"),rc=p(),y(va.$$.fragment),ic=p(),y(ka.$$.fragment),oc=p(),Eh=l("p"),gi=s("D\u01B0\u1EDBi \u0111\xE2y l\xE0 c\xE1c nh\xE3n cho c\xE1c ph\u1EA7n t\u1EED \u0111\u1EA7u ti\xEAn v\xE0 th\u1EE9 hai trong t\u1EADp d\u1EEF li\u1EC7u c\u1EE7a m\xECnh:"),pc=p(),y($a.$$.fragment),uc=p(),y(ya.$$.fragment),mc=p(),Ie.c(),wh=p(),ys=l("h3"),Bs=l("a"),fl=l("span"),y(ja.$$.fragment),di=p(),_l=l("span"),fi=s("Th\u01B0\u1EDBc \u0111o"),gc=p(),y(Ea.$$.fragment),dc=p(),Bt&&Bt.c(),xh=p(),Zt=l("p"),_i=s("Ch\u1EC9 s\u1ED1 truy\u1EC1n th\u1ED1ng \u0111\u01B0\u1EE3c s\u1EED d\u1EE5ng cho b\xE0i to\xE1n d\u1ECBch l\xE0 "),wa=l("a"),bi=s("\u0111i\u1EC3m BLEU"),vi=s(", \u0111\u01B0\u1EE3c gi\u1EDBi thi\u1EC7u trong "),xa=l("a"),ki=s("m\u1ED9t b\xE0i b\xE1o n\u0103m 2002"),$i=s(" b\u1EDFi Kishore Papineni v\xE0 c\u1ED9ng s\u1EF1. \u0110i\u1EC3m BLEU \u0111\xE1nh gi\xE1 m\u1EE9c \u0111\u1ED9 g\u1EA7n g\u0169i c\u1EE7a b\u1EA3n d\u1ECBch v\u1EDBi nh\xE3n c\u1EE7a ch\xFAng. N\xF3 kh\xF4ng \u0111o l\u01B0\u1EDDng m\u1EE9c \u0111\u1ED9 d\u1EC5 hi\u1EC3u ho\u1EB7c t\xEDnh \u0111\xFAng ng\u1EEF ph\xE1p c\u1EE7a c\xE1c \u0111\u1EA7u ra \u0111\u01B0\u1EE3c t\u1EA1o ra c\u1EE7a m\xF4 h\xECnh, nh\u01B0ng s\u1EED d\u1EE5ng c\xE1c quy t\u1EAFc th\u1ED1ng k\xEA \u0111\u1EC3 \u0111\u1EA3m b\u1EA3o r\u1EB1ng t\u1EA5t c\u1EA3 c\xE1c t\u1EEB trong c\xE1c \u0111\u1EA7u ra \u0111\u01B0\u1EE3c t\u1EA1o c\u0169ng xu\u1EA5t hi\u1EC7n trong c\xE1c nh\xE3n. Ngo\xE0i ra, c\xF3 c\xE1c quy t\u1EAFc ph\u1EA1t vi\u1EC7c l\u1EB7p l\u1EA1i c\xE1c t\u1EEB gi\u1ED1ng nhau n\u1EBFu ch\xFAng kh\xF4ng \u0111\u01B0\u1EE3c l\u1EB7p l\u1EA1i trong c\xE1c nh\xE3n (\u0111\u1EC3 tr\xE1nh m\xF4 h\xECnh xu\u1EA5t ra c\xE1c c\xE2u nh\u01B0 "),bl=l("code"),yi=s('"the the the"'),ji=s(") v\xE0 xu\u1EA5t ra c\xE1c c\xE2u ng\u1EAFn h\u01A1n c\xE1c c\xE2u trong nh\xE3n (\u0111\u1EC3 tr\xE1nh m\xF4 h\xECnh xu\u1EA5t ra c\xE1c c\xE2u nh\u01B0 "),vl=l("code"),Ei=s('"the"'),wi=s(")."),fc=p(),Ms=l("p"),xi=s("M\u1ED9t \u0111i\u1EC3m y\u1EBFu c\u1EE7a BLEU l\xE0 n\xF3 mong \u0111\u1EE3i v\u0103n b\u1EA3n \u0111\xE3 \u0111\u01B0\u1EE3c tokenize, \u0111i\u1EC1u n\xE0y g\xE2y kh\xF3 kh\u0103n cho vi\u1EC7c so s\xE1nh \u0111i\u1EC3m gi\u1EEFa c\xE1c m\xF4 h\xECnh s\u1EED d\u1EE5ng c\xE1c b\u1ED9 tokenize kh\xE1c nhau. V\xEC v\u1EADy, thay v\xE0o \u0111\xF3, ch\u1EC9 s\u1ED1 \u0111\u01B0\u1EE3c s\u1EED d\u1EE5ng ph\u1ED5 bi\u1EBFn nh\u1EA5t cho c\xE1c m\xF4 h\xECnh d\u1ECBch \u0111i\u1EC3m chu\u1EA9n ng\xE0y nay l\xE0 "),qa=l("a"),qi=s("SacreBLEU"),Ti=s(", gi\u1EA3i quy\u1EBFt \u0111i\u1EC3m y\u1EBFu n\xE0y (v\xE0 c\xE1c ch\u1EC9 s\u1ED1 kh\xE1c) b\u1EB1ng c\xE1ch chu\u1EA9n h\xF3a b\u01B0\u1EDBc tokenize. \u0110\u1EC3 s\u1EED d\u1EE5ng ch\u1EC9 s\u1ED1 n\xE0y, tr\u01B0\u1EDBc ti\xEAn ch\xFAng ta c\u1EA7n c\xE0i \u0111\u1EB7t th\u01B0 vi\u1EC7n SacreBLEU:"),_c=p(),y(Ta.$$.fragment),bc=p(),gs=l("p"),Ci=s("Ch\xFAng ta c\xF3 th\u1EC3 t\u1EA3i n\xF3 v\u1EDBi "),kl=l("code"),Pi=s("evaluate.load()"),Di=s(" nh\u01B0 ch\xFAng ta \u0111\xE3 l\xE0m trong "),qh=l("a"),zi=s("Ch\u01B0\u01A1ng 3"),Ai=s(":"),vc=p(),y(Ca.$$.fragment),kc=p(),Th=l("p"),Si=s("Ch\u1EC9 s\u1ED1 n\xE0y s\u1EBD l\u1EA5y v\u0103n b\u1EA3n l\xE0m \u0111\u1EA7u v\xE0o v\xE0 nh\xE3n. N\xF3 \u0111\u01B0\u1EE3c thi\u1EBFt k\u1EBF \u0111\u1EC3 ch\u1EA5p nh\u1EADn m\u1ED9t s\u1ED1 nh\xE3n c\xF3 th\u1EC3 ch\u1EA5p nh\u1EADn \u0111\u01B0\u1EE3c, v\xEC th\u01B0\u1EDDng c\xF3 nhi\u1EC1u b\u1EA3n d\u1ECBch c\xF3 th\u1EC3 ch\u1EA5p nh\u1EADn \u0111\u01B0\u1EE3c c\u1EE7a c\xF9ng m\u1ED9t c\xE2u - t\u1EADp d\u1EEF li\u1EC7u ta \u0111ang s\u1EED d\u1EE5ng ch\u1EC9 cung c\u1EA5p m\u1ED9t nh\xE3n, nh\u01B0ng kh\xF4ng hi\u1EBFm trong NLP \u0111\u1EC3 t\xECm t\u1EADp d\u1EEF li\u1EC7u cung c\u1EA5p m\u1ED9t s\u1ED1 c\xE2u d\u01B0\u1EDBi d\u1EA1ng nh\xE3n. V\xEC v\u1EADy, c\xE1c d\u1EF1 \u0111o\xE1n ph\u1EA3i l\xE0 m\u1ED9t danh s\xE1ch c\xE1c c\xE2u, nh\u01B0ng c\xE1c tham chi\u1EBFu ph\u1EA3i l\xE0 m\u1ED9t danh s\xE1ch c\xE1c danh s\xE1ch c\xE1c c\xE2u."),$c=p(),Ch=l("p"),Oi=s("H\xE3y th\u1EED m\u1ED9t m\u1EABu:"),yc=p(),y(Pa.$$.fragment),jc=p(),y(Da.$$.fragment),Ec=p(),Jt=l("p"),Ni=s("Ta nh\u1EADn \u0111\u01B0\u1EE3c \u0111i\u1EC3m BLEU l\xE0 46.75, kh\xE1 t\u1ED1t - \u0111\u1EC3 tham kh\u1EA3o, m\xF4 h\xECnh Transformer ban \u0111\u1EA7u trong b\xE0i b\xE1o "),za=l("a"),Li=s("\u201CAttention Is All You Need\u201D"),Hi=s(" \u0111\u1EA1t \u0111\u01B0\u1EE3c \u0111i\u1EC3m BLEU l\xE0 41.8 cho m\u1ED9t t\xE1c v\u1EE5 d\u1ECBch t\u01B0\u01A1ng t\u1EF1 gi\u1EEFa ti\u1EBFng Anh v\xE0 ti\u1EBFng Ph\xE1p! (\u0110\u1EC3 bi\u1EBFt th\xEAm th\xF4ng tin v\u1EC1 c\xE1c ch\u1EC9 s\u1ED1 ri\xEAng l\u1EBB, nh\u01B0 "),$l=l("code"),Bi=s("counts"),Mi=s(" v\xE0 "),yl=l("code"),Fi=s("bp"),Ui=s(", h\xE3y xem "),Aa=l("a"),Ii=s("kho l\u01B0u tr\u1EEF SacreBLEU"),Vi=s(".) M\u1EB7t kh\xE1c, n\u1EBFu ch\xFAng ta th\u1EED v\u1EDBi hai lo\u1EA1i d\u1EF1 \u0111o\xE1n kh\xF4ng t\u1ED1t (nhi\u1EC1u l\u1EA7n l\u1EB7p l\u1EA1i ho\u1EB7c qu\xE1 ng\u1EAFn) th\u01B0\u1EDDng xu\u1EA5t hi\u1EC7n trong c\xE1c m\xF4 h\xECnh d\u1ECBch, ch\xFAng ta s\u1EBD nh\u1EADn \u0111\u01B0\u1EE3c \u0111i\u1EC3m BLEU kh\xE1 t\u1EC7:"),wc=p(),y(Sa.$$.fragment),xc=p(),y(Oa.$$.fragment),qc=p(),y(Na.$$.fragment),Tc=p(),y(La.$$.fragment),Cc=p(),Ph=l("p"),Ki=s("\u0110i\u1EC3m s\u1ED1 c\xF3 th\u1EC3 t\u0103ng t\u1EEB 0 \u0111\u1EBFn 100 v\xE0 c\xE0ng cao th\xEC c\xE0ng t\u1ED1t."),Pc=p(),Ke.c(),Dh=p(),zh=l("p"),Ri=s("B\xE2y gi\u1EDD \u0111i\u1EC1u n\xE0y \u0111\xE3 ho\xE0n t\u1EA5t, ch\xFAng ta \u0111\xE3 s\u1EB5n s\xE0ng tinh ch\u1EC9nh m\xF4 h\xECnh c\u1EE7a m\xECnh!"),Dc=p(),js=l("h3"),Fs=l("a"),jl=l("span"),y(Ha.$$.fragment),Gi=p(),El=l("span"),Xi=s("Tinh ch\u1EC9nh m\xF4 h\xECnh"),zc=p(),Ah=l("p"),Wi=s("B\u01B0\u1EDBc \u0111\u1EA7u ti\xEAn l\xE0 \u0111\u0103ng nh\u1EADp v\xE0o Hugging Face \u0111\u1EC3 b\u1EA1n c\xF3 th\u1EC3 t\u1EA3i k\u1EBFt qu\u1EA3 c\u1EE7a m\xECnh l\xEAn Model Hub. C\xF3 m\u1ED9t ch\u1EE9c n\u0103ng ti\u1EC7n l\u1EE3i \u0111\u1EC3 gi\xFAp b\u1EA1n l\xE0m \u0111i\u1EC1u n\xE0y trong notebook:"),Ac=p(),y(Ba.$$.fragment),Sc=p(),Sh=l("p"),Yi=s("Thao t\xE1c n\xE0y s\u1EBD hi\u1EC3n th\u1ECB m\u1ED9t ti\u1EC7n \xEDch m\xE0 b\u1EA1n c\xF3 th\u1EC3 nh\u1EADp th\xF4ng tin \u0111\u0103ng nh\u1EADp Hugging Face c\u1EE7a m\xECnh."),Oc=p(),Oh=l("p"),Zi=s("N\u1EBFu b\u1EA1n kh\xF4ng l\xE0m vi\u1EC7c trong notebook, ch\u1EC9 c\u1EA7n nh\u1EADp d\xF2ng sau v\xE0o terminal c\u1EE7a b\u1EA1n:"),Nc=p(),y(Ma.$$.fragment),Lc=p(),Ge.c(),Nh=p(),Xn&&Xn.c(),Lh=p(),Es=l("h2"),Us=l("a"),wl=l("span"),y(Fa.$$.fragment),Ji=p(),xl=l("span"),Qi=s("S\u1EED d\u1EE5ng m\xF4 h\xECnh tinh ch\u1EC9nh"),Hc=p(),Is=l("p"),no=s("Ch\xFAng t\xF4i \u0111\xE3 ch\u1EC9 cho b\u1EA1n c\xE1ch b\u1EA1n c\xF3 th\u1EC3 s\u1EED d\u1EE5ng m\xF4 h\xECnh m\xE0 ta \u0111\xE3 tinh ch\u1EC9nh tr\xEAn Model Hub b\u1EB1ng ti\u1EC7n \xEDch lu\u1EADn suy. \u0110\u1EC3 s\u1EED d\u1EE5ng n\xF3 c\u1EE5c b\u1ED9 trong m\u1ED9t "),ql=l("code"),to=s("pipeline"),eo=s(", ch\xFAng ta ch\u1EC9 c\u1EA7n ch\u1EC9 \u0111\u1ECBnh m\xE3 \u0111\u1ECBnh danh m\xF4 h\xECnh th\xEDch h\u1EE3p:"),Bc=p(),y(Ua.$$.fragment),Mc=p(),y(Ia.$$.fragment),Fc=p(),Hh=l("p"),so=s("\u0110\xFAng nh\u01B0 mong \u0111\u1EE3i, m\xF4 h\xECnh \u0111\u01B0\u1EE3c hu\u1EA5n luy\u1EC7n tr\u01B0\u1EDBc c\u1EE7a ch\xFAng ta \u0111\xE3 \u0111i\u1EC1u ch\u1EC9nh ki\u1EBFn th\u1EE9c c\u1EE7a n\xF3 cho ph\xF9 h\u1EE3p v\u1EDBi kho ng\u1EEF li\u1EC7u m\xE0 ch\xFAng ta \u0111\xE3 tinh ch\u1EC9nh v\xE0 thay v\xEC \u0111\u1EC3 nguy\xEAn t\u1EEB \u201Cthread\u201D trong ti\u1EBFng Anh, gi\u1EDD \u0111\xE2y n\xF3 \u0111\xE3 d\u1ECBch n\xF3 sang phi\xEAn b\u1EA3n ch\xEDnh th\u1EE9c ti\u1EBFng Ph\xE1p. \u0110\u1ED1i v\u1EDBi \u201Cplugin\u201D c\u0169ng v\u1EADy:"),Uc=p(),y(Va.$$.fragment),Ic=p(),y(Ka.$$.fragment),Vc=p(),Bh=l("p"),ao=s("M\u1ED9t v\xED d\u1EE5 tuy\u1EC7t v\u1EDDi kh\xE1c v\u1EC1 th\xEDch \u1EE9ng chuy\u1EC7n m\xF4n!"),Kc=p(),y(Vs.$$.fragment),this.h()},l(n){const i=gu('[data-svelte="svelte-1phssyn"]',document.head);o=c(i,"META",{name:!0,content:!0}),i.forEach(t),$=u(n),j(d.$$.fragment,n),x=u(n),z=c(n,"H1",{class:!0});var Ja=r(z);_=c(Ja,"A",{id:!0,class:!0,href:!0});var Mh=r(_);C=c(Mh,"SPAN",{});var Tl=r(C);j(D.$$.fragment,Tl),Tl.forEach(t),Mh.forEach(t),P=u(Ja),q=c(Ja,"SPAN",{});var Cl=r(q);O=a(Cl,"D\u1ECBch m\xE1y"),Cl.forEach(t),Ja.forEach(t),T=u(n),F.l(n),I=u(n),B=c(n,"P",{});var ws=r(B);tn=a(ws,"B\xE2y gi\u1EDD ch\xFAng ta h\xE3y \u0111i s\xE2u v\xE0o d\u1ECBch m\xE1y. \u0110\xE2y l\xE0 m\u1ED9t "),U=c(ws,"A",{href:!0});var Pl=r(U);H=a(Pl,"t\xE1c v\u1EE5 chu\u1ED7i sang chu\u1ED7i"),Pl.forEach(t),X=a(ws,", c\xF3 ngh\u0129a l\xE0 \u0111\xE2y l\xE0 m\u1ED9t v\u1EA5n \u0111\u1EC1 c\xF3 th\u1EC3 \u0111\u01B0\u1EE3c h\xECnh th\xE0nh nh\u01B0 \u0111i t\u1EEB m\u1ED9t chu\u1ED7i n\xE0y sang chu\u1ED7i kh\xE1c. Theo ngh\u0129a \u0111\xF3, v\u1EA5n \u0111\u1EC1 kh\xE1 gi\u1ED1ng v\u1EDBi "),Y=c(ws,"A",{href:!0});var Fh=r(Y);rn=a(Fh,"t\xF3m t\u1EAFt"),Fh.forEach(t),on=a(ws," v\xE0 b\u1EA1n c\xF3 th\u1EC3 \u0111i\u1EC1u ch\u1EC9nh nh\u1EEFng g\xEC ch\xFAng ta s\u1EBD th\u1EA5y \u1EDF \u0111\xE2y th\xE0nh c\xE1c v\u1EA5n \u0111\u1EC1 chu\u1ED7i sang chu\u1ED7i kh\xE1c nh\u01B0:"),ws.forEach(t),sn=u(n),Q=c(n,"UL",{});var Ks=r(Q);Z=c(Ks,"LI",{});var xs=r(Z);R=c(xs,"STRONG",{});var Uh=r(R);un=a(Uh,"Chuy\u1EC3n v\u0103n phong"),Uh.forEach(t),dn=a(xs,": T\u1EA1o m\xF4 h\xECnh "),en=c(xs,"EM",{});var Ih=r(en);nn=a(Ih,"d\u1ECBch"),Ih.forEach(t),fn=a(xs," v\u0103n b\u1EA3n \u0111\u01B0\u1EE3c vi\u1EBFt theo m\u1ED9t phong c\xE1ch nh\u1EA5t \u0111\u1ECBnh sang m\u1ED9t phong c\xE1ch kh\xE1c (v\xED d\u1EE5: t\u1EEB trang tr\u1ECDng sang th\xF4ng th\u01B0\u1EDDng ho\u1EB7c ti\u1EBFng Anh Shakespearean sang ti\u1EBFng Anh hi\u1EC7n \u0111\u1EA1i)"),xs.forEach(t),mn=u(Ks),ln=c(Ks,"LI",{});var Vh=r(ln);M=c(Vh,"STRONG",{});var bo=r(M);G=a(bo,"H\u1ECFi \u0111\xE1p chung"),bo.forEach(t),jn=a(Vh,": T\u1EA1o m\u1ED9t m\xF4 h\xECnh t\u1EA1o c\xE2u tr\u1EA3 l\u1EDDi cho c\xE1c c\xE2u h\u1ECFi, d\u1EF1a tr\xEAn ng\u1EEF c\u1EA3nh"),Vh.forEach(t),Ks.forEach(t),xn=u(n),j(pn.$$.fragment,n),W=u(n),an=c(n,"P",{});var Gc=r(an);kn=a(Gc,"N\u1EBFu b\u1EA1n c\xF3 m\u1ED9t kho v\u0103n b\u1EA3n \u0111\u1EE7 l\u1EDBn v\u1EDBi hai (ho\u1EB7c nhi\u1EC1u) ng\xF4n ng\u1EEF, b\u1EA1n c\xF3 th\u1EC3 hu\u1EA5n luy\u1EC7n m\u1ED9t m\xF4 h\xECnh d\u1ECBch m\u1EDBi t\u1EEB \u0111\u1EA7u gi\u1ED1ng nh\u01B0 ch\xFAng ta s\u1EBD l\xE0m trong ph\u1EA7n "),Tn=c(Gc,"A",{href:!0});var vo=r(Tn);On=a(vo,"l\u1EADp m\xF4 h\xECnh ng\xF4n ng\u1EEF nh\xE2n qu\u1EA3"),vo.forEach(t),_n=a(Gc,". Tuy nhi\xEAn, s\u1EBD nhanh h\u01A1n n\u1EBFu tinh ch\u1EC9nh m\xF4 h\xECnh d\u1ECBch hi\u1EC7n c\xF3, c\xF3 th\u1EC3 l\xE0 m\xF4 h\xECnh \u0111a ng\xF4n ng\u1EEF nh\u01B0 mT5 ho\u1EB7c mBART m\xE0 b\u1EA1n mu\u1ED1n tinh ch\u1EC9nh cho ph\xF9 h\u1EE3p v\u1EDBi m\u1ED9t c\u1EB7p ng\xF4n ng\u1EEF c\u1EE5 th\u1EC3 ho\u1EB7c th\u1EADm ch\xED l\xE0 m\u1ED9t m\xF4 h\xECnh chuy\xEAn d\u1EE5ng \u0111\u1EC3 d\u1ECBch t\u1EEB ng\xF4n ng\u1EEF n\xE0y sang ng\xF4n ng\u1EEF kh\xE1c m\xE0 b\u1EA1n mu\u1ED1n tinh ch\u1EC9nh \u0111\u1EC3 ph\xF9 h\u1EE3p v\u1EDBi kho d\u1EEF li\u1EC7u c\u1EE5 th\u1EC3 c\u1EE7a m\xECnh."),Gc.forEach(t),bn=u(n),J=c(n,"P",{});var Rs=r(J);Cn=a(Rs,"Trong ph\u1EA7n n\xE0y, ch\xFAng ta s\u1EBD tinh ch\u1EC9nh m\xF4 h\xECnh Marian \u0111\u01B0\u1EE3c hu\u1EA5n luy\u1EC7n tr\u01B0\u1EDBc \u0111\u1EC3 d\u1ECBch t\u1EEB ti\u1EBFng Anh sang ti\u1EBFng Ph\xE1p (v\xEC r\u1EA5t nhi\u1EC1u nh\xE2n vi\xEAn c\u1EE7a Hugging Face n\xF3i c\u1EA3 hai ng\xF4n ng\u1EEF \u0111\xF3) tr\xEAn "),wn=c(Rs,"A",{href:!0,rel:!0});var ko=r(wn);mt=a(ko,"t\u1EADp d\u1EEF li\u1EC7u KDE4"),ko.forEach(t),Nn=a(Rs,", l\xE0 t\u1EADp d\u1EEF li\u1EC7u c\xE1c t\u1EC7p \u0111\u01B0\u1EE3c b\u1EA3n \u0111\u1ECBa h\xF3a cho "),En=c(Rs,"A",{href:!0,rel:!0});var $o=r(En);Ln=a($o,"\u1EE9ng d\u1EE5ng KDE"),$o.forEach(t),gt=a(Rs,". M\xF4 h\xECnh ch\xFAng ta s\u1EBD s\u1EED d\u1EE5ng \u0111\xE3 \u0111\u01B0\u1EE3c hu\u1EA5n luy\u1EC7n tr\u01B0\u1EDBc tr\xEAn m\u1ED9t kho d\u1EEF li\u1EC7u l\u1EDBn g\u1ED3m c\xE1c v\u0103n b\u1EA3n ti\u1EBFng Ph\xE1p v\xE0 ti\u1EBFng Anh \u0111\u01B0\u1EE3c l\u1EA5y t\u1EEB "),$n=c(Rs,"A",{href:!0,rel:!0});var yo=r($n);Hn=a(yo,"T\u1EADp d\u1EEF li\u1EC7u Opus"),yo.forEach(t),at=a(Rs,", th\u1EF1c s\u1EF1 ch\u1EE9a t\u1EADp d\u1EEF li\u1EC7u KDE4. Nh\u01B0ng ngay c\u1EA3 khi m\xF4 h\xECnh hu\u1EA5n luy\u1EC7n tr\u01B0\u1EDBc m\xE0 ch\xFAng ta s\u1EED d\u1EE5ng \u0111\xE3 nh\xECn th\u1EA5y d\u1EEF li\u1EC7u \u0111\xF3 trong qu\xE1 tr\xECnh hu\u1EA5n luy\u1EC7n tr\u01B0\u1EDBc c\u1EE7a n\xF3, ch\xFAng ta s\u1EBD th\u1EA5y r\u1EB1ng ta c\xF3 th\u1EC3 nh\u1EADn \u0111\u01B0\u1EE3c phi\xEAn b\u1EA3n t\u1ED1t h\u01A1n c\u1EE7a n\xF3 sau khi tinh ch\u1EC9nh."),Rs.forEach(t),k=u(n),K=c(n,"P",{});var jo=r(K);Bn=a(jo,"Sau khi ho\xE0n th\xE0nh, ch\xFAng ta s\u1EBD c\xF3 m\u1ED9t m\xF4 h\xECnh c\xF3 th\u1EC3 \u0111\u01B0a ra c\xE1c d\u1EF1 \u0111o\xE1n nh\u01B0 sau:"),jo.forEach(t),zn=u(n),gn=c(n,"IFRAME",{src:!0,frameborder:!0,height:!0,title:!0,class:!0,allow:!0,sandbox:!0}),r(gn).forEach(t),Tt=u(n),cn=c(n,"A",{class:!0,href:!0});var Xc=r(cn);Pn=c(Xc,"IMG",{class:!0,src:!0,alt:!0}),Ct=u(Xc),qn=c(Xc,"IMG",{class:!0,src:!0,alt:!0}),Xc.forEach(t),rt=u(n),hn=c(n,"P",{});var Wc=r(hn);Pt=a(Wc,"Nh\u01B0 trong c\xE1c ph\u1EA7n tr\u01B0\u1EDBc, b\u1EA1n c\xF3 th\u1EC3 t\xECm th\u1EA5y m\xF4 h\xECnh th\u1EF1c t\u1EBF m\xE0 ch\xFAng ta s\u1EBD hu\u1EA5n luy\u1EC7n v\xE0 t\u1EA3i l\xEAn Hub b\u1EB1ng c\xE1ch s\u1EED d\u1EE5ng \u0111o\u1EA1n m\xE3 b\xEAn d\u01B0\u1EDBi v\xE0 ki\u1EC3m tra k\u1EF9 c\xE1c d\u1EF1 \u0111o\xE1n c\u1EE7a n\xF3 "),Dn=c(Wc,"A",{href:!0,rel:!0});var Eo=r(Dn);ue=a(Eo,"t\u1EA1i \u0111\xE2y"),Eo.forEach(t),Mt=a(Wc,"."),Wc.forEach(t),Ft=u(n),Wn=c(n,"H2",{class:!0});var Yc=r(Wn);Mn=c(Yc,"A",{id:!0,class:!0,href:!0});var wo=r(Mn);Dt=c(wo,"SPAN",{});var xo=r(Dt);j(dt.$$.fragment,xo),xo.forEach(t),wo.forEach(t),zt=u(Yc),At=c(Yc,"SPAN",{});var qo=r(At);Yn=a(qo,"Chu\u1EA9n b\u1ECB d\u1EEF li\u1EC7u"),qo.forEach(t),Yc.forEach(t),ne=u(n),yn=c(n,"P",{});var Gs=r(yn);St=a(Gs,"\u0110\u1EC3 tinh ch\u1EC9nh ho\u1EB7c hu\u1EA5n luy\u1EC7n m\u1ED9t m\xF4 h\xECnh d\u1ECBch t\u1EEB \u0111\u1EA7u, ch\xFAng ta s\u1EBD c\u1EA7n m\u1ED9t t\u1EADp d\u1EEF li\u1EC7u ph\xF9 h\u1EE3p v\u1EDBi t\xE1c v\u1EE5. Nh\u01B0 \u0111\xE3 \u0111\u1EC1 c\u1EADp tr\u01B0\u1EDBc \u0111\xE2y, ch\xFAng ta s\u1EBD s\u1EED d\u1EE5ng "),Zn=c(Gs,"A",{href:!0,rel:!0});var To=r(Zn);me=a(To,"t\u1EADp d\u1EEF li\u1EC7u KDE4"),To.forEach(t),ft=a(Gs," trong ph\u1EA7n n\xE0y, nh\u01B0ng b\u1EA1n c\xF3 th\u1EC3 \u0111i\u1EC1u ch\u1EC9nh \u0111o\u1EA1n m\xE3 \u0111\u1EC3 s\u1EED d\u1EE5ng d\u1EEF li\u1EC7u c\u1EE7a ri\xEAng m\xECnh kh\xE1 d\u1EC5 d\xE0ng, mi\u1EC5n l\xE0 b\u1EA1n c\xF3 c\xE1c c\u1EB7p c\u1EE7a c\xE1c c\xE2u b\u1EB1ng hai ng\xF4n ng\u1EEF m\xE0 b\u1EA1n mu\u1ED1n d\u1ECBch t\u1EEB v\xE0 t\u1EDBi. Tham kh\u1EA3o l\u1EA1i "),Fn=c(Gs,"A",{href:!0});var Co=r(Fn);_t=a(Co,"Ch\u01B0\u01A1ng 5"),Co.forEach(t),Un=a(Gs," n\u1EBFu b\u1EA1n c\u1EA7n l\u1EDDi nh\u1EAFc v\u1EC1 c\xE1ch t\u1EA3i d\u1EEF li\u1EC7u t\xF9y ch\u1EC9nh c\u1EE7a m\xECnh trong "),bt=c(Gs,"CODE",{});var Po=r(bt);te=a(Po,"Dataset"),Po.forEach(t),ge=a(Gs,"."),Gs.forEach(t),In=u(n),Vn=c(n,"H3",{class:!0});var Zc=r(Vn);Jn=c(Zc,"A",{id:!0,class:!0,href:!0});var Do=r(Jn);ee=c(Do,"SPAN",{});var zo=r(ee);j(vt.$$.fragment,zo),zo.forEach(t),Do.forEach(t),Kn=u(Zc),Qn=c(Zc,"SPAN",{});var Ao=r(Qn);se=a(Ao,"B\u1ED9 d\u1EEF li\u1EC7u KDE4"),Ao.forEach(t),Zc.forEach(t),it=u(n),An=c(n,"P",{});var Jc=r(An);Ut=a(Jc,"Nh\u01B0 th\u01B0\u1EDDng l\u1EC7, ch\xFAng ta t\u1EA3i xu\u1ED1ng t\u1EADp d\u1EEF li\u1EC7u c\u1EE7a m\xECnh b\u1EB1ng c\xE1ch s\u1EED d\u1EE5ng h\xE0m "),kt=c(Jc,"CODE",{});var So=r(kt);de=a(So,"load_dataset()"),So.forEach(t),Rn=a(Jc,":"),Jc.forEach(t),$t=u(n),j(nt.$$.fragment,n),Ot=u(n),yt=c(n,"P",{});var Qc=r(yt);It=a(Qc,"N\u1EBFu b\u1EA1n mu\u1ED1n l\xE0m vi\u1EC7c v\u1EDBi m\u1ED9t c\u1EB7p ng\xF4n ng\u1EEF kh\xE1c, b\u1EA1n c\xF3 th\u1EC3 ch\u1EC9 \u0111\u1ECBnh ch\xFAng b\u1EB1ng \u0111o\u1EA1n m\xE3 c\u1EE7a ch\xFAng. C\xF3 t\u1ED5ng s\u1ED1 92 ng\xF4n ng\u1EEF c\xF3 s\u1EB5n cho b\u1ED9 d\u1EEF li\u1EC7u n\xE0y; b\u1EA1n c\xF3 th\u1EC3 th\u1EA5y t\u1EA5t c\u1EA3 ch\xFAng b\u1EB1ng c\xE1ch m\u1EDF r\u1ED9ng c\xE1c th\u1EBB ng\xF4n ng\u1EEF tr\xEAn "),tt=c(Qc,"A",{href:!0,rel:!0});var Oo=r(tt);Ee=a(Oo,"th\u1EBB d\u1EEF li\u1EC7u"),Oo.forEach(t),ae=a(Qc," c\u1EE7a n\xF3."),Qc.forEach(t),g=u(n),N=c(n,"IMG",{src:!0,alt:!0,width:!0}),we=u(n),Et=c(n,"P",{});var No=r(Et);Xe=a(No,"H\xE3y xem t\u1EADp d\u1EEF li\u1EC7u:"),No.forEach(t),ot=u(n),j(pt.$$.fragment,n),he=u(n),j(Vt.$$.fragment,n),Kt=u(n),vn=c(n,"P",{});var Xs=r(vn);fe=a(Xs,"Ch\xFAng ta c\xF3 210,173 c\u1EB7p c\xE2u, nh\u01B0ng ch\u1EC9 trong m\u1ED9t l\u1EA7n t\xE1ch, v\xEC v\u1EADy ch\xFAng ta s\u1EBD c\u1EA7n t\u1EA1o b\u1ED9 ki\u1EC3m \u0111\u1ECBnh c\u1EE7a ri\xEAng m\xECnh. Nh\u01B0 ch\xFAng ta \u0111\xE3 th\u1EA5y trong "),Nt=c(Xs,"A",{href:!0});var Lo=r(Nt);Sn=a(Lo,"Ch\u01B0\u01A1ng 5"),Lo.forEach(t),We=a(Xs,", "),Rt=c(Xs,"CODE",{});var Ho=r(Rt);Ye=a(Ho,"Dataset"),Ho.forEach(t),Ze=a(Xs," c\xF3 ph\u01B0\u01A1ng th\u1EE9c "),le=c(Xs,"CODE",{});var Bo=r(le);Gn=a(Bo,"train_test_split()"),Bo.forEach(t),_e=a(Xs," c\xF3 th\u1EC3 gi\xFAp ch\xFAng ta. Ch\xFAng ta s\u1EBD cung c\u1EA5p m\u1ED9t h\u1EA1t gi\u1ED1ng (seed) cho kh\u1EA3 n\u0103ng t\xE1i t\u1EA1o:"),Xs.forEach(t),Gt=u(n),j(Xt.$$.fragment,n),xe=u(n),j(wt.$$.fragment,n),qe=u(n),ut=c(n,"P",{});var Kh=r(ut);be=a(Kh,"B\u1EA1n c\xF3 th\u1EC3 \u0111\u1ED5i "),xt=c(Kh,"CODE",{});var Mo=r(xt);Je=a(Mo,'"test"'),Mo.forEach(t),Te=a(Kh," th\xE0nh "),qt=c(Kh,"CODE",{});var Fo=r(qt);Ce=a(Fo,'"validation"'),Fo.forEach(t),Wt=a(Kh," nh\u01B0 sau:"),Kh.forEach(t),_s=u(n),j(et.$$.fragment,n),qs=u(n),ve=c(n,"P",{});var Uo=r(ve);Zs=a(Uo,"B\xE2y gi\u1EDD ch\xFAng ta h\xE3y xem x\xE9t m\u1ED9t ph\u1EA7n t\u1EED c\u1EE7a t\u1EADp d\u1EEF li\u1EC7u:"),Uo.forEach(t),Ts=u(n),j(Lt.$$.fragment,n),Qe=u(n),j(Pe.$$.fragment,n),Cs=u(n),De=c(n,"P",{});var Io=r(De);m=a(Io,"Ch\xFAng ta nh\u1EADn \u0111\u01B0\u1EE3c m\u1ED9t t\u1EEB \u0111i\u1EC3n c\xF3 hai c\xE2u b\u1EB1ng c\u1EB7p ng\xF4n ng\u1EEF m\xE0 ta y\xEAu c\u1EA7u. M\u1ED9t \u0111i\u1EC3m \u0111\u1EB7c bi\u1EC7t c\u1EE7a b\u1ED9 d\u1EEF li\u1EC7u \u0111\u1EA7y \u0111\u1EE7 c\xE1c thu\u1EADt ng\u1EEF khoa h\u1ECDc m\xE1y t\xEDnh k\u1EF9 thu\u1EADt n\xE0y l\xE0 ch\xFAng \u0111\u1EC1u \u0111\u01B0\u1EE3c d\u1ECBch ho\xE0n to\xE0n b\u1EB1ng ti\u1EBFng Ph\xE1p. Tuy nhi\xEAn, c\xE1c k\u1EF9 s\u01B0 Ph\xE1p th\u01B0\u1EDDng l\u01B0\u1EDDi bi\u1EBFng v\xE0 \u0111\u1EC3 l\u1EA1i h\u1EA7u h\u1EBFt c\xE1c t\u1EEB chuy\xEAn ng\xE0nh khoa h\u1ECDc m\xE1y t\xEDnh b\u1EB1ng ti\u1EBFng Anh khi h\u1ECD n\xF3i chuy\u1EC7n. V\xED d\u1EE5, \u1EDF \u0111\xE2y, t\u1EEB \u201Cthreads\u201D c\xF3 th\u1EC3 xu\u1EA5t hi\u1EC7n trong m\u1ED9t c\xE2u ti\u1EBFng Ph\xE1p, \u0111\u1EB7c bi\u1EC7t l\xE0 trong m\u1ED9t cu\u1ED9c tr\xF2 chuy\u1EC7n k\u1EF9 thu\u1EADt; nh\u01B0ng trong t\u1EADp d\u1EEF li\u1EC7u n\xE0y, n\xF3 \u0111\xE3 \u0111\u01B0\u1EE3c d\u1ECBch th\xE0nh \u0111\xFAng h\u01A1n l\xE0 \u201Cfils de discussion\u201D. M\xF4 h\xECnh hu\u1EA5n luy\u1EC7n tr\u01B0\u1EDBc m\xE0 ch\xFAng ta s\u1EED d\u1EE5ng, \u0111\xE3 \u0111\u01B0\u1EE3c hu\u1EA5n luy\u1EC7n tr\u01B0\u1EDBc tr\xEAn m\u1ED9t kho ng\u1EEF li\u1EC7u l\u1EDBn h\u01A1n c\u1EE7a c\xE1c c\xE2u ti\u1EBFng Ph\xE1p v\xE0 ti\u1EBFng Anh, c\xF3 t\xF9y ch\u1ECDn d\u1EC5 d\xE0ng h\u01A1n l\xE0 \u0111\u1EC3 nguy\xEAn t\u1EEB nh\u01B0 sau:"),Io.forEach(t),L=u(n),j(ns.$$.fragment,n),Js=u(n),j(ts.$$.fragment,n),ze=u(n),bs=c(n,"P",{});var Vo=r(bs);th=a(Vo,`M\u1ED9t v\xED d\u1EE5 kh\xE1c v\u1EC1 h\xE0nh vi n\xE0y c\xF3 th\u1EC3 \u0111\u01B0\u1EE3c nh\xECn th\u1EA5y v\u1EDBi t\u1EEB \u201Cplugin\u201D, \u0111\xE2y kh\xF4ng ph\u1EA3i l\xE0 m\u1ED9t t\u1EEB ch\xEDnh th\u1EE9c trong ti\u1EBFng Ph\xE1p nh\u01B0ng h\u1EA7u h\u1EBFt ng\u01B0\u1EDDi b\u1EA3n ng\u1EEF s\u1EBD hi\u1EC3u v\xE0 kh\xF4ng b\u1EADn t\xE2m \u0111\u1EBFn vi\u1EC7c d\u1ECBch.
Trong t\u1EADp d\u1EEF li\u1EC7u KDE4, t\u1EEB n\xE0y \u0111\xE3 \u0111\u01B0\u1EE3c d\u1ECBch b\u1EB1ng ti\u1EBFng Ph\xE1p m\u1ED9t c\xE1ch ch\xEDnh th\u1ED1ng h\u01A1n th\xE0nh \u201Cmodule d\u2019extension\u201D:`),Vo.forEach(t),vs=u(n),j(es.$$.fragment,n),Qs=u(n),j(ss.$$.fragment,n),Ae=u(n),ks=c(n,"P",{});var Ko=r(ks);eh=a(Ko,"Tuy nhi\xEAn, m\xF4 h\xECnh \u0111\u01B0\u1EE3c hu\u1EA5n luy\u1EC7n tr\u01B0\u1EDBc c\u1EE7a ch\xFAng ta g\u1EAFn v\u1EDBi t\u1EEB ti\u1EBFng Anh nh\u1ECF g\u1ECDn v\xE0 quen thu\u1ED9c:"),Ko.forEach(t),na=u(n),j(as.$$.fragment,n),Se=u(n),j(hs.$$.fragment,n),ta=u(n),Ht=c(n,"P",{});var Ro=r(Ht);sh=a(Ro,"S\u1EBD r\u1EA5t th\xFA v\u1ECB khi xem li\u1EC7u m\xF4 h\xECnh tinh ch\u1EC9nh c\u1EE7a m\xECnh c\xF3 ti\u1EBFp thu nh\u1EEFng \u0111\u1EB7c \u0111i\u1EC3m \u0111\xF3 c\u1EE7a t\u1EADp d\u1EEF li\u1EC7u hay kh\xF4ng (c\u1EA3nh b\xE1o spoiler: n\xF3 s\u1EBD x\u1EA3y ra)."),Ro.forEach(t),ea=u(n),j(ls.$$.fragment,n),ce=u(n),j(Oe.$$.fragment,n),sa=u(n),ke=c(n,"H3",{class:!0});var nr=r(ke);Ne=c(nr,"A",{id:!0,class:!0,href:!0});var Go=r(Ne);$e=c(Go,"SPAN",{});var Xo=r($e);j(cs.$$.fragment,Xo),Xo.forEach(t),Go.forEach(t),ah=u(nr),rs=c(nr,"SPAN",{});var Wo=r(rs);hh=a(Wo,"Chu\u1EA9n b\u1ECB d\u1EEF li\u1EC7u"),Wo.forEach(t),nr.forEach(t),aa=u(n),j(is.$$.fragment,n),Le=u(n),re=c(n,"P",{});var Rh=r(re);lh=a(Rh,"B\xE2y gi\u1EDD b\u1EA1n n\xEAn bi\u1EBFt \u0111i\u1EC1u n\xE0y: t\u1EA5t c\u1EA3 c\xE1c v\u0103n b\u1EA3n c\u1EA7n \u0111\u01B0\u1EE3c chuy\u1EC3n \u0111\u1ED5i th\xE0nh t\u1EADp h\u1EE3p c\xE1c token ID \u0111\u1EC3 m\xF4 h\xECnh c\xF3 th\u1EC3 hi\u1EC3u \u0111\u01B0\u1EE3c ch\xFAng. \u0110\u1ED1i v\u1EDBi t\xE1c v\u1EE5 n\xE0y, ch\xFAng ta s\u1EBD c\u1EA7n tokenize c\u1EA3 \u0111\u1EA7u v\xE0o v\xE0 nh\xE3n. T\xE1c v\u1EE5 \u0111\u1EA7u ti\xEAn c\u1EE7a ch\xFAng ta l\xE0 t\u1EA1o \u0111\u1ED1i t\u01B0\u1EE3ng "),ye=c(Rh,"CODE",{});var Yo=r(ye);ch=a(Yo,"tokenizer"),Yo.forEach(t),rh=a(Rh,". Nh\u01B0 \u0111\xE3 l\u01B0u \xFD tr\u01B0\u1EDBc \u0111\xF3, ch\xFAng ta s\u1EBD s\u1EED d\u1EE5ng m\xF4 h\xECnh hu\u1EA5n luy\u1EC7n tr\u01B0\u1EDBc t\u1EEB ti\u1EBFng Anh sang ti\u1EBFng Ph\xE1p c\u1EE7a Marian. N\u1EBFu b\u1EA1n \u0111ang th\u1EED \u0111o\u1EA1n m\xE3 n\xE0y v\u1EDBi m\u1ED9t c\u1EB7p ng\xF4n ng\u1EEF kh\xE1c, h\xE3y \u0111\u1EA3m b\u1EA3o \u0111i\u1EC1u ch\u1EC9nh checkpoint c\u1EE7a m\xF4 h\xECnh. T\u1ED5 ch\u1EE9c "),Yt=c(Rh,"A",{href:!0,rel:!0});var Zo=r(Yt);ih=a(Zo,"Helsinki-NLP"),Zo.forEach(t),oh=a(Rh," cung c\u1EA5p h\u01A1n m\u1ED9t ngh\xECn m\xF4 h\xECnh b\u1EB1ng nhi\u1EC1u ng\xF4n ng\u1EEF."),Rh.forEach(t),ie=u(n),j(os.$$.fragment,n),ha=u(n),oe=c(n,"P",{});var Gh=r(oe);ps=a(Gh,"You can also replace the "),Ps=c(Gh,"CODE",{});var Jo=r(Ps);ph=a(Jo,"model_checkpoint"),Jo.forEach(t),uh=a(Gh," with any other model you prefer from the "),la=c(Gh,"A",{href:!0,rel:!0});var Qo=r(la);mr=a(Qo,"Hub"),Qo.forEach(t),gr=a(Gh,", or a local folder where you\u2019ve saved a pretrained model and a tokenizer."),Gh.forEach(t),Dl=u(n),j(Ds.$$.fragment,n),zl=u(n),zs=c(n,"P",{});var tr=r(zs);dr=a(tr,"Vi\u1EC7c chu\u1EA9n b\u1ECB d\u1EEF li\u1EC7u c\u1EE7a ch\xFAng ta kh\xE1 \u0111\u01A1n gi\u1EA3n. Ch\u1EC9 c\xF3 m\u1ED9t \u0111i\u1EC1u c\u1EA7n nh\u1EDB: b\u1EA1n x\u1EED l\xFD c\xE1c \u0111\u1EA7u v\xE0o nh\u01B0 b\xECnh th\u01B0\u1EDDng, nh\u01B0ng \u0111\u1ED1i v\u1EDBi c\xE1c nh\xE3n, b\u1EA1n c\u1EA7n ph\u1EA3i b\u1ECDc tokenizer b\xEAn trong tr\xECnh qu\u1EA3n l\xFD ng\u1EEF c\u1EA3nh "),Zh=c(tr,"CODE",{});var np=r(Zh);fr=a(np,"as_target_tokenizer()"),np.forEach(t),_r=a(tr,"."),tr.forEach(t),Al=u(n),As=c(n,"P",{});var er=r(As);br=a(er,"Tr\xECnh qu\u1EA3n l\xFD ng\u1EEF c\u1EA3nh trong Python \u0111\u01B0\u1EE3c gi\u1EDBi thi\u1EC7u v\u1EDBi c\xE2u l\u1EC7nh "),Jh=c(er,"CODE",{});var tp=r(Jh);vr=a(tp,"with"),tp.forEach(t),kr=a(er," v\xE0 r\u1EA5t h\u1EEFu \xEDch khi b\u1EA1n c\xF3 hai ho\u1EA1t \u0111\u1ED9ng li\xEAn quan \u0111\u1EC3 th\u1EF1c thi nh\u01B0 m\u1ED9t c\u1EB7p. V\xED d\u1EE5 ph\u1ED5 bi\u1EBFn nh\u1EA5t v\u1EC1 \u0111i\u1EC1u n\xE0y l\xE0 khi b\u1EA1n vi\u1EBFt ho\u1EB7c \u0111\u1ECDc m\u1ED9t t\u1EC7p, th\u01B0\u1EDDng \u0111\u01B0\u1EE3c th\u1EF1c hi\u1EC7n b\xEAn trong m\u1ED9t l\u1EC7nh nh\u01B0:"),er.forEach(t),Sl=u(n),j(ca.$$.fragment,n),Ol=u(n),us=c(n,"P",{});var Xh=r(us);$r=a(Xh,"\u1EDE \u0111\xE2y, hai ho\u1EA1t \u0111\u1ED9ng li\xEAn quan \u0111\u01B0\u1EE3c th\u1EF1c hi\u1EC7n nh\u01B0 m\u1ED9t c\u1EB7p l\xE0 c\xE1c h\xE0nh \u0111\u1ED9ng m\u1EDF v\xE0 \u0111\xF3ng t\u1EC7p. \u0110\u1ED1i t\u01B0\u1EE3ng t\u01B0\u01A1ng \u1EE9ng v\u1EDBi t\u1EC7p \u0111\xE3 m\u1EDF "),Qh=c(Xh,"CODE",{});var ep=r(Qh);yr=a(ep,"f"),ep.forEach(t),jr=a(Xh," ch\u1EC9 t\u1ED3n t\u1EA1i b\xEAn trong kh\u1ED1i \u0111\u01B0\u1EE3c th\u1EE5t l\u1EC1 d\u01B0\u1EDBi d\u1EA5u "),nl=c(Xh,"CODE",{});var sp=r(nl);Er=a(sp,"with"),sp.forEach(t),wr=a(Xh,"; s\u1EF1 m\u1EDF \u0111\u1EA7u x\u1EA3y ra tr\u01B0\u1EDBc kh\u1ED1i \u0111\xF3 v\xE0 \u0111\xF3ng \u1EDF cu\u1ED1i kh\u1ED1i."),Xh.forEach(t),Nl=u(n),Ss=c(n,"P",{});var sr=r(Ss);xr=a(sr,"Trong tr\u01B0\u1EDDng h\u1EE3p n\xE0y, tr\xECnh qu\u1EA3n l\xFD ng\u1EEF c\u1EA3nh "),tl=c(sr,"CODE",{});var ap=r(tl);qr=a(ap,"as_target_tokenizer()"),ap.forEach(t),Tr=a(sr," s\u1EBD \u0111\u1EB7t tokenizer \u1EDF ng\xF4n ng\u1EEF \u0111\u1EA7u ra (\u1EDF \u0111\xE2y, ti\u1EBFng Ph\xE1p) tr\u01B0\u1EDBc khi kh\u1ED1i \u0111\u01B0\u1EE3c th\u1EE5t l\u1EC1 \u0111\u01B0\u1EE3c th\u1EF1c thi, sau \u0111\xF3 \u0111\u1EB7t n\xF3 tr\u1EDF l\u1EA1i b\u1EB1ng ng\xF4n ng\u1EEF \u0111\u1EA7u v\xE0o (\u1EDF \u0111\xE2y, ti\u1EBFng Anh)."),sr.forEach(t),Ll=u(n),mh=c(n,"P",{});var hp=r(mh);Cr=a(hp,"V\xEC v\u1EADy, vi\u1EC7c x\u1EED l\xFD tr\u01B0\u1EDBc m\u1ED9t m\u1EABu tr\xF4ng nh\u01B0 th\u1EBF n\xE0y:"),hp.forEach(t),Hl=u(n),j(ra.$$.fragment,n),Bl=u(n),gh=c(n,"P",{});var lp=r(gh);Pr=a(lp,"N\u1EBFu ch\xFAng ta qu\xEAn tokenize c\xE1c nh\xE3n b\xEAn trong tr\xECnh qu\u1EA3n l\xFD ng\u1EEF c\u1EA3nh, ch\xFAng s\u1EBD \u0111\u01B0\u1EE3c tokenize b\u1EDFi tr\xECnh tokenize \u0111\u1EA7u v\xE0o, trong tr\u01B0\u1EDDng h\u1EE3p m\xF4 h\xECnh Marian s\u1EBD kh\xF4ng ho\u1EA1t \u0111\u1ED9ng t\u1ED1t ch\xFAt n\xE0o:"),lp.forEach(t),Ml=u(n),j(ia.$$.fragment,n),Fl=u(n),j(oa.$$.fragment,n),Ul=u(n),dh=c(n,"P",{});var cp=r(dh);Dr=a(cp,"Nh\u01B0 ch\xFAng ta c\xF3 th\u1EC3 th\u1EA5y, vi\u1EC7c s\u1EED d\u1EE5ng tr\xECnh tokenize ti\u1EBFng Anh \u0111\u1EC3 x\u1EED l\xFD tr\u01B0\u1EDBc m\u1ED9t c\xE2u ti\u1EBFng Ph\xE1p d\u1EABn \u0111\u1EBFn nhi\u1EC1u token h\u01A1n, v\xEC tr\xECnh tokenize kh\xF4ng bi\u1EBFt b\u1EA5t k\u1EF3 t\u1EEB ti\u1EBFng Ph\xE1p n\xE0o (ngo\u1EA1i tr\u1EEB nh\u1EEFng t\u1EEB c\u0169ng xu\u1EA5t hi\u1EC7n trong ti\u1EBFng Anh, nh\u01B0 \u201Cdiscussion\u201D)."),cp.forEach(t),Il=u(n),je=c(n,"P",{});var Ws=r(je);zr=a(Ws,"C\u1EA3 "),el=c(Ws,"CODE",{});var rp=r(el);Ar=a(rp,"inputs"),rp.forEach(t),Sr=a(Ws," v\xE0 "),sl=c(Ws,"CODE",{});var ip=r(sl);Or=a(ip,"targets"),ip.forEach(t),Nr=a(Ws," \u0111\u1EC1u l\xE0 t\u1EEB \u0111i\u1EC3n v\u1EDBi c\xE1c kh\xF3a th\xF4ng th\u01B0\u1EDDng c\u1EE7a ch\xFAng ta (ID \u0111\u1EA7u v\xE0o, attention mask, v.v.), v\xEC v\u1EADy b\u01B0\u1EDBc cu\u1ED1i c\xF9ng l\xE0 \u0111\u1EB7t "),al=c(Ws,"CODE",{});var op=r(al);Lr=a(op,'"labels"'),op.forEach(t),Hr=a(Ws," b\xEAn trong c\xE1c \u0111\u1EA7u v\xE0o. Ch\xFAng ta th\u1EF1c hi\u1EC7n \u0111i\u1EC1u n\xE0y trong ch\u1EE9c n\u0103ng ti\u1EC1n x\u1EED l\xFD m\xE0 ta s\u1EBD \xE1p d\u1EE5ng tr\xEAn c\xE1c t\u1EADp d\u1EEF li\u1EC7u:"),Ws.forEach(t),Vl=u(n),j(pa.$$.fragment,n),Kl=u(n),fh=c(n,"P",{});var pp=r(fh);Br=a(pp,"Note that we set similar maximum lengths for our inputs and outputs. Since the texts we\u2019re dealing with seem pretty short, we use 128."),pp.forEach(t),Rl=u(n),j(Os.$$.fragment,n),Gl=u(n),j(Ns.$$.fragment,n),Xl=u(n),_h=c(n,"P",{});var up=r(_h);Mr=a(up,"B\xE2y gi\u1EDD ch\xFAng ta c\xF3 th\u1EC3 \xE1p d\u1EE5ng ti\u1EC1n x\u1EED l\xFD \u0111\xF3 trong m\u1ED9t l\u1EA7n tr\xEAn t\u1EA5t c\u1EA3 c\xE1c ph\u1EA7n c\u1EE7a t\u1EADp d\u1EEF li\u1EC7u c\u1EE7a m\xECnh:"),up.forEach(t),Wl=u(n),j(ua.$$.fragment,n),Yl=u(n),bh=c(n,"P",{});var mp=r(bh);Fr=a(mp,"B\xE2y gi\u1EDD d\u1EEF li\u1EC7u \u0111\xE3 \u0111\u01B0\u1EE3c ti\u1EC1n x\u1EED l\xFD, ch\xFAng ta \u0111\xE3 s\u1EB5n s\xE0ng \u0111\u1EC3 tinh ch\u1EC9nh m\xF4 h\xECnh ti\u1EC1n x\u1EED l\xFD c\u1EE7a m\xECnh!"),mp.forEach(t),Zl=u(n),Be.l(n),vh=u(n),kh=c(n,"P",{});var gp=r(kh);Ur=a(gp,"L\u01B0u \xFD r\u1EB1ng l\u1EA7n n\xE0y ch\xFAng ta \u0111ang s\u1EED d\u1EE5ng m\u1ED9t m\xF4 h\xECnh \u0111\xE3 \u0111\u01B0\u1EE3c hu\u1EA5n luy\u1EC7n v\u1EC1 t\xE1c v\u1EE5 d\u1ECBch v\xE0 th\u1EF1c s\u1EF1 c\xF3 th\u1EC3 \u0111\u01B0\u1EE3c s\u1EED d\u1EE5ng, v\xEC v\u1EADy kh\xF4ng c\xF3 c\u1EA3nh b\xE1o n\xE0o v\u1EC1 vi\u1EC7c thi\u1EBFu c\xE1c tr\u1ECDng s\u1ED1 ho\u1EB7c nh\u1EEFng tr\u1ECDng s\u1ED1 m\u1EDBi \u0111\u01B0\u1EE3c kh\u1EDFi t\u1EA1o."),gp.forEach(t),Jl=u(n),$s=c(n,"H3",{class:!0});var ar=r($s);Ls=c(ar,"A",{id:!0,class:!0,href:!0});var dp=r(Ls);hl=c(dp,"SPAN",{});var fp=r(hl);j(ma.$$.fragment,fp),fp.forEach(t),dp.forEach(t),Ir=u(ar),ll=c(ar,"SPAN",{});var _p=r(ll);Vr=a(_p,"\u0110\u1ED1i chi\u1EBFu d\u1EEF li\u1EC7u"),_p.forEach(t),ar.forEach(t),Ql=u(n),ms=c(n,"P",{});var Wh=r(ms);Kr=a(Wh,"Ch\xFAng ta s\u1EBD c\u1EA7n m\u1ED9t c\xF4ng c\u1EE5 \u0111\u1ED1i chi\u1EBFu d\u1EEF li\u1EC7u \u0111\u1EC3 x\u1EED l\xFD ph\u1EA7n \u0111\u1EC7m cho ph\xE2n ph\u1ED1i \u0111\u1ED9ng. Ch\xFAng ta kh\xF4ng th\u1EC3 ch\u1EC9 s\u1EED d\u1EE5ng m\u1ED9t "),cl=c(Wh,"CODE",{});var bp=r(cl);Rr=a(bp,"DataCollatorWithPadding"),bp.forEach(t),Gr=a(Wh," nh\u01B0 [Ch\u01B0\u01A1ng 3](/course/ chapter3) trong tr\u01B0\u1EDDng h\u1EE3p n\xE0y, b\u1EDFi v\xEC \u0111i\u1EC1u \u0111\xF3 ch\u1EC9 \u0111\u1EC7m c\xE1c \u0111\u1EA7u v\xE0o (ID \u0111\u1EA7u v\xE0o, attention mask, v\xE0 lo\u1EA1i token ID). C\xE1c nh\xE3n c\u1EE7a ch\xFAng ta c\u0169ng ph\u1EA3i \u0111\u01B0\u1EE3c \u0111\u1EC7m theo chi\u1EC1u d\xE0i t\u1ED1i \u0111a c\xF3 trong nh\xE3n. V\xE0, nh\u01B0 \u0111\xE3 \u0111\u1EC1 c\u1EADp tr\u01B0\u1EDBc \u0111\xE2y, gi\xE1 tr\u1ECB \u0111\u1EC7m \u0111\u01B0\u1EE3c s\u1EED d\u1EE5ng \u0111\u1EC3 \u0111\u1EC7m c\xE1c nh\xE3n ph\u1EA3i l\xE0 "),rl=c(Wh,"CODE",{});var vp=r(rl);Xr=a(vp,"-100"),vp.forEach(t),Wr=a(Wh," ch\u1EE9 kh\xF4ng ph\u1EA3i token \u0111\u1EC7m c\u1EE7a tr\xECnh tokenize, \u0111\u1EC3 \u0111\u1EA3m b\u1EA3o c\xE1c gi\xE1 tr\u1ECB \u0111\u1EC7m \u0111\xF3 b\u1ECB b\u1ECF qua trong t\xEDnh to\xE1n m\u1EA5t m\xE1t."),Wh.forEach(t),nc=u(n),st=c(n,"P",{});var Qt=r(st);Yr=a(Qt,"T\u1EA5t c\u1EA3 \u0111i\u1EC1u n\xE0y \u0111\u01B0\u1EE3c th\u1EF1c hi\u1EC7n b\u1EDFi "),ga=c(Qt,"A",{href:!0,rel:!0});var kp=r(ga);il=c(kp,"CODE",{});var $p=r(il);Zr=a($p,"DataCollatorForSeq2Seq"),$p.forEach(t),kp.forEach(t),Jr=a(Qt,". Gi\u1ED1ng nh\u01B0 "),ol=c(Qt,"CODE",{});var yp=r(ol);Qr=a(yp,"DataCollatorWithPadding"),yp.forEach(t),ni=a(Qt,", n\xF3 s\u1EED d\u1EE5ng "),pl=c(Qt,"CODE",{});var jp=r(pl);ti=a(jp,"tokenizer"),jp.forEach(t),ei=a(Qt," \u0111\u01B0\u1EE3c s\u1EED d\u1EE5ng \u0111\u1EC3 x\u1EED l\xFD tr\u01B0\u1EDBc c\xE1c \u0111\u1EA7u v\xE0o, nh\u01B0ng n\xF3 c\u0169ng l\u1EA5y "),ul=c(Qt,"CODE",{});var Ep=r(ul);si=a(Ep,"model"),Ep.forEach(t),ai=a(Qt,". \u0110i\u1EC1u n\xE0y l\xE0 do tr\xECnh \u0111\u1ED1i chi\u1EBFu d\u1EEF li\u1EC7u n\xE0y c\u0169ng s\u1EBD ch\u1ECBu tr\xE1ch nhi\u1EC7m chu\u1EA9n b\u1ECB c\xE1c ID \u0111\u1EA7u v\xE0o c\u1EE7a b\u1ED9 gi\u1EA3i m\xE3, l\xE0 c\xE1c phi\xEAn b\u1EA3n \u0111\u01B0\u1EE3c d\u1ECBch chuy\u1EC3n c\u1EE7a c\xE1c nh\xE3n v\u1EDBi m\u1ED9t token \u0111\u1EB7c bi\u1EC7t \u1EDF \u0111\u1EA7u. V\xEC s\u1EF1 thay \u0111\u1ED5i n\xE0y \u0111\u01B0\u1EE3c th\u1EF1c hi\u1EC7n h\u01A1i kh\xE1c \u0111\u1ED1i v\u1EDBi c\xE1c ki\u1EBFn \u200B\u200Btr\xFAc kh\xE1c nhau, n\xEAn "),ml=c(Qt,"CODE",{});var wp=r(ml);hi=a(wp,"DataCollatorForSeq2Seq"),wp.forEach(t),li=a(Qt," c\u1EA7n bi\u1EBFt \u0111\u1ED1i t\u01B0\u1EE3ng "),gl=c(Qt,"CODE",{});var xp=r(gl);ci=a(xp,"model"),xp.forEach(t),ri=a(Qt,":"),Qt.forEach(t),tc=u(n),Fe.l(n),$h=u(n),yh=c(n,"P",{});var qp=r(yh);ii=a(qp,"\u0110\u1EC3 ki\u1EC3m tra \u0111i\u1EC1u n\xE0y tr\xEAn m\u1ED9t s\u1ED1 m\u1EABu, ch\xFAng ta ch\u1EC9 c\u1EA7n g\u1ECDi n\xF3 trong danh s\xE1ch c\xE1c v\xED d\u1EE5 t\u1EEB b\u1ED9 hu\u1EA5n luy\u1EC7n \u0111\u01B0\u1EE3c tokenize c\u1EE7a m\xECnh:"),qp.forEach(t),ec=u(n),j(da.$$.fragment,n),sc=u(n),j(fa.$$.fragment,n),ac=u(n),Hs=c(n,"P",{});var hr=r(Hs);oi=a(hr,"Ch\xFAng t\xF4i c\xF3 th\u1EC3 ki\u1EC3m tra nh\xE3n \u0111\xE3 \u0111\u01B0\u1EE3c \u0111\u1EC7m \u0111\u1EBFn \u0111\u1ED9 d\xE0i t\u1ED1i \u0111a c\u1EE7a l\xF4 hay ch\u01B0a, b\u1EB1ng c\xE1ch s\u1EED d\u1EE5ng "),dl=c(hr,"CODE",{});var Tp=r(dl);pi=a(Tp,"-100"),Tp.forEach(t),ui=a(hr,":"),hr.forEach(t),hc=u(n),j(_a.$$.fragment,n),lc=u(n),j(ba.$$.fragment,n),cc=u(n),jh=c(n,"P",{});var Cp=r(jh);mi=a(Cp,"V\xE0 ch\xFAng t\xF4i c\u0169ng c\xF3 th\u1EC3 xem x\xE9t c\xE1c ID \u0111\u1EA7u v\xE0o c\u1EE7a b\u1ED9 gi\u1EA3i m\xE3, \u0111\u1EC3 bi\u1EBFt r\u1EB1ng ch\xFAng l\xE0 c\xE1c phi\xEAn b\u1EA3n \u0111\u01B0\u1EE3c thay \u0111\u1ED5i c\u1EE7a nh\xE3n:"),Cp.forEach(t),rc=u(n),j(va.$$.fragment,n),ic=u(n),j(ka.$$.fragment,n),oc=u(n),Eh=c(n,"P",{});var Pp=r(Eh);gi=a(Pp,"D\u01B0\u1EDBi \u0111\xE2y l\xE0 c\xE1c nh\xE3n cho c\xE1c ph\u1EA7n t\u1EED \u0111\u1EA7u ti\xEAn v\xE0 th\u1EE9 hai trong t\u1EADp d\u1EEF li\u1EC7u c\u1EE7a m\xECnh:"),Pp.forEach(t),pc=u(n),j($a.$$.fragment,n),uc=u(n),j(ya.$$.fragment,n),mc=u(n),Ie.l(n),wh=u(n),ys=c(n,"H3",{class:!0});var lr=r(ys);Bs=c(lr,"A",{id:!0,class:!0,href:!0});var Dp=r(Bs);fl=c(Dp,"SPAN",{});var zp=r(fl);j(ja.$$.fragment,zp),zp.forEach(t),Dp.forEach(t),di=u(lr),_l=c(lr,"SPAN",{});var Ap=r(_l);fi=a(Ap,"Th\u01B0\u1EDBc \u0111o"),Ap.forEach(t),lr.forEach(t),gc=u(n),j(Ea.$$.fragment,n),dc=u(n),Bt&&Bt.l(n),xh=u(n),Zt=c(n,"P",{});var ds=r(Zt);_i=a(ds,"Ch\u1EC9 s\u1ED1 truy\u1EC1n th\u1ED1ng \u0111\u01B0\u1EE3c s\u1EED d\u1EE5ng cho b\xE0i to\xE1n d\u1ECBch l\xE0 "),wa=c(ds,"A",{href:!0,rel:!0});var Sp=r(wa);bi=a(Sp,"\u0111i\u1EC3m BLEU"),Sp.forEach(t),vi=a(ds,", \u0111\u01B0\u1EE3c gi\u1EDBi thi\u1EC7u trong "),xa=c(ds,"A",{href:!0,rel:!0});var Op=r(xa);ki=a(Op,"m\u1ED9t b\xE0i b\xE1o n\u0103m 2002"),Op.forEach(t),$i=a(ds," b\u1EDFi Kishore Papineni v\xE0 c\u1ED9ng s\u1EF1. \u0110i\u1EC3m BLEU \u0111\xE1nh gi\xE1 m\u1EE9c \u0111\u1ED9 g\u1EA7n g\u0169i c\u1EE7a b\u1EA3n d\u1ECBch v\u1EDBi nh\xE3n c\u1EE7a ch\xFAng. N\xF3 kh\xF4ng \u0111o l\u01B0\u1EDDng m\u1EE9c \u0111\u1ED9 d\u1EC5 hi\u1EC3u ho\u1EB7c t\xEDnh \u0111\xFAng ng\u1EEF ph\xE1p c\u1EE7a c\xE1c \u0111\u1EA7u ra \u0111\u01B0\u1EE3c t\u1EA1o ra c\u1EE7a m\xF4 h\xECnh, nh\u01B0ng s\u1EED d\u1EE5ng c\xE1c quy t\u1EAFc th\u1ED1ng k\xEA \u0111\u1EC3 \u0111\u1EA3m b\u1EA3o r\u1EB1ng t\u1EA5t c\u1EA3 c\xE1c t\u1EEB trong c\xE1c \u0111\u1EA7u ra \u0111\u01B0\u1EE3c t\u1EA1o c\u0169ng xu\u1EA5t hi\u1EC7n trong c\xE1c nh\xE3n. Ngo\xE0i ra, c\xF3 c\xE1c quy t\u1EAFc ph\u1EA1t vi\u1EC7c l\u1EB7p l\u1EA1i c\xE1c t\u1EEB gi\u1ED1ng nhau n\u1EBFu ch\xFAng kh\xF4ng \u0111\u01B0\u1EE3c l\u1EB7p l\u1EA1i trong c\xE1c nh\xE3n (\u0111\u1EC3 tr\xE1nh m\xF4 h\xECnh xu\u1EA5t ra c\xE1c c\xE2u nh\u01B0 "),bl=c(ds,"CODE",{});var Np=r(bl);yi=a(Np,'"the the the"'),Np.forEach(t),ji=a(ds,") v\xE0 xu\u1EA5t ra c\xE1c c\xE2u ng\u1EAFn h\u01A1n c\xE1c c\xE2u trong nh\xE3n (\u0111\u1EC3 tr\xE1nh m\xF4 h\xECnh xu\u1EA5t ra c\xE1c c\xE2u nh\u01B0 "),vl=c(ds,"CODE",{});var Lp=r(vl);Ei=a(Lp,'"the"'),Lp.forEach(t),wi=a(ds,")."),ds.forEach(t),fc=u(n),Ms=c(n,"P",{});var cr=r(Ms);xi=a(cr,"M\u1ED9t \u0111i\u1EC3m y\u1EBFu c\u1EE7a BLEU l\xE0 n\xF3 mong \u0111\u1EE3i v\u0103n b\u1EA3n \u0111\xE3 \u0111\u01B0\u1EE3c tokenize, \u0111i\u1EC1u n\xE0y g\xE2y kh\xF3 kh\u0103n cho vi\u1EC7c so s\xE1nh \u0111i\u1EC3m gi\u1EEFa c\xE1c m\xF4 h\xECnh s\u1EED d\u1EE5ng c\xE1c b\u1ED9 tokenize kh\xE1c nhau. V\xEC v\u1EADy, thay v\xE0o \u0111\xF3, ch\u1EC9 s\u1ED1 \u0111\u01B0\u1EE3c s\u1EED d\u1EE5ng ph\u1ED5 bi\u1EBFn nh\u1EA5t cho c\xE1c m\xF4 h\xECnh d\u1ECBch \u0111i\u1EC3m chu\u1EA9n ng\xE0y nay l\xE0 "),qa=c(cr,"A",{href:!0,rel:!0});var Hp=r(qa);qi=a(Hp,"SacreBLEU"),Hp.forEach(t),Ti=a(cr,", gi\u1EA3i quy\u1EBFt \u0111i\u1EC3m y\u1EBFu n\xE0y (v\xE0 c\xE1c ch\u1EC9 s\u1ED1 kh\xE1c) b\u1EB1ng c\xE1ch chu\u1EA9n h\xF3a b\u01B0\u1EDBc tokenize. \u0110\u1EC3 s\u1EED d\u1EE5ng ch\u1EC9 s\u1ED1 n\xE0y, tr\u01B0\u1EDBc ti\xEAn ch\xFAng ta c\u1EA7n c\xE0i \u0111\u1EB7t th\u01B0 vi\u1EC7n SacreBLEU:"),cr.forEach(t),_c=u(n),j(Ta.$$.fragment,n),bc=u(n),gs=c(n,"P",{});var Yh=r(gs);Ci=a(Yh,"Ch\xFAng ta c\xF3 th\u1EC3 t\u1EA3i n\xF3 v\u1EDBi "),kl=c(Yh,"CODE",{});var Bp=r(kl);Pi=a(Bp,"evaluate.load()"),Bp.forEach(t),Di=a(Yh," nh\u01B0 ch\xFAng ta \u0111\xE3 l\xE0m trong "),qh=c(Yh,"A",{href:!0});var Mp=r(qh);zi=a(Mp,"Ch\u01B0\u01A1ng 3"),Mp.forEach(t),Ai=a(Yh,":"),Yh.forEach(t),vc=u(n),j(Ca.$$.fragment,n),kc=u(n),Th=c(n,"P",{});var Fp=r(Th);Si=a(Fp,"Ch\u1EC9 s\u1ED1 n\xE0y s\u1EBD l\u1EA5y v\u0103n b\u1EA3n l\xE0m \u0111\u1EA7u v\xE0o v\xE0 nh\xE3n. N\xF3 \u0111\u01B0\u1EE3c thi\u1EBFt k\u1EBF \u0111\u1EC3 ch\u1EA5p nh\u1EADn m\u1ED9t s\u1ED1 nh\xE3n c\xF3 th\u1EC3 ch\u1EA5p nh\u1EADn \u0111\u01B0\u1EE3c, v\xEC th\u01B0\u1EDDng c\xF3 nhi\u1EC1u b\u1EA3n d\u1ECBch c\xF3 th\u1EC3 ch\u1EA5p nh\u1EADn \u0111\u01B0\u1EE3c c\u1EE7a c\xF9ng m\u1ED9t c\xE2u - t\u1EADp d\u1EEF li\u1EC7u ta \u0111ang s\u1EED d\u1EE5ng ch\u1EC9 cung c\u1EA5p m\u1ED9t nh\xE3n, nh\u01B0ng kh\xF4ng hi\u1EBFm trong NLP \u0111\u1EC3 t\xECm t\u1EADp d\u1EEF li\u1EC7u cung c\u1EA5p m\u1ED9t s\u1ED1 c\xE2u d\u01B0\u1EDBi d\u1EA1ng nh\xE3n. V\xEC v\u1EADy, c\xE1c d\u1EF1 \u0111o\xE1n ph\u1EA3i l\xE0 m\u1ED9t danh s\xE1ch c\xE1c c\xE2u, nh\u01B0ng c\xE1c tham chi\u1EBFu ph\u1EA3i l\xE0 m\u1ED9t danh s\xE1ch c\xE1c danh s\xE1ch c\xE1c c\xE2u."),Fp.forEach(t),$c=u(n),Ch=c(n,"P",{});var Up=r(Ch);Oi=a(Up,"H\xE3y th\u1EED m\u1ED9t m\u1EABu:"),Up.forEach(t),yc=u(n),j(Pa.$$.fragment,n),jc=u(n),j(Da.$$.fragment,n),Ec=u(n),Jt=c(n,"P",{});var fs=r(Jt);Ni=a(fs,"Ta nh\u1EADn \u0111\u01B0\u1EE3c \u0111i\u1EC3m BLEU l\xE0 46.75, kh\xE1 t\u1ED1t - \u0111\u1EC3 tham kh\u1EA3o, m\xF4 h\xECnh Transformer ban \u0111\u1EA7u trong b\xE0i b\xE1o "),za=c(fs,"A",{href:!0,rel:!0});var Ip=r(za);Li=a(Ip,"\u201CAttention Is All You Need\u201D"),Ip.forEach(t),Hi=a(fs," \u0111\u1EA1t \u0111\u01B0\u1EE3c \u0111i\u1EC3m BLEU l\xE0 41.8 cho m\u1ED9t t\xE1c v\u1EE5 d\u1ECBch t\u01B0\u01A1ng t\u1EF1 gi\u1EEFa ti\u1EBFng Anh v\xE0 ti\u1EBFng Ph\xE1p! (\u0110\u1EC3 bi\u1EBFt th\xEAm th\xF4ng tin v\u1EC1 c\xE1c ch\u1EC9 s\u1ED1 ri\xEAng l\u1EBB, nh\u01B0 "),$l=c(fs,"CODE",{});var Vp=r($l);Bi=a(Vp,"counts"),Vp.forEach(t),Mi=a(fs," v\xE0 "),yl=c(fs,"CODE",{});var Kp=r(yl);Fi=a(Kp,"bp"),Kp.forEach(t),Ui=a(fs,", h\xE3y xem "),Aa=c(fs,"A",{href:!0,rel:!0});var Rp=r(Aa);Ii=a(Rp,"kho l\u01B0u tr\u1EEF SacreBLEU"),Rp.forEach(t),Vi=a(fs,".) M\u1EB7t kh\xE1c, n\u1EBFu ch\xFAng ta th\u1EED v\u1EDBi hai lo\u1EA1i d\u1EF1 \u0111o\xE1n kh\xF4ng t\u1ED1t (nhi\u1EC1u l\u1EA7n l\u1EB7p l\u1EA1i ho\u1EB7c qu\xE1 ng\u1EAFn) th\u01B0\u1EDDng xu\u1EA5t hi\u1EC7n trong c\xE1c m\xF4 h\xECnh d\u1ECBch, ch\xFAng ta s\u1EBD nh\u1EADn \u0111\u01B0\u1EE3c \u0111i\u1EC3m BLEU kh\xE1 t\u1EC7:"),fs.forEach(t),wc=u(n),j(Sa.$$.fragment,n),xc=u(n),j(Oa.$$.fragment,n),qc=u(n),j(Na.$$.fragment,n),Tc=u(n),j(La.$$.fragment,n),Cc=u(n),Ph=c(n,"P",{});var Gp=r(Ph);Ki=a(Gp,"\u0110i\u1EC3m s\u1ED1 c\xF3 th\u1EC3 t\u0103ng t\u1EEB 0 \u0111\u1EBFn 100 v\xE0 c\xE0ng cao th\xEC c\xE0ng t\u1ED1t."),Gp.forEach(t),Pc=u(n),Ke.l(n),Dh=u(n),zh=c(n,"P",{});var Xp=r(zh);Ri=a(Xp,"B\xE2y gi\u1EDD \u0111i\u1EC1u n\xE0y \u0111\xE3 ho\xE0n t\u1EA5t, ch\xFAng ta \u0111\xE3 s\u1EB5n s\xE0ng tinh ch\u1EC9nh m\xF4 h\xECnh c\u1EE7a m\xECnh!"),Xp.forEach(t),Dc=u(n),js=c(n,"H3",{class:!0});var rr=r(js);Fs=c(rr,"A",{id:!0,class:!0,href:!0});var Wp=r(Fs);jl=c(Wp,"SPAN",{});var Yp=r(jl);j(Ha.$$.fragment,Yp),Yp.forEach(t),Wp.forEach(t),Gi=u(rr),El=c(rr,"SPAN",{});var Zp=r(El);Xi=a(Zp,"Tinh ch\u1EC9nh m\xF4 h\xECnh"),Zp.forEach(t),rr.forEach(t),zc=u(n),Ah=c(n,"P",{});var Jp=r(Ah);Wi=a(Jp,"B\u01B0\u1EDBc \u0111\u1EA7u ti\xEAn l\xE0 \u0111\u0103ng nh\u1EADp v\xE0o Hugging Face \u0111\u1EC3 b\u1EA1n c\xF3 th\u1EC3 t\u1EA3i k\u1EBFt qu\u1EA3 c\u1EE7a m\xECnh l\xEAn Model Hub. C\xF3 m\u1ED9t ch\u1EE9c n\u0103ng ti\u1EC7n l\u1EE3i \u0111\u1EC3 gi\xFAp b\u1EA1n l\xE0m \u0111i\u1EC1u n\xE0y trong notebook:"),Jp.forEach(t),Ac=u(n),j(Ba.$$.fragment,n),Sc=u(n),Sh=c(n,"P",{});var Qp=r(Sh);Yi=a(Qp,"Thao t\xE1c n\xE0y s\u1EBD hi\u1EC3n th\u1ECB m\u1ED9t ti\u1EC7n \xEDch m\xE0 b\u1EA1n c\xF3 th\u1EC3 nh\u1EADp th\xF4ng tin \u0111\u0103ng nh\u1EADp Hugging Face c\u1EE7a m\xECnh."),Qp.forEach(t),Oc=u(n),Oh=c(n,"P",{});var nu=r(Oh);Zi=a(nu,"N\u1EBFu b\u1EA1n kh\xF4ng l\xE0m vi\u1EC7c trong notebook, ch\u1EC9 c\u1EA7n nh\u1EADp d\xF2ng sau v\xE0o terminal c\u1EE7a b\u1EA1n:"),nu.forEach(t),Nc=u(n),j(Ma.$$.fragment,n),Lc=u(n),Ge.l(n),Nh=u(n),Xn&&Xn.l(n),Lh=u(n),Es=c(n,"H2",{class:!0});var ir=r(Es);Us=c(ir,"A",{id:!0,class:!0,href:!0});var tu=r(Us);wl=c(tu,"SPAN",{});var eu=r(wl);j(Fa.$$.fragment,eu),eu.forEach(t),tu.forEach(t),Ji=u(ir),xl=c(ir,"SPAN",{});var su=r(xl);Qi=a(su,"S\u1EED d\u1EE5ng m\xF4 h\xECnh tinh ch\u1EC9nh"),su.forEach(t),ir.forEach(t),Hc=u(n),Is=c(n,"P",{});var or=r(Is);no=a(or,"Ch\xFAng t\xF4i \u0111\xE3 ch\u1EC9 cho b\u1EA1n c\xE1ch b\u1EA1n c\xF3 th\u1EC3 s\u1EED d\u1EE5ng m\xF4 h\xECnh m\xE0 ta \u0111\xE3 tinh ch\u1EC9nh tr\xEAn Model Hub b\u1EB1ng ti\u1EC7n \xEDch lu\u1EADn suy. \u0110\u1EC3 s\u1EED d\u1EE5ng n\xF3 c\u1EE5c b\u1ED9 trong m\u1ED9t "),ql=c(or,"CODE",{});var au=r(ql);to=a(au,"pipeline"),au.forEach(t),eo=a(or,", ch\xFAng ta ch\u1EC9 c\u1EA7n ch\u1EC9 \u0111\u1ECBnh m\xE3 \u0111\u1ECBnh danh m\xF4 h\xECnh th\xEDch h\u1EE3p:"),or.forEach(t),Bc=u(n),j(Ua.$$.fragment,n),Mc=u(n),j(Ia.$$.fragment,n),Fc=u(n),Hh=c(n,"P",{});var hu=r(Hh);so=a(hu,"\u0110\xFAng nh\u01B0 mong \u0111\u1EE3i, m\xF4 h\xECnh \u0111\u01B0\u1EE3c hu\u1EA5n luy\u1EC7n tr\u01B0\u1EDBc c\u1EE7a ch\xFAng ta \u0111\xE3 \u0111i\u1EC1u ch\u1EC9nh ki\u1EBFn th\u1EE9c c\u1EE7a n\xF3 cho ph\xF9 h\u1EE3p v\u1EDBi kho ng\u1EEF li\u1EC7u m\xE0 ch\xFAng ta \u0111\xE3 tinh ch\u1EC9nh v\xE0 thay v\xEC \u0111\u1EC3 nguy\xEAn t\u1EEB \u201Cthread\u201D trong ti\u1EBFng Anh, gi\u1EDD \u0111\xE2y n\xF3 \u0111\xE3 d\u1ECBch n\xF3 sang phi\xEAn b\u1EA3n ch\xEDnh th\u1EE9c ti\u1EBFng Ph\xE1p. \u0110\u1ED1i v\u1EDBi \u201Cplugin\u201D c\u0169ng v\u1EADy:"),hu.forEach(t),Uc=u(n),j(Va.$$.fragment,n),Ic=u(n),j(Ka.$$.fragment,n),Vc=u(n),Bh=c(n,"P",{});var lu=r(Bh);ao=a(lu,"M\u1ED9t v\xED d\u1EE5 tuy\u1EC7t v\u1EDDi kh\xE1c v\u1EC1 th\xEDch \u1EE9ng chuy\u1EC7n m\xF4n!"),lu.forEach(t),Kc=u(n),j(Vs.$$.fragment,n),this.h()},h(){f(o,"name","hf:doc:metadata"),f(o,"content",JSON.stringify(Hu)),f(_,"id","dch-my"),f(_,"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"),f(_,"href","#dch-my"),f(z,"class","relative group"),f(U,"href","/course/chapter1/7"),f(Y,"href","/course/chapter7/6"),f(Tn,"href","/course/chapter7/6"),f(wn,"href","https://huggingface.co/datasets/kde4"),f(wn,"rel","nofollow"),f(En,"href","https://apps.kde.org/"),f(En,"rel","nofollow"),f($n,"href","https://opus.nlpl.eu/"),f($n,"rel","nofollow"),pr(gn.src,ht="https://hf.space/gradioiframe/course-demos/marian-finetuned-kde4-en-to-fr/+")||f(gn,"src",ht),f(gn,"frameborder","0"),f(gn,"height","350"),f(gn,"title","Gradio app"),f(gn,"class","block dark:hidden container p-0 flex-grow space-iframe"),f(gn,"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"),f(gn,"sandbox","allow-forms allow-modals allow-popups allow-popups-to-escape-sandbox allow-same-origin allow-scripts allow-downloads"),f(Pn,"class","block dark:hidden lg:w-3/5"),pr(Pn.src,lt="https://huggingface.co/datasets/huggingface-course/documentation-images/resolve/main/en/chapter7/modeleval-marian-finetuned-kde4-en-to-fr.png")||f(Pn,"src",lt),f(Pn,"alt","One-hot encoded labels for question answering."),f(qn,"class","hidden dark:block lg:w-3/5"),pr(qn.src,ct="https://huggingface.co/datasets/huggingface-course/documentation-images/resolve/main/en/chapter7/modeleval-marian-finetuned-kde4-en-to-fr-dark.png")||f(qn,"src",ct),f(qn,"alt","One-hot encoded labels for question answering."),f(cn,"class","flex justify-center"),f(cn,"href","/huggingface-course/marian-finetuned-kde4-en-to-fr"),f(Dn,"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."),f(Dn,"rel","nofollow"),f(Mn,"id","chun-b-d-liu"),f(Mn,"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"),f(Mn,"href","#chun-b-d-liu"),f(Wn,"class","relative group"),f(Zn,"href","https://huggingface.co/datasets/kde4"),f(Zn,"rel","nofollow"),f(Fn,"href","/course/chapter5"),f(Jn,"id","b-d-liu-kde4"),f(Jn,"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"),f(Jn,"href","#b-d-liu-kde4"),f(Vn,"class","relative group"),f(tt,"href","https://huggingface.co/datasets/kde4"),f(tt,"rel","nofollow"),pr(N.src,jt="https://huggingface.co/datasets/huggingface-course/documentation-images/resolve/main/en/chapter7/language_tags.png")||f(N,"src",jt),f(N,"alt","Language available for the KDE4 dataset."),f(N,"width","100%"),f(Nt,"href","/course/chapter5"),f(Ne,"id","chun-b-d-liu"),f(Ne,"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"),f(Ne,"href","#chun-b-d-liu"),f(ke,"class","relative group"),f(Yt,"href","https://huggingface.co/Helsinki-NLP"),f(Yt,"rel","nofollow"),f(la,"href","https://huggingface.co/models"),f(la,"rel","nofollow"),f(Ls,"id","i-chiu-d-liu"),f(Ls,"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"),f(Ls,"href","#i-chiu-d-liu"),f($s,"class","relative group"),f(ga,"href","https://huggingface.co/transformers/main_classes/data_collator.html#datacollatorforseq2seq"),f(ga,"rel","nofollow"),f(Bs,"id","thc-o"),f(Bs,"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"),f(Bs,"href","#thc-o"),f(ys,"class","relative group"),f(wa,"href","https://en.wikipedia.org/wiki/BLEU"),f(wa,"rel","nofollow"),f(xa,"href","https://aclanthology.org/P02-1040.pdf"),f(xa,"rel","nofollow"),f(qa,"href","https://github.com/mjpost/sacrebleu"),f(qa,"rel","nofollow"),f(qh,"href","/course/chapter3"),f(za,"href","https://arxiv.org/pdf/1706.03762.pdf"),f(za,"rel","nofollow"),f(Aa,"href","https://github.com/mjpost/sacrebleu/blob/078c440168c6adc89ba75fe6d63f0d922d42bcfe/sacrebleu/metrics/bleu.py#L74"),f(Aa,"rel","nofollow"),f(Fs,"id","tinh-chnh-m-hnh"),f(Fs,"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"),f(Fs,"href","#tinh-chnh-m-hnh"),f(js,"class","relative group"),f(Us,"id","s-dng-m-hnh-tinh-chnh"),f(Us,"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"),f(Us,"href","#s-dng-m-hnh-tinh-chnh"),f(Es,"class","relative group")},m(n,i){e(document.head,o),h(n,$,i),E(d,n,i),h(n,x,i),h(n,z,i),e(z,_),e(_,C),E(D,C,null),e(z,P),e(z,q),e(q,O),h(n,T,i),Ra[S].m(n,i),h(n,I,i),h(n,B,i),e(B,tn),e(B,U),e(U,H),e(B,X),e(B,Y),e(Y,rn),e(B,on),h(n,sn,i),h(n,Q,i),e(Q,Z),e(Z,R),e(R,un),e(Z,dn),e(Z,en),e(en,nn),e(Z,fn),e(Q,mn),e(Q,ln),e(ln,M),e(M,G),e(ln,jn),h(n,xn,i),E(pn,n,i),h(n,W,i),h(n,an,i),e(an,kn),e(an,Tn),e(Tn,On),e(an,_n),h(n,bn,i),h(n,J,i),e(J,Cn),e(J,wn),e(wn,mt),e(J,Nn),e(J,En),e(En,Ln),e(J,gt),e(J,$n),e($n,Hn),e(J,at),h(n,k,i),h(n,K,i),e(K,Bn),h(n,zn,i),h(n,gn,i),h(n,Tt,i),h(n,cn,i),e(cn,Pn),e(cn,Ct),e(cn,qn),h(n,rt,i),h(n,hn,i),e(hn,Pt),e(hn,Dn),e(Dn,ue),e(hn,Mt),h(n,Ft,i),h(n,Wn,i),e(Wn,Mn),e(Mn,Dt),E(dt,Dt,null),e(Wn,zt),e(Wn,At),e(At,Yn),h(n,ne,i),h(n,yn,i),e(yn,St),e(yn,Zn),e(Zn,me),e(yn,ft),e(yn,Fn),e(Fn,_t),e(yn,Un),e(yn,bt),e(bt,te),e(yn,ge),h(n,In,i),h(n,Vn,i),e(Vn,Jn),e(Jn,ee),E(vt,ee,null),e(Vn,Kn),e(Vn,Qn),e(Qn,se),h(n,it,i),h(n,An,i),e(An,Ut),e(An,kt),e(kt,de),e(An,Rn),h(n,$t,i),E(nt,n,i),h(n,Ot,i),h(n,yt,i),e(yt,It),e(yt,tt),e(tt,Ee),e(yt,ae),h(n,g,i),h(n,N,i),h(n,we,i),h(n,Et,i),e(Et,Xe),h(n,ot,i),E(pt,n,i),h(n,he,i),E(Vt,n,i),h(n,Kt,i),h(n,vn,i),e(vn,fe),e(vn,Nt),e(Nt,Sn),e(vn,We),e(vn,Rt),e(Rt,Ye),e(vn,Ze),e(vn,le),e(le,Gn),e(vn,_e),h(n,Gt,i),E(Xt,n,i),h(n,xe,i),E(wt,n,i),h(n,qe,i),h(n,ut,i),e(ut,be),e(ut,xt),e(xt,Je),e(ut,Te),e(ut,qt),e(qt,Ce),e(ut,Wt),h(n,_s,i),E(et,n,i),h(n,qs,i),h(n,ve,i),e(ve,Zs),h(n,Ts,i),E(Lt,n,i),h(n,Qe,i),E(Pe,n,i),h(n,Cs,i),h(n,De,i),e(De,m),h(n,L,i),E(ns,n,i),h(n,Js,i),E(ts,n,i),h(n,ze,i),h(n,bs,i),e(bs,th),h(n,vs,i),E(es,n,i),h(n,Qs,i),E(ss,n,i),h(n,Ae,i),h(n,ks,i),e(ks,eh),h(n,na,i),E(as,n,i),h(n,Se,i),E(hs,n,i),h(n,ta,i),h(n,Ht,i),e(Ht,sh),h(n,ea,i),E(ls,n,i),h(n,ce,i),E(Oe,n,i),h(n,sa,i),h(n,ke,i),e(ke,Ne),e(Ne,$e),E(cs,$e,null),e(ke,ah),e(ke,rs),e(rs,hh),h(n,aa,i),E(is,n,i),h(n,Le,i),h(n,re,i),e(re,lh),e(re,ye),e(ye,ch),e(re,rh),e(re,Yt),e(Yt,ih),e(re,oh),h(n,ie,i),E(os,n,i),h(n,ha,i),h(n,oe,i),e(oe,ps),e(oe,Ps),e(Ps,ph),e(oe,uh),e(oe,la),e(la,mr),e(oe,gr),h(n,Dl,i),E(Ds,n,i),h(n,zl,i),h(n,zs,i),e(zs,dr),e(zs,Zh),e(Zh,fr),e(zs,_r),h(n,Al,i),h(n,As,i),e(As,br),e(As,Jh),e(Jh,vr),e(As,kr),h(n,Sl,i),E(ca,n,i),h(n,Ol,i),h(n,us,i),e(us,$r),e(us,Qh),e(Qh,yr),e(us,jr),e(us,nl),e(nl,Er),e(us,wr),h(n,Nl,i),h(n,Ss,i),e(Ss,xr),e(Ss,tl),e(tl,qr),e(Ss,Tr),h(n,Ll,i),h(n,mh,i),e(mh,Cr),h(n,Hl,i),E(ra,n,i),h(n,Bl,i),h(n,gh,i),e(gh,Pr),h(n,Ml,i),E(ia,n,i),h(n,Fl,i),E(oa,n,i),h(n,Ul,i),h(n,dh,i),e(dh,Dr),h(n,Il,i),h(n,je,i),e(je,zr),e(je,el),e(el,Ar),e(je,Sr),e(je,sl),e(sl,Or),e(je,Nr),e(je,al),e(al,Lr),e(je,Hr),h(n,Vl,i),E(pa,n,i),h(n,Kl,i),h(n,fh,i),e(fh,Br),h(n,Rl,i),E(Os,n,i),h(n,Gl,i),E(Ns,n,i),h(n,Xl,i),h(n,_h,i),e(_h,Mr),h(n,Wl,i),E(ua,n,i),h(n,Yl,i),h(n,bh,i),e(bh,Fr),h(n,Zl,i),Ga[He].m(n,i),h(n,vh,i),h(n,kh,i),e(kh,Ur),h(n,Jl,i),h(n,$s,i),e($s,Ls),e(Ls,hl),E(ma,hl,null),e($s,Ir),e($s,ll),e(ll,Vr),h(n,Ql,i),h(n,ms,i),e(ms,Kr),e(ms,cl),e(cl,Rr),e(ms,Gr),e(ms,rl),e(rl,Xr),e(ms,Wr),h(n,nc,i),h(n,st,i),e(st,Yr),e(st,ga),e(ga,il),e(il,Zr),e(st,Jr),e(st,ol),e(ol,Qr),e(st,ni),e(st,pl),e(pl,ti),e(st,ei),e(st,ul),e(ul,si),e(st,ai),e(st,ml),e(ml,hi),e(st,li),e(st,gl),e(gl,ci),e(st,ri),h(n,tc,i),Xa[Me].m(n,i),h(n,$h,i),h(n,yh,i),e(yh,ii),h(n,ec,i),E(da,n,i),h(n,sc,i),E(fa,n,i),h(n,ac,i),h(n,Hs,i),e(Hs,oi),e(Hs,dl),e(dl,pi),e(Hs,ui),h(n,hc,i),E(_a,n,i),h(n,lc,i),E(ba,n,i),h(n,cc,i),h(n,jh,i),e(jh,mi),h(n,rc,i),E(va,n,i),h(n,ic,i),E(ka,n,i),h(n,oc,i),h(n,Eh,i),e(Eh,gi),h(n,pc,i),E($a,n,i),h(n,uc,i),E(ya,n,i),h(n,mc,i),Wa[Ue].m(n,i),h(n,wh,i),h(n,ys,i),e(ys,Bs),e(Bs,fl),E(ja,fl,null),e(ys,di),e(ys,_l),e(_l,fi),h(n,gc,i),E(Ea,n,i),h(n,dc,i),Bt&&Bt.m(n,i),h(n,xh,i),h(n,Zt,i),e(Zt,_i),e(Zt,wa),e(wa,bi),e(Zt,vi),e(Zt,xa),e(xa,ki),e(Zt,$i),e(Zt,bl),e(bl,yi),e(Zt,ji),e(Zt,vl),e(vl,Ei),e(Zt,wi),h(n,fc,i),h(n,Ms,i),e(Ms,xi),e(Ms,qa),e(qa,qi),e(Ms,Ti),h(n,_c,i),E(Ta,n,i),h(n,bc,i),h(n,gs,i),e(gs,Ci),e(gs,kl),e(kl,Pi),e(gs,Di),e(gs,qh),e(qh,zi),e(gs,Ai),h(n,vc,i),E(Ca,n,i),h(n,kc,i),h(n,Th,i),e(Th,Si),h(n,$c,i),h(n,Ch,i),e(Ch,Oi),h(n,yc,i),E(Pa,n,i),h(n,jc,i),E(Da,n,i),h(n,Ec,i),h(n,Jt,i),e(Jt,Ni),e(Jt,za),e(za,Li),e(Jt,Hi),e(Jt,$l),e($l,Bi),e(Jt,Mi),e(Jt,yl),e(yl,Fi),e(Jt,Ui),e(Jt,Aa),e(Aa,Ii),e(Jt,Vi),h(n,wc,i),E(Sa,n,i),h(n,xc,i),E(Oa,n,i),h(n,qc,i),E(Na,n,i),h(n,Tc,i),E(La,n,i),h(n,Cc,i),h(n,Ph,i),e(Ph,Ki),h(n,Pc,i),Ya[Ve].m(n,i),h(n,Dh,i),h(n,zh,i),e(zh,Ri),h(n,Dc,i),h(n,js,i),e(js,Fs),e(Fs,jl),E(Ha,jl,null),e(js,Gi),e(js,El),e(El,Xi),h(n,zc,i),h(n,Ah,i),e(Ah,Wi),h(n,Ac,i),E(Ba,n,i),h(n,Sc,i),h(n,Sh,i),e(Sh,Yi),h(n,Oc,i),h(n,Oh,i),e(Oh,Zi),h(n,Nc,i),E(Ma,n,i),h(n,Lc,i),Za[Re].m(n,i),h(n,Nh,i),Xn&&Xn.m(n,i),h(n,Lh,i),h(n,Es,i),e(Es,Us),e(Us,wl),E(Fa,wl,null),e(Es,Ji),e(Es,xl),e(xl,Qi),h(n,Hc,i),h(n,Is,i),e(Is,no),e(Is,ql),e(ql,to),e(Is,eo),h(n,Bc,i),E(Ua,n,i),h(n,Mc,i),E(Ia,n,i),h(n,Fc,i),h(n,Hh,i),e(Hh,so),h(n,Uc,i),E(Va,n,i),h(n,Ic,i),E(Ka,n,i),h(n,Vc,i),h(n,Bh,i),e(Bh,ao),h(n,Kc,i),E(Vs,n,i),Rc=!0},p(n,[i]){const Ja={};i&1&&(Ja.fw=n[0]),d.$set(Ja);let Mh=S;S=lo(n),S!==Mh&&(nh(),v(Ra[Mh],1,1,()=>{Ra[Mh]=null}),Qa(),F=Ra[S],F||(F=Ra[S]=ho[S](n),F.c()),b(F,1),F.m(I.parentNode,I));const Tl={};i&2&&(Tl.$$scope={dirty:i,ctx:n}),Oe.$set(Tl);const Cl={};i&2&&(Cl.$$scope={dirty:i,ctx:n}),Ds.$set(Cl);const ws={};i&2&&(ws.$$scope={dirty:i,ctx:n}),Os.$set(ws);const Pl={};i&2&&(Pl.$$scope={dirty:i,ctx:n}),Ns.$set(Pl);let Fh=He;He=ro(n),He!==Fh&&(nh(),v(Ga[Fh],1,1,()=>{Ga[Fh]=null}),Qa(),Be=Ga[He],Be||(Be=Ga[He]=co[He](n),Be.c()),b(Be,1),Be.m(vh.parentNode,vh));let Ks=Me;Me=oo(n),Me!==Ks&&(nh(),v(Xa[Ks],1,1,()=>{Xa[Ks]=null}),Qa(),Fe=Xa[Me],Fe||(Fe=Xa[Me]=io[Me](n),Fe.c()),b(Fe,1),Fe.m($h.parentNode,$h));let xs=Ue;Ue=uo(n),Ue!==xs&&(nh(),v(Wa[xs],1,1,()=>{Wa[xs]=null}),Qa(),Ie=Wa[Ue],Ie||(Ie=Wa[Ue]=po[Ue](n),Ie.c()),b(Ie,1),Ie.m(wh.parentNode,wh)),n[0]==="pt"?Bt||(Bt=ru(),Bt.c(),Bt.m(xh.parentNode,xh)):Bt&&(Bt.d(1),Bt=null);let Uh=Ve;Ve=go(n),Ve!==Uh&&(nh(),v(Ya[Uh],1,1,()=>{Ya[Uh]=null}),Qa(),Ke=Ya[Ve],Ke||(Ke=Ya[Ve]=mo[Ve](n),Ke.c()),b(Ke,1),Ke.m(Dh.parentNode,Dh));let Ih=Re;Re=_o(n),Re!==Ih&&(nh(),v(Za[Ih],1,1,()=>{Za[Ih]=null}),Qa(),Ge=Za[Re],Ge||(Ge=Za[Re]=fo[Re](n),Ge.c()),b(Ge,1),Ge.m(Nh.parentNode,Nh)),n[0]==="pt"?Xn?i&1&&b(Xn,1):(Xn=iu(),Xn.c(),b(Xn,1),Xn.m(Lh.parentNode,Lh)):Xn&&(nh(),v(Xn,1,1,()=>{Xn=null}),Qa());const Vh={};i&2&&(Vh.$$scope={dirty:i,ctx:n}),Vs.$set(Vh)},i(n){Rc||(b(d.$$.fragment,n),b(D.$$.fragment,n),b(F),b(pn.$$.fragment,n),b(dt.$$.fragment,n),b(vt.$$.fragment,n),b(nt.$$.fragment,n),b(pt.$$.fragment,n),b(Vt.$$.fragment,n),b(Xt.$$.fragment,n),b(wt.$$.fragment,n),b(et.$$.fragment,n),b(Lt.$$.fragment,n),b(Pe.$$.fragment,n),b(ns.$$.fragment,n),b(ts.$$.fragment,n),b(es.$$.fragment,n),b(ss.$$.fragment,n),b(as.$$.fragment,n),b(hs.$$.fragment,n),b(ls.$$.fragment,n),b(Oe.$$.fragment,n),b(cs.$$.fragment,n),b(is.$$.fragment,n),b(os.$$.fragment,n),b(Ds.$$.fragment,n),b(ca.$$.fragment,n),b(ra.$$.fragment,n),b(ia.$$.fragment,n),b(oa.$$.fragment,n),b(pa.$$.fragment,n),b(Os.$$.fragment,n),b(Ns.$$.fragment,n),b(ua.$$.fragment,n),b(Be),b(ma.$$.fragment,n),b(Fe),b(da.$$.fragment,n),b(fa.$$.fragment,n),b(_a.$$.fragment,n),b(ba.$$.fragment,n),b(va.$$.fragment,n),b(ka.$$.fragment,n),b($a.$$.fragment,n),b(ya.$$.fragment,n),b(Ie),b(ja.$$.fragment,n),b(Ea.$$.fragment,n),b(Ta.$$.fragment,n),b(Ca.$$.fragment,n),b(Pa.$$.fragment,n),b(Da.$$.fragment,n),b(Sa.$$.fragment,n),b(Oa.$$.fragment,n),b(Na.$$.fragment,n),b(La.$$.fragment,n),b(Ke),b(Ha.$$.fragment,n),b(Ba.$$.fragment,n),b(Ma.$$.fragment,n),b(Ge),b(Xn),b(Fa.$$.fragment,n),b(Ua.$$.fragment,n),b(Ia.$$.fragment,n),b(Va.$$.fragment,n),b(Ka.$$.fragment,n),b(Vs.$$.fragment,n),Rc=!0)},o(n){v(d.$$.fragment,n),v(D.$$.fragment,n),v(F),v(pn.$$.fragment,n),v(dt.$$.fragment,n),v(vt.$$.fragment,n),v(nt.$$.fragment,n),v(pt.$$.fragment,n),v(Vt.$$.fragment,n),v(Xt.$$.fragment,n),v(wt.$$.fragment,n),v(et.$$.fragment,n),v(Lt.$$.fragment,n),v(Pe.$$.fragment,n),v(ns.$$.fragment,n),v(ts.$$.fragment,n),v(es.$$.fragment,n),v(ss.$$.fragment,n),v(as.$$.fragment,n),v(hs.$$.fragment,n),v(ls.$$.fragment,n),v(Oe.$$.fragment,n),v(cs.$$.fragment,n),v(is.$$.fragment,n),v(os.$$.fragment,n),v(Ds.$$.fragment,n),v(ca.$$.fragment,n),v(ra.$$.fragment,n),v(ia.$$.fragment,n),v(oa.$$.fragment,n),v(pa.$$.fragment,n),v(Os.$$.fragment,n),v(Ns.$$.fragment,n),v(ua.$$.fragment,n),v(Be),v(ma.$$.fragment,n),v(Fe),v(da.$$.fragment,n),v(fa.$$.fragment,n),v(_a.$$.fragment,n),v(ba.$$.fragment,n),v(va.$$.fragment,n),v(ka.$$.fragment,n),v($a.$$.fragment,n),v(ya.$$.fragment,n),v(Ie),v(ja.$$.fragment,n),v(Ea.$$.fragment,n),v(Ta.$$.fragment,n),v(Ca.$$.fragment,n),v(Pa.$$.fragment,n),v(Da.$$.fragment,n),v(Sa.$$.fragment,n),v(Oa.$$.fragment,n),v(Na.$$.fragment,n),v(La.$$.fragment,n),v(Ke),v(Ha.$$.fragment,n),v(Ba.$$.fragment,n),v(Ma.$$.fragment,n),v(Ge),v(Xn),v(Fa.$$.fragment,n),v(Ua.$$.fragment,n),v(Ia.$$.fragment,n),v(Va.$$.fragment,n),v(Ka.$$.fragment,n),v(Vs.$$.fragment,n),Rc=!1},d(n){t(o),n&&t($),w(d,n),n&&t(x),n&&t(z),w(D),n&&t(T),Ra[S].d(n),n&&t(I),n&&t(B),n&&t(sn),n&&t(Q),n&&t(xn),w(pn,n),n&&t(W),n&&t(an),n&&t(bn),n&&t(J),n&&t(k),n&&t(K),n&&t(zn),n&&t(gn),n&&t(Tt),n&&t(cn),n&&t(rt),n&&t(hn),n&&t(Ft),n&&t(Wn),w(dt),n&&t(ne),n&&t(yn),n&&t(In),n&&t(Vn),w(vt),n&&t(it),n&&t(An),n&&t($t),w(nt,n),n&&t(Ot),n&&t(yt),n&&t(g),n&&t(N),n&&t(we),n&&t(Et),n&&t(ot),w(pt,n),n&&t(he),w(Vt,n),n&&t(Kt),n&&t(vn),n&&t(Gt),w(Xt,n),n&&t(xe),w(wt,n),n&&t(qe),n&&t(ut),n&&t(_s),w(et,n),n&&t(qs),n&&t(ve),n&&t(Ts),w(Lt,n),n&&t(Qe),w(Pe,n),n&&t(Cs),n&&t(De),n&&t(L),w(ns,n),n&&t(Js),w(ts,n),n&&t(ze),n&&t(bs),n&&t(vs),w(es,n),n&&t(Qs),w(ss,n),n&&t(Ae),n&&t(ks),n&&t(na),w(as,n),n&&t(Se),w(hs,n),n&&t(ta),n&&t(Ht),n&&t(ea),w(ls,n),n&&t(ce),w(Oe,n),n&&t(sa),n&&t(ke),w(cs),n&&t(aa),w(is,n),n&&t(Le),n&&t(re),n&&t(ie),w(os,n),n&&t(ha),n&&t(oe),n&&t(Dl),w(Ds,n),n&&t(zl),n&&t(zs),n&&t(Al),n&&t(As),n&&t(Sl),w(ca,n),n&&t(Ol),n&&t(us),n&&t(Nl),n&&t(Ss),n&&t(Ll),n&&t(mh),n&&t(Hl),w(ra,n),n&&t(Bl),n&&t(gh),n&&t(Ml),w(ia,n),n&&t(Fl),w(oa,n),n&&t(Ul),n&&t(dh),n&&t(Il),n&&t(je),n&&t(Vl),w(pa,n),n&&t(Kl),n&&t(fh),n&&t(Rl),w(Os,n),n&&t(Gl),w(Ns,n),n&&t(Xl),n&&t(_h),n&&t(Wl),w(ua,n),n&&t(Yl),n&&t(bh),n&&t(Zl),Ga[He].d(n),n&&t(vh),n&&t(kh),n&&t(Jl),n&&t($s),w(ma),n&&t(Ql),n&&t(ms),n&&t(nc),n&&t(st),n&&t(tc),Xa[Me].d(n),n&&t($h),n&&t(yh),n&&t(ec),w(da,n),n&&t(sc),w(fa,n),n&&t(ac),n&&t(Hs),n&&t(hc),w(_a,n),n&&t(lc),w(ba,n),n&&t(cc),n&&t(jh),n&&t(rc),w(va,n),n&&t(ic),w(ka,n),n&&t(oc),n&&t(Eh),n&&t(pc),w($a,n),n&&t(uc),w(ya,n),n&&t(mc),Wa[Ue].d(n),n&&t(wh),n&&t(ys),w(ja),n&&t(gc),w(Ea,n),n&&t(dc),Bt&&Bt.d(n),n&&t(xh),n&&t(Zt),n&&t(fc),n&&t(Ms),n&&t(_c),w(Ta,n),n&&t(bc),n&&t(gs),n&&t(vc),w(Ca,n),n&&t(kc),n&&t(Th),n&&t($c),n&&t(Ch),n&&t(yc),w(Pa,n),n&&t(jc),w(Da,n),n&&t(Ec),n&&t(Jt),n&&t(wc),w(Sa,n),n&&t(xc),w(Oa,n),n&&t(qc),w(Na,n),n&&t(Tc),w(La,n),n&&t(Cc),n&&t(Ph),n&&t(Pc),Ya[Ve].d(n),n&&t(Dh),n&&t(zh),n&&t(Dc),n&&t(js),w(Ha),n&&t(zc),n&&t(Ah),n&&t(Ac),w(Ba,n),n&&t(Sc),n&&t(Sh),n&&t(Oc),n&&t(Oh),n&&t(Nc),w(Ma,n),n&&t(Lc),Za[Re].d(n),n&&t(Nh),Xn&&Xn.d(n),n&&t(Lh),n&&t(Es),w(Fa),n&&t(Hc),n&&t(Is),n&&t(Bc),w(Ua,n),n&&t(Mc),w(Ia,n),n&&t(Fc),n&&t(Hh),n&&t(Uc),w(Va,n),n&&t(Ic),w(Ka,n),n&&t(Vc),n&&t(Bh),n&&t(Kc),w(Vs,n)}}}const Hu={local:"dch-my",sections:[{local:"chun-b-d-liu",sections:[{local:"b-d-liu-kde4",title:"B\u1ED9 d\u1EEF li\u1EC7u KDE4"},{local:"chun-b-d-liu",title:"Chu\u1EA9n b\u1ECB d\u1EEF li\u1EC7u"}],title:"Chu\u1EA9n b\u1ECB d\u1EEF li\u1EC7u"},{local:"tinh-chnh-m-hnh-vi-api-trainer",title:"Tinh ch\u1EC9nh m\xF4 h\xECnh v\u1EDBi API `Trainer`"},{local:"tinh-chnh-m-hnh-vi-keras",sections:[{local:"i-chiu-d-liu",title:"\u0110\u1ED1i chi\u1EBFu d\u1EEF li\u1EC7u"},{local:"thc-o",title:"Th\u01B0\u1EDBc \u0111o"},{local:"tinh-chnh-m-hnh",title:"Tinh ch\u1EC9nh m\xF4 h\xECnh"}],title:"Tinh ch\u1EC9nh m\xF4 h\xECnh v\u1EDBi Keras"},{local:"mt-vng-hun-luyn-ty-chnh",sections:[{local:"chun-b-mi-th-cho-qua-trnh-hun-luyn",title:"Chu\u1EA9n b\u1ECB m\u1ECDi th\u1EE9 cho qua tr\xECnh hu\u1EA5n luy\u1EC7n"},{local:"vng-lp-hun-luyn",title:"V\xF2ng l\u1EB7p hu\u1EA5n luy\u1EC7n"}],title:"M\u1ED9t v\xF2ng hu\u1EA5n luy\u1EC7n t\xF9y ch\u1EC9nh"},{local:"s-dng-m-hnh-tinh-chnh",title:"S\u1EED d\u1EE5ng m\xF4 h\xECnh tinh ch\u1EC9nh"}],title:"D\u1ECBch m\xE1y"};function Bu(V,o,$){let d="pt";return du(()=>{const x=new URLSearchParams(window.location.search);$(0,d=x.get("fw")||"pt")}),[d]}class Gu extends pu{constructor(o){super();uu(this,o,Bu,Lu,mu,{})}}export{Gu as default,Hu as metadata};
