import{S as Ef,i as qf,s as Tf,e as h,t as e,k as m,w as _,c as l,a as c,h as a,d as s,m as p,x as y,b as d,g as r,G as t,y as k,q as f,o as b,B as $,U as _f,M as Cf,V as yf,N as Wc,p as Al,v as zf,n as Ol}from"../../chunks/vendor-hf-doc-builder.js";import{T as ca}from"../../chunks/Tip-hf-doc-builder.js";import{Y as qu}from"../../chunks/Youtube-hf-doc-builder.js";import{I as Xt}from"../../chunks/IconCopyLink-hf-doc-builder.js";import{C}from"../../chunks/CodeBlock-hf-doc-builder.js";import{D as jf}from"../../chunks/DocNotebookDropdown-hf-doc-builder.js";import{F as Df}from"../../chunks/FrameworkSwitchCourse-hf-doc-builder.js";function Sf(W){let u,w;return u=new jf({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/section5_tf.ipynb"},{label:"Aws Studio",value:"https://studiolab.sagemaker.aws/import/github/huggingface/notebooks/blob/master/course/vi/chapter7/section5_tf.ipynb"}]}}),{c(){_(u.$$.fragment)},l(g){y(u.$$.fragment,g)},m(g,x){k(u,g,x),w=!0},i(g){w||(f(u.$$.fragment,g),w=!0)},o(g){b(u.$$.fragment,g),w=!1},d(g){$(u,g)}}}function Af(W){let u,w;return u=new jf({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/section5_pt.ipynb"},{label:"Aws Studio",value:"https://studiolab.sagemaker.aws/import/github/huggingface/notebooks/blob/master/course/vi/chapter7/section5_pt.ipynb"}]}}),{c(){_(u.$$.fragment)},l(g){y(u.$$.fragment,g)},m(g,x){k(u,g,x),w=!0},i(g){w||(f(u.$$.fragment,g),w=!0)},o(g){b(u.$$.fragment,g),w=!1},d(g){$(u,g)}}}function Of(W){let u,w,g,x,L,E,N,O,q,z,S;return{c(){u=h("p"),w=e("\u270F\uFE0F "),g=h("strong"),x=e("Th\u1EED nghi\u1EC7m th\xF4i!"),L=e(" Thay \u0111\u1ED5i seed ng\u1EABu nhi\xEAn trong l\u1EC7nh "),E=h("code"),N=e("Dataset.shuffle()"),O=e(" \u0111\u1EC3 kh\xE1m ph\xE1 c\xE1c b\xE0i \u0111\xE1nh gi\xE1 kh\xE1c trong kho t\xE0i li\u1EC7u. N\u1EBFu b\u1EA1n l\xE0 ng\u01B0\u1EDDi n\xF3i ti\u1EBFng T\xE2y Ban Nha, h\xE3y xem m\u1ED9t s\u1ED1 b\xE0i \u0111\xE1nh gi\xE1 trong "),q=h("code"),z=e("spanish_dataset"),S=e(" \u0111\u1EC3 xem li\u1EC7u c\xE1c ti\xEAu \u0111\u1EC1 c\xF3 gi\u1ED1ng nh\u01B0 nh\u1EEFng b\u1EA3n t\xF3m t\u1EAFt h\u1EE3p l\xFD hay kh\xF4ng.")},l(A){u=l(A,"P",{});var D=c(u);w=a(D,"\u270F\uFE0F "),g=l(D,"STRONG",{});var I=c(g);x=a(I,"Th\u1EED nghi\u1EC7m th\xF4i!"),I.forEach(s),L=a(D," Thay \u0111\u1ED5i seed ng\u1EABu nhi\xEAn trong l\u1EC7nh "),E=l(D,"CODE",{});var X=c(E);N=a(X,"Dataset.shuffle()"),X.forEach(s),O=a(D," \u0111\u1EC3 kh\xE1m ph\xE1 c\xE1c b\xE0i \u0111\xE1nh gi\xE1 kh\xE1c trong kho t\xE0i li\u1EC7u. N\u1EBFu b\u1EA1n l\xE0 ng\u01B0\u1EDDi n\xF3i ti\u1EBFng T\xE2y Ban Nha, h\xE3y xem m\u1ED9t s\u1ED1 b\xE0i \u0111\xE1nh gi\xE1 trong "),q=l(D,"CODE",{});var K=c(q);z=a(K,"spanish_dataset"),K.forEach(s),S=a(D," \u0111\u1EC3 xem li\u1EC7u c\xE1c ti\xEAu \u0111\u1EC1 c\xF3 gi\u1ED1ng nh\u01B0 nh\u1EEFng b\u1EA3n t\xF3m t\u1EAFt h\u1EE3p l\xFD hay kh\xF4ng."),D.forEach(s)},m(A,D){r(A,u,D),t(u,w),t(u,g),t(g,x),t(u,L),t(u,E),t(E,N),t(u,O),t(u,q),t(q,z),t(u,S)},d(A){A&&s(u)}}}function Pf(W){let u,w,g,x,L,E,N,O;return{c(){u=h("p"),w=e("\u270F\uFE0F "),g=h("strong"),x=e("Th\u1EED nghi\u1EC7m th\xF4i!"),L=e(" Khi b\u1EA1n \u0111\xE3 l\xE0m qua ph\u1EA7n n\xE0y, h\xE3y xem mT5 so v\u1EDBi mBART t\u1ED1t nh\u01B0 th\u1EBF n\xE0o b\u1EB1ng c\xE1ch tinh ch\u1EC9nh ph\u1EA7n sau v\u1EDBi c\xE1c k\u1EF9 thu\u1EADt t\u01B0\u01A1ng t\u1EF1. \u0110\u1EC3 c\xF3 \u0111i\u1EC3m th\u01B0\u1EDFng, b\u1EA1n c\u0169ng c\xF3 th\u1EC3 th\u1EED tinh ch\u1EC9nh T5 ch\u1EC9 tr\xEAn c\xE1c b\xE0i \u0111\xE1nh gi\xE1 ti\u1EBFng Anh. V\xEC T5 c\xF3 ti\u1EC1n t\u1ED1 nh\u1EAFc \u0111\u1EB7c bi\u1EC7t, b\u1EA1n s\u1EBD c\u1EA7n th\xEAm  "),E=h("code"),N=e("summarize:"),O=e(" v\xE0o tr\u01B0\u1EDBc c\xE1c m\u1EABu \u0111\u1EA7u v\xE0o trong c\xE1c b\u01B0\u1EDBc ti\u1EC1n x\u1EED l\xFD b\xEAn d\u01B0\u1EDBi.")},l(q){u=l(q,"P",{});var z=c(u);w=a(z,"\u270F\uFE0F "),g=l(z,"STRONG",{});var S=c(g);x=a(S,"Th\u1EED nghi\u1EC7m th\xF4i!"),S.forEach(s),L=a(z," Khi b\u1EA1n \u0111\xE3 l\xE0m qua ph\u1EA7n n\xE0y, h\xE3y xem mT5 so v\u1EDBi mBART t\u1ED1t nh\u01B0 th\u1EBF n\xE0o b\u1EB1ng c\xE1ch tinh ch\u1EC9nh ph\u1EA7n sau v\u1EDBi c\xE1c k\u1EF9 thu\u1EADt t\u01B0\u01A1ng t\u1EF1. \u0110\u1EC3 c\xF3 \u0111i\u1EC3m th\u01B0\u1EDFng, b\u1EA1n c\u0169ng c\xF3 th\u1EC3 th\u1EED tinh ch\u1EC9nh T5 ch\u1EC9 tr\xEAn c\xE1c b\xE0i \u0111\xE1nh gi\xE1 ti\u1EBFng Anh. V\xEC T5 c\xF3 ti\u1EC1n t\u1ED1 nh\u1EAFc \u0111\u1EB7c bi\u1EC7t, b\u1EA1n s\u1EBD c\u1EA7n th\xEAm  "),E=l(z,"CODE",{});var A=c(E);N=a(A,"summarize:"),A.forEach(s),O=a(z," v\xE0o tr\u01B0\u1EDBc c\xE1c m\u1EABu \u0111\u1EA7u v\xE0o trong c\xE1c b\u01B0\u1EDBc ti\u1EC1n x\u1EED l\xFD b\xEAn d\u01B0\u1EDBi."),z.forEach(s)},m(q,z){r(q,u,z),t(u,w),t(u,g),t(g,x),t(u,L),t(u,E),t(E,N),t(u,O)},d(q){q&&s(u)}}}function Lf(W){let u,w;return{c(){u=h("p"),w=e("\u{1F4A1} Trong giai \u0111o\u1EA1n \u0111\u1EA7u c\u1EE7a c\xE1c d\u1EF1 \xE1n NLP c\u1EE7a b\u1EA1n, m\u1ED9t ph\u01B0\u01A1ng ph\xE1p hay l\xE0 hu\u1EA5n luy\u1EC7n m\u1ED9t l\u1EDBp c\xE1c m\xF4 h\xECnh \u201Cnh\u1ECF\u201D tr\xEAn m\u1ED9t m\u1EABu d\u1EEF li\u1EC7u nh\u1ECF. \u0110i\u1EC1u n\xE0y cho ph\xE9p b\u1EA1n g\u1EE1 l\u1ED7i v\xE0 l\u1EB7p l\u1EA1i nhanh h\u01A1n \u0111\u1ED1i v\u1EDBi quy tr\xECnh l\xE0m vi\u1EC7c \u0111\u1EA7u cu\u1ED1i. M\u1ED9t khi b\u1EA1n t\u1EF1 tin v\xE0o k\u1EBFt qu\u1EA3, b\u1EA1n lu\xF4n c\xF3 th\u1EC3 m\u1EDF r\u1ED9ng m\xF4 h\xECnh b\u1EB1ng c\xE1ch thay \u0111\u1ED5i checkpoint c\u1EE7a m\xF4 h\xECnh!")},l(g){u=l(g,"P",{});var x=c(u);w=a(x,"\u{1F4A1} Trong giai \u0111o\u1EA1n \u0111\u1EA7u c\u1EE7a c\xE1c d\u1EF1 \xE1n NLP c\u1EE7a b\u1EA1n, m\u1ED9t ph\u01B0\u01A1ng ph\xE1p hay l\xE0 hu\u1EA5n luy\u1EC7n m\u1ED9t l\u1EDBp c\xE1c m\xF4 h\xECnh \u201Cnh\u1ECF\u201D tr\xEAn m\u1ED9t m\u1EABu d\u1EEF li\u1EC7u nh\u1ECF. \u0110i\u1EC1u n\xE0y cho ph\xE9p b\u1EA1n g\u1EE1 l\u1ED7i v\xE0 l\u1EB7p l\u1EA1i nhanh h\u01A1n \u0111\u1ED1i v\u1EDBi quy tr\xECnh l\xE0m vi\u1EC7c \u0111\u1EA7u cu\u1ED1i. M\u1ED9t khi b\u1EA1n t\u1EF1 tin v\xE0o k\u1EBFt qu\u1EA3, b\u1EA1n lu\xF4n c\xF3 th\u1EC3 m\u1EDF r\u1ED9ng m\xF4 h\xECnh b\u1EB1ng c\xE1ch thay \u0111\u1ED5i checkpoint c\u1EE7a m\xF4 h\xECnh!"),x.forEach(s)},m(g,x){r(g,u,x),t(u,w)},d(g){g&&s(u)}}}function Nf(W){let u,w,g,x,L,E,N,O,q,z,S;return{c(){u=h("p"),w=e("\u{1F4A1} B\u1EA1n c\xF3 th\u1EC3 nh\u1EADn th\u1EA5y r\u1EB1ng ch\xFAng ta \u0111\xE3 s\u1EED d\u1EE5ng "),g=h("code"),x=e("batched=True"),L=e(" trong h\xE0m"),E=h("code"),N=e("Dataset.map()"),O=e(" \u1EDF tr\xEAn. \u0110i\u1EC1u n\xE0y m\xE3 h\xF3a c\xE1c m\u1EABu theo l\xF4 1,000 (m\u1EB7c \u0111\u1ECBnh) v\xE0 cho ph\xE9p b\u1EA1n s\u1EED d\u1EE5ng kh\u1EA3 n\u0103ng \u0111a lu\u1ED3ng c\u1EE7a c\xE1c b\u1ED9 tokenizer nhanh trong \u{1F917} Transformers. N\u1EBFu c\xF3 th\u1EC3, h\xE3y th\u1EED s\u1EED d\u1EE5ng "),q=h("code"),z=e("batched=True"),S=e(" \u0111\u1EC3 t\u1EADn d\u1EE5ng t\u1ED1i \u0111a qu\xE1 tr\xECnh ti\u1EC1n x\u1EED l\xFD c\u1EE7a b\u1EA1n!")},l(A){u=l(A,"P",{});var D=c(u);w=a(D,"\u{1F4A1} B\u1EA1n c\xF3 th\u1EC3 nh\u1EADn th\u1EA5y r\u1EB1ng ch\xFAng ta \u0111\xE3 s\u1EED d\u1EE5ng "),g=l(D,"CODE",{});var I=c(g);x=a(I,"batched=True"),I.forEach(s),L=a(D," trong h\xE0m"),E=l(D,"CODE",{});var X=c(E);N=a(X,"Dataset.map()"),X.forEach(s),O=a(D," \u1EDF tr\xEAn. \u0110i\u1EC1u n\xE0y m\xE3 h\xF3a c\xE1c m\u1EABu theo l\xF4 1,000 (m\u1EB7c \u0111\u1ECBnh) v\xE0 cho ph\xE9p b\u1EA1n s\u1EED d\u1EE5ng kh\u1EA3 n\u0103ng \u0111a lu\u1ED3ng c\u1EE7a c\xE1c b\u1ED9 tokenizer nhanh trong \u{1F917} Transformers. N\u1EBFu c\xF3 th\u1EC3, h\xE3y th\u1EED s\u1EED d\u1EE5ng "),q=l(D,"CODE",{});var K=c(q);z=a(K,"batched=True"),K.forEach(s),S=a(D," \u0111\u1EC3 t\u1EADn d\u1EE5ng t\u1ED1i \u0111a qu\xE1 tr\xECnh ti\u1EC1n x\u1EED l\xFD c\u1EE7a b\u1EA1n!"),D.forEach(s)},m(A,D){r(A,u,D),t(u,w),t(u,g),t(g,x),t(u,L),t(u,E),t(E,N),t(u,O),t(u,q),t(q,z),t(u,S)},d(A){A&&s(u)}}}function Rf(W){let u,w,g,x,L,E,N;return{c(){u=h("p"),w=e("\u{1F64B} \u0110\u1EEBng lo l\u1EAFng n\u1EBFu \u0111\xE2y l\xE0 l\u1EA7n \u0111\u1EA7u ti\xEAn b\u1EA1n nghe n\xF3i v\u1EC1 precision v\xE0 recall - ch\xFAng ta s\u1EBD c\xF9ng nhau \u0111i\u1EC3m qua m\u1ED9t s\u1ED1 v\xED d\u1EE5 r\xF5 r\xE0ng \u0111\u1EC3 l\xE0m r\xF5 t\u1EA5t c\u1EA3. C\xE1c ch\u1EC9 s\u1ED1 n\xE0y th\u01B0\u1EDDng g\u1EB7p trong c\xE1c t\xE1c v\u1EE5 ph\xE2n lo\u1EA1i, v\xEC v\u1EADy n\u1EBFu b\u1EA1n mu\u1ED1n hi\u1EC3u c\xE1ch x\xE1c \u0111\u1ECBnh precision v\xE0 recall trong ng\u1EEF c\u1EA3nh \u0111\xF3, ch\xFAng t\xF4i khuy\xEAn b\u1EA1n n\xEAn xem "),g=h("a"),x=e("h\u01B0\u1EDBng d\u1EABn "),L=h("code"),E=e("scikit-learn"),N=e("."),this.h()},l(O){u=l(O,"P",{});var q=c(u);w=a(q,"\u{1F64B} \u0110\u1EEBng lo l\u1EAFng n\u1EBFu \u0111\xE2y l\xE0 l\u1EA7n \u0111\u1EA7u ti\xEAn b\u1EA1n nghe n\xF3i v\u1EC1 precision v\xE0 recall - ch\xFAng ta s\u1EBD c\xF9ng nhau \u0111i\u1EC3m qua m\u1ED9t s\u1ED1 v\xED d\u1EE5 r\xF5 r\xE0ng \u0111\u1EC3 l\xE0m r\xF5 t\u1EA5t c\u1EA3. C\xE1c ch\u1EC9 s\u1ED1 n\xE0y th\u01B0\u1EDDng g\u1EB7p trong c\xE1c t\xE1c v\u1EE5 ph\xE2n lo\u1EA1i, v\xEC v\u1EADy n\u1EBFu b\u1EA1n mu\u1ED1n hi\u1EC3u c\xE1ch x\xE1c \u0111\u1ECBnh precision v\xE0 recall trong ng\u1EEF c\u1EA3nh \u0111\xF3, ch\xFAng t\xF4i khuy\xEAn b\u1EA1n n\xEAn xem "),g=l(q,"A",{href:!0,rel:!0});var z=c(g);x=a(z,"h\u01B0\u1EDBng d\u1EABn "),L=l(z,"CODE",{});var S=c(L);E=a(S,"scikit-learn"),S.forEach(s),z.forEach(s),N=a(q,"."),q.forEach(s),this.h()},h(){d(g,"href","https://scikit-learn.org/stable/auto_examples/model_selection/plot_precision_recall.html"),d(g,"rel","nofollow")},m(O,q){r(O,u,q),t(u,w),t(u,g),t(g,x),t(g,L),t(L,E),t(u,N)},d(O){O&&s(u)}}}function Hf(W){let u,w,g,x,L,E,N,O;return{c(){u=h("p"),w=e("\u270F\uFE0F "),g=h("strong"),x=e("Th\u1EED nghi\u1EC7m th\xF4i!"),L=e(" T\u1EA1o v\xED d\u1EE5 c\u1EE7a ri\xEAng b\u1EA1n v\u1EC1 b\u1EA3n t\xF3m t\u1EAFt \u0111\u01B0\u1EE3c t\u1EA1o v\xE0 tham kh\u1EA3o, v\xE0 xem li\u1EC7u \u0111i\u1EC3m k\u1EBFt qu\u1EA3 ROUGE c\xF3 gi\u1ED1ng v\u1EDBi t\xEDnh to\xE1n th\u1EE7 c\xF4ng d\u1EF1a tr\xEAn c\xE1c c\xF4ng th\u1EE9c v\u1EC1 precision v\xE0 recall hay kh\xF4ng. \u0110\u1EC3 c\xF3 \u0111i\u1EC3m th\u01B0\u1EDFng, h\xE3y chia v\u0103n b\u1EA3n th\xE0nh bigrams v\xE0 so s\xE1nh \u0111\u1ED9 ch\xEDnh x\xE1c v\xE0 thu h\u1ED3i cho ch\u1EC9 s\u1ED1 "),E=h("code"),N=e("rouge2"),O=e(".")},l(q){u=l(q,"P",{});var z=c(u);w=a(z,"\u270F\uFE0F "),g=l(z,"STRONG",{});var S=c(g);x=a(S,"Th\u1EED nghi\u1EC7m th\xF4i!"),S.forEach(s),L=a(z," T\u1EA1o v\xED d\u1EE5 c\u1EE7a ri\xEAng b\u1EA1n v\u1EC1 b\u1EA3n t\xF3m t\u1EAFt \u0111\u01B0\u1EE3c t\u1EA1o v\xE0 tham kh\u1EA3o, v\xE0 xem li\u1EC7u \u0111i\u1EC3m k\u1EBFt qu\u1EA3 ROUGE c\xF3 gi\u1ED1ng v\u1EDBi t\xEDnh to\xE1n th\u1EE7 c\xF4ng d\u1EF1a tr\xEAn c\xE1c c\xF4ng th\u1EE9c v\u1EC1 precision v\xE0 recall hay kh\xF4ng. \u0110\u1EC3 c\xF3 \u0111i\u1EC3m th\u01B0\u1EDFng, h\xE3y chia v\u0103n b\u1EA3n th\xE0nh bigrams v\xE0 so s\xE1nh \u0111\u1ED9 ch\xEDnh x\xE1c v\xE0 thu h\u1ED3i cho ch\u1EC9 s\u1ED1 "),E=l(z,"CODE",{});var A=c(E);N=a(A,"rouge2"),A.forEach(s),O=a(z,"."),z.forEach(s)},m(q,z){r(q,u,z),t(u,w),t(u,g),t(g,x),t(u,L),t(u,E),t(E,N),t(u,O)},d(q){q&&s(u)}}}function If(W){let u,w,g,x,L,E,N,O,q,z,S,A,D,I,X,K,J,M,Y;return x=new Xt({}),M=new C({props:{code:`from transformers import TFAutoModelForSeq2SeqLM

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

model = TFAutoModelForSeq2SeqLM.from_pretrained(model_checkpoint)`}}),{c(){u=h("h2"),w=h("a"),g=h("span"),_(x.$$.fragment),L=m(),E=h("span"),N=e("Tinh ch\u1EC9nh mT5 v\u1EDBi Keras"),O=m(),q=h("p"),z=e("Vi\u1EC7c tinh ch\u1EC9nh m\u1ED9t m\xF4 h\xECnh \u0111\u1EC3 t\xF3m t\u1EAFt r\u1EA5t gi\u1ED1ng v\u1EDBi c\xE1c t\xE1c v\u1EE5 kh\xE1c m\xE0 ch\xFAng ta \u0111\xE3 \u0111\u1EC1 c\u1EADp trong ch\u01B0\u01A1ng n\xE0y. \u0110i\u1EC1u \u0111\u1EA7u ti\xEAn ch\xFAng ta c\u1EA7n l\xE0m l\xE0 t\u1EA3i m\xF4 h\xECnh \u0111\u01B0\u1EE3c hu\u1EA5n luy\u1EC7n tr\u01B0\u1EDBc t\u1EEB checkpoint "),S=h("code"),A=e("mt5-small"),D=e(". V\xEC t\xF3m t\u1EAFt l\xE0 m\u1ED9t t\xE1c v\u1EE5 chu\u1ED7i sang chu\u1ED7i, ch\xFAng ta c\xF3 th\u1EC3 t\u1EA3i m\xF4 h\xECnh b\u1EB1ng l\u1EDBp "),I=h("code"),X=e("TFAutoModelForSeq2SeqLM"),K=e(", l\u1EDBp n\xE0y s\u1EBD t\u1EF1 \u0111\u1ED9ng t\u1EA3i xu\u1ED1ng v\xE0 l\u01B0u v\xE0o b\u1ED9 nh\u1EDB cache c\xE1c tr\u1ECDng s\u1ED1:"),J=m(),_(M.$$.fragment),this.h()},l(P){u=l(P,"H2",{class:!0});var U=c(u);w=l(U,"A",{id:!0,class:!0,href:!0});var G=c(w);g=l(G,"SPAN",{});var Q=c(g);y(x.$$.fragment,Q),Q.forEach(s),G.forEach(s),L=p(U),E=l(U,"SPAN",{});var an=c(E);N=a(an,"Tinh ch\u1EC9nh mT5 v\u1EDBi Keras"),an.forEach(s),U.forEach(s),O=p(P),q=l(P,"P",{});var tn=c(q);z=a(tn,"Vi\u1EC7c tinh ch\u1EC9nh m\u1ED9t m\xF4 h\xECnh \u0111\u1EC3 t\xF3m t\u1EAFt r\u1EA5t gi\u1ED1ng v\u1EDBi c\xE1c t\xE1c v\u1EE5 kh\xE1c m\xE0 ch\xFAng ta \u0111\xE3 \u0111\u1EC1 c\u1EADp trong ch\u01B0\u01A1ng n\xE0y. \u0110i\u1EC1u \u0111\u1EA7u ti\xEAn ch\xFAng ta c\u1EA7n l\xE0m l\xE0 t\u1EA3i m\xF4 h\xECnh \u0111\u01B0\u1EE3c hu\u1EA5n luy\u1EC7n tr\u01B0\u1EDBc t\u1EEB checkpoint "),S=l(tn,"CODE",{});var B=c(S);A=a(B,"mt5-small"),B.forEach(s),D=a(tn,". V\xEC t\xF3m t\u1EAFt l\xE0 m\u1ED9t t\xE1c v\u1EE5 chu\u1ED7i sang chu\u1ED7i, ch\xFAng ta c\xF3 th\u1EC3 t\u1EA3i m\xF4 h\xECnh b\u1EB1ng l\u1EDBp "),I=l(tn,"CODE",{});var sn=c(I);X=a(sn,"TFAutoModelForSeq2SeqLM"),sn.forEach(s),K=a(tn,", l\u1EDBp n\xE0y s\u1EBD t\u1EF1 \u0111\u1ED9ng t\u1EA3i xu\u1ED1ng v\xE0 l\u01B0u v\xE0o b\u1ED9 nh\u1EDB cache c\xE1c tr\u1ECDng s\u1ED1:"),tn.forEach(s),J=p(P),y(M.$$.fragment,P),this.h()},h(){d(w,"id","tinh-chnh-mt5-vi-keras"),d(w,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),d(w,"href","#tinh-chnh-mt5-vi-keras"),d(u,"class","relative group")},m(P,U){r(P,u,U),t(u,w),t(w,g),k(x,g,null),t(u,L),t(u,E),t(E,N),r(P,O,U),r(P,q,U),t(q,z),t(q,S),t(S,A),t(q,D),t(q,I),t(I,X),t(q,K),r(P,J,U),k(M,P,U),Y=!0},i(P){Y||(f(x.$$.fragment,P),f(M.$$.fragment,P),Y=!0)},o(P){b(x.$$.fragment,P),b(M.$$.fragment,P),Y=!1},d(P){P&&s(u),$(x),P&&s(O),P&&s(q),P&&s(J),$(M,P)}}}function Gf(W){let u,w,g,x,L,E,N,O,q,z,S,A,D,I,X,K,J,M,Y,P,U;return x=new Xt({}),P=new C({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(){u=h("h2"),w=h("a"),g=h("span"),_(x.$$.fragment),L=m(),E=h("span"),N=e("Tinh ch\u1EC9nh mT5 v\u1EDBi API "),O=h("code"),q=e("Trainer"),z=m(),S=h("p"),A=e("Vi\u1EC7c tinh ch\u1EC9nh m\u1ED9t m\xF4 h\xECnh \u0111\u1EC3 t\xF3m t\u1EAFt r\u1EA5t gi\u1ED1ng v\u1EDBi c\xE1c t\xE1c v\u1EE5 kh\xE1c m\xE0 ch\xFAng ta \u0111\xE3 \u0111\u1EC1 c\u1EADp trong ch\u01B0\u01A1ng n\xE0y. \u0110i\u1EC1u \u0111\u1EA7u ti\xEAn ch\xFAng ta c\u1EA7n l\xE0m l\xE0 t\u1EA3i m\xF4 h\xECnh \u0111\u01B0\u1EE3c hu\u1EA5n luy\u1EC7n tr\u01B0\u1EDBc t\u1EEB checkpoint "),D=h("code"),I=e("mt5-small"),X=e(". V\xEC t\xF3m t\u1EAFt l\xE0 m\u1ED9t t\xE1c v\u1EE5 chu\u1ED7i sang chu\u1ED7i, ch\xFAng ta c\xF3 th\u1EC3 t\u1EA3i m\xF4 h\xECnh b\u1EB1ng l\u1EDBp "),K=h("code"),J=e("AutoModelForSeq2SeqLM"),M=e(", l\u1EDBp n\xE0y s\u1EBD t\u1EF1 \u0111\u1ED9ng t\u1EA3i xu\u1ED1ng v\xE0 l\u01B0u v\xE0o b\u1ED9 nh\u1EDB cache c\xE1c tr\u1ECDng s\u1ED1:"),Y=m(),_(P.$$.fragment),this.h()},l(G){u=l(G,"H2",{class:!0});var Q=c(u);w=l(Q,"A",{id:!0,class:!0,href:!0});var an=c(w);g=l(an,"SPAN",{});var tn=c(g);y(x.$$.fragment,tn),tn.forEach(s),an.forEach(s),L=p(Q),E=l(Q,"SPAN",{});var B=c(E);N=a(B,"Tinh ch\u1EC9nh mT5 v\u1EDBi API "),O=l(B,"CODE",{});var sn=c(O);q=a(sn,"Trainer"),sn.forEach(s),B.forEach(s),Q.forEach(s),z=p(G),S=l(G,"P",{});var F=c(S);A=a(F,"Vi\u1EC7c tinh ch\u1EC9nh m\u1ED9t m\xF4 h\xECnh \u0111\u1EC3 t\xF3m t\u1EAFt r\u1EA5t gi\u1ED1ng v\u1EDBi c\xE1c t\xE1c v\u1EE5 kh\xE1c m\xE0 ch\xFAng ta \u0111\xE3 \u0111\u1EC1 c\u1EADp trong ch\u01B0\u01A1ng n\xE0y. \u0110i\u1EC1u \u0111\u1EA7u ti\xEAn ch\xFAng ta c\u1EA7n l\xE0m l\xE0 t\u1EA3i m\xF4 h\xECnh \u0111\u01B0\u1EE3c hu\u1EA5n luy\u1EC7n tr\u01B0\u1EDBc t\u1EEB checkpoint "),D=l(F,"CODE",{});var rn=c(D);I=a(rn,"mt5-small"),rn.forEach(s),X=a(F,". V\xEC t\xF3m t\u1EAFt l\xE0 m\u1ED9t t\xE1c v\u1EE5 chu\u1ED7i sang chu\u1ED7i, ch\xFAng ta c\xF3 th\u1EC3 t\u1EA3i m\xF4 h\xECnh b\u1EB1ng l\u1EDBp "),K=l(F,"CODE",{});var gn=c(K);J=a(gn,"AutoModelForSeq2SeqLM"),gn.forEach(s),M=a(F,", l\u1EDBp n\xE0y s\u1EBD t\u1EF1 \u0111\u1ED9ng t\u1EA3i xu\u1ED1ng v\xE0 l\u01B0u v\xE0o b\u1ED9 nh\u1EDB cache c\xE1c tr\u1ECDng s\u1ED1:"),F.forEach(s),Y=p(G),y(P.$$.fragment,G),this.h()},h(){d(w,"id","tinh-chnh-mt5-vi-api-trainer"),d(w,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),d(w,"href","#tinh-chnh-mt5-vi-api-trainer"),d(u,"class","relative group")},m(G,Q){r(G,u,Q),t(u,w),t(w,g),k(x,g,null),t(u,L),t(u,E),t(E,N),t(E,O),t(O,q),r(G,z,Q),r(G,S,Q),t(S,A),t(S,D),t(D,I),t(S,X),t(S,K),t(K,J),t(S,M),r(G,Y,Q),k(P,G,Q),U=!0},i(G){U||(f(x.$$.fragment,G),f(P.$$.fragment,G),U=!0)},o(G){b(x.$$.fragment,G),b(P.$$.fragment,G),U=!1},d(G){G&&s(u),$(x),G&&s(z),G&&s(S),G&&s(Y),$(P,G)}}}function Mf(W){let u,w,g,x,L;return{c(){u=h("p"),w=e("\u{1F4A1} N\u1EBFu b\u1EA1n \u0111ang t\u1EF1 h\u1ECFi t\u1EA1i sao b\u1EA1n kh\xF4ng th\u1EA5y b\u1EA5t k\u1EF3 c\u1EA3nh b\xE1o n\xE0o v\u1EC1 vi\u1EC7c tinh ch\u1EC9nh m\xF4 h\xECnh tr\xEAn m\u1ED9t t\xE1c v\u1EE5 ph\xEDa sau, \u0111\xF3 l\xE0 b\u1EDFi v\xEC \u0111\u1ED1i v\u1EDBi c\xE1c t\xE1c v\u1EE5 chu\u1ED7i sang chu\u1ED7i, ch\xFAng ta gi\u1EEF t\u1EA5t c\u1EA3 c\xE1c tr\u1ECDng s\u1ED1 c\u1EE7a m\u1EA1ng. So s\xE1nh m\xF4 h\xECnh n\xE0y v\u1EDBi m\xF4 h\xECnh ph\xE2n lo\u1EA1i v\u0103n b\u1EA3n trong "),g=h("a"),x=e("Ch\u01B0\u01A1ng 3"),L=e(", trong \u0111\xF3 ph\u1EA7n \u0111\u1EA7u c\u1EE7a m\xF4 h\xECnh \u0111\u1ECBnh s\u1EB5n \u0111\u01B0\u1EE3c thay th\u1EBF b\u1EB1ng m\u1ED9t m\u1EA1ng \u0111\u01B0\u1EE3c kh\u1EDFi t\u1EA1o ng\u1EABu nhi\xEAn."),this.h()},l(E){u=l(E,"P",{});var N=c(u);w=a(N,"\u{1F4A1} N\u1EBFu b\u1EA1n \u0111ang t\u1EF1 h\u1ECFi t\u1EA1i sao b\u1EA1n kh\xF4ng th\u1EA5y b\u1EA5t k\u1EF3 c\u1EA3nh b\xE1o n\xE0o v\u1EC1 vi\u1EC7c tinh ch\u1EC9nh m\xF4 h\xECnh tr\xEAn m\u1ED9t t\xE1c v\u1EE5 ph\xEDa sau, \u0111\xF3 l\xE0 b\u1EDFi v\xEC \u0111\u1ED1i v\u1EDBi c\xE1c t\xE1c v\u1EE5 chu\u1ED7i sang chu\u1ED7i, ch\xFAng ta gi\u1EEF t\u1EA5t c\u1EA3 c\xE1c tr\u1ECDng s\u1ED1 c\u1EE7a m\u1EA1ng. So s\xE1nh m\xF4 h\xECnh n\xE0y v\u1EDBi m\xF4 h\xECnh ph\xE2n lo\u1EA1i v\u0103n b\u1EA3n trong "),g=l(N,"A",{href:!0});var O=c(g);x=a(O,"Ch\u01B0\u01A1ng 3"),O.forEach(s),L=a(N,", trong \u0111\xF3 ph\u1EA7n \u0111\u1EA7u c\u1EE7a m\xF4 h\xECnh \u0111\u1ECBnh s\u1EB5n \u0111\u01B0\u1EE3c thay th\u1EBF b\u1EB1ng m\u1ED9t m\u1EA1ng \u0111\u01B0\u1EE3c kh\u1EDFi t\u1EA1o ng\u1EABu nhi\xEAn."),N.forEach(s),this.h()},h(){d(g,"href","/course/chapter3")},m(E,N){r(E,u,N),t(u,w),t(u,g),t(g,x),t(u,L)},d(E){E&&s(u)}}}function kf(W){let u,w,g,x,L,E,N,O,q,z,S,A,D,I,X,K,J,M,Y,P,U,G,Q,an,tn,B,sn,F,rn,gn,qn,vn,Z,_n,pn,nn,yn,kn,hn,Dn,dn,on,v,R,mn,j,V,$n,jn,un,Tn,en,Un,tt,cn,wn,Rn,Sn,wt,ln,Yt,vt,ct,st,rt,Bn,xt,Wn,_t,Et,An,it,et,ot;return z=new C({props:{code:`from transformers import Seq2SeqTrainingArguments

batch_size = 8
num_train_epochs = 8
# Hi\u1EC7n th\u1ECB m\u1EA5t m\xE1t hu\u1EA5n luy\u1EC7n m\u1ED7i epoch
logging_steps = len(tokenized_datasets["train"]) // batch_size
model_name = model_checkpoint.split("/")[-1]

args = Seq2SeqTrainingArguments(
    output_dir=f"{model_name}-finetuned-amazon-en-es",
    evaluation_strategy="epoch",
    learning_rate=5.6e-5,
    per_device_train_batch_size=batch_size,
    per_device_eval_batch_size=batch_size,
    weight_decay=0.01,
    save_total_limit=3,
    num_train_epochs=num_train_epochs,
    predict_with_generate=True,
    logging_steps=logging_steps,
    push_to_hub=True,
)`,highlighted:`<span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> Seq2SeqTrainingArguments

batch_size = <span class="hljs-number">8</span>
num_train_epochs = <span class="hljs-number">8</span>
<span class="hljs-comment"># Hi\u1EC7n th\u1ECB m\u1EA5t m\xE1t hu\u1EA5n luy\u1EC7n m\u1ED7i epoch</span>
logging_steps = <span class="hljs-built_in">len</span>(tokenized_datasets[<span class="hljs-string">&quot;train&quot;</span>]) // batch_size
model_name = model_checkpoint.split(<span class="hljs-string">&quot;/&quot;</span>)[-<span class="hljs-number">1</span>]

args = Seq2SeqTrainingArguments(
    output_dir=<span class="hljs-string">f&quot;<span class="hljs-subst">{model_name}</span>-finetuned-amazon-en-es&quot;</span>,
    evaluation_strategy=<span class="hljs-string">&quot;epoch&quot;</span>,
    learning_rate=<span class="hljs-number">5.6e-5</span>,
    per_device_train_batch_size=batch_size,
    per_device_eval_batch_size=batch_size,
    weight_decay=<span class="hljs-number">0.01</span>,
    save_total_limit=<span class="hljs-number">3</span>,
    num_train_epochs=num_train_epochs,
    predict_with_generate=<span class="hljs-literal">True</span>,
    logging_steps=logging_steps,
    push_to_hub=<span class="hljs-literal">True</span>,
)`}}),et=new C({props:{code:`import numpy as np


def compute_metrics(eval_pred):
    predictions, labels = eval_pred
    # Gi\u1EA3i m\xE3 c\xE1c t\xF3m t\u1EAFt \u0111\u01B0\u1EE3c t\u1EA1o ra th\xE0nh v\u0103n b\u1EA3n
    decoded_preds = tokenizer.batch_decode(predictions, skip_special_tokens=True)
    # Thay -100 v\xE0o nh\xE3n v\xEC ta kh\xF4ng th\u1EC3 gi\u1EA3i m\xE3 ch\xFAng
    labels = np.where(labels != -100, labels, tokenizer.pad_token_id)
    # Gi\u1EA3i m\xE3 c\xE1c t\xF3m t\u1EAFt m\u1EABu th\xE0nh v\u0103n b\u1EA3n
    decoded_labels = tokenizer.batch_decode(labels, skip_special_tokens=True)
    # ROUGE k\xEC v\u1ECDng d\xF2ng m\u1EDBi sau m\u1ED7i c\xE2u
    decoded_preds = ["\\n".join(sent_tokenize(pred.strip())) for pred in decoded_preds]
    decoded_labels = ["\\n".join(sent_tokenize(label.strip())) for label in decoded_labels]
    # T\xEDnh \u0111i\u1EC3m ROUGE
    result = rouge_score.compute(
        predictions=decoded_preds, references=decoded_labels, use_stemmer=True
    )
    # Tr\xEDch xu\u1EA5t \u0111i\u1EC3m trung v\u1ECB
    result = {key: value.mid.fmeasure * 100 for key, value in result.items()}
    return {k: round(v, 4) for k, v in result.items()}`,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_pred</span>):
    predictions, labels = eval_pred
    <span class="hljs-comment"># Gi\u1EA3i m\xE3 c\xE1c t\xF3m t\u1EAFt \u0111\u01B0\u1EE3c t\u1EA1o ra th\xE0nh v\u0103n b\u1EA3n</span>
    decoded_preds = tokenizer.batch_decode(predictions, skip_special_tokens=<span class="hljs-literal">True</span>)
    <span class="hljs-comment"># Thay -100 v\xE0o nh\xE3n v\xEC ta kh\xF4ng th\u1EC3 gi\u1EA3i m\xE3 ch\xFAng</span>
    labels = np.where(labels != -<span class="hljs-number">100</span>, labels, tokenizer.pad_token_id)
    <span class="hljs-comment"># Gi\u1EA3i m\xE3 c\xE1c t\xF3m t\u1EAFt m\u1EABu th\xE0nh v\u0103n b\u1EA3n</span>
    decoded_labels = tokenizer.batch_decode(labels, skip_special_tokens=<span class="hljs-literal">True</span>)
    <span class="hljs-comment"># ROUGE k\xEC v\u1ECDng d\xF2ng m\u1EDBi sau m\u1ED7i c\xE2u</span>
    decoded_preds = [<span class="hljs-string">&quot;\\n&quot;</span>.join(sent_tokenize(pred.strip())) <span class="hljs-keyword">for</span> pred <span class="hljs-keyword">in</span> decoded_preds]
    decoded_labels = [<span class="hljs-string">&quot;\\n&quot;</span>.join(sent_tokenize(label.strip())) <span class="hljs-keyword">for</span> label <span class="hljs-keyword">in</span> decoded_labels]
    <span class="hljs-comment"># T\xEDnh \u0111i\u1EC3m ROUGE</span>
    result = rouge_score.compute(
        predictions=decoded_preds, references=decoded_labels, use_stemmer=<span class="hljs-literal">True</span>
    )
    <span class="hljs-comment"># Tr\xEDch xu\u1EA5t \u0111i\u1EC3m trung v\u1ECB</span>
    result = {key: value.mid.fmeasure * <span class="hljs-number">100</span> <span class="hljs-keyword">for</span> key, value <span class="hljs-keyword">in</span> result.items()}
    <span class="hljs-keyword">return</span> {k: <span class="hljs-built_in">round</span>(v, <span class="hljs-number">4</span>) <span class="hljs-keyword">for</span> k, v <span class="hljs-keyword">in</span> result.items()}`}}),{c(){u=h("p"),w=e("Ch\xFAng ta s\u1EBD c\u1EA7n t\u1EA1o t\xF3m t\u1EAFt \u0111\u1EC3 t\xEDnh \u0111i\u1EC3m ROUGE trong qu\xE1 tr\xECnh hu\u1EA5n luy\u1EC7n. May m\u1EAFn thay, \u{1F917} Transformers cung c\u1EA5p c\xE1c l\u1EDBp "),g=h("code"),x=e("Seq2SeqTrainingArguments"),L=e(" v\xE0 "),E=h("code"),N=e("Seq2SeqTrainer"),O=e(" chuy\xEAn d\u1EE5ng c\xF3 th\u1EC3 t\u1EF1 \u0111\u1ED9ng l\xE0m vi\u1EC7c n\xE0y cho ch\xFAng ta! \u0110\u1EC3 xem c\xE1ch n\xE0y ho\u1EA1t \u0111\u1ED9ng nh\u01B0 th\u1EBF n\xE0o, tr\u01B0\u1EDBc ti\xEAn ch\xFAng ta h\xE3y x\xE1c \u0111\u1ECBnh c\xE1c si\xEAu tham s\u1ED1 v\xE0 c\xE1c tham s\u1ED1 kh\xE1c cho c\xE1c th\u1EED nghi\u1EC7m c\u1EE7a m\xECnh:"),q=m(),_(z.$$.fragment),S=m(),A=h("p"),D=e("\u1EDE \u0111\xE2y, tham s\u1ED1 "),I=h("code"),X=e("predict_with_generate"),K=e(" \u0111\xE3 \u0111\u01B0\u1EE3c \u0111\u1EB7t \u0111\u1EC3 ch\u1EC9 ra r\u1EB1ng ch\xFAng ta n\xEAn t\u1EA1o c\xE1c b\u1EA3n t\xF3m t\u1EAFt trong qu\xE1 tr\xECnh \u0111\xE1nh gi\xE1 \u0111\u1EC3 c\xF3 th\u1EC3 t\xEDnh to\xE1n \u0111i\u1EC3m ROUGE cho m\u1ED7i epoch. Nh\u01B0 \u0111\xE3 th\u1EA3o lu\u1EADn trong "),J=h("a"),M=e("Ch\u01B0\u01A1ng 1"),Y=e(", b\u1ED9 gi\u1EA3i m\xE3 th\u1EF1c hi\u1EC7n lu\u1EADn suy b\u1EB1ng c\xE1ch d\u1EF1 \u0111o\xE1n t\u1EEBng token v\xE0 \u0111i\u1EC1u n\xE0y \u0111\u01B0\u1EE3c th\u1EF1c hi\u1EC7n b\u1EDFi ph\u01B0\u01A1ng th\u1EE9c "),P=h("code"),U=e("generate()"),G=e(" c\u1EE7a m\xF4 h\xECnh. \u0110\u1EB7t "),Q=h("code"),an=e("predict_with_generate=True"),tn=e(" s\u1EBD cho "),B=h("code"),sn=e("Seq2SeqTrainer"),F=e(" s\u1EED d\u1EE5ng ph\u01B0\u01A1ng ph\xE1p \u0111\xF3 \u0111\u1EC3 \u0111\xE1nh gi\xE1. Ch\xFAng ta c\u0169ng \u0111\xE3 \u0111i\u1EC1u ch\u1EC9nh m\u1ED9t s\u1ED1 si\xEAu tham s\u1ED1 m\u1EB7c \u0111\u1ECBnh, nh\u01B0 t\u1ED1c \u0111\u1ED9 h\u1ECDc, s\u1ED1 epoch v\xE0 gi\u1EA3m tr\u1ECDng s\u1ED1 v\xE0 ch\xFAng ta \u0111\xE3 \u0111\u1EB7t t\xF9y ch\u1ECDn "),rn=h("code"),gn=e("save_total_limit"),qn=e(" \u0111\u1EC3 ch\u1EC9 l\u01B0u t\u1ED1i \u0111a 3 checkpoint trong qu\xE1 tr\xECnh hu\u1EA5n luy\u1EC7n - \u0111i\u1EC1u n\xE0y l\xE0 do ngay c\u1EA3 phi\xEAn b\u1EA3n \u201Cnh\u1ECF\u201D c\u1EE7a mT5 s\u1EED d\u1EE5ng kho\u1EA3ng m\u1ED9t GB dung l\u01B0\u1EE3ng \u1ED5 c\u1EE9ng v\xE0 ch\xFAng ta c\xF3 th\u1EC3 ti\u1EBFt ki\u1EC7m m\u1ED9t ch\xFAt dung l\u01B0\u1EE3ng b\u1EB1ng c\xE1ch gi\u1EDBi h\u1EA1n s\u1ED1 l\u01B0\u1EE3ng b\u1EA3n sao ta l\u01B0u."),vn=m(),Z=h("p"),_n=e("Tham s\u1ED1 "),pn=h("code"),nn=e("push_to_hub=True"),yn=e(" s\u1EBD cho ph\xE9p ch\xFAng ta \u0111\u1EA9y m\xF4 h\xECnh v\xE0o Hub sau khi hu\u1EA5n luy\u1EC7n; b\u1EA1n s\u1EBD t\xECm th\u1EA5y kho l\u01B0u tr\u1EEF b\xEAn d\u01B0\u1EDBi h\u1ED3 s\u01A1 ng\u01B0\u1EDDi d\xF9ng c\u1EE7a m\xECnh \u1EDF v\u1ECB tr\xED \u0111\u01B0\u1EE3c x\xE1c \u0111\u1ECBnh b\u1EDFi "),kn=h("code"),hn=e("output_dir"),Dn=e(". 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 \u0111\u1EBFn b\u1EB1ng tham s\u1ED1 "),dn=h("code"),on=e("hub_model_id"),v=e(" (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 \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 "),R=h("a"),mn=h("code"),j=e("huggingface-course"),V=e(", ch\xFAng ta \u0111\xE3 th\xEAm "),$n=h("code"),jn=e('hub_model_id="huggingface-course/mt5-finetuned-amazon-en-es"'),un=e(" th\xE0nh "),Tn=h("code"),en=e("Seq2SeqTrainingArguments"),Un=e("."),tt=m(),cn=h("p"),wn=e("\u0110i\u1EC1u ti\u1EBFp theo ch\xFAng ta c\u1EA7n l\xE0m l\xE0 cung c\u1EA5p cho ng\u01B0\u1EDDi hu\u1EA5n luy\u1EC7n m\u1ED9t h\xE0m "),Rn=h("code"),Sn=e("compute_metrics()"),wt=e(" \u0111\u1EC3 ch\xFAng ta c\xF3 th\u1EC3 \u0111\xE1nh gi\xE1 m\xF4 h\xECnh c\u1EE7a m\xECnh trong qu\xE1 tr\xECnh hu\u1EA5n luy\u1EC7n. \u0110\u1EC3 t\xF3m t\u1EAFt, \u0111i\u1EC1u n\xE0y c\u1EA7n nhi\u1EC1u h\u01A1n l\xE0 \u0111\u01A1n gi\u1EA3n g\u1ECDi "),ln=h("code"),Yt=e("rouge_score.compute()"),vt=e(" tr\xEAn c\xE1c d\u1EF1 \u0111o\xE1n c\u1EE7a m\xF4 h\xECnh, v\xEC ch\xFAng ta c\u1EA7n "),ct=h("em"),st=e("gi\u1EA3i m\xE3"),rt=e(" c\xE1c k\u1EBFt qu\u1EA3 \u0111\u1EA7u ra v\xE0 nh\xE3n th\xE0nh v\u0103n b\u1EA3n tr\u01B0\u1EDBc khi ch\xFAng ta c\xF3 th\u1EC3 t\xEDnh \u0111i\u1EC3m ROUGE. H\xE0m sau th\u1EF1c hi\u1EC7n ch\xEDnh x\xE1c \u0111i\u1EC1u \u0111\xF3 v\xE0 c\u0169ng s\u1EED d\u1EE5ng h\xE0m "),Bn=h("code"),xt=e("sent_tokenize()"),Wn=e(" t\u1EEB "),_t=h("code"),Et=e("nltk"),An=e(" \u0111\u1EC3 t\xE1ch c\xE1c c\xE2u t\xF3m t\u1EAFt b\u1EB1ng c\xE1c d\xF2ng m\u1EDBi:"),it=m(),_(et.$$.fragment),this.h()},l(H){u=l(H,"P",{});var fn=c(u);w=a(fn,"Ch\xFAng ta s\u1EBD c\u1EA7n t\u1EA1o t\xF3m t\u1EAFt \u0111\u1EC3 t\xEDnh \u0111i\u1EC3m ROUGE trong qu\xE1 tr\xECnh hu\u1EA5n luy\u1EC7n. May m\u1EAFn thay, \u{1F917} Transformers cung c\u1EA5p c\xE1c l\u1EDBp "),g=l(fn,"CODE",{});var yt=c(g);x=a(yt,"Seq2SeqTrainingArguments"),yt.forEach(s),L=a(fn," v\xE0 "),E=l(fn,"CODE",{});var qt=c(E);N=a(qt,"Seq2SeqTrainer"),qt.forEach(s),O=a(fn," chuy\xEAn d\u1EE5ng c\xF3 th\u1EC3 t\u1EF1 \u0111\u1ED9ng l\xE0m vi\u1EC7c n\xE0y cho ch\xFAng ta! \u0110\u1EC3 xem c\xE1ch n\xE0y ho\u1EA1t \u0111\u1ED9ng nh\u01B0 th\u1EBF n\xE0o, tr\u01B0\u1EDBc ti\xEAn ch\xFAng ta h\xE3y x\xE1c \u0111\u1ECBnh c\xE1c si\xEAu tham s\u1ED1 v\xE0 c\xE1c tham s\u1ED1 kh\xE1c cho c\xE1c th\u1EED nghi\u1EC7m c\u1EE7a m\xECnh:"),fn.forEach(s),q=p(H),y(z.$$.fragment,H),S=p(H),A=l(H,"P",{});var xn=c(A);D=a(xn,"\u1EDE \u0111\xE2y, tham s\u1ED1 "),I=l(xn,"CODE",{});var Tt=c(I);X=a(Tt,"predict_with_generate"),Tt.forEach(s),K=a(xn," \u0111\xE3 \u0111\u01B0\u1EE3c \u0111\u1EB7t \u0111\u1EC3 ch\u1EC9 ra r\u1EB1ng ch\xFAng ta n\xEAn t\u1EA1o c\xE1c b\u1EA3n t\xF3m t\u1EAFt trong qu\xE1 tr\xECnh \u0111\xE1nh gi\xE1 \u0111\u1EC3 c\xF3 th\u1EC3 t\xEDnh to\xE1n \u0111i\u1EC3m ROUGE cho m\u1ED7i epoch. Nh\u01B0 \u0111\xE3 th\u1EA3o lu\u1EADn trong "),J=l(xn,"A",{href:!0});var Fn=c(J);M=a(Fn,"Ch\u01B0\u01A1ng 1"),Fn.forEach(s),Y=a(xn,", b\u1ED9 gi\u1EA3i m\xE3 th\u1EF1c hi\u1EC7n lu\u1EADn suy b\u1EB1ng c\xE1ch d\u1EF1 \u0111o\xE1n t\u1EEBng token v\xE0 \u0111i\u1EC1u n\xE0y \u0111\u01B0\u1EE3c th\u1EF1c hi\u1EC7n b\u1EDFi ph\u01B0\u01A1ng th\u1EE9c "),P=l(xn,"CODE",{});var Qt=c(P);U=a(Qt,"generate()"),Qt.forEach(s),G=a(xn," c\u1EE7a m\xF4 h\xECnh. \u0110\u1EB7t "),Q=l(xn,"CODE",{});var at=c(Q);an=a(at,"predict_with_generate=True"),at.forEach(s),tn=a(xn," s\u1EBD cho "),B=l(xn,"CODE",{});var ht=c(B);sn=a(ht,"Seq2SeqTrainer"),ht.forEach(s),F=a(xn," s\u1EED d\u1EE5ng ph\u01B0\u01A1ng ph\xE1p \u0111\xF3 \u0111\u1EC3 \u0111\xE1nh gi\xE1. Ch\xFAng ta c\u0169ng \u0111\xE3 \u0111i\u1EC1u ch\u1EC9nh m\u1ED9t s\u1ED1 si\xEAu tham s\u1ED1 m\u1EB7c \u0111\u1ECBnh, nh\u01B0 t\u1ED1c \u0111\u1ED9 h\u1ECDc, s\u1ED1 epoch v\xE0 gi\u1EA3m tr\u1ECDng s\u1ED1 v\xE0 ch\xFAng ta \u0111\xE3 \u0111\u1EB7t t\xF9y ch\u1ECDn "),rn=l(xn,"CODE",{});var Xn=c(rn);gn=a(Xn,"save_total_limit"),Xn.forEach(s),qn=a(xn," \u0111\u1EC3 ch\u1EC9 l\u01B0u t\u1ED1i \u0111a 3 checkpoint trong qu\xE1 tr\xECnh hu\u1EA5n luy\u1EC7n - \u0111i\u1EC1u n\xE0y l\xE0 do ngay c\u1EA3 phi\xEAn b\u1EA3n \u201Cnh\u1ECF\u201D c\u1EE7a mT5 s\u1EED d\u1EE5ng kho\u1EA3ng m\u1ED9t GB dung l\u01B0\u1EE3ng \u1ED5 c\u1EE9ng v\xE0 ch\xFAng ta c\xF3 th\u1EC3 ti\u1EBFt ki\u1EC7m m\u1ED9t ch\xFAt dung l\u01B0\u1EE3ng b\u1EB1ng c\xE1ch gi\u1EDBi h\u1EA1n s\u1ED1 l\u01B0\u1EE3ng b\u1EA3n sao ta l\u01B0u."),xn.forEach(s),vn=p(H),Z=l(H,"P",{});var bn=c(Z);_n=a(bn,"Tham s\u1ED1 "),pn=l(bn,"CODE",{});var Vn=c(pn);nn=a(Vn,"push_to_hub=True"),Vn.forEach(s),yn=a(bn," s\u1EBD cho ph\xE9p ch\xFAng ta \u0111\u1EA9y m\xF4 h\xECnh v\xE0o Hub sau khi hu\u1EA5n luy\u1EC7n; b\u1EA1n s\u1EBD t\xECm th\u1EA5y kho l\u01B0u tr\u1EEF b\xEAn d\u01B0\u1EDBi h\u1ED3 s\u01A1 ng\u01B0\u1EDDi d\xF9ng c\u1EE7a m\xECnh \u1EDF v\u1ECB tr\xED \u0111\u01B0\u1EE3c x\xE1c \u0111\u1ECBnh b\u1EDFi "),kn=l(bn,"CODE",{});var Jt=c(kn);hn=a(Jt,"output_dir"),Jt.forEach(s),Dn=a(bn,". 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 \u0111\u1EBFn b\u1EB1ng tham s\u1ED1 "),dn=l(bn,"CODE",{});var Yn=c(dn);on=a(Yn,"hub_model_id"),Yn.forEach(s),v=a(bn," (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 \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 "),R=l(bn,"A",{href:!0,rel:!0});var Zt=c(R);mn=l(Zt,"CODE",{});var Kn=c(mn);j=a(Kn,"huggingface-course"),Kn.forEach(s),Zt.forEach(s),V=a(bn,", ch\xFAng ta \u0111\xE3 th\xEAm "),$n=l(bn,"CODE",{});var Ct=c($n);jn=a(Ct,'hub_model_id="huggingface-course/mt5-finetuned-amazon-en-es"'),Ct.forEach(s),un=a(bn," th\xE0nh "),Tn=l(bn,"CODE",{});var zt=c(Tn);en=a(zt,"Seq2SeqTrainingArguments"),zt.forEach(s),Un=a(bn,"."),bn.forEach(s),tt=p(H),cn=l(H,"P",{});var On=c(cn);wn=a(On,"\u0110i\u1EC1u ti\u1EBFp theo ch\xFAng ta c\u1EA7n l\xE0m l\xE0 cung c\u1EA5p cho ng\u01B0\u1EDDi hu\u1EA5n luy\u1EC7n m\u1ED9t h\xE0m "),Rn=l(On,"CODE",{});var ns=c(Rn);Sn=a(ns,"compute_metrics()"),ns.forEach(s),wt=a(On," \u0111\u1EC3 ch\xFAng ta c\xF3 th\u1EC3 \u0111\xE1nh gi\xE1 m\xF4 h\xECnh c\u1EE7a m\xECnh trong qu\xE1 tr\xECnh hu\u1EA5n luy\u1EC7n. \u0110\u1EC3 t\xF3m t\u1EAFt, \u0111i\u1EC1u n\xE0y c\u1EA7n nhi\u1EC1u h\u01A1n l\xE0 \u0111\u01A1n gi\u1EA3n g\u1ECDi "),ln=l(On,"CODE",{});var Qn=c(ln);Yt=a(Qn,"rouge_score.compute()"),Qn.forEach(s),vt=a(On," tr\xEAn c\xE1c d\u1EF1 \u0111o\xE1n c\u1EE7a m\xF4 h\xECnh, v\xEC ch\xFAng ta c\u1EA7n "),ct=l(On,"EM",{});var ts=c(ct);st=a(ts,"gi\u1EA3i m\xE3"),ts.forEach(s),rt=a(On," c\xE1c k\u1EBFt qu\u1EA3 \u0111\u1EA7u ra v\xE0 nh\xE3n th\xE0nh v\u0103n b\u1EA3n tr\u01B0\u1EDBc khi ch\xFAng ta c\xF3 th\u1EC3 t\xEDnh \u0111i\u1EC3m ROUGE. H\xE0m sau th\u1EF1c hi\u1EC7n ch\xEDnh x\xE1c \u0111i\u1EC1u \u0111\xF3 v\xE0 c\u0169ng s\u1EED d\u1EE5ng h\xE0m "),Bn=l(On,"CODE",{});var mt=c(Bn);xt=a(mt,"sent_tokenize()"),mt.forEach(s),Wn=a(On," t\u1EEB "),_t=l(On,"CODE",{});var Dt=c(_t);Et=a(Dt,"nltk"),Dt.forEach(s),An=a(On," \u0111\u1EC3 t\xE1ch c\xE1c c\xE2u t\xF3m t\u1EAFt b\u1EB1ng c\xE1c d\xF2ng m\u1EDBi:"),On.forEach(s),it=p(H),y(et.$$.fragment,H),this.h()},h(){d(J,"href","/course/chapter1"),d(R,"href","https://huggingface.co/huggingface-course"),d(R,"rel","nofollow")},m(H,fn){r(H,u,fn),t(u,w),t(u,g),t(g,x),t(u,L),t(u,E),t(E,N),t(u,O),r(H,q,fn),k(z,H,fn),r(H,S,fn),r(H,A,fn),t(A,D),t(A,I),t(I,X),t(A,K),t(A,J),t(J,M),t(A,Y),t(A,P),t(P,U),t(A,G),t(A,Q),t(Q,an),t(A,tn),t(A,B),t(B,sn),t(A,F),t(A,rn),t(rn,gn),t(A,qn),r(H,vn,fn),r(H,Z,fn),t(Z,_n),t(Z,pn),t(pn,nn),t(Z,yn),t(Z,kn),t(kn,hn),t(Z,Dn),t(Z,dn),t(dn,on),t(Z,v),t(Z,R),t(R,mn),t(mn,j),t(Z,V),t(Z,$n),t($n,jn),t(Z,un),t(Z,Tn),t(Tn,en),t(Z,Un),r(H,tt,fn),r(H,cn,fn),t(cn,wn),t(cn,Rn),t(Rn,Sn),t(cn,wt),t(cn,ln),t(ln,Yt),t(cn,vt),t(cn,ct),t(ct,st),t(cn,rt),t(cn,Bn),t(Bn,xt),t(cn,Wn),t(cn,_t),t(_t,Et),t(cn,An),r(H,it,fn),k(et,H,fn),ot=!0},i(H){ot||(f(z.$$.fragment,H),f(et.$$.fragment,H),ot=!0)},o(H){b(z.$$.fragment,H),b(et.$$.fragment,H),ot=!1},d(H){H&&s(u),H&&s(q),$(z,H),H&&s(S),H&&s(A),H&&s(vn),H&&s(Z),H&&s(tt),H&&s(cn),H&&s(it),$(et,H)}}}function Uf(W){let u,w;return u=new C({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(){_(u.$$.fragment)},l(g){y(u.$$.fragment,g)},m(g,x){k(u,g,x),w=!0},i(g){w||(f(u.$$.fragment,g),w=!0)},o(g){b(u.$$.fragment,g),w=!1},d(g){$(u,g)}}}function Bf(W){let u,w;return u=new C({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(){_(u.$$.fragment)},l(g){y(u.$$.fragment,g)},m(g,x){k(u,g,x),w=!0},i(g){w||(f(u.$$.fragment,g),w=!0)},o(g){b(u.$$.fragment,g),w=!1},d(g){$(u,g)}}}function Ff(W){let u,w,g,x,L,E,N,O,q,z,S,A,D,I,X,K,J,M,Y,P,U,G,Q,an,tn,B,sn,F,rn,gn,qn,vn,Z,_n,pn,nn,yn,kn,hn,Dn,dn,on;return D=new C({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=8,
)
tf_eval_dataset = tokenized_datasets["validation"].to_tf_dataset(
    columns=["input_ids", "attention_mask", "labels"],
    collate_fn=data_collator,
    shuffle=False,
    batch_size=8,
)`,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">8</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">8</span>,
)`}}),M=new C({props:{code:`from transformers import create_optimizer
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_train_epochs = 8
num_train_steps = len(tf_train_dataset) * num_train_epochs
model_name = model_checkpoint.split("/")[-1]

optimizer, schedule = create_optimizer(
    init_lr=5.6e-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">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_train_epochs = <span class="hljs-number">8</span>
num_train_steps = <span class="hljs-built_in">len</span>(tf_train_dataset) * num_train_epochs
model_name = model_checkpoint.split(<span class="hljs-string">&quot;/&quot;</span>)[-<span class="hljs-number">1</span>]

optimizer, schedule = create_optimizer(
    init_lr=<span class="hljs-number">5.6e-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>)`}}),B=new C({props:{code:`from transformers.keras_callbacks import PushToHubCallback

callback = PushToHubCallback(
    output_dir=f"{model_name}-finetuned-amazon-en-es", tokenizer=tokenizer
)

model.fit(
    tf_train_dataset, validation_data=tf_eval_dataset, callbacks=[callback], epochs=8
)`,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">f&quot;<span class="hljs-subst">{model_name}</span>-finetuned-amazon-en-es&quot;</span>, tokenizer=tokenizer
)

model.fit(
    tf_train_dataset, validation_data=tf_eval_dataset, callbacks=[callback], epochs=<span class="hljs-number">8</span>
)`}}),_n=new C({props:{code:`from tqdm import tqdm
import numpy as np

all_preds = []
all_labels = []
for batch in tqdm(tf_eval_dataset):
    predictions = model.generate(**batch)
    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 = ["\\n".join(sent_tokenize(pred.strip())) for pred in decoded_preds]
    decoded_labels = ["\\n".join(sent_tokenize(label.strip())) for label in decoded_labels]
    all_preds.extend(decoded_preds)
    all_labels.extend(decoded_labels)`,highlighted:`<span class="hljs-keyword">from</span> tqdm <span class="hljs-keyword">import</span> tqdm
<span class="hljs-keyword">import</span> numpy <span class="hljs-keyword">as</span> np

all_preds = []
all_labels = []
<span class="hljs-keyword">for</span> batch <span class="hljs-keyword">in</span> tqdm(tf_eval_dataset):
    predictions = model.generate(**batch)
    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 = [<span class="hljs-string">&quot;\\n&quot;</span>.join(sent_tokenize(pred.strip())) <span class="hljs-keyword">for</span> pred <span class="hljs-keyword">in</span> decoded_preds]
    decoded_labels = [<span class="hljs-string">&quot;\\n&quot;</span>.join(sent_tokenize(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)`}}),hn=new C({props:{code:`result = rouge_score.compute(
    predictions=decoded_preds, references=decoded_labels, use_stemmer=True
)
result = {key: value.mid.fmeasure * 100 for key, value in result.items()}
{k: round(v, 4) for k, v in result.items()}`,highlighted:`result = rouge_score.compute(
    predictions=decoded_preds, references=decoded_labels, use_stemmer=<span class="hljs-literal">True</span>
)
result = {key: value.mid.fmeasure * <span class="hljs-number">100</span> <span class="hljs-keyword">for</span> key, value <span class="hljs-keyword">in</span> result.items()}
{k: <span class="hljs-built_in">round</span>(v, <span class="hljs-number">4</span>) <span class="hljs-keyword">for</span> k, v <span class="hljs-keyword">in</span> result.items()}`}}),dn=new C({props:{code:"{'rouge1': 31.4815, 'rouge2': 25.4386, 'rougeL': 31.4815, 'rougeLsum': 31.4815}",highlighted:'{&#x27;rouge1&#x27;: <span class="hljs-number">31.4815</span>, &#x27;rouge2&#x27;: <span class="hljs-number">25.4386</span>, &#x27;rougeL&#x27;: <span class="hljs-number">31.4815</span>, &#x27;rougeLsum&#x27;: <span class="hljs-number">31.4815</span>}'}}),{c(){u=h("p"),w=e("Ch\xFAng t\xF4i g\u1EA7n nh\u01B0 \u0111\xE3 s\u1EB5n s\xE0ng \u0111\u1EC3 hu\u1EA5n luy\u1EC7n! Ch\xFAng ta ch\u1EC9 c\u1EA7n chuy\u1EC3n \u0111\u1ED5i t\u1EADp d\u1EEF li\u1EC7u c\u1EE7a m\xECnh th\xE0nh "),g=h("code"),x=e("tf.data.Dataset"),L=e(" b\u1EB1ng c\xE1ch s\u1EED d\u1EE5ng tr\xECnh \u0111\u1ED1i chi\u1EBFu d\u1EEF li\u1EC7u \u0111\xE3 x\xE1c \u0111\u1ECBnh \u1EDF tr\xEAn, sau \u0111\xF3 m\xF4 h\xECnh "),E=h("code"),N=e("compile()"),O=e(" v\xE0 "),q=h("code"),z=e("fit()"),S=e(". \u0110\u1EA7u ti\xEAn, b\u1ED9 d\u1EEF li\u1EC7u:"),A=m(),_(D.$$.fragment),I=m(),X=h("p"),K=e("B\xE2y gi\u1EDD, ch\xFAng ta x\xE1c \u0111\u1ECBnh c\xE1c si\xEAu tham s\u1ED1 hu\u1EA5n luy\u1EC7n c\u1EE7a m\xECnh v\xE0 bi\xEAn d\u1ECBch:"),J=m(),_(M.$$.fragment),Y=m(),P=h("p"),U=e("And finally, we fit the model. We use a "),G=h("code"),Q=e("PushToHubCallback"),an=e(" to save the model to the Hub after each epoch, which will allow us to use it for inference later:"),tn=m(),_(B.$$.fragment),sn=m(),F=h("p"),rn=e("Ch\xFAng ta nh\u1EADn \u0111\u01B0\u1EE3c m\u1ED9t s\u1ED1 gi\xE1 tr\u1ECB m\u1EA5t m\xE1t trong qu\xE1 tr\xECnh hu\u1EA5n luy\u1EC7n, nh\u01B0ng th\u1EF1c s\u1EF1 ch\xFAng ta mu\u1ED1n xem c\xE1c ch\u1EC9 s\u1ED1 ROUGE m\xE0 ta \u0111\xE3 t\xEDnh to\xE1n tr\u01B0\u1EDBc \u0111\xF3. \u0110\u1EC3 c\xF3 \u0111\u01B0\u1EE3c c\xE1c s\u1ED1 li\u1EC7u \u0111\xF3, ch\xFAng t\xF4i s\u1EBD c\u1EA7n t\u1EA1o k\u1EBFt qu\u1EA3 \u0111\u1EA7u ra t\u1EEB m\xF4 h\xECnh v\xE0 chuy\u1EC3n \u0111\u1ED5i ch\xFAng th\xE0nh chu\u1ED7i. H\xE3y x\xE2y d\u1EF1ng m\u1ED9t s\u1ED1 danh s\xE1ch nh\xE3n v\xE0 d\u1EF1 \u0111o\xE1n cho ch\u1EC9 s\u1ED1 ROUGE \u0111\u1EC3 so s\xE1nh (l\u01B0u \xFD r\u1EB1ng n\u1EBFu b\u1EA1n g\u1EB7p l\u1ED7i nh\u1EADp cho ph\u1EA7n n\xE0y, b\u1EA1n c\xF3 th\u1EC3 c\u1EA7n ph\u1EA3i "),gn=h("code"),qn=e("!pip install tqdm"),vn=e("):"),Z=m(),_(_n.$$.fragment),pn=m(),nn=h("p"),yn=e("Khi ch\xFAng ta c\xF3 danh s\xE1ch c\xE1c chu\u1ED7i nh\xE3n v\xE0 chu\u1ED7i d\u1EF1 \u0111o\xE1n, vi\u1EC7c t\xEDnh to\xE1n \u0111i\u1EC3m ROUGE th\u1EADt d\u1EC5 d\xE0ng:"),kn=m(),_(hn.$$.fragment),Dn=m(),_(dn.$$.fragment)},l(v){u=l(v,"P",{});var R=c(u);w=a(R,"Ch\xFAng t\xF4i g\u1EA7n nh\u01B0 \u0111\xE3 s\u1EB5n s\xE0ng \u0111\u1EC3 hu\u1EA5n luy\u1EC7n! Ch\xFAng ta ch\u1EC9 c\u1EA7n chuy\u1EC3n \u0111\u1ED5i t\u1EADp d\u1EEF li\u1EC7u c\u1EE7a m\xECnh th\xE0nh "),g=l(R,"CODE",{});var mn=c(g);x=a(mn,"tf.data.Dataset"),mn.forEach(s),L=a(R," b\u1EB1ng c\xE1ch s\u1EED d\u1EE5ng tr\xECnh \u0111\u1ED1i chi\u1EBFu d\u1EEF li\u1EC7u \u0111\xE3 x\xE1c \u0111\u1ECBnh \u1EDF tr\xEAn, sau \u0111\xF3 m\xF4 h\xECnh "),E=l(R,"CODE",{});var j=c(E);N=a(j,"compile()"),j.forEach(s),O=a(R," v\xE0 "),q=l(R,"CODE",{});var V=c(q);z=a(V,"fit()"),V.forEach(s),S=a(R,". \u0110\u1EA7u ti\xEAn, b\u1ED9 d\u1EEF li\u1EC7u:"),R.forEach(s),A=p(v),y(D.$$.fragment,v),I=p(v),X=l(v,"P",{});var $n=c(X);K=a($n,"B\xE2y gi\u1EDD, ch\xFAng ta x\xE1c \u0111\u1ECBnh c\xE1c si\xEAu tham s\u1ED1 hu\u1EA5n luy\u1EC7n c\u1EE7a m\xECnh v\xE0 bi\xEAn d\u1ECBch:"),$n.forEach(s),J=p(v),y(M.$$.fragment,v),Y=p(v),P=l(v,"P",{});var jn=c(P);U=a(jn,"And finally, we fit the model. We use a "),G=l(jn,"CODE",{});var un=c(G);Q=a(un,"PushToHubCallback"),un.forEach(s),an=a(jn," to save the model to the Hub after each epoch, which will allow us to use it for inference later:"),jn.forEach(s),tn=p(v),y(B.$$.fragment,v),sn=p(v),F=l(v,"P",{});var Tn=c(F);rn=a(Tn,"Ch\xFAng ta nh\u1EADn \u0111\u01B0\u1EE3c m\u1ED9t s\u1ED1 gi\xE1 tr\u1ECB m\u1EA5t m\xE1t trong qu\xE1 tr\xECnh hu\u1EA5n luy\u1EC7n, nh\u01B0ng th\u1EF1c s\u1EF1 ch\xFAng ta mu\u1ED1n xem c\xE1c ch\u1EC9 s\u1ED1 ROUGE m\xE0 ta \u0111\xE3 t\xEDnh to\xE1n tr\u01B0\u1EDBc \u0111\xF3. \u0110\u1EC3 c\xF3 \u0111\u01B0\u1EE3c c\xE1c s\u1ED1 li\u1EC7u \u0111\xF3, ch\xFAng t\xF4i s\u1EBD c\u1EA7n t\u1EA1o k\u1EBFt qu\u1EA3 \u0111\u1EA7u ra t\u1EEB m\xF4 h\xECnh v\xE0 chuy\u1EC3n \u0111\u1ED5i ch\xFAng th\xE0nh chu\u1ED7i. H\xE3y x\xE2y d\u1EF1ng m\u1ED9t s\u1ED1 danh s\xE1ch nh\xE3n v\xE0 d\u1EF1 \u0111o\xE1n cho ch\u1EC9 s\u1ED1 ROUGE \u0111\u1EC3 so s\xE1nh (l\u01B0u \xFD r\u1EB1ng n\u1EBFu b\u1EA1n g\u1EB7p l\u1ED7i nh\u1EADp cho ph\u1EA7n n\xE0y, b\u1EA1n c\xF3 th\u1EC3 c\u1EA7n ph\u1EA3i "),gn=l(Tn,"CODE",{});var en=c(gn);qn=a(en,"!pip install tqdm"),en.forEach(s),vn=a(Tn,"):"),Tn.forEach(s),Z=p(v),y(_n.$$.fragment,v),pn=p(v),nn=l(v,"P",{});var Un=c(nn);yn=a(Un,"Khi ch\xFAng ta c\xF3 danh s\xE1ch c\xE1c chu\u1ED7i nh\xE3n v\xE0 chu\u1ED7i d\u1EF1 \u0111o\xE1n, vi\u1EC7c t\xEDnh to\xE1n \u0111i\u1EC3m ROUGE th\u1EADt d\u1EC5 d\xE0ng:"),Un.forEach(s),kn=p(v),y(hn.$$.fragment,v),Dn=p(v),y(dn.$$.fragment,v)},m(v,R){r(v,u,R),t(u,w),t(u,g),t(g,x),t(u,L),t(u,E),t(E,N),t(u,O),t(u,q),t(q,z),t(u,S),r(v,A,R),k(D,v,R),r(v,I,R),r(v,X,R),t(X,K),r(v,J,R),k(M,v,R),r(v,Y,R),r(v,P,R),t(P,U),t(P,G),t(G,Q),t(P,an),r(v,tn,R),k(B,v,R),r(v,sn,R),r(v,F,R),t(F,rn),t(F,gn),t(gn,qn),t(F,vn),r(v,Z,R),k(_n,v,R),r(v,pn,R),r(v,nn,R),t(nn,yn),r(v,kn,R),k(hn,v,R),r(v,Dn,R),k(dn,v,R),on=!0},i(v){on||(f(D.$$.fragment,v),f(M.$$.fragment,v),f(B.$$.fragment,v),f(_n.$$.fragment,v),f(hn.$$.fragment,v),f(dn.$$.fragment,v),on=!0)},o(v){b(D.$$.fragment,v),b(M.$$.fragment,v),b(B.$$.fragment,v),b(_n.$$.fragment,v),b(hn.$$.fragment,v),b(dn.$$.fragment,v),on=!1},d(v){v&&s(u),v&&s(A),$(D,v),v&&s(I),v&&s(X),v&&s(J),$(M,v),v&&s(Y),v&&s(P),v&&s(tn),$(B,v),v&&s(sn),v&&s(F),v&&s(Z),$(_n,v),v&&s(pn),v&&s(nn),v&&s(kn),$(hn,v),v&&s(Dn),$(dn,v)}}}function Vf(W){let u,w,g,x,L,E,N,O,q,z,S,A,D,I,X,K,J,M,Y,P,U,G,Q,an,tn,B,sn,F,rn,gn,qn,vn,Z,_n,pn,nn,yn,kn,hn,Dn,dn,on,v,R,mn;return x=new C({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,
)`}}),q=new C({props:{code:"trainer.train()",highlighted:"trainer.train()"}}),J=new C({props:{code:"trainer.evaluate()",highlighted:"trainer.evaluate()"}}),Y=new C({props:{code:`{'eval_loss': 3.028524398803711,
 'eval_rouge1': 16.9728,
 'eval_rouge2': 8.2969,
 'eval_rougeL': 16.8366,
 'eval_rougeLsum': 16.851,
 'eval_gen_len': 10.1597,
 'eval_runtime': 6.1054,
 'eval_samples_per_second': 38.982,
 'eval_steps_per_second': 4.914}`,highlighted:`{<span class="hljs-string">&#x27;eval_loss&#x27;</span>: <span class="hljs-number">3.028524398803711</span>,
 <span class="hljs-string">&#x27;eval_rouge1&#x27;</span>: <span class="hljs-number">16.9728</span>,
 <span class="hljs-string">&#x27;eval_rouge2&#x27;</span>: <span class="hljs-number">8.2969</span>,
 <span class="hljs-string">&#x27;eval_rougeL&#x27;</span>: <span class="hljs-number">16.8366</span>,
 <span class="hljs-string">&#x27;eval_rougeLsum&#x27;</span>: <span class="hljs-number">16.851</span>,
 <span class="hljs-string">&#x27;eval_gen_len&#x27;</span>: <span class="hljs-number">10.1597</span>,
 <span class="hljs-string">&#x27;eval_runtime&#x27;</span>: <span class="hljs-number">6.1054</span>,
 <span class="hljs-string">&#x27;eval_samples_per_second&#x27;</span>: <span class="hljs-number">38.982</span>,
 <span class="hljs-string">&#x27;eval_steps_per_second&#x27;</span>: <span class="hljs-number">4.914</span>}`}}),an=new C({props:{code:'trainer.push_to_hub(commit_message="Training complete", tags="summarization")',highlighted:'trainer.push_to_hub(<span class="hljs-attribute">commit_message</span>=<span class="hljs-string">&quot;Training complete&quot;</span>, <span class="hljs-attribute">tags</span>=<span class="hljs-string">&quot;summarization&quot;</span>)'}}),B=new C({props:{code:"'https://huggingface.co/huggingface-course/mt5-finetuned-amazon-en-es/commit/aa0536b829b28e73e1e4b94b8a5aacec420d40e0'",highlighted:'<span class="hljs-string">&#x27;https://huggingface.co/huggingface-course/mt5-finetuned-amazon-en-es/commit/aa0536b829b28e73e1e4b94b8a5aacec420d40e0&#x27;</span>'}}),{c(){u=h("p"),w=e("Cu\u1ED1i c\xF9ng th\xEC ch\xFAng ta c\u0169ng c\xF3 t\u1EA5t c\u1EA3 nh\u1EEFng nguy\xEAn li\u1EC7u c\u1EA7n thi\u1EBFt \u0111\u1EC3 luy\u1EC7n t\u1EADp! B\xE2y gi\u1EDD ch\xFAng ta ch\u1EC9 c\u1EA7n kh\u1EDFi t\u1EA1o tr\xECnh hu\u1EA5n luy\u1EC7n v\u1EDBi c\xE1c tham s\u1ED1 ti\xEAu chu\u1EA9n:"),g=m(),_(x.$$.fragment),L=m(),E=h("p"),N=e("v\xE0 kh\u1EDFi ch\u1EA1y ch\u01B0\u01A1ng tr\xECnh hu\u1EA5n luy\u1EC7n c\u1EE7a m\xECnh:"),O=m(),_(q.$$.fragment),z=m(),S=h("p"),A=e("Trong qu\xE1 tr\xECnh hu\u1EA5n luy\u1EC7n, b\u1EA1n s\u1EBD th\u1EA5y m\u1EA5t m\xE1t hu\u1EA5n luy\u1EC7n gi\u1EA3m v\xE0 \u0111i\u1EC3m ROUGE t\u0103ng l\xEAn theo t\u1EEBng epoch. Sau khi qu\xE1 tr\xECnh hu\u1EA5n luy\u1EC7n ho\xE0n t\u1EA5t, b\u1EA1n c\xF3 th\u1EC3 xem \u0111i\u1EC3m ROUGE cu\u1ED1i c\xF9ng b\u1EB1ng c\xE1ch ch\u1EA1y "),D=h("code"),I=e("Trainer.evaluate()"),X=e(":"),K=m(),_(J.$$.fragment),M=m(),_(Y.$$.fragment),P=m(),U=h("p"),G=e("T\u1EEB \u0111i\u1EC3m s\u1ED1, ch\xFAng ta c\xF3 th\u1EC3 th\u1EA5y r\u1EB1ng m\xF4 h\xECnh c\u1EE7a m\xECnh \u0111\xE3 v\u01B0\u1EE3t tr\u1ED9i so v\u1EDBi m\xF4 h\xECnh c\u01A1 s\u1EDF v\u1EDBi 3 b\xE0i \u0111\u1EA7u ti\xEAn - th\u1EADt tuy\u1EC7t! \u0110i\u1EC1u cu\u1ED1i c\xF9ng c\u1EA7n l\xE0m l\xE0 \u0111\u1EA9y c\xE1c tr\u1ECDng s\u1ED1 m\xF4 h\xECnh v\xE0o Hub, nh\u01B0 sau:"),Q=m(),_(an.$$.fragment),tn=m(),_(B.$$.fragment),sn=m(),F=h("p"),rn=e("Thao t\xE1c n\xE0y s\u1EBD l\u01B0u c\xE1c checkpoint v\xE0 c\xE1c t\u1EC7p c\u1EA5u h\xECnh v\xE0o "),gn=h("code"),qn=e("output_dir"),vn=e(", tr\u01B0\u1EDBc khi t\u1EA3i t\u1EA5t c\u1EA3 c\xE1c t\u1EC7p l\xEAn Hub. B\u1EB1ng c\xE1ch ch\u1EC9 \u0111\u1ECBnh tham s\u1ED1 "),Z=h("code"),_n=e("tags"),pn=e(", ch\xFAng ta c\u0169ng \u0111\u1EA3m b\u1EA3o r\u1EB1ng ti\u1EC7n \xEDch con tr\xEAn Hub s\u1EBD l\xE0 m\u1ED9t ti\u1EC7n \xEDch con d\xE0nh cho quy tr\xECnh t\xF3m t\u1EAFt thay v\xEC ti\u1EC7n \xEDch t\u1EA1o v\u0103n b\u1EA3n m\u1EB7c \u0111\u1ECBnh \u0111\u01B0\u1EE3c li\xEAn k\u1EBFt v\u1EDBi ki\u1EBFn tr\xFAc mT5 (\u0111\u1EC3 bi\u1EBFt th\xEAm th\xF4ng tin v\u1EC1 th\u1EBB m\xF4 h\xECnh, h\xE3y xem t\xE0i li\u1EC7u "),nn=h("a"),yn=e("\u{1F917} Hub "),kn=e("). \u0110\u1EA7u ra t\u1EEB "),hn=h("code"),Dn=e("trainr.push_to_hub())"),dn=e(" l\xE0 m\u1ED9t URL t\u1EDBi h\xE0m b\u0103m cam k\u1EBFt Git, v\xEC v\u1EADy b\u1EA1n c\xF3 th\u1EC3 d\u1EC5 d\xE0ng xem c\xE1c thay \u0111\u1ED5i \u0111\xE3 \u0111\u01B0\u1EE3c th\u1EF1c hi\u1EC7n \u0111\u1ED1i v\u1EDBi kho l\u01B0u tr\u1EEF m\xF4 h\xECnh!"),on=m(),v=h("p"),R=e("\u0110\u1EC3 k\u1EBFt th\xFAc ph\u1EA7n n\xE0y, h\xE3y xem c\xE1ch ch\xFAng ta c\u0169ng c\xF3 th\u1EC3 tinh ch\u1EC9nh mT5 b\u1EB1ng c\xE1ch s\u1EED d\u1EE5ng c\xE1c t\xEDnh n\u0103ng c\u1EA5p th\u1EA5p do \u{1F917} Accelerate cung c\u1EA5p."),this.h()},l(j){u=l(j,"P",{});var V=c(u);w=a(V,"Cu\u1ED1i c\xF9ng th\xEC ch\xFAng ta c\u0169ng c\xF3 t\u1EA5t c\u1EA3 nh\u1EEFng nguy\xEAn li\u1EC7u c\u1EA7n thi\u1EBFt \u0111\u1EC3 luy\u1EC7n t\u1EADp! B\xE2y gi\u1EDD ch\xFAng ta ch\u1EC9 c\u1EA7n kh\u1EDFi t\u1EA1o tr\xECnh hu\u1EA5n luy\u1EC7n v\u1EDBi c\xE1c tham s\u1ED1 ti\xEAu chu\u1EA9n:"),V.forEach(s),g=p(j),y(x.$$.fragment,j),L=p(j),E=l(j,"P",{});var $n=c(E);N=a($n,"v\xE0 kh\u1EDFi ch\u1EA1y ch\u01B0\u01A1ng tr\xECnh hu\u1EA5n luy\u1EC7n c\u1EE7a m\xECnh:"),$n.forEach(s),O=p(j),y(q.$$.fragment,j),z=p(j),S=l(j,"P",{});var jn=c(S);A=a(jn,"Trong qu\xE1 tr\xECnh hu\u1EA5n luy\u1EC7n, b\u1EA1n s\u1EBD th\u1EA5y m\u1EA5t m\xE1t hu\u1EA5n luy\u1EC7n gi\u1EA3m v\xE0 \u0111i\u1EC3m ROUGE t\u0103ng l\xEAn theo t\u1EEBng epoch. Sau khi qu\xE1 tr\xECnh hu\u1EA5n luy\u1EC7n ho\xE0n t\u1EA5t, b\u1EA1n c\xF3 th\u1EC3 xem \u0111i\u1EC3m ROUGE cu\u1ED1i c\xF9ng b\u1EB1ng c\xE1ch ch\u1EA1y "),D=l(jn,"CODE",{});var un=c(D);I=a(un,"Trainer.evaluate()"),un.forEach(s),X=a(jn,":"),jn.forEach(s),K=p(j),y(J.$$.fragment,j),M=p(j),y(Y.$$.fragment,j),P=p(j),U=l(j,"P",{});var Tn=c(U);G=a(Tn,"T\u1EEB \u0111i\u1EC3m s\u1ED1, ch\xFAng ta c\xF3 th\u1EC3 th\u1EA5y r\u1EB1ng m\xF4 h\xECnh c\u1EE7a m\xECnh \u0111\xE3 v\u01B0\u1EE3t tr\u1ED9i so v\u1EDBi m\xF4 h\xECnh c\u01A1 s\u1EDF v\u1EDBi 3 b\xE0i \u0111\u1EA7u ti\xEAn - th\u1EADt tuy\u1EC7t! \u0110i\u1EC1u cu\u1ED1i c\xF9ng c\u1EA7n l\xE0m l\xE0 \u0111\u1EA9y c\xE1c tr\u1ECDng s\u1ED1 m\xF4 h\xECnh v\xE0o Hub, nh\u01B0 sau:"),Tn.forEach(s),Q=p(j),y(an.$$.fragment,j),tn=p(j),y(B.$$.fragment,j),sn=p(j),F=l(j,"P",{});var en=c(F);rn=a(en,"Thao t\xE1c n\xE0y s\u1EBD l\u01B0u c\xE1c checkpoint v\xE0 c\xE1c t\u1EC7p c\u1EA5u h\xECnh v\xE0o "),gn=l(en,"CODE",{});var Un=c(gn);qn=a(Un,"output_dir"),Un.forEach(s),vn=a(en,", tr\u01B0\u1EDBc khi t\u1EA3i t\u1EA5t c\u1EA3 c\xE1c t\u1EC7p l\xEAn Hub. B\u1EB1ng c\xE1ch ch\u1EC9 \u0111\u1ECBnh tham s\u1ED1 "),Z=l(en,"CODE",{});var tt=c(Z);_n=a(tt,"tags"),tt.forEach(s),pn=a(en,", ch\xFAng ta c\u0169ng \u0111\u1EA3m b\u1EA3o r\u1EB1ng ti\u1EC7n \xEDch con tr\xEAn Hub s\u1EBD l\xE0 m\u1ED9t ti\u1EC7n \xEDch con d\xE0nh cho quy tr\xECnh t\xF3m t\u1EAFt thay v\xEC ti\u1EC7n \xEDch t\u1EA1o v\u0103n b\u1EA3n m\u1EB7c \u0111\u1ECBnh \u0111\u01B0\u1EE3c li\xEAn k\u1EBFt v\u1EDBi ki\u1EBFn tr\xFAc mT5 (\u0111\u1EC3 bi\u1EBFt th\xEAm th\xF4ng tin v\u1EC1 th\u1EBB m\xF4 h\xECnh, h\xE3y xem t\xE0i li\u1EC7u "),nn=l(en,"A",{href:!0,rel:!0});var cn=c(nn);yn=a(cn,"\u{1F917} Hub "),cn.forEach(s),kn=a(en,"). \u0110\u1EA7u ra t\u1EEB "),hn=l(en,"CODE",{});var wn=c(hn);Dn=a(wn,"trainr.push_to_hub())"),wn.forEach(s),dn=a(en," l\xE0 m\u1ED9t URL t\u1EDBi h\xE0m b\u0103m cam k\u1EBFt Git, v\xEC v\u1EADy b\u1EA1n c\xF3 th\u1EC3 d\u1EC5 d\xE0ng xem c\xE1c thay \u0111\u1ED5i \u0111\xE3 \u0111\u01B0\u1EE3c th\u1EF1c hi\u1EC7n \u0111\u1ED1i v\u1EDBi kho l\u01B0u tr\u1EEF m\xF4 h\xECnh!"),en.forEach(s),on=p(j),v=l(j,"P",{});var Rn=c(v);R=a(Rn,"\u0110\u1EC3 k\u1EBFt th\xFAc ph\u1EA7n n\xE0y, h\xE3y xem c\xE1ch ch\xFAng ta c\u0169ng c\xF3 th\u1EC3 tinh ch\u1EC9nh mT5 b\u1EB1ng c\xE1ch s\u1EED d\u1EE5ng c\xE1c t\xEDnh n\u0103ng c\u1EA5p th\u1EA5p do \u{1F917} Accelerate cung c\u1EA5p."),Rn.forEach(s),this.h()},h(){d(nn,"href","https://huggingface.co/docs/hub/main#how-is-a-models-type-of-inference-api-and-widget-detined"),d(nn,"rel","nofollow")},m(j,V){r(j,u,V),t(u,w),r(j,g,V),k(x,j,V),r(j,L,V),r(j,E,V),t(E,N),r(j,O,V),k(q,j,V),r(j,z,V),r(j,S,V),t(S,A),t(S,D),t(D,I),t(S,X),r(j,K,V),k(J,j,V),r(j,M,V),k(Y,j,V),r(j,P,V),r(j,U,V),t(U,G),r(j,Q,V),k(an,j,V),r(j,tn,V),k(B,j,V),r(j,sn,V),r(j,F,V),t(F,rn),t(F,gn),t(gn,qn),t(F,vn),t(F,Z),t(Z,_n),t(F,pn),t(F,nn),t(nn,yn),t(F,kn),t(F,hn),t(hn,Dn),t(F,dn),r(j,on,V),r(j,v,V),t(v,R),mn=!0},i(j){mn||(f(x.$$.fragment,j),f(q.$$.fragment,j),f(J.$$.fragment,j),f(Y.$$.fragment,j),f(an.$$.fragment,j),f(B.$$.fragment,j),mn=!0)},o(j){b(x.$$.fragment,j),b(q.$$.fragment,j),b(J.$$.fragment,j),b(Y.$$.fragment,j),b(an.$$.fragment,j),b(B.$$.fragment,j),mn=!1},d(j){j&&s(u),j&&s(g),$(x,j),j&&s(L),j&&s(E),j&&s(O),$(q,j),j&&s(z),j&&s(S),j&&s(K),$(J,j),j&&s(M),$(Y,j),j&&s(P),j&&s(U),j&&s(Q),$(an,j),j&&s(tn),$(B,j),j&&s(sn),j&&s(F),j&&s(on),j&&s(v)}}}function $f(W){let u,w,g,x,L,E,N,O,q,z,S,A,D,I,X,K,J,M,Y,P,U,G,Q,an,tn,B,sn,F,rn,gn,qn,vn,Z,_n,pn,nn,yn,kn,hn,Dn,dn,on,v,R,mn,j,V,$n,jn,un,Tn,en,Un,tt,cn,wn,Rn,Sn,wt,ln,Yt,vt,ct,st,rt,Bn,xt,Wn,_t,Et,An,it,et,ot,H,fn,yt,qt,xn,Tt,Fn,Qt,at,ht,Xn,bn,Vn,Jt,Yn,Zt,Kn,Ct,zt,On,ns,Qn,ts,mt,Dt,Cn,ra,ks,ss,_e,kt,ye,$s,js,ke,es,ws,St,ia,xs,as,$e,zn,$t,pt,Vs,hs,Ks,Ws,oa,Es,qs,ma,Ts,Jn,ls,Xs,Ys,pa,je,cs,Cs,zs,ua,Ds,rs,we,Pn,xe,Hn,ga,Qs,Js,da,Zs,ne,fa,te,Ee,Ss,qe,At,Ot,Pt,Lt,is,Nt,Te,lt,os,$h,Ce;return x=new Xt({}),U=new Xt({}),pn=new C({props:{code:'tokenized_datasets.set_format("torch")',highlighted:'tokenized_datasets.set_format(<span class="hljs-string">&quot;torch&quot;</span>)'}}),v=new C({props:{code:"model = AutoModelForSeq2SeqLM.from_pretrained(model_checkpoint)",highlighted:"model = AutoModelForSeq2SeqLM.from_pretrained(model_checkpoint)"}}),$n=new C({props:{code:`from torch.utils.data import DataLoader

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

batch_size = <span class="hljs-number">8</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=batch_size,
)
eval_dataloader = DataLoader(
    tokenized_datasets[<span class="hljs-string">&quot;validation&quot;</span>], collate_fn=data_collator, batch_size=batch_size
)`}}),wn=new C({props:{code:`from torch.optim import AdamW

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

optimizer = AdamW(model.parameters(), lr=<span class="hljs-number">2e-5</span>)`}}),st=new C({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
)`}}),Bn=new ca({props:{$$slots:{default:[Kf]},$$scope:{ctx:W}}}),ht=new C({props:{code:`from transformers import get_scheduler

num_train_epochs = 10
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">10</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 C({props:{code:`def postprocess_text(preds, labels):
    preds = [pred.strip() for pred in preds]
    labels = [label.strip() for label in labels]

    # ROUGE k\xEC v\u1ECDng d\xF2ng m\u1EDBi sau m\u1ED7i c\xE2u
    preds = ["\\n".join(nltk.sent_tokenize(pred)) for pred in preds]
    labels = ["\\n".join(nltk.sent_tokenize(label)) for label in labels]

    return preds, labels`,highlighted:`<span class="hljs-keyword">def</span> <span class="hljs-title function_">postprocess_text</span>(<span class="hljs-params">preds, labels</span>):
    preds = [pred.strip() <span class="hljs-keyword">for</span> pred <span class="hljs-keyword">in</span> preds]
    labels = [label.strip() <span class="hljs-keyword">for</span> label <span class="hljs-keyword">in</span> labels]

    <span class="hljs-comment"># ROUGE k\xEC v\u1ECDng d\xF2ng m\u1EDBi sau m\u1ED7i c\xE2u</span>
    preds = [<span class="hljs-string">&quot;\\n&quot;</span>.join(nltk.sent_tokenize(pred)) <span class="hljs-keyword">for</span> pred <span class="hljs-keyword">in</span> preds]
    labels = [<span class="hljs-string">&quot;\\n&quot;</span>.join(nltk.sent_tokenize(label)) <span class="hljs-keyword">for</span> label <span class="hljs-keyword">in</span> labels]

    <span class="hljs-keyword">return</span> preds, labels`}}),ss=new C({props:{code:`from huggingface_hub import get_full_repo_name

model_name = "test-bert-finetuned-squad-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> get_full_repo_name

model_name = <span class="hljs-string">&quot;test-bert-finetuned-squad-accelerate&quot;</span>
repo_name = get_full_repo_name(model_name)
repo_name`}}),kt=new C({props:{code:"'lewtun/mt5-finetuned-amazon-en-es-accelerate'",highlighted:'<span class="hljs-string">&#x27;lewtun/mt5-finetuned-amazon-en-es-accelerate&#x27;</span>'}}),es=new C({props:{code:`from huggingface_hub import Repository

output_dir = "results-mt5-finetuned-squad-accelerate"
repo = Repository(output_dir, clone_from=repo_name)`,highlighted:`<span class="hljs-keyword">from</span> huggingface_hub <span class="hljs-keyword">import</span> Repository

output_dir = <span class="hljs-string">&quot;results-mt5-finetuned-squad-accelerate&quot;</span>
repo = Repository(output_dir, clone_from=repo_name)`}}),hs=new Xt({}),Ot=new C({props:{code:`from tqdm.auto import tqdm
import torch
import numpy as np

progress_bar = tqdm(range(num_training_steps))

for epoch in range(num_train_epochs):
    # Hu\u1EA5n luy\u1EC7n
    model.train()
    for step, batch in enumerate(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 step, batch in enumerate(eval_dataloader):
        with torch.no_grad():
            generated_tokens = accelerator.unwrap_model(model).generate(
                batch["input_ids"],
                attention_mask=batch["attention_mask"],
            )

            generated_tokens = accelerator.pad_across_processes(
                generated_tokens, dim=1, pad_index=tokenizer.pad_token_id
            )
            labels = batch["labels"]

            # N\u1EBFu ta kh\xF4ng \u0111\u1EC7m \u0111\u1EBFn \u0111\u1ED9 gi\u1EA3i t\u1ED1i \u0111a, ta c\u1EA7n \u0111\u1EC7m c\u1EA3 nh\xE3n n\u1EEFa
            labels = accelerator.pad_across_processes(
                batch["labels"], dim=1, pad_index=tokenizer.pad_token_id
            )

            generated_tokens = accelerator.gather(generated_tokens).cpu().numpy()
            labels = accelerator.gather(labels).cpu().numpy()

            # Thay -100 \u1EDF nh\xE3n v\xEC ta kh\xF4ng th\u1EC3  gi\u1EA3i m\xE3 ch\xFAng
            labels = np.where(labels != -100, labels, tokenizer.pad_token_id)
            if isinstance(generated_tokens, tuple):
                generated_tokens = generated_tokens[0]
            decoded_preds = tokenizer.batch_decode(
                generated_tokens, skip_special_tokens=True
            )
            decoded_labels = tokenizer.batch_decode(labels, skip_special_tokens=True)

            decoded_preds, decoded_labels = postprocess_text(
                decoded_preds, decoded_labels
            )

            rouge_score.add_batch(predictions=decoded_preds, references=decoded_labels)

    # T\xEDnh to\xE1n c\xE1c ch\u1EC9 s\u1ED1
    result = rouge_score.compute()
    # Tr\xEDch xu\u1EA5t \u0111i\u1EC3m trung v\u1ECB ROUGE
    result = {key: value.mid.fmeasure * 100 for key, value in result.items()}
    result = {k: round(v, 4) for k, v in result.items()}
    print(f"Epoch {epoch}:", result)

    # 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
<span class="hljs-keyword">import</span> numpy <span class="hljs-keyword">as</span> np

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> step, batch <span class="hljs-keyword">in</span> <span class="hljs-built_in">enumerate</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> step, batch <span class="hljs-keyword">in</span> <span class="hljs-built_in">enumerate</span>(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>],
            )

            generated_tokens = accelerator.pad_across_processes(
                generated_tokens, dim=<span class="hljs-number">1</span>, pad_index=tokenizer.pad_token_id
            )
            labels = batch[<span class="hljs-string">&quot;labels&quot;</span>]

            <span class="hljs-comment"># N\u1EBFu ta kh\xF4ng \u0111\u1EC7m \u0111\u1EBFn \u0111\u1ED9 gi\u1EA3i t\u1ED1i \u0111a, ta c\u1EA7n \u0111\u1EC7m c\u1EA3 nh\xE3n n\u1EEFa</span>
            labels = accelerator.pad_across_processes(
                batch[<span class="hljs-string">&quot;labels&quot;</span>], dim=<span class="hljs-number">1</span>, pad_index=tokenizer.pad_token_id
            )

            generated_tokens = accelerator.gather(generated_tokens).cpu().numpy()
            labels = accelerator.gather(labels).cpu().numpy()

            <span class="hljs-comment"># Thay -100 \u1EDF nh\xE3n v\xEC ta kh\xF4ng th\u1EC3  gi\u1EA3i m\xE3 ch\xFAng</span>
            labels = np.where(labels != -<span class="hljs-number">100</span>, labels, tokenizer.pad_token_id)
            <span class="hljs-keyword">if</span> <span class="hljs-built_in">isinstance</span>(generated_tokens, <span class="hljs-built_in">tuple</span>):
                generated_tokens = generated_tokens[<span class="hljs-number">0</span>]
            decoded_preds = tokenizer.batch_decode(
                generated_tokens, skip_special_tokens=<span class="hljs-literal">True</span>
            )
            decoded_labels = tokenizer.batch_decode(labels, skip_special_tokens=<span class="hljs-literal">True</span>)

            decoded_preds, decoded_labels = postprocess_text(
                decoded_preds, decoded_labels
            )

            rouge_score.add_batch(predictions=decoded_preds, references=decoded_labels)

    <span class="hljs-comment"># T\xEDnh to\xE1n c\xE1c ch\u1EC9 s\u1ED1</span>
    result = rouge_score.compute()
    <span class="hljs-comment"># Tr\xEDch xu\u1EA5t \u0111i\u1EC3m trung v\u1ECB ROUGE</span>
    result = {key: value.mid.fmeasure * <span class="hljs-number">100</span> <span class="hljs-keyword">for</span> key, value <span class="hljs-keyword">in</span> result.items()}
    result = {k: <span class="hljs-built_in">round</span>(v, <span class="hljs-number">4</span>) <span class="hljs-keyword">for</span> k, v <span class="hljs-keyword">in</span> result.items()}
    <span class="hljs-built_in">print</span>(<span class="hljs-string">f&quot;Epoch <span class="hljs-subst">{epoch}</span>:&quot;</span>, result)

    <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>
        )`}}),Lt=new C({props:{code:`Epoch 0: {'rouge1': 5.6351, 'rouge2': 1.1625, 'rougeL': 5.4866, 'rougeLsum': 5.5005}
Epoch 1: {'rouge1': 9.8646, 'rouge2': 3.4106, 'rougeL': 9.9439, 'rougeLsum': 9.9306}
Epoch 2: {'rouge1': 11.0872, 'rouge2': 3.3273, 'rougeL': 11.0508, 'rougeLsum': 10.9468}
Epoch 3: {'rouge1': 11.8587, 'rouge2': 4.8167, 'rougeL': 11.7986, 'rougeLsum': 11.7518}
Epoch 4: {'rouge1': 12.9842, 'rouge2': 5.5887, 'rougeL': 12.7546, 'rougeLsum': 12.7029}
Epoch 5: {'rouge1': 13.4628, 'rouge2': 6.4598, 'rougeL': 13.312, 'rougeLsum': 13.2913}
Epoch 6: {'rouge1': 12.9131, 'rouge2': 5.8914, 'rougeL': 12.6896, 'rougeLsum': 12.5701}
Epoch 7: {'rouge1': 13.3079, 'rouge2': 6.2994, 'rougeL': 13.1536, 'rougeLsum': 13.1194}
Epoch 8: {'rouge1': 13.96, 'rouge2': 6.5998, 'rougeL': 13.9123, 'rougeLsum': 13.7744}
Epoch 9: {'rouge1': 14.1192, 'rouge2': 7.0059, 'rougeL': 14.1172, 'rougeLsum': 13.9509}`,highlighted:`Epoch <span class="hljs-number">0</span>: {<span class="hljs-string">&#x27;rouge1&#x27;</span>: <span class="hljs-number">5.6351</span>, <span class="hljs-string">&#x27;rouge2&#x27;</span>: <span class="hljs-number">1.1625</span>, <span class="hljs-string">&#x27;rougeL&#x27;</span>: <span class="hljs-number">5.4866</span>, <span class="hljs-string">&#x27;rougeLsum&#x27;</span>: <span class="hljs-number">5.5005</span>}
Epoch <span class="hljs-number">1</span>: {<span class="hljs-string">&#x27;rouge1&#x27;</span>: <span class="hljs-number">9.8646</span>, <span class="hljs-string">&#x27;rouge2&#x27;</span>: <span class="hljs-number">3.4106</span>, <span class="hljs-string">&#x27;rougeL&#x27;</span>: <span class="hljs-number">9.9439</span>, <span class="hljs-string">&#x27;rougeLsum&#x27;</span>: <span class="hljs-number">9.9306</span>}
Epoch <span class="hljs-number">2</span>: {<span class="hljs-string">&#x27;rouge1&#x27;</span>: <span class="hljs-number">11.0872</span>, <span class="hljs-string">&#x27;rouge2&#x27;</span>: <span class="hljs-number">3.3273</span>, <span class="hljs-string">&#x27;rougeL&#x27;</span>: <span class="hljs-number">11.0508</span>, <span class="hljs-string">&#x27;rougeLsum&#x27;</span>: <span class="hljs-number">10.9468</span>}
Epoch <span class="hljs-number">3</span>: {<span class="hljs-string">&#x27;rouge1&#x27;</span>: <span class="hljs-number">11.8587</span>, <span class="hljs-string">&#x27;rouge2&#x27;</span>: <span class="hljs-number">4.8167</span>, <span class="hljs-string">&#x27;rougeL&#x27;</span>: <span class="hljs-number">11.7986</span>, <span class="hljs-string">&#x27;rougeLsum&#x27;</span>: <span class="hljs-number">11.7518</span>}
Epoch <span class="hljs-number">4</span>: {<span class="hljs-string">&#x27;rouge1&#x27;</span>: <span class="hljs-number">12.9842</span>, <span class="hljs-string">&#x27;rouge2&#x27;</span>: <span class="hljs-number">5.5887</span>, <span class="hljs-string">&#x27;rougeL&#x27;</span>: <span class="hljs-number">12.7546</span>, <span class="hljs-string">&#x27;rougeLsum&#x27;</span>: <span class="hljs-number">12.7029</span>}
Epoch <span class="hljs-number">5</span>: {<span class="hljs-string">&#x27;rouge1&#x27;</span>: <span class="hljs-number">13.4628</span>, <span class="hljs-string">&#x27;rouge2&#x27;</span>: <span class="hljs-number">6.4598</span>, <span class="hljs-string">&#x27;rougeL&#x27;</span>: <span class="hljs-number">13.312</span>, <span class="hljs-string">&#x27;rougeLsum&#x27;</span>: <span class="hljs-number">13.2913</span>}
Epoch <span class="hljs-number">6</span>: {<span class="hljs-string">&#x27;rouge1&#x27;</span>: <span class="hljs-number">12.9131</span>, <span class="hljs-string">&#x27;rouge2&#x27;</span>: <span class="hljs-number">5.8914</span>, <span class="hljs-string">&#x27;rougeL&#x27;</span>: <span class="hljs-number">12.6896</span>, <span class="hljs-string">&#x27;rougeLsum&#x27;</span>: <span class="hljs-number">12.5701</span>}
Epoch <span class="hljs-number">7</span>: {<span class="hljs-string">&#x27;rouge1&#x27;</span>: <span class="hljs-number">13.3079</span>, <span class="hljs-string">&#x27;rouge2&#x27;</span>: <span class="hljs-number">6.2994</span>, <span class="hljs-string">&#x27;rougeL&#x27;</span>: <span class="hljs-number">13.1536</span>, <span class="hljs-string">&#x27;rougeLsum&#x27;</span>: <span class="hljs-number">13.1194</span>}
Epoch <span class="hljs-number">8</span>: {<span class="hljs-string">&#x27;rouge1&#x27;</span>: <span class="hljs-number">13.96</span>, <span class="hljs-string">&#x27;rouge2&#x27;</span>: <span class="hljs-number">6.5998</span>, <span class="hljs-string">&#x27;rougeL&#x27;</span>: <span class="hljs-number">13.9123</span>, <span class="hljs-string">&#x27;rougeLsum&#x27;</span>: <span class="hljs-number">13.7744</span>}
Epoch <span class="hljs-number">9</span>: {<span class="hljs-string">&#x27;rouge1&#x27;</span>: <span class="hljs-number">14.1192</span>, <span class="hljs-string">&#x27;rouge2&#x27;</span>: <span class="hljs-number">7.0059</span>, <span class="hljs-string">&#x27;rougeL&#x27;</span>: <span class="hljs-number">14.1172</span>, <span class="hljs-string">&#x27;rougeLsum&#x27;</span>: <span class="hljs-number">13.9509</span>}`}}),{c(){u=h("h2"),w=h("a"),g=h("span"),_(x.$$.fragment),L=m(),E=h("span"),N=e("Tinh ch\u1EC9nh mT5 v\u1EDBi \u{1F917} Accelerate"),O=m(),q=h("p"),z=e("Tinh ch\u1EC9nh m\xF4 h\xECnh c\u1EE7a ch\xFAng ta v\u1EDBi \u{1F917} Accelerate r\u1EA5t gi\u1ED1ng v\u1EDBi v\xED d\u1EE5 ph\xE2n lo\u1EA1i v\u0103n b\u1EA3n m\xE0 ch\xFAng ta \u0111\xE3 g\u1EB7p trong "),S=h("a"),A=e("Ch\u01B0\u01A1ng 3"),D=e(". S\u1EF1 kh\xE1c bi\u1EC7t ch\xEDnh s\u1EBD l\xE0 nhu c\u1EA7u t\u1EA1o t\xF3m t\u1EAFt c\u1EE7a ch\xFAng ta m\u1ED9t c\xE1ch r\xF5 r\xE0ng trong qu\xE1 tr\xECnh hu\u1EA5n luy\u1EC7n v\xE0 x\xE1c \u0111\u1ECBnh c\xE1ch ch\xFAng ta t\xEDnh \u0111i\u1EC3m ROUGE (nh\u1EDB l\u1EA1i r\u1EB1ng "),I=h("code"),X=e("Seq2SeqTrainer"),K=e(" \u0111\xE3 l\xE0m cho ch\xFAng ta). H\xE3y xem c\xE1ch ch\xFAng ta c\xF3 th\u1EC3 th\u1EF1c hi\u1EC7n hai y\xEAu c\u1EA7u n\xE0y trong \u{1F917} Accelerate!"),J=m(),M=h("h3"),Y=h("a"),P=h("span"),_(U.$$.fragment),G=m(),Q=h("span"),an=e("Chu\u1EA9n b\u1ECB m\u1ECDi th\u1EE9 cho hu\u1EA5n luy\u1EC7n"),tn=m(),B=h("p"),sn=e("\u0110i\u1EC1u \u0111\u1EA7u ti\xEAn ch\xFAng ta c\u1EA7n l\xE0m l\xE0 t\u1EA1o m\u1ED9t "),F=h("code"),rn=e("DataLoader"),gn=e(" cho m\u1ED7i ph\u1EA7n t\xE1ch c\u1EE7a ch\xFAng ta. V\xEC c\xE1c b\u1ED9 l\u01B0u tr\u1EEF d\u1EEF li\u1EC7u PyTorch mong \u0111\u1EE3i h\xE0ng lo\u1EA1t c\xE1c tensor, ch\xFAng ta c\u1EA7n \u0111\u1EB7t \u0111\u1ECBnh d\u1EA1ng th\xE0nh "),qn=h("code"),vn=e('"torch"'),Z=e(" trong b\u1ED9 d\u1EEF li\u1EC7u c\u1EE7a m\xECnh:"),_n=m(),_(pn.$$.fragment),nn=m(),yn=h("p"),kn=e("B\xE2y gi\u1EDD ch\xFAng ta \u0111\xE3 c\xF3 t\u1EADp d\u1EEF li\u1EC7u ch\u1EC9 bao g\u1ED3m c\xE1c tensor, vi\u1EC7c ti\u1EBFp theo c\u1EA7n l\xE0m l\xE0 kh\u1EDFi t\u1EA1o l\u1EA1i "),hn=h("code"),Dn=e("DataCollatorForSeq2Seq"),dn=e(". \u0110\u1ED1i v\u1EDBi \u0111i\u1EC1u n\xE0y, ch\xFAng ta c\u1EA7n cung c\u1EA5p m\u1ED9t phi\xEAn b\u1EA3n m\u1EDBi c\u1EE7a m\xF4 h\xECnh, v\xEC v\u1EADy h\xE3y t\u1EA3i l\u1EA1i t\u1EEB b\u1ED9 nh\u1EDB cache c\u1EE7a m\xECnh:"),on=m(),_(v.$$.fragment),R=m(),mn=h("p"),j=e("Sau \u0111\xF3, ch\xFAng ta c\xF3 th\u1EC3 kh\u1EDFi t\u1EA1o tr\xECnh \u0111\u1ED1i chi\u1EBFu d\u1EEF li\u1EC7u v\xE0 s\u1EED d\u1EE5ng c\xF4ng c\u1EE5 n\xE0y \u0111\u1EC3 x\xE1c \u0111\u1ECBnh b\u1ED9 l\u01B0u d\u1EEF li\u1EC7u c\u1EE7a m\xECnh:"),V=m(),_($n.$$.fragment),jn=m(),un=h("p"),Tn=e("\u0110i\u1EC1u ti\u1EBFp theo c\u1EA7n l\xE0m l\xE0 x\xE1c \u0111\u1ECBnh tr\xECnh t\u1ED1i \u01B0u h\xF3a m\xE0 ch\xFAng ta mu\u1ED1n s\u1EED d\u1EE5ng. Nh\u01B0 trong c\xE1c v\xED d\u1EE5 kh\xE1c, ch\xFAng ta s\u1EBD s\u1EED d\u1EE5ng "),en=h("code"),Un=e("AdamW"),tt=e(", tr\xECnh ho\u1EA1t \u0111\u1ED9ng t\u1ED1t cho h\u1EA7u h\u1EBFt c\xE1c v\u1EA5n \u0111\u1EC1:"),cn=m(),_(wn.$$.fragment),Rn=m(),Sn=h("p"),wt=e("Cu\u1ED1i c\xF9ng, ch\xFAng ta cung c\u1EA5p m\xF4 h\xECnh, tr\xECnh t\u1ED1i \u01B0u h\xF3a v\xE0 b\u1ED9 ghi d\u1EEF li\u1EC7u c\u1EE7a m\xECnh v\xE0o ph\u01B0\u01A1ng th\u1EE9c "),ln=h("code"),Yt=e("accelerator.prepare()"),vt=e(":"),ct=m(),_(st.$$.fragment),rt=m(),_(Bn.$$.fragment),xt=m(),Wn=h("p"),_t=e("B\xE2y gi\u1EDD ch\xFAng ta \u0111\xE3 chu\u1EA9n b\u1ECB c\xE1c \u0111\u1ED1i t\u01B0\u1EE3ng c\u1EE7a m\xECnh, c\xF2n ba vi\u1EC7c c\u1EA7n l\xE0m:"),Et=m(),An=h("ul"),it=h("li"),et=e("X\xE1c \u0111\u1ECBnh l\u1ECBch tr\xECnh t\u1ED1c \u0111\u1ED9 h\u1ECDc."),ot=m(),H=h("li"),fn=e("Th\u1EF1c hi\u1EC7n ch\u1EE9c n\u0103ng h\u1EADu x\u1EED l\xFD c\xE1c b\u1EA3n t\xF3m t\u1EAFt \u0111\u1EC3 \u0111\xE1nh gi\xE1."),yt=m(),qt=h("li"),xn=e("T\u1EA1o m\u1ED9t kho l\u01B0u tr\u1EEF tr\xEAn Hub m\xE0 ta c\xF3 th\u1EC3 \u0111\u1EA9y m\xF4 h\xECnh c\u1EE7a m\xECnh l\xEAn \u0111\xF3."),Tt=m(),Fn=h("p"),Qt=e("\u0110\u1ED1i v\u1EDBi l\u1ECBch tr\xECnh t\u1ED1c \u0111\u1ED9 h\u1ECDc, ch\xFAng ta s\u1EBD s\u1EED d\u1EE5ng l\u1ECBch tr\xECnh tuy\u1EBFn t\xEDnh ti\xEAu chu\u1EA9n t\u1EEB c\xE1c ph\u1EA7n tr\u01B0\u1EDBc:"),at=m(),_(ht.$$.fragment),Xn=m(),bn=h("p"),Vn=e("\u0110\u1EC3 h\u1EADu x\u1EED l\xFD, ch\xFAng ta c\u1EA7n m\u1ED9t h\xE0m chia c\xE1c t\xF3m t\u1EAFt \u0111\xE3 t\u1EA1o th\xE0nh c\xE1c c\xE2u \u0111\u01B0\u1EE3c ph\xE2n t\xE1ch b\u1EB1ng c\xE1c d\xF2ng m\u1EDBi. \u0110\xE2y l\xE0 \u0111\u1ECBnh d\u1EA1ng m\xE0 ch\u1EC9 s\u1ED1 ROUGE mong \u0111\u1EE3i v\xE0 ch\xFAng ta c\xF3 th\u1EC3 \u0111\u1EA1t \u0111\u01B0\u1EE3c \u0111i\u1EC1u n\xE0y b\u1EB1ng \u0111o\u1EA1n m\xE3 sau:"),Jt=m(),_(Yn.$$.fragment),Zt=m(),Kn=h("p"),Ct=e("\u0110i\u1EC1u n\xE0y s\u1EBD tr\xF4ng quen thu\u1ED9c v\u1EDBi b\u1EA1n n\u1EBFu b\u1EA1n nh\u1EDB l\u1EA1i c\xE1ch ch\xFAng ta \u0111\xE3 \u0111\u1ECBnh ngh\u0129a h\xE0m "),zt=h("code"),On=e("compute_metrics()"),ns=e(" c\u1EE7a "),Qn=h("code"),ts=e("Seq2SeqTrainer"),mt=e("."),Dt=m(),Cn=h("p"),ra=e("Cu\u1ED1i c\xF9ng, ch\xFAng ta c\u1EA7n t\u1EA1o m\u1ED9t kho l\u01B0u tr\u1EEF m\xF4 h\xECnh tr\xEAn Hugging Face Hub. \u0110\u1ED1i v\u1EDBi \u0111i\u1EC1u n\xE0y, ch\xFAng ta c\xF3 th\u1EC3 s\u1EED d\u1EE5ng th\u01B0 vi\u1EC7n \u{1F917} Hub c\xF3 ti\xEAu \u0111\u1EC1 th\xEDch h\u1EE3p. Ch\xFAng ta ch\u1EC9 c\u1EA7n x\xE1c \u0111\u1ECBnh t\xEAn cho kho l\u01B0u tr\u1EEF c\u1EE7a m\xECnh v\xE0 th\u01B0 vi\u1EC7n c\xF3 ch\u1EE9c n\u0103ng ti\u1EC7n \xEDch \u0111\u1EC3 k\u1EBFt h\u1EE3p ID kho l\u01B0u tr\u1EEF v\u1EDBi h\u1ED3 s\u01A1 ng\u01B0\u1EDDi d\xF9ng:"),ks=m(),_(ss.$$.fragment),_e=m(),_(kt.$$.fragment),ye=m(),$s=h("p"),js=e("B\xE2y gi\u1EDD ch\xFAng ta c\xF3 th\u1EC3 s\u1EED d\u1EE5ng t\xEAn kho l\u01B0u tr\u1EEF n\xE0y \u0111\u1EC3 sao ch\xE9p phi\xEAn b\u1EA3n c\u1EE5c b\u1ED9 v\xE0o th\u01B0 m\u1EE5c k\u1EBFt qu\u1EA3 c\u1EE7a ch\xFAng ta, n\u01A1i s\u1EBD l\u01B0u tr\u1EEF c\xE1c t\u1EA1o t\xE1c hu\u1EA5n luy\u1EC7n:"),ke=m(),_(es.$$.fragment),ws=m(),St=h("p"),ia=e("\u0110i\u1EC1u n\xE0y s\u1EBD cho ph\xE9p ch\xFAng ta \u0111\u1EA9y c\xE1c t\u1EA1o t\xE1c tr\u1EDF l\u1EA1i Hub b\u1EB1ng c\xE1ch g\u1ECDi ph\u01B0\u01A1ng th\u1EE9c "),xs=h("code"),as=e("repo.push_to_hub()"),$e=e(" trong qu\xE1 tr\xECnh hu\u1EA5n luy\u1EC7n! B\xE2y gi\u1EDD ch\xFAng ta h\xE3y k\u1EBFt th\xFAc ph\xE2n t\xEDch b\u1EB1ng c\xE1ch vi\u1EBFt ra v\xF2ng l\u1EB7p hu\u1EA5n luy\u1EC7n."),zn=m(),$t=h("h3"),pt=h("a"),Vs=h("span"),_(hs.$$.fragment),Ks=m(),Ws=h("span"),oa=e("V\xF2ng l\u1EB7p hu\u1EA5n luy\u1EC7n"),Es=m(),qs=h("p"),ma=e("V\xF2ng l\u1EB7p hu\u1EA5n luy\u1EC7n \u0111\u1EC3 t\xF3m t\u1EAFt kh\xE1 gi\u1ED1ng v\u1EDBi c\xE1c v\xED d\u1EE5 \u{1F917} Accelerate kh\xE1c m\xE0 ch\xFAng ta \u0111\xE3 g\u1EB7p v\xE0 g\u1EA7n nh\u01B0 \u0111\u01B0\u1EE3c chia th\xE0nh b\u1ED1n b\u01B0\u1EDBc ch\xEDnh:"),Ts=m(),Jn=h("ol"),ls=h("li"),Xs=e("Hu\u1EA5n luy\u1EC7n m\xF4 h\xECnh b\u1EB1ng c\xE1ch l\u1EB7p l\u1EA1i t\u1EA5t c\u1EA3 c\xE1c v\xED d\u1EE5 trong "),Ys=h("code"),pa=e("train_dataloader"),je=e(" cho m\u1ED7i epoch."),cs=m(),Cs=h("li"),zs=e("T\u1EA1o t\xF3m t\u1EAFt m\xF4 h\xECnh v\xE0o cu\u1ED1i m\u1ED7i epoch, b\u1EB1ng c\xE1ch t\u1EA1o token \u0111\u1EA7u ti\xEAn v\xE0 sau \u0111\xF3 gi\u1EA3i m\xE3 ch\xFAng (v\xE0 t\xF3m t\u1EAFt tham chi\u1EBFu) th\xE0nh v\u0103n b\u1EA3n."),ua=m(),Ds=h("li"),rs=e("T\xEDnh to\xE1n \u0111i\u1EC3m ROUGE b\u1EB1ng c\xE1c k\u1EF9 thu\u1EADt t\u01B0\u01A1ng t\u1EF1 m\xE0 ch\xFAng ta \u0111\xE3 th\u1EA5y tr\u01B0\u1EDBc \u0111\xF3."),we=m(),Pn=h("li"),xe=e("L\u01B0u c\xE1c checkpoint v\xE0 \u0111\u1EA9y m\u1ECDi th\u1EE9 v\xE0o Hub. \u1EDE \u0111\xE2y, ch\xFAng ta d\u1EF1a v\xE0o tham s\u1ED1 "),Hn=h("code"),ga=e("blocking=False"),Qs=e(" ti\u1EC7n l\u1EE3i c\u1EE7a \u0111\u1ED1i t\u01B0\u1EE3ng "),Js=h("code"),da=e("Repository"),Zs=e(" \u0111\u1EC3 c\xF3 th\u1EC3 \u0111\u1EA9y c\xE1c checkpoint \u1EDF m\u1ED7i epoch "),ne=h("em"),fa=e("b\u1EA5t \u0111\u1ED3ng b\u1ED9"),te=e(". \u0110i\u1EC1u n\xE0y cho ph\xE9p ta ti\u1EBFp t\u1EE5c hu\u1EA5n luy\u1EC7n m\xE0 kh\xF4ng ph\u1EA3i \u0111\u1EE3i t\u1EA3i l\xEAn h\u01A1i ch\u1EADm v\u1EDBi m\xF4 h\xECnh c\xF3 k\xEDch th\u01B0\u1EDBc GB!"),Ee=m(),Ss=h("p"),qe=e("C\xE1c b\u01B0\u1EDBc n\xE0y c\xF3 th\u1EC3 \u0111\u01B0\u1EE3c nh\xECn th\u1EA5y trong kh\u1ED1i m\xE3 sau:"),At=m(),_(Ot.$$.fragment),Pt=m(),_(Lt.$$.fragment),is=m(),Nt=h("p"),Te=e("V\xE0 th\u1EBF \u0111\xF3! Khi b\u1EA1n ch\u1EA1y n\xF3, b\u1EA1n s\u1EBD c\xF3 m\u1ED9t m\xF4 h\xECnh v\xE0 k\u1EBFt qu\u1EA3 kh\xE1 gi\u1ED1ng v\u1EDBi nh\u1EEFng m\xF4 h\xECnh m\xE0 ch\xFAng ta thu \u0111\u01B0\u1EE3c v\u1EDBi "),lt=h("code"),os=e("Trainer"),$h=e("."),this.h()},l(o){u=l(o,"H2",{class:!0});var T=c(u);w=l(T,"A",{id:!0,class:!0,href:!0});var ba=c(w);g=l(ba,"SPAN",{});var ms=c(g);y(x.$$.fragment,ms),ms.forEach(s),ba.forEach(s),L=p(T),E=l(T,"SPAN",{});var jh=c(E);N=a(jh,"Tinh ch\u1EC9nh mT5 v\u1EDBi \u{1F917} Accelerate"),jh.forEach(s),T.forEach(s),O=p(o),q=l(o,"P",{});var Rt=c(q);z=a(Rt,"Tinh ch\u1EC9nh m\xF4 h\xECnh c\u1EE7a ch\xFAng ta v\u1EDBi \u{1F917} Accelerate r\u1EA5t gi\u1ED1ng v\u1EDBi v\xED d\u1EE5 ph\xE2n lo\u1EA1i v\u0103n b\u1EA3n m\xE0 ch\xFAng ta \u0111\xE3 g\u1EB7p trong "),S=l(Rt,"A",{href:!0});var wh=c(S);A=a(wh,"Ch\u01B0\u01A1ng 3"),wh.forEach(s),D=a(Rt,". S\u1EF1 kh\xE1c bi\u1EC7t ch\xEDnh s\u1EBD l\xE0 nhu c\u1EA7u t\u1EA1o t\xF3m t\u1EAFt c\u1EE7a ch\xFAng ta m\u1ED9t c\xE1ch r\xF5 r\xE0ng trong qu\xE1 tr\xECnh hu\u1EA5n luy\u1EC7n v\xE0 x\xE1c \u0111\u1ECBnh c\xE1ch ch\xFAng ta t\xEDnh \u0111i\u1EC3m ROUGE (nh\u1EDB l\u1EA1i r\u1EB1ng "),I=l(Rt,"CODE",{});var xh=c(I);X=a(xh,"Seq2SeqTrainer"),xh.forEach(s),K=a(Rt," \u0111\xE3 l\xE0m cho ch\xFAng ta). H\xE3y xem c\xE1ch ch\xFAng ta c\xF3 th\u1EC3 th\u1EF1c hi\u1EC7n hai y\xEAu c\u1EA7u n\xE0y trong \u{1F917} Accelerate!"),Rt.forEach(s),J=p(o),M=l(o,"H3",{class:!0});var se=c(M);Y=l(se,"A",{id:!0,class:!0,href:!0});var As=c(Y);P=l(As,"SPAN",{});var va=c(P);y(U.$$.fragment,va),va.forEach(s),As.forEach(s),G=p(se),Q=l(se,"SPAN",{});var ee=c(Q);an=a(ee,"Chu\u1EA9n b\u1ECB m\u1ECDi th\u1EE9 cho hu\u1EA5n luy\u1EC7n"),ee.forEach(s),se.forEach(s),tn=p(o),B=l(o,"P",{});var Os=c(B);sn=a(Os,"\u0110i\u1EC1u \u0111\u1EA7u ti\xEAn ch\xFAng ta c\u1EA7n l\xE0m l\xE0 t\u1EA1o m\u1ED9t "),F=l(Os,"CODE",{});var _a=c(F);rn=a(_a,"DataLoader"),_a.forEach(s),gn=a(Os," cho m\u1ED7i ph\u1EA7n t\xE1ch c\u1EE7a ch\xFAng ta. V\xEC c\xE1c b\u1ED9 l\u01B0u tr\u1EEF d\u1EEF li\u1EC7u PyTorch mong \u0111\u1EE3i h\xE0ng lo\u1EA1t c\xE1c tensor, ch\xFAng ta c\u1EA7n \u0111\u1EB7t \u0111\u1ECBnh d\u1EA1ng th\xE0nh "),qn=l(Os,"CODE",{});var Ht=c(qn);vn=a(Ht,'"torch"'),Ht.forEach(s),Z=a(Os," trong b\u1ED9 d\u1EEF li\u1EC7u c\u1EE7a m\xECnh:"),Os.forEach(s),_n=p(o),y(pn.$$.fragment,o),nn=p(o),yn=l(o,"P",{});var jt=c(yn);kn=a(jt,"B\xE2y gi\u1EDD ch\xFAng ta \u0111\xE3 c\xF3 t\u1EADp d\u1EEF li\u1EC7u ch\u1EC9 bao g\u1ED3m c\xE1c tensor, vi\u1EC7c ti\u1EBFp theo c\u1EA7n l\xE0m l\xE0 kh\u1EDFi t\u1EA1o l\u1EA1i "),hn=l(jt,"CODE",{});var ze=c(hn);Dn=a(ze,"DataCollatorForSeq2Seq"),ze.forEach(s),dn=a(jt,". \u0110\u1ED1i v\u1EDBi \u0111i\u1EC1u n\xE0y, ch\xFAng ta c\u1EA7n cung c\u1EA5p m\u1ED9t phi\xEAn b\u1EA3n m\u1EDBi c\u1EE7a m\xF4 h\xECnh, v\xEC v\u1EADy h\xE3y t\u1EA3i l\u1EA1i t\u1EEB b\u1ED9 nh\u1EDB cache c\u1EE7a m\xECnh:"),jt.forEach(s),on=p(o),y(v.$$.fragment,o),R=p(o),mn=l(o,"P",{});var Ps=c(mn);j=a(Ps,"Sau \u0111\xF3, ch\xFAng ta c\xF3 th\u1EC3 kh\u1EDFi t\u1EA1o tr\xECnh \u0111\u1ED1i chi\u1EBFu d\u1EEF li\u1EC7u v\xE0 s\u1EED d\u1EE5ng c\xF4ng c\u1EE5 n\xE0y \u0111\u1EC3 x\xE1c \u0111\u1ECBnh b\u1ED9 l\u01B0u d\u1EEF li\u1EC7u c\u1EE7a m\xECnh:"),Ps.forEach(s),V=p(o),y($n.$$.fragment,o),jn=p(o),un=l(o,"P",{});var De=c(un);Tn=a(De,"\u0110i\u1EC1u ti\u1EBFp theo c\u1EA7n l\xE0m l\xE0 x\xE1c \u0111\u1ECBnh tr\xECnh t\u1ED1i \u01B0u h\xF3a m\xE0 ch\xFAng ta mu\u1ED1n s\u1EED d\u1EE5ng. Nh\u01B0 trong c\xE1c v\xED d\u1EE5 kh\xE1c, ch\xFAng ta s\u1EBD s\u1EED d\u1EE5ng "),en=l(De,"CODE",{});var Se=c(en);Un=a(Se,"AdamW"),Se.forEach(s),tt=a(De,", tr\xECnh ho\u1EA1t \u0111\u1ED9ng t\u1ED1t cho h\u1EA7u h\u1EBFt c\xE1c v\u1EA5n \u0111\u1EC1:"),De.forEach(s),cn=p(o),y(wn.$$.fragment,o),Rn=p(o),Sn=l(o,"P",{});var Ae=c(Sn);wt=a(Ae,"Cu\u1ED1i c\xF9ng, ch\xFAng ta cung c\u1EA5p m\xF4 h\xECnh, tr\xECnh t\u1ED1i \u01B0u h\xF3a v\xE0 b\u1ED9 ghi d\u1EEF li\u1EC7u c\u1EE7a m\xECnh v\xE0o ph\u01B0\u01A1ng th\u1EE9c "),ln=l(Ae,"CODE",{});var ya=c(ln);Yt=a(ya,"accelerator.prepare()"),ya.forEach(s),vt=a(Ae,":"),Ae.forEach(s),ct=p(o),y(st.$$.fragment,o),rt=p(o),y(Bn.$$.fragment,o),xt=p(o),Wn=l(o,"P",{});var ps=c(Wn);_t=a(ps,"B\xE2y gi\u1EDD ch\xFAng ta \u0111\xE3 chu\u1EA9n b\u1ECB c\xE1c \u0111\u1ED1i t\u01B0\u1EE3ng c\u1EE7a m\xECnh, c\xF2n ba vi\u1EC7c c\u1EA7n l\xE0m:"),ps.forEach(s),Et=p(o),An=l(o,"UL",{});var Ls=c(An);it=l(Ls,"LI",{});var ae=c(it);et=a(ae,"X\xE1c \u0111\u1ECBnh l\u1ECBch tr\xECnh t\u1ED1c \u0111\u1ED9 h\u1ECDc."),ae.forEach(s),ot=p(Ls),H=l(Ls,"LI",{});var Eh=c(H);fn=a(Eh,"Th\u1EF1c hi\u1EC7n ch\u1EE9c n\u0103ng h\u1EADu x\u1EED l\xFD c\xE1c b\u1EA3n t\xF3m t\u1EAFt \u0111\u1EC3 \u0111\xE1nh gi\xE1."),Eh.forEach(s),yt=p(Ls),qt=l(Ls,"LI",{});var qh=c(qt);xn=a(qh,"T\u1EA1o m\u1ED9t kho l\u01B0u tr\u1EEF tr\xEAn Hub m\xE0 ta c\xF3 th\u1EC3 \u0111\u1EA9y m\xF4 h\xECnh c\u1EE7a m\xECnh l\xEAn \u0111\xF3."),qh.forEach(s),Ls.forEach(s),Tt=p(o),Fn=l(o,"P",{});var ka=c(Fn);Qt=a(ka,"\u0110\u1ED1i v\u1EDBi l\u1ECBch tr\xECnh t\u1ED1c \u0111\u1ED9 h\u1ECDc, ch\xFAng ta s\u1EBD s\u1EED d\u1EE5ng l\u1ECBch tr\xECnh tuy\u1EBFn t\xEDnh ti\xEAu chu\u1EA9n t\u1EEB c\xE1c ph\u1EA7n tr\u01B0\u1EDBc:"),ka.forEach(s),at=p(o),y(ht.$$.fragment,o),Xn=p(o),bn=l(o,"P",{});var us=c(bn);Vn=a(us,"\u0110\u1EC3 h\u1EADu x\u1EED l\xFD, ch\xFAng ta c\u1EA7n m\u1ED9t h\xE0m chia c\xE1c t\xF3m t\u1EAFt \u0111\xE3 t\u1EA1o th\xE0nh c\xE1c c\xE2u \u0111\u01B0\u1EE3c ph\xE2n t\xE1ch b\u1EB1ng c\xE1c d\xF2ng m\u1EDBi. \u0110\xE2y l\xE0 \u0111\u1ECBnh d\u1EA1ng m\xE0 ch\u1EC9 s\u1ED1 ROUGE mong \u0111\u1EE3i v\xE0 ch\xFAng ta c\xF3 th\u1EC3 \u0111\u1EA1t \u0111\u01B0\u1EE3c \u0111i\u1EC1u n\xE0y b\u1EB1ng \u0111o\u1EA1n m\xE3 sau:"),us.forEach(s),Jt=p(o),y(Yn.$$.fragment,o),Zt=p(o),Kn=l(o,"P",{});var It=c(Kn);Ct=a(It,"\u0110i\u1EC1u n\xE0y s\u1EBD tr\xF4ng quen thu\u1ED9c v\u1EDBi b\u1EA1n n\u1EBFu b\u1EA1n nh\u1EDB l\u1EA1i c\xE1ch ch\xFAng ta \u0111\xE3 \u0111\u1ECBnh ngh\u0129a h\xE0m "),zt=l(It,"CODE",{});var Gt=c(zt);On=a(Gt,"compute_metrics()"),Gt.forEach(s),ns=a(It," c\u1EE7a "),Qn=l(It,"CODE",{});var he=c(Qn);ts=a(he,"Seq2SeqTrainer"),he.forEach(s),mt=a(It,"."),It.forEach(s),Dt=p(o),Cn=l(o,"P",{});var Th=c(Cn);ra=a(Th,"Cu\u1ED1i c\xF9ng, ch\xFAng ta c\u1EA7n t\u1EA1o m\u1ED9t kho l\u01B0u tr\u1EEF m\xF4 h\xECnh tr\xEAn Hugging Face Hub. \u0110\u1ED1i v\u1EDBi \u0111i\u1EC1u n\xE0y, ch\xFAng ta c\xF3 th\u1EC3 s\u1EED d\u1EE5ng th\u01B0 vi\u1EC7n \u{1F917} Hub c\xF3 ti\xEAu \u0111\u1EC1 th\xEDch h\u1EE3p. Ch\xFAng ta ch\u1EC9 c\u1EA7n x\xE1c \u0111\u1ECBnh t\xEAn cho kho l\u01B0u tr\u1EEF c\u1EE7a m\xECnh v\xE0 th\u01B0 vi\u1EC7n c\xF3 ch\u1EE9c n\u0103ng ti\u1EC7n \xEDch \u0111\u1EC3 k\u1EBFt h\u1EE3p ID kho l\u01B0u tr\u1EEF v\u1EDBi h\u1ED3 s\u01A1 ng\u01B0\u1EDDi d\xF9ng:"),Th.forEach(s),ks=p(o),y(ss.$$.fragment,o),_e=p(o),y(kt.$$.fragment,o),ye=p(o),$s=l(o,"P",{});var Ch=c($s);js=a(Ch,"B\xE2y gi\u1EDD ch\xFAng ta c\xF3 th\u1EC3 s\u1EED d\u1EE5ng t\xEAn kho l\u01B0u tr\u1EEF n\xE0y \u0111\u1EC3 sao ch\xE9p phi\xEAn b\u1EA3n c\u1EE5c b\u1ED9 v\xE0o th\u01B0 m\u1EE5c k\u1EBFt qu\u1EA3 c\u1EE7a ch\xFAng ta, n\u01A1i s\u1EBD l\u01B0u tr\u1EEF c\xE1c t\u1EA1o t\xE1c hu\u1EA5n luy\u1EC7n:"),Ch.forEach(s),ke=p(o),y(es.$$.fragment,o),ws=p(o),St=l(o,"P",{});var Ns=c(St);ia=a(Ns,"\u0110i\u1EC1u n\xE0y s\u1EBD cho ph\xE9p ch\xFAng ta \u0111\u1EA9y c\xE1c t\u1EA1o t\xE1c tr\u1EDF l\u1EA1i Hub b\u1EB1ng c\xE1ch g\u1ECDi ph\u01B0\u01A1ng th\u1EE9c "),xs=l(Ns,"CODE",{});var zh=c(xs);as=a(zh,"repo.push_to_hub()"),zh.forEach(s),$e=a(Ns," trong qu\xE1 tr\xECnh hu\u1EA5n luy\u1EC7n! B\xE2y gi\u1EDD ch\xFAng ta h\xE3y k\u1EBFt th\xFAc ph\xE2n t\xEDch b\u1EB1ng c\xE1ch vi\u1EBFt ra v\xF2ng l\u1EB7p hu\u1EA5n luy\u1EC7n."),Ns.forEach(s),zn=p(o),$t=l(o,"H3",{class:!0});var Oe=c($t);pt=l(Oe,"A",{id:!0,class:!0,href:!0});var le=c(pt);Vs=l(le,"SPAN",{});var Dh=c(Vs);y(hs.$$.fragment,Dh),Dh.forEach(s),le.forEach(s),Ks=p(Oe),Ws=l(Oe,"SPAN",{});var Sh=c(Ws);oa=a(Sh,"V\xF2ng l\u1EB7p hu\u1EA5n luy\u1EC7n"),Sh.forEach(s),Oe.forEach(s),Es=p(o),qs=l(o,"P",{});var In=c(qs);ma=a(In,"V\xF2ng l\u1EB7p hu\u1EA5n luy\u1EC7n \u0111\u1EC3 t\xF3m t\u1EAFt kh\xE1 gi\u1ED1ng v\u1EDBi c\xE1c v\xED d\u1EE5 \u{1F917} Accelerate kh\xE1c m\xE0 ch\xFAng ta \u0111\xE3 g\u1EB7p v\xE0 g\u1EA7n nh\u01B0 \u0111\u01B0\u1EE3c chia th\xE0nh b\u1ED1n b\u01B0\u1EDBc ch\xEDnh:"),In.forEach(s),Ts=p(o),Jn=l(o,"OL",{});var Gn=c(Jn);ls=l(Gn,"LI",{});var gs=c(ls);Xs=a(gs,"Hu\u1EA5n luy\u1EC7n m\xF4 h\xECnh b\u1EB1ng c\xE1ch l\u1EB7p l\u1EA1i t\u1EA5t c\u1EA3 c\xE1c v\xED d\u1EE5 trong "),Ys=l(gs,"CODE",{});var Rs=c(Ys);pa=a(Rs,"train_dataloader"),Rs.forEach(s),je=a(gs," cho m\u1ED7i epoch."),gs.forEach(s),cs=p(Gn),Cs=l(Gn,"LI",{});var Ah=c(Cs);zs=a(Ah,"T\u1EA1o t\xF3m t\u1EAFt m\xF4 h\xECnh v\xE0o cu\u1ED1i m\u1ED7i epoch, b\u1EB1ng c\xE1ch t\u1EA1o token \u0111\u1EA7u ti\xEAn v\xE0 sau \u0111\xF3 gi\u1EA3i m\xE3 ch\xFAng (v\xE0 t\xF3m t\u1EAFt tham chi\u1EBFu) th\xE0nh v\u0103n b\u1EA3n."),Ah.forEach(s),ua=p(Gn),Ds=l(Gn,"LI",{});var Oh=c(Ds);rs=a(Oh,"T\xEDnh to\xE1n \u0111i\u1EC3m ROUGE b\u1EB1ng c\xE1c k\u1EF9 thu\u1EADt t\u01B0\u01A1ng t\u1EF1 m\xE0 ch\xFAng ta \u0111\xE3 th\u1EA5y tr\u01B0\u1EDBc \u0111\xF3."),Oh.forEach(s),we=p(Gn),Pn=l(Gn,"LI",{});var ut=c(Pn);xe=a(ut,"L\u01B0u c\xE1c checkpoint v\xE0 \u0111\u1EA9y m\u1ECDi th\u1EE9 v\xE0o Hub. \u1EDE \u0111\xE2y, ch\xFAng ta d\u1EF1a v\xE0o tham s\u1ED1 "),Hn=l(ut,"CODE",{});var Ph=c(Hn);ga=a(Ph,"blocking=False"),Ph.forEach(s),Qs=a(ut," ti\u1EC7n l\u1EE3i c\u1EE7a \u0111\u1ED1i t\u01B0\u1EE3ng "),Js=l(ut,"CODE",{});var Lh=c(Js);da=a(Lh,"Repository"),Lh.forEach(s),Zs=a(ut," \u0111\u1EC3 c\xF3 th\u1EC3 \u0111\u1EA9y c\xE1c checkpoint \u1EDF m\u1ED7i epoch "),ne=l(ut,"EM",{});var ce=c(ne);fa=a(ce,"b\u1EA5t \u0111\u1ED3ng b\u1ED9"),ce.forEach(s),te=a(ut,". \u0110i\u1EC1u n\xE0y cho ph\xE9p ta ti\u1EBFp t\u1EE5c hu\u1EA5n luy\u1EC7n m\xE0 kh\xF4ng ph\u1EA3i \u0111\u1EE3i t\u1EA3i l\xEAn h\u01A1i ch\u1EADm v\u1EDBi m\xF4 h\xECnh c\xF3 k\xEDch th\u01B0\u1EDBc GB!"),ut.forEach(s),Gn.forEach(s),Ee=p(o),Ss=l(o,"P",{});var Nh=c(Ss);qe=a(Nh,"C\xE1c b\u01B0\u1EDBc n\xE0y c\xF3 th\u1EC3 \u0111\u01B0\u1EE3c nh\xECn th\u1EA5y trong kh\u1ED1i m\xE3 sau:"),Nh.forEach(s),At=p(o),y(Ot.$$.fragment,o),Pt=p(o),y(Lt.$$.fragment,o),is=p(o),Nt=l(o,"P",{});var Pe=c(Nt);Te=a(Pe,"V\xE0 th\u1EBF \u0111\xF3! Khi b\u1EA1n ch\u1EA1y n\xF3, b\u1EA1n s\u1EBD c\xF3 m\u1ED9t m\xF4 h\xECnh v\xE0 k\u1EBFt qu\u1EA3 kh\xE1 gi\u1ED1ng v\u1EDBi nh\u1EEFng m\xF4 h\xECnh m\xE0 ch\xFAng ta thu \u0111\u01B0\u1EE3c v\u1EDBi "),lt=l(Pe,"CODE",{});var Mt=c(lt);os=a(Mt,"Trainer"),Mt.forEach(s),$h=a(Pe,"."),Pe.forEach(s),this.h()},h(){d(w,"id","tinh-chnh-mt5-vi-accelerate"),d(w,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),d(w,"href","#tinh-chnh-mt5-vi-accelerate"),d(u,"class","relative group"),d(S,"href","/course/chapter3"),d(Y,"id","chun-b-mi-th-cho-hun-luyn"),d(Y,"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"),d(Y,"href","#chun-b-mi-th-cho-hun-luyn"),d(M,"class","relative group"),d(pt,"id","vng-lp-hun-luyn"),d(pt,"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"),d(pt,"href","#vng-lp-hun-luyn"),d($t,"class","relative group")},m(o,T){r(o,u,T),t(u,w),t(w,g),k(x,g,null),t(u,L),t(u,E),t(E,N),r(o,O,T),r(o,q,T),t(q,z),t(q,S),t(S,A),t(q,D),t(q,I),t(I,X),t(q,K),r(o,J,T),r(o,M,T),t(M,Y),t(Y,P),k(U,P,null),t(M,G),t(M,Q),t(Q,an),r(o,tn,T),r(o,B,T),t(B,sn),t(B,F),t(F,rn),t(B,gn),t(B,qn),t(qn,vn),t(B,Z),r(o,_n,T),k(pn,o,T),r(o,nn,T),r(o,yn,T),t(yn,kn),t(yn,hn),t(hn,Dn),t(yn,dn),r(o,on,T),k(v,o,T),r(o,R,T),r(o,mn,T),t(mn,j),r(o,V,T),k($n,o,T),r(o,jn,T),r(o,un,T),t(un,Tn),t(un,en),t(en,Un),t(un,tt),r(o,cn,T),k(wn,o,T),r(o,Rn,T),r(o,Sn,T),t(Sn,wt),t(Sn,ln),t(ln,Yt),t(Sn,vt),r(o,ct,T),k(st,o,T),r(o,rt,T),k(Bn,o,T),r(o,xt,T),r(o,Wn,T),t(Wn,_t),r(o,Et,T),r(o,An,T),t(An,it),t(it,et),t(An,ot),t(An,H),t(H,fn),t(An,yt),t(An,qt),t(qt,xn),r(o,Tt,T),r(o,Fn,T),t(Fn,Qt),r(o,at,T),k(ht,o,T),r(o,Xn,T),r(o,bn,T),t(bn,Vn),r(o,Jt,T),k(Yn,o,T),r(o,Zt,T),r(o,Kn,T),t(Kn,Ct),t(Kn,zt),t(zt,On),t(Kn,ns),t(Kn,Qn),t(Qn,ts),t(Kn,mt),r(o,Dt,T),r(o,Cn,T),t(Cn,ra),r(o,ks,T),k(ss,o,T),r(o,_e,T),k(kt,o,T),r(o,ye,T),r(o,$s,T),t($s,js),r(o,ke,T),k(es,o,T),r(o,ws,T),r(o,St,T),t(St,ia),t(St,xs),t(xs,as),t(St,$e),r(o,zn,T),r(o,$t,T),t($t,pt),t(pt,Vs),k(hs,Vs,null),t($t,Ks),t($t,Ws),t(Ws,oa),r(o,Es,T),r(o,qs,T),t(qs,ma),r(o,Ts,T),r(o,Jn,T),t(Jn,ls),t(ls,Xs),t(ls,Ys),t(Ys,pa),t(ls,je),t(Jn,cs),t(Jn,Cs),t(Cs,zs),t(Jn,ua),t(Jn,Ds),t(Ds,rs),t(Jn,we),t(Jn,Pn),t(Pn,xe),t(Pn,Hn),t(Hn,ga),t(Pn,Qs),t(Pn,Js),t(Js,da),t(Pn,Zs),t(Pn,ne),t(ne,fa),t(Pn,te),r(o,Ee,T),r(o,Ss,T),t(Ss,qe),r(o,At,T),k(Ot,o,T),r(o,Pt,T),k(Lt,o,T),r(o,is,T),r(o,Nt,T),t(Nt,Te),t(Nt,lt),t(lt,os),t(Nt,$h),Ce=!0},i(o){Ce||(f(x.$$.fragment,o),f(U.$$.fragment,o),f(pn.$$.fragment,o),f(v.$$.fragment,o),f($n.$$.fragment,o),f(wn.$$.fragment,o),f(st.$$.fragment,o),f(Bn.$$.fragment,o),f(ht.$$.fragment,o),f(Yn.$$.fragment,o),f(ss.$$.fragment,o),f(kt.$$.fragment,o),f(es.$$.fragment,o),f(hs.$$.fragment,o),f(Ot.$$.fragment,o),f(Lt.$$.fragment,o),Ce=!0)},o(o){b(x.$$.fragment,o),b(U.$$.fragment,o),b(pn.$$.fragment,o),b(v.$$.fragment,o),b($n.$$.fragment,o),b(wn.$$.fragment,o),b(st.$$.fragment,o),b(Bn.$$.fragment,o),b(ht.$$.fragment,o),b(Yn.$$.fragment,o),b(ss.$$.fragment,o),b(kt.$$.fragment,o),b(es.$$.fragment,o),b(hs.$$.fragment,o),b(Ot.$$.fragment,o),b(Lt.$$.fragment,o),Ce=!1},d(o){o&&s(u),$(x),o&&s(O),o&&s(q),o&&s(J),o&&s(M),$(U),o&&s(tn),o&&s(B),o&&s(_n),$(pn,o),o&&s(nn),o&&s(yn),o&&s(on),$(v,o),o&&s(R),o&&s(mn),o&&s(V),$($n,o),o&&s(jn),o&&s(un),o&&s(cn),$(wn,o),o&&s(Rn),o&&s(Sn),o&&s(ct),$(st,o),o&&s(rt),$(Bn,o),o&&s(xt),o&&s(Wn),o&&s(Et),o&&s(An),o&&s(Tt),o&&s(Fn),o&&s(at),$(ht,o),o&&s(Xn),o&&s(bn),o&&s(Jt),$(Yn,o),o&&s(Zt),o&&s(Kn),o&&s(Dt),o&&s(Cn),o&&s(ks),$(ss,o),o&&s(_e),$(kt,o),o&&s(ye),o&&s($s),o&&s(ke),$(es,o),o&&s(ws),o&&s(St),o&&s(zn),o&&s($t),$(hs),o&&s(Es),o&&s(qs),o&&s(Ts),o&&s(Jn),o&&s(Ee),o&&s(Ss),o&&s(At),$(Ot,o),o&&s(Pt),$(Lt,o),o&&s(is),o&&s(Nt)}}}function Kf(W){let u,w;return{c(){u=h("p"),w=e("\u{1F6A8} N\u1EBFu b\u1EA1n \u0111ang hu\u1EA5n luy\u1EC7n tr\xEAn TPU, b\u1EA1n s\u1EBD c\u1EA7n chuy\u1EC3n t\u1EA5t c\u1EA3 \u0111o\u1EA1n m\xE3 \u1EDF tr\xEAn v\xE0o m\u1ED9t h\xE0m hu\u1EA5n luy\u1EC7n chuy\xEAn d\u1EE5ng. Xem [Ch\u01B0\u01A1ng 3(/course/chapter3) \u0111\u1EC3 bi\u1EBFt th\xEAm chi ti\u1EBFt.")},l(g){u=l(g,"P",{});var x=c(u);w=a(x,"\u{1F6A8} N\u1EBFu b\u1EA1n \u0111ang hu\u1EA5n luy\u1EC7n tr\xEAn TPU, b\u1EA1n s\u1EBD c\u1EA7n chuy\u1EC3n t\u1EA5t c\u1EA3 \u0111o\u1EA1n m\xE3 \u1EDF tr\xEAn v\xE0o m\u1ED9t h\xE0m hu\u1EA5n luy\u1EC7n chuy\xEAn d\u1EE5ng. Xem [Ch\u01B0\u01A1ng 3(/course/chapter3) \u0111\u1EC3 bi\u1EBFt th\xEAm chi ti\u1EBFt."),x.forEach(s)},m(g,x){r(g,u,x),t(u,w)},d(g){g&&s(u)}}}function Wf(W){let u,w,g,x,L,E,N,O,q,z,S,A,D,I,X,K,J,M,Y,P,U,G,Q,an,tn,B,sn,F,rn,gn,qn,vn,Z,_n,pn,nn,yn,kn,hn,Dn,dn,on,v,R,mn,j,V,$n,jn,un,Tn,en,Un,tt,cn,wn,Rn,Sn,wt,ln,Yt,vt,ct,st,rt,Bn,xt,Wn,_t,Et,An,it,et,ot,H,fn,yt,qt,xn,Tt,Fn,Qt,at,ht,Xn,bn,Vn,Jt,Yn,Zt,Kn,Ct,zt,On,ns,Qn,ts,mt,Dt,Cn,ra,ks,ss,_e,kt,ye,$s,js,ke,es,ws,St,ia,xs,as,$e,zn,$t,pt,Vs,hs,Ks,Ws,oa,Es,qs,ma,Ts,Jn,ls,Xs,Ys,pa,je,cs,Cs,zs,ua,Ds,rs,we,Pn,xe,Hn,ga,Qs,Js,da,Zs,ne,fa,te,Ee,Ss,qe,At,Ot,Pt,Lt,is,Nt,Te,lt,os,$h,Ce,o,T,ba,ms,jh,Rt,wh,xh,se,As,va,ee,Os,_a,Ht,jt,ze,Ps,De,Se,Ae,ya,ps,Ls,ae,Eh,qh,ka,us,It,Gt,he,Th,Ch,Ns,zh,Oe,le,Dh,Sh,In,Gn,gs,Rs,Ah,Oh,ut,Ph,Lh,ce,Nh,Pe,Mt,Rh,$a,Zi,no,Pl,to,so,Hh,eo,ao,re,Ih,ja,ho,lo,wa,co,Ll,ro,io,oo,Gh,mo,po,ie,Mh,xa,uo,go,Nl,fo,bo,Uh,vo,_o,oe,Bh,Ea,yo,ko,Rl,$o,jo,Fh,wo,xo,me,Vh,qa,Eo,qo,Hl,To,Co,Kh,zo,Xc,Wh,Do,Yc,Le,So,Il,Ao,Oo,Qc,pe,Ta,Tu,Po,Ca,Cu,Jc,Xh,Lo,Zc,Ne,nr,ue,Re,Gl,za,No,Ml,Ro,tr,Da,sr,He,Ho,Ul,Io,Go,er,Sa,ar,Ie,hr,Yh,Mo,lr,Aa,cr,Oa,rr,gt,Uo,Bl,Bo,Fo,Fl,Vo,Ko,Qh,Wo,Xo,Vl,Yo,Qo,ir,Pa,or,La,mr,Ut,Jo,Kl,Zo,nm,Wl,tm,sm,Jh,em,am,pr,Ge,hm,Xl,lm,cm,ur,Na,gr,dt,rm,Yl,im,om,Ql,mm,pm,Jl,um,gm,Zl,dm,fm,dr,Hs,bm,nc,vm,_m,tc,ym,km,fr,Ra,br,Zh,$m,vr,Me,_r,ge,Ue,sc,Ha,jm,ec,wm,yr,Ia,kr,nl,xm,$r,Be,Em,Ga,qm,Tm,jr,Ma,wr,Is,Cm,ac,zm,Dm,hc,Sm,Am,xr,Fe,Er,Ua,Om,qr,wf='<span class="katex-display"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML" display="block"><semantics><mrow><mrow><mi mathvariant="normal">R</mi><mi mathvariant="normal">e</mi><mi mathvariant="normal">c</mi><mi mathvariant="normal">a</mi><mi mathvariant="normal">l</mi><mi mathvariant="normal">l</mi></mrow><mo>=</mo><mfrac><mrow><mi mathvariant="normal">N</mi><mi mathvariant="normal">u</mi><mi mathvariant="normal">m</mi><mi mathvariant="normal">b</mi><mi mathvariant="normal">e</mi><mi mathvariant="normal">r</mi><mtext>\u2009</mtext><mi mathvariant="normal">o</mi><mi mathvariant="normal">f</mi><mtext>\u2009</mtext><mi mathvariant="normal">o</mi><mi mathvariant="normal">v</mi><mi mathvariant="normal">e</mi><mi mathvariant="normal">r</mi><mi mathvariant="normal">l</mi><mi mathvariant="normal">a</mi><mi mathvariant="normal">p</mi><mi mathvariant="normal">p</mi><mi mathvariant="normal">i</mi><mi mathvariant="normal">n</mi><mi mathvariant="normal">g</mi><mtext>\u2009</mtext><mi mathvariant="normal">w</mi><mi mathvariant="normal">o</mi><mi mathvariant="normal">r</mi><mi mathvariant="normal">d</mi><mi mathvariant="normal">s</mi></mrow><mrow><mi mathvariant="normal">T</mi><mi mathvariant="normal">o</mi><mi mathvariant="normal">t</mi><mi mathvariant="normal">a</mi><mi mathvariant="normal">l</mi><mtext>\u2009</mtext><mi mathvariant="normal">n</mi><mi mathvariant="normal">u</mi><mi mathvariant="normal">m</mi><mi mathvariant="normal">b</mi><mi mathvariant="normal">e</mi><mi mathvariant="normal">r</mi><mtext>\u2009</mtext><mi mathvariant="normal">o</mi><mi mathvariant="normal">f</mi><mtext>\u2009</mtext><mi mathvariant="normal">w</mi><mi mathvariant="normal">o</mi><mi mathvariant="normal">r</mi><mi mathvariant="normal">d</mi><mi mathvariant="normal">s</mi><mtext>\u2009</mtext><mi mathvariant="normal">i</mi><mi mathvariant="normal">n</mi><mtext>\u2009</mtext><mi mathvariant="normal">r</mi><mi mathvariant="normal">e</mi><mi mathvariant="normal">f</mi><mi mathvariant="normal">e</mi><mi mathvariant="normal">r</mi><mi mathvariant="normal">e</mi><mi mathvariant="normal">n</mi><mi mathvariant="normal">c</mi><mi mathvariant="normal">e</mi><mtext>\u2009</mtext><mi mathvariant="normal">s</mi><mi mathvariant="normal">u</mi><mi mathvariant="normal">m</mi><mi mathvariant="normal">m</mi><mi mathvariant="normal">a</mi><mi mathvariant="normal">r</mi><mi mathvariant="normal">y</mi></mrow></mfrac></mrow><annotation encoding="application/x-tex"> \\mathrm{Recall} = \\frac{\\mathrm{Number\\,of\\,overlapping\\, words}}{\\mathrm{Total\\, number\\, of\\, words\\, in\\, reference\\, summary}} </annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord"><span class="mord mathrm">Recall</span></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:2.2519em;vertical-align:-0.8804em;"></span><span class="mord"><span class="mopen nulldelimiter"></span><span class="mfrac"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.3714em;"><span style="top:-2.314em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord"><span class="mord mathrm">Total</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord mathrm">number</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord mathrm" style="margin-right:0.07778em;">of</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord mathrm">words</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord mathrm">in</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord mathrm">reference</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord mathrm" style="margin-right:0.01389em;">summary</span></span></span></span><span style="top:-3.23em;"><span class="pstrut" style="height:3em;"></span><span class="frac-line" style="border-bottom-width:0.04em;"></span></span><span style="top:-3.677em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord"><span class="mord mathrm">Number</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord mathrm" style="margin-right:0.07778em;">of</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord mathrm" style="margin-right:0.01389em;">overlapping</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord mathrm">words</span></span></span></span></span><span class="vlist-s">\u200B</span></span><span class="vlist-r"><span class="vlist" style="height:0.8804em;"><span></span></span></span></span></span><span class="mclose nulldelimiter"></span></span></span></span></span></span>',Tr,Ba,Pm,Cr,xf='<span class="katex-display"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML" display="block"><semantics><mrow><mrow><mi mathvariant="normal">P</mi><mi mathvariant="normal">r</mi><mi mathvariant="normal">e</mi><mi mathvariant="normal">c</mi><mi mathvariant="normal">i</mi><mi mathvariant="normal">s</mi><mi mathvariant="normal">i</mi><mi mathvariant="normal">o</mi><mi mathvariant="normal">n</mi></mrow><mo>=</mo><mfrac><mrow><mi mathvariant="normal">N</mi><mi mathvariant="normal">u</mi><mi mathvariant="normal">m</mi><mi mathvariant="normal">b</mi><mi mathvariant="normal">e</mi><mi mathvariant="normal">r</mi><mtext>\u2009</mtext><mi mathvariant="normal">o</mi><mi mathvariant="normal">f</mi><mtext>\u2009</mtext><mi mathvariant="normal">o</mi><mi mathvariant="normal">v</mi><mi mathvariant="normal">e</mi><mi mathvariant="normal">r</mi><mi mathvariant="normal">l</mi><mi mathvariant="normal">a</mi><mi mathvariant="normal">p</mi><mi mathvariant="normal">p</mi><mi mathvariant="normal">i</mi><mi mathvariant="normal">n</mi><mi mathvariant="normal">g</mi><mtext>\u2009</mtext><mi mathvariant="normal">w</mi><mi mathvariant="normal">o</mi><mi mathvariant="normal">r</mi><mi mathvariant="normal">d</mi><mi mathvariant="normal">s</mi></mrow><mrow><mi mathvariant="normal">T</mi><mi mathvariant="normal">o</mi><mi mathvariant="normal">t</mi><mi mathvariant="normal">a</mi><mi mathvariant="normal">l</mi><mtext>\u2009</mtext><mi mathvariant="normal">n</mi><mi mathvariant="normal">u</mi><mi mathvariant="normal">m</mi><mi mathvariant="normal">b</mi><mi mathvariant="normal">e</mi><mi mathvariant="normal">r</mi><mtext>\u2009</mtext><mi mathvariant="normal">o</mi><mi mathvariant="normal">f</mi><mtext>\u2009</mtext><mi mathvariant="normal">w</mi><mi mathvariant="normal">o</mi><mi mathvariant="normal">r</mi><mi mathvariant="normal">d</mi><mi mathvariant="normal">s</mi><mtext>\u2009</mtext><mi mathvariant="normal">i</mi><mi mathvariant="normal">n</mi><mtext>\u2009</mtext><mi mathvariant="normal">g</mi><mi mathvariant="normal">e</mi><mi mathvariant="normal">n</mi><mi mathvariant="normal">e</mi><mi mathvariant="normal">r</mi><mi mathvariant="normal">a</mi><mi mathvariant="normal">t</mi><mi mathvariant="normal">e</mi><mi mathvariant="normal">d</mi><mtext>\u2009</mtext><mi mathvariant="normal">s</mi><mi mathvariant="normal">u</mi><mi mathvariant="normal">m</mi><mi mathvariant="normal">m</mi><mi mathvariant="normal">a</mi><mi mathvariant="normal">r</mi><mi mathvariant="normal">y</mi></mrow></mfrac></mrow><annotation encoding="application/x-tex"> \\mathrm{Precision} = \\frac{\\mathrm{Number\\,of\\,overlapping\\, words}}{\\mathrm{Total\\, number\\, of\\, words\\, in\\, generated\\, summary}} </annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6833em;"></span><span class="mord"><span class="mord mathrm">Precision</span></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:2.2519em;vertical-align:-0.8804em;"></span><span class="mord"><span class="mopen nulldelimiter"></span><span class="mfrac"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:1.3714em;"><span style="top:-2.314em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord"><span class="mord mathrm">Total</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord mathrm">number</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord mathrm" style="margin-right:0.07778em;">of</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord mathrm">words</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord mathrm">in</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord mathrm">generated</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord mathrm" style="margin-right:0.01389em;">summary</span></span></span></span><span style="top:-3.23em;"><span class="pstrut" style="height:3em;"></span><span class="frac-line" style="border-bottom-width:0.04em;"></span></span><span style="top:-3.677em;"><span class="pstrut" style="height:3em;"></span><span class="mord"><span class="mord"><span class="mord mathrm">Number</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord mathrm" style="margin-right:0.07778em;">of</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord mathrm" style="margin-right:0.01389em;">overlapping</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord mathrm">words</span></span></span></span></span><span class="vlist-s">\u200B</span></span><span class="vlist-r"><span class="vlist" style="height:0.8804em;"><span></span></span></span></span></span><span class="mclose nulldelimiter"></span></span></span></span></span></span>',zr,Ve,Lm,lc,Nm,Rm,Dr,Fa,Sr,tl,Hm,Ar,Va,Or,Ke,Im,cc,Gm,Mm,Pr,Ka,Lr,Wa,Nr,Zn,Um,rc,Bm,Fm,ic,Vm,Km,oc,Wm,Xm,mc,Ym,Qm,pc,Jm,Zm,Rr,Xa,Hr,Ya,Ir,nt,np,uc,tp,sp,gc,ep,ap,dc,hp,lp,fc,cp,rp,bc,ip,op,Gr,We,Mr,sl,mp,Ur,de,Xe,vc,Qa,pp,_c,up,Br,ft,gp,yc,dp,fp,kc,bp,vp,$c,_p,yp,jc,kp,$p,Fr,Ja,Vr,el,jp,Kr,Za,Wr,Ye,wp,wc,xp,Ep,Xr,nh,Yr,th,Qr,al,qp,Jr,sh,Zr,hl,Tp,ni,eh,ti,ah,si,Qe,Cp,xc,zp,Dp,ei,ds,fs,ll,Je,ai,cl,Sp,hi,hh,li,rl,Ap,ci,lh,ri,il,Ze,Op,ol,Pp,Lp,ii,Bt,Np,Ec,Rp,Hp,qc,Ip,Gp,Tc,Mp,Up,oi,bs,vs,ml,pl,Bp,mi,ch,pi,Gs,Fp,Cc,Vp,Kp,zc,Wp,Xp,ui,rh,gi,ih,di,En,Yp,Dc,Qp,Jp,Sc,Zp,nu,Ac,tu,su,Oc,eu,au,Pc,hu,lu,Lc,cu,ru,Nc,iu,ou,Rc,mu,pu,fi,_s,ys,ul,gl,fe,na,Hc,oh,uu,Ic,gu,bi,ta,du,Gc,fu,bu,vi,mh,_i,dl,vu,yi,ph,ki,fl,_u,$i,uh,ji,gh,wi,sa,yu,Mc,ku,$u,xi,dh,Ei,fh,qi,bl,ju,Ti,vl,wu,Ci;g=new Df({props:{fw:W[0]}}),O=new Xt({});const zu=[Af,Sf],bh=[];function Du(n,i){return n[0]==="pt"?0:1}D=Du(W),I=bh[D]=zu[D](W),tn=new qu({props:{id:"yHnr5Dk2zCI"}}),mn=new Xt({}),wn=new C({props:{code:`from datasets import load_dataset

spanish_dataset = load_dataset("amazon_reviews_multi", "es")
english_dataset = load_dataset("amazon_reviews_multi", "en")
english_dataset`,highlighted:`<span class="hljs-keyword">from</span> datasets <span class="hljs-keyword">import</span> load_dataset

spanish_dataset = load_dataset(<span class="hljs-string">&quot;amazon_reviews_multi&quot;</span>, <span class="hljs-string">&quot;es&quot;</span>)
english_dataset = load_dataset(<span class="hljs-string">&quot;amazon_reviews_multi&quot;</span>, <span class="hljs-string">&quot;en&quot;</span>)
english_dataset`}}),Sn=new C({props:{code:`DatasetDict({
    train: Dataset({
        features: ['review_id', 'product_id', 'reviewer_id', 'stars', 'review_body', 'review_title', 'language', 'product_category'],
        num_rows: 200000
    })
    validation: Dataset({
        features: ['review_id', 'product_id', 'reviewer_id', 'stars', 'review_body', 'review_title', 'language', 'product_category'],
        num_rows: 5000
    })
    test: Dataset({
        features: ['review_id', 'product_id', 'reviewer_id', 'stars', 'review_body', 'review_title', 'language', 'product_category'],
        num_rows: 5000
    })
})`,highlighted:`DatasetDict({
    train: Dataset({
        features: [<span class="hljs-string">&#x27;review_id&#x27;</span>, <span class="hljs-string">&#x27;product_id&#x27;</span>, <span class="hljs-string">&#x27;reviewer_id&#x27;</span>, <span class="hljs-string">&#x27;stars&#x27;</span>, <span class="hljs-string">&#x27;review_body&#x27;</span>, <span class="hljs-string">&#x27;review_title&#x27;</span>, <span class="hljs-string">&#x27;language&#x27;</span>, <span class="hljs-string">&#x27;product_category&#x27;</span>],
        num_rows: <span class="hljs-number">200000</span>
    })
    validation: Dataset({
        features: [<span class="hljs-string">&#x27;review_id&#x27;</span>, <span class="hljs-string">&#x27;product_id&#x27;</span>, <span class="hljs-string">&#x27;reviewer_id&#x27;</span>, <span class="hljs-string">&#x27;stars&#x27;</span>, <span class="hljs-string">&#x27;review_body&#x27;</span>, <span class="hljs-string">&#x27;review_title&#x27;</span>, <span class="hljs-string">&#x27;language&#x27;</span>, <span class="hljs-string">&#x27;product_category&#x27;</span>],
        num_rows: <span class="hljs-number">5000</span>
    })
    test: Dataset({
        features: [<span class="hljs-string">&#x27;review_id&#x27;</span>, <span class="hljs-string">&#x27;product_id&#x27;</span>, <span class="hljs-string">&#x27;reviewer_id&#x27;</span>, <span class="hljs-string">&#x27;stars&#x27;</span>, <span class="hljs-string">&#x27;review_body&#x27;</span>, <span class="hljs-string">&#x27;review_title&#x27;</span>, <span class="hljs-string">&#x27;language&#x27;</span>, <span class="hljs-string">&#x27;product_category&#x27;</span>],
        num_rows: <span class="hljs-number">5000</span>
    })
})`}}),Fn=new C({props:{code:`def show_samples(dataset, num_samples=3, seed=42):
    sample = dataset["train"].shuffle(seed=seed).select(range(num_samples))
    for example in sample:
        print(f"\\n'>> Title: {example['review_title']}'")
        print(f"'>> Review: {example['review_body']}'")


show_samples(english_dataset)`,highlighted:`<span class="hljs-keyword">def</span> <span class="hljs-title function_">show_samples</span>(<span class="hljs-params">dataset, num_samples=<span class="hljs-number">3</span>, seed=<span class="hljs-number">42</span></span>):
    sample = dataset[<span class="hljs-string">&quot;train&quot;</span>].shuffle(seed=seed).select(<span class="hljs-built_in">range</span>(num_samples))
    <span class="hljs-keyword">for</span> example <span class="hljs-keyword">in</span> sample:
        <span class="hljs-built_in">print</span>(<span class="hljs-string">f&quot;\\n&#x27;&gt;&gt; Title: <span class="hljs-subst">{example[<span class="hljs-string">&#x27;review_title&#x27;</span>]}</span>&#x27;&quot;</span>)
        <span class="hljs-built_in">print</span>(<span class="hljs-string">f&quot;&#x27;&gt;&gt; Review: <span class="hljs-subst">{example[<span class="hljs-string">&#x27;review_body&#x27;</span>]}</span>&#x27;&quot;</span>)


show_samples(english_dataset)`}}),at=new C({props:{code:`'>> Title: Worked in front position, not rear'
'>> Review: 3 stars because these are not rear brakes as stated in the item description. At least the mount adapter only worked on the front fork of the bike that I got it for.'

'>> Title: meh'
'>> Review: Does it\u2019s job and it\u2019s gorgeous but mine is falling apart, I had to basically put it together again with hot glue'

'>> Title: Can\\'t beat these for the money'
'>> Review: Bought this for handling miscellaneous aircraft parts and hanger "stuff" that I needed to organize; it really fit the bill. The unit arrived quickly, was well packaged and arrived intact (always a good sign). There are five wall mounts-- three on the top and two on the bottom. I wanted to mount it on the wall, so all I had to do was to remove the top two layers of plastic drawers, as well as the bottom corner drawers, place it when I wanted and mark it; I then used some of the new plastic screw in wall anchors (the 50 pound variety) and it easily mounted to the wall. Some have remarked that they wanted dividers for the drawers, and that they made those. Good idea. My application was that I needed something that I can see the contents at about eye level, so I wanted the fuller-sized drawers. I also like that these are the new plastic that doesn\\'t get brittle and split like my older plastic drawers did. I like the all-plastic construction. It\\'s heavy duty enough to hold metal parts, but being made of plastic it\\'s not as heavy as a metal frame, so you can easily mount it to the wall and still load it up with heavy stuff, or light stuff. No problem there. For the money, you can\\'t beat it. Best one of these I\\'ve bought to date-- and I\\'ve been using some version of these for over forty years.'`,highlighted:`<span class="hljs-string">&#x27;&gt;&gt; Title: Worked in front position, not rear&#x27;</span>
<span class="hljs-string">&#x27;&gt;&gt; Review: 3 stars because these are not rear brakes as stated in the item description. At least the mount adapter only worked on the front fork of the bike that I got it for.&#x27;</span>

<span class="hljs-string">&#x27;&gt;&gt; Title: meh&#x27;</span>
<span class="hljs-string">&#x27;&gt;&gt; Review: Does it\u2019s job and it\u2019s gorgeous but mine is falling apart, I had to basically put it together again with hot glue&#x27;</span>

<span class="hljs-string">&#x27;&gt;&gt; Title: Can\\&#x27;t beat these for the money&#x27;</span>
<span class="hljs-string">&#x27;&gt;&gt; Review: Bought this for handling miscellaneous aircraft parts and hanger &quot;stuff&quot; that I needed to organize; it really fit the bill. The unit arrived quickly, was well packaged and arrived intact (always a good sign). There are five wall mounts-- three on the top and two on the bottom. I wanted to mount it on the wall, so all I had to do was to remove the top two layers of plastic drawers, as well as the bottom corner drawers, place it when I wanted and mark it; I then used some of the new plastic screw in wall anchors (the 50 pound variety) and it easily mounted to the wall. Some have remarked that they wanted dividers for the drawers, and that they made those. Good idea. My application was that I needed something that I can see the contents at about eye level, so I wanted the fuller-sized drawers. I also like that these are the new plastic that doesn\\&#x27;t get brittle and split like my older plastic drawers did. I like the all-plastic construction. It\\&#x27;s heavy duty enough to hold metal parts, but being made of plastic it\\&#x27;s not as heavy as a metal frame, so you can easily mount it to the wall and still load it up with heavy stuff, or light stuff. No problem there. For the money, you can\\&#x27;t beat it. Best one of these I\\&#x27;ve bought to date-- and I\\&#x27;ve been using some version of these for over forty years.&#x27;</span>`}}),Xn=new ca({props:{$$slots:{default:[Of]},$$scope:{ctx:W}}}),Qn=new C({props:{code:`english_dataset.set_format("pandas")
english_df = english_dataset["train"][:]
# Hi\u1EC3n th\u1ECB s\u1ED1 l\u01B0\u1EE3ng cho 20 s\u1EA3n ph\u1EA9m h\xE0ng \u0111\u1EA7u
english_df["product_category"].value_counts()[:20]`,highlighted:`english_dataset.set_format(<span class="hljs-string">&quot;pandas&quot;</span>)
english_df = english_dataset[<span class="hljs-string">&quot;train&quot;</span>][:]
<span class="hljs-comment"># Hi\u1EC3n th\u1ECB s\u1ED1 l\u01B0\u1EE3ng cho 20 s\u1EA3n ph\u1EA9m h\xE0ng \u0111\u1EA7u</span>
english_df[<span class="hljs-string">&quot;product_category&quot;</span>].value_counts()[:<span class="hljs-number">20</span>]`}}),mt=new C({props:{code:`home                      17679
apparel                   15951
wireless                  15717
other                     13418
beauty                    12091
drugstore                 11730
kitchen                   10382
toy                        8745
sports                     8277
automotive                 7506
lawn_and_garden            7327
home_improvement           7136
pet_products               7082
digital_ebook_purchase     6749
pc                         6401
electronics                6186
office_product             5521
shoes                      5197
grocery                    4730
book                       3756
Name: product_category, dtype: int64`,highlighted:`home                      <span class="hljs-number">17679</span>
apparel                   <span class="hljs-number">15951</span>
wireless                  <span class="hljs-number">15717</span>
other                     <span class="hljs-number">13418</span>
beauty                    <span class="hljs-number">12091</span>
drugstore                 <span class="hljs-number">11730</span>
kitchen                   <span class="hljs-number">10382</span>
toy                        <span class="hljs-number">8745</span>
sports                     <span class="hljs-number">8277</span>
automotive                 <span class="hljs-number">7506</span>
lawn_and_garden            <span class="hljs-number">7327</span>
home_improvement           <span class="hljs-number">7136</span>
pet_products               <span class="hljs-number">7082</span>
digital_ebook_purchase     <span class="hljs-number">6749</span>
pc                         <span class="hljs-number">6401</span>
electronics                <span class="hljs-number">6186</span>
office_product             <span class="hljs-number">5521</span>
shoes                      <span class="hljs-number">5197</span>
grocery                    <span class="hljs-number">4730</span>
book                       <span class="hljs-number">3756</span>
Name: product_category, dtype: int64`}}),as=new C({props:{code:`def filter_books(example):
    return (
        example["product_category"] == "book"
        or example["product_category"] == "digital_ebook_purchase"
    )`,highlighted:`<span class="hljs-keyword">def</span> <span class="hljs-title function_">filter_books</span>(<span class="hljs-params">example</span>):
    <span class="hljs-keyword">return</span> (
        example[<span class="hljs-string">&quot;product_category&quot;</span>] == <span class="hljs-string">&quot;book&quot;</span>
        <span class="hljs-keyword">or</span> example[<span class="hljs-string">&quot;product_category&quot;</span>] == <span class="hljs-string">&quot;digital_ebook_purchase&quot;</span>
    )`}}),cs=new C({props:{code:"english_dataset.reset_format()",highlighted:"english_dataset.reset_format()"}}),rs=new C({props:{code:`spanish_books = spanish_dataset.filter(filter_books)
english_books = english_dataset.filter(filter_books)
show_samples(english_books)`,highlighted:`spanish_books = spanish_dataset.<span class="hljs-built_in">filter</span>(filter_books)
english_books = english_dataset.<span class="hljs-built_in">filter</span>(filter_books)
show_samples(english_books)`}}),Pn=new C({props:{code:`'>> Title: I\\'m dissapointed.'
'>> Review: I guess I had higher expectations for this book from the reviews. I really thought I\\'d at least like it. The plot idea was great. I loved Ash but, it just didnt go anywhere. Most of the book was about their radio show and talking to callers. I wanted the author to dig deeper so we could really get to know the characters. All we know about Grace is that she is attractive looking, Latino and is kind of a brat. I\\'m dissapointed.'

'>> Title: Good art, good price, poor design'
'>> Review: I had gotten the DC Vintage calendar the past two years, but it was on backorder forever this year and I saw they had shrunk the dimensions for no good reason. This one has good art choices but the design has the fold going through the picture, so it\\'s less aesthetically pleasing, especially if you want to keep a picture to hang. For the price, a good calendar'

'>> Title: Helpful'
'>> Review: Nearly all the tips useful and. I consider myself an intermediate to advanced user of OneNote. I would highly recommend.'`,highlighted:`<span class="hljs-string">&#x27;&gt;&gt; Title: I\\&#x27;m dissapointed.&#x27;</span>
<span class="hljs-string">&#x27;&gt;&gt; Review: I guess I had higher expectations for this book from the reviews. I really thought I\\&#x27;d at least like it. The plot idea was great. I loved Ash but, it just didnt go anywhere. Most of the book was about their radio show and talking to callers. I wanted the author to dig deeper so we could really get to know the characters. All we know about Grace is that she is attractive looking, Latino and is kind of a brat. I\\&#x27;m dissapointed.&#x27;</span>

<span class="hljs-string">&#x27;&gt;&gt; Title: Good art, good price, poor design&#x27;</span>
<span class="hljs-string">&#x27;&gt;&gt; Review: I had gotten the DC Vintage calendar the past two years, but it was on backorder forever this year and I saw they had shrunk the dimensions for no good reason. This one has good art choices but the design has the fold going through the picture, so it\\&#x27;s less aesthetically pleasing, especially if you want to keep a picture to hang. For the price, a good calendar&#x27;</span>

<span class="hljs-string">&#x27;&gt;&gt; Title: Helpful&#x27;</span>
<span class="hljs-string">&#x27;&gt;&gt; Review: Nearly all the tips useful and. I consider myself an intermediate to advanced user of OneNote. I would highly recommend.&#x27;</span>`}}),At=new C({props:{code:`from datasets import concatenate_datasets, DatasetDict

books_dataset = DatasetDict()

for split in english_books.keys():
    books_dataset[split] = concatenate_datasets(
        [english_books[split], spanish_books[split]]
    )
    books_dataset[split] = books_dataset[split].shuffle(seed=42)

# Ch\u1ECDn ra m\u1ED9t v\xE0i m\u1EABu
show_samples(books_dataset)`,highlighted:`<span class="hljs-keyword">from</span> datasets <span class="hljs-keyword">import</span> concatenate_datasets, DatasetDict

books_dataset = DatasetDict()

<span class="hljs-keyword">for</span> split <span class="hljs-keyword">in</span> english_books.keys():
    books_dataset[split] = concatenate_datasets(
        [english_books[split], spanish_books[split]]
    )
    books_dataset[split] = books_dataset[split].shuffle(seed=<span class="hljs-number">42</span>)

<span class="hljs-comment"># Ch\u1ECDn ra m\u1ED9t v\xE0i m\u1EABu</span>
show_samples(books_dataset)`}}),Pt=new C({props:{code:`'>> Title: Easy to follow!!!!'
'>> Review: I loved The dash diet weight loss Solution. Never hungry. I would recommend this diet. Also the menus are well rounded. Try it. Has lots of the information need thanks.'

'>> Title: PARCIALMENTE DA\xD1ADO'
'>> Review: Me lleg\xF3 el d\xEDa que tocaba, junto a otros libros que ped\xED, pero la caja lleg\xF3 en mal estado lo cual da\xF1\xF3 las esquinas de los libros porque ven\xEDan sin protecci\xF3n (forro).'

'>> Title: no lo he podido descargar'
'>> Review: igual que el anterior'`,highlighted:`<span class="hljs-string">&#x27;&gt;&gt; Title: Easy to follow!!!!&#x27;</span>
<span class="hljs-string">&#x27;&gt;&gt; Review: I loved The dash diet weight loss Solution. Never hungry. I would recommend this diet. Also the menus are well rounded. Try it. Has lots of the information need thanks.&#x27;</span>

<span class="hljs-string">&#x27;&gt;&gt; Title: PARCIALMENTE DA\xD1ADO&#x27;</span>
<span class="hljs-string">&#x27;&gt;&gt; Review: Me lleg\xF3 el d\xEDa que tocaba, junto a otros libros que ped\xED, pero la caja lleg\xF3 en mal estado lo cual da\xF1\xF3 las esquinas de los libros porque ven\xEDan sin protecci\xF3n (forro).&#x27;</span>

<span class="hljs-string">&#x27;&gt;&gt; Title: no lo he podido descargar&#x27;</span>
<span class="hljs-string">&#x27;&gt;&gt; Review: igual que el anterior&#x27;</span>`}}),As=new C({props:{code:'books_dataset = books_dataset.filter(lambda x: len(x["review_title"].split()) > 2)',highlighted:'books_dataset = books_dataset.<span class="hljs-built_in">filter</span>(<span class="hljs-keyword">lambda</span> x: <span class="hljs-built_in">len</span>(x[<span class="hljs-string">&quot;review_title&quot;</span>].split()) &gt; <span class="hljs-number">2</span>)'}}),Ps=new Xt({}),Ne=new ca({props:{$$slots:{default:[Pf]},$$scope:{ctx:W}}}),za=new Xt({}),Da=new qu({props:{id:"1m7BerpSq8A"}}),Sa=new C({props:{code:`from transformers import AutoTokenizer

model_checkpoint = "google/mt5-small"
tokenizer = AutoTokenizer.from_pretrained(model_checkpoint)`,highlighted:`<span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoTokenizer

model_checkpoint = <span class="hljs-string">&quot;google/mt5-small&quot;</span>
tokenizer = AutoTokenizer.from_pretrained(model_checkpoint)`}}),Ie=new ca({props:{$$slots:{default:[Lf]},$$scope:{ctx:W}}}),Aa=new C({props:{code:`inputs = tokenizer("I loved reading the Hunger Games!")
inputs`,highlighted:`inputs = tokenizer(<span class="hljs-string">&quot;I loved reading the Hunger Games!&quot;</span>)
inputs`}}),Oa=new C({props:{code:"{'input_ids': [336, 259, 28387, 11807, 287, 62893, 295, 12507, 1], 'attention_mask': [1, 1, 1, 1, 1, 1, 1, 1, 1]}",highlighted:'{<span class="hljs-string">&#x27;input_ids&#x27;</span>: [<span class="hljs-number">336</span>, <span class="hljs-number">259</span>, <span class="hljs-number">28387</span>, <span class="hljs-number">11807</span>, <span class="hljs-number">287</span>, <span class="hljs-number">62893</span>, <span class="hljs-number">295</span>, <span class="hljs-number">12507</span>, <span class="hljs-number">1</span>], <span class="hljs-string">&#x27;attention_mask&#x27;</span>: [<span class="hljs-number">1</span>, <span class="hljs-number">1</span>, <span class="hljs-number">1</span>, <span class="hljs-number">1</span>, <span class="hljs-number">1</span>, <span class="hljs-number">1</span>, <span class="hljs-number">1</span>, <span class="hljs-number">1</span>, <span class="hljs-number">1</span>]}'}}),Pa=new C({props:{code:"tokenizer.convert_ids_to_tokens(inputs.input_ids)",highlighted:"tokenizer.convert_ids_to_tokens(inputs.input_ids)"}}),La=new C({props:{code:"['\u2581I', '\u2581', 'loved', '\u2581reading', '\u2581the', '\u2581Hung', 'er', '\u2581Games', '</s>']",highlighted:'[<span class="hljs-string">&#x27;\u2581I&#x27;</span>, <span class="hljs-string">&#x27;\u2581&#x27;</span>, <span class="hljs-string">&#x27;loved&#x27;</span>, <span class="hljs-string">&#x27;\u2581reading&#x27;</span>, <span class="hljs-string">&#x27;\u2581the&#x27;</span>, <span class="hljs-string">&#x27;\u2581Hung&#x27;</span>, <span class="hljs-string">&#x27;er&#x27;</span>, <span class="hljs-string">&#x27;\u2581Games&#x27;</span>, <span class="hljs-string">&#x27;&lt;/s&gt;&#x27;</span>]'}}),Na=new C({props:{code:`max_input_length = 512
max_target_length = 30


def preprocess_function(examples):
    model_inputs = tokenizer(
        examples["review_body"], max_length=max_input_length, truncation=True
    )
    # Thi\u1EBFt l\u1EADp tokenizer cho nh\xE3n
    with tokenizer.as_target_tokenizer():
        labels = tokenizer(
            examples["review_title"], max_length=max_target_length, truncation=True
        )

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


<span class="hljs-keyword">def</span> <span class="hljs-title function_">preprocess_function</span>(<span class="hljs-params">examples</span>):
    model_inputs = tokenizer(
        examples[<span class="hljs-string">&quot;review_body&quot;</span>], 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(
            examples[<span class="hljs-string">&quot;review_title&quot;</span>], 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`}}),Ra=new C({props:{code:"tokenized_datasets = books_dataset.map(preprocess_function, batched=True)",highlighted:'tokenized_datasets = books_dataset.<span class="hljs-built_in">map</span>(preprocess_function, batched=<span class="hljs-literal">True</span>)'}}),Me=new ca({props:{$$slots:{default:[Nf]},$$scope:{ctx:W}}}),Ha=new Xt({}),Ia=new qu({props:{id:"TMshhnrEXlg"}}),Ma=new C({props:{code:`generated_summary = "I absolutely loved reading the Hunger Games"
reference_summary = "I loved reading the Hunger Games"`,highlighted:`generated_summary = <span class="hljs-string">&quot;I absolutely loved reading the Hunger Games&quot;</span>
reference_summary = <span class="hljs-string">&quot;I loved reading the Hunger Games&quot;</span>`}}),Fe=new ca({props:{$$slots:{default:[Rf]},$$scope:{ctx:W}}}),Fa=new C({props:{code:"!pip install rouge_score",highlighted:"!pip install rouge_score"}}),Va=new C({props:{code:`import evaluate

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

rouge_score = evaluate.load(<span class="hljs-string">&quot;rouge&quot;</span>)`}}),Ka=new C({props:{code:`scores = rouge_score.compute(
    predictions=[generated_summary], references=[reference_summary]
)
scores`,highlighted:`scores = rouge_score.compute(
    predictions=[generated_summary], references=[reference_summary]
)
scores`}}),Wa=new C({props:{code:`{'rouge1': AggregateScore(low=Score(precision=0.86, recall=1.0, fmeasure=0.92), mid=Score(precision=0.86, recall=1.0, fmeasure=0.92), high=Score(precision=0.86, recall=1.0, fmeasure=0.92)),
 'rouge2': AggregateScore(low=Score(precision=0.67, recall=0.8, fmeasure=0.73), mid=Score(precision=0.67, recall=0.8, fmeasure=0.73), high=Score(precision=0.67, recall=0.8, fmeasure=0.73)),
 'rougeL': AggregateScore(low=Score(precision=0.86, recall=1.0, fmeasure=0.92), mid=Score(precision=0.86, recall=1.0, fmeasure=0.92), high=Score(precision=0.86, recall=1.0, fmeasure=0.92)),
 'rougeLsum': AggregateScore(low=Score(precision=0.86, recall=1.0, fmeasure=0.92), mid=Score(precision=0.86, recall=1.0, fmeasure=0.92), high=Score(precision=0.86, recall=1.0, fmeasure=0.92))}`,highlighted:`{<span class="hljs-string">&#x27;rouge1&#x27;</span>: AggregateScore(low=Score(precision=<span class="hljs-number">0.86</span>, recall=<span class="hljs-number">1.0</span>, fmeasure=<span class="hljs-number">0.92</span>), mid=Score(precision=<span class="hljs-number">0.86</span>, recall=<span class="hljs-number">1.0</span>, fmeasure=<span class="hljs-number">0.92</span>), high=Score(precision=<span class="hljs-number">0.86</span>, recall=<span class="hljs-number">1.0</span>, fmeasure=<span class="hljs-number">0.92</span>)),
 <span class="hljs-string">&#x27;rouge2&#x27;</span>: AggregateScore(low=Score(precision=<span class="hljs-number">0.67</span>, recall=<span class="hljs-number">0.8</span>, fmeasure=<span class="hljs-number">0.73</span>), mid=Score(precision=<span class="hljs-number">0.67</span>, recall=<span class="hljs-number">0.8</span>, fmeasure=<span class="hljs-number">0.73</span>), high=Score(precision=<span class="hljs-number">0.67</span>, recall=<span class="hljs-number">0.8</span>, fmeasure=<span class="hljs-number">0.73</span>)),
 <span class="hljs-string">&#x27;rougeL&#x27;</span>: AggregateScore(low=Score(precision=<span class="hljs-number">0.86</span>, recall=<span class="hljs-number">1.0</span>, fmeasure=<span class="hljs-number">0.92</span>), mid=Score(precision=<span class="hljs-number">0.86</span>, recall=<span class="hljs-number">1.0</span>, fmeasure=<span class="hljs-number">0.92</span>), high=Score(precision=<span class="hljs-number">0.86</span>, recall=<span class="hljs-number">1.0</span>, fmeasure=<span class="hljs-number">0.92</span>)),
 <span class="hljs-string">&#x27;rougeLsum&#x27;</span>: AggregateScore(low=Score(precision=<span class="hljs-number">0.86</span>, recall=<span class="hljs-number">1.0</span>, fmeasure=<span class="hljs-number">0.92</span>), mid=Score(precision=<span class="hljs-number">0.86</span>, recall=<span class="hljs-number">1.0</span>, fmeasure=<span class="hljs-number">0.92</span>), high=Score(precision=<span class="hljs-number">0.86</span>, recall=<span class="hljs-number">1.0</span>, fmeasure=<span class="hljs-number">0.92</span>))}`}}),Xa=new C({props:{code:'scores["rouge1"].mid',highlighted:'scores[<span class="hljs-string">&quot;rouge1&quot;</span>].mid'}}),Ya=new C({props:{code:"Score(precision=0.86, recall=1.0, fmeasure=0.92)",highlighted:'Score(precision=<span class="hljs-number">0.86</span>, recall=<span class="hljs-number">1.0</span>, fmeasure=<span class="hljs-number">0.92</span>)'}}),We=new ca({props:{$$slots:{default:[Hf]},$$scope:{ctx:W}}}),Qa=new Xt({}),Ja=new C({props:{code:"!pip install nltk",highlighted:"!pip install nltk"}}),Za=new C({props:{code:`import nltk

nltk.download("punkt")`,highlighted:`<span class="hljs-keyword">import</span> nltk

nltk.download(<span class="hljs-string">&quot;punkt&quot;</span>)`}}),nh=new C({props:{code:`from nltk.tokenize import sent_tokenize


def three_sentence_summary(text):
    return "\\n".join(sent_tokenize(text)[:3])


print(three_sentence_summary(books_dataset["train"][1]["review_body"]))`,highlighted:`<span class="hljs-keyword">from</span> nltk.tokenize <span class="hljs-keyword">import</span> sent_tokenize


<span class="hljs-keyword">def</span> <span class="hljs-title function_">three_sentence_summary</span>(<span class="hljs-params">text</span>):
    <span class="hljs-keyword">return</span> <span class="hljs-string">&quot;\\n&quot;</span>.join(sent_tokenize(text)[:<span class="hljs-number">3</span>])


<span class="hljs-built_in">print</span>(three_sentence_summary(books_dataset[<span class="hljs-string">&quot;train&quot;</span>][<span class="hljs-number">1</span>][<span class="hljs-string">&quot;review_body&quot;</span>]))`}}),th=new C({props:{code:`'I grew up reading Koontz, and years ago, I stopped,convinced i had "outgrown" him.'
'Still,when a friend was looking for something suspenseful too read, I suggested Koontz.'
'She found Strangers.'`,highlighted:`<span class="hljs-string">&#x27;I grew up reading Koontz, and years ago, I stopped,convinced i had &quot;outgrown&quot; him.&#x27;</span>
<span class="hljs-string">&#x27;Still,when a friend was looking for something suspenseful too read, I suggested Koontz.&#x27;</span>
<span class="hljs-string">&#x27;She found Strangers.&#x27;</span>`}}),sh=new C({props:{code:`def evaluate_baseline(dataset, metric):
    summaries = [three_sentence_summary(text) for text in dataset["review_body"]]
    return metric.compute(predictions=summaries, references=dataset["review_title"])`,highlighted:`<span class="hljs-keyword">def</span> <span class="hljs-title function_">evaluate_baseline</span>(<span class="hljs-params">dataset, metric</span>):
    summaries = [three_sentence_summary(text) <span class="hljs-keyword">for</span> text <span class="hljs-keyword">in</span> dataset[<span class="hljs-string">&quot;review_body&quot;</span>]]
    <span class="hljs-keyword">return</span> metric.compute(predictions=summaries, references=dataset[<span class="hljs-string">&quot;review_title&quot;</span>])`}}),eh=new C({props:{code:`import pandas as pd

score = evaluate_baseline(books_dataset["validation"], rouge_score)
rouge_names = ["rouge1", "rouge2", "rougeL", "rougeLsum"]
rouge_dict = dict((rn, round(score[rn].mid.fmeasure * 100, 2)) for rn in rouge_names)
rouge_dict`,highlighted:`<span class="hljs-keyword">import</span> pandas <span class="hljs-keyword">as</span> pd

score = evaluate_baseline(books_dataset[<span class="hljs-string">&quot;validation&quot;</span>], rouge_score)
rouge_names = [<span class="hljs-string">&quot;rouge1&quot;</span>, <span class="hljs-string">&quot;rouge2&quot;</span>, <span class="hljs-string">&quot;rougeL&quot;</span>, <span class="hljs-string">&quot;rougeLsum&quot;</span>]
rouge_dict = <span class="hljs-built_in">dict</span>((rn, <span class="hljs-built_in">round</span>(score[rn].mid.fmeasure * <span class="hljs-number">100</span>, <span class="hljs-number">2</span>)) <span class="hljs-keyword">for</span> rn <span class="hljs-keyword">in</span> rouge_names)
rouge_dict`}}),ah=new C({props:{code:"{'rouge1': 16.74, 'rouge2': 8.83, 'rougeL': 15.6, 'rougeLsum': 15.96}",highlighted:'{<span class="hljs-string">&#x27;rouge1&#x27;</span>: <span class="hljs-number">16.74</span>, <span class="hljs-string">&#x27;rouge2&#x27;</span>: <span class="hljs-number">8.83</span>, <span class="hljs-string">&#x27;rougeL&#x27;</span>: <span class="hljs-number">15.6</span>, <span class="hljs-string">&#x27;rougeLsum&#x27;</span>: <span class="hljs-number">15.96</span>}'}});const Su=[Gf,If],vh=[];function Au(n,i){return n[0]==="pt"?0:1}ds=Au(W),fs=vh[ds]=Su[ds](W),Je=new ca({props:{$$slots:{default:[Mf]},$$scope:{ctx:W}}}),hh=new C({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()`}}),lh=new C({props:{code:"huggingface-cli login",highlighted:'huggingface-<span class="hljs-keyword">cli</span> login'}});let Ln=W[0]==="pt"&&kf();const Ou=[Bf,Uf],_h=[];function Pu(n,i){return n[0]==="pt"?0:1}bs=Pu(W),vs=_h[bs]=Ou[bs](W),ch=new C({props:{code:`tokenized_datasets = tokenized_datasets.remove_columns(
    books_dataset["train"].column_names
)`,highlighted:`tokenized_datasets = tokenized_datasets.remove_columns(
    books_dataset[<span class="hljs-string">&quot;train&quot;</span>].column_names
)`}}),rh=new C({props:{code:`features = [tokenized_datasets["train"][i] for i in range(2)]
data_collator(features)`,highlighted:`features = [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">2</span>)]
data_collator(features)`}}),ih=new C({props:{code:`{'attention_mask': tensor([[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
         1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0],
        [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
         1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]]), 'input_ids': tensor([[  1494,    259,   8622,    390,    259,    262,   2316,   3435,    955,
            772,    281,    772,   1617,    263,    305,  14701,    260,   1385,
           3031,    259,  24146,    332,   1037,    259,  43906,    305,    336,
            260,      1,      0,      0,      0,      0,      0,      0],
        [   259,  27531,  13483,    259,   7505,    260, 112240,  15192,    305,
          53198,    276,    259,  74060,    263,    260,    459,  25640,    776,
           2119,    336,    259,   2220,    259,  18896,    288,   4906,    288,
           1037,   3931,    260,   7083, 101476,   1143,    260,      1]]), 'labels': tensor([[ 7483,   259,  2364, 15695,     1,  -100],
        [  259, 27531, 13483,   259,  7505,     1]]), 'decoder_input_ids': tensor([[    0,  7483,   259,  2364, 15695,     1],
        [    0,   259, 27531, 13483,   259,  7505]])}`,highlighted:`{<span class="hljs-string">&#x27;attention_mask&#x27;</span>: tensor([[<span class="hljs-number">1</span>, <span class="hljs-number">1</span>, <span class="hljs-number">1</span>, <span class="hljs-number">1</span>, <span class="hljs-number">1</span>, <span class="hljs-number">1</span>, <span class="hljs-number">1</span>, <span class="hljs-number">1</span>, <span class="hljs-number">1</span>, <span class="hljs-number">1</span>, <span class="hljs-number">1</span>, <span class="hljs-number">1</span>, <span class="hljs-number">1</span>, <span class="hljs-number">1</span>, <span class="hljs-number">1</span>, <span class="hljs-number">1</span>, <span class="hljs-number">1</span>, <span class="hljs-number">1</span>, <span class="hljs-number">1</span>, <span class="hljs-number">1</span>, <span class="hljs-number">1</span>, <span class="hljs-number">1</span>, <span class="hljs-number">1</span>, <span class="hljs-number">1</span>,
         <span class="hljs-number">1</span>, <span class="hljs-number">1</span>, <span class="hljs-number">1</span>, <span class="hljs-number">1</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-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>],
        [<span class="hljs-number">1</span>, <span class="hljs-number">1</span>, <span class="hljs-number">1</span>, <span class="hljs-number">1</span>, <span class="hljs-number">1</span>, <span class="hljs-number">1</span>, <span class="hljs-number">1</span>, <span class="hljs-number">1</span>, <span class="hljs-number">1</span>, <span class="hljs-number">1</span>, <span class="hljs-number">1</span>, <span class="hljs-number">1</span>, <span class="hljs-number">1</span>, <span class="hljs-number">1</span>, <span class="hljs-number">1</span>, <span class="hljs-number">1</span>, <span class="hljs-number">1</span>, <span class="hljs-number">1</span>, <span class="hljs-number">1</span>, <span class="hljs-number">1</span>, <span class="hljs-number">1</span>, <span class="hljs-number">1</span>, <span class="hljs-number">1</span>, <span class="hljs-number">1</span>,
         <span class="hljs-number">1</span>, <span class="hljs-number">1</span>, <span class="hljs-number">1</span>, <span class="hljs-number">1</span>, <span class="hljs-number">1</span>, <span class="hljs-number">1</span>, <span class="hljs-number">1</span>, <span class="hljs-number">1</span>, <span class="hljs-number">1</span>, <span class="hljs-number">1</span>, <span class="hljs-number">1</span>]]), <span class="hljs-string">&#x27;input_ids&#x27;</span>: tensor([[  <span class="hljs-number">1494</span>,    <span class="hljs-number">259</span>,   <span class="hljs-number">8622</span>,    <span class="hljs-number">390</span>,    <span class="hljs-number">259</span>,    <span class="hljs-number">262</span>,   <span class="hljs-number">2316</span>,   <span class="hljs-number">3435</span>,    <span class="hljs-number">955</span>,
            <span class="hljs-number">772</span>,    <span class="hljs-number">281</span>,    <span class="hljs-number">772</span>,   <span class="hljs-number">1617</span>,    <span class="hljs-number">263</span>,    <span class="hljs-number">305</span>,  <span class="hljs-number">14701</span>,    <span class="hljs-number">260</span>,   <span class="hljs-number">1385</span>,
           <span class="hljs-number">3031</span>,    <span class="hljs-number">259</span>,  <span class="hljs-number">24146</span>,    <span class="hljs-number">332</span>,   <span class="hljs-number">1037</span>,    <span class="hljs-number">259</span>,  <span class="hljs-number">43906</span>,    <span class="hljs-number">305</span>,    <span class="hljs-number">336</span>,
            <span class="hljs-number">260</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-number">0</span>,      <span class="hljs-number">0</span>,      <span class="hljs-number">0</span>],
        [   <span class="hljs-number">259</span>,  <span class="hljs-number">27531</span>,  <span class="hljs-number">13483</span>,    <span class="hljs-number">259</span>,   <span class="hljs-number">7505</span>,    <span class="hljs-number">260</span>, <span class="hljs-number">112240</span>,  <span class="hljs-number">15192</span>,    <span class="hljs-number">305</span>,
          <span class="hljs-number">53198</span>,    <span class="hljs-number">276</span>,    <span class="hljs-number">259</span>,  <span class="hljs-number">74060</span>,    <span class="hljs-number">263</span>,    <span class="hljs-number">260</span>,    <span class="hljs-number">459</span>,  <span class="hljs-number">25640</span>,    <span class="hljs-number">776</span>,
           <span class="hljs-number">2119</span>,    <span class="hljs-number">336</span>,    <span class="hljs-number">259</span>,   <span class="hljs-number">2220</span>,    <span class="hljs-number">259</span>,  <span class="hljs-number">18896</span>,    <span class="hljs-number">288</span>,   <span class="hljs-number">4906</span>,    <span class="hljs-number">288</span>,
           <span class="hljs-number">1037</span>,   <span class="hljs-number">3931</span>,    <span class="hljs-number">260</span>,   <span class="hljs-number">7083</span>, <span class="hljs-number">101476</span>,   <span class="hljs-number">1143</span>,    <span class="hljs-number">260</span>,      <span class="hljs-number">1</span>]]), <span class="hljs-string">&#x27;labels&#x27;</span>: tensor([[ <span class="hljs-number">7483</span>,   <span class="hljs-number">259</span>,  <span class="hljs-number">2364</span>, <span class="hljs-number">15695</span>,     <span class="hljs-number">1</span>,  -<span class="hljs-number">100</span>],
        [  <span class="hljs-number">259</span>, <span class="hljs-number">27531</span>, <span class="hljs-number">13483</span>,   <span class="hljs-number">259</span>,  <span class="hljs-number">7505</span>,     <span class="hljs-number">1</span>]]), <span class="hljs-string">&#x27;decoder_input_ids&#x27;</span>: tensor([[    <span class="hljs-number">0</span>,  <span class="hljs-number">7483</span>,   <span class="hljs-number">259</span>,  <span class="hljs-number">2364</span>, <span class="hljs-number">15695</span>,     <span class="hljs-number">1</span>],
        [    <span class="hljs-number">0</span>,   <span class="hljs-number">259</span>, <span class="hljs-number">27531</span>, <span class="hljs-number">13483</span>,   <span class="hljs-number">259</span>,  <span class="hljs-number">7505</span>]])}`}});const Lu=[Vf,Ff],yh=[];function Nu(n,i){return n[0]==="pt"?0:1}_s=Nu(W),ys=yh[_s]=Lu[_s](W);let Nn=W[0]==="pt"&&$f(W);return oh=new Xt({}),mh=new C({props:{code:`from transformers import pipeline

hub_model_id = "huggingface-course/mt5-small-finetuned-amazon-en-es"
summarizer = pipeline("summarization", model=hub_model_id)`,highlighted:`<span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> pipeline

hub_model_id = <span class="hljs-string">&quot;huggingface-course/mt5-small-finetuned-amazon-en-es&quot;</span>
summarizer = pipeline(<span class="hljs-string">&quot;summarization&quot;</span>, model=hub_model_id)`}}),ph=new C({props:{code:`def print_summary(idx):
    review = books_dataset["test"][idx]["review_body"]
    title = books_dataset["test"][idx]["review_title"]
    summary = summarizer(books_dataset["test"][idx]["review_body"])[0]["summary_text"]
    print(f"'>>> Review: {review}'")
    print(f"\\n'>>> Title: {title}'")
    print(f"\\n'>>> Summary: {summary}'")`,highlighted:`<span class="hljs-keyword">def</span> <span class="hljs-title function_">print_summary</span>(<span class="hljs-params">idx</span>):
    review = books_dataset[<span class="hljs-string">&quot;test&quot;</span>][idx][<span class="hljs-string">&quot;review_body&quot;</span>]
    title = books_dataset[<span class="hljs-string">&quot;test&quot;</span>][idx][<span class="hljs-string">&quot;review_title&quot;</span>]
    summary = summarizer(books_dataset[<span class="hljs-string">&quot;test&quot;</span>][idx][<span class="hljs-string">&quot;review_body&quot;</span>])[<span class="hljs-number">0</span>][<span class="hljs-string">&quot;summary_text&quot;</span>]
    <span class="hljs-built_in">print</span>(<span class="hljs-string">f&quot;&#x27;&gt;&gt;&gt; Review: <span class="hljs-subst">{review}</span>&#x27;&quot;</span>)
    <span class="hljs-built_in">print</span>(<span class="hljs-string">f&quot;\\n&#x27;&gt;&gt;&gt; Title: <span class="hljs-subst">{title}</span>&#x27;&quot;</span>)
    <span class="hljs-built_in">print</span>(<span class="hljs-string">f&quot;\\n&#x27;&gt;&gt;&gt; Summary: <span class="hljs-subst">{summary}</span>&#x27;&quot;</span>)`}}),uh=new C({props:{code:"print_summary(100)",highlighted:'print_summary(<span class="hljs-number">100</span>)'}}),gh=new C({props:{code:`'>>> Review: Nothing special at all about this product... the book is too small and stiff and hard to write in. The huge sticker on the back doesn\u2019t come off and looks super tacky. I would not purchase this again. I could have just bought a journal from the dollar store and it would be basically the same thing. It\u2019s also really expensive for what it is.'

'>>> Title: Not impressed at all... buy something else'

'>>> Summary: Nothing special at all about this product'`,highlighted:`<span class="hljs-string">&#x27;&gt;&gt;&gt; Review: Nothing special at all about this product... the book is too small and stiff and hard to write in. The huge sticker on the back doesn\u2019t come off and looks super tacky. I would not purchase this again. I could have just bought a journal from the dollar store and it would be basically the same thing. It\u2019s also really expensive for what it is.&#x27;</span>

<span class="hljs-string">&#x27;&gt;&gt;&gt; Title: Not impressed at all... buy something else&#x27;</span>

<span class="hljs-string">&#x27;&gt;&gt;&gt; Summary: Nothing special at all about this product&#x27;</span>`}}),dh=new C({props:{code:"print_summary(0)",highlighted:'print_summary(<span class="hljs-number">0</span>)'}}),fh=new C({props:{code:`'>>> Review: Es una trilogia que se hace muy facil de leer. Me ha gustado, no me esperaba el final para nada'

'>>> Title: Buena literatura para adolescentes'

'>>> Summary: Muy facil de leer'`,highlighted:`<span class="hljs-string">&#x27;&gt;&gt;&gt; Review: Es una trilogia que se hace muy facil de leer. Me ha gustado, no me esperaba el final para nada&#x27;</span>

<span class="hljs-string">&#x27;&gt;&gt;&gt; Title: Buena literatura para adolescentes&#x27;</span>

<span class="hljs-string">&#x27;&gt;&gt;&gt; Summary: Muy facil de leer&#x27;</span>`}}),{c(){u=h("meta"),w=m(),_(g.$$.fragment),x=m(),L=h("h1"),E=h("a"),N=h("span"),_(O.$$.fragment),q=m(),z=h("span"),S=e("T\xF3m t\u1EAFt"),A=m(),I.c(),X=m(),K=h("p"),J=e("Trong ph\u1EA7n n\xE0y, ch\xFAng ta s\u1EBD xem x\xE9t c\xE1ch c\xE1c m\xF4 h\xECnh Transformer c\xF3 th\u1EC3 \u0111\u01B0\u1EE3c s\u1EED d\u1EE5ng \u0111\u1EC3 c\xF4 \u0111\u1ECDng c\xE1c t\xE0i li\u1EC7u d\xE0i th\xE0nh c\xE1c b\u1EA3n t\xF3m t\u1EAFt, m\u1ED9t t\xE1c v\u1EE5 \u0111\u01B0\u1EE3c g\u1ECDi l\xE0 "),M=h("em"),Y=e("text summarization"),P=e(" hay "),U=h("em"),G=e("t\xF3m t\u1EAFt v\u0103n b\u1EA3n"),Q=e(". \u0110\xE2y l\xE0 m\u1ED9t trong nh\u1EEFng t\xE1c v\u1EE5 NLP th\xE1ch th\u1EE9c nh\u1EA5t v\xEC n\xF3 \u0111\xF2i h\u1ECFi nhi\u1EC1u kh\u1EA3 n\u0103ng, ch\u1EB3ng h\u1EA1n nh\u01B0 hi\u1EC3u c\xE1c \u0111o\u1EA1n v\u0103n d\xE0i v\xE0 t\u1EA1o ra v\u0103n b\u1EA3n m\u1EA1ch l\u1EA1c n\u1EAFm b\u1EAFt c\xE1c ch\u1EE7 \u0111\u1EC1 ch\xEDnh trong t\xE0i li\u1EC7u. Tuy nhi\xEAn, khi \u0111\u01B0\u1EE3c th\u1EF1c hi\u1EC7n t\u1ED1t, t\xF3m t\u1EAFt v\u0103n b\u1EA3n l\xE0 m\u1ED9t c\xF4ng c\u1EE5 m\u1EA1nh m\u1EBD c\xF3 th\u1EC3 t\u0103ng t\u1ED1c c\xE1c quy tr\xECnh kinh doanh kh\xE1c nhau b\u1EB1ng c\xE1ch gi\u1EA3m b\u1EDBt g\xE1nh n\u1EB7ng cho c\xE1c chuy\xEAn gia mi\u1EC1n ph\u1EA3i \u0111\u1ECDc chi ti\u1EBFt c\xE1c t\xE0i li\u1EC7u d\xE0i."),an=m(),_(tn.$$.fragment),B=m(),sn=h("p"),F=e("M\u1EB7c d\xF9 \u0111\xE3 t\u1ED3n t\u1EA1i nhi\u1EC1u m\xF4 h\xECnh \u0111\u01B0\u1EE3c tinh ch\u1EC9nh kh\xE1c nhau \u0111\u1EC3 t\xF3m t\u1EAFt tr\xEAn "),rn=h("a"),gn=e("Hugging Face Hub"),qn=e(", h\u1EA7u h\u1EBFt t\u1EA5t c\u1EA3 c\xE1c m\xF4 h\xECnh n\xE0y ch\u1EC9 ph\xF9 h\u1EE3p v\u1EDBi c\xE1c t\xE0i li\u1EC7u ti\u1EBFng Anh. V\xEC v\u1EADy, \u0111\u1EC3 t\u1EA1o th\xEAm m\u1ED9t \u0111i\u1EC3m nh\u1EA5n trong ph\u1EA7n n\xE0y, ch\xFAng t\xF4i s\u1EBD hu\u1EA5n luy\u1EC7n m\u1ED9t m\xF4 h\xECnh song ng\u1EEF cho ti\u1EBFng Anh v\xE0 ti\u1EBFng T\xE2y Ban Nha. \u0110\u1EBFn cu\u1ED1i ph\u1EA7n n\xE0y, b\u1EA1n s\u1EBD c\xF3 m\u1ED9t "),vn=h("a"),Z=e("m\xF4 h\xECnh"),_n=e(" c\xF3 th\u1EC3 t\xF3m t\u1EAFt c\xE1c \u0111\xE1nh gi\xE1 c\u1EE7a kh\xE1ch h\xE0ng nh\u01B0 \u0111\u01B0\u1EE3c hi\u1EC3n th\u1ECB \u1EDF \u0111\xE2y:"),pn=m(),nn=h("iframe"),kn=m(),hn=h("p"),Dn=e("Nh\u01B0 ch\xFAng ta s\u1EBD th\u1EA5y, nh\u1EEFng b\u1EA3n t\xF3m t\u1EAFt n\xE0y ng\u1EAFn g\u1ECDn v\xEC ch\xFAng \u0111\u01B0\u1EE3c h\u1ECDc t\u1EEB c\xE1c ti\xEAu \u0111\u1EC1 m\xE0 kh\xE1ch h\xE0ng cung c\u1EA5p trong c\xE1c b\xE0i \u0111\xE1nh gi\xE1 s\u1EA3n ph\u1EA9m c\u1EE7a h\u1ECD. H\xE3y b\u1EAFt \u0111\u1EA7u b\u1EB1ng c\xE1ch t\u1EADp h\u1EE3p m\u1ED9t kho ng\u1EEF li\u1EC7u song ng\u1EEF ph\xF9 h\u1EE3p cho t\xE1c v\u1EE5 n\xE0y."),dn=m(),on=h("h2"),v=h("a"),R=h("span"),_(mn.$$.fragment),j=m(),V=h("span"),$n=e("Chu\u1EA9n b\u1ECB kho ng\u1EEF li\u1EC7u \u0111a ng\xF4n ng\u1EEF"),jn=m(),un=h("p"),Tn=e("Ch\xFAng ta s\u1EBD s\u1EED d\u1EE5ng "),en=h("a"),Un=e("Multilingual Amazon Reviews Corpus"),tt=e(" \u0111\u1EC3 t\u1EA1o tr\xECnh t\xF3m t\u1EAFt song ng\u1EEF. T\u1EADp t\xE0i li\u1EC7u n\xE0y bao g\u1ED3m c\xE1c b\xE0i \u0111\xE1nh gi\xE1 s\u1EA3n ph\u1EA9m c\u1EE7a Amazon b\u1EB1ng s\xE1u ng\xF4n ng\u1EEF v\xE0 th\u01B0\u1EDDng \u0111\u01B0\u1EE3c s\u1EED d\u1EE5ng \u0111\u1EC3 \u0111\xE1nh gi\xE1 c\xE1c b\u1ED9 ph\xE2n lo\u1EA1i \u0111a ng\xF4n ng\u1EEF. Tuy nhi\xEAn, v\xEC m\u1ED7i b\xE0i \u0111\xE1nh gi\xE1 \u0111i k\xE8m v\u1EDBi m\u1ED9t ti\xEAu \u0111\u1EC1 ng\u1EAFn, ch\xFAng ta c\xF3 th\u1EC3 s\u1EED d\u1EE5ng c\xE1c ti\xEAu \u0111\u1EC1 n\xE0y l\xE0m nh\xE3n t\xF3m t\u1EAFt cho m\xF4 h\xECnh c\u1EE7a ch\xFAng ta \u0111\u1EC3 h\u1ECDc! \u0110\u1EC3 b\u1EAFt \u0111\u1EA7u, h\xE3y t\u1EA3i xu\u1ED1ng c\xE1c t\u1EADp h\u1EE3p con ti\u1EBFng Anh v\xE0 ti\u1EBFng T\xE2y Ban Nha t\u1EEB Hugging Face Hub:"),cn=m(),_(wn.$$.fragment),Rn=m(),_(Sn.$$.fragment),wt=m(),ln=h("p"),Yt=e("Nh\u01B0 b\u1EA1n c\xF3 th\u1EC3 th\u1EA5y, \u0111\u1ED1i v\u1EDBi m\u1ED7i ng\xF4n ng\u1EEF, c\xF3 200,000 \u0111\xE1nh gi\xE1 cho ph\u1EA7n "),vt=h("code"),ct=e("hu\u1EA5n luy\u1EC7n"),st=e(" v\xE0 5,000 nh\u1EADn x\xE9t cho m\u1ED7i ph\u1EA7n "),rt=h("code"),Bn=e("ki\u1EC3m \u0111\u1ECBnh"),xt=e(" v\xE0 "),Wn=h("code"),_t=e("ki\u1EC3m th\u1EED"),Et=e(". Th\xF4ng tin \u0111\xE1nh gi\xE1 m\xE0 ch\xFAng ta quan t\xE2m \u0111\u01B0\u1EE3c ch\u1EE9a trong c\u1ED9t "),An=h("code"),it=e("review_body"),et=e(" v\xE0 "),ot=h("code"),H=e("review_title"),fn=e(". H\xE3y xem m\u1ED9t v\xE0i v\xED d\u1EE5 b\u1EB1ng c\xE1ch t\u1EA1o m\u1ED9t h\xE0m \u0111\u01A1n gi\u1EA3n l\u1EA5y m\u1ED9t m\u1EABu ng\u1EABu nhi\xEAn t\u1EEB t\u1EADp hu\u1EA5n luy\u1EC7n v\u1EDBi c\xE1c k\u1EF9 thu\u1EADt ch\xFAng ta \u0111\xE3 h\u1ECDc trong "),yt=h("a"),qt=e("Ch\u01B0\u01A1ng 5"),xn=e(":"),Tt=m(),_(Fn.$$.fragment),Qt=m(),_(at.$$.fragment),ht=m(),_(Xn.$$.fragment),bn=m(),Vn=h("p"),Jt=e("M\u1EABu n\xE0y cho th\u1EA5y s\u1EF1 \u0111a d\u1EA1ng c\u1EE7a c\xE1c b\xE0i \u0111\xE1nh gi\xE1 m\xE0 ng\u01B0\u1EDDi ta th\u01B0\u1EDDng t\xECm th\u1EA5y tr\xEAn m\u1EA1ng, t\u1EEB t\xEDch c\u1EF1c \u0111\u1EBFn ti\xEAu c\u1EF1c (v\xE0 m\u1ECDi th\u1EE9 \u1EDF gi\u1EEFa!). M\u1EB7c d\xF9 v\xED d\u1EE5 v\u1EDBi ti\xEAu \u0111\u1EC1 \u201Cmeh\u201D kh\xF4ng nhi\u1EC1u th\xF4ng tin, nh\u01B0ng c\xE1c ti\xEAu \u0111\u1EC1 kh\xE1c tr\xF4ng gi\u1ED1ng nh\u01B0 nh\u1EEFng b\u1EA3n t\xF3m t\u1EAFt ph\xF9 h\u1EE3p v\u1EC1 b\u1EA3n th\xE2n c\xE1c \u0111\xE1nh gi\xE1. Vi\u1EC7c hu\u1EA5n luy\u1EC7n m\u1ED9t m\xF4 h\xECnh t\xF3m t\u1EAFt cho t\u1EA5t c\u1EA3 400,000 b\xE0i \u0111\xE1nh gi\xE1 s\u1EBD m\u1EA5t qu\xE1 nhi\u1EC1u th\u1EDDi gian tr\xEAn m\u1ED9t GPU, v\xEC v\u1EADy thay v\xE0o \u0111\xF3, ch\xFAng ta s\u1EBD t\u1EADp trung v\xE0o vi\u1EC7c t\u1EA1o t\xF3m t\u1EAFt cho m\u1ED9t mi\u1EC1n s\u1EA3n ph\u1EA9m. \u0110\u1EC3 bi\u1EBFt t\xEAn mi\u1EC1n m\xE0 ch\xFAng ta c\xF3 th\u1EC3 ch\u1ECDn, h\xE3y chuy\u1EC3n \u0111\u1ED5i "),Yn=h("code"),Zt=e("english_dataset"),Kn=e(" th\xE0nh "),Ct=h("code"),zt=e("pandas.DataFrame"),On=e(" v\xE0 t\xEDnh to\xE1n s\u1ED1 l\u01B0\u1EE3ng \u0111\xE1nh gi\xE1 cho m\u1ED7i danh m\u1EE5c s\u1EA3n ph\u1EA9m:"),ns=m(),_(Qn.$$.fragment),ts=m(),_(mt.$$.fragment),Dt=m(),Cn=h("p"),ra=e("C\xE1c s\u1EA3n ph\u1EA9m ph\u1ED5 bi\u1EBFn nh\u1EA5t trong t\u1EADp d\u1EEF li\u1EC7u ti\u1EBFng Anh l\xE0 v\u1EC1 \u0111\u1ED3 gia d\u1EE5ng, qu\u1EA7n \xE1o v\xE0 thi\u1EBFt b\u1ECB \u0111i\u1EC7n t\u1EED kh\xF4ng d\xE2y. Tuy nhi\xEAn, \u0111\u1EC3 g\u1EAFn b\xF3 v\u1EDBi ch\u1EE7 \u0111\u1EC1 Amazon, ch\xFAng ta h\xE3y t\u1EADp trung v\xE0o vi\u1EC7c t\xF3m t\u1EAFt c\xE1c b\xE0i \u0111\xE1nh gi\xE1 s\xE1ch - x\xE9t cho c\xF9ng, \u0111\xE2y l\xE0 nh\u1EEFng g\xEC c\xF4ng ty \u0111\u01B0\u1EE3c th\xE0nh l\u1EADp! Ch\xFAng t\xF4i c\xF3 th\u1EC3 th\u1EA5y hai danh m\u1EE5c s\u1EA3n ph\u1EA9m ph\xF9 h\u1EE3p v\u1EDBi h\xF3a \u0111\u01A1n ("),ks=h("code"),ss=e("book"),_e=e(" v\xE0 "),kt=h("code"),ye=e("digital_ebook_purchase"),$s=e("), v\xEC v\u1EADy, h\xE3y l\u1ECDc t\u1EADp d\u1EEF li\u1EC7u b\u1EB1ng c\u1EA3 hai ng\xF4n ng\u1EEF ch\u1EC9 cho c\xE1c s\u1EA3n ph\u1EA9m n\xE0y. Nh\u01B0 ch\xFAng ta \u0111\xE3 th\u1EA5y trong "),js=h("a"),ke=e("Ch\u01B0\u01A1ng 5"),es=e(", h\xE0m "),ws=h("code"),St=e("Dataset.filter()"),ia=e(" cho ph\xE9p ch\xFAng ta c\u1EAFt m\u1ED9t t\u1EADp d\u1EEF li\u1EC7u r\u1EA5t hi\u1EC7u qu\u1EA3, v\xEC v\u1EADy ch\xFAng ta c\xF3 th\u1EC3 x\xE1c \u0111\u1ECBnh m\u1ED9t h\xE0m \u0111\u01A1n gi\u1EA3n \u0111\u1EC3 th\u1EF1c hi\u1EC7n \u0111i\u1EC1u n\xE0y:"),xs=m(),_(as.$$.fragment),$e=m(),zn=h("p"),$t=e("B\xE2y gi\u1EDD khi ch\xFAng ta \xE1p d\u1EE5ng h\xE0m n\xE0y cho "),pt=h("code"),Vs=e("english_dataset"),hs=e(" v\xE0 "),Ks=h("code"),Ws=e("spanish_dataset"),oa=e(", k\u1EBFt qu\u1EA3 s\u1EBD ch\u1EC9 ch\u1EE9a nh\u1EEFng h\xE0ng li\xEAn quan \u0111\u1EBFn danh m\u1EE5c s\xE1ch. Tr\u01B0\u1EDBc khi \xE1p d\u1EE5ng b\u1ED9 l\u1ECDc, h\xE3y chuy\u1EC3n \u0111\u1ECBnh d\u1EA1ng c\u1EE7a "),Es=h("code"),qs=e("english_dataset"),ma=e(" t\u1EEB "),Ts=h("code"),Jn=e('"pandas"'),ls=e(" tr\u1EDF l\u1EA1i "),Xs=h("code"),Ys=e('"arrow"'),pa=e(":"),je=m(),_(cs.$$.fragment),Cs=m(),zs=h("p"),ua=e("Sau \u0111\xF3, ch\xFAng t\xF4i c\xF3 th\u1EC3 \xE1p d\u1EE5ng ch\u1EE9c n\u0103ng b\u1ED9 l\u1ECDc v\xE0 \u0111\u1EC3 ki\u1EC3m tra m\u1ED9t m\u1EABu \u0111\xE1nh gi\xE1 \u0111\u1EC3 xem ch\xFAng c\xF3 th\u1EF1c s\u1EF1 l\xE0 v\u1EC1 s\xE1ch hay kh\xF4ng:"),Ds=m(),_(rs.$$.fragment),we=m(),_(Pn.$$.fragment),xe=m(),Hn=h("p"),ga=e("\u0110\u01B0\u1EE3c r\u1ED3i, ch\xFAng ta c\xF3 th\u1EC3 th\u1EA5y r\u1EB1ng c\xE1c b\xE0i \u0111\xE1nh gi\xE1 kh\xF4ng ho\xE0n to\xE0n v\u1EC1 s\xE1ch v\xE0 c\xF3 th\u1EC3 \u0111\u1EC1 c\u1EADp \u0111\u1EBFn nh\u1EEFng th\u1EE9 nh\u01B0 l\u1ECBch v\xE0 c\xE1c \u1EE9ng d\u1EE5ng \u0111i\u1EC7n t\u1EED nh\u01B0 OneNote. Tuy nhi\xEAn, m\u1EA3ng n\xE0y c\xF3 v\u1EBB th\xEDch h\u1EE3p \u0111\u1EC3 hu\u1EA5n luy\u1EC7n m\u1ED9t m\xF4 h\xECnh t\xF3m t\u1EAFt. Tr\u01B0\u1EDBc khi xem x\xE9t c\xE1c m\xF4 h\xECnh kh\xE1c nhau ph\xF9 h\u1EE3p cho t\xE1c v\u1EE5 n\xE0y, ch\xFAng ta c\xF2n m\u1ED9t b\u01B0\u1EDBc chu\u1EA9n b\u1ECB d\u1EEF li\u1EC7u cu\u1ED1i c\xF9ng c\u1EA7n l\xE0m: k\u1EBFt h\u1EE3p c\xE1c b\xE0i \u0111\xE1nh gi\xE1 b\u1EB1ng ti\u1EBFng Anh v\xE0 ti\u1EBFng T\xE2y Ban Nha d\u01B0\u1EDBi d\u1EA1ng m\u1ED9t \u0111\u1ED1i t\u01B0\u1EE3ng "),Qs=h("code"),Js=e("DatasetDict"),da=e(" duy nh\u1EA5t. \u{1F917} Datasets cung c\u1EA5p m\u1ED9t h\xE0m "),Zs=h("code"),ne=e("concatenate_datasets()"),fa=e(" ti\u1EC7n d\u1EE5ng (nh\u01B0 t\xEAn cho th\u1EA5y) s\u1EBD x\u1EBFp ch\u1ED3ng hai \u0111\u1ED1i t\u01B0\u1EE3ng "),te=h("code"),Ee=e("Dataset"),Ss=e(" l\xEAn tr\xEAn nhau. V\xEC v\u1EADy, \u0111\u1EC3 t\u1EA1o t\u1EADp d\u1EEF li\u1EC7u song ng\u1EEF c\u1EE7a m\xECnh, ch\xFAng ta s\u1EBD l\u1EB7p l\u1EA1i t\u1EEBng ph\u1EA7n d\u1EEF li\u1EC7u, n\u1ED1i c\xE1c t\u1EADp d\u1EEF li\u1EC7u cho ph\u1EA7n \u0111\xF3 v\xE0 x\xE1o tr\u1ED9n k\u1EBFt qu\u1EA3 \u0111\u1EC3 \u0111\u1EA3m b\u1EA3o m\xF4 h\xECnh kh\xF4ng qu\xE1 ph\xF9 h\u1EE3p v\u1EDBi m\u1ED9t ng\xF4n ng\u1EEF duy nh\u1EA5t:"),qe=m(),_(At.$$.fragment),Ot=m(),_(Pt.$$.fragment),Lt=m(),is=h("p"),Nt=e("\u0110\xE2y ch\u1EAFc ch\u1EAFn l\xE0 s\u1EF1 k\u1EBFt h\u1EE3p gi\u1EEFa c\xE1c b\xE0i \u0111\xE1nh gi\xE1 b\u1EB1ng ti\u1EBFng Anh v\xE0 ti\u1EBFng T\xE2y Ban Nha! B\xE2y gi\u1EDD ch\xFAng ta \u0111\xE3 c\xF3 m\u1ED9t kho t\xE0i li\u1EC7u hu\u1EA5n luy\u1EC7n, m\u1ED9t \u0111i\u1EC1u cu\u1ED1i c\xF9ng c\u1EA7n ki\u1EC3m tra l\xE0 s\u1EF1 ph\xE2n b\u1ED1 c\xE1c t\u1EEB trong c\xE1c b\xE0i \u0111\xE1nh gi\xE1 v\xE0 ti\xEAu \u0111\u1EC1 c\u1EE7a ch\xFAng. \u0110i\u1EC1u n\xE0y \u0111\u1EB7c bi\u1EC7t quan tr\u1ECDng \u0111\u1ED1i v\u1EDBi c\xE1c t\xE1c v\u1EE5 t\xF3m t\u1EAFt, trong \u0111\xF3 c\xE1c t\xF3m t\u1EAFt tham chi\u1EBFu ng\u1EAFn trong d\u1EEF li\u1EC7u c\xF3 th\u1EC3 l\xE0m sai l\u1EC7ch m\xF4 h\xECnh ch\u1EC9 xu\u1EA5t ra m\u1ED9t ho\u1EB7c hai t\u1EEB trong c\xE1c t\xF3m t\u1EAFt \u0111\xE3 t\u1EA1o. C\xE1c bi\u1EC3u \u0111\u1ED3 b\xEAn d\u01B0\u1EDBi hi\u1EC3n th\u1ECB c\xE1c ph\xE2n b\u1ED1 t\u1EEB v\xE0 ch\xFAng ta c\xF3 th\u1EC3 th\u1EA5y r\u1EB1ng c\xE1c ti\xEAu \u0111\u1EC1 b\u1ECB l\u1EC7ch nhi\u1EC1u v\u1EC1 ch\u1EC9 1-2 t\u1EEB:"),Te=m(),lt=h("div"),os=h("img"),Ce=m(),o=h("img"),ba=m(),ms=h("p"),jh=e("\u0110\u1EC3 gi\u1EA3i quy\u1EBFt v\u1EA5n \u0111\u1EC1 n\xE0y, ch\xFAng ta s\u1EBD l\u1ECDc ra c\xE1c v\xED d\u1EE5 c\xF3 ti\xEAu \u0111\u1EC1 r\u1EA5t ng\u1EAFn \u0111\u1EC3 m\xF4 h\xECnh c\xF3 th\u1EC3 t\u1EA1o ra c\xE1c b\u1EA3n t\xF3m t\u1EAFt th\xFA v\u1ECB h\u01A1n. V\xEC ch\xFAng ta \u0111ang x\u1EED l\xFD c\xE1c v\u0103n b\u1EA3n ti\u1EBFng Anh v\xE0 ti\u1EBFng T\xE2y Ban Nha, ch\xFAng ta c\xF3 th\u1EC3 s\u1EED d\u1EE5ng ph\u01B0\u01A1ng ph\xE1p th\xF4 \u0111\u1EC3 ph\xE2n chia c\xE1c ti\xEAu \u0111\u1EC1 theo d\u1EA5u c\xE1ch v\xE0 sau \u0111\xF3 s\u1EED d\u1EE5ng ph\u01B0\u01A1ng ph\xE1p "),Rt=h("code"),wh=e("Dataset.filter()"),xh=e(" \u0111\xE1ng tin c\u1EADy c\u1EE7a m\xECnh nh\u01B0 sau:"),se=m(),_(As.$$.fragment),va=m(),ee=h("p"),Os=e("B\xE2y gi\u1EDD ch\xFAng ta \u0111\xE3 chu\u1EA9n b\u1ECB kho t\xE0i li\u1EC7u c\u1EE7a m\xECnh, h\xE3y c\xF9ng xem m\u1ED9t v\xE0i m\u1EABu Transformer kh\u1EA3 thi m\xE0 ng\u01B0\u1EDDi ta c\xF3 th\u1EC3 tinh ch\u1EC9nh n\xF3!"),_a=m(),Ht=h("h2"),jt=h("a"),ze=h("span"),_(Ps.$$.fragment),De=m(),Se=h("span"),Ae=e("C\xE1c m\xF4 h\xECnh cho t\xF3m t\u1EAFt v\u0103n b\u1EA3n"),ya=m(),ps=h("p"),Ls=e("N\u1EBFu b\u1EA1n ngh\u0129 v\u1EC1 n\xF3, t\xF3m t\u1EAFt v\u0103n b\u1EA3n l\xE0 m\u1ED9t lo\u1EA1i t\xE1c v\u1EE5 t\u01B0\u01A1ng t\u1EF1 nh\u01B0 d\u1ECBch m\xE1y: ch\xFAng ta c\xF3 m\u1ED9t ph\u1EA7n n\u1ED9i dung v\u0103n b\u1EA3n gi\u1ED1ng nh\u01B0 m\u1ED9t b\xE0i \u0111\xE1nh gi\xE1 m\xE0 ta mu\u1ED1n \u201Cd\u1ECBch\u201D th\xE0nh m\u1ED9t phi\xEAn b\u1EA3n ng\u1EAFn h\u01A1n \u0111\u1EC3 n\u1EAFm b\u1EAFt c\xE1c t\xEDnh n\u0103ng n\u1ED5i b\u1EADt c\u1EE7a \u0111\u1EA7u v\xE0o. Theo \u0111\xF3, h\u1EA7u h\u1EBFt c\xE1c m\xF4 h\xECnh Transformer \u0111\u1EC3 t\xF3m t\u1EAFt \u0111\u1EC1u \xE1p d\u1EE5ng ki\u1EBFn tr\xFAc b\u1ED9 m\xE3 h\xF3a-gi\u1EA3i m\xE3 m\xE0 ch\xFAng ta \u0111\xE3 g\u1EB7p l\u1EA7n \u0111\u1EA7u ti\xEAn trong "),ae=h("a"),Eh=e("Ch\u01B0\u01A1ng 1"),qh=e(", m\u1EB7c d\xF9 c\xF3 m\u1ED9t s\u1ED1 ngo\u1EA1i l\u1EC7 nh\u01B0 h\u1ECD m\xF4 h\xECnh GPT c\u0169ng c\xF3 th\u1EC3 \u0111\u01B0\u1EE3c s\u1EED d\u1EE5ng \u0111\u1EC3 t\xF3m t\u1EAFt trong c\xE0i \u0111\u1EB7t few-shot. B\u1EA3ng sau \u0111\xE2y li\u1EC7t k\xEA m\u1ED9t s\u1ED1 m\xF4 h\xECnh \u0111\u01B0\u1EE3c hu\u1EA5n luy\u1EC7n tr\u01B0\u1EDBc ph\u1ED5 bi\u1EBFn c\xF3 th\u1EC3 \u0111\u01B0\u1EE3c tinh ch\u1EC9nh \u0111\u1EC3 t\xF3m t\u1EAFt."),ka=m(),us=h("table"),It=h("thead"),Gt=h("tr"),he=h("th"),Th=e("M\xF4 h\xECnh Transformer"),Ch=m(),Ns=h("th"),zh=e("M\xF4 t\u1EA3"),Oe=m(),le=h("th"),Dh=e("\u0110a ng\xF4n ng\u1EEF?"),Sh=m(),In=h("tbody"),Gn=h("tr"),gs=h("td"),Rs=h("a"),Ah=e("GPT-2"),Oh=m(),ut=h("td"),Ph=e("M\u1EB7c d\xF9 \u0111\u01B0\u1EE3c hu\u1EA5n luy\u1EC7n nh\u01B0 m\u1ED9t m\xF4 h\xECnh ng\xF4n ng\u1EEF t\u1EF1 h\u1ED3i quy, b\u1EA1n c\xF3 th\u1EC3 d\xF9ng GPT-2 \u0111\u1EC3 t\u1EA1o ra c\xE1c b\u1EA3n t\xF3m t\u1EAFt b\u1EB1ng c\xE1ch n\u1ED1i \u201CTL;DR\u201D cu\u1ED1i m\u1ED7i \u0111o\u1EA1n \u0111\u1EA7u v\xE0o."),Lh=m(),ce=h("td"),Nh=e("\u274C"),Pe=m(),Mt=h("tr"),Rh=h("td"),$a=h("a"),Zi=e("PEGASUS"),no=m(),Pl=h("td"),to=e("S\u1EED d\u1EE5ng h\xE0m m\u1EE5c ti\xEAu hu\u1EA5n luy\u1EC7n tr\u01B0\u1EDBc \u0111\u1EC3 d\u1EF1 \u0111o\xE1n c\xE1c c\xE2u b\u1ECB \u1EA9n \u0111i trong v\u0103n b\u1EA3n \u0111a c\xE2u. C\u01A1 ch\u1EBF n\xE0y g\u1EA7n v\u1EDBi t\xF3m t\u1EAFt h\u01A1n m\xF4 h\xECnh ng\xF4n ng\u1EEF vanilla v\xE0 \u0111\u1EA1t \u0111i\u1EC3m cao h\u01A1n tr\xEAn c\xE1c chu\u1EA9n ph\u1ED5 bi\u1EBFn."),so=m(),Hh=h("td"),eo=e("\u274C"),ao=m(),re=h("tr"),Ih=h("td"),ja=h("a"),ho=e("T5"),lo=m(),wa=h("td"),co=e("M\u1ED9t ki\u1EBFn tr\xFAc Transformer ph\u1ED5 qu\xE1t t\u1EA1o ra t\u1EA5t c\u1EA3 c\xE1c t\xE1c v\u1EE5 trong khung v\u0103n b\u1EA3n sang v\u0103n b\u1EA3n; v\xED d\u1EE5,\u0111\u1ECBnh d\u1EA1ng \u0111\u1EA7u v\xE0o cho m\xF4 h\xECnh \u0111\u1EC3 t\xF3m t\u1EAFt t\xE0i li\u1EC7u l\xE0 "),Ll=h("code"),ro=e("summarize: ARTICLE"),io=e("."),oo=m(),Gh=h("td"),mo=e("\u274C"),po=m(),ie=h("tr"),Mh=h("td"),xa=h("a"),uo=e("mT5"),go=m(),Nl=h("td"),fo=e("M\u1ED9t phi\xEAn b\u1EA3n \u0111a ng\xF4n ng\u1EEF c\u1EE7a T5, \u0111\u01B0\u1EE3c hu\u1EA5n luy\u1EC7n tr\u01B0\u1EDBc tr\xEAn kho ng\u1EEF li\u1EC7u Common Crawl corpus (mC4), bao g\u1ED3m 101 ng\xF4n ng\u1EEF."),bo=m(),Uh=h("td"),vo=e("\u2705"),_o=m(),oe=h("tr"),Bh=h("td"),Ea=h("a"),yo=e("BART"),ko=m(),Rl=h("td"),$o=e("M\u1ED9t ki\u1EBFn tr\xFAc Transformer m\u1EDBi v\u1EDBi c\u1EA3 b\u1ED9 m\xE3 h\xF3a v\xE0 gi\u1EA3i m\xE3 \u0111\u01B0\u1EE3c hu\u1EA5n luy\u1EC7n \u0111\u1EC3 t\xE1i t\u1EA1o l\u1EA1i \u0111\u1EA7u v\xE0o b\u1ECB ph\xE1, k\u1EBFt h\u1EE3p c\xE1c c\u01A1 ch\u1EBF hu\u1EA5n luy\u1EC7n tr\u01B0\u1EDBc c\u1EE7a BERT v\xE0 GPT-2."),jo=m(),Fh=h("td"),wo=e("\u274C"),xo=m(),me=h("tr"),Vh=h("td"),qa=h("a"),Eo=e("mBART-50"),qo=m(),Hl=h("td"),To=e("Phi\xEAn b\u1EA3n \u0111a ng\xF4n ng\u1EEF c\u1EE7a BART, hu\u1EA5n luy\u1EC7n tr\u01B0\u1EDBc tr\xEAn 50 ng\xF4n ng\u1EEF."),Co=m(),Kh=h("td"),zo=e("\u2705"),Xc=m(),Wh=h("p"),Do=e("Nh\u01B0 b\u1EA1n c\xF3 th\u1EC3 th\u1EA5y t\u1EEB b\u1EA3ng n\xE0y, ph\u1EA7n l\u1EDBn c\xE1c m\xF4 h\xECnh Transformer \u0111\u1EC3 t\xF3m t\u1EAFt (v\xE0 th\u1EF1c s\u1EF1 l\xE0 h\u1EA7u h\u1EBFt c\xE1c t\xE1c v\u1EE5 NLP) l\xE0 \u0111\u01A1n ng\u1EEF. \u0110i\u1EC1u n\xE0y th\u1EADt tuy\u1EC7t n\u1EBFu t\xE1c v\u1EE5 c\u1EE7a b\u1EA1n s\u1EED d\u1EE5ng ng\xF4n ng\u1EEF \u201Cnhi\u1EC1u t\xE0i nguy\xEAn\u201D nh\u01B0 ti\u1EBFng Anh ho\u1EB7c ti\u1EBFng \u0110\u1EE9c, nh\u01B0ng b\u1EDBt d\u1EA7n \u0111\u1ED1i v\u1EDBi h\xE0ng ngh\xECn ng\xF4n ng\u1EEF kh\xE1c \u0111ang \u0111\u01B0\u1EE3c s\u1EED d\u1EE5ng tr\xEAn kh\u1EAFp th\u1EBF gi\u1EDBi. May m\u1EAFn thay, c\xF3 m\u1ED9t lo\u1EA1i m\xF4 h\xECnh Transformer \u0111a ng\xF4n ng\u1EEF, nh\u01B0 mT5 v\xE0 mBART, ra \u0111\u1EDDi \u0111\u1EC3 gi\u1EA3i c\u1EE9u ta. Nh\u1EEFng m\xF4 h\xECnh n\xE0y \u0111\u01B0\u1EE3c hu\u1EA5n luy\u1EC7n tr\u01B0\u1EDBc b\u1EB1ng c\xE1ch s\u1EED d\u1EE5ng m\xF4 h\xECnh ng\xF4n ng\u1EEF, nh\u01B0ng c\xF3 m\u1ED9t \u0111i\u1EC3m kh\xE1c bi\u1EC7t: thay v\xEC hu\u1EA5n luy\u1EC7n ng\u1EEF li\u1EC7u c\u1EE7a m\u1ED9t ng\xF4n ng\u1EEF, ch\xFAng \u0111\u01B0\u1EE3c hu\u1EA5n luy\u1EC7n c\xF9ng l\xFAc v\u1EC1 c\xE1c v\u0103n b\u1EA3n b\u1EB1ng h\u01A1n 50 ng\xF4n ng\u1EEF c\xF9ng m\u1ED9t l\xFAc!"),Yc=m(),Le=h("p"),So=e("Ch\xFAng ta s\u1EBD t\u1EADp trung v\xE0o mT5, m\u1ED9t ki\u1EBFn tr\xFAc th\xFA v\u1ECB d\u1EF1a tr\xEAn T5 \u0111\xE3 \u0111\u01B0\u1EE3c hu\u1EA5n luy\u1EC7n tr\u01B0\u1EDBc trong khung v\u0103n b\u1EA3n sang v\u0103n b\u1EA3n. Trong T5, m\u1ECDi t\xE1c v\u1EE5 NLP \u0111\u01B0\u1EE3c x\xE2y d\u1EF1ng d\u01B0\u1EDBi d\u1EA1ng ti\u1EC1n t\u1ED1 nh\u1EAFc nh\u01B0 "),Il=h("code"),Ao=e("summarize:"),Oo=e(" \u0111i\u1EC1u ki\u1EC7n n\xE0o \u0111\u1EC3 m\xF4 h\xECnh \u0111i\u1EC1u ch\u1EC9nh v\u0103n b\u1EA3n \u0111\u01B0\u1EE3c t\u1EA1o th\xE0nh l\u1EDDi nh\u1EAFc. Nh\u01B0 th\u1EC3 hi\u1EC7n trong h\xECnh b\xEAn d\u01B0\u1EDBi, \u0111i\u1EC1u n\xE0y l\xE0m cho T5 tr\u1EDF n\xEAn c\u1EF1c k\u1EF3 linh ho\u1EA1t, v\xEC b\u1EA1n c\xF3 th\u1EC3 gi\u1EA3i quy\u1EBFt nhi\u1EC1u t\xE1c v\u1EE5 ch\u1EC9 v\u1EDBi m\u1ED9t m\xF4 h\xECnh duy nh\u1EA5t!"),Qc=m(),pe=h("div"),Ta=h("img"),Po=m(),Ca=h("img"),Jc=m(),Xh=h("p"),Lo=e("mT5 kh\xF4ng s\u1EED d\u1EE5ng ti\u1EC1n t\u1ED1, nh\u01B0ng chia s\u1EBB ph\u1EA7n l\u1EDBn t\xEDnh linh ho\u1EA1t c\u1EE7a T5 v\xE0 c\xF3 l\u1EE3i th\u1EBF l\xE0 \u0111a ng\xF4n ng\u1EEF. Gi\u1EDD ta \u0111\xE3 ch\u1ECDn m\u1ED9t m\xF4 h\xECnh, h\xE3y xem x\xE9t vi\u1EC7c chu\u1EA9n b\u1ECB d\u1EEF li\u1EC7u \u0111\u1EC3 hu\u1EA5n luy\u1EC7n."),Zc=m(),_(Ne.$$.fragment),nr=m(),ue=h("h2"),Re=h("a"),Gl=h("span"),_(za.$$.fragment),No=m(),Ml=h("span"),Ro=e("Ti\u1EC1n x\u1EED l\xFD d\u1EEF li\u1EC7u"),tr=m(),_(Da.$$.fragment),sr=m(),He=h("p"),Ho=e("T\xE1c v\u1EE5 ti\u1EBFp theo c\u1EE7a ch\xFAng ta l\xE0 tokenize v\xE0 m\xE3 h\xF3a c\xE1c b\xE0i \u0111\xE1nh gi\xE1 v\xE0 ti\xEAu \u0111\u1EC1 c\u1EE7a ch\xFAng. Nh\u01B0 th\u01B0\u1EDDng l\u1EC7, ta b\u1EAFt \u0111\u1EA7u b\u1EB1ng c\xE1ch t\u1EA3i tokenizer \u0111\u01B0\u1EE3c li\xEAn k\u1EBFt v\u1EDBi checkpoint m\xF4 h\xECnh \u0111\u01B0\u1EE3c hu\u1EA5n luy\u1EC7n tr\u01B0\u1EDBc. Ch\xFAng ta s\u1EBD s\u1EED d\u1EE5ng "),Ul=h("code"),Io=e("mt5-small"),Go=e(" l\xE0m checkpoint \u0111\u1EC3 c\xF3 th\u1EC3 tinh ch\u1EC9nh m\xF4 h\xECnh trong m\u1ED9t kho\u1EA3ng th\u1EDDi gian h\u1EE3p l\xFD:"),er=m(),_(Sa.$$.fragment),ar=m(),_(Ie.$$.fragment),hr=m(),Yh=h("p"),Mo=e("H\xE3y th\u1EED nghi\u1EC7m mT5 tokenizer tr\xEAn m\u1ED9t v\xED d\u1EE5 nh\u1ECF:"),lr=m(),_(Aa.$$.fragment),cr=m(),_(Oa.$$.fragment),rr=m(),gt=h("p"),Uo=e("\u1EDE \u0111\xE2y, ch\xFAng ta c\xF3 th\u1EC3 th\u1EA5y "),Bl=h("code"),Bo=e("input_ids"),Fo=e(" v\xE0 "),Fl=h("code"),Vo=e("attention_mask"),Ko=e(" m\xE0 ch\xFAng ta \u0111\xE3 g\u1EB7p trong c\xE1c th\u1EED nghi\u1EC7m tinh ch\u1EC9nh \u0111\u1EA7u ti\xEAn c\u1EE7a ch\xFAng ta trong "),Qh=h("a"),Wo=e("Ch\u01B0\u01A1ng 3"),Xo=e(". H\xE3y gi\u1EA3i m\xE3 c\xE1c ID \u0111\u1EA7u v\xE0o n\xE0y b\u1EB1ng h\xE0m "),Vl=h("code"),Yo=e("convert_ids_to_tokens()"),Qo=e(" c\u1EE7a tokenizer \u0111\u1EC3 xem ch\xFAng ta \u0111ang x\u1EED l\xFD lo\u1EA1i tokenizer n\xE0o:"),ir=m(),_(Pa.$$.fragment),or=m(),_(La.$$.fragment),mr=m(),Ut=h("p"),Jo=e("K\xFD t\u1EF1 Unicode \u0111\u1EB7c bi\u1EC7t "),Kl=h("code"),Zo=e("\u2581"),nm=e(" v\xE0 token cu\u1ED1i chu\u1ED7i "),Wl=h("code"),tm=e("</s>"),sm=e(" cho bi\u1EBFt ta \u0111ang x\u1EED l\xFD SentencePiece tokenizer, d\u1EF1a tr\xEAn thu\u1EADt to\xE1n ph\xE2n \u0111o\u1EA1n Unigram \u0111\u01B0\u1EE3c th\u1EA3o lu\u1EADn trong "),Jh=h("a"),em=e("Ch\u01B0\u01A1ng 6"),am=e(". Unigram \u0111\u1EB7c bi\u1EC7t h\u1EEFu \xEDch \u0111\u1ED1i v\u1EDBi kho ng\u1EEF li\u1EC7u \u0111a ng\xF4n ng\u1EEF v\xEC n\xF3 cho ph\xE9p SentencePiece b\u1EA5t kh\u1EA3 tri v\u1EC1 d\u1EA5u, d\u1EA5u c\xE2u v\xE0 th\u1EF1c t\u1EBF l\xE0 nhi\u1EC1u ng\xF4n ng\u1EEF, nh\u01B0 ti\u1EBFng Nh\u1EADt, kh\xF4ng c\xF3 k\xFD t\u1EF1 kho\u1EA3ng tr\u1EAFng."),pr=m(),Ge=h("p"),hm=e("\u0110\u1EC3 m\xE3 h\xF3a kho t\xE0i li\u1EC7u c\u1EE7a m\xECnh, ch\xFAng ta ph\u1EA3i x\u1EED l\xFD m\u1ED9t c\xE1ch t\xEDnh t\u1EBF v\u1EDBi t\xF3m t\u1EAFt: b\u1EDFi v\xEC c\xE1c nh\xE3n c\u0169ng l\xE0 v\u0103n b\u1EA3n, c\xF3 th\u1EC3 ch\xFAng v\u01B0\u1EE3t qu\xE1 k\xEDch th\u01B0\u1EDBc ng\u1EEF c\u1EA3nh t\u1ED1i \u0111a c\u1EE7a m\xF4 h\xECnh. \u0110i\u1EC1u n\xE0y c\xF3 ngh\u0129a l\xE0 ch\xFAng ta c\u1EA7n \xE1p d\u1EE5ng vi\u1EC7c c\u1EAFt b\u1EDBt cho c\u1EA3 c\xE1c b\xE0i \u0111\xE1nh gi\xE1 v\xE0 ti\xEAu \u0111\u1EC1 c\u1EE7a ch\xFAng \u0111\u1EC3 \u0111\u1EA3m b\u1EA3o kh\xF4ng truy\u1EC1n c\xE1c \u0111\u1EA7u v\xE0o qu\xE1 d\xE0i cho m\xF4 h\xECnh c\u1EE7a m\xECnh. C\xE1c tokenizer trong \u{1F917} Transformers cung c\u1EA5p m\u1ED9t h\xE0m "),Xl=h("code"),lm=e("as_target_tokenizer()"),cm=e(" ti\u1EC7n l\u1EE3i cho ph\xE9p b\u1EA1n m\xE3 h\xF3a c\xE1c nh\xE3n song song v\u1EDBi c\xE1c \u0111\u1EA7u v\xE0o. \u0110i\u1EC1u n\xE0y th\u01B0\u1EDDng \u0111\u01B0\u1EE3c th\u1EF1c hi\u1EC7n b\u1EB1ng c\xE1ch s\u1EED d\u1EE5ng tr\xECnh qu\u1EA3n l\xFD ng\u1EEF c\u1EA3nh b\xEAn trong m\u1ED9t ch\u1EE9c n\u0103ng ti\u1EC1n x\u1EED l\xFD, tr\u01B0\u1EDBc ti\xEAn m\xE3 h\xF3a c\xE1c \u0111\u1EA7u v\xE0o, sau \u0111\xF3 m\xE3 h\xF3a c\xE1c nh\xE3n d\u01B0\u1EDBi d\u1EA1ng m\u1ED9t c\u1ED9t ri\xEAng bi\u1EC7t. \u0110\xE2y l\xE0 m\u1ED9t v\xED d\u1EE5 v\u1EC1 m\u1ED9t h\xE0m nh\u01B0 v\u1EADy cho mT5:"),ur=m(),_(Na.$$.fragment),gr=m(),dt=h("p"),rm=e("H\xE3y xem qua \u0111o\u1EA1n m\xE3 n\xE0y \u0111\u1EC3 hi\u1EC3u \u0111i\u1EC1u g\xEC \u0111ang x\u1EA3y ra. \u0110i\u1EC1u \u0111\u1EA7u ti\xEAn ch\xFAng ta \u0111\xE3 l\xE0m l\xE0 x\xE1c \u0111\u1ECBnh c\xE1c gi\xE1 tr\u1ECB cho "),Yl=h("code"),im=e("max_input_length"),om=e(" v\xE0 "),Ql=h("code"),mm=e("max_target_length"),pm=e(", \u0111\u1EB7t gi\u1EDBi h\u1EA1n tr\xEAn cho th\u1EDDi l\u01B0\u1EE3ng c\xE1c b\xE0i \u0111\xE1nh gi\xE1 v\xE0 ti\xEAu \u0111\u1EC1 c\u1EE7a ch\xFAng. V\xEC n\u1ED9i dung \u0111\xE1nh gi\xE1 th\u01B0\u1EDDng l\u1EDBn h\u01A1n nhi\u1EC1u so v\u1EDBi ti\xEAu \u0111\u1EC1, ch\xFAng ta \u0111\xE3 \u0111i\u1EC1u ch\u1EC9nh c\xE1c gi\xE1 tr\u1ECB n\xE0y cho ph\xF9 h\u1EE3p. Sau \u0111\xF3, trong ch\xEDnh "),Jl=h("code"),um=e("preprocess_function()"),gm=e(", ch\xFAng ta c\xF3 th\u1EC3 th\u1EA5y c\xE1c b\xE0i \u0111\xE1nh gi\xE1 \u0111\u01B0\u1EE3c tokenize \u0111\u1EA7u ti\xEAn, ti\u1EBFp theo l\xE0 c\xE1c ti\xEAu \u0111\u1EC1 v\u1EDBi "),Zl=h("code"),dm=e("as_target_tokenizer()"),fm=e("."),dr=m(),Hs=h("p"),bm=e("V\u1EDBi "),nc=h("code"),vm=e("preprocess_function()"),_m=e(", vi\u1EC7c tokenize to\xE0n b\u1ED9 kho d\u1EEF li\u1EC7u b\u1EB1ng h\xE0m "),tc=h("code"),ym=e("Dataset.map()"),km=e(" ti\u1EC7n d\u1EE5ng m\xE0 ch\xFAng ta \u0111\xE3 s\u1EED d\u1EE5ng r\u1ED9ng r\xE3i trong su\u1ED1t kh\xF3a h\u1ECDc n\xE0y l\xE0 m\u1ED9t v\u1EA5n \u0111\u1EC1 \u0111\u01A1n gi\u1EA3n:"),fr=m(),_(Ra.$$.fragment),br=m(),Zh=h("p"),$m=e("B\xE2y gi\u1EDD kho d\u1EEF li\u1EC7u \u0111\xE3 \u0111\u01B0\u1EE3c x\u1EED l\xFD tr\u01B0\u1EDBc, ch\xFAng ta h\xE3y xem x\xE9t m\u1ED9t s\u1ED1 ch\u1EC9 s\u1ED1 th\u01B0\u1EDDng \u0111\u01B0\u1EE3c s\u1EED d\u1EE5ng \u0111\u1EC3 t\xF3m t\u1EAFt. Nh\u01B0 ch\xFAng ta s\u1EBD th\u1EA5y, kh\xF4ng c\xF3 gi\u1EA3i ph\xE1p d\u1EC5 d\xE0ng v\xE0 nhanh ch\xF3ng khi n\xF3i \u0111\u1EBFn vi\u1EC7c \u0111o l\u01B0\u1EDDng ch\u1EA5t l\u01B0\u1EE3ng c\u1EE7a v\u0103n b\u1EA3n do m\xE1y t\u1EA1o ra."),vr=m(),_(Me.$$.fragment),_r=m(),ge=h("h2"),Ue=h("a"),sc=h("span"),_(Ha.$$.fragment),jm=m(),ec=h("span"),wm=e("Th\u01B0\u1EDBc \u0111o cho t\xF3m t\u1EAFt v\u0103n b\u1EA3n"),yr=m(),_(Ia.$$.fragment),kr=m(),nl=h("p"),xm=e("So v\u1EDBi h\u1EA7u h\u1EBFt c\xE1c t\xE1c v\u1EE5 kh\xE1c m\xE0 ch\xFAng ta \u0111\xE3 \u0111\u1EC1 c\u1EADp trong kh\xF3a h\u1ECDc n\xE0y, vi\u1EC7c \u0111o l\u01B0\u1EDDng hi\u1EC7u su\u1EA5t c\u1EE7a c\xE1c t\xE1c v\u1EE5 t\u1EA1o v\u0103n b\u1EA3n nh\u01B0 t\xF3m t\u1EAFt ho\u1EB7c d\u1ECBch kh\xF4ng \u0111\u01A1n gi\u1EA3n b\u1EB1ng. V\xED d\u1EE5: \u0111\u01B0\u1EE3c \u0111\u01B0a ra m\u1ED9t b\xE0i \u0111\xE1nh gi\xE1 nh\u01B0 \u201CI loved reading the Hunger Games\u201D, c\xF3 nhi\u1EC1u b\u1EA3n t\xF3m t\u1EAFt h\u1EE3p l\u1EC7, ch\u1EB3ng h\u1EA1n nh\u01B0 \u201CI loved the Hunger Games\u201D ho\u1EB7c \u201CHunger Games is a great read\u201D. R\xF5 r\xE0ng, vi\u1EC7c \xE1p d\u1EE5ng m\u1ED9t s\u1ED1 lo\u1EA1i \u0111\u1ED1i s\xE1nh ch\xEDnh x\xE1c n\xE0o \u0111\xF3 gi\u1EEFa b\u1EA3n t\xF3m t\u1EAFt \u0111\u01B0\u1EE3c t\u1EA1o v\xE0 nh\xE3n kh\xF4ng ph\u1EA3i l\xE0 m\u1ED9t gi\u1EA3i ph\xE1p t\u1ED1t - ngay c\u1EA3 con ng\u01B0\u1EDDi c\u0169ng s\u1EBD \u0111\xE1nh gi\xE1 th\u1EA5p h\u01A1n theo m\u1ED9t ch\u1EC9 s\u1ED1 nh\u01B0 v\u1EADy, b\u1EDFi v\xEC t\u1EA5t c\u1EA3 ch\xFAng ta \u0111\u1EC1u c\xF3 phong c\xE1ch vi\u1EBFt ri\xEAng c\u1EE7a m\xECnh."),$r=m(),Be=h("p"),Em=e("\u0110\u1EC3 t\xF3m t\u1EAFt, m\u1ED9t trong nh\u1EEFng ch\u1EC9 s\u1ED1 \u0111\u01B0\u1EE3c s\u1EED d\u1EE5ng ph\u1ED5 bi\u1EBFn nh\u1EA5t l\xE0 "),Ga=h("a"),qm=e("\u0111i\u1EC3m ROUGE"),Tm=e(" (vi\u1EBFt t\u1EAFt c\u1EE7a Recall-Oriented Understudy for Gisting Assessment). \xDD t\u01B0\u1EDFng c\u01A1 b\u1EA3n \u0111\u1EB1ng sau th\u01B0\u1EDBc \u0111o n\xE0y l\xE0 so s\xE1nh m\u1ED9t b\u1EA3n t\xF3m t\u1EAFt \u0111\xE3 t\u1EA1o v\u1EDBi m\u1ED9t t\u1EADp h\u1EE3p c\xE1c b\u1EA3n t\xF3m t\u1EAFt tham chi\u1EBFu th\u01B0\u1EDDng do con ng\u01B0\u1EDDi t\u1EA1o ra. \u0110\u1EC3 l\xE0m cho \u0111i\u1EC1u n\xE0y ch\xEDnh x\xE1c h\u01A1n, gi\u1EA3 s\u1EED ch\xFAng ta mu\u1ED1n so s\xE1nh hai b\u1EA3n t\xF3m t\u1EAFt sau:"),jr=m(),_(Ma.$$.fragment),wr=m(),Is=h("p"),Cm=e("M\u1ED9t c\xE1ch \u0111\u1EC3 c\xF3 th\u1EC3 so s\xE1nh ch\xFAng l\xE0 \u0111\u1EBFm s\u1ED1 t\u1EEB tr\xF9ng l\u1EB7p, trong tr\u01B0\u1EDDng h\u1EE3p n\xE0y s\u1EBD l\xE0 6. Tuy nhi\xEAn, \u0111i\u1EC1u n\xE0y h\u01A1i th\xF4, v\xEC v\u1EADy thay v\xE0o \u0111\xF3 ROUGE d\u1EF1a tr\xEAn vi\u1EC7c t\xEDnh to\xE1n \u0111i\u1EC3m s\u1ED1 "),ac=h("em"),zm=e("precision"),Dm=e("  v\xE0 "),hc=h("em"),Sm=e("recall"),Am=e(" cho s\u1EF1 tr\xF9ng l\u1EB7p."),xr=m(),_(Fe.$$.fragment),Er=m(),Ua=h("p"),Om=e(`\u0110\u1ED1i v\u1EDBi ROUGE, recall \u0111o l\u01B0\u1EDDng m\u1EE9c \u0111\u1ED9 t\xF3m t\u1EAFt tham chi\u1EBFu thu \u0111\u01B0\u1EE3c t\u1EEB c\xE1i \u0111\xE3 t\u1EA1o. N\u1EBFu ch\xFAng ta ch\u1EC9 so s\xE1nh c\xE1c t\u1EEB, recall c\xF3 th\u1EC3 \u0111\u01B0\u1EE3c t\xEDnh theo c\xF4ng th\u1EE9c sau:
`),qr=new _f,Tr=m(),Ba=h("p"),Pm=e(`\u0110\u1ED1i v\u1EDBi v\xED d\u1EE5 \u0111\u01A1n gi\u1EA3n \u1EDF tr\xEAn, c\xF4ng th\u1EE9c n\xE0y cho ph\xE9p nh\u1EDB ho\xE0n h\u1EA3o l\xE0 6/6 = 1; t\u1EE9c l\xE0 t\u1EA5t c\u1EA3 c\xE1c t\u1EEB trong b\u1EA3n t\xF3m t\u1EAFt tham chi\u1EBFu \u0111\xE3 \u0111\u01B0\u1EE3c t\u1EA1o ra b\u1EDFi m\xF4 h\xECnh. \u0110i\u1EC1u n\xE0y nghe c\xF3 v\u1EBB tuy\u1EC7t v\u1EDDi, nh\u01B0ng h\xE3y t\u01B0\u1EDFng t\u01B0\u1EE3ng n\u1EBFu b\u1EA3n t\xF3m t\u1EAFt \u0111\u01B0\u1EE3c t\u1EA1o c\u1EE7a ch\xFAng ta l\xE0 \u201CI really really loved reading the Hunger Games all night\u201D. \u0110i\u1EC1u n\xE0y c\u0169ng s\u1EBD c\xF3 m\u1ED9t recall ho\xE0n h\u1EA3o, nh\u01B0ng \u0111\u01B0\u1EE3c cho l\xE0 m\u1ED9t b\u1EA3n t\xF3m t\u1EAFt t\u1ED3i t\u1EC7 h\u01A1n v\xEC n\xF3 d\xE0i d\xF2ng. \u0110\u1EC3 \u0111\u1ED1i ph\xF3 v\u1EDBi nh\u1EEFng t\xECnh hu\u1ED1ng n\xE0y, ch\xFAng ta c\u0169ng t\xEDnh to\xE1n \u0111\u1ED9 precision, trong ng\u1EEF c\u1EA3nh ROUGE \u0111o l\u01B0\u1EDDng m\u1EE9c \u0111\u1ED9 li\xEAn quan c\u1EE7a b\u1EA3n t\xF3m t\u1EAFt \u0111\xE3 t\u1EA1o:
`),Cr=new _f,zr=m(),Ve=h("p"),Lm=e("\xC1p d\u1EE5ng \u0111i\u1EC1u n\xE0y cho b\u1EA3n t\xF3m t\u1EAFt d\xE0i d\xF2ng c\u1EE7a ch\xFAng ta s\u1EBD cho precision l\xE0 6/10 = 0.6, th\u1EA5p h\u01A1n \u0111\xE1ng k\u1EC3 so v\u1EDBi precision 6/7 = 0.86 thu \u0111\u01B0\u1EE3c b\u1EB1ng ph\u01B0\u01A1ng ph\xE1p ng\u1EAFn h\u01A1n c\u1EE7a m\xECnh. Trong th\u1EF1c t\u1EBF, c\u1EA3 precision v\xE0 recall th\u01B0\u1EDDng \u0111\u01B0\u1EE3c t\xEDnh to\xE1n, v\xE0 sau \u0111\xF3 \u0111i\u1EC3m F1 (gi\xE1 tr\u1ECB trung b\xECnh h\xE0i h\xF2a c\u1EE7a precision v\xE0 recall) \u0111\u01B0\u1EE3c b\xE1o c\xE1o. Ch\xFAng ta c\xF3 th\u1EC3 th\u1EF1c hi\u1EC7n vi\u1EC7c n\xE0y d\u1EC5 d\xE0ng trong \u{1F917} Datasets b\u1EB1ng c\xE1ch c\xE0i \u0111\u1EB7t g\xF3i "),lc=h("code"),Nm=e("rouge_score"),Rm=e(" tr\u01B0\u1EDBc:"),Dr=m(),_(Fa.$$.fragment),Sr=m(),tl=h("p"),Hm=e("v\xE0 sau \u0111\xF3 t\u1EA3i ch\u1EC9 s\u1ED1 ROUGE nh\u01B0 sau:"),Ar=m(),_(Va.$$.fragment),Or=m(),Ke=h("p"),Im=e("Sau \u0111\xF3 ta c\xF3 th\u1EC3 s\u1EED d\u1EE5ng h\xE0m "),cc=h("code"),Gm=e("rouge_score.compute()"),Mm=e(" \u0111\u1EC3 t\xEDnh t\u1EA5t c\u1EA3 c\xE1c ch\u1EC9 s\u1ED1 trong m\u1ED9t l\u1EA7n:"),Pr=m(),_(Ka.$$.fragment),Lr=m(),_(Wa.$$.fragment),Nr=m(),Zn=h("p"),Um=e("Ch\xE0, c\xF3 r\u1EA5t nhi\u1EC1u th\xF4ng tin trong \u0111\u1EA7u ra \u0111\xF3 - t\u1EA5t c\u1EA3 c\xF3 ngh\u0129a l\xE0 g\xEC? \u0110\u1EA7u ti\xEAn, \u{1F917} Datasets th\u1EF1c s\u1EF1 t\xEDnh to\xE1n kho\u1EA3ng tin c\u1EADy cho precision, recall v\xE0 F1 score; \u0111\xE2y l\xE0 c\xE1c thu\u1ED9c t\xEDnh "),rc=h("code"),Bm=e("low"),Fm=e(", "),ic=h("code"),Vm=e("mid"),Km=e(" v\xE0 "),oc=h("code"),Wm=e("high"),Xm=e(" m\xE0 b\u1EA1n c\xF3 th\u1EC3 xem \u1EDF \u0111\xE2y. H\u01A1n n\u1EEFa, \u{1F917} Datasets t\xEDnh to\xE1n nhi\u1EC1u \u0111i\u1EC3m ROUGE kh\xE1c nhau d\u1EF1a tr\xEAn c\xE1c lo\u1EA1i v\u0103n b\u1EA3n chi ti\u1EBFt kh\xE1c nhau khi so s\xE1nh c\xE1c t\xF3m t\u1EAFt \u0111\xE3 t\u1EA1o v\xE0 tham chi\u1EBFu. Bi\u1EBFn th\u1EC3 "),mc=h("code"),Ym=e("rouge1"),Qm=e(" l\xE0 s\u1EF1 ch\u1ED3ng ch\xE9o c\u1EE7a c\xE1c kh\u1ED1i \u0111\u01A1n - \u0111\xE2y ch\u1EC9 l\xE0 m\u1ED9t c\xE1ch n\xF3i hoa m\u1EF9 \u0111\u1EC3 n\xF3i v\u1EC1 s\u1EF1 ch\u1ED3ng ch\xE9o c\u1EE7a c\xE1c t\u1EEB v\xE0 ch\xEDnh x\xE1c l\xE0 s\u1ED1 li\u1EC7u m\xE0 ch\xFAng ta \u0111\xE3 th\u1EA3o lu\u1EADn \u1EDF tr\xEAn. \u0110\u1EC3 x\xE1c minh \u0111i\u1EC1u n\xE0y, ch\xFAng ta h\xE3y l\u1EA5y ra gi\xE1 tr\u1ECB "),pc=h("code"),Jm=e("mid"),Zm=e(" \u0111i\u1EC3m s\u1ED1 c\u1EE7a m\xECnh:"),Rr=m(),_(Xa.$$.fragment),Hr=m(),_(Ya.$$.fragment),Ir=m(),nt=h("p"),np=e("Tuy\u1EC7t v\u1EDDi, precision v\xE0 recall l\u1EA1i kh\u1EDBp v\u1EDBi nhau! C\xF2n nh\u1EEFng \u0111i\u1EC3m ROUGE kh\xE1c th\xEC sao? "),uc=h("code"),tp=e("rouge2"),sp=e(" \u0111o l\u01B0\u1EDDng s\u1EF1 tr\xF9ng l\u1EB7p gi\u1EEFa c\xE1c bigram (h\xE3y ngh\u0129 r\u1EB1ng \u0111\xF3 l\xE0 s\u1EF1 ch\u1ED3ng ch\xE9o c\u1EE7a c\xE1c c\u1EB7p t\u1EEB), trong khi "),gc=h("code"),ep=e("rougeL"),ap=e(" v\xE0 "),dc=h("code"),hp=e("rougeLsum"),lp=e(" \u0111o l\u01B0\u1EDDng c\xE1c chu\u1ED7i t\u1EEB ph\xF9 h\u1EE3p d\xE0i nh\u1EA5t b\u1EB1ng c\xE1ch t\xECm ki\u1EBFm c\xE1c chu\u1ED7i con chung d\xE0i nh\u1EA5t trong c\xE1c b\u1EA3n t\xF3m t\u1EAFt \u0111\u01B0\u1EE3c t\u1EA1o v\xE0 tham chi\u1EBFu. \u201Csum\u201D trong "),fc=h("code"),cp=e("rougeLsum"),rp=e(" \u0111\u1EC1 c\u1EADp \u0111\u1EBFn th\u1EF1c t\u1EBF l\xE0 ch\u1EC9 s\u1ED1 n\xE0y \u0111\u01B0\u1EE3c t\xEDnh tr\xEAn to\xE0n b\u1ED9 b\u1EA3n t\xF3m t\u1EAFt, trong khi "),bc=h("code"),ip=e("rougeL"),op=e(" \u0111\u01B0\u1EE3c t\xEDnh l\xE0 gi\xE1 tr\u1ECB trung b\xECnh tr\xEAn c\xE1c c\xE2u ri\xEAng l\u1EBB."),Gr=m(),_(We.$$.fragment),Mr=m(),sl=h("p"),mp=e("Ch\xFAng t\xF4i s\u1EBD s\u1EED d\u1EE5ng c\xE1c \u0111i\u1EC3m ROUGE n\xE0y \u0111\u1EC3 theo d\xF5i hi\u1EC7u su\u1EA5t c\u1EE7a m\xF4 h\xECnh, nh\u01B0ng tr\u01B0\u1EDBc khi l\xE0m \u0111i\u1EC1u \u0111\xF3, h\xE3y l\xE0m \u0111i\u1EC1u m\xE0 m\u1ECDi ng\u01B0\u1EDDi th\u1EF1c h\xE0nh NLP gi\u1ECFi n\xEAn l\xE0m: t\u1EA1o m\u1ED9t \u0111\u01B0\u1EDDng c\u01A1 s\u1EDF m\u1EA1nh m\u1EBD nh\u01B0ng \u0111\u01A1n gi\u1EA3n!"),Ur=m(),de=h("h3"),Xe=h("a"),vc=h("span"),_(Qa.$$.fragment),pp=m(),_c=h("span"),up=e("T\u1EA1o m\u1ED9t \u0111\u01B0\u1EDDng c\u01A1 s\u1EDF m\u1EA1nh m\u1EBD"),Br=m(),ft=h("p"),gp=e("M\xF4t m\xF4 h\xECnh c\u01A1 s\u1EDF cho t\xF3m t\u1EAFt v\u0103n b\u1EA3n, \u0111\xF3 l\xE0 ch\u1EC9 c\u1EA7n l\u1EA5y ba c\xE2u \u0111\u1EA7u ti\xEAn c\u1EE7a m\u1ED9t b\xE0i b\xE1o, th\u01B0\u1EDDng \u0111\u01B0\u1EE3c g\u1ECDi l\xE0 "),yc=h("em"),dp=e("lead-3"),fp=e(" hay "),kc=h("em"),bp=e("3 b\xE0i \u0111\u1EA7u"),vp=e(". Ch\xFAng ta c\xF3 th\u1EC3 s\u1EED d\u1EE5ng c\xE1c d\u1EA5u ch\u1EA5m \u0111\u1EC3 theo d\xF5i ranh gi\u1EDBi c\xE2u, nh\u01B0ng \u0111i\u1EC1u n\xE0y s\u1EBD kh\xF4ng th\xE0nh c\xF4ng \u0111\u1ED1i v\u1EDBi c\xE1c t\u1EEB vi\u1EBFt t\u1EAFt nh\u01B0 \u201CU.S.\u201D ho\u1EB7c \u201CU.N.\u201D - v\xEC v\u1EADy thay v\xE0o \u0111\xF3, ch\xFAng ta s\u1EBD s\u1EED d\u1EE5ng th\u01B0 vi\u1EC7n "),$c=h("code"),_p=e("nltk"),yp=e(", bao g\u1ED3m m\u1ED9t thu\u1EADt to\xE1n t\u1ED1t h\u01A1n \u0111\u1EC3 x\u1EED l\xFD nh\u1EEFng tr\u01B0\u1EDDng h\u1EE3p n\xE0y. B\u1EA1n c\xF3 th\u1EC3 c\xE0i \u0111\u1EB7t g\xF3i b\u1EB1ng c\xE1ch s\u1EED d\u1EE5ng "),jc=h("code"),kp=e("pip"),$p=e(" nh\u01B0 sau:"),Fr=m(),_(Ja.$$.fragment),Vr=m(),el=h("p"),jp=e("v\xE0 sau \u0111\xF3 t\u1EA3i c\xE1c quy t\u1EAFc d\u1EA5u c\xE2u:"),Kr=m(),_(Za.$$.fragment),Wr=m(),Ye=h("p"),wp=e("Ti\u1EBFp theo, ch\xFAng ta nh\u1EADp tokenizer c\xE2u t\u1EEB "),wc=h("code"),xp=e("nltk"),Ep=e(" v\xE0 t\u1EA1o m\u1ED9t h\xE0m \u0111\u01A1n gi\u1EA3n \u0111\u1EC3 tr\xEDch xu\u1EA5t ba c\xE2u \u0111\u1EA7u ti\xEAn trong m\u1ED9t b\xE0i \u0111\xE1nh gi\xE1. Quy \u01B0\u1EDBc trong ph\u1EA7n t\xF3m t\u1EAFt v\u0103n b\u1EA3n l\xE0 t\xE1ch t\u1EEBng ph\u1EA7n t\xF3m t\u1EAFt b\u1EB1ng m\u1ED9t d\xF2ng m\u1EDBi, v\xEC v\u1EADy h\xE3y bao g\u1ED3m ph\u1EA7n n\xE0y v\xE0 ki\u1EC3m tra n\xF3 tr\xEAn m\u1ED9t v\xED d\u1EE5 hu\u1EA5n luy\u1EC7n:"),Xr=m(),_(nh.$$.fragment),Yr=m(),_(th.$$.fragment),Qr=m(),al=h("p"),qp=e("\u0110i\u1EC1u n\xE0y c\xF3 v\u1EBB hi\u1EC7u qu\u1EA3, v\xEC v\u1EADy b\xE2y gi\u1EDD ch\xFAng ta h\xE3y tri\u1EC3n khai m\u1ED9t h\xE0m tr\xEDch xu\u1EA5t c\xE1c \u201Ct\xF3m t\u1EAFt\u201D n\xE0y t\u1EEB t\u1EADp d\u1EEF li\u1EC7u v\xE0 t\xEDnh to\xE1n \u0111i\u1EC3m ROUGE cho m\xF4 h\xECnh c\u01A1 s\u1EDF:"),Jr=m(),_(sh.$$.fragment),Zr=m(),hl=h("p"),Tp=e("Sau \u0111\xF3, ch\xFAng ta c\xF3 th\u1EC3 s\u1EED d\u1EE5ng h\xE0m n\xE0y \u0111\u1EC3 t\xEDnh to\xE1n \u0111i\u1EC3m ROUGE tr\xEAn t\u1EADp ki\u1EC3m \u0111\u1ECBnh v\xE0 ki\u1EC3m tra ch\xFAng m\u1ED9t ch\xFAt b\u1EB1ng c\xE1ch s\u1EED d\u1EE5ng Pandas:"),ni=m(),_(eh.$$.fragment),ti=m(),_(ah.$$.fragment),si=m(),Qe=h("p"),Cp=e("Ch\xFAng ta c\xF3 th\u1EC3 th\u1EA5y r\u1EB1ng \u0111i\u1EC3m "),xc=h("code"),zp=e("rouge2"),Dp=e(" th\u1EA5p h\u01A1n \u0111\xE1ng k\u1EC3 so v\u1EDBi ph\u1EA7n c\xF2n l\u1EA1i; \u0111i\u1EC1u n\xE0y c\xF3 th\u1EC3 ph\u1EA3n \xE1nh th\u1EF1c t\u1EBF l\xE0 ti\xEAu \u0111\u1EC1 b\xE0i \u0111\xE1nh gi\xE1 th\u01B0\u1EDDng ng\u1EAFn g\u1ECDn v\xE0 do \u0111\xF3, m\xF4 h\xECnh c\u01A1 s\u1EDF c\u1EE7a 3 b\xE0i \u0111\u1EA7u qu\xE1 d\xE0i d\xF2ng. B\xE2y gi\u1EDD ch\xFAng ta \u0111\xE3 c\xF3 m\u1ED9t c\u01A1 s\u1EDF t\u1ED1t \u0111\u1EC3 l\xE0m vi\u1EC7c, h\xE3y chuy\u1EC3n s\u1EF1 ch\xFA \xFD c\u1EE7a ch\xFAng ta sang vi\u1EC7c tinh ch\u1EC9nh mT5!"),ei=m(),fs.c(),ll=m(),_(Je.$$.fragment),ai=m(),cl=h("p"),Sp=e("\u0110i\u1EC1u ti\u1EBFp theo ch\xFAng ta c\u1EA7n l\xE0m l\xE0 \u0111\u0103ng nh\u1EADp v\xE0o Hugging Face Hub. N\u1EBFu b\u1EA1n \u0111ang ch\u1EA1y \u0111o\u1EA1n m\xE3 n\xE0y trong notebook, b\u1EA1n c\xF3 th\u1EC3 l\xE0m nh\u01B0 v\u1EADy v\u1EDBi h\xE0m ti\u1EC7n \xEDch sau:"),hi=m(),_(hh.$$.fragment),li=m(),rl=h("p"),Ap=e("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 c\u1EE7a m\xECnh. Ngo\xE0i ra, b\u1EA1n c\xF3 th\u1EC3 ch\u1EA1y l\u1EC7nh n\xE0y trong thi\u1EBFt b\u1ECB \u0111\u1EA7u cu\u1ED1i c\u1EE7a m\xECnh v\xE0 \u0111\u0103ng nh\u1EADp v\xE0o \u0111\xF3:"),ci=m(),_(lh.$$.fragment),ri=m(),Ln&&Ln.c(),il=m(),Ze=h("p"),Op=e("Ti\u1EBFp theo, ch\xFAng ta c\u1EA7n ph\u1EA3i x\xE1c \u0111\u1ECBnh m\u1ED9t b\u1ED9 \u0111\u1ED1i chi\u1EBFu d\u1EEF li\u1EC7u cho t\xE1c v\u1EE5 chu\u1ED7i sang chu\u1ED7i c\u1EE7a ch\xFAng ta. V\xEC mT5 l\xE0 m\xF4 h\xECnh Transformer b\u1ED9 m\xE3 h\xF3a-gi\u1EA3i m\xE3, m\u1ED9t \u0111i\u1EC1u tinh t\u1EBF khi chu\u1EA9n b\u1ECB c\xE1c l\xF4 l\xE0 trong qu\xE1 tr\xECnh gi\u1EA3i m\xE3, ch\xFAng ta c\u1EA7n chuy\u1EC3n c\xE1c nh\xE3n sang ph\u1EA3i t\u1EEBng nh\xE3n. \u0110i\u1EC1u n\xE0y l\xE0 b\u1EAFt bu\u1ED9c \u0111\u1EC3 \u0111\u1EA3m b\u1EA3o r\u1EB1ng b\u1ED9 gi\u1EA3i m\xE3 ch\u1EC9 nh\xECn th\u1EA5y c\xE1c nh\xE3n tr\u01B0\u1EDBc \u0111\xF3 ch\u1EE9 kh\xF4ng ph\u1EA3i nh\xE3n hi\u1EC7n t\u1EA1i ho\u1EB7c t\u01B0\u01A1ng lai, \u0111i\u1EC1u n\xE0y s\u1EBD gi\xFAp m\xF4 h\xECnh d\u1EC5 d\xE0ng ghi nh\u1EDB. \u0110i\u1EC1u n\xE0y t\u01B0\u01A1ng t\u1EF1 nh\u01B0 c\xE1ch \xE1p d\u1EE5ng masked self-attention cho c\xE1c \u0111\u1EA7u v\xE0o trong m\u1ED9t t\xE1c v\u1EE5 nh\u01B0 "),ol=h("a"),Pp=e("m\xF4 h\xECnh ng\xF4n ng\u1EEF nh\xE2n qu\u1EA3"),Lp=e("."),ii=m(),Bt=h("p"),Np=e("May m\u1EAFn thay, \u{1F917} Transformers cung c\u1EA5p m\u1ED9t b\u1ED9 \u0111\u1ED1i chi\u1EBFu "),Ec=h("code"),Rp=e("DataCollatorForSeq2Seq"),Hp=e(" s\u1EBD t\u1EF1 \u0111\u1ED9ng \u0111\u1EC7m c\xE1c \u0111\u1EA7u v\xE0o v\xE0 nh\xE3n cho ch\xFAng ta. \u0110\u1EC3 kh\u1EDFi t\u1EA1o b\u1ED9 \u0111\u1ED1i chi\u1EBFu n\xE0y, ch\xFAng ta ch\u1EC9 c\u1EA7n cung c\u1EA5p "),qc=h("code"),Ip=e("tokenizer"),Gp=e(" v\xE0 "),Tc=h("code"),Mp=e("model"),Up=e(":"),oi=m(),vs.c(),ml=m(),pl=h("p"),Bp=e("H\xE3y xem nh\u1EEFng g\xEC m\xE0 m\xE1y \u0111\u1ED1i chi\u1EBFu n\xE0y t\u1EA1o ra khi \u0111\u01B0\u1EE3c cung c\u1EA5p m\u1ED9t lo\u1EA1t c\xE1c v\xED d\u1EE5 nh\u1ECF. \u0110\u1EA7u ti\xEAn, ch\xFAng ta c\u1EA7n x\xF3a c\xE1c c\u1ED9t c\xF3 chu\u1ED7i v\xEC tr\xECnh \u0111\u1ED1i chi\u1EBFu s\u1EBD kh\xF4ng bi\u1EBFt c\xE1ch ch\xE8n c\xE1c ph\u1EA7n t\u1EED n\xE0y:"),mi=m(),_(ch.$$.fragment),pi=m(),Gs=h("p"),Fp=e("V\xEC b\u1ED9 \u0111\u1ED1i chi\u1EBFu mong \u0111\u1EE3i m\u1ED9t danh s\xE1ch c\xE1c "),Cc=h("code"),Vp=e("dict"),Kp=e(", trong \u0111\xF3 m\u1ED7i "),zc=h("code"),Wp=e("dict"),Xp=e(" \u0111\u1EA1i di\u1EC7n cho m\u1ED9t v\xED d\u1EE5 duy nh\u1EA5t trong t\u1EADp d\u1EEF li\u1EC7u, ch\xFAng ta c\u0169ng c\u1EA7n cu\u1ED9n d\u1EEF li\u1EC7u th\xE0nh \u0111\u1ECBnh d\u1EA1ng mong \u0111\u1EE3i tr\u01B0\u1EDBc khi chuy\u1EC3n n\xF3 \u0111\u1EBFn b\u1ED9 \u0111\u1ED1i chi\u1EBFu d\u1EEF li\u1EC7u:"),ui=m(),_(rh.$$.fragment),gi=m(),_(ih.$$.fragment),di=m(),En=h("p"),Yp=e("\u0110i\u1EC1u ch\xEDnh c\u1EA7n ch\xFA \xFD \u1EDF \u0111\xE2y l\xE0 m\u1EABu \u0111\u1EA7u ti\xEAn d\xE0i h\u01A1n th\u1EE9 hai, do \u0111\xF3, "),Dc=h("code"),Qp=e("input_ids"),Jp=e(" v\xE0 "),Sc=h("code"),Zp=e("attention_mask"),nu=e(" c\u1EE7a m\u1EABu th\u1EE9 hai \u0111\xE3 \u0111\u01B0\u1EE3c \u0111\u1EC7m \u1EDF b\xEAn ph\u1EA3i b\u1EB1ng "),Ac=h("code"),tu=e("[PAD]"),su=e(" (c\xF3 ID l\xE0 "),Oc=h("code"),eu=e("0"),au=e("). T\u01B0\u01A1ng t\u1EF1, ch\xFAng ta c\xF3 th\u1EC3 th\u1EA5y r\u1EB1ng "),Pc=h("code"),hu=e("labels"),lu=e(" \u0111\xE3 \u0111\u01B0\u1EE3c \u0111\u1EC7m b\u1EB1ng "),Lc=h("code"),cu=e("-100"),ru=e(", \u0111\u1EC3 \u0111\u1EA3m b\u1EA3o r\u1EB1ng c\xE1c token \u0111\u1EC7m \u0111\u01B0\u1EE3c b\u1ECF qua b\u1EDFi h\xE0m m\u1EA5t m\xE1t. V\xE0 cu\u1ED1i c\xF9ng, ch\xFAng ta c\xF3 th\u1EC3 th\u1EA5y m\u1ED9t "),Nc=h("code"),iu=e("decoder_input_ids"),ou=e(" m\u1EDBi \u0111\xE3 chuy\u1EC3n c\xE1c nh\xE3n sang b\xEAn ph\u1EA3i b\u1EB1ng c\xE1ch ch\xE8n "),Rc=h("code"),mu=e("[PAD]"),pu=e(" v\xE0o m\u1EE5c nh\u1EADp \u0111\u1EA7u ti\xEAn."),fi=m(),ys.c(),ul=m(),Nn&&Nn.c(),gl=m(),fe=h("h2"),na=h("a"),Hc=h("span"),_(oh.$$.fragment),uu=m(),Ic=h("span"),gu=e("S\u1EED d\u1EE5ng m\xF4 h\xECnh tinh ch\u1EC9nh c\u1EE7a b\u1EA1n"),bi=m(),ta=h("p"),du=e("Khi b\u1EA1n \u0111\xE3 \u0111\u1EA9y m\xF4 h\xECnh v\xE0o Hub, b\u1EA1n c\xF3 th\u1EC3 ch\u01A1i v\u1EDBi n\xF3 th\xF4ng qua ti\u1EC7n \xEDch lu\u1EADn suy ho\u1EB7c v\u1EDBi \u0111\u1ED1i t\u01B0\u1EE3ng "),Gc=h("code"),fu=e("pipeline"),bu=e(", nh\u01B0 sau:"),vi=m(),_(mh.$$.fragment),_i=m(),dl=h("p"),vu=e("Ch\xFAng ta c\xF3 th\u1EC3 cung c\u1EA5p m\u1ED9t s\u1ED1 m\u1EABu t\u1EEB b\u1ED9 ki\u1EC3m th\u1EED (m\xE0 m\xF4 h\xECnh ch\u01B0a th\u1EA5y) v\xE0o pipeline \u0111\u1EC3 c\xF3 c\u1EA3m nh\u1EADn v\u1EC1 ch\u1EA5t l\u01B0\u1EE3ng c\u1EE7a c\xE1c b\u1EA3n t\xF3m t\u1EAFt. Tr\u01B0\u1EDBc ti\xEAn, h\xE3y tri\u1EC3n khai m\u1ED9t ch\u1EE9c n\u0103ng \u0111\u01A1n gi\u1EA3n \u0111\u1EC3 hi\u1EC3n th\u1ECB b\xE0i \u0111\xE1nh gi\xE1, ti\xEAu \u0111\u1EC1 v\xE0 b\u1EA3n t\xF3m t\u1EAFt \u0111\xE3 t\u1EA1o c\xF9ng nhau:"),yi=m(),_(ph.$$.fragment),ki=m(),fl=h("p"),_u=e("H\xE3y xem m\u1ED9t trong nh\u1EEFng m\u1EABu ti\u1EBFng Anh m\xE0 ch\xFAng ta nh\u1EADn \u0111\u01B0\u1EE3c:"),$i=m(),_(uh.$$.fragment),ji=m(),_(gh.$$.fragment),wi=m(),sa=h("p"),yu=e("\u0110i\u1EC1u n\xE0y kh\xF4ng qu\xE1 t\u1EC7! Ch\xFAng ta c\xF3 th\u1EC3 th\u1EA5y r\u1EB1ng m\xF4 h\xECnh c\u1EE7a m\xECnh \u0111\xE3 th\u1EF1c s\u1EF1 c\xF3 th\u1EC3 th\u1EF1c hi\u1EC7n t\xF3m t\u1EAFt "),Mc=h("em"),ku=e("tr\u1EEBu t\u01B0\u1EE3ng"),$u=e(" b\u1EB1ng c\xE1ch t\u0103ng c\u01B0\u1EDDng c\xE1c ph\u1EA7n c\u1EE7a b\xE0i \u0111\xE1nh gi\xE1 b\u1EB1ng c\xE1c t\u1EEB m\u1EDBi. V\xE0 c\xF3 l\u1EBD kh\xEDa c\u1EA1nh th\xFA v\u1ECB nh\u1EA5t c\u1EE7a m\xF4 h\xECnh c\u1EE7a ch\xFAng ta l\xE0 n\xF3 \u0111\u01B0\u1EE3c s\u1EED d\u1EE5ng song ng\u1EEF, v\xEC v\u1EADy ta c\u0169ng c\xF3 th\u1EC3 t\u1EA1o t\xF3m t\u1EAFt c\xE1c b\xE0i \u0111\xE1nh gi\xE1 b\u1EB1ng ti\u1EBFng T\xE2y Ban Nha:"),xi=m(),_(dh.$$.fragment),Ei=m(),_(fh.$$.fragment),qi=m(),bl=h("p"),ju=e("B\u1EA3n t\xF3m t\u1EAFt \u0111\u01B0\u1EE3c d\u1ECBch th\xE0nh \u201CVery easy to read\u201D trong ti\u1EBFng Anh, m\xE0 ch\xFAng ta c\xF3 th\u1EC3 th\u1EA5y trong tr\u01B0\u1EDDng h\u1EE3p n\xE0y \u0111\u01B0\u1EE3c tr\xEDch tr\u1EF1c ti\u1EBFp t\u1EEB \u0111\xE1nh gi\xE1. Tuy nhi\xEAn, \u0111i\u1EC1u n\xE0y cho th\u1EA5y t\xEDnh linh ho\u1EA1t c\u1EE7a m\xF4 h\xECnh mT5 v\xE0 cho b\u1EA1n bi\u1EBFt c\u1EA3m gi\xE1c tri\u1EC3n khai v\u1EDBi kho ng\u1EEF li\u1EC7u \u0111a ng\xF4n ng\u1EEF l\xE0 nh\u01B0 th\u1EBF n\xE0o!"),Ti=m(),vl=h("p"),wu=e("Ti\u1EBFp theo, ch\xFAng ta s\u1EBD chuy\u1EC3n s\u1EF1 ch\xFA \xFD sang m\u1ED9t t\xE1c v\u1EE5 ph\u1EE9c t\u1EA1p h\u01A1n m\u1ED9t ch\xFAt: hu\u1EA5n luy\u1EC7n m\u1ED9t m\xF4 h\xECnh ng\xF4n ng\u1EEF t\u1EEB \u0111\u1EA7u."),this.h()},l(n){const i=Cf('[data-svelte="svelte-1phssyn"]',document.head);u=l(i,"META",{name:!0,content:!0}),i.forEach(s),w=p(n),y(g.$$.fragment,n),x=p(n),L=l(n,"H1",{class:!0});var kh=c(L);E=l(kh,"A",{id:!0,class:!0,href:!0});var _l=c(E);N=l(_l,"SPAN",{});var Uc=c(N);y(O.$$.fragment,Uc),Uc.forEach(s),_l.forEach(s),q=p(kh),z=l(kh,"SPAN",{});var Bc=c(z);S=a(Bc,"T\xF3m t\u1EAFt"),Bc.forEach(s),kh.forEach(s),A=p(n),I.l(n),X=p(n),K=l(n,"P",{});var be=c(K);J=a(be,"Trong ph\u1EA7n n\xE0y, ch\xFAng ta s\u1EBD xem x\xE9t c\xE1ch c\xE1c m\xF4 h\xECnh Transformer c\xF3 th\u1EC3 \u0111\u01B0\u1EE3c s\u1EED d\u1EE5ng \u0111\u1EC3 c\xF4 \u0111\u1ECDng c\xE1c t\xE0i li\u1EC7u d\xE0i th\xE0nh c\xE1c b\u1EA3n t\xF3m t\u1EAFt, m\u1ED9t t\xE1c v\u1EE5 \u0111\u01B0\u1EE3c g\u1ECDi l\xE0 "),M=l(be,"EM",{});var Fc=c(M);Y=a(Fc,"text summarization"),Fc.forEach(s),P=a(be," hay "),U=l(be,"EM",{});var Vc=c(U);G=a(Vc,"t\xF3m t\u1EAFt v\u0103n b\u1EA3n"),Vc.forEach(s),Q=a(be,". \u0110\xE2y l\xE0 m\u1ED9t trong nh\u1EEFng t\xE1c v\u1EE5 NLP th\xE1ch th\u1EE9c nh\u1EA5t v\xEC n\xF3 \u0111\xF2i h\u1ECFi nhi\u1EC1u kh\u1EA3 n\u0103ng, ch\u1EB3ng h\u1EA1n nh\u01B0 hi\u1EC3u c\xE1c \u0111o\u1EA1n v\u0103n d\xE0i v\xE0 t\u1EA1o ra v\u0103n b\u1EA3n m\u1EA1ch l\u1EA1c n\u1EAFm b\u1EAFt c\xE1c ch\u1EE7 \u0111\u1EC1 ch\xEDnh trong t\xE0i li\u1EC7u. Tuy nhi\xEAn, khi \u0111\u01B0\u1EE3c th\u1EF1c hi\u1EC7n t\u1ED1t, t\xF3m t\u1EAFt v\u0103n b\u1EA3n l\xE0 m\u1ED9t c\xF4ng c\u1EE5 m\u1EA1nh m\u1EBD c\xF3 th\u1EC3 t\u0103ng t\u1ED1c c\xE1c quy tr\xECnh kinh doanh kh\xE1c nhau b\u1EB1ng c\xE1ch gi\u1EA3m b\u1EDBt g\xE1nh n\u1EB7ng cho c\xE1c chuy\xEAn gia mi\u1EC1n ph\u1EA3i \u0111\u1ECDc chi ti\u1EBFt c\xE1c t\xE0i li\u1EC7u d\xE0i."),be.forEach(s),an=p(n),y(tn.$$.fragment,n),B=p(n),sn=l(n,"P",{});var ve=c(sn);F=a(ve,"M\u1EB7c d\xF9 \u0111\xE3 t\u1ED3n t\u1EA1i nhi\u1EC1u m\xF4 h\xECnh \u0111\u01B0\u1EE3c tinh ch\u1EC9nh kh\xE1c nhau \u0111\u1EC3 t\xF3m t\u1EAFt tr\xEAn "),rn=l(ve,"A",{href:!0,rel:!0});var yl=c(rn);gn=a(yl,"Hugging Face Hub"),yl.forEach(s),qn=a(ve,", h\u1EA7u h\u1EBFt t\u1EA5t c\u1EA3 c\xE1c m\xF4 h\xECnh n\xE0y ch\u1EC9 ph\xF9 h\u1EE3p v\u1EDBi c\xE1c t\xE0i li\u1EC7u ti\u1EBFng Anh. V\xEC v\u1EADy, \u0111\u1EC3 t\u1EA1o th\xEAm m\u1ED9t \u0111i\u1EC3m nh\u1EA5n trong ph\u1EA7n n\xE0y, ch\xFAng t\xF4i s\u1EBD hu\u1EA5n luy\u1EC7n m\u1ED9t m\xF4 h\xECnh song ng\u1EEF cho ti\u1EBFng Anh v\xE0 ti\u1EBFng T\xE2y Ban Nha. \u0110\u1EBFn cu\u1ED1i ph\u1EA7n n\xE0y, b\u1EA1n s\u1EBD c\xF3 m\u1ED9t "),vn=l(ve,"A",{href:!0,rel:!0});var Kc=c(vn);Z=a(Kc,"m\xF4 h\xECnh"),Kc.forEach(s),_n=a(ve," c\xF3 th\u1EC3 t\xF3m t\u1EAFt c\xE1c \u0111\xE1nh gi\xE1 c\u1EE7a kh\xE1ch h\xE0ng nh\u01B0 \u0111\u01B0\u1EE3c hi\u1EC3n th\u1ECB \u1EDF \u0111\xE2y:"),ve.forEach(s),pn=p(n),nn=l(n,"IFRAME",{src:!0,frameborder:!0,height:!0,title:!0,class:!0,allow:!0,sandbox:!0}),c(nn).forEach(s),kn=p(n),hn=l(n,"P",{});var kl=c(hn);Dn=a(kl,"Nh\u01B0 ch\xFAng ta s\u1EBD th\u1EA5y, nh\u1EEFng b\u1EA3n t\xF3m t\u1EAFt n\xE0y ng\u1EAFn g\u1ECDn v\xEC ch\xFAng \u0111\u01B0\u1EE3c h\u1ECDc t\u1EEB c\xE1c ti\xEAu \u0111\u1EC1 m\xE0 kh\xE1ch h\xE0ng cung c\u1EA5p trong c\xE1c b\xE0i \u0111\xE1nh gi\xE1 s\u1EA3n ph\u1EA9m c\u1EE7a h\u1ECD. H\xE3y b\u1EAFt \u0111\u1EA7u b\u1EB1ng c\xE1ch t\u1EADp h\u1EE3p m\u1ED9t kho ng\u1EEF li\u1EC7u song ng\u1EEF ph\xF9 h\u1EE3p cho t\xE1c v\u1EE5 n\xE0y."),kl.forEach(s),dn=p(n),on=l(n,"H2",{class:!0});var ea=c(on);v=l(ea,"A",{id:!0,class:!0,href:!0});var Ru=c(v);R=l(Ru,"SPAN",{});var Hu=c(R);y(mn.$$.fragment,Hu),Hu.forEach(s),Ru.forEach(s),j=p(ea),V=l(ea,"SPAN",{});var Iu=c(V);$n=a(Iu,"Chu\u1EA9n b\u1ECB kho ng\u1EEF li\u1EC7u \u0111a ng\xF4n ng\u1EEF"),Iu.forEach(s),ea.forEach(s),jn=p(n),un=l(n,"P",{});var zi=c(un);Tn=a(zi,"Ch\xFAng ta s\u1EBD s\u1EED d\u1EE5ng "),en=l(zi,"A",{href:!0,rel:!0});var Gu=c(en);Un=a(Gu,"Multilingual Amazon Reviews Corpus"),Gu.forEach(s),tt=a(zi," \u0111\u1EC3 t\u1EA1o tr\xECnh t\xF3m t\u1EAFt song ng\u1EEF. T\u1EADp t\xE0i li\u1EC7u n\xE0y bao g\u1ED3m c\xE1c b\xE0i \u0111\xE1nh gi\xE1 s\u1EA3n ph\u1EA9m c\u1EE7a Amazon b\u1EB1ng s\xE1u ng\xF4n ng\u1EEF v\xE0 th\u01B0\u1EDDng \u0111\u01B0\u1EE3c s\u1EED d\u1EE5ng \u0111\u1EC3 \u0111\xE1nh gi\xE1 c\xE1c b\u1ED9 ph\xE2n lo\u1EA1i \u0111a ng\xF4n ng\u1EEF. Tuy nhi\xEAn, v\xEC m\u1ED7i b\xE0i \u0111\xE1nh gi\xE1 \u0111i k\xE8m v\u1EDBi m\u1ED9t ti\xEAu \u0111\u1EC1 ng\u1EAFn, ch\xFAng ta c\xF3 th\u1EC3 s\u1EED d\u1EE5ng c\xE1c ti\xEAu \u0111\u1EC1 n\xE0y l\xE0m nh\xE3n t\xF3m t\u1EAFt cho m\xF4 h\xECnh c\u1EE7a ch\xFAng ta \u0111\u1EC3 h\u1ECDc! \u0110\u1EC3 b\u1EAFt \u0111\u1EA7u, h\xE3y t\u1EA3i xu\u1ED1ng c\xE1c t\u1EADp h\u1EE3p con ti\u1EBFng Anh v\xE0 ti\u1EBFng T\xE2y Ban Nha t\u1EEB Hugging Face Hub:"),zi.forEach(s),cn=p(n),y(wn.$$.fragment,n),Rn=p(n),y(Sn.$$.fragment,n),wt=p(n),ln=l(n,"P",{});var bt=c(ln);Yt=a(bt,"Nh\u01B0 b\u1EA1n c\xF3 th\u1EC3 th\u1EA5y, \u0111\u1ED1i v\u1EDBi m\u1ED7i ng\xF4n ng\u1EEF, c\xF3 200,000 \u0111\xE1nh gi\xE1 cho ph\u1EA7n "),vt=l(bt,"CODE",{});var Mu=c(vt);ct=a(Mu,"hu\u1EA5n luy\u1EC7n"),Mu.forEach(s),st=a(bt," v\xE0 5,000 nh\u1EADn x\xE9t cho m\u1ED7i ph\u1EA7n "),rt=l(bt,"CODE",{});var Uu=c(rt);Bn=a(Uu,"ki\u1EC3m \u0111\u1ECBnh"),Uu.forEach(s),xt=a(bt," v\xE0 "),Wn=l(bt,"CODE",{});var Bu=c(Wn);_t=a(Bu,"ki\u1EC3m th\u1EED"),Bu.forEach(s),Et=a(bt,". Th\xF4ng tin \u0111\xE1nh gi\xE1 m\xE0 ch\xFAng ta quan t\xE2m \u0111\u01B0\u1EE3c ch\u1EE9a trong c\u1ED9t "),An=l(bt,"CODE",{});var Fu=c(An);it=a(Fu,"review_body"),Fu.forEach(s),et=a(bt," v\xE0 "),ot=l(bt,"CODE",{});var Vu=c(ot);H=a(Vu,"review_title"),Vu.forEach(s),fn=a(bt,". H\xE3y xem m\u1ED9t v\xE0i v\xED d\u1EE5 b\u1EB1ng c\xE1ch t\u1EA1o m\u1ED9t h\xE0m \u0111\u01A1n gi\u1EA3n l\u1EA5y m\u1ED9t m\u1EABu ng\u1EABu nhi\xEAn t\u1EEB t\u1EADp hu\u1EA5n luy\u1EC7n v\u1EDBi c\xE1c k\u1EF9 thu\u1EADt ch\xFAng ta \u0111\xE3 h\u1ECDc trong "),yt=l(bt,"A",{href:!0});var Ku=c(yt);qt=a(Ku,"Ch\u01B0\u01A1ng 5"),Ku.forEach(s),xn=a(bt,":"),bt.forEach(s),Tt=p(n),y(Fn.$$.fragment,n),Qt=p(n),y(at.$$.fragment,n),ht=p(n),y(Xn.$$.fragment,n),bn=p(n),Vn=l(n,"P",{});var $l=c(Vn);Jt=a($l,"M\u1EABu n\xE0y cho th\u1EA5y s\u1EF1 \u0111a d\u1EA1ng c\u1EE7a c\xE1c b\xE0i \u0111\xE1nh gi\xE1 m\xE0 ng\u01B0\u1EDDi ta th\u01B0\u1EDDng t\xECm th\u1EA5y tr\xEAn m\u1EA1ng, t\u1EEB t\xEDch c\u1EF1c \u0111\u1EBFn ti\xEAu c\u1EF1c (v\xE0 m\u1ECDi th\u1EE9 \u1EDF gi\u1EEFa!). M\u1EB7c d\xF9 v\xED d\u1EE5 v\u1EDBi ti\xEAu \u0111\u1EC1 \u201Cmeh\u201D kh\xF4ng nhi\u1EC1u th\xF4ng tin, nh\u01B0ng c\xE1c ti\xEAu \u0111\u1EC1 kh\xE1c tr\xF4ng gi\u1ED1ng nh\u01B0 nh\u1EEFng b\u1EA3n t\xF3m t\u1EAFt ph\xF9 h\u1EE3p v\u1EC1 b\u1EA3n th\xE2n c\xE1c \u0111\xE1nh gi\xE1. Vi\u1EC7c hu\u1EA5n luy\u1EC7n m\u1ED9t m\xF4 h\xECnh t\xF3m t\u1EAFt cho t\u1EA5t c\u1EA3 400,000 b\xE0i \u0111\xE1nh gi\xE1 s\u1EBD m\u1EA5t qu\xE1 nhi\u1EC1u th\u1EDDi gian tr\xEAn m\u1ED9t GPU, v\xEC v\u1EADy thay v\xE0o \u0111\xF3, ch\xFAng ta s\u1EBD t\u1EADp trung v\xE0o vi\u1EC7c t\u1EA1o t\xF3m t\u1EAFt cho m\u1ED9t mi\u1EC1n s\u1EA3n ph\u1EA9m. \u0110\u1EC3 bi\u1EBFt t\xEAn mi\u1EC1n m\xE0 ch\xFAng ta c\xF3 th\u1EC3 ch\u1ECDn, h\xE3y chuy\u1EC3n \u0111\u1ED5i "),Yn=l($l,"CODE",{});var Wu=c(Yn);Zt=a(Wu,"english_dataset"),Wu.forEach(s),Kn=a($l," th\xE0nh "),Ct=l($l,"CODE",{});var Xu=c(Ct);zt=a(Xu,"pandas.DataFrame"),Xu.forEach(s),On=a($l," v\xE0 t\xEDnh to\xE1n s\u1ED1 l\u01B0\u1EE3ng \u0111\xE1nh gi\xE1 cho m\u1ED7i danh m\u1EE5c s\u1EA3n ph\u1EA9m:"),$l.forEach(s),ns=p(n),y(Qn.$$.fragment,n),ts=p(n),y(mt.$$.fragment,n),Dt=p(n),Cn=l(n,"P",{});var Ms=c(Cn);ra=a(Ms,"C\xE1c s\u1EA3n ph\u1EA9m ph\u1ED5 bi\u1EBFn nh\u1EA5t trong t\u1EADp d\u1EEF li\u1EC7u ti\u1EBFng Anh l\xE0 v\u1EC1 \u0111\u1ED3 gia d\u1EE5ng, qu\u1EA7n \xE1o v\xE0 thi\u1EBFt b\u1ECB \u0111i\u1EC7n t\u1EED kh\xF4ng d\xE2y. Tuy nhi\xEAn, \u0111\u1EC3 g\u1EAFn b\xF3 v\u1EDBi ch\u1EE7 \u0111\u1EC1 Amazon, ch\xFAng ta h\xE3y t\u1EADp trung v\xE0o vi\u1EC7c t\xF3m t\u1EAFt c\xE1c b\xE0i \u0111\xE1nh gi\xE1 s\xE1ch - x\xE9t cho c\xF9ng, \u0111\xE2y l\xE0 nh\u1EEFng g\xEC c\xF4ng ty \u0111\u01B0\u1EE3c th\xE0nh l\u1EADp! Ch\xFAng t\xF4i c\xF3 th\u1EC3 th\u1EA5y hai danh m\u1EE5c s\u1EA3n ph\u1EA9m ph\xF9 h\u1EE3p v\u1EDBi h\xF3a \u0111\u01A1n ("),ks=l(Ms,"CODE",{});var Yu=c(ks);ss=a(Yu,"book"),Yu.forEach(s),_e=a(Ms," v\xE0 "),kt=l(Ms,"CODE",{});var Qu=c(kt);ye=a(Qu,"digital_ebook_purchase"),Qu.forEach(s),$s=a(Ms,"), v\xEC v\u1EADy, h\xE3y l\u1ECDc t\u1EADp d\u1EEF li\u1EC7u b\u1EB1ng c\u1EA3 hai ng\xF4n ng\u1EEF ch\u1EC9 cho c\xE1c s\u1EA3n ph\u1EA9m n\xE0y. Nh\u01B0 ch\xFAng ta \u0111\xE3 th\u1EA5y trong "),js=l(Ms,"A",{href:!0});var Ju=c(js);ke=a(Ju,"Ch\u01B0\u01A1ng 5"),Ju.forEach(s),es=a(Ms,", h\xE0m "),ws=l(Ms,"CODE",{});var Zu=c(ws);St=a(Zu,"Dataset.filter()"),Zu.forEach(s),ia=a(Ms," cho ph\xE9p ch\xFAng ta c\u1EAFt m\u1ED9t t\u1EADp d\u1EEF li\u1EC7u r\u1EA5t hi\u1EC7u qu\u1EA3, v\xEC v\u1EADy ch\xFAng ta c\xF3 th\u1EC3 x\xE1c \u0111\u1ECBnh m\u1ED9t h\xE0m \u0111\u01A1n gi\u1EA3n \u0111\u1EC3 th\u1EF1c hi\u1EC7n \u0111i\u1EC1u n\xE0y:"),Ms.forEach(s),xs=p(n),y(as.$$.fragment,n),$e=p(n),zn=l(n,"P",{});var Ft=c(zn);$t=a(Ft,"B\xE2y gi\u1EDD khi ch\xFAng ta \xE1p d\u1EE5ng h\xE0m n\xE0y cho "),pt=l(Ft,"CODE",{});var ng=c(pt);Vs=a(ng,"english_dataset"),ng.forEach(s),hs=a(Ft," v\xE0 "),Ks=l(Ft,"CODE",{});var tg=c(Ks);Ws=a(tg,"spanish_dataset"),tg.forEach(s),oa=a(Ft,", k\u1EBFt qu\u1EA3 s\u1EBD ch\u1EC9 ch\u1EE9a nh\u1EEFng h\xE0ng li\xEAn quan \u0111\u1EBFn danh m\u1EE5c s\xE1ch. Tr\u01B0\u1EDBc khi \xE1p d\u1EE5ng b\u1ED9 l\u1ECDc, h\xE3y chuy\u1EC3n \u0111\u1ECBnh d\u1EA1ng c\u1EE7a "),Es=l(Ft,"CODE",{});var sg=c(Es);qs=a(sg,"english_dataset"),sg.forEach(s),ma=a(Ft," t\u1EEB "),Ts=l(Ft,"CODE",{});var eg=c(Ts);Jn=a(eg,'"pandas"'),eg.forEach(s),ls=a(Ft," tr\u1EDF l\u1EA1i "),Xs=l(Ft,"CODE",{});var ag=c(Xs);Ys=a(ag,'"arrow"'),ag.forEach(s),pa=a(Ft,":"),Ft.forEach(s),je=p(n),y(cs.$$.fragment,n),Cs=p(n),zs=l(n,"P",{});var hg=c(zs);ua=a(hg,"Sau \u0111\xF3, ch\xFAng t\xF4i c\xF3 th\u1EC3 \xE1p d\u1EE5ng ch\u1EE9c n\u0103ng b\u1ED9 l\u1ECDc v\xE0 \u0111\u1EC3 ki\u1EC3m tra m\u1ED9t m\u1EABu \u0111\xE1nh gi\xE1 \u0111\u1EC3 xem ch\xFAng c\xF3 th\u1EF1c s\u1EF1 l\xE0 v\u1EC1 s\xE1ch hay kh\xF4ng:"),hg.forEach(s),Ds=p(n),y(rs.$$.fragment,n),we=p(n),y(Pn.$$.fragment,n),xe=p(n),Hn=l(n,"P",{});var aa=c(Hn);ga=a(aa,"\u0110\u01B0\u1EE3c r\u1ED3i, ch\xFAng ta c\xF3 th\u1EC3 th\u1EA5y r\u1EB1ng c\xE1c b\xE0i \u0111\xE1nh gi\xE1 kh\xF4ng ho\xE0n to\xE0n v\u1EC1 s\xE1ch v\xE0 c\xF3 th\u1EC3 \u0111\u1EC1 c\u1EADp \u0111\u1EBFn nh\u1EEFng th\u1EE9 nh\u01B0 l\u1ECBch v\xE0 c\xE1c \u1EE9ng d\u1EE5ng \u0111i\u1EC7n t\u1EED nh\u01B0 OneNote. Tuy nhi\xEAn, m\u1EA3ng n\xE0y c\xF3 v\u1EBB th\xEDch h\u1EE3p \u0111\u1EC3 hu\u1EA5n luy\u1EC7n m\u1ED9t m\xF4 h\xECnh t\xF3m t\u1EAFt. Tr\u01B0\u1EDBc khi xem x\xE9t c\xE1c m\xF4 h\xECnh kh\xE1c nhau ph\xF9 h\u1EE3p cho t\xE1c v\u1EE5 n\xE0y, ch\xFAng ta c\xF2n m\u1ED9t b\u01B0\u1EDBc chu\u1EA9n b\u1ECB d\u1EEF li\u1EC7u cu\u1ED1i c\xF9ng c\u1EA7n l\xE0m: k\u1EBFt h\u1EE3p c\xE1c b\xE0i \u0111\xE1nh gi\xE1 b\u1EB1ng ti\u1EBFng Anh v\xE0 ti\u1EBFng T\xE2y Ban Nha d\u01B0\u1EDBi d\u1EA1ng m\u1ED9t \u0111\u1ED1i t\u01B0\u1EE3ng "),Qs=l(aa,"CODE",{});var lg=c(Qs);Js=a(lg,"DatasetDict"),lg.forEach(s),da=a(aa," duy nh\u1EA5t. \u{1F917} Datasets cung c\u1EA5p m\u1ED9t h\xE0m "),Zs=l(aa,"CODE",{});var cg=c(Zs);ne=a(cg,"concatenate_datasets()"),cg.forEach(s),fa=a(aa," ti\u1EC7n d\u1EE5ng (nh\u01B0 t\xEAn cho th\u1EA5y) s\u1EBD x\u1EBFp ch\u1ED3ng hai \u0111\u1ED1i t\u01B0\u1EE3ng "),te=l(aa,"CODE",{});var rg=c(te);Ee=a(rg,"Dataset"),rg.forEach(s),Ss=a(aa," l\xEAn tr\xEAn nhau. V\xEC v\u1EADy, \u0111\u1EC3 t\u1EA1o t\u1EADp d\u1EEF li\u1EC7u song ng\u1EEF c\u1EE7a m\xECnh, ch\xFAng ta s\u1EBD l\u1EB7p l\u1EA1i t\u1EEBng ph\u1EA7n d\u1EEF li\u1EC7u, n\u1ED1i c\xE1c t\u1EADp d\u1EEF li\u1EC7u cho ph\u1EA7n \u0111\xF3 v\xE0 x\xE1o tr\u1ED9n k\u1EBFt qu\u1EA3 \u0111\u1EC3 \u0111\u1EA3m b\u1EA3o m\xF4 h\xECnh kh\xF4ng qu\xE1 ph\xF9 h\u1EE3p v\u1EDBi m\u1ED9t ng\xF4n ng\u1EEF duy nh\u1EA5t:"),aa.forEach(s),qe=p(n),y(At.$$.fragment,n),Ot=p(n),y(Pt.$$.fragment,n),Lt=p(n),is=l(n,"P",{});var ig=c(is);Nt=a(ig,"\u0110\xE2y ch\u1EAFc ch\u1EAFn l\xE0 s\u1EF1 k\u1EBFt h\u1EE3p gi\u1EEFa c\xE1c b\xE0i \u0111\xE1nh gi\xE1 b\u1EB1ng ti\u1EBFng Anh v\xE0 ti\u1EBFng T\xE2y Ban Nha! B\xE2y gi\u1EDD ch\xFAng ta \u0111\xE3 c\xF3 m\u1ED9t kho t\xE0i li\u1EC7u hu\u1EA5n luy\u1EC7n, m\u1ED9t \u0111i\u1EC1u cu\u1ED1i c\xF9ng c\u1EA7n ki\u1EC3m tra l\xE0 s\u1EF1 ph\xE2n b\u1ED1 c\xE1c t\u1EEB trong c\xE1c b\xE0i \u0111\xE1nh gi\xE1 v\xE0 ti\xEAu \u0111\u1EC1 c\u1EE7a ch\xFAng. \u0110i\u1EC1u n\xE0y \u0111\u1EB7c bi\u1EC7t quan tr\u1ECDng \u0111\u1ED1i v\u1EDBi c\xE1c t\xE1c v\u1EE5 t\xF3m t\u1EAFt, trong \u0111\xF3 c\xE1c t\xF3m t\u1EAFt tham chi\u1EBFu ng\u1EAFn trong d\u1EEF li\u1EC7u c\xF3 th\u1EC3 l\xE0m sai l\u1EC7ch m\xF4 h\xECnh ch\u1EC9 xu\u1EA5t ra m\u1ED9t ho\u1EB7c hai t\u1EEB trong c\xE1c t\xF3m t\u1EAFt \u0111\xE3 t\u1EA1o. C\xE1c bi\u1EC3u \u0111\u1ED3 b\xEAn d\u01B0\u1EDBi hi\u1EC3n th\u1ECB c\xE1c ph\xE2n b\u1ED1 t\u1EEB v\xE0 ch\xFAng ta c\xF3 th\u1EC3 th\u1EA5y r\u1EB1ng c\xE1c ti\xEAu \u0111\u1EC1 b\u1ECB l\u1EC7ch nhi\u1EC1u v\u1EC1 ch\u1EC9 1-2 t\u1EEB:"),ig.forEach(s),Te=p(n),lt=l(n,"DIV",{class:!0});var Di=c(lt);os=l(Di,"IMG",{class:!0,src:!0,alt:!0}),Ce=p(Di),o=l(Di,"IMG",{class:!0,src:!0,alt:!0}),Di.forEach(s),ba=p(n),ms=l(n,"P",{});var Si=c(ms);jh=a(Si,"\u0110\u1EC3 gi\u1EA3i quy\u1EBFt v\u1EA5n \u0111\u1EC1 n\xE0y, ch\xFAng ta s\u1EBD l\u1ECDc ra c\xE1c v\xED d\u1EE5 c\xF3 ti\xEAu \u0111\u1EC1 r\u1EA5t ng\u1EAFn \u0111\u1EC3 m\xF4 h\xECnh c\xF3 th\u1EC3 t\u1EA1o ra c\xE1c b\u1EA3n t\xF3m t\u1EAFt th\xFA v\u1ECB h\u01A1n. V\xEC ch\xFAng ta \u0111ang x\u1EED l\xFD c\xE1c v\u0103n b\u1EA3n ti\u1EBFng Anh v\xE0 ti\u1EBFng T\xE2y Ban Nha, ch\xFAng ta c\xF3 th\u1EC3 s\u1EED d\u1EE5ng ph\u01B0\u01A1ng ph\xE1p th\xF4 \u0111\u1EC3 ph\xE2n chia c\xE1c ti\xEAu \u0111\u1EC1 theo d\u1EA5u c\xE1ch v\xE0 sau \u0111\xF3 s\u1EED d\u1EE5ng ph\u01B0\u01A1ng ph\xE1p "),Rt=l(Si,"CODE",{});var og=c(Rt);wh=a(og,"Dataset.filter()"),og.forEach(s),xh=a(Si," \u0111\xE1ng tin c\u1EADy c\u1EE7a m\xECnh nh\u01B0 sau:"),Si.forEach(s),se=p(n),y(As.$$.fragment,n),va=p(n),ee=l(n,"P",{});var mg=c(ee);Os=a(mg,"B\xE2y gi\u1EDD ch\xFAng ta \u0111\xE3 chu\u1EA9n b\u1ECB kho t\xE0i li\u1EC7u c\u1EE7a m\xECnh, h\xE3y c\xF9ng xem m\u1ED9t v\xE0i m\u1EABu Transformer kh\u1EA3 thi m\xE0 ng\u01B0\u1EDDi ta c\xF3 th\u1EC3 tinh ch\u1EC9nh n\xF3!"),mg.forEach(s),_a=p(n),Ht=l(n,"H2",{class:!0});var Ai=c(Ht);jt=l(Ai,"A",{id:!0,class:!0,href:!0});var pg=c(jt);ze=l(pg,"SPAN",{});var ug=c(ze);y(Ps.$$.fragment,ug),ug.forEach(s),pg.forEach(s),De=p(Ai),Se=l(Ai,"SPAN",{});var gg=c(Se);Ae=a(gg,"C\xE1c m\xF4 h\xECnh cho t\xF3m t\u1EAFt v\u0103n b\u1EA3n"),gg.forEach(s),Ai.forEach(s),ya=p(n),ps=l(n,"P",{});var Oi=c(ps);Ls=a(Oi,"N\u1EBFu b\u1EA1n ngh\u0129 v\u1EC1 n\xF3, t\xF3m t\u1EAFt v\u0103n b\u1EA3n l\xE0 m\u1ED9t lo\u1EA1i t\xE1c v\u1EE5 t\u01B0\u01A1ng t\u1EF1 nh\u01B0 d\u1ECBch m\xE1y: ch\xFAng ta c\xF3 m\u1ED9t ph\u1EA7n n\u1ED9i dung v\u0103n b\u1EA3n gi\u1ED1ng nh\u01B0 m\u1ED9t b\xE0i \u0111\xE1nh gi\xE1 m\xE0 ta mu\u1ED1n \u201Cd\u1ECBch\u201D th\xE0nh m\u1ED9t phi\xEAn b\u1EA3n ng\u1EAFn h\u01A1n \u0111\u1EC3 n\u1EAFm b\u1EAFt c\xE1c t\xEDnh n\u0103ng n\u1ED5i b\u1EADt c\u1EE7a \u0111\u1EA7u v\xE0o. Theo \u0111\xF3, h\u1EA7u h\u1EBFt c\xE1c m\xF4 h\xECnh Transformer \u0111\u1EC3 t\xF3m t\u1EAFt \u0111\u1EC1u \xE1p d\u1EE5ng ki\u1EBFn tr\xFAc b\u1ED9 m\xE3 h\xF3a-gi\u1EA3i m\xE3 m\xE0 ch\xFAng ta \u0111\xE3 g\u1EB7p l\u1EA7n \u0111\u1EA7u ti\xEAn trong "),ae=l(Oi,"A",{href:!0});var dg=c(ae);Eh=a(dg,"Ch\u01B0\u01A1ng 1"),dg.forEach(s),qh=a(Oi,", m\u1EB7c d\xF9 c\xF3 m\u1ED9t s\u1ED1 ngo\u1EA1i l\u1EC7 nh\u01B0 h\u1ECD m\xF4 h\xECnh GPT c\u0169ng c\xF3 th\u1EC3 \u0111\u01B0\u1EE3c s\u1EED d\u1EE5ng \u0111\u1EC3 t\xF3m t\u1EAFt trong c\xE0i \u0111\u1EB7t few-shot. B\u1EA3ng sau \u0111\xE2y li\u1EC7t k\xEA m\u1ED9t s\u1ED1 m\xF4 h\xECnh \u0111\u01B0\u1EE3c hu\u1EA5n luy\u1EC7n tr\u01B0\u1EDBc ph\u1ED5 bi\u1EBFn c\xF3 th\u1EC3 \u0111\u01B0\u1EE3c tinh ch\u1EC9nh \u0111\u1EC3 t\xF3m t\u1EAFt."),Oi.forEach(s),ka=p(n),us=l(n,"TABLE",{});var Pi=c(us);It=l(Pi,"THEAD",{});var fg=c(It);Gt=l(fg,"TR",{});var jl=c(Gt);he=l(jl,"TH",{align:!0});var bg=c(he);Th=a(bg,"M\xF4 h\xECnh Transformer"),bg.forEach(s),Ch=p(jl),Ns=l(jl,"TH",{});var vg=c(Ns);zh=a(vg,"M\xF4 t\u1EA3"),vg.forEach(s),Oe=p(jl),le=l(jl,"TH",{align:!0});var _g=c(le);Dh=a(_g,"\u0110a ng\xF4n ng\u1EEF?"),_g.forEach(s),jl.forEach(s),fg.forEach(s),Sh=p(Pi),In=l(Pi,"TBODY",{});var Vt=c(In);Gn=l(Vt,"TR",{});var wl=c(Gn);gs=l(wl,"TD",{align:!0});var yg=c(gs);Rs=l(yg,"A",{href:!0,rel:!0});var kg=c(Rs);Ah=a(kg,"GPT-2"),kg.forEach(s),yg.forEach(s),Oh=p(wl),ut=l(wl,"TD",{});var $g=c(ut);Ph=a($g,"M\u1EB7c d\xF9 \u0111\u01B0\u1EE3c hu\u1EA5n luy\u1EC7n nh\u01B0 m\u1ED9t m\xF4 h\xECnh ng\xF4n ng\u1EEF t\u1EF1 h\u1ED3i quy, b\u1EA1n c\xF3 th\u1EC3 d\xF9ng GPT-2 \u0111\u1EC3 t\u1EA1o ra c\xE1c b\u1EA3n t\xF3m t\u1EAFt b\u1EB1ng c\xE1ch n\u1ED1i \u201CTL;DR\u201D cu\u1ED1i m\u1ED7i \u0111o\u1EA1n \u0111\u1EA7u v\xE0o."),$g.forEach(s),Lh=p(wl),ce=l(wl,"TD",{align:!0});var jg=c(ce);Nh=a(jg,"\u274C"),jg.forEach(s),wl.forEach(s),Pe=p(Vt),Mt=l(Vt,"TR",{});var xl=c(Mt);Rh=l(xl,"TD",{align:!0});var wg=c(Rh);$a=l(wg,"A",{href:!0,rel:!0});var xg=c($a);Zi=a(xg,"PEGASUS"),xg.forEach(s),wg.forEach(s),no=p(xl),Pl=l(xl,"TD",{});var Eg=c(Pl);to=a(Eg,"S\u1EED d\u1EE5ng h\xE0m m\u1EE5c ti\xEAu hu\u1EA5n luy\u1EC7n tr\u01B0\u1EDBc \u0111\u1EC3 d\u1EF1 \u0111o\xE1n c\xE1c c\xE2u b\u1ECB \u1EA9n \u0111i trong v\u0103n b\u1EA3n \u0111a c\xE2u. C\u01A1 ch\u1EBF n\xE0y g\u1EA7n v\u1EDBi t\xF3m t\u1EAFt h\u01A1n m\xF4 h\xECnh ng\xF4n ng\u1EEF vanilla v\xE0 \u0111\u1EA1t \u0111i\u1EC3m cao h\u01A1n tr\xEAn c\xE1c chu\u1EA9n ph\u1ED5 bi\u1EBFn."),Eg.forEach(s),so=p(xl),Hh=l(xl,"TD",{align:!0});var qg=c(Hh);eo=a(qg,"\u274C"),qg.forEach(s),xl.forEach(s),ao=p(Vt),re=l(Vt,"TR",{});var El=c(re);Ih=l(El,"TD",{align:!0});var Tg=c(Ih);ja=l(Tg,"A",{href:!0,rel:!0});var Cg=c(ja);ho=a(Cg,"T5"),Cg.forEach(s),Tg.forEach(s),lo=p(El),wa=l(El,"TD",{});var Li=c(wa);co=a(Li,"M\u1ED9t ki\u1EBFn tr\xFAc Transformer ph\u1ED5 qu\xE1t t\u1EA1o ra t\u1EA5t c\u1EA3 c\xE1c t\xE1c v\u1EE5 trong khung v\u0103n b\u1EA3n sang v\u0103n b\u1EA3n; v\xED d\u1EE5,\u0111\u1ECBnh d\u1EA1ng \u0111\u1EA7u v\xE0o cho m\xF4 h\xECnh \u0111\u1EC3 t\xF3m t\u1EAFt t\xE0i li\u1EC7u l\xE0 "),Ll=l(Li,"CODE",{});var zg=c(Ll);ro=a(zg,"summarize: ARTICLE"),zg.forEach(s),io=a(Li,"."),Li.forEach(s),oo=p(El),Gh=l(El,"TD",{align:!0});var Dg=c(Gh);mo=a(Dg,"\u274C"),Dg.forEach(s),El.forEach(s),po=p(Vt),ie=l(Vt,"TR",{});var ql=c(ie);Mh=l(ql,"TD",{align:!0});var Sg=c(Mh);xa=l(Sg,"A",{href:!0,rel:!0});var Ag=c(xa);uo=a(Ag,"mT5"),Ag.forEach(s),Sg.forEach(s),go=p(ql),Nl=l(ql,"TD",{});var Og=c(Nl);fo=a(Og,"M\u1ED9t phi\xEAn b\u1EA3n \u0111a ng\xF4n ng\u1EEF c\u1EE7a T5, \u0111\u01B0\u1EE3c hu\u1EA5n luy\u1EC7n tr\u01B0\u1EDBc tr\xEAn kho ng\u1EEF li\u1EC7u Common Crawl corpus (mC4), bao g\u1ED3m 101 ng\xF4n ng\u1EEF."),Og.forEach(s),bo=p(ql),Uh=l(ql,"TD",{align:!0});var Pg=c(Uh);vo=a(Pg,"\u2705"),Pg.forEach(s),ql.forEach(s),_o=p(Vt),oe=l(Vt,"TR",{});var Tl=c(oe);Bh=l(Tl,"TD",{align:!0});var Lg=c(Bh);Ea=l(Lg,"A",{href:!0,rel:!0});var Ng=c(Ea);yo=a(Ng,"BART"),Ng.forEach(s),Lg.forEach(s),ko=p(Tl),Rl=l(Tl,"TD",{});var Rg=c(Rl);$o=a(Rg,"M\u1ED9t ki\u1EBFn tr\xFAc Transformer m\u1EDBi v\u1EDBi c\u1EA3 b\u1ED9 m\xE3 h\xF3a v\xE0 gi\u1EA3i m\xE3 \u0111\u01B0\u1EE3c hu\u1EA5n luy\u1EC7n \u0111\u1EC3 t\xE1i t\u1EA1o l\u1EA1i \u0111\u1EA7u v\xE0o b\u1ECB ph\xE1, k\u1EBFt h\u1EE3p c\xE1c c\u01A1 ch\u1EBF hu\u1EA5n luy\u1EC7n tr\u01B0\u1EDBc c\u1EE7a BERT v\xE0 GPT-2."),Rg.forEach(s),jo=p(Tl),Fh=l(Tl,"TD",{align:!0});var Hg=c(Fh);wo=a(Hg,"\u274C"),Hg.forEach(s),Tl.forEach(s),xo=p(Vt),me=l(Vt,"TR",{});var Cl=c(me);Vh=l(Cl,"TD",{align:!0});var Ig=c(Vh);qa=l(Ig,"A",{href:!0,rel:!0});var Gg=c(qa);Eo=a(Gg,"mBART-50"),Gg.forEach(s),Ig.forEach(s),qo=p(Cl),Hl=l(Cl,"TD",{});var Mg=c(Hl);To=a(Mg,"Phi\xEAn b\u1EA3n \u0111a ng\xF4n ng\u1EEF c\u1EE7a BART, hu\u1EA5n luy\u1EC7n tr\u01B0\u1EDBc tr\xEAn 50 ng\xF4n ng\u1EEF."),Mg.forEach(s),Co=p(Cl),Kh=l(Cl,"TD",{align:!0});var Ug=c(Kh);zo=a(Ug,"\u2705"),Ug.forEach(s),Cl.forEach(s),Vt.forEach(s),Pi.forEach(s),Xc=p(n),Wh=l(n,"P",{});var Bg=c(Wh);Do=a(Bg,"Nh\u01B0 b\u1EA1n c\xF3 th\u1EC3 th\u1EA5y t\u1EEB b\u1EA3ng n\xE0y, ph\u1EA7n l\u1EDBn c\xE1c m\xF4 h\xECnh Transformer \u0111\u1EC3 t\xF3m t\u1EAFt (v\xE0 th\u1EF1c s\u1EF1 l\xE0 h\u1EA7u h\u1EBFt c\xE1c t\xE1c v\u1EE5 NLP) l\xE0 \u0111\u01A1n ng\u1EEF. \u0110i\u1EC1u n\xE0y th\u1EADt tuy\u1EC7t n\u1EBFu t\xE1c v\u1EE5 c\u1EE7a b\u1EA1n s\u1EED d\u1EE5ng ng\xF4n ng\u1EEF \u201Cnhi\u1EC1u t\xE0i nguy\xEAn\u201D nh\u01B0 ti\u1EBFng Anh ho\u1EB7c ti\u1EBFng \u0110\u1EE9c, nh\u01B0ng b\u1EDBt d\u1EA7n \u0111\u1ED1i v\u1EDBi h\xE0ng ngh\xECn ng\xF4n ng\u1EEF kh\xE1c \u0111ang \u0111\u01B0\u1EE3c s\u1EED d\u1EE5ng tr\xEAn kh\u1EAFp th\u1EBF gi\u1EDBi. May m\u1EAFn thay, c\xF3 m\u1ED9t lo\u1EA1i m\xF4 h\xECnh Transformer \u0111a ng\xF4n ng\u1EEF, nh\u01B0 mT5 v\xE0 mBART, ra \u0111\u1EDDi \u0111\u1EC3 gi\u1EA3i c\u1EE9u ta. Nh\u1EEFng m\xF4 h\xECnh n\xE0y \u0111\u01B0\u1EE3c hu\u1EA5n luy\u1EC7n tr\u01B0\u1EDBc b\u1EB1ng c\xE1ch s\u1EED d\u1EE5ng m\xF4 h\xECnh ng\xF4n ng\u1EEF, nh\u01B0ng c\xF3 m\u1ED9t \u0111i\u1EC3m kh\xE1c bi\u1EC7t: thay v\xEC hu\u1EA5n luy\u1EC7n ng\u1EEF li\u1EC7u c\u1EE7a m\u1ED9t ng\xF4n ng\u1EEF, ch\xFAng \u0111\u01B0\u1EE3c hu\u1EA5n luy\u1EC7n c\xF9ng l\xFAc v\u1EC1 c\xE1c v\u0103n b\u1EA3n b\u1EB1ng h\u01A1n 50 ng\xF4n ng\u1EEF c\xF9ng m\u1ED9t l\xFAc!"),Bg.forEach(s),Yc=p(n),Le=l(n,"P",{});var Ni=c(Le);So=a(Ni,"Ch\xFAng ta s\u1EBD t\u1EADp trung v\xE0o mT5, m\u1ED9t ki\u1EBFn tr\xFAc th\xFA v\u1ECB d\u1EF1a tr\xEAn T5 \u0111\xE3 \u0111\u01B0\u1EE3c hu\u1EA5n luy\u1EC7n tr\u01B0\u1EDBc trong khung v\u0103n b\u1EA3n sang v\u0103n b\u1EA3n. Trong T5, m\u1ECDi t\xE1c v\u1EE5 NLP \u0111\u01B0\u1EE3c x\xE2y d\u1EF1ng d\u01B0\u1EDBi d\u1EA1ng ti\u1EC1n t\u1ED1 nh\u1EAFc nh\u01B0 "),Il=l(Ni,"CODE",{});var Fg=c(Il);Ao=a(Fg,"summarize:"),Fg.forEach(s),Oo=a(Ni," \u0111i\u1EC1u ki\u1EC7n n\xE0o \u0111\u1EC3 m\xF4 h\xECnh \u0111i\u1EC1u ch\u1EC9nh v\u0103n b\u1EA3n \u0111\u01B0\u1EE3c t\u1EA1o th\xE0nh l\u1EDDi nh\u1EAFc. Nh\u01B0 th\u1EC3 hi\u1EC7n trong h\xECnh b\xEAn d\u01B0\u1EDBi, \u0111i\u1EC1u n\xE0y l\xE0m cho T5 tr\u1EDF n\xEAn c\u1EF1c k\u1EF3 linh ho\u1EA1t, v\xEC b\u1EA1n c\xF3 th\u1EC3 gi\u1EA3i quy\u1EBFt nhi\u1EC1u t\xE1c v\u1EE5 ch\u1EC9 v\u1EDBi m\u1ED9t m\xF4 h\xECnh duy nh\u1EA5t!"),Ni.forEach(s),Qc=p(n),pe=l(n,"DIV",{class:!0});var Ri=c(pe);Ta=l(Ri,"IMG",{class:!0,src:!0,alt:!0}),Po=p(Ri),Ca=l(Ri,"IMG",{class:!0,src:!0,alt:!0}),Ri.forEach(s),Jc=p(n),Xh=l(n,"P",{});var Vg=c(Xh);Lo=a(Vg,"mT5 kh\xF4ng s\u1EED d\u1EE5ng ti\u1EC1n t\u1ED1, nh\u01B0ng chia s\u1EBB ph\u1EA7n l\u1EDBn t\xEDnh linh ho\u1EA1t c\u1EE7a T5 v\xE0 c\xF3 l\u1EE3i th\u1EBF l\xE0 \u0111a ng\xF4n ng\u1EEF. Gi\u1EDD ta \u0111\xE3 ch\u1ECDn m\u1ED9t m\xF4 h\xECnh, h\xE3y xem x\xE9t vi\u1EC7c chu\u1EA9n b\u1ECB d\u1EEF li\u1EC7u \u0111\u1EC3 hu\u1EA5n luy\u1EC7n."),Vg.forEach(s),Zc=p(n),y(Ne.$$.fragment,n),nr=p(n),ue=l(n,"H2",{class:!0});var Hi=c(ue);Re=l(Hi,"A",{id:!0,class:!0,href:!0});var Kg=c(Re);Gl=l(Kg,"SPAN",{});var Wg=c(Gl);y(za.$$.fragment,Wg),Wg.forEach(s),Kg.forEach(s),No=p(Hi),Ml=l(Hi,"SPAN",{});var Xg=c(Ml);Ro=a(Xg,"Ti\u1EC1n x\u1EED l\xFD d\u1EEF li\u1EC7u"),Xg.forEach(s),Hi.forEach(s),tr=p(n),y(Da.$$.fragment,n),sr=p(n),He=l(n,"P",{});var Ii=c(He);Ho=a(Ii,"T\xE1c v\u1EE5 ti\u1EBFp theo c\u1EE7a ch\xFAng ta l\xE0 tokenize v\xE0 m\xE3 h\xF3a c\xE1c b\xE0i \u0111\xE1nh gi\xE1 v\xE0 ti\xEAu \u0111\u1EC1 c\u1EE7a ch\xFAng. Nh\u01B0 th\u01B0\u1EDDng l\u1EC7, ta b\u1EAFt \u0111\u1EA7u b\u1EB1ng c\xE1ch t\u1EA3i tokenizer \u0111\u01B0\u1EE3c li\xEAn k\u1EBFt v\u1EDBi checkpoint m\xF4 h\xECnh \u0111\u01B0\u1EE3c hu\u1EA5n luy\u1EC7n tr\u01B0\u1EDBc. Ch\xFAng ta s\u1EBD s\u1EED d\u1EE5ng "),Ul=l(Ii,"CODE",{});var Yg=c(Ul);Io=a(Yg,"mt5-small"),Yg.forEach(s),Go=a(Ii," l\xE0m checkpoint \u0111\u1EC3 c\xF3 th\u1EC3 tinh ch\u1EC9nh m\xF4 h\xECnh trong m\u1ED9t kho\u1EA3ng th\u1EDDi gian h\u1EE3p l\xFD:"),Ii.forEach(s),er=p(n),y(Sa.$$.fragment,n),ar=p(n),y(Ie.$$.fragment,n),hr=p(n),Yh=l(n,"P",{});var Qg=c(Yh);Mo=a(Qg,"H\xE3y th\u1EED nghi\u1EC7m mT5 tokenizer tr\xEAn m\u1ED9t v\xED d\u1EE5 nh\u1ECF:"),Qg.forEach(s),lr=p(n),y(Aa.$$.fragment,n),cr=p(n),y(Oa.$$.fragment,n),rr=p(n),gt=l(n,"P",{});var Us=c(gt);Uo=a(Us,"\u1EDE \u0111\xE2y, ch\xFAng ta c\xF3 th\u1EC3 th\u1EA5y "),Bl=l(Us,"CODE",{});var Jg=c(Bl);Bo=a(Jg,"input_ids"),Jg.forEach(s),Fo=a(Us," v\xE0 "),Fl=l(Us,"CODE",{});var Zg=c(Fl);Vo=a(Zg,"attention_mask"),Zg.forEach(s),Ko=a(Us," m\xE0 ch\xFAng ta \u0111\xE3 g\u1EB7p trong c\xE1c th\u1EED nghi\u1EC7m tinh ch\u1EC9nh \u0111\u1EA7u ti\xEAn c\u1EE7a ch\xFAng ta trong "),Qh=l(Us,"A",{href:!0});var nd=c(Qh);Wo=a(nd,"Ch\u01B0\u01A1ng 3"),nd.forEach(s),Xo=a(Us,". H\xE3y gi\u1EA3i m\xE3 c\xE1c ID \u0111\u1EA7u v\xE0o n\xE0y b\u1EB1ng h\xE0m "),Vl=l(Us,"CODE",{});var td=c(Vl);Yo=a(td,"convert_ids_to_tokens()"),td.forEach(s),Qo=a(Us," c\u1EE7a tokenizer \u0111\u1EC3 xem ch\xFAng ta \u0111ang x\u1EED l\xFD lo\u1EA1i tokenizer n\xE0o:"),Us.forEach(s),ir=p(n),y(Pa.$$.fragment,n),or=p(n),y(La.$$.fragment,n),mr=p(n),Ut=l(n,"P",{});var ha=c(Ut);Jo=a(ha,"K\xFD t\u1EF1 Unicode \u0111\u1EB7c bi\u1EC7t "),Kl=l(ha,"CODE",{});var sd=c(Kl);Zo=a(sd,"\u2581"),sd.forEach(s),nm=a(ha," v\xE0 token cu\u1ED1i chu\u1ED7i "),Wl=l(ha,"CODE",{});var ed=c(Wl);tm=a(ed,"</s>"),ed.forEach(s),sm=a(ha," cho bi\u1EBFt ta \u0111ang x\u1EED l\xFD SentencePiece tokenizer, d\u1EF1a tr\xEAn thu\u1EADt to\xE1n ph\xE2n \u0111o\u1EA1n Unigram \u0111\u01B0\u1EE3c th\u1EA3o lu\u1EADn trong "),Jh=l(ha,"A",{href:!0});var ad=c(Jh);em=a(ad,"Ch\u01B0\u01A1ng 6"),ad.forEach(s),am=a(ha,". Unigram \u0111\u1EB7c bi\u1EC7t h\u1EEFu \xEDch \u0111\u1ED1i v\u1EDBi kho ng\u1EEF li\u1EC7u \u0111a ng\xF4n ng\u1EEF v\xEC n\xF3 cho ph\xE9p SentencePiece b\u1EA5t kh\u1EA3 tri v\u1EC1 d\u1EA5u, d\u1EA5u c\xE2u v\xE0 th\u1EF1c t\u1EBF l\xE0 nhi\u1EC1u ng\xF4n ng\u1EEF, nh\u01B0 ti\u1EBFng Nh\u1EADt, kh\xF4ng c\xF3 k\xFD t\u1EF1 kho\u1EA3ng tr\u1EAFng."),ha.forEach(s),pr=p(n),Ge=l(n,"P",{});var Gi=c(Ge);hm=a(Gi,"\u0110\u1EC3 m\xE3 h\xF3a kho t\xE0i li\u1EC7u c\u1EE7a m\xECnh, ch\xFAng ta ph\u1EA3i x\u1EED l\xFD m\u1ED9t c\xE1ch t\xEDnh t\u1EBF v\u1EDBi t\xF3m t\u1EAFt: b\u1EDFi v\xEC c\xE1c nh\xE3n c\u0169ng l\xE0 v\u0103n b\u1EA3n, c\xF3 th\u1EC3 ch\xFAng v\u01B0\u1EE3t qu\xE1 k\xEDch th\u01B0\u1EDBc ng\u1EEF c\u1EA3nh t\u1ED1i \u0111a c\u1EE7a m\xF4 h\xECnh. \u0110i\u1EC1u n\xE0y c\xF3 ngh\u0129a l\xE0 ch\xFAng ta c\u1EA7n \xE1p d\u1EE5ng vi\u1EC7c c\u1EAFt b\u1EDBt cho c\u1EA3 c\xE1c b\xE0i \u0111\xE1nh gi\xE1 v\xE0 ti\xEAu \u0111\u1EC1 c\u1EE7a ch\xFAng \u0111\u1EC3 \u0111\u1EA3m b\u1EA3o kh\xF4ng truy\u1EC1n c\xE1c \u0111\u1EA7u v\xE0o qu\xE1 d\xE0i cho m\xF4 h\xECnh c\u1EE7a m\xECnh. C\xE1c tokenizer trong \u{1F917} Transformers cung c\u1EA5p m\u1ED9t h\xE0m "),Xl=l(Gi,"CODE",{});var hd=c(Xl);lm=a(hd,"as_target_tokenizer()"),hd.forEach(s),cm=a(Gi," ti\u1EC7n l\u1EE3i cho ph\xE9p b\u1EA1n m\xE3 h\xF3a c\xE1c nh\xE3n song song v\u1EDBi c\xE1c \u0111\u1EA7u v\xE0o. \u0110i\u1EC1u n\xE0y th\u01B0\u1EDDng \u0111\u01B0\u1EE3c th\u1EF1c hi\u1EC7n b\u1EB1ng c\xE1ch s\u1EED d\u1EE5ng tr\xECnh qu\u1EA3n l\xFD ng\u1EEF c\u1EA3nh b\xEAn trong m\u1ED9t ch\u1EE9c n\u0103ng ti\u1EC1n x\u1EED l\xFD, tr\u01B0\u1EDBc ti\xEAn m\xE3 h\xF3a c\xE1c \u0111\u1EA7u v\xE0o, sau \u0111\xF3 m\xE3 h\xF3a c\xE1c nh\xE3n d\u01B0\u1EDBi d\u1EA1ng m\u1ED9t c\u1ED9t ri\xEAng bi\u1EC7t. \u0110\xE2y l\xE0 m\u1ED9t v\xED d\u1EE5 v\u1EC1 m\u1ED9t h\xE0m nh\u01B0 v\u1EADy cho mT5:"),Gi.forEach(s),ur=p(n),y(Na.$$.fragment,n),gr=p(n),dt=l(n,"P",{});var Bs=c(dt);rm=a(Bs,"H\xE3y xem qua \u0111o\u1EA1n m\xE3 n\xE0y \u0111\u1EC3 hi\u1EC3u \u0111i\u1EC1u g\xEC \u0111ang x\u1EA3y ra. \u0110i\u1EC1u \u0111\u1EA7u ti\xEAn ch\xFAng ta \u0111\xE3 l\xE0m l\xE0 x\xE1c \u0111\u1ECBnh c\xE1c gi\xE1 tr\u1ECB cho "),Yl=l(Bs,"CODE",{});var ld=c(Yl);im=a(ld,"max_input_length"),ld.forEach(s),om=a(Bs," v\xE0 "),Ql=l(Bs,"CODE",{});var cd=c(Ql);mm=a(cd,"max_target_length"),cd.forEach(s),pm=a(Bs,", \u0111\u1EB7t gi\u1EDBi h\u1EA1n tr\xEAn cho th\u1EDDi l\u01B0\u1EE3ng c\xE1c b\xE0i \u0111\xE1nh gi\xE1 v\xE0 ti\xEAu \u0111\u1EC1 c\u1EE7a ch\xFAng. V\xEC n\u1ED9i dung \u0111\xE1nh gi\xE1 th\u01B0\u1EDDng l\u1EDBn h\u01A1n nhi\u1EC1u so v\u1EDBi ti\xEAu \u0111\u1EC1, ch\xFAng ta \u0111\xE3 \u0111i\u1EC1u ch\u1EC9nh c\xE1c gi\xE1 tr\u1ECB n\xE0y cho ph\xF9 h\u1EE3p. Sau \u0111\xF3, trong ch\xEDnh "),Jl=l(Bs,"CODE",{});var rd=c(Jl);um=a(rd,"preprocess_function()"),rd.forEach(s),gm=a(Bs,", ch\xFAng ta c\xF3 th\u1EC3 th\u1EA5y c\xE1c b\xE0i \u0111\xE1nh gi\xE1 \u0111\u01B0\u1EE3c tokenize \u0111\u1EA7u ti\xEAn, ti\u1EBFp theo l\xE0 c\xE1c ti\xEAu \u0111\u1EC1 v\u1EDBi "),Zl=l(Bs,"CODE",{});var id=c(Zl);dm=a(id,"as_target_tokenizer()"),id.forEach(s),fm=a(Bs,"."),Bs.forEach(s),dr=p(n),Hs=l(n,"P",{});var zl=c(Hs);bm=a(zl,"V\u1EDBi "),nc=l(zl,"CODE",{});var od=c(nc);vm=a(od,"preprocess_function()"),od.forEach(s),_m=a(zl,", vi\u1EC7c tokenize to\xE0n b\u1ED9 kho d\u1EEF li\u1EC7u b\u1EB1ng h\xE0m "),tc=l(zl,"CODE",{});var md=c(tc);ym=a(md,"Dataset.map()"),md.forEach(s),km=a(zl," ti\u1EC7n d\u1EE5ng m\xE0 ch\xFAng ta \u0111\xE3 s\u1EED d\u1EE5ng r\u1ED9ng r\xE3i trong su\u1ED1t kh\xF3a h\u1ECDc n\xE0y l\xE0 m\u1ED9t v\u1EA5n \u0111\u1EC1 \u0111\u01A1n gi\u1EA3n:"),zl.forEach(s),fr=p(n),y(Ra.$$.fragment,n),br=p(n),Zh=l(n,"P",{});var pd=c(Zh);$m=a(pd,"B\xE2y gi\u1EDD kho d\u1EEF li\u1EC7u \u0111\xE3 \u0111\u01B0\u1EE3c x\u1EED l\xFD tr\u01B0\u1EDBc, ch\xFAng ta h\xE3y xem x\xE9t m\u1ED9t s\u1ED1 ch\u1EC9 s\u1ED1 th\u01B0\u1EDDng \u0111\u01B0\u1EE3c s\u1EED d\u1EE5ng \u0111\u1EC3 t\xF3m t\u1EAFt. Nh\u01B0 ch\xFAng ta s\u1EBD th\u1EA5y, kh\xF4ng c\xF3 gi\u1EA3i ph\xE1p d\u1EC5 d\xE0ng v\xE0 nhanh ch\xF3ng khi n\xF3i \u0111\u1EBFn vi\u1EC7c \u0111o l\u01B0\u1EDDng ch\u1EA5t l\u01B0\u1EE3ng c\u1EE7a v\u0103n b\u1EA3n do m\xE1y t\u1EA1o ra."),pd.forEach(s),vr=p(n),y(Me.$$.fragment,n),_r=p(n),ge=l(n,"H2",{class:!0});var Mi=c(ge);Ue=l(Mi,"A",{id:!0,class:!0,href:!0});var ud=c(Ue);sc=l(ud,"SPAN",{});var gd=c(sc);y(Ha.$$.fragment,gd),gd.forEach(s),ud.forEach(s),jm=p(Mi),ec=l(Mi,"SPAN",{});var dd=c(ec);wm=a(dd,"Th\u01B0\u1EDBc \u0111o cho t\xF3m t\u1EAFt v\u0103n b\u1EA3n"),dd.forEach(s),Mi.forEach(s),yr=p(n),y(Ia.$$.fragment,n),kr=p(n),nl=l(n,"P",{});var fd=c(nl);xm=a(fd,"So v\u1EDBi h\u1EA7u h\u1EBFt c\xE1c t\xE1c v\u1EE5 kh\xE1c m\xE0 ch\xFAng ta \u0111\xE3 \u0111\u1EC1 c\u1EADp trong kh\xF3a h\u1ECDc n\xE0y, vi\u1EC7c \u0111o l\u01B0\u1EDDng hi\u1EC7u su\u1EA5t c\u1EE7a c\xE1c t\xE1c v\u1EE5 t\u1EA1o v\u0103n b\u1EA3n nh\u01B0 t\xF3m t\u1EAFt ho\u1EB7c d\u1ECBch kh\xF4ng \u0111\u01A1n gi\u1EA3n b\u1EB1ng. V\xED d\u1EE5: \u0111\u01B0\u1EE3c \u0111\u01B0a ra m\u1ED9t b\xE0i \u0111\xE1nh gi\xE1 nh\u01B0 \u201CI loved reading the Hunger Games\u201D, c\xF3 nhi\u1EC1u b\u1EA3n t\xF3m t\u1EAFt h\u1EE3p l\u1EC7, ch\u1EB3ng h\u1EA1n nh\u01B0 \u201CI loved the Hunger Games\u201D ho\u1EB7c \u201CHunger Games is a great read\u201D. R\xF5 r\xE0ng, vi\u1EC7c \xE1p d\u1EE5ng m\u1ED9t s\u1ED1 lo\u1EA1i \u0111\u1ED1i s\xE1nh ch\xEDnh x\xE1c n\xE0o \u0111\xF3 gi\u1EEFa b\u1EA3n t\xF3m t\u1EAFt \u0111\u01B0\u1EE3c t\u1EA1o v\xE0 nh\xE3n kh\xF4ng ph\u1EA3i l\xE0 m\u1ED9t gi\u1EA3i ph\xE1p t\u1ED1t - ngay c\u1EA3 con ng\u01B0\u1EDDi c\u0169ng s\u1EBD \u0111\xE1nh gi\xE1 th\u1EA5p h\u01A1n theo m\u1ED9t ch\u1EC9 s\u1ED1 nh\u01B0 v\u1EADy, b\u1EDFi v\xEC t\u1EA5t c\u1EA3 ch\xFAng ta \u0111\u1EC1u c\xF3 phong c\xE1ch vi\u1EBFt ri\xEAng c\u1EE7a m\xECnh."),fd.forEach(s),$r=p(n),Be=l(n,"P",{});var Ui=c(Be);Em=a(Ui,"\u0110\u1EC3 t\xF3m t\u1EAFt, m\u1ED9t trong nh\u1EEFng ch\u1EC9 s\u1ED1 \u0111\u01B0\u1EE3c s\u1EED d\u1EE5ng ph\u1ED5 bi\u1EBFn nh\u1EA5t l\xE0 "),Ga=l(Ui,"A",{href:!0,rel:!0});var bd=c(Ga);qm=a(bd,"\u0111i\u1EC3m ROUGE"),bd.forEach(s),Tm=a(Ui," (vi\u1EBFt t\u1EAFt c\u1EE7a Recall-Oriented Understudy for Gisting Assessment). \xDD t\u01B0\u1EDFng c\u01A1 b\u1EA3n \u0111\u1EB1ng sau th\u01B0\u1EDBc \u0111o n\xE0y l\xE0 so s\xE1nh m\u1ED9t b\u1EA3n t\xF3m t\u1EAFt \u0111\xE3 t\u1EA1o v\u1EDBi m\u1ED9t t\u1EADp h\u1EE3p c\xE1c b\u1EA3n t\xF3m t\u1EAFt tham chi\u1EBFu th\u01B0\u1EDDng do con ng\u01B0\u1EDDi t\u1EA1o ra. \u0110\u1EC3 l\xE0m cho \u0111i\u1EC1u n\xE0y ch\xEDnh x\xE1c h\u01A1n, gi\u1EA3 s\u1EED ch\xFAng ta mu\u1ED1n so s\xE1nh hai b\u1EA3n t\xF3m t\u1EAFt sau:"),Ui.forEach(s),jr=p(n),y(Ma.$$.fragment,n),wr=p(n),Is=l(n,"P",{});var Dl=c(Is);Cm=a(Dl,"M\u1ED9t c\xE1ch \u0111\u1EC3 c\xF3 th\u1EC3 so s\xE1nh ch\xFAng l\xE0 \u0111\u1EBFm s\u1ED1 t\u1EEB tr\xF9ng l\u1EB7p, trong tr\u01B0\u1EDDng h\u1EE3p n\xE0y s\u1EBD l\xE0 6. Tuy nhi\xEAn, \u0111i\u1EC1u n\xE0y h\u01A1i th\xF4, v\xEC v\u1EADy thay v\xE0o \u0111\xF3 ROUGE d\u1EF1a tr\xEAn vi\u1EC7c t\xEDnh to\xE1n \u0111i\u1EC3m s\u1ED1 "),ac=l(Dl,"EM",{});var vd=c(ac);zm=a(vd,"precision"),vd.forEach(s),Dm=a(Dl,"  v\xE0 "),hc=l(Dl,"EM",{});var _d=c(hc);Sm=a(_d,"recall"),_d.forEach(s),Am=a(Dl," cho s\u1EF1 tr\xF9ng l\u1EB7p."),Dl.forEach(s),xr=p(n),y(Fe.$$.fragment,n),Er=p(n),Ua=l(n,"P",{});var xu=c(Ua);Om=a(xu,`\u0110\u1ED1i v\u1EDBi ROUGE, recall \u0111o l\u01B0\u1EDDng m\u1EE9c \u0111\u1ED9 t\xF3m t\u1EAFt tham chi\u1EBFu thu \u0111\u01B0\u1EE3c t\u1EEB c\xE1i \u0111\xE3 t\u1EA1o. N\u1EBFu ch\xFAng ta ch\u1EC9 so s\xE1nh c\xE1c t\u1EEB, recall c\xF3 th\u1EC3 \u0111\u01B0\u1EE3c t\xEDnh theo c\xF4ng th\u1EE9c sau:
`),qr=yf(xu),xu.forEach(s),Tr=p(n),Ba=l(n,"P",{});var Eu=c(Ba);Pm=a(Eu,`\u0110\u1ED1i v\u1EDBi v\xED d\u1EE5 \u0111\u01A1n gi\u1EA3n \u1EDF tr\xEAn, c\xF4ng th\u1EE9c n\xE0y cho ph\xE9p nh\u1EDB ho\xE0n h\u1EA3o l\xE0 6/6 = 1; t\u1EE9c l\xE0 t\u1EA5t c\u1EA3 c\xE1c t\u1EEB trong b\u1EA3n t\xF3m t\u1EAFt tham chi\u1EBFu \u0111\xE3 \u0111\u01B0\u1EE3c t\u1EA1o ra b\u1EDFi m\xF4 h\xECnh. \u0110i\u1EC1u n\xE0y nghe c\xF3 v\u1EBB tuy\u1EC7t v\u1EDDi, nh\u01B0ng h\xE3y t\u01B0\u1EDFng t\u01B0\u1EE3ng n\u1EBFu b\u1EA3n t\xF3m t\u1EAFt \u0111\u01B0\u1EE3c t\u1EA1o c\u1EE7a ch\xFAng ta l\xE0 \u201CI really really loved reading the Hunger Games all night\u201D. \u0110i\u1EC1u n\xE0y c\u0169ng s\u1EBD c\xF3 m\u1ED9t recall ho\xE0n h\u1EA3o, nh\u01B0ng \u0111\u01B0\u1EE3c cho l\xE0 m\u1ED9t b\u1EA3n t\xF3m t\u1EAFt t\u1ED3i t\u1EC7 h\u01A1n v\xEC n\xF3 d\xE0i d\xF2ng. \u0110\u1EC3 \u0111\u1ED1i ph\xF3 v\u1EDBi nh\u1EEFng t\xECnh hu\u1ED1ng n\xE0y, ch\xFAng ta c\u0169ng t\xEDnh to\xE1n \u0111\u1ED9 precision, trong ng\u1EEF c\u1EA3nh ROUGE \u0111o l\u01B0\u1EDDng m\u1EE9c \u0111\u1ED9 li\xEAn quan c\u1EE7a b\u1EA3n t\xF3m t\u1EAFt \u0111\xE3 t\u1EA1o:
`),Cr=yf(Eu),Eu.forEach(s),zr=p(n),Ve=l(n,"P",{});var Bi=c(Ve);Lm=a(Bi,"\xC1p d\u1EE5ng \u0111i\u1EC1u n\xE0y cho b\u1EA3n t\xF3m t\u1EAFt d\xE0i d\xF2ng c\u1EE7a ch\xFAng ta s\u1EBD cho precision l\xE0 6/10 = 0.6, th\u1EA5p h\u01A1n \u0111\xE1ng k\u1EC3 so v\u1EDBi precision 6/7 = 0.86 thu \u0111\u01B0\u1EE3c b\u1EB1ng ph\u01B0\u01A1ng ph\xE1p ng\u1EAFn h\u01A1n c\u1EE7a m\xECnh. Trong th\u1EF1c t\u1EBF, c\u1EA3 precision v\xE0 recall th\u01B0\u1EDDng \u0111\u01B0\u1EE3c t\xEDnh to\xE1n, v\xE0 sau \u0111\xF3 \u0111i\u1EC3m F1 (gi\xE1 tr\u1ECB trung b\xECnh h\xE0i h\xF2a c\u1EE7a precision v\xE0 recall) \u0111\u01B0\u1EE3c b\xE1o c\xE1o. Ch\xFAng ta c\xF3 th\u1EC3 th\u1EF1c hi\u1EC7n vi\u1EC7c n\xE0y d\u1EC5 d\xE0ng trong \u{1F917} Datasets b\u1EB1ng c\xE1ch c\xE0i \u0111\u1EB7t g\xF3i "),lc=l(Bi,"CODE",{});var yd=c(lc);Nm=a(yd,"rouge_score"),yd.forEach(s),Rm=a(Bi," tr\u01B0\u1EDBc:"),Bi.forEach(s),Dr=p(n),y(Fa.$$.fragment,n),Sr=p(n),tl=l(n,"P",{});var kd=c(tl);Hm=a(kd,"v\xE0 sau \u0111\xF3 t\u1EA3i ch\u1EC9 s\u1ED1 ROUGE nh\u01B0 sau:"),kd.forEach(s),Ar=p(n),y(Va.$$.fragment,n),Or=p(n),Ke=l(n,"P",{});var Fi=c(Ke);Im=a(Fi,"Sau \u0111\xF3 ta c\xF3 th\u1EC3 s\u1EED d\u1EE5ng h\xE0m "),cc=l(Fi,"CODE",{});var $d=c(cc);Gm=a($d,"rouge_score.compute()"),$d.forEach(s),Mm=a(Fi," \u0111\u1EC3 t\xEDnh t\u1EA5t c\u1EA3 c\xE1c ch\u1EC9 s\u1ED1 trong m\u1ED9t l\u1EA7n:"),Fi.forEach(s),Pr=p(n),y(Ka.$$.fragment,n),Lr=p(n),y(Wa.$$.fragment,n),Nr=p(n),Zn=l(n,"P",{});var Kt=c(Zn);Um=a(Kt,"Ch\xE0, c\xF3 r\u1EA5t nhi\u1EC1u th\xF4ng tin trong \u0111\u1EA7u ra \u0111\xF3 - t\u1EA5t c\u1EA3 c\xF3 ngh\u0129a l\xE0 g\xEC? \u0110\u1EA7u ti\xEAn, \u{1F917} Datasets th\u1EF1c s\u1EF1 t\xEDnh to\xE1n kho\u1EA3ng tin c\u1EADy cho precision, recall v\xE0 F1 score; \u0111\xE2y l\xE0 c\xE1c thu\u1ED9c t\xEDnh "),rc=l(Kt,"CODE",{});var jd=c(rc);Bm=a(jd,"low"),jd.forEach(s),Fm=a(Kt,", "),ic=l(Kt,"CODE",{});var wd=c(ic);Vm=a(wd,"mid"),wd.forEach(s),Km=a(Kt," v\xE0 "),oc=l(Kt,"CODE",{});var xd=c(oc);Wm=a(xd,"high"),xd.forEach(s),Xm=a(Kt," m\xE0 b\u1EA1n c\xF3 th\u1EC3 xem \u1EDF \u0111\xE2y. H\u01A1n n\u1EEFa, \u{1F917} Datasets t\xEDnh to\xE1n nhi\u1EC1u \u0111i\u1EC3m ROUGE kh\xE1c nhau d\u1EF1a tr\xEAn c\xE1c lo\u1EA1i v\u0103n b\u1EA3n chi ti\u1EBFt kh\xE1c nhau khi so s\xE1nh c\xE1c t\xF3m t\u1EAFt \u0111\xE3 t\u1EA1o v\xE0 tham chi\u1EBFu. Bi\u1EBFn th\u1EC3 "),mc=l(Kt,"CODE",{});var Ed=c(mc);Ym=a(Ed,"rouge1"),Ed.forEach(s),Qm=a(Kt," l\xE0 s\u1EF1 ch\u1ED3ng ch\xE9o c\u1EE7a c\xE1c kh\u1ED1i \u0111\u01A1n - \u0111\xE2y ch\u1EC9 l\xE0 m\u1ED9t c\xE1ch n\xF3i hoa m\u1EF9 \u0111\u1EC3 n\xF3i v\u1EC1 s\u1EF1 ch\u1ED3ng ch\xE9o c\u1EE7a c\xE1c t\u1EEB v\xE0 ch\xEDnh x\xE1c l\xE0 s\u1ED1 li\u1EC7u m\xE0 ch\xFAng ta \u0111\xE3 th\u1EA3o lu\u1EADn \u1EDF tr\xEAn. \u0110\u1EC3 x\xE1c minh \u0111i\u1EC1u n\xE0y, ch\xFAng ta h\xE3y l\u1EA5y ra gi\xE1 tr\u1ECB "),pc=l(Kt,"CODE",{});var qd=c(pc);Jm=a(qd,"mid"),qd.forEach(s),Zm=a(Kt," \u0111i\u1EC3m s\u1ED1 c\u1EE7a m\xECnh:"),Kt.forEach(s),Rr=p(n),y(Xa.$$.fragment,n),Hr=p(n),y(Ya.$$.fragment,n),Ir=p(n),nt=l(n,"P",{});var Wt=c(nt);np=a(Wt,"Tuy\u1EC7t v\u1EDDi, precision v\xE0 recall l\u1EA1i kh\u1EDBp v\u1EDBi nhau! C\xF2n nh\u1EEFng \u0111i\u1EC3m ROUGE kh\xE1c th\xEC sao? "),uc=l(Wt,"CODE",{});var Td=c(uc);tp=a(Td,"rouge2"),Td.forEach(s),sp=a(Wt," \u0111o l\u01B0\u1EDDng s\u1EF1 tr\xF9ng l\u1EB7p gi\u1EEFa c\xE1c bigram (h\xE3y ngh\u0129 r\u1EB1ng \u0111\xF3 l\xE0 s\u1EF1 ch\u1ED3ng ch\xE9o c\u1EE7a c\xE1c c\u1EB7p t\u1EEB), trong khi "),gc=l(Wt,"CODE",{});var Cd=c(gc);ep=a(Cd,"rougeL"),Cd.forEach(s),ap=a(Wt," v\xE0 "),dc=l(Wt,"CODE",{});var zd=c(dc);hp=a(zd,"rougeLsum"),zd.forEach(s),lp=a(Wt," \u0111o l\u01B0\u1EDDng c\xE1c chu\u1ED7i t\u1EEB ph\xF9 h\u1EE3p d\xE0i nh\u1EA5t b\u1EB1ng c\xE1ch t\xECm ki\u1EBFm c\xE1c chu\u1ED7i con chung d\xE0i nh\u1EA5t trong c\xE1c b\u1EA3n t\xF3m t\u1EAFt \u0111\u01B0\u1EE3c t\u1EA1o v\xE0 tham chi\u1EBFu. \u201Csum\u201D trong "),fc=l(Wt,"CODE",{});var Dd=c(fc);cp=a(Dd,"rougeLsum"),Dd.forEach(s),rp=a(Wt," \u0111\u1EC1 c\u1EADp \u0111\u1EBFn th\u1EF1c t\u1EBF l\xE0 ch\u1EC9 s\u1ED1 n\xE0y \u0111\u01B0\u1EE3c t\xEDnh tr\xEAn to\xE0n b\u1ED9 b\u1EA3n t\xF3m t\u1EAFt, trong khi "),bc=l(Wt,"CODE",{});var Sd=c(bc);ip=a(Sd,"rougeL"),Sd.forEach(s),op=a(Wt," \u0111\u01B0\u1EE3c t\xEDnh l\xE0 gi\xE1 tr\u1ECB trung b\xECnh tr\xEAn c\xE1c c\xE2u ri\xEAng l\u1EBB."),Wt.forEach(s),Gr=p(n),y(We.$$.fragment,n),Mr=p(n),sl=l(n,"P",{});var Ad=c(sl);mp=a(Ad,"Ch\xFAng t\xF4i s\u1EBD s\u1EED d\u1EE5ng c\xE1c \u0111i\u1EC3m ROUGE n\xE0y \u0111\u1EC3 theo d\xF5i hi\u1EC7u su\u1EA5t c\u1EE7a m\xF4 h\xECnh, nh\u01B0ng tr\u01B0\u1EDBc khi l\xE0m \u0111i\u1EC1u \u0111\xF3, h\xE3y l\xE0m \u0111i\u1EC1u m\xE0 m\u1ECDi ng\u01B0\u1EDDi th\u1EF1c h\xE0nh NLP gi\u1ECFi n\xEAn l\xE0m: t\u1EA1o m\u1ED9t \u0111\u01B0\u1EDDng c\u01A1 s\u1EDF m\u1EA1nh m\u1EBD nh\u01B0ng \u0111\u01A1n gi\u1EA3n!"),Ad.forEach(s),Ur=p(n),de=l(n,"H3",{class:!0});var Vi=c(de);Xe=l(Vi,"A",{id:!0,class:!0,href:!0});var Od=c(Xe);vc=l(Od,"SPAN",{});var Pd=c(vc);y(Qa.$$.fragment,Pd),Pd.forEach(s),Od.forEach(s),pp=p(Vi),_c=l(Vi,"SPAN",{});var Ld=c(_c);up=a(Ld,"T\u1EA1o m\u1ED9t \u0111\u01B0\u1EDDng c\u01A1 s\u1EDF m\u1EA1nh m\u1EBD"),Ld.forEach(s),Vi.forEach(s),Br=p(n),ft=l(n,"P",{});var Fs=c(ft);gp=a(Fs,"M\xF4t m\xF4 h\xECnh c\u01A1 s\u1EDF cho t\xF3m t\u1EAFt v\u0103n b\u1EA3n, \u0111\xF3 l\xE0 ch\u1EC9 c\u1EA7n l\u1EA5y ba c\xE2u \u0111\u1EA7u ti\xEAn c\u1EE7a m\u1ED9t b\xE0i b\xE1o, th\u01B0\u1EDDng \u0111\u01B0\u1EE3c g\u1ECDi l\xE0 "),yc=l(Fs,"EM",{});var Nd=c(yc);dp=a(Nd,"lead-3"),Nd.forEach(s),fp=a(Fs," hay "),kc=l(Fs,"EM",{});var Rd=c(kc);bp=a(Rd,"3 b\xE0i \u0111\u1EA7u"),Rd.forEach(s),vp=a(Fs,". Ch\xFAng ta c\xF3 th\u1EC3 s\u1EED d\u1EE5ng c\xE1c d\u1EA5u ch\u1EA5m \u0111\u1EC3 theo d\xF5i ranh gi\u1EDBi c\xE2u, nh\u01B0ng \u0111i\u1EC1u n\xE0y s\u1EBD kh\xF4ng th\xE0nh c\xF4ng \u0111\u1ED1i v\u1EDBi c\xE1c t\u1EEB vi\u1EBFt t\u1EAFt nh\u01B0 \u201CU.S.\u201D ho\u1EB7c \u201CU.N.\u201D - v\xEC v\u1EADy thay v\xE0o \u0111\xF3, ch\xFAng ta s\u1EBD s\u1EED d\u1EE5ng th\u01B0 vi\u1EC7n "),$c=l(Fs,"CODE",{});var Hd=c($c);_p=a(Hd,"nltk"),Hd.forEach(s),yp=a(Fs,", bao g\u1ED3m m\u1ED9t thu\u1EADt to\xE1n t\u1ED1t h\u01A1n \u0111\u1EC3 x\u1EED l\xFD nh\u1EEFng tr\u01B0\u1EDDng h\u1EE3p n\xE0y. B\u1EA1n c\xF3 th\u1EC3 c\xE0i \u0111\u1EB7t g\xF3i b\u1EB1ng c\xE1ch s\u1EED d\u1EE5ng "),jc=l(Fs,"CODE",{});var Id=c(jc);kp=a(Id,"pip"),Id.forEach(s),$p=a(Fs," nh\u01B0 sau:"),Fs.forEach(s),Fr=p(n),y(Ja.$$.fragment,n),Vr=p(n),el=l(n,"P",{});var Gd=c(el);jp=a(Gd,"v\xE0 sau \u0111\xF3 t\u1EA3i c\xE1c quy t\u1EAFc d\u1EA5u c\xE2u:"),Gd.forEach(s),Kr=p(n),y(Za.$$.fragment,n),Wr=p(n),Ye=l(n,"P",{});var Ki=c(Ye);wp=a(Ki,"Ti\u1EBFp theo, ch\xFAng ta nh\u1EADp tokenizer c\xE2u t\u1EEB "),wc=l(Ki,"CODE",{});var Md=c(wc);xp=a(Md,"nltk"),Md.forEach(s),Ep=a(Ki," v\xE0 t\u1EA1o m\u1ED9t h\xE0m \u0111\u01A1n gi\u1EA3n \u0111\u1EC3 tr\xEDch xu\u1EA5t ba c\xE2u \u0111\u1EA7u ti\xEAn trong m\u1ED9t b\xE0i \u0111\xE1nh gi\xE1. Quy \u01B0\u1EDBc trong ph\u1EA7n t\xF3m t\u1EAFt v\u0103n b\u1EA3n l\xE0 t\xE1ch t\u1EEBng ph\u1EA7n t\xF3m t\u1EAFt b\u1EB1ng m\u1ED9t d\xF2ng m\u1EDBi, v\xEC v\u1EADy h\xE3y bao g\u1ED3m ph\u1EA7n n\xE0y v\xE0 ki\u1EC3m tra n\xF3 tr\xEAn m\u1ED9t v\xED d\u1EE5 hu\u1EA5n luy\u1EC7n:"),Ki.forEach(s),Xr=p(n),y(nh.$$.fragment,n),Yr=p(n),y(th.$$.fragment,n),Qr=p(n),al=l(n,"P",{});var Ud=c(al);qp=a(Ud,"\u0110i\u1EC1u n\xE0y c\xF3 v\u1EBB hi\u1EC7u qu\u1EA3, v\xEC v\u1EADy b\xE2y gi\u1EDD ch\xFAng ta h\xE3y tri\u1EC3n khai m\u1ED9t h\xE0m tr\xEDch xu\u1EA5t c\xE1c \u201Ct\xF3m t\u1EAFt\u201D n\xE0y t\u1EEB t\u1EADp d\u1EEF li\u1EC7u v\xE0 t\xEDnh to\xE1n \u0111i\u1EC3m ROUGE cho m\xF4 h\xECnh c\u01A1 s\u1EDF:"),Ud.forEach(s),Jr=p(n),y(sh.$$.fragment,n),Zr=p(n),hl=l(n,"P",{});var Bd=c(hl);Tp=a(Bd,"Sau \u0111\xF3, ch\xFAng ta c\xF3 th\u1EC3 s\u1EED d\u1EE5ng h\xE0m n\xE0y \u0111\u1EC3 t\xEDnh to\xE1n \u0111i\u1EC3m ROUGE tr\xEAn t\u1EADp ki\u1EC3m \u0111\u1ECBnh v\xE0 ki\u1EC3m tra ch\xFAng m\u1ED9t ch\xFAt b\u1EB1ng c\xE1ch s\u1EED d\u1EE5ng Pandas:"),Bd.forEach(s),ni=p(n),y(eh.$$.fragment,n),ti=p(n),y(ah.$$.fragment,n),si=p(n),Qe=l(n,"P",{});var Wi=c(Qe);Cp=a(Wi,"Ch\xFAng ta c\xF3 th\u1EC3 th\u1EA5y r\u1EB1ng \u0111i\u1EC3m "),xc=l(Wi,"CODE",{});var Fd=c(xc);zp=a(Fd,"rouge2"),Fd.forEach(s),Dp=a(Wi," th\u1EA5p h\u01A1n \u0111\xE1ng k\u1EC3 so v\u1EDBi ph\u1EA7n c\xF2n l\u1EA1i; \u0111i\u1EC1u n\xE0y c\xF3 th\u1EC3 ph\u1EA3n \xE1nh th\u1EF1c t\u1EBF l\xE0 ti\xEAu \u0111\u1EC1 b\xE0i \u0111\xE1nh gi\xE1 th\u01B0\u1EDDng ng\u1EAFn g\u1ECDn v\xE0 do \u0111\xF3, m\xF4 h\xECnh c\u01A1 s\u1EDF c\u1EE7a 3 b\xE0i \u0111\u1EA7u qu\xE1 d\xE0i d\xF2ng. B\xE2y gi\u1EDD ch\xFAng ta \u0111\xE3 c\xF3 m\u1ED9t c\u01A1 s\u1EDF t\u1ED1t \u0111\u1EC3 l\xE0m vi\u1EC7c, h\xE3y chuy\u1EC3n s\u1EF1 ch\xFA \xFD c\u1EE7a ch\xFAng ta sang vi\u1EC7c tinh ch\u1EC9nh mT5!"),Wi.forEach(s),ei=p(n),fs.l(n),ll=p(n),y(Je.$$.fragment,n),ai=p(n),cl=l(n,"P",{});var Vd=c(cl);Sp=a(Vd,"\u0110i\u1EC1u ti\u1EBFp theo ch\xFAng ta c\u1EA7n l\xE0m l\xE0 \u0111\u0103ng nh\u1EADp v\xE0o Hugging Face Hub. N\u1EBFu b\u1EA1n \u0111ang ch\u1EA1y \u0111o\u1EA1n m\xE3 n\xE0y trong notebook, b\u1EA1n c\xF3 th\u1EC3 l\xE0m nh\u01B0 v\u1EADy v\u1EDBi h\xE0m ti\u1EC7n \xEDch sau:"),Vd.forEach(s),hi=p(n),y(hh.$$.fragment,n),li=p(n),rl=l(n,"P",{});var Kd=c(rl);Ap=a(Kd,"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 c\u1EE7a m\xECnh. Ngo\xE0i ra, b\u1EA1n c\xF3 th\u1EC3 ch\u1EA1y l\u1EC7nh n\xE0y trong thi\u1EBFt b\u1ECB \u0111\u1EA7u cu\u1ED1i c\u1EE7a m\xECnh v\xE0 \u0111\u0103ng nh\u1EADp v\xE0o \u0111\xF3:"),Kd.forEach(s),ci=p(n),y(lh.$$.fragment,n),ri=p(n),Ln&&Ln.l(n),il=p(n),Ze=l(n,"P",{});var Xi=c(Ze);Op=a(Xi,"Ti\u1EBFp theo, ch\xFAng ta c\u1EA7n ph\u1EA3i x\xE1c \u0111\u1ECBnh m\u1ED9t b\u1ED9 \u0111\u1ED1i chi\u1EBFu d\u1EEF li\u1EC7u cho t\xE1c v\u1EE5 chu\u1ED7i sang chu\u1ED7i c\u1EE7a ch\xFAng ta. V\xEC mT5 l\xE0 m\xF4 h\xECnh Transformer b\u1ED9 m\xE3 h\xF3a-gi\u1EA3i m\xE3, m\u1ED9t \u0111i\u1EC1u tinh t\u1EBF khi chu\u1EA9n b\u1ECB c\xE1c l\xF4 l\xE0 trong qu\xE1 tr\xECnh gi\u1EA3i m\xE3, ch\xFAng ta c\u1EA7n chuy\u1EC3n c\xE1c nh\xE3n sang ph\u1EA3i t\u1EEBng nh\xE3n. \u0110i\u1EC1u n\xE0y l\xE0 b\u1EAFt bu\u1ED9c \u0111\u1EC3 \u0111\u1EA3m b\u1EA3o r\u1EB1ng b\u1ED9 gi\u1EA3i m\xE3 ch\u1EC9 nh\xECn th\u1EA5y c\xE1c nh\xE3n tr\u01B0\u1EDBc \u0111\xF3 ch\u1EE9 kh\xF4ng ph\u1EA3i nh\xE3n hi\u1EC7n t\u1EA1i ho\u1EB7c t\u01B0\u01A1ng lai, \u0111i\u1EC1u n\xE0y s\u1EBD gi\xFAp m\xF4 h\xECnh d\u1EC5 d\xE0ng ghi nh\u1EDB. \u0110i\u1EC1u n\xE0y t\u01B0\u01A1ng t\u1EF1 nh\u01B0 c\xE1ch \xE1p d\u1EE5ng masked self-attention cho c\xE1c \u0111\u1EA7u v\xE0o trong m\u1ED9t t\xE1c v\u1EE5 nh\u01B0 "),ol=l(Xi,"A",{href:!0});var Wd=c(ol);Pp=a(Wd,"m\xF4 h\xECnh ng\xF4n ng\u1EEF nh\xE2n qu\u1EA3"),Wd.forEach(s),Lp=a(Xi,"."),Xi.forEach(s),ii=p(n),Bt=l(n,"P",{});var la=c(Bt);Np=a(la,"May m\u1EAFn thay, \u{1F917} Transformers cung c\u1EA5p m\u1ED9t b\u1ED9 \u0111\u1ED1i chi\u1EBFu "),Ec=l(la,"CODE",{});var Xd=c(Ec);Rp=a(Xd,"DataCollatorForSeq2Seq"),Xd.forEach(s),Hp=a(la," s\u1EBD t\u1EF1 \u0111\u1ED9ng \u0111\u1EC7m c\xE1c \u0111\u1EA7u v\xE0o v\xE0 nh\xE3n cho ch\xFAng ta. \u0110\u1EC3 kh\u1EDFi t\u1EA1o b\u1ED9 \u0111\u1ED1i chi\u1EBFu n\xE0y, ch\xFAng ta ch\u1EC9 c\u1EA7n cung c\u1EA5p "),qc=l(la,"CODE",{});var Yd=c(qc);Ip=a(Yd,"tokenizer"),Yd.forEach(s),Gp=a(la," v\xE0 "),Tc=l(la,"CODE",{});var Qd=c(Tc);Mp=a(Qd,"model"),Qd.forEach(s),Up=a(la,":"),la.forEach(s),oi=p(n),vs.l(n),ml=p(n),pl=l(n,"P",{});var Jd=c(pl);Bp=a(Jd,"H\xE3y xem nh\u1EEFng g\xEC m\xE0 m\xE1y \u0111\u1ED1i chi\u1EBFu n\xE0y t\u1EA1o ra khi \u0111\u01B0\u1EE3c cung c\u1EA5p m\u1ED9t lo\u1EA1t c\xE1c v\xED d\u1EE5 nh\u1ECF. \u0110\u1EA7u ti\xEAn, ch\xFAng ta c\u1EA7n x\xF3a c\xE1c c\u1ED9t c\xF3 chu\u1ED7i v\xEC tr\xECnh \u0111\u1ED1i chi\u1EBFu s\u1EBD kh\xF4ng bi\u1EBFt c\xE1ch ch\xE8n c\xE1c ph\u1EA7n t\u1EED n\xE0y:"),Jd.forEach(s),mi=p(n),y(ch.$$.fragment,n),pi=p(n),Gs=l(n,"P",{});var Sl=c(Gs);Fp=a(Sl,"V\xEC b\u1ED9 \u0111\u1ED1i chi\u1EBFu mong \u0111\u1EE3i m\u1ED9t danh s\xE1ch c\xE1c "),Cc=l(Sl,"CODE",{});var Zd=c(Cc);Vp=a(Zd,"dict"),Zd.forEach(s),Kp=a(Sl,", trong \u0111\xF3 m\u1ED7i "),zc=l(Sl,"CODE",{});var nf=c(zc);Wp=a(nf,"dict"),nf.forEach(s),Xp=a(Sl," \u0111\u1EA1i di\u1EC7n cho m\u1ED9t v\xED d\u1EE5 duy nh\u1EA5t trong t\u1EADp d\u1EEF li\u1EC7u, ch\xFAng ta c\u0169ng c\u1EA7n cu\u1ED9n d\u1EEF li\u1EC7u th\xE0nh \u0111\u1ECBnh d\u1EA1ng mong \u0111\u1EE3i tr\u01B0\u1EDBc khi chuy\u1EC3n n\xF3 \u0111\u1EBFn b\u1ED9 \u0111\u1ED1i chi\u1EBFu d\u1EEF li\u1EC7u:"),Sl.forEach(s),ui=p(n),y(rh.$$.fragment,n),gi=p(n),y(ih.$$.fragment,n),di=p(n),En=l(n,"P",{});var Mn=c(En);Yp=a(Mn,"\u0110i\u1EC1u ch\xEDnh c\u1EA7n ch\xFA \xFD \u1EDF \u0111\xE2y l\xE0 m\u1EABu \u0111\u1EA7u ti\xEAn d\xE0i h\u01A1n th\u1EE9 hai, do \u0111\xF3, "),Dc=l(Mn,"CODE",{});var tf=c(Dc);Qp=a(tf,"input_ids"),tf.forEach(s),Jp=a(Mn," v\xE0 "),Sc=l(Mn,"CODE",{});var sf=c(Sc);Zp=a(sf,"attention_mask"),sf.forEach(s),nu=a(Mn," c\u1EE7a m\u1EABu th\u1EE9 hai \u0111\xE3 \u0111\u01B0\u1EE3c \u0111\u1EC7m \u1EDF b\xEAn ph\u1EA3i b\u1EB1ng "),Ac=l(Mn,"CODE",{});var ef=c(Ac);tu=a(ef,"[PAD]"),ef.forEach(s),su=a(Mn," (c\xF3 ID l\xE0 "),Oc=l(Mn,"CODE",{});var af=c(Oc);eu=a(af,"0"),af.forEach(s),au=a(Mn,"). T\u01B0\u01A1ng t\u1EF1, ch\xFAng ta c\xF3 th\u1EC3 th\u1EA5y r\u1EB1ng "),Pc=l(Mn,"CODE",{});var hf=c(Pc);hu=a(hf,"labels"),hf.forEach(s),lu=a(Mn," \u0111\xE3 \u0111\u01B0\u1EE3c \u0111\u1EC7m b\u1EB1ng "),Lc=l(Mn,"CODE",{});var lf=c(Lc);cu=a(lf,"-100"),lf.forEach(s),ru=a(Mn,", \u0111\u1EC3 \u0111\u1EA3m b\u1EA3o r\u1EB1ng c\xE1c token \u0111\u1EC7m \u0111\u01B0\u1EE3c b\u1ECF qua b\u1EDFi h\xE0m m\u1EA5t m\xE1t. V\xE0 cu\u1ED1i c\xF9ng, ch\xFAng ta c\xF3 th\u1EC3 th\u1EA5y m\u1ED9t "),Nc=l(Mn,"CODE",{});var cf=c(Nc);iu=a(cf,"decoder_input_ids"),cf.forEach(s),ou=a(Mn," m\u1EDBi \u0111\xE3 chuy\u1EC3n c\xE1c nh\xE3n sang b\xEAn ph\u1EA3i b\u1EB1ng c\xE1ch ch\xE8n "),Rc=l(Mn,"CODE",{});var rf=c(Rc);mu=a(rf,"[PAD]"),rf.forEach(s),pu=a(Mn," v\xE0o m\u1EE5c nh\u1EADp \u0111\u1EA7u ti\xEAn."),Mn.forEach(s),fi=p(n),ys.l(n),ul=p(n),Nn&&Nn.l(n),gl=p(n),fe=l(n,"H2",{class:!0});var Yi=c(fe);na=l(Yi,"A",{id:!0,class:!0,href:!0});var of=c(na);Hc=l(of,"SPAN",{});var mf=c(Hc);y(oh.$$.fragment,mf),mf.forEach(s),of.forEach(s),uu=p(Yi),Ic=l(Yi,"SPAN",{});var pf=c(Ic);gu=a(pf,"S\u1EED d\u1EE5ng m\xF4 h\xECnh tinh ch\u1EC9nh c\u1EE7a b\u1EA1n"),pf.forEach(s),Yi.forEach(s),bi=p(n),ta=l(n,"P",{});var Qi=c(ta);du=a(Qi,"Khi b\u1EA1n \u0111\xE3 \u0111\u1EA9y m\xF4 h\xECnh v\xE0o Hub, b\u1EA1n c\xF3 th\u1EC3 ch\u01A1i v\u1EDBi n\xF3 th\xF4ng qua ti\u1EC7n \xEDch lu\u1EADn suy ho\u1EB7c v\u1EDBi \u0111\u1ED1i t\u01B0\u1EE3ng "),Gc=l(Qi,"CODE",{});var uf=c(Gc);fu=a(uf,"pipeline"),uf.forEach(s),bu=a(Qi,", nh\u01B0 sau:"),Qi.forEach(s),vi=p(n),y(mh.$$.fragment,n),_i=p(n),dl=l(n,"P",{});var gf=c(dl);vu=a(gf,"Ch\xFAng ta c\xF3 th\u1EC3 cung c\u1EA5p m\u1ED9t s\u1ED1 m\u1EABu t\u1EEB b\u1ED9 ki\u1EC3m th\u1EED (m\xE0 m\xF4 h\xECnh ch\u01B0a th\u1EA5y) v\xE0o pipeline \u0111\u1EC3 c\xF3 c\u1EA3m nh\u1EADn v\u1EC1 ch\u1EA5t l\u01B0\u1EE3ng c\u1EE7a c\xE1c b\u1EA3n t\xF3m t\u1EAFt. Tr\u01B0\u1EDBc ti\xEAn, h\xE3y tri\u1EC3n khai m\u1ED9t ch\u1EE9c n\u0103ng \u0111\u01A1n gi\u1EA3n \u0111\u1EC3 hi\u1EC3n th\u1ECB b\xE0i \u0111\xE1nh gi\xE1, ti\xEAu \u0111\u1EC1 v\xE0 b\u1EA3n t\xF3m t\u1EAFt \u0111\xE3 t\u1EA1o c\xF9ng nhau:"),gf.forEach(s),yi=p(n),y(ph.$$.fragment,n),ki=p(n),fl=l(n,"P",{});var df=c(fl);_u=a(df,"H\xE3y xem m\u1ED9t trong nh\u1EEFng m\u1EABu ti\u1EBFng Anh m\xE0 ch\xFAng ta nh\u1EADn \u0111\u01B0\u1EE3c:"),df.forEach(s),$i=p(n),y(uh.$$.fragment,n),ji=p(n),y(gh.$$.fragment,n),wi=p(n),sa=l(n,"P",{});var Ji=c(sa);yu=a(Ji,"\u0110i\u1EC1u n\xE0y kh\xF4ng qu\xE1 t\u1EC7! Ch\xFAng ta c\xF3 th\u1EC3 th\u1EA5y r\u1EB1ng m\xF4 h\xECnh c\u1EE7a m\xECnh \u0111\xE3 th\u1EF1c s\u1EF1 c\xF3 th\u1EC3 th\u1EF1c hi\u1EC7n t\xF3m t\u1EAFt "),Mc=l(Ji,"EM",{});var ff=c(Mc);ku=a(ff,"tr\u1EEBu t\u01B0\u1EE3ng"),ff.forEach(s),$u=a(Ji," b\u1EB1ng c\xE1ch t\u0103ng c\u01B0\u1EDDng c\xE1c ph\u1EA7n c\u1EE7a b\xE0i \u0111\xE1nh gi\xE1 b\u1EB1ng c\xE1c t\u1EEB m\u1EDBi. V\xE0 c\xF3 l\u1EBD kh\xEDa c\u1EA1nh th\xFA v\u1ECB nh\u1EA5t c\u1EE7a m\xF4 h\xECnh c\u1EE7a ch\xFAng ta l\xE0 n\xF3 \u0111\u01B0\u1EE3c s\u1EED d\u1EE5ng song ng\u1EEF, v\xEC v\u1EADy ta c\u0169ng c\xF3 th\u1EC3 t\u1EA1o t\xF3m t\u1EAFt c\xE1c b\xE0i \u0111\xE1nh gi\xE1 b\u1EB1ng ti\u1EBFng T\xE2y Ban Nha:"),Ji.forEach(s),xi=p(n),y(dh.$$.fragment,n),Ei=p(n),y(fh.$$.fragment,n),qi=p(n),bl=l(n,"P",{});var bf=c(bl);ju=a(bf,"B\u1EA3n t\xF3m t\u1EAFt \u0111\u01B0\u1EE3c d\u1ECBch th\xE0nh \u201CVery easy to read\u201D trong ti\u1EBFng Anh, m\xE0 ch\xFAng ta c\xF3 th\u1EC3 th\u1EA5y trong tr\u01B0\u1EDDng h\u1EE3p n\xE0y \u0111\u01B0\u1EE3c tr\xEDch tr\u1EF1c ti\u1EBFp t\u1EEB \u0111\xE1nh gi\xE1. Tuy nhi\xEAn, \u0111i\u1EC1u n\xE0y cho th\u1EA5y t\xEDnh linh ho\u1EA1t c\u1EE7a m\xF4 h\xECnh mT5 v\xE0 cho b\u1EA1n bi\u1EBFt c\u1EA3m gi\xE1c tri\u1EC3n khai v\u1EDBi kho ng\u1EEF li\u1EC7u \u0111a ng\xF4n ng\u1EEF l\xE0 nh\u01B0 th\u1EBF n\xE0o!"),bf.forEach(s),Ti=p(n),vl=l(n,"P",{});var vf=c(vl);wu=a(vf,"Ti\u1EBFp theo, ch\xFAng ta s\u1EBD chuy\u1EC3n s\u1EF1 ch\xFA \xFD sang m\u1ED9t t\xE1c v\u1EE5 ph\u1EE9c t\u1EA1p h\u01A1n m\u1ED9t ch\xFAt: hu\u1EA5n luy\u1EC7n m\u1ED9t m\xF4 h\xECnh ng\xF4n ng\u1EEF t\u1EEB \u0111\u1EA7u."),vf.forEach(s),this.h()},h(){d(u,"name","hf:doc:metadata"),d(u,"content",JSON.stringify(Xf)),d(E,"id","tm-tt"),d(E,"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"),d(E,"href","#tm-tt"),d(L,"class","relative group"),d(rn,"href","https://huggingface.co/models?pipeline_tag=summarization&sort=downloads"),d(rn,"rel","nofollow"),d(vn,"href","https://huggingface.co/huggingface-course/mt5-small-finetuned-amazon-en-es"),d(vn,"rel","nofollow"),Wc(nn.src,yn="https://hf.space/gradioiframe/course-demos/mt5-small-finetuned-amazon-en-es/+")||d(nn,"src",yn),d(nn,"frameborder","0"),d(nn,"height","400"),d(nn,"title","Gradio app"),d(nn,"class","block dark:hidden container p-0 flex-grow space-iframe"),d(nn,"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"),d(nn,"sandbox","allow-forms allow-modals allow-popups allow-popups-to-escape-sandbox allow-same-origin allow-scripts allow-downloads"),d(v,"id","chun-b-kho-ng-liu-a-ngn-ng"),d(v,"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"),d(v,"href","#chun-b-kho-ng-liu-a-ngn-ng"),d(on,"class","relative group"),d(en,"href","https://huggingface.co/datasets/amazon_reviews_multi"),d(en,"rel","nofollow"),d(yt,"href","/course/chapter5"),d(js,"href","/course/chapter5"),d(os,"class","block dark:hidden"),Wc(os.src,$h="https://huggingface.co/datasets/huggingface-course/documentation-images/resolve/main/en/chapter7/review-lengths.svg")||d(os,"src",$h),d(os,"alt","Word count distributions for the review titles and texts."),d(o,"class","hidden dark:block"),Wc(o.src,T="https://huggingface.co/datasets/huggingface-course/documentation-images/resolve/main/en/chapter7/review-lengths-dark.svg")||d(o,"src",T),d(o,"alt","Word count distributions for the review titles and texts."),d(lt,"class","flex justify-center"),d(jt,"id","cc-m-hnh-cho-tm-tt-vn-bn"),d(jt,"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"),d(jt,"href","#cc-m-hnh-cho-tm-tt-vn-bn"),d(Ht,"class","relative group"),d(ae,"href","/course/chapter1"),d(he,"align","center"),d(le,"align","center"),d(Rs,"href","https://huggingface.co/gpt2-xl"),d(Rs,"rel","nofollow"),d(gs,"align","center"),d(ce,"align","center"),d($a,"href","https://huggingface.co/google/pegasus-large"),d($a,"rel","nofollow"),d(Rh,"align","center"),d(Hh,"align","center"),d(ja,"href","https://huggingface.co/t5-base"),d(ja,"rel","nofollow"),d(Ih,"align","center"),d(Gh,"align","center"),d(xa,"href","https://huggingface.co/google/mt5-base"),d(xa,"rel","nofollow"),d(Mh,"align","center"),d(Uh,"align","center"),d(Ea,"href","https://huggingface.co/facebook/bart-base"),d(Ea,"rel","nofollow"),d(Bh,"align","center"),d(Fh,"align","center"),d(qa,"href","https://huggingface.co/facebook/mbart-large-50"),d(qa,"rel","nofollow"),d(Vh,"align","center"),d(Kh,"align","center"),d(Ta,"class","block dark:hidden"),Wc(Ta.src,Tu="https://huggingface.co/datasets/huggingface-course/documentation-images/resolve/main/en/chapter7/t5.svg")||d(Ta,"src",Tu),d(Ta,"alt","Different tasks performed by the T5 architecture."),d(Ca,"class","hidden dark:block"),Wc(Ca.src,Cu="https://huggingface.co/datasets/huggingface-course/documentation-images/resolve/main/en/chapter7/t5-dark.svg")||d(Ca,"src",Cu),d(Ca,"alt","Different tasks performed by the T5 architecture."),d(pe,"class","flex justify-center"),d(Re,"id","tin-x-l-d-liu"),d(Re,"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"),d(Re,"href","#tin-x-l-d-liu"),d(ue,"class","relative group"),d(Qh,"href","/course/chapter3"),d(Jh,"href","/course/chapter6"),d(Ue,"id","thc-o-cho-tm-tt-vn-bn"),d(Ue,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),d(Ue,"href","#thc-o-cho-tm-tt-vn-bn"),d(ge,"class","relative group"),d(Ga,"href","https://en.wikipedia.org/wiki/ROUGE_(metric)"),d(Ga,"rel","nofollow"),qr.a=null,Cr.a=null,d(Xe,"id","to-mt-ng-c-s-mnh-m"),d(Xe,"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"),d(Xe,"href","#to-mt-ng-c-s-mnh-m"),d(de,"class","relative group"),d(ol,"href","/course/chapter7/6"),d(na,"id","s-dng-m-hnh-tinh-chnh-ca-bn"),d(na,"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"),d(na,"href","#s-dng-m-hnh-tinh-chnh-ca-bn"),d(fe,"class","relative group")},m(n,i){t(document.head,u),r(n,w,i),k(g,n,i),r(n,x,i),r(n,L,i),t(L,E),t(E,N),k(O,N,null),t(L,q),t(L,z),t(z,S),r(n,A,i),bh[D].m(n,i),r(n,X,i),r(n,K,i),t(K,J),t(K,M),t(M,Y),t(K,P),t(K,U),t(U,G),t(K,Q),r(n,an,i),k(tn,n,i),r(n,B,i),r(n,sn,i),t(sn,F),t(sn,rn),t(rn,gn),t(sn,qn),t(sn,vn),t(vn,Z),t(sn,_n),r(n,pn,i),r(n,nn,i),r(n,kn,i),r(n,hn,i),t(hn,Dn),r(n,dn,i),r(n,on,i),t(on,v),t(v,R),k(mn,R,null),t(on,j),t(on,V),t(V,$n),r(n,jn,i),r(n,un,i),t(un,Tn),t(un,en),t(en,Un),t(un,tt),r(n,cn,i),k(wn,n,i),r(n,Rn,i),k(Sn,n,i),r(n,wt,i),r(n,ln,i),t(ln,Yt),t(ln,vt),t(vt,ct),t(ln,st),t(ln,rt),t(rt,Bn),t(ln,xt),t(ln,Wn),t(Wn,_t),t(ln,Et),t(ln,An),t(An,it),t(ln,et),t(ln,ot),t(ot,H),t(ln,fn),t(ln,yt),t(yt,qt),t(ln,xn),r(n,Tt,i),k(Fn,n,i),r(n,Qt,i),k(at,n,i),r(n,ht,i),k(Xn,n,i),r(n,bn,i),r(n,Vn,i),t(Vn,Jt),t(Vn,Yn),t(Yn,Zt),t(Vn,Kn),t(Vn,Ct),t(Ct,zt),t(Vn,On),r(n,ns,i),k(Qn,n,i),r(n,ts,i),k(mt,n,i),r(n,Dt,i),r(n,Cn,i),t(Cn,ra),t(Cn,ks),t(ks,ss),t(Cn,_e),t(Cn,kt),t(kt,ye),t(Cn,$s),t(Cn,js),t(js,ke),t(Cn,es),t(Cn,ws),t(ws,St),t(Cn,ia),r(n,xs,i),k(as,n,i),r(n,$e,i),r(n,zn,i),t(zn,$t),t(zn,pt),t(pt,Vs),t(zn,hs),t(zn,Ks),t(Ks,Ws),t(zn,oa),t(zn,Es),t(Es,qs),t(zn,ma),t(zn,Ts),t(Ts,Jn),t(zn,ls),t(zn,Xs),t(Xs,Ys),t(zn,pa),r(n,je,i),k(cs,n,i),r(n,Cs,i),r(n,zs,i),t(zs,ua),r(n,Ds,i),k(rs,n,i),r(n,we,i),k(Pn,n,i),r(n,xe,i),r(n,Hn,i),t(Hn,ga),t(Hn,Qs),t(Qs,Js),t(Hn,da),t(Hn,Zs),t(Zs,ne),t(Hn,fa),t(Hn,te),t(te,Ee),t(Hn,Ss),r(n,qe,i),k(At,n,i),r(n,Ot,i),k(Pt,n,i),r(n,Lt,i),r(n,is,i),t(is,Nt),r(n,Te,i),r(n,lt,i),t(lt,os),t(lt,Ce),t(lt,o),r(n,ba,i),r(n,ms,i),t(ms,jh),t(ms,Rt),t(Rt,wh),t(ms,xh),r(n,se,i),k(As,n,i),r(n,va,i),r(n,ee,i),t(ee,Os),r(n,_a,i),r(n,Ht,i),t(Ht,jt),t(jt,ze),k(Ps,ze,null),t(Ht,De),t(Ht,Se),t(Se,Ae),r(n,ya,i),r(n,ps,i),t(ps,Ls),t(ps,ae),t(ae,Eh),t(ps,qh),r(n,ka,i),r(n,us,i),t(us,It),t(It,Gt),t(Gt,he),t(he,Th),t(Gt,Ch),t(Gt,Ns),t(Ns,zh),t(Gt,Oe),t(Gt,le),t(le,Dh),t(us,Sh),t(us,In),t(In,Gn),t(Gn,gs),t(gs,Rs),t(Rs,Ah),t(Gn,Oh),t(Gn,ut),t(ut,Ph),t(Gn,Lh),t(Gn,ce),t(ce,Nh),t(In,Pe),t(In,Mt),t(Mt,Rh),t(Rh,$a),t($a,Zi),t(Mt,no),t(Mt,Pl),t(Pl,to),t(Mt,so),t(Mt,Hh),t(Hh,eo),t(In,ao),t(In,re),t(re,Ih),t(Ih,ja),t(ja,ho),t(re,lo),t(re,wa),t(wa,co),t(wa,Ll),t(Ll,ro),t(wa,io),t(re,oo),t(re,Gh),t(Gh,mo),t(In,po),t(In,ie),t(ie,Mh),t(Mh,xa),t(xa,uo),t(ie,go),t(ie,Nl),t(Nl,fo),t(ie,bo),t(ie,Uh),t(Uh,vo),t(In,_o),t(In,oe),t(oe,Bh),t(Bh,Ea),t(Ea,yo),t(oe,ko),t(oe,Rl),t(Rl,$o),t(oe,jo),t(oe,Fh),t(Fh,wo),t(In,xo),t(In,me),t(me,Vh),t(Vh,qa),t(qa,Eo),t(me,qo),t(me,Hl),t(Hl,To),t(me,Co),t(me,Kh),t(Kh,zo),r(n,Xc,i),r(n,Wh,i),t(Wh,Do),r(n,Yc,i),r(n,Le,i),t(Le,So),t(Le,Il),t(Il,Ao),t(Le,Oo),r(n,Qc,i),r(n,pe,i),t(pe,Ta),t(pe,Po),t(pe,Ca),r(n,Jc,i),r(n,Xh,i),t(Xh,Lo),r(n,Zc,i),k(Ne,n,i),r(n,nr,i),r(n,ue,i),t(ue,Re),t(Re,Gl),k(za,Gl,null),t(ue,No),t(ue,Ml),t(Ml,Ro),r(n,tr,i),k(Da,n,i),r(n,sr,i),r(n,He,i),t(He,Ho),t(He,Ul),t(Ul,Io),t(He,Go),r(n,er,i),k(Sa,n,i),r(n,ar,i),k(Ie,n,i),r(n,hr,i),r(n,Yh,i),t(Yh,Mo),r(n,lr,i),k(Aa,n,i),r(n,cr,i),k(Oa,n,i),r(n,rr,i),r(n,gt,i),t(gt,Uo),t(gt,Bl),t(Bl,Bo),t(gt,Fo),t(gt,Fl),t(Fl,Vo),t(gt,Ko),t(gt,Qh),t(Qh,Wo),t(gt,Xo),t(gt,Vl),t(Vl,Yo),t(gt,Qo),r(n,ir,i),k(Pa,n,i),r(n,or,i),k(La,n,i),r(n,mr,i),r(n,Ut,i),t(Ut,Jo),t(Ut,Kl),t(Kl,Zo),t(Ut,nm),t(Ut,Wl),t(Wl,tm),t(Ut,sm),t(Ut,Jh),t(Jh,em),t(Ut,am),r(n,pr,i),r(n,Ge,i),t(Ge,hm),t(Ge,Xl),t(Xl,lm),t(Ge,cm),r(n,ur,i),k(Na,n,i),r(n,gr,i),r(n,dt,i),t(dt,rm),t(dt,Yl),t(Yl,im),t(dt,om),t(dt,Ql),t(Ql,mm),t(dt,pm),t(dt,Jl),t(Jl,um),t(dt,gm),t(dt,Zl),t(Zl,dm),t(dt,fm),r(n,dr,i),r(n,Hs,i),t(Hs,bm),t(Hs,nc),t(nc,vm),t(Hs,_m),t(Hs,tc),t(tc,ym),t(Hs,km),r(n,fr,i),k(Ra,n,i),r(n,br,i),r(n,Zh,i),t(Zh,$m),r(n,vr,i),k(Me,n,i),r(n,_r,i),r(n,ge,i),t(ge,Ue),t(Ue,sc),k(Ha,sc,null),t(ge,jm),t(ge,ec),t(ec,wm),r(n,yr,i),k(Ia,n,i),r(n,kr,i),r(n,nl,i),t(nl,xm),r(n,$r,i),r(n,Be,i),t(Be,Em),t(Be,Ga),t(Ga,qm),t(Be,Tm),r(n,jr,i),k(Ma,n,i),r(n,wr,i),r(n,Is,i),t(Is,Cm),t(Is,ac),t(ac,zm),t(Is,Dm),t(Is,hc),t(hc,Sm),t(Is,Am),r(n,xr,i),k(Fe,n,i),r(n,Er,i),r(n,Ua,i),t(Ua,Om),qr.m(wf,Ua),r(n,Tr,i),r(n,Ba,i),t(Ba,Pm),Cr.m(xf,Ba),r(n,zr,i),r(n,Ve,i),t(Ve,Lm),t(Ve,lc),t(lc,Nm),t(Ve,Rm),r(n,Dr,i),k(Fa,n,i),r(n,Sr,i),r(n,tl,i),t(tl,Hm),r(n,Ar,i),k(Va,n,i),r(n,Or,i),r(n,Ke,i),t(Ke,Im),t(Ke,cc),t(cc,Gm),t(Ke,Mm),r(n,Pr,i),k(Ka,n,i),r(n,Lr,i),k(Wa,n,i),r(n,Nr,i),r(n,Zn,i),t(Zn,Um),t(Zn,rc),t(rc,Bm),t(Zn,Fm),t(Zn,ic),t(ic,Vm),t(Zn,Km),t(Zn,oc),t(oc,Wm),t(Zn,Xm),t(Zn,mc),t(mc,Ym),t(Zn,Qm),t(Zn,pc),t(pc,Jm),t(Zn,Zm),r(n,Rr,i),k(Xa,n,i),r(n,Hr,i),k(Ya,n,i),r(n,Ir,i),r(n,nt,i),t(nt,np),t(nt,uc),t(uc,tp),t(nt,sp),t(nt,gc),t(gc,ep),t(nt,ap),t(nt,dc),t(dc,hp),t(nt,lp),t(nt,fc),t(fc,cp),t(nt,rp),t(nt,bc),t(bc,ip),t(nt,op),r(n,Gr,i),k(We,n,i),r(n,Mr,i),r(n,sl,i),t(sl,mp),r(n,Ur,i),r(n,de,i),t(de,Xe),t(Xe,vc),k(Qa,vc,null),t(de,pp),t(de,_c),t(_c,up),r(n,Br,i),r(n,ft,i),t(ft,gp),t(ft,yc),t(yc,dp),t(ft,fp),t(ft,kc),t(kc,bp),t(ft,vp),t(ft,$c),t($c,_p),t(ft,yp),t(ft,jc),t(jc,kp),t(ft,$p),r(n,Fr,i),k(Ja,n,i),r(n,Vr,i),r(n,el,i),t(el,jp),r(n,Kr,i),k(Za,n,i),r(n,Wr,i),r(n,Ye,i),t(Ye,wp),t(Ye,wc),t(wc,xp),t(Ye,Ep),r(n,Xr,i),k(nh,n,i),r(n,Yr,i),k(th,n,i),r(n,Qr,i),r(n,al,i),t(al,qp),r(n,Jr,i),k(sh,n,i),r(n,Zr,i),r(n,hl,i),t(hl,Tp),r(n,ni,i),k(eh,n,i),r(n,ti,i),k(ah,n,i),r(n,si,i),r(n,Qe,i),t(Qe,Cp),t(Qe,xc),t(xc,zp),t(Qe,Dp),r(n,ei,i),vh[ds].m(n,i),r(n,ll,i),k(Je,n,i),r(n,ai,i),r(n,cl,i),t(cl,Sp),r(n,hi,i),k(hh,n,i),r(n,li,i),r(n,rl,i),t(rl,Ap),r(n,ci,i),k(lh,n,i),r(n,ri,i),Ln&&Ln.m(n,i),r(n,il,i),r(n,Ze,i),t(Ze,Op),t(Ze,ol),t(ol,Pp),t(Ze,Lp),r(n,ii,i),r(n,Bt,i),t(Bt,Np),t(Bt,Ec),t(Ec,Rp),t(Bt,Hp),t(Bt,qc),t(qc,Ip),t(Bt,Gp),t(Bt,Tc),t(Tc,Mp),t(Bt,Up),r(n,oi,i),_h[bs].m(n,i),r(n,ml,i),r(n,pl,i),t(pl,Bp),r(n,mi,i),k(ch,n,i),r(n,pi,i),r(n,Gs,i),t(Gs,Fp),t(Gs,Cc),t(Cc,Vp),t(Gs,Kp),t(Gs,zc),t(zc,Wp),t(Gs,Xp),r(n,ui,i),k(rh,n,i),r(n,gi,i),k(ih,n,i),r(n,di,i),r(n,En,i),t(En,Yp),t(En,Dc),t(Dc,Qp),t(En,Jp),t(En,Sc),t(Sc,Zp),t(En,nu),t(En,Ac),t(Ac,tu),t(En,su),t(En,Oc),t(Oc,eu),t(En,au),t(En,Pc),t(Pc,hu),t(En,lu),t(En,Lc),t(Lc,cu),t(En,ru),t(En,Nc),t(Nc,iu),t(En,ou),t(En,Rc),t(Rc,mu),t(En,pu),r(n,fi,i),yh[_s].m(n,i),r(n,ul,i),Nn&&Nn.m(n,i),r(n,gl,i),r(n,fe,i),t(fe,na),t(na,Hc),k(oh,Hc,null),t(fe,uu),t(fe,Ic),t(Ic,gu),r(n,bi,i),r(n,ta,i),t(ta,du),t(ta,Gc),t(Gc,fu),t(ta,bu),r(n,vi,i),k(mh,n,i),r(n,_i,i),r(n,dl,i),t(dl,vu),r(n,yi,i),k(ph,n,i),r(n,ki,i),r(n,fl,i),t(fl,_u),r(n,$i,i),k(uh,n,i),r(n,ji,i),k(gh,n,i),r(n,wi,i),r(n,sa,i),t(sa,yu),t(sa,Mc),t(Mc,ku),t(sa,$u),r(n,xi,i),k(dh,n,i),r(n,Ei,i),k(fh,n,i),r(n,qi,i),r(n,bl,i),t(bl,ju),r(n,Ti,i),r(n,vl,i),t(vl,wu),Ci=!0},p(n,[i]){const kh={};i&1&&(kh.fw=n[0]),g.$set(kh);let _l=D;D=Du(n),D!==_l&&(Ol(),b(bh[_l],1,1,()=>{bh[_l]=null}),Al(),I=bh[D],I||(I=bh[D]=zu[D](n),I.c()),f(I,1),I.m(X.parentNode,X));const Uc={};i&2&&(Uc.$$scope={dirty:i,ctx:n}),Xn.$set(Uc);const Bc={};i&2&&(Bc.$$scope={dirty:i,ctx:n}),Ne.$set(Bc);const be={};i&2&&(be.$$scope={dirty:i,ctx:n}),Ie.$set(be);const Fc={};i&2&&(Fc.$$scope={dirty:i,ctx:n}),Me.$set(Fc);const Vc={};i&2&&(Vc.$$scope={dirty:i,ctx:n}),Fe.$set(Vc);const ve={};i&2&&(ve.$$scope={dirty:i,ctx:n}),We.$set(ve);let yl=ds;ds=Au(n),ds!==yl&&(Ol(),b(vh[yl],1,1,()=>{vh[yl]=null}),Al(),fs=vh[ds],fs||(fs=vh[ds]=Su[ds](n),fs.c()),f(fs,1),fs.m(ll.parentNode,ll));const Kc={};i&2&&(Kc.$$scope={dirty:i,ctx:n}),Je.$set(Kc),n[0]==="pt"?Ln?i&1&&f(Ln,1):(Ln=kf(),Ln.c(),f(Ln,1),Ln.m(il.parentNode,il)):Ln&&(Ol(),b(Ln,1,1,()=>{Ln=null}),Al());let kl=bs;bs=Pu(n),bs!==kl&&(Ol(),b(_h[kl],1,1,()=>{_h[kl]=null}),Al(),vs=_h[bs],vs||(vs=_h[bs]=Ou[bs](n),vs.c()),f(vs,1),vs.m(ml.parentNode,ml));let ea=_s;_s=Nu(n),_s!==ea&&(Ol(),b(yh[ea],1,1,()=>{yh[ea]=null}),Al(),ys=yh[_s],ys||(ys=yh[_s]=Lu[_s](n),ys.c()),f(ys,1),ys.m(ul.parentNode,ul)),n[0]==="pt"?Nn?i&1&&f(Nn,1):(Nn=$f(n),Nn.c(),f(Nn,1),Nn.m(gl.parentNode,gl)):Nn&&(Ol(),b(Nn,1,1,()=>{Nn=null}),Al())},i(n){Ci||(f(g.$$.fragment,n),f(O.$$.fragment,n),f(I),f(tn.$$.fragment,n),f(mn.$$.fragment,n),f(wn.$$.fragment,n),f(Sn.$$.fragment,n),f(Fn.$$.fragment,n),f(at.$$.fragment,n),f(Xn.$$.fragment,n),f(Qn.$$.fragment,n),f(mt.$$.fragment,n),f(as.$$.fragment,n),f(cs.$$.fragment,n),f(rs.$$.fragment,n),f(Pn.$$.fragment,n),f(At.$$.fragment,n),f(Pt.$$.fragment,n),f(As.$$.fragment,n),f(Ps.$$.fragment,n),f(Ne.$$.fragment,n),f(za.$$.fragment,n),f(Da.$$.fragment,n),f(Sa.$$.fragment,n),f(Ie.$$.fragment,n),f(Aa.$$.fragment,n),f(Oa.$$.fragment,n),f(Pa.$$.fragment,n),f(La.$$.fragment,n),f(Na.$$.fragment,n),f(Ra.$$.fragment,n),f(Me.$$.fragment,n),f(Ha.$$.fragment,n),f(Ia.$$.fragment,n),f(Ma.$$.fragment,n),f(Fe.$$.fragment,n),f(Fa.$$.fragment,n),f(Va.$$.fragment,n),f(Ka.$$.fragment,n),f(Wa.$$.fragment,n),f(Xa.$$.fragment,n),f(Ya.$$.fragment,n),f(We.$$.fragment,n),f(Qa.$$.fragment,n),f(Ja.$$.fragment,n),f(Za.$$.fragment,n),f(nh.$$.fragment,n),f(th.$$.fragment,n),f(sh.$$.fragment,n),f(eh.$$.fragment,n),f(ah.$$.fragment,n),f(fs),f(Je.$$.fragment,n),f(hh.$$.fragment,n),f(lh.$$.fragment,n),f(Ln),f(vs),f(ch.$$.fragment,n),f(rh.$$.fragment,n),f(ih.$$.fragment,n),f(ys),f(Nn),f(oh.$$.fragment,n),f(mh.$$.fragment,n),f(ph.$$.fragment,n),f(uh.$$.fragment,n),f(gh.$$.fragment,n),f(dh.$$.fragment,n),f(fh.$$.fragment,n),Ci=!0)},o(n){b(g.$$.fragment,n),b(O.$$.fragment,n),b(I),b(tn.$$.fragment,n),b(mn.$$.fragment,n),b(wn.$$.fragment,n),b(Sn.$$.fragment,n),b(Fn.$$.fragment,n),b(at.$$.fragment,n),b(Xn.$$.fragment,n),b(Qn.$$.fragment,n),b(mt.$$.fragment,n),b(as.$$.fragment,n),b(cs.$$.fragment,n),b(rs.$$.fragment,n),b(Pn.$$.fragment,n),b(At.$$.fragment,n),b(Pt.$$.fragment,n),b(As.$$.fragment,n),b(Ps.$$.fragment,n),b(Ne.$$.fragment,n),b(za.$$.fragment,n),b(Da.$$.fragment,n),b(Sa.$$.fragment,n),b(Ie.$$.fragment,n),b(Aa.$$.fragment,n),b(Oa.$$.fragment,n),b(Pa.$$.fragment,n),b(La.$$.fragment,n),b(Na.$$.fragment,n),b(Ra.$$.fragment,n),b(Me.$$.fragment,n),b(Ha.$$.fragment,n),b(Ia.$$.fragment,n),b(Ma.$$.fragment,n),b(Fe.$$.fragment,n),b(Fa.$$.fragment,n),b(Va.$$.fragment,n),b(Ka.$$.fragment,n),b(Wa.$$.fragment,n),b(Xa.$$.fragment,n),b(Ya.$$.fragment,n),b(We.$$.fragment,n),b(Qa.$$.fragment,n),b(Ja.$$.fragment,n),b(Za.$$.fragment,n),b(nh.$$.fragment,n),b(th.$$.fragment,n),b(sh.$$.fragment,n),b(eh.$$.fragment,n),b(ah.$$.fragment,n),b(fs),b(Je.$$.fragment,n),b(hh.$$.fragment,n),b(lh.$$.fragment,n),b(Ln),b(vs),b(ch.$$.fragment,n),b(rh.$$.fragment,n),b(ih.$$.fragment,n),b(ys),b(Nn),b(oh.$$.fragment,n),b(mh.$$.fragment,n),b(ph.$$.fragment,n),b(uh.$$.fragment,n),b(gh.$$.fragment,n),b(dh.$$.fragment,n),b(fh.$$.fragment,n),Ci=!1},d(n){s(u),n&&s(w),$(g,n),n&&s(x),n&&s(L),$(O),n&&s(A),bh[D].d(n),n&&s(X),n&&s(K),n&&s(an),$(tn,n),n&&s(B),n&&s(sn),n&&s(pn),n&&s(nn),n&&s(kn),n&&s(hn),n&&s(dn),n&&s(on),$(mn),n&&s(jn),n&&s(un),n&&s(cn),$(wn,n),n&&s(Rn),$(Sn,n),n&&s(wt),n&&s(ln),n&&s(Tt),$(Fn,n),n&&s(Qt),$(at,n),n&&s(ht),$(Xn,n),n&&s(bn),n&&s(Vn),n&&s(ns),$(Qn,n),n&&s(ts),$(mt,n),n&&s(Dt),n&&s(Cn),n&&s(xs),$(as,n),n&&s($e),n&&s(zn),n&&s(je),$(cs,n),n&&s(Cs),n&&s(zs),n&&s(Ds),$(rs,n),n&&s(we),$(Pn,n),n&&s(xe),n&&s(Hn),n&&s(qe),$(At,n),n&&s(Ot),$(Pt,n),n&&s(Lt),n&&s(is),n&&s(Te),n&&s(lt),n&&s(ba),n&&s(ms),n&&s(se),$(As,n),n&&s(va),n&&s(ee),n&&s(_a),n&&s(Ht),$(Ps),n&&s(ya),n&&s(ps),n&&s(ka),n&&s(us),n&&s(Xc),n&&s(Wh),n&&s(Yc),n&&s(Le),n&&s(Qc),n&&s(pe),n&&s(Jc),n&&s(Xh),n&&s(Zc),$(Ne,n),n&&s(nr),n&&s(ue),$(za),n&&s(tr),$(Da,n),n&&s(sr),n&&s(He),n&&s(er),$(Sa,n),n&&s(ar),$(Ie,n),n&&s(hr),n&&s(Yh),n&&s(lr),$(Aa,n),n&&s(cr),$(Oa,n),n&&s(rr),n&&s(gt),n&&s(ir),$(Pa,n),n&&s(or),$(La,n),n&&s(mr),n&&s(Ut),n&&s(pr),n&&s(Ge),n&&s(ur),$(Na,n),n&&s(gr),n&&s(dt),n&&s(dr),n&&s(Hs),n&&s(fr),$(Ra,n),n&&s(br),n&&s(Zh),n&&s(vr),$(Me,n),n&&s(_r),n&&s(ge),$(Ha),n&&s(yr),$(Ia,n),n&&s(kr),n&&s(nl),n&&s($r),n&&s(Be),n&&s(jr),$(Ma,n),n&&s(wr),n&&s(Is),n&&s(xr),$(Fe,n),n&&s(Er),n&&s(Ua),n&&s(Tr),n&&s(Ba),n&&s(zr),n&&s(Ve),n&&s(Dr),$(Fa,n),n&&s(Sr),n&&s(tl),n&&s(Ar),$(Va,n),n&&s(Or),n&&s(Ke),n&&s(Pr),$(Ka,n),n&&s(Lr),$(Wa,n),n&&s(Nr),n&&s(Zn),n&&s(Rr),$(Xa,n),n&&s(Hr),$(Ya,n),n&&s(Ir),n&&s(nt),n&&s(Gr),$(We,n),n&&s(Mr),n&&s(sl),n&&s(Ur),n&&s(de),$(Qa),n&&s(Br),n&&s(ft),n&&s(Fr),$(Ja,n),n&&s(Vr),n&&s(el),n&&s(Kr),$(Za,n),n&&s(Wr),n&&s(Ye),n&&s(Xr),$(nh,n),n&&s(Yr),$(th,n),n&&s(Qr),n&&s(al),n&&s(Jr),$(sh,n),n&&s(Zr),n&&s(hl),n&&s(ni),$(eh,n),n&&s(ti),$(ah,n),n&&s(si),n&&s(Qe),n&&s(ei),vh[ds].d(n),n&&s(ll),$(Je,n),n&&s(ai),n&&s(cl),n&&s(hi),$(hh,n),n&&s(li),n&&s(rl),n&&s(ci),$(lh,n),n&&s(ri),Ln&&Ln.d(n),n&&s(il),n&&s(Ze),n&&s(ii),n&&s(Bt),n&&s(oi),_h[bs].d(n),n&&s(ml),n&&s(pl),n&&s(mi),$(ch,n),n&&s(pi),n&&s(Gs),n&&s(ui),$(rh,n),n&&s(gi),$(ih,n),n&&s(di),n&&s(En),n&&s(fi),yh[_s].d(n),n&&s(ul),Nn&&Nn.d(n),n&&s(gl),n&&s(fe),$(oh),n&&s(bi),n&&s(ta),n&&s(vi),$(mh,n),n&&s(_i),n&&s(dl),n&&s(yi),$(ph,n),n&&s(ki),n&&s(fl),n&&s($i),$(uh,n),n&&s(ji),$(gh,n),n&&s(wi),n&&s(sa),n&&s(xi),$(dh,n),n&&s(Ei),$(fh,n),n&&s(qi),n&&s(bl),n&&s(Ti),n&&s(vl)}}}const Xf={local:"tm-tt",sections:[{local:"chun-b-kho-ng-liu-a-ngn-ng",title:"Chu\u1EA9n b\u1ECB kho ng\u1EEF li\u1EC7u \u0111a ng\xF4n ng\u1EEF"},{local:"cc-m-hnh-cho-tm-tt-vn-bn",title:"C\xE1c m\xF4 h\xECnh cho t\xF3m t\u1EAFt v\u0103n b\u1EA3n"},{local:"tin-x-l-d-liu",title:"Ti\u1EC1n x\u1EED l\xFD d\u1EEF li\u1EC7u"},{local:"thc-o-cho-tm-tt-vn-bn",sections:[{local:"to-mt-ng-c-s-mnh-m",title:"T\u1EA1o m\u1ED9t \u0111\u01B0\u1EDDng c\u01A1 s\u1EDF m\u1EA1nh m\u1EBD"}],title:"Th\u01B0\u1EDBc \u0111o cho t\xF3m t\u1EAFt v\u0103n b\u1EA3n"},{local:"tinh-chnh-mt5-vi-api-trainer",title:"Tinh ch\u1EC9nh mT5 v\u1EDBi API `Trainer`"},{local:"tinh-chnh-mt5-vi-keras",title:"Tinh ch\u1EC9nh mT5 v\u1EDBi Keras"},{local:"tinh-chnh-mt5-vi-accelerate",sections:[{local:"chun-b-mi-th-cho-hun-luyn",title:"Chu\u1EA9n b\u1ECB m\u1ECDi th\u1EE9 cho hu\u1EA5n luy\u1EC7n"},{local:"vng-lp-hun-luyn",title:"V\xF2ng l\u1EB7p hu\u1EA5n luy\u1EC7n"}],title:"Tinh ch\u1EC9nh mT5 v\u1EDBi \u{1F917} Accelerate"},{local:"s-dng-m-hnh-tinh-chnh-ca-bn",title:"S\u1EED d\u1EE5ng m\xF4 h\xECnh tinh ch\u1EC9nh c\u1EE7a b\u1EA1n"}],title:"T\xF3m t\u1EAFt"};function Yf(W,u,w){let g="pt";return zf(()=>{const x=new URLSearchParams(window.location.search);w(0,g=x.get("fw")||"pt")}),[g]}class ab extends Ef{constructor(u){super();qf(this,u,Yf,Wf,Tf,{})}}export{ab as default,Xf as metadata};
