import{S as Ld,i as Fd,s as Hd,e as c,t as s,k as p,w as j,c as h,a as r,h as a,d as n,m as u,x as q,g as i,G as e,y as E,q as f,o as _,B as C,b as A,M as Id,N as tm,p as Oe,v as Vd,n as ze}from"../../chunks/vendor-hf-doc-builder.js";import{T as xo}from"../../chunks/Tip-hf-doc-builder.js";import{Y as $o}from"../../chunks/Youtube-hf-doc-builder.js";import{I as nn}from"../../chunks/IconCopyLink-hf-doc-builder.js";import{C as S}from"../../chunks/CodeBlock-hf-doc-builder.js";import{D as zd}from"../../chunks/DocNotebookDropdown-hf-doc-builder.js";import{F as Qd}from"../../chunks/FrameworkSwitchCourse-hf-doc-builder.js";function Gd(H){let o,v;return o=new zd({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/section7_tf.ipynb"},{label:"Aws Studio",value:"https://studiolab.sagemaker.aws/import/github/huggingface/notebooks/blob/master/course/vi/chapter7/section7_tf.ipynb"}]}}),{c(){j(o.$$.fragment)},l(g){q(o.$$.fragment,g)},m(g,y){E(o,g,y),v=!0},i(g){v||(f(o.$$.fragment,g),v=!0)},o(g){_(o.$$.fragment,g),v=!1},d(g){C(o,g)}}}function Rd(H){let o,v;return o=new zd({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/section7_pt.ipynb"},{label:"Aws Studio",value:"https://studiolab.sagemaker.aws/import/github/huggingface/notebooks/blob/master/course/vi/chapter7/section7_pt.ipynb"}]}}),{c(){j(o.$$.fragment)},l(g){q(o.$$.fragment,g)},m(g,y){E(o,g,y),v=!0},i(g){v||(f(o.$$.fragment,g),v=!0)},o(g){_(o.$$.fragment,g),v=!1},d(g){C(o,g)}}}function Kd(H){let o,v,g,y,D,b,$,x,d,B,k,w,P,L;return{c(){o=c("p"),v=s("\u{1F4A1} C\xE1c m\xF4 h\xECnh m\xE3 h\xF3a nh\u01B0 BERT c\xF3 xu h\u01B0\u1EDBng tuy\u1EC7t v\u1EDDi trong vi\u1EC7c tr\xEDch xu\u1EA5t c\xE2u tr\u1EA3 l\u1EDDi cho c\xE1c c\xE2u h\u1ECFi d\u1EA1ng th\u1EF1c t\u1EBF nh\u01B0 \u201CAi \u0111\xE3 ph\xE1t minh ra ki\u1EBFn tr\xFAc Transformer?\u201D nh\u01B0ng kh\xE1 k\xE9m khi tr\u1EA3 l\u1EDDi nh\u1EEFng c\xE2u h\u1ECFi m\u1EDF nh\u01B0 \u201CT\u1EA1i sao b\u1EA7u tr\u1EDDi l\u1EA1i c\xF3 m\xE0u xanh?\u201D Trong nh\u1EEFng tr\u01B0\u1EDDng h\u1EE3p kh\xF3 kh\u0103n h\u01A1n n\xE0y, c\xE1c m\xF4 h\xECnh m\xE3 h\xF3a-gi\u1EA3i m\xE3 nh\u01B0 T5 v\xE0 BART th\u01B0\u1EDDng \u0111\u01B0\u1EE3c s\u1EED d\u1EE5ng \u0111\u1EC3 t\u1ED5ng h\u1EE3p th\xF4ng tin theo c\xE1ch kh\xE1 gi\u1ED1ng v\u1EDBi "),g=c("a"),y=s("t\xF3m t\u1EAFt v\u0103n b\u1EA3n"),D=s(". N\u1EBFu b\u1EA1n quan t\xE2m \u0111\u1EBFn ki\u1EC3u tr\u1EA3 l\u1EDDi c\xE2u h\u1ECFi "),b=c("em"),$=s("chung chung"),x=s(" n\xE0y, ch\xFAng t\xF4i khuy\xEAn b\u1EA1n n\xEAn xem "),d=c("a"),B=s("demo"),k=s(" c\u1EE7a ch\xFAng t\xF4i d\u1EF1a tr\xEAn "),w=c("a"),P=s("b\u1ED9 d\u1EEF li\u1EC7u ELI5"),L=s("."),this.h()},l(N){o=h(N,"P",{});var T=r(o);v=a(T,"\u{1F4A1} C\xE1c m\xF4 h\xECnh m\xE3 h\xF3a nh\u01B0 BERT c\xF3 xu h\u01B0\u1EDBng tuy\u1EC7t v\u1EDDi trong vi\u1EC7c tr\xEDch xu\u1EA5t c\xE2u tr\u1EA3 l\u1EDDi cho c\xE1c c\xE2u h\u1ECFi d\u1EA1ng th\u1EF1c t\u1EBF nh\u01B0 \u201CAi \u0111\xE3 ph\xE1t minh ra ki\u1EBFn tr\xFAc Transformer?\u201D nh\u01B0ng kh\xE1 k\xE9m khi tr\u1EA3 l\u1EDDi nh\u1EEFng c\xE2u h\u1ECFi m\u1EDF nh\u01B0 \u201CT\u1EA1i sao b\u1EA7u tr\u1EDDi l\u1EA1i c\xF3 m\xE0u xanh?\u201D Trong nh\u1EEFng tr\u01B0\u1EDDng h\u1EE3p kh\xF3 kh\u0103n h\u01A1n n\xE0y, c\xE1c m\xF4 h\xECnh m\xE3 h\xF3a-gi\u1EA3i m\xE3 nh\u01B0 T5 v\xE0 BART th\u01B0\u1EDDng \u0111\u01B0\u1EE3c s\u1EED d\u1EE5ng \u0111\u1EC3 t\u1ED5ng h\u1EE3p th\xF4ng tin theo c\xE1ch kh\xE1 gi\u1ED1ng v\u1EDBi "),g=h(T,"A",{href:!0});var F=r(g);y=a(F,"t\xF3m t\u1EAFt v\u0103n b\u1EA3n"),F.forEach(n),D=a(T,". N\u1EBFu b\u1EA1n quan t\xE2m \u0111\u1EBFn ki\u1EC3u tr\u1EA3 l\u1EDDi c\xE2u h\u1ECFi "),b=h(T,"EM",{});var I=r(b);$=a(I,"chung chung"),I.forEach(n),x=a(T," n\xE0y, ch\xFAng t\xF4i khuy\xEAn b\u1EA1n n\xEAn xem "),d=h(T,"A",{href:!0,rel:!0});var z=r(d);B=a(z,"demo"),z.forEach(n),k=a(T," c\u1EE7a ch\xFAng t\xF4i d\u1EF1a tr\xEAn "),w=h(T,"A",{href:!0,rel:!0});var R=r(w);P=a(R,"b\u1ED9 d\u1EEF li\u1EC7u ELI5"),R.forEach(n),L=a(T,"."),T.forEach(n),this.h()},h(){A(g,"href","/course/chapter7/5"),A(d,"href","https://yjernite.github.io/lfqa.html"),A(d,"rel","nofollow"),A(w,"href","https://huggingface.co/datasets/eli5"),A(w,"rel","nofollow")},m(N,T){i(N,o,T),e(o,v),e(o,g),e(g,y),e(o,D),e(o,b),e(b,$),e(o,x),e(o,d),e(d,B),e(o,k),e(o,w),e(w,P),e(o,L)},d(N){N&&n(o)}}}function Wd(H){let o,v,g,y,D,b,$,x,d,B,k;return{c(){o=c("p"),v=s("\u270F\uFE0F "),g=c("strong"),y=s("\u0110\u1EBFn l\u01B0\u1EE3t b\u1EA1n!"),D=s(" Khi s\u1EED d\u1EE5ng ki\u1EBFn tr\xFAc XLNet, ph\u1EA7n \u0111\u1EC7m \u0111\u01B0\u1EE3c \xE1p d\u1EE5ng \u1EDF b\xEAn tr\xE1i v\xE0 c\xE2u h\u1ECFi v\xE0 ng\u1EEF c\u1EA3nh \u0111\u01B0\u1EE3c chuy\u1EC3n \u0111\u1ED5i. \u0110i\u1EC1u ch\u1EC9nh t\u1EA5t c\u1EA3 m\xE3 ch\xFAng ta v\u1EEBa th\u1EA5y v\u1EDBi ki\u1EBFn tr\xFAc XLNet (v\xE0 th\xEAm "),b=c("code"),$=s("padding=True"),x=s("). L\u01B0u \xFD r\u1EB1ng token "),d=c("code"),B=s("[CLS]"),k=s(" c\xF3 th\u1EC3 kh\xF4ng \u1EDF v\u1ECB tr\xED 0 khi \xE1p d\u1EE5ng ph\u1EA7n \u0111\u1EC7m.")},l(w){o=h(w,"P",{});var P=r(o);v=a(P,"\u270F\uFE0F "),g=h(P,"STRONG",{});var L=r(g);y=a(L,"\u0110\u1EBFn l\u01B0\u1EE3t b\u1EA1n!"),L.forEach(n),D=a(P," Khi s\u1EED d\u1EE5ng ki\u1EBFn tr\xFAc XLNet, ph\u1EA7n \u0111\u1EC7m \u0111\u01B0\u1EE3c \xE1p d\u1EE5ng \u1EDF b\xEAn tr\xE1i v\xE0 c\xE2u h\u1ECFi v\xE0 ng\u1EEF c\u1EA3nh \u0111\u01B0\u1EE3c chuy\u1EC3n \u0111\u1ED5i. \u0110i\u1EC1u ch\u1EC9nh t\u1EA5t c\u1EA3 m\xE3 ch\xFAng ta v\u1EEBa th\u1EA5y v\u1EDBi ki\u1EBFn tr\xFAc XLNet (v\xE0 th\xEAm "),b=h(P,"CODE",{});var N=r(b);$=a(N,"padding=True"),N.forEach(n),x=a(P,"). L\u01B0u \xFD r\u1EB1ng token "),d=h(P,"CODE",{});var T=r(d);B=a(T,"[CLS]"),T.forEach(n),k=a(P," c\xF3 th\u1EC3 kh\xF4ng \u1EDF v\u1ECB tr\xED 0 khi \xE1p d\u1EE5ng ph\u1EA7n \u0111\u1EC7m."),P.forEach(n)},m(w,P){i(w,o,P),e(o,v),e(o,g),e(g,y),e(o,D),e(o,b),e(b,$),e(o,x),e(o,d),e(d,B),e(o,k)},d(w){w&&n(o)}}}function Ud(H){let o,v,g,y,D,b,$,x,d,B,k;return y=new nn({}),{c(){o=c("h2"),v=c("a"),g=c("span"),j(y.$$.fragment),D=p(),b=c("span"),$=s("Tinh ch\u1EC9nh m\xF4 h\xECn v\u1EDBi Keras"),x=p(),d=c("p"),B=s("\u0110o\u1EA1n m\xE3 hu\u1EA5n luy\u1EC7n cho m\u1EABu n\xE0y s\u1EBD tr\xF4ng r\u1EA5t gi\u1ED1ng trong c\xE1c ph\u1EA7n tr\u01B0\u1EDBc, nh\u01B0ng vi\u1EC7c t\xEDnh to\xE1n c\xE1c s\u1ED1 li\u1EC7u s\u1EBD l\xE0 m\u1ED9t th\u1EED th\xE1ch \u0111\u1ED9c \u0111\xE1o. V\xEC ch\xFAng ta \u0111\xE3 \u0111\u1EC7m t\u1EA5t c\u1EA3 c\xE1c m\u1EABu \u0111\u1EBFn \u0111\u1ED9 d\xE0i t\u1ED1i \u0111a m\xE0 ch\xFAng ta \u0111\u1EB7t, kh\xF4ng c\xF3 c\xF4ng c\u1EE5 \u0111\u1ED1i chi\u1EBFu d\u1EEF li\u1EC7u \u0111\u1EC3 x\xE1c \u0111\u1ECBnh, v\xEC v\u1EADy vi\u1EC7c t\xEDnh to\xE1n s\u1ED1 li\u1EC7u n\xE0y th\u1EF1c s\u1EF1 l\xE0 \u0111i\u1EC1u duy nh\u1EA5t ta ph\u1EA3i lo l\u1EAFng. Ph\u1EA7n kh\xF3 s\u1EBD l\xE0 h\u1EADu x\u1EED l\xFD c\xE1c d\u1EF1 \u0111o\xE1n c\u1EE7a m\xF4 h\xECnh th\xE0nh c\xE1c kho\u1EA3ng v\u0103n b\u1EA3n trong c\xE1c v\xED d\u1EE5 ban \u0111\u1EA7u; khi ch\xFAng ta \u0111\xE3 l\xE0m \u0111i\u1EC1u \u0111\xF3, ch\u1EC9 s\u1ED1 t\u1EEB th\u01B0 vi\u1EC7n \u{1F917} Datasets s\u1EBD th\u1EF1c hi\u1EC7n h\u1EA7u h\u1EBFt c\xF4ng vi\u1EC7c cho ta."),this.h()},l(w){o=h(w,"H2",{class:!0});var P=r(o);v=h(P,"A",{id:!0,class:!0,href:!0});var L=r(v);g=h(L,"SPAN",{});var N=r(g);q(y.$$.fragment,N),N.forEach(n),L.forEach(n),D=u(P),b=h(P,"SPAN",{});var T=r(b);$=a(T,"Tinh ch\u1EC9nh m\xF4 h\xECn v\u1EDBi Keras"),T.forEach(n),P.forEach(n),x=u(w),d=h(w,"P",{});var F=r(d);B=a(F,"\u0110o\u1EA1n m\xE3 hu\u1EA5n luy\u1EC7n cho m\u1EABu n\xE0y s\u1EBD tr\xF4ng r\u1EA5t gi\u1ED1ng trong c\xE1c ph\u1EA7n tr\u01B0\u1EDBc, nh\u01B0ng vi\u1EC7c t\xEDnh to\xE1n c\xE1c s\u1ED1 li\u1EC7u s\u1EBD l\xE0 m\u1ED9t th\u1EED th\xE1ch \u0111\u1ED9c \u0111\xE1o. V\xEC ch\xFAng ta \u0111\xE3 \u0111\u1EC7m t\u1EA5t c\u1EA3 c\xE1c m\u1EABu \u0111\u1EBFn \u0111\u1ED9 d\xE0i t\u1ED1i \u0111a m\xE0 ch\xFAng ta \u0111\u1EB7t, kh\xF4ng c\xF3 c\xF4ng c\u1EE5 \u0111\u1ED1i chi\u1EBFu d\u1EEF li\u1EC7u \u0111\u1EC3 x\xE1c \u0111\u1ECBnh, v\xEC v\u1EADy vi\u1EC7c t\xEDnh to\xE1n s\u1ED1 li\u1EC7u n\xE0y th\u1EF1c s\u1EF1 l\xE0 \u0111i\u1EC1u duy nh\u1EA5t ta ph\u1EA3i lo l\u1EAFng. Ph\u1EA7n kh\xF3 s\u1EBD l\xE0 h\u1EADu x\u1EED l\xFD c\xE1c d\u1EF1 \u0111o\xE1n c\u1EE7a m\xF4 h\xECnh th\xE0nh c\xE1c kho\u1EA3ng v\u0103n b\u1EA3n trong c\xE1c v\xED d\u1EE5 ban \u0111\u1EA7u; khi ch\xFAng ta \u0111\xE3 l\xE0m \u0111i\u1EC1u \u0111\xF3, ch\u1EC9 s\u1ED1 t\u1EEB th\u01B0 vi\u1EC7n \u{1F917} Datasets s\u1EBD th\u1EF1c hi\u1EC7n h\u1EA7u h\u1EBFt c\xF4ng vi\u1EC7c cho ta."),F.forEach(n),this.h()},h(){A(v,"id","tinh-chnh-m-hn-vi-keras"),A(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"),A(v,"href","#tinh-chnh-m-hn-vi-keras"),A(o,"class","relative group")},m(w,P){i(w,o,P),e(o,v),e(v,g),E(y,g,null),e(o,D),e(o,b),e(b,$),i(w,x,P),i(w,d,P),e(d,B),k=!0},i(w){k||(f(y.$$.fragment,w),k=!0)},o(w){_(y.$$.fragment,w),k=!1},d(w){w&&n(o),C(y),w&&n(x),w&&n(d)}}}function Xd(H){let o,v,g,y,D,b,$,x,d,B,k,w,P,L,N,T;return y=new nn({}),{c(){o=c("h2"),v=c("a"),g=c("span"),j(y.$$.fragment),D=p(),b=c("span"),$=s("Tinh ch\u1EC9nh m\xF4 h\xECn v\u1EDBi API "),x=c("code"),d=s("Trainer"),B=p(),k=c("p"),w=s("\u0110o\u1EA1n m\xE3 hu\u1EA5n luy\u1EC7n cho m\u1EABu n\xE0y s\u1EBD tr\xF4ng r\u1EA5t gi\u1ED1ng trong c\xE1c ph\u1EA7n tr\u01B0\u1EDBc - \u0111i\u1EC1u kh\xF3 nh\u1EA5t s\u1EBD l\xE0 vi\u1EBFt h\xE0m "),P=c("code"),L=s("compute_metrics()"),N=s(". V\xEC ch\xFAng ta \u0111\xE3 \u0111\u1EC7m t\u1EA5t c\u1EA3 c\xE1c m\u1EABu \u0111\u1EBFn \u0111\u1ED9 d\xE0i t\u1ED1i \u0111a m\xE0 ta \u0111\u1EB7t, kh\xF4ng c\xF3 c\xF4ng c\u1EE5 \u0111\u1ED1i chi\u1EBFu d\u1EEF li\u1EC7u \u0111\u1EC3 x\xE1c \u0111\u1ECBnh, v\xEC v\u1EADy vi\u1EC7c t\xEDnh to\xE1n s\u1ED1 li\u1EC7u n\xE0y th\u1EF1c s\u1EF1 l\xE0 \u0111i\u1EC1u duy nh\u1EA5t ch\xFAng ta ph\u1EA3i lo l\u1EAFng. Ph\u1EA7n kh\xF3 kh\u0103n s\u1EBD l\xE0 h\u1EADu x\u1EED l\xFD c\xE1c d\u1EF1 \u0111o\xE1n c\u1EE7a m\xF4 h\xECnh th\xE0nh c\xE1c kho\u1EA3ng v\u0103n b\u1EA3n trong c\xE1c v\xED d\u1EE5 ban \u0111\u1EA7u; khi ta \u0111\xE3 l\xE0m \u0111i\u1EC1u \u0111\xF3, ch\u1EC9 s\u1ED1 t\u1EEB th\u01B0 vi\u1EC7n \u{1F917} Datasets s\u1EBD th\u1EF1c hi\u1EC7n h\u1EA7u h\u1EBFt c\xF4ng vi\u1EC7c cho m\xECnh."),this.h()},l(F){o=h(F,"H2",{class:!0});var I=r(o);v=h(I,"A",{id:!0,class:!0,href:!0});var z=r(v);g=h(z,"SPAN",{});var R=r(g);q(y.$$.fragment,R),R.forEach(n),z.forEach(n),D=u(I),b=h(I,"SPAN",{});var G=r(b);$=a(G,"Tinh ch\u1EC9nh m\xF4 h\xECn v\u1EDBi API "),x=h(G,"CODE",{});var V=r(x);d=a(V,"Trainer"),V.forEach(n),G.forEach(n),I.forEach(n),B=u(F),k=h(F,"P",{});var J=r(k);w=a(J,"\u0110o\u1EA1n m\xE3 hu\u1EA5n luy\u1EC7n cho m\u1EABu n\xE0y s\u1EBD tr\xF4ng r\u1EA5t gi\u1ED1ng trong c\xE1c ph\u1EA7n tr\u01B0\u1EDBc - \u0111i\u1EC1u kh\xF3 nh\u1EA5t s\u1EBD l\xE0 vi\u1EBFt h\xE0m "),P=h(J,"CODE",{});var U=r(P);L=a(U,"compute_metrics()"),U.forEach(n),N=a(J,". V\xEC ch\xFAng ta \u0111\xE3 \u0111\u1EC7m t\u1EA5t c\u1EA3 c\xE1c m\u1EABu \u0111\u1EBFn \u0111\u1ED9 d\xE0i t\u1ED1i \u0111a m\xE0 ta \u0111\u1EB7t, kh\xF4ng c\xF3 c\xF4ng c\u1EE5 \u0111\u1ED1i chi\u1EBFu d\u1EEF li\u1EC7u \u0111\u1EC3 x\xE1c \u0111\u1ECBnh, v\xEC v\u1EADy vi\u1EC7c t\xEDnh to\xE1n s\u1ED1 li\u1EC7u n\xE0y th\u1EF1c s\u1EF1 l\xE0 \u0111i\u1EC1u duy nh\u1EA5t ch\xFAng ta ph\u1EA3i lo l\u1EAFng. Ph\u1EA7n kh\xF3 kh\u0103n s\u1EBD l\xE0 h\u1EADu x\u1EED l\xFD c\xE1c d\u1EF1 \u0111o\xE1n c\u1EE7a m\xF4 h\xECnh th\xE0nh c\xE1c kho\u1EA3ng v\u0103n b\u1EA3n trong c\xE1c v\xED d\u1EE5 ban \u0111\u1EA7u; khi ta \u0111\xE3 l\xE0m \u0111i\u1EC1u \u0111\xF3, ch\u1EC9 s\u1ED1 t\u1EEB th\u01B0 vi\u1EC7n \u{1F917} Datasets s\u1EBD th\u1EF1c hi\u1EC7n h\u1EA7u h\u1EBFt c\xF4ng vi\u1EC7c cho m\xECnh."),J.forEach(n),this.h()},h(){A(v,"id","tinh-chnh-m-hn-vi-api-trainer"),A(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"),A(v,"href","#tinh-chnh-m-hn-vi-api-trainer"),A(o,"class","relative group")},m(F,I){i(F,o,I),e(o,v),e(v,g),E(y,g,null),e(o,D),e(o,b),e(b,$),e(b,x),e(x,d),i(F,B,I),i(F,k,I),e(k,w),e(k,P),e(P,L),e(k,N),T=!0},i(F){T||(f(y.$$.fragment,F),T=!0)},o(F){_(y.$$.fragment,F),T=!1},d(F){F&&n(o),C(y),F&&n(B),F&&n(k)}}}function Jd(H){let o,v;return o=new $o({props:{id:"VN67ZpN33Ss"}}),{c(){j(o.$$.fragment)},l(g){q(o.$$.fragment,g)},m(g,y){E(o,g,y),v=!0},i(g){v||(f(o.$$.fragment,g),v=!0)},o(g){_(o.$$.fragment,g),v=!1},d(g){C(o,g)}}}function Yd(H){let o,v;return o=new $o({props:{id:"BNy08iIWVJM"}}),{c(){j(o.$$.fragment)},l(g){q(o.$$.fragment,g)},m(g,y){E(o,g,y),v=!0},i(g){v||(f(o.$$.fragment,g),v=!0)},o(g){_(o.$$.fragment,g),v=!1},d(g){C(o,g)}}}function Zd(H){let o,v,g,y,D,b,$;return o=new S({props:{code:`import tensorflow as tf
from transformers import TFAutoModelForQuestionAnswering

eval_set_for_model = eval_set.remove_columns(["example_id", "offset_mapping"])
eval_set_for_model.set_format("numpy")

batch = {k: eval_set_for_model[k] for k in eval_set_for_model.column_names}
trained_model = TFAutoModelForQuestionAnswering.from_pretrained(trained_checkpoint)

outputs = trained_model(**batch)`,highlighted:`<span class="hljs-keyword">import</span> tensorflow <span class="hljs-keyword">as</span> tf
<span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> TFAutoModelForQuestionAnswering

eval_set_for_model = eval_set.remove_columns([<span class="hljs-string">&quot;example_id&quot;</span>, <span class="hljs-string">&quot;offset_mapping&quot;</span>])
eval_set_for_model.set_format(<span class="hljs-string">&quot;numpy&quot;</span>)

batch = {k: eval_set_for_model[k] <span class="hljs-keyword">for</span> k <span class="hljs-keyword">in</span> eval_set_for_model.column_names}
trained_model = TFAutoModelForQuestionAnswering.from_pretrained(trained_checkpoint)

outputs = trained_model(**batch)`}}),b=new S({props:{code:`start_logits = outputs.start_logits.numpy()
end_logits = outputs.end_logits.numpy()`,highlighted:`start_logits = outputs.start_logits.numpy()
end_logits = outputs.end_logits.numpy()`}}),{c(){j(o.$$.fragment),v=p(),g=c("p"),y=s("\u0110\u1EC3 d\u1EC5 d\xE0ng th\u1EED nghi\u1EC7m, h\xE3y chuy\u1EC3n \u0111\u1ED5i c\xE1c k\u1EBFt qu\u1EA3 \u0111\u1EA7u ra n\xE0y th\xE0nh m\u1EA3ng NumPy:"),D=p(),j(b.$$.fragment)},l(x){q(o.$$.fragment,x),v=u(x),g=h(x,"P",{});var d=r(g);y=a(d,"\u0110\u1EC3 d\u1EC5 d\xE0ng th\u1EED nghi\u1EC7m, h\xE3y chuy\u1EC3n \u0111\u1ED5i c\xE1c k\u1EBFt qu\u1EA3 \u0111\u1EA7u ra n\xE0y th\xE0nh m\u1EA3ng NumPy:"),d.forEach(n),D=u(x),q(b.$$.fragment,x)},m(x,d){E(o,x,d),i(x,v,d),i(x,g,d),e(g,y),i(x,D,d),E(b,x,d),$=!0},i(x){$||(f(o.$$.fragment,x),f(b.$$.fragment,x),$=!0)},o(x){_(o.$$.fragment,x),_(b.$$.fragment,x),$=!1},d(x){C(o,x),x&&n(v),x&&n(g),x&&n(D),C(b,x)}}}function tf(H){let o,v,g,y,D,b,$,x,d,B;return o=new S({props:{code:`import torch
from transformers import AutoModelForQuestionAnswering

eval_set_for_model = eval_set.remove_columns(["example_id", "offset_mapping"])
eval_set_for_model.set_format("torch")

device = torch.device("cuda") if torch.cuda.is_available() else torch.device("cpu")
batch = {k: eval_set_for_model[k].to(device) for k in eval_set_for_model.column_names}
trained_model = AutoModelForQuestionAnswering.from_pretrained(trained_checkpoint).to(
    device
)

with torch.no_grad():
    outputs = trained_model(**batch)`,highlighted:`<span class="hljs-keyword">import</span> torch
<span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoModelForQuestionAnswering

eval_set_for_model = eval_set.remove_columns([<span class="hljs-string">&quot;example_id&quot;</span>, <span class="hljs-string">&quot;offset_mapping&quot;</span>])
eval_set_for_model.set_format(<span class="hljs-string">&quot;torch&quot;</span>)

device = torch.device(<span class="hljs-string">&quot;cuda&quot;</span>) <span class="hljs-keyword">if</span> torch.cuda.is_available() <span class="hljs-keyword">else</span> torch.device(<span class="hljs-string">&quot;cpu&quot;</span>)
batch = {k: eval_set_for_model[k].to(device) <span class="hljs-keyword">for</span> k <span class="hljs-keyword">in</span> eval_set_for_model.column_names}
trained_model = AutoModelForQuestionAnswering.from_pretrained(trained_checkpoint).to(
    device
)

<span class="hljs-keyword">with</span> torch.no_grad():
    outputs = trained_model(**batch)`}}),d=new S({props:{code:`start_logits = outputs.start_logits.cpu().numpy()
end_logits = outputs.end_logits.cpu().numpy()`,highlighted:`start_logits = outputs.start_logits.cpu().numpy()
end_logits = outputs.end_logits.cpu().numpy()`}}),{c(){j(o.$$.fragment),v=p(),g=c("p"),y=s("V\xEC "),D=c("code"),b=s("Trainer"),$=s(" s\u1EBD tr\u1EA3 cho ta c\xE1c d\u1EF1 \u0111o\xE1n d\u01B0\u1EDBi d\u1EA1ng m\u1EA3ng NumPy, ta s\u1EBD l\u1EA5y c\xE1c logit b\u1EAFt \u0111\u1EA7u v\xE0 k\u1EBFt th\xFAc v\xE0 chuy\u1EC3n n\xF3 th\xE0nh d\u1EA1ng:"),x=p(),j(d.$$.fragment)},l(k){q(o.$$.fragment,k),v=u(k),g=h(k,"P",{});var w=r(g);y=a(w,"V\xEC "),D=h(w,"CODE",{});var P=r(D);b=a(P,"Trainer"),P.forEach(n),$=a(w," s\u1EBD tr\u1EA3 cho ta c\xE1c d\u1EF1 \u0111o\xE1n d\u01B0\u1EDBi d\u1EA1ng m\u1EA3ng NumPy, ta s\u1EBD l\u1EA5y c\xE1c logit b\u1EAFt \u0111\u1EA7u v\xE0 k\u1EBFt th\xFAc v\xE0 chuy\u1EC3n n\xF3 th\xE0nh d\u1EA1ng:"),w.forEach(n),x=u(k),q(d.$$.fragment,k)},m(k,w){E(o,k,w),i(k,v,w),i(k,g,w),e(g,y),e(g,D),e(D,b),e(g,$),i(k,x,w),E(d,k,w),B=!0},i(k){B||(f(o.$$.fragment,k),f(d.$$.fragment,k),B=!0)},o(k){_(o.$$.fragment,k),_(d.$$.fragment,k),B=!1},d(k){C(o,k),k&&n(v),k&&n(g),k&&n(x),C(d,k)}}}function nf(H){let o,v,g,y,D;return{c(){o=c("p"),v=s("B\xE2y gi\u1EDD, h\xE3y \u0111\u1EB7t m\u1ECDi th\u1EE9 ta v\u1EEBa l\xE0m v\xE0o m\u1ED9t h\xE0m "),g=c("code"),y=s("compute_metrics()"),D=s(" m\xE0 ta s\u1EBD s\u1EED d\u1EE5ng sau khi hu\u1EA5n luy\u1EC7n m\xF4 h\xECnh c\u1EE7a m\xECnh. Ch\xFAng ta s\u1EBD c\u1EA7n truy\u1EC1n nhi\u1EC1u h\u01A1n l\xE0 nh\u1EADt k\xFD \u0111\u1EA7u ra, v\xEC ta ph\u1EA3i t\xECm trong t\u1EADp d\u1EEF li\u1EC7u c\xE1c \u0111\u1EB7c tr\u01B0ng cho ph\u1EA7n offset v\xE0 trong t\u1EADp d\u1EEF li\u1EC7u c\xE1c m\u1EABu cho c\xE1c ng\u1EEF c\u1EA3nh ban \u0111\u1EA7u:")},l(b){o=h(b,"P",{});var $=r(o);v=a($,"B\xE2y gi\u1EDD, h\xE3y \u0111\u1EB7t m\u1ECDi th\u1EE9 ta v\u1EEBa l\xE0m v\xE0o m\u1ED9t h\xE0m "),g=h($,"CODE",{});var x=r(g);y=a(x,"compute_metrics()"),x.forEach(n),D=a($," m\xE0 ta s\u1EBD s\u1EED d\u1EE5ng sau khi hu\u1EA5n luy\u1EC7n m\xF4 h\xECnh c\u1EE7a m\xECnh. Ch\xFAng ta s\u1EBD c\u1EA7n truy\u1EC1n nhi\u1EC1u h\u01A1n l\xE0 nh\u1EADt k\xFD \u0111\u1EA7u ra, v\xEC ta ph\u1EA3i t\xECm trong t\u1EADp d\u1EEF li\u1EC7u c\xE1c \u0111\u1EB7c tr\u01B0ng cho ph\u1EA7n offset v\xE0 trong t\u1EADp d\u1EEF li\u1EC7u c\xE1c m\u1EABu cho c\xE1c ng\u1EEF c\u1EA3nh ban \u0111\u1EA7u:"),$.forEach(n)},m(b,$){i(b,o,$),e(o,v),e(o,g),e(g,y),e(o,D)},d(b){b&&n(o)}}}function ef(H){let o,v,g,y,D,b,$,x,d,B,k,w,P,L,N,T,F,I,z,R;return{c(){o=c("p"),v=s("B\xE2y gi\u1EDD ch\xFAng ta h\xE3y \u0111\u1EB7t m\u1ECDi th\u1EE9 ta v\u1EEBa l\xE0m trong m\u1ED9t h\xE0m "),g=c("code"),y=s("compute_metrics()"),D=s(" m\xE0 ta s\u1EBD s\u1EED d\u1EE5ng trong "),b=c("code"),$=s("Trainer"),x=s(". Th\xF4ng th\u01B0\u1EDDng, h\xE0m "),d=c("code"),B=s("compute_metrics()"),k=s(" \u0111\xF3 ch\u1EC9 nh\u1EADn \u0111\u01B0\u1EE3c m\u1ED9t tuple "),w=c("code"),P=s("eval_preds"),L=s(" v\u1EDBi c\xE1c logit v\xE0 nh\xE3n. \u1EDE \u0111\xE2y ch\xFAng ta s\u1EBD c\u1EA7n nhi\u1EC1u h\u01A1n m\u1ED9t ch\xFAt, v\xEC ch\xFAng ta ph\u1EA3i t\xECm trong t\u1EADp d\u1EEF li\u1EC7u c\xE1c \u0111\u1EB7c tr\u01B0ng cho ph\u1EA7n b\xF9 v\xE0 trong t\u1EADp d\u1EEF li\u1EC7u c\xE1c v\xED d\u1EE5 cho c\xE1c ng\u1EEF c\u1EA3nh ban \u0111\u1EA7u, v\xEC v\u1EADy ch\xFAng ta s\u1EBD kh\xF4ng th\u1EC3 s\u1EED d\u1EE5ng ch\u1EE9c n\u0103ng n\xE0y \u0111\u1EC3 nh\u1EADn k\u1EBFt qu\u1EA3 \u0111\xE1nh gi\xE1 th\u01B0\u1EDDng xuy\xEAn trong qu\xE1 tr\xECnh hu\u1EA5n luy\u1EC7n. Ch\xFAng ta s\u1EBD ch\u1EC9 s\u1EED d\u1EE5ng n\xF3 khi k\u1EBFt th\xFAc kh\xF3a hu\u1EA5nl luy\u1EC7n \u0111\u1EC3 ki\u1EC3m tra k\u1EBFt qu\u1EA3."),N=p(),T=c("p"),F=s("H\xE0m "),I=c("code"),z=s("compute_metrics()"),R=s(" nh\xF3m c\xE1c b\u01B0\u1EDBc gi\u1ED1ng nh\u01B0 tr\u01B0\u1EDBc; ch\xFAng ta ch\u1EC9 th\xEAm m\u1ED9t ki\u1EC3m tra nh\u1ECF trong tr\u01B0\u1EDDng h\u1EE3p ta kh\xF4ng \u0111\u01B0a ra b\u1EA5t k\u1EF3 c\xE2u tr\u1EA3 l\u1EDDi h\u1EE3p l\u1EC7 n\xE0o (trong tr\u01B0\u1EDDng h\u1EE3p \u0111\xF3 ta d\u1EF1 \u0111o\xE1n m\u1ED9t chu\u1ED7i tr\u1ED1ng).")},l(G){o=h(G,"P",{});var V=r(o);v=a(V,"B\xE2y gi\u1EDD ch\xFAng ta h\xE3y \u0111\u1EB7t m\u1ECDi th\u1EE9 ta v\u1EEBa l\xE0m trong m\u1ED9t h\xE0m "),g=h(V,"CODE",{});var J=r(g);y=a(J,"compute_metrics()"),J.forEach(n),D=a(V," m\xE0 ta s\u1EBD s\u1EED d\u1EE5ng trong "),b=h(V,"CODE",{});var U=r(b);$=a(U,"Trainer"),U.forEach(n),x=a(V,". Th\xF4ng th\u01B0\u1EDDng, h\xE0m "),d=h(V,"CODE",{});var O=r(d);B=a(O,"compute_metrics()"),O.forEach(n),k=a(V," \u0111\xF3 ch\u1EC9 nh\u1EADn \u0111\u01B0\u1EE3c m\u1ED9t tuple "),w=h(V,"CODE",{});var K=r(w);P=a(K,"eval_preds"),K.forEach(n),L=a(V," v\u1EDBi c\xE1c logit v\xE0 nh\xE3n. \u1EDE \u0111\xE2y ch\xFAng ta s\u1EBD c\u1EA7n nhi\u1EC1u h\u01A1n m\u1ED9t ch\xFAt, v\xEC ch\xFAng ta ph\u1EA3i t\xECm trong t\u1EADp d\u1EEF li\u1EC7u c\xE1c \u0111\u1EB7c tr\u01B0ng cho ph\u1EA7n b\xF9 v\xE0 trong t\u1EADp d\u1EEF li\u1EC7u c\xE1c v\xED d\u1EE5 cho c\xE1c ng\u1EEF c\u1EA3nh ban \u0111\u1EA7u, v\xEC v\u1EADy ch\xFAng ta s\u1EBD kh\xF4ng th\u1EC3 s\u1EED d\u1EE5ng ch\u1EE9c n\u0103ng n\xE0y \u0111\u1EC3 nh\u1EADn k\u1EBFt qu\u1EA3 \u0111\xE1nh gi\xE1 th\u01B0\u1EDDng xuy\xEAn trong qu\xE1 tr\xECnh hu\u1EA5n luy\u1EC7n. Ch\xFAng ta s\u1EBD ch\u1EC9 s\u1EED d\u1EE5ng n\xF3 khi k\u1EBFt th\xFAc kh\xF3a hu\u1EA5nl luy\u1EC7n \u0111\u1EC3 ki\u1EC3m tra k\u1EBFt qu\u1EA3."),V.forEach(n),N=u(G),T=h(G,"P",{});var Y=r(T);F=a(Y,"H\xE0m "),I=h(Y,"CODE",{});var nt=r(I);z=a(nt,"compute_metrics()"),nt.forEach(n),R=a(Y," nh\xF3m c\xE1c b\u01B0\u1EDBc gi\u1ED1ng nh\u01B0 tr\u01B0\u1EDBc; ch\xFAng ta ch\u1EC9 th\xEAm m\u1ED9t ki\u1EC3m tra nh\u1ECF trong tr\u01B0\u1EDDng h\u1EE3p ta kh\xF4ng \u0111\u01B0a ra b\u1EA5t k\u1EF3 c\xE2u tr\u1EA3 l\u1EDDi h\u1EE3p l\u1EC7 n\xE0o (trong tr\u01B0\u1EDDng h\u1EE3p \u0111\xF3 ta d\u1EF1 \u0111o\xE1n m\u1ED9t chu\u1ED7i tr\u1ED1ng)."),Y.forEach(n)},m(G,V){i(G,o,V),e(o,v),e(o,g),e(g,y),e(o,D),e(o,b),e(b,$),e(o,x),e(o,d),e(d,B),e(o,k),e(o,w),e(w,P),e(o,L),i(G,N,V),i(G,T,V),e(T,F),e(T,I),e(I,z),e(T,R)},d(G){G&&n(o),G&&n(N),G&&n(T)}}}function sf(H){let o,v,g,y,D,b,$,x;return $=new S({props:{code:"model = TFAutoModelForQuestionAnswering.from_pretrained(model_checkpoint)",highlighted:"model = TFAutoModelForQuestionAnswering.from_pretrained(model_checkpoint)"}}),{c(){o=c("p"),v=s("Gi\u1EDD ta \u0111\xE3 s\u1EB5n s\xE0ng \u0111\u1EC3 hu\u1EA5n luy\u1EC7n m\xF4 h\xECnh c\u1EE7a m\xECnh. H\xE3y c\u0169ng t\u1EA1o ra n\xF3 s\u1EED d\u1EE5ng l\u1EDBp "),g=c("code"),y=s("TFAutoModelForQuestionAnswering"),D=s(" nh\u01B0 tr\u01B0\u1EDBc \u0111\xF3:"),b=p(),j($.$$.fragment)},l(d){o=h(d,"P",{});var B=r(o);v=a(B,"Gi\u1EDD ta \u0111\xE3 s\u1EB5n s\xE0ng \u0111\u1EC3 hu\u1EA5n luy\u1EC7n m\xF4 h\xECnh c\u1EE7a m\xECnh. H\xE3y c\u0169ng t\u1EA1o ra n\xF3 s\u1EED d\u1EE5ng l\u1EDBp "),g=h(B,"CODE",{});var k=r(g);y=a(k,"TFAutoModelForQuestionAnswering"),k.forEach(n),D=a(B," nh\u01B0 tr\u01B0\u1EDBc \u0111\xF3:"),B.forEach(n),b=u(d),q($.$$.fragment,d)},m(d,B){i(d,o,B),e(o,v),e(o,g),e(g,y),e(o,D),i(d,b,B),E($,d,B),x=!0},i(d){x||(f($.$$.fragment,d),x=!0)},o(d){_($.$$.fragment,d),x=!1},d(d){d&&n(o),d&&n(b),C($,d)}}}function af(H){let o,v,g,y,D,b,$,x;return $=new S({props:{code:"model = AutoModelForQuestionAnswering.from_pretrained(model_checkpoint)",highlighted:"model = AutoModelForQuestionAnswering.from_pretrained(model_checkpoint)"}}),{c(){o=c("p"),v=s("Gi\u1EDD ta \u0111\xE3 s\u1EB5n s\xE0ng \u0111\u1EC3 hu\u1EA5n luy\u1EC7n m\xF4 h\xECnh c\u1EE7a m\xECnh. H\xE3y c\u0169ng t\u1EA1o ra n\xF3 s\u1EED d\u1EE5ng l\u1EDBp "),g=c("code"),y=s("AutoModelForQuestionAnswering"),D=s(" nh\u01B0 tr\u01B0\u1EDBc \u0111\xF3:"),b=p(),j($.$$.fragment)},l(d){o=h(d,"P",{});var B=r(o);v=a(B,"Gi\u1EDD ta \u0111\xE3 s\u1EB5n s\xE0ng \u0111\u1EC3 hu\u1EA5n luy\u1EC7n m\xF4 h\xECnh c\u1EE7a m\xECnh. H\xE3y c\u0169ng t\u1EA1o ra n\xF3 s\u1EED d\u1EE5ng l\u1EDBp "),g=h(B,"CODE",{});var k=r(g);y=a(k,"AutoModelForQuestionAnswering"),k.forEach(n),D=a(B," nh\u01B0 tr\u01B0\u1EDBc \u0111\xF3:"),B.forEach(n),b=u(d),q($.$$.fragment,d)},m(d,B){i(d,o,B),e(o,v),e(o,g),e(g,y),e(o,D),i(d,b,B),E($,d,B),x=!0},i(d){x||(f($.$$.fragment,d),x=!0)},o(d){_($.$$.fragment,d),x=!1},d(d){d&&n(o),d&&n(b),C($,d)}}}function lf(H){let o,v,g,y,D,b,$,x,d,B,k,w,P,L,N,T,F,I,z,R,G,V,J,U;return y=new S({props:{code:`from transformers import DefaultDataCollator

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

data_collator = DefaultDataCollator(return_tensors=<span class="hljs-string">&quot;tf&quot;</span>)`}}),d=new S({props:{code:`tf_train_dataset = train_dataset.to_tf_dataset(
    columns=[
        "input_ids",
        "start_positions",
        "end_positions",
        "attention_mask",
        "token_type_ids",
    ],
    collate_fn=data_collator,
    shuffle=True,
    batch_size=16,
)
tf_eval_dataset = validation_dataset.to_tf_dataset(
    columns=["input_ids", "attention_mask", "token_type_ids"],
    collate_fn=data_collator,
    shuffle=False,
    batch_size=16,
)`,highlighted:`tf_train_dataset = train_dataset.to_tf_dataset(
    columns=[
        <span class="hljs-string">&quot;input_ids&quot;</span>,
        <span class="hljs-string">&quot;start_positions&quot;</span>,
        <span class="hljs-string">&quot;end_positions&quot;</span>,
        <span class="hljs-string">&quot;attention_mask&quot;</span>,
        <span class="hljs-string">&quot;token_type_ids&quot;</span>,
    ],
    collate_fn=data_collator,
    shuffle=<span class="hljs-literal">True</span>,
    batch_size=<span class="hljs-number">16</span>,
)
tf_eval_dataset = validation_dataset.to_tf_dataset(
    columns=[<span class="hljs-string">&quot;input_ids&quot;</span>, <span class="hljs-string">&quot;attention_mask&quot;</span>, <span class="hljs-string">&quot;token_type_ids&quot;</span>],
    collate_fn=data_collator,
    shuffle=<span class="hljs-literal">False</span>,
    batch_size=<span class="hljs-number">16</span>,
)`}}),L=new S({props:{code:`from transformers import create_optimizer
from transformers.keras_callbacks import PushToHubCallback
import tensorflow as tf

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

num_train_epochs = 3
num_train_steps = len(tf_train_dataset) * num_train_epochs
optimizer, schedule = create_optimizer(
    init_lr=2e-5,
    num_warmup_steps=0,
    num_train_steps=num_train_steps,
    weight_decay_rate=0.01,
)
model.compile(optimizer=optimizer)

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

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

num_train_epochs = <span class="hljs-number">3</span>
num_train_steps = <span class="hljs-built_in">len</span>(tf_train_dataset) * num_train_epochs
optimizer, schedule = create_optimizer(
    init_lr=<span class="hljs-number">2e-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>)`}}),{c(){o=c("p"),v=s("B\xE2y gi\u1EDD \u0111\xE3 xong, ch\xFAng ta c\xF3 th\u1EC3 t\u1EA1o TF Datasets c\u1EE7a m\xECnh. Ch\xFAng ta c\xF3 th\u1EC3 s\u1EED d\u1EE5ng c\xF4ng c\u1EE5 \u0111\u1ED1i chi\u1EBFu d\u1EEF li\u1EC7u m\u1EB7c \u0111\u1ECBnh \u0111\u01A1n gi\u1EA3n l\u1EA7n n\xE0y:"),g=p(),j(y.$$.fragment),D=p(),b=c("p"),$=s("V\xE0 gi\u1EDD ch\xFAng ta t\u1EA1o b\u1ED9 d\u1EEF li\u1EC7u nh\u01B0 b\xECnh th\u01B0\u1EDDng."),x=p(),j(d.$$.fragment),B=p(),k=c("p"),w=s("Ti\u1EBFp theo, ch\xFAng ta thi\u1EBFt l\u1EADp c\xE1c si\xEAu tham s\u1ED1 hu\u1EA5n luy\u1EC7n v\xE0 bi\xEAn d\u1ECBch m\xF4 h\xECnh c\u1EE7a m\xECnh:"),P=p(),j(L.$$.fragment),N=p(),T=c("p"),F=s("Cu\u1ED1i c\xF9ng, ta \u0111\xE3 s\u1EB5n s\xE0ng \u0111\u1EC3 hu\u1EA5n luy\u1EC7n v\u1EDBi "),I=c("code"),z=s("model.fit()"),R=s(". Ta s\u1EED d\u1EE5ng "),G=c("code"),V=s("PushToHubCallback"),J=s(" \u0111\u1EC3 t\u1EA3i m\xF4 h\xECnh l\xEAn Hub sau m\u1ED7i epoch.")},l(O){o=h(O,"P",{});var K=r(o);v=a(K,"B\xE2y gi\u1EDD \u0111\xE3 xong, ch\xFAng ta c\xF3 th\u1EC3 t\u1EA1o TF Datasets c\u1EE7a m\xECnh. Ch\xFAng ta c\xF3 th\u1EC3 s\u1EED d\u1EE5ng c\xF4ng c\u1EE5 \u0111\u1ED1i chi\u1EBFu d\u1EEF li\u1EC7u m\u1EB7c \u0111\u1ECBnh \u0111\u01A1n gi\u1EA3n l\u1EA7n n\xE0y:"),K.forEach(n),g=u(O),q(y.$$.fragment,O),D=u(O),b=h(O,"P",{});var Y=r(b);$=a(Y,"V\xE0 gi\u1EDD ch\xFAng ta t\u1EA1o b\u1ED9 d\u1EEF li\u1EC7u nh\u01B0 b\xECnh th\u01B0\u1EDDng."),Y.forEach(n),x=u(O),q(d.$$.fragment,O),B=u(O),k=h(O,"P",{});var nt=r(k);w=a(nt,"Ti\u1EBFp theo, ch\xFAng ta thi\u1EBFt l\u1EADp c\xE1c si\xEAu tham s\u1ED1 hu\u1EA5n luy\u1EC7n v\xE0 bi\xEAn d\u1ECBch m\xF4 h\xECnh c\u1EE7a m\xECnh:"),nt.forEach(n),P=u(O),q(L.$$.fragment,O),N=u(O),T=h(O,"P",{});var W=r(T);F=a(W,"Cu\u1ED1i c\xF9ng, ta \u0111\xE3 s\u1EB5n s\xE0ng \u0111\u1EC3 hu\u1EA5n luy\u1EC7n v\u1EDBi "),I=h(W,"CODE",{});var ct=r(I);z=a(ct,"model.fit()"),ct.forEach(n),R=a(W,". Ta s\u1EED d\u1EE5ng "),G=h(W,"CODE",{});var _t=r(G);V=a(_t,"PushToHubCallback"),_t.forEach(n),J=a(W," \u0111\u1EC3 t\u1EA3i m\xF4 h\xECnh l\xEAn Hub sau m\u1ED7i epoch."),W.forEach(n)},m(O,K){i(O,o,K),e(o,v),i(O,g,K),E(y,O,K),i(O,D,K),i(O,b,K),e(b,$),i(O,x,K),E(d,O,K),i(O,B,K),i(O,k,K),e(k,w),i(O,P,K),E(L,O,K),i(O,N,K),i(O,T,K),e(T,F),e(T,I),e(I,z),e(T,R),e(T,G),e(G,V),e(T,J),U=!0},i(O){U||(f(y.$$.fragment,O),f(d.$$.fragment,O),f(L.$$.fragment,O),U=!0)},o(O){_(y.$$.fragment,O),_(d.$$.fragment,O),_(L.$$.fragment,O),U=!1},d(O){O&&n(o),O&&n(g),C(y,O),O&&n(D),O&&n(b),O&&n(x),C(d,O),O&&n(B),O&&n(k),O&&n(P),C(L,O),O&&n(N),O&&n(T)}}}function cf(H){let o,v,g,y,D,b,$,x,d,B,k,w,P,L,N,T,F,I,z,R,G,V,J,U,O,K,Y,nt,W,ct,_t,Tt,at,en,Ft;return nt=new S({props:{code:`from transformers import TrainingArguments

args = TrainingArguments(
    "bert-finetuned-squad",
    evaluation_strategy="no",
    save_strategy="epoch",
    learning_rate=2e-5,
    num_train_epochs=3,
    weight_decay=0.01,
    fp16=True,
    push_to_hub=True,
)`,highlighted:`<span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> TrainingArguments

args = TrainingArguments(
    <span class="hljs-string">&quot;bert-finetuned-squad&quot;</span>,
    evaluation_strategy=<span class="hljs-string">&quot;no&quot;</span>,
    save_strategy=<span class="hljs-string">&quot;epoch&quot;</span>,
    learning_rate=<span class="hljs-number">2e-5</span>,
    num_train_epochs=<span class="hljs-number">3</span>,
    weight_decay=<span class="hljs-number">0.01</span>,
    fp16=<span class="hljs-literal">True</span>,
    push_to_hub=<span class="hljs-literal">True</span>,
)`}}),{c(){o=c("p"),v=s("Khi \u0111i\u1EC1u n\xE0y \u0111\u01B0\u1EE3c th\u1EF1c hi\u1EC7n, ch\xFAng ta c\xF3 th\u1EC3 x\xE1c \u0111\u1ECBnh "),g=c("code"),y=s("TrainingArguments"),D=s(" c\u1EE7a m\xECnh. Nh\u01B0 ta \u0111\xE3 n\xF3i khi x\xE1c \u0111\u1ECBnh ch\u1EE9c n\u0103ng c\u1EE7a m\xECnh \u0111\u1EC3 t\xEDnh to\xE1n c\xE1c ch\u1EC9 s\u1ED1, ch\xFAng ta s\u1EBD kh\xF4ng th\u1EC3 c\xF3 v\xF2ng l\u1EB7p \u0111\xE1nh gi\xE1 th\u01B0\u1EDDng xuy\xEAn v\xEC \u0111\u1EB7c tr\u01B0ng c\u1EE7a h\xE0m "),b=c("code"),$=s("compute_metrics()"),x=s(". Ch\xFAng ta c\xF3 th\u1EC3 vi\u1EBFt l\u1EDBp con c\u1EE7a ri\xEAng m\xECnh v\u1EC1 "),d=c("code"),B=s("Trainer"),k=s(" \u0111\u1EC3 l\xE0m \u0111i\u1EC1u n\xE0y (m\u1ED9t c\xE1ch ti\u1EBFp c\u1EADn b\u1EA1n c\xF3 th\u1EC3 t\xECm th\u1EA5y trong "),w=c("a"),P=s("b\u1ED9 l\u1EC7nh m\u1EABu cho h\u1ECFi \u0111\xE1p"),L=s("), nh\u01B0ng h\u01A1i d\xE0i cho ph\u1EA7n n\xE0y. Thay v\xE0o \u0111\xF3, ch\xFAng ta s\u1EBD ch\u1EC9 \u0111\xE1nh gi\xE1 m\xF4 h\xECnh khi k\u1EBFt th\xFAc hu\u1EA5n luy\u1EC7n t\u1EA1i \u0111\xE2y v\xE0 ch\u1EC9 cho b\u1EA1n c\xE1ch th\u1EF1c hi\u1EC7n \u0111\xE1nh gi\xE1 th\u01B0\u1EDDng xuy\xEAn trong \u201CV\xF2ng hu\u1EA5n luy\u1EC7n t\xF9y ch\u1EC9nh\u201D b\xEAn d\u01B0\u1EDBi."),N=p(),T=c("p"),F=s("\u0110\xE2y th\u1EF1c s\u1EF1 l\xE0 n\u01A1i API "),I=c("code"),z=s("Trainer"),R=s(" th\u1EC3 hi\u1EC7n c\xE1c gi\u1EDBi h\u1EA1n c\u1EE7a n\xF3 v\xE0 l\xE0 l\xFAc th\u01B0 vi\u1EC7n \u{1F917} Accelerate t\u1ECFa s\xE1ng: vi\u1EC7c t\xF9y ch\u1EC9nh l\u1EDBp cho m\u1ED9t tr\u01B0\u1EDDng h\u1EE3p s\u1EED d\u1EE5ng c\u1EE5 th\u1EC3 c\xF3 th\u1EC3 g\xE2y kh\xF3 kh\u0103n, nh\u01B0ng vi\u1EC7c \u0111i\u1EC1u ch\u1EC9nh m\u1ED9t v\xF2ng hu\u1EA5n luy\u1EC7n \u0111\u01B0\u1EE3c ti\u1EBFp x\xFAc ho\xE0n to\xE0n r\u1EA5t d\u1EC5 d\xE0ng."),G=p(),V=c("p"),J=s("Ch\xFAng ta h\xE3y xem x\xE9t c\xE1c "),U=c("code"),O=s("TrainingArguments"),K=s(" c\u1EE7a m\xECnh:"),Y=p(),j(nt.$$.fragment),W=p(),ct=c("p"),_t=s("Ch\xFAng ta \u0111\xE3 th\u1EA5y h\u1EA7u h\u1EBFt nh\u1EEFng \u0111i\u1EC1u n\xE0y tr\u01B0\u1EDBc \u0111\xE2y: ch\xFAng ta \u0111\u1EB7t m\u1ED9t s\u1ED1 si\xEAu tham s\u1ED1 (nh\u01B0 t\u1ED1c \u0111\u1ED9 h\u1ECDc, s\u1ED1 epoch ta d\xF9ng \u0111\u1EC3 hu\u1EA5n luy\u1EC7n v\xE0 m\u1ED9t s\u1ED1 ph\xE2n r\xE3 tr\u1ECDng s\u1ED1) v\xE0 cho bi\u1EBFt r\u1EB1ng ch\xFAng ta mu\u1ED1n l\u01B0u m\xF4 h\xECnh v\xE0o cu\u1ED1i m\u1ED7i epoch, b\u1ECF qua \u0111\xE1nh gi\xE1 v\xE0 t\u1EA3i k\u1EBFt qu\u1EA3 c\u1EE7a m\xECnh l\xEAn Model Hub. Ch\xFAng ta c\u0169ng cho ph\xE9p hu\u1EA5n luy\u1EC7n ch\xEDnh x\xE1c h\u1ED7n h\u1EE3p v\u1EDBi "),Tt=c("code"),at=s("fp16 = True"),en=s(", v\xEC n\xF3 c\xF3 th\u1EC3 t\u0103ng t\u1ED1c hu\u1EA5n luy\u1EC7n m\u1ED9t c\xE1ch \u0111\u1ED9c \u0111\xE1o tr\xEAn GPU g\u1EA7n \u0111\xE2y."),this.h()},l(Q){o=h(Q,"P",{});var X=r(o);v=a(X,"Khi \u0111i\u1EC1u n\xE0y \u0111\u01B0\u1EE3c th\u1EF1c hi\u1EC7n, ch\xFAng ta c\xF3 th\u1EC3 x\xE1c \u0111\u1ECBnh "),g=h(X,"CODE",{});var Dt=r(g);y=a(Dt,"TrainingArguments"),Dt.forEach(n),D=a(X," c\u1EE7a m\xECnh. Nh\u01B0 ta \u0111\xE3 n\xF3i khi x\xE1c \u0111\u1ECBnh ch\u1EE9c n\u0103ng c\u1EE7a m\xECnh \u0111\u1EC3 t\xEDnh to\xE1n c\xE1c ch\u1EC9 s\u1ED1, ch\xFAng ta s\u1EBD kh\xF4ng th\u1EC3 c\xF3 v\xF2ng l\u1EB7p \u0111\xE1nh gi\xE1 th\u01B0\u1EDDng xuy\xEAn v\xEC \u0111\u1EB7c tr\u01B0ng c\u1EE7a h\xE0m "),b=h(X,"CODE",{});var ie=r(b);$=a(ie,"compute_metrics()"),ie.forEach(n),x=a(X,". Ch\xFAng ta c\xF3 th\u1EC3 vi\u1EBFt l\u1EDBp con c\u1EE7a ri\xEAng m\xECnh v\u1EC1 "),d=h(X,"CODE",{});var sn=r(d);B=a(sn,"Trainer"),sn.forEach(n),k=a(X," \u0111\u1EC3 l\xE0m \u0111i\u1EC1u n\xE0y (m\u1ED9t c\xE1ch ti\u1EBFp c\u1EADn b\u1EA1n c\xF3 th\u1EC3 t\xECm th\u1EA5y trong "),w=h(X,"A",{href:!0,rel:!0});var fn=r(w);P=a(fn,"b\u1ED9 l\u1EC7nh m\u1EABu cho h\u1ECFi \u0111\xE1p"),fn.forEach(n),L=a(X,"), nh\u01B0ng h\u01A1i d\xE0i cho ph\u1EA7n n\xE0y. Thay v\xE0o \u0111\xF3, ch\xFAng ta s\u1EBD ch\u1EC9 \u0111\xE1nh gi\xE1 m\xF4 h\xECnh khi k\u1EBFt th\xFAc hu\u1EA5n luy\u1EC7n t\u1EA1i \u0111\xE2y v\xE0 ch\u1EC9 cho b\u1EA1n c\xE1ch th\u1EF1c hi\u1EC7n \u0111\xE1nh gi\xE1 th\u01B0\u1EDDng xuy\xEAn trong \u201CV\xF2ng hu\u1EA5n luy\u1EC7n t\xF9y ch\u1EC9nh\u201D b\xEAn d\u01B0\u1EDBi."),X.forEach(n),N=u(Q),T=h(Q,"P",{});var ut=r(T);F=a(ut,"\u0110\xE2y th\u1EF1c s\u1EF1 l\xE0 n\u01A1i API "),I=h(ut,"CODE",{});var an=r(I);z=a(an,"Trainer"),an.forEach(n),R=a(ut," th\u1EC3 hi\u1EC7n c\xE1c gi\u1EDBi h\u1EA1n c\u1EE7a n\xF3 v\xE0 l\xE0 l\xFAc th\u01B0 vi\u1EC7n \u{1F917} Accelerate t\u1ECFa s\xE1ng: vi\u1EC7c t\xF9y ch\u1EC9nh l\u1EDBp cho m\u1ED9t tr\u01B0\u1EDDng h\u1EE3p s\u1EED d\u1EE5ng c\u1EE5 th\u1EC3 c\xF3 th\u1EC3 g\xE2y kh\xF3 kh\u0103n, nh\u01B0ng vi\u1EC7c \u0111i\u1EC1u ch\u1EC9nh m\u1ED9t v\xF2ng hu\u1EA5n luy\u1EC7n \u0111\u01B0\u1EE3c ti\u1EBFp x\xFAc ho\xE0n to\xE0n r\u1EA5t d\u1EC5 d\xE0ng."),ut.forEach(n),G=u(Q),V=h(Q,"P",{});var et=r(V);J=a(et,"Ch\xFAng ta h\xE3y xem x\xE9t c\xE1c "),U=h(et,"CODE",{});var vt=r(U);O=a(vt,"TrainingArguments"),vt.forEach(n),K=a(et," c\u1EE7a m\xECnh:"),et.forEach(n),Y=u(Q),q(nt.$$.fragment,Q),W=u(Q),ct=h(Q,"P",{});var mt=r(ct);_t=a(mt,"Ch\xFAng ta \u0111\xE3 th\u1EA5y h\u1EA7u h\u1EBFt nh\u1EEFng \u0111i\u1EC1u n\xE0y tr\u01B0\u1EDBc \u0111\xE2y: ch\xFAng ta \u0111\u1EB7t m\u1ED9t s\u1ED1 si\xEAu tham s\u1ED1 (nh\u01B0 t\u1ED1c \u0111\u1ED9 h\u1ECDc, s\u1ED1 epoch ta d\xF9ng \u0111\u1EC3 hu\u1EA5n luy\u1EC7n v\xE0 m\u1ED9t s\u1ED1 ph\xE2n r\xE3 tr\u1ECDng s\u1ED1) v\xE0 cho bi\u1EBFt r\u1EB1ng ch\xFAng ta mu\u1ED1n l\u01B0u m\xF4 h\xECnh v\xE0o cu\u1ED1i m\u1ED7i epoch, b\u1ECF qua \u0111\xE1nh gi\xE1 v\xE0 t\u1EA3i k\u1EBFt qu\u1EA3 c\u1EE7a m\xECnh l\xEAn Model Hub. Ch\xFAng ta c\u0169ng cho ph\xE9p hu\u1EA5n luy\u1EC7n ch\xEDnh x\xE1c h\u1ED7n h\u1EE3p v\u1EDBi "),Tt=h(mt,"CODE",{});var At=r(Tt);at=a(At,"fp16 = True"),At.forEach(n),en=a(mt,", v\xEC n\xF3 c\xF3 th\u1EC3 t\u0103ng t\u1ED1c hu\u1EA5n luy\u1EC7n m\u1ED9t c\xE1ch \u0111\u1ED9c \u0111\xE1o tr\xEAn GPU g\u1EA7n \u0111\xE2y."),mt.forEach(n),this.h()},h(){A(w,"href","https://github.com/huggingface/transformers/blob/master/examples/pytorch/question-answering/trainer_qa.py"),A(w,"rel","nofollow")},m(Q,X){i(Q,o,X),e(o,v),e(o,g),e(g,y),e(o,D),e(o,b),e(b,$),e(o,x),e(o,d),e(d,B),e(o,k),e(o,w),e(w,P),e(o,L),i(Q,N,X),i(Q,T,X),e(T,F),e(T,I),e(I,z),e(T,R),i(Q,G,X),i(Q,V,X),e(V,J),e(V,U),e(U,O),e(V,K),i(Q,Y,X),E(nt,Q,X),i(Q,W,X),i(Q,ct,X),e(ct,_t),e(ct,Tt),e(Tt,at),e(ct,en),Ft=!0},i(Q){Ft||(f(nt.$$.fragment,Q),Ft=!0)},o(Q){_(nt.$$.fragment,Q),Ft=!1},d(Q){Q&&n(o),Q&&n(N),Q&&n(T),Q&&n(G),Q&&n(V),Q&&n(Y),C(nt,Q),Q&&n(W),Q&&n(ct)}}}function hf(H){let o,v;return o=new S({props:{code:`from transformers.keras_callbacks import PushToHubCallback

callback = PushToHubCallback(output_dir="bert-finetuned-squad", tokenizer=tokenizer)

# Ch\xFAng ta s\u1EBD th\u1EF1c hi\u1EC7n ki\u1EC3m \u0111\u1ECBnh sau \u0111\xF3, v\xEC v\u1EADy kh\xF4ng c\xF3 qu\xE1 tr\xECnh hu\u1EA5nlluy\u1EC7n gi\u1EEFa qu\xE1 tr\xECnh ki\u1EC3m \u0111\u1ECBnh
model.fit(tf_train_dataset, callbacks=[callback], epochs=num_train_epochs)`,highlighted:`<span class="hljs-keyword">from</span> transformers.keras_callbacks <span class="hljs-keyword">import</span> PushToHubCallback

callback = PushToHubCallback(output_dir=<span class="hljs-string">&quot;bert-finetuned-squad&quot;</span>, tokenizer=tokenizer)

<span class="hljs-comment"># Ch\xFAng ta s\u1EBD th\u1EF1c hi\u1EC7n ki\u1EC3m \u0111\u1ECBnh sau \u0111\xF3, v\xEC v\u1EADy kh\xF4ng c\xF3 qu\xE1 tr\xECnh hu\u1EA5nlluy\u1EC7n gi\u1EEFa qu\xE1 tr\xECnh ki\u1EC3m \u0111\u1ECBnh</span>
model.fit(tf_train_dataset, callbacks=[callback], epochs=num_train_epochs)`}}),{c(){j(o.$$.fragment)},l(g){q(o.$$.fragment,g)},m(g,y){E(o,g,y),v=!0},i(g){v||(f(o.$$.fragment,g),v=!0)},o(g){_(o.$$.fragment,g),v=!1},d(g){C(o,g)}}}function rf(H){let o,v,g,y,D,b,$,x,d,B;return o=new xo({props:{$$slots:{default:[of]},$$scope:{ctx:H}}}),d=new S({props:{code:`from transformers import Trainer

trainer = Trainer(
    model=model,
    args=args,
    train_dataset=train_dataset,
    eval_dataset=validation_dataset,
    tokenizer=tokenizer,
)
trainer.train()`,highlighted:`<span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> Trainer

trainer = Trainer(
    model=model,
    args=args,
    train_dataset=train_dataset,
    eval_dataset=validation_dataset,
    tokenizer=tokenizer,
)
trainer.train()`}}),{c(){j(o.$$.fragment),v=p(),g=c("p"),y=s("Cu\u1ED1i c\xF9ng, ta ch\u1EC9 c\u1EA7n truy\u1EC1n m\u1ECDi th\u1EE9 v\xE0o l\u1EDBp "),D=c("code"),b=s("Trainer"),$=s(" v\xE0 kh\u1EDFi \u0111\u1ED9ng vi\u1EC7c hu\u1EA5n luy\u1EC7n:"),x=p(),j(d.$$.fragment)},l(k){q(o.$$.fragment,k),v=u(k),g=h(k,"P",{});var w=r(g);y=a(w,"Cu\u1ED1i c\xF9ng, ta ch\u1EC9 c\u1EA7n truy\u1EC1n m\u1ECDi th\u1EE9 v\xE0o l\u1EDBp "),D=h(w,"CODE",{});var P=r(D);b=a(P,"Trainer"),P.forEach(n),$=a(w," v\xE0 kh\u1EDFi \u0111\u1ED9ng vi\u1EC7c hu\u1EA5n luy\u1EC7n:"),w.forEach(n),x=u(k),q(d.$$.fragment,k)},m(k,w){E(o,k,w),i(k,v,w),i(k,g,w),e(g,y),e(g,D),e(D,b),e(g,$),i(k,x,w),E(d,k,w),B=!0},i(k){B||(f(o.$$.fragment,k),f(d.$$.fragment,k),B=!0)},o(k){_(o.$$.fragment,k),_(d.$$.fragment,k),B=!1},d(k){C(o,k),k&&n(v),k&&n(g),k&&n(x),C(d,k)}}}function of(H){let o,v,g,y,D;return{c(){o=c("p"),v=s("\u{1F4A1} N\u1EBFu th\u01B0 m\u1EE5c \u0111\u1EA7u ra b\u1EA1n \u0111ang s\u1EED d\u1EE5ng t\u1ED3n t\u1EA1i, n\xF3 c\u1EA7n ph\u1EA3i l\xE0 b\u1EA3n sao c\u1EE5c b\u1ED9 c\u1EE7a kho l\u01B0u tr\u1EEF m\xE0 b\u1EA1n mu\u1ED1n \u0111\u1EA9y \u0111\u1EBFn (v\xEC v\u1EADy h\xE3y \u0111\u1EB7t t\xEAn m\u1EDBi n\u1EBFu b\u1EA1n g\u1EB7p l\u1ED7i khi x\xE1c \u0111\u1ECBnh "),g=c("code"),y=s("Trainer"),D=s(" c\u1EE7a m\xECnh).")},l(b){o=h(b,"P",{});var $=r(o);v=a($,"\u{1F4A1} N\u1EBFu th\u01B0 m\u1EE5c \u0111\u1EA7u ra b\u1EA1n \u0111ang s\u1EED d\u1EE5ng t\u1ED3n t\u1EA1i, n\xF3 c\u1EA7n ph\u1EA3i l\xE0 b\u1EA3n sao c\u1EE5c b\u1ED9 c\u1EE7a kho l\u01B0u tr\u1EEF m\xE0 b\u1EA1n mu\u1ED1n \u0111\u1EA9y \u0111\u1EBFn (v\xEC v\u1EADy h\xE3y \u0111\u1EB7t t\xEAn m\u1EDBi n\u1EBFu b\u1EA1n g\u1EB7p l\u1ED7i khi x\xE1c \u0111\u1ECBnh "),g=h($,"CODE",{});var x=r(g);y=a(x,"Trainer"),x.forEach(n),D=a($," c\u1EE7a m\xECnh)."),$.forEach(n)},m(b,$){i(b,o,$),e(o,v),e(o,g),e(g,y),e(o,D)},d(b){b&&n(o)}}}function pf(H){let o,v,g,y,D,b,$,x,d,B,k,w,P,L;return P=new S({props:{code:`predictions = model.predict(tf_eval_dataset)
compute_metrics(
    predictions["start_logits"],
    predictions["end_logits"],
    validation_dataset,
    raw_datasets["validation"],
)`,highlighted:`predictions = model.predict(tf_eval_dataset)
compute_metrics(
    predictions[<span class="hljs-string">&quot;start_logits&quot;</span>],
    predictions[<span class="hljs-string">&quot;end_logits&quot;</span>],
    validation_dataset,
    raw_datasets[<span class="hljs-string">&quot;validation&quot;</span>],
)`}}),{c(){o=c("p"),v=s("Sau khi qu\xE1 tr\xECnh hu\u1EA5n luy\u1EC7n ho\xE0n t\u1EA5t, cu\u1ED1i c\xF9ng ta c\u0169ng c\xF3 th\u1EC3 \u0111\xE1nh gi\xE1 m\xF4 h\xECnh c\u1EE7a m\xECnh (v\xE0 c\u1EA7u nguy\u1EC7n r\u1EB1ng ta \u0111\xE3 kh\xF4ng d\xE0nh t\u1EA5t c\u1EA3 th\u1EDDi gian t\xEDnh to\xE1n v\xE0o vi\u1EC7c g\xEC). Ph\u01B0\u01A1ng th\u1EE9c "),g=c("code"),y=s("predict()"),D=s(" c\u1EE7a "),b=c("code"),$=s("model"),x=s(" s\u1EBD \u0111\u1EA3m nh\u1EADn vi\u1EC7c nh\u1EADn c\xE1c d\u1EF1 \u0111o\xE1n v\xE0 v\xEC ta \u0111\xE3 th\u1EF1c hi\u1EC7n t\u1EA5t c\u1EA3 c\xE1c c\xF4ng vi\u1EC7c kh\xF3 kh\u0103n trong vi\u1EC7c x\xE1c \u0111\u1ECBnh m\u1ED9t h\xE0m "),d=c("code"),B=s("compute_metrics()"),k=s(" tr\u01B0\u1EDBc \u0111\xF3, ch\xFAng ta c\xF3 th\u1EC3 nh\u1EADn \u0111\u01B0\u1EE3c k\u1EBFt qu\u1EA3 c\u1EE7a m\xECnh trong m\u1ED9t d\xF2ng duy nh\u1EA5t:"),w=p(),j(P.$$.fragment)},l(N){o=h(N,"P",{});var T=r(o);v=a(T,"Sau khi qu\xE1 tr\xECnh hu\u1EA5n luy\u1EC7n ho\xE0n t\u1EA5t, cu\u1ED1i c\xF9ng ta c\u0169ng c\xF3 th\u1EC3 \u0111\xE1nh gi\xE1 m\xF4 h\xECnh c\u1EE7a m\xECnh (v\xE0 c\u1EA7u nguy\u1EC7n r\u1EB1ng ta \u0111\xE3 kh\xF4ng d\xE0nh t\u1EA5t c\u1EA3 th\u1EDDi gian t\xEDnh to\xE1n v\xE0o vi\u1EC7c g\xEC). Ph\u01B0\u01A1ng th\u1EE9c "),g=h(T,"CODE",{});var F=r(g);y=a(F,"predict()"),F.forEach(n),D=a(T," c\u1EE7a "),b=h(T,"CODE",{});var I=r(b);$=a(I,"model"),I.forEach(n),x=a(T," s\u1EBD \u0111\u1EA3m nh\u1EADn vi\u1EC7c nh\u1EADn c\xE1c d\u1EF1 \u0111o\xE1n v\xE0 v\xEC ta \u0111\xE3 th\u1EF1c hi\u1EC7n t\u1EA5t c\u1EA3 c\xE1c c\xF4ng vi\u1EC7c kh\xF3 kh\u0103n trong vi\u1EC7c x\xE1c \u0111\u1ECBnh m\u1ED9t h\xE0m "),d=h(T,"CODE",{});var z=r(d);B=a(z,"compute_metrics()"),z.forEach(n),k=a(T," tr\u01B0\u1EDBc \u0111\xF3, ch\xFAng ta c\xF3 th\u1EC3 nh\u1EADn \u0111\u01B0\u1EE3c k\u1EBFt qu\u1EA3 c\u1EE7a m\xECnh trong m\u1ED9t d\xF2ng duy nh\u1EA5t:"),T.forEach(n),w=u(N),q(P.$$.fragment,N)},m(N,T){i(N,o,T),e(o,v),e(o,g),e(g,y),e(o,D),e(o,b),e(b,$),e(o,x),e(o,d),e(d,B),e(o,k),i(N,w,T),E(P,N,T),L=!0},i(N){L||(f(P.$$.fragment,N),L=!0)},o(N){_(P.$$.fragment,N),L=!1},d(N){N&&n(o),N&&n(w),C(P,N)}}}function uf(H){let o,v,g,y,D,b,$,x,d,B,k,w,P,L;return P=new S({props:{code:`predictions, _, _ = trainer.predict(validation_dataset)
start_logits, end_logits = predictions
compute_metrics(start_logits, end_logits, validation_dataset, raw_datasets["validation"])`,highlighted:`predictions, _, _ = trainer.predict(validation_dataset)
start_logits, end_logits = predictions
compute_metrics(start_logits, end_logits, validation_dataset, raw_datasets[<span class="hljs-string">&quot;validation&quot;</span>])`}}),{c(){o=c("p"),v=s("Sau khi qu\xE1 tr\xECnh hu\u1EA5n luy\u1EC7n ho\xE0n t\u1EA5t, cu\u1ED1i c\xF9ng ta c\u0169ng c\xF3 th\u1EC3 \u0111\xE1nh gi\xE1 m\xF4 h\xECnh c\u1EE7a m\xECnh (v\xE0 c\u1EA7u nguy\u1EC7n r\u1EB1ng ta \u0111\xE3 kh\xF4ng d\xE0nh t\u1EA5t c\u1EA3 th\u1EDDi gian t\xEDnh to\xE1n v\xE0o vi\u1EC7c g\xEC). Ph\u01B0\u01A1ng th\u1EE9c "),g=c("code"),y=s("predict()"),D=s(" c\u1EE7a "),b=c("code"),$=s("Trainer"),x=s(" s\u1EBD tr\u1EA3 v\u1EC1 m\u1ED9t b\u1ED9 gi\xE1 tr\u1ECB trong \u0111\xF3 c\xE1c ph\u1EA7n t\u1EED \u0111\u1EA7u ti\xEAn s\u1EBD l\xE0 c\xE1c d\u1EF1 \u0111o\xE1n c\u1EE7a m\xF4 h\xECnh (\u1EDF \u0111\xE2y l\xE0 m\u1ED9t c\u1EB7p v\u1EDBi c\xE1c logit b\u1EAFt \u0111\u1EA7u v\xE0 k\u1EBFt th\xFAc). Ch\xFAng ta g\u1EEDi ch\xFAng \u0111\u1EBFn h\xE0m "),d=c("code"),B=s("compute_metrics())"),k=s(" c\u1EE7a m\xECnh:"),w=p(),j(P.$$.fragment)},l(N){o=h(N,"P",{});var T=r(o);v=a(T,"Sau khi qu\xE1 tr\xECnh hu\u1EA5n luy\u1EC7n ho\xE0n t\u1EA5t, cu\u1ED1i c\xF9ng ta c\u0169ng c\xF3 th\u1EC3 \u0111\xE1nh gi\xE1 m\xF4 h\xECnh c\u1EE7a m\xECnh (v\xE0 c\u1EA7u nguy\u1EC7n r\u1EB1ng ta \u0111\xE3 kh\xF4ng d\xE0nh t\u1EA5t c\u1EA3 th\u1EDDi gian t\xEDnh to\xE1n v\xE0o vi\u1EC7c g\xEC). Ph\u01B0\u01A1ng th\u1EE9c "),g=h(T,"CODE",{});var F=r(g);y=a(F,"predict()"),F.forEach(n),D=a(T," c\u1EE7a "),b=h(T,"CODE",{});var I=r(b);$=a(I,"Trainer"),I.forEach(n),x=a(T," s\u1EBD tr\u1EA3 v\u1EC1 m\u1ED9t b\u1ED9 gi\xE1 tr\u1ECB trong \u0111\xF3 c\xE1c ph\u1EA7n t\u1EED \u0111\u1EA7u ti\xEAn s\u1EBD l\xE0 c\xE1c d\u1EF1 \u0111o\xE1n c\u1EE7a m\xF4 h\xECnh (\u1EDF \u0111\xE2y l\xE0 m\u1ED9t c\u1EB7p v\u1EDBi c\xE1c logit b\u1EAFt \u0111\u1EA7u v\xE0 k\u1EBFt th\xFAc). Ch\xFAng ta g\u1EEDi ch\xFAng \u0111\u1EBFn h\xE0m "),d=h(T,"CODE",{});var z=r(d);B=a(z,"compute_metrics())"),z.forEach(n),k=a(T," c\u1EE7a m\xECnh:"),T.forEach(n),w=u(N),q(P.$$.fragment,N)},m(N,T){i(N,o,T),e(o,v),e(o,g),e(g,y),e(o,D),e(o,b),e(b,$),e(o,x),e(o,d),e(d,B),e(o,k),i(N,w,T),E(P,N,T),L=!0},i(N){L||(f(P.$$.fragment,N),L=!0)},o(N){_(P.$$.fragment,N),L=!1},d(N){N&&n(o),N&&n(w),C(P,N)}}}function Md(H){let o,v,g,y,D,b,$,x,d,B,k,w,P,L,N,T,F,I;return $=new S({props:{code:'trainer.push_to_hub(commit_message="Training complete")',highlighted:'trainer.push_to_hub(commit_message=<span class="hljs-string">&quot;Training complete&quot;</span>)'}}),w=new S({props:{code:"'https://huggingface.co/sgugger/bert-finetuned-squad/commit/9dcee1fbc25946a6ed4bb32efb1bd71d5fa90b68'",highlighted:'<span class="hljs-string">&#x27;https://huggingface.co/sgugger/bert-finetuned-squad/commit/9dcee1fbc25946a6ed4bb32efb1bd71d5fa90b68&#x27;</span>'}}),{c(){o=c("p"),v=s("Cu\u1ED1i c\xF9ng, ta s\u1EED d\u1EE5ng ph\u01B0\u01A1ng th\u1EE9c "),g=c("code"),y=s("push_to_hub()"),D=s(" \u0111\u1EC3 \u0111\u1EA3m b\u1EA3o ta s\u1EBD t\u1EA3i phi\xEAn b\u1EA3n m\u1EDBi nh\u1EA5t c\u1EE7a m\xF4 h\xECnh:"),b=p(),j($.$$.fragment),x=p(),d=c("p"),B=s("\u0110i\u1EC1u n\xE0y tr\u1EA3 v\u1EC1 URL c\u1EE7a cam k\u1EBFt m\xE0 n\xF3 v\u1EEBa th\u1EF1c hi\u1EC7n, n\u1EBFu b\u1EA1n mu\u1ED1n ki\u1EC3m tra n\xF3:"),k=p(),j(w.$$.fragment),P=p(),L=c("p"),N=c("code"),T=s("Trainer"),F=s(" c\u0169ng so\u1EA1n th\u1EA3o m\u1ED9t th\u1EBB m\xF4 h\xECnh v\u1EDBi t\u1EA5t c\u1EA3 c\xE1c k\u1EBFt qu\u1EA3 \u0111\xE1nh gi\xE1 v\xE0 t\u1EA3i n\xF3 l\xEAn.")},l(z){o=h(z,"P",{});var R=r(o);v=a(R,"Cu\u1ED1i c\xF9ng, ta s\u1EED d\u1EE5ng ph\u01B0\u01A1ng th\u1EE9c "),g=h(R,"CODE",{});var G=r(g);y=a(G,"push_to_hub()"),G.forEach(n),D=a(R," \u0111\u1EC3 \u0111\u1EA3m b\u1EA3o ta s\u1EBD t\u1EA3i phi\xEAn b\u1EA3n m\u1EDBi nh\u1EA5t c\u1EE7a m\xF4 h\xECnh:"),R.forEach(n),b=u(z),q($.$$.fragment,z),x=u(z),d=h(z,"P",{});var V=r(d);B=a(V,"\u0110i\u1EC1u n\xE0y tr\u1EA3 v\u1EC1 URL c\u1EE7a cam k\u1EBFt m\xE0 n\xF3 v\u1EEBa th\u1EF1c hi\u1EC7n, n\u1EBFu b\u1EA1n mu\u1ED1n ki\u1EC3m tra n\xF3:"),V.forEach(n),k=u(z),q(w.$$.fragment,z),P=u(z),L=h(z,"P",{});var J=r(L);N=h(J,"CODE",{});var U=r(N);T=a(U,"Trainer"),U.forEach(n),F=a(J," c\u0169ng so\u1EA1n th\u1EA3o m\u1ED9t th\u1EBB m\xF4 h\xECnh v\u1EDBi t\u1EA5t c\u1EA3 c\xE1c k\u1EBFt qu\u1EA3 \u0111\xE1nh gi\xE1 v\xE0 t\u1EA3i n\xF3 l\xEAn."),J.forEach(n)},m(z,R){i(z,o,R),e(o,v),e(o,g),e(g,y),e(o,D),i(z,b,R),E($,z,R),i(z,x,R),i(z,d,R),e(d,B),i(z,k,R),E(w,z,R),i(z,P,R),i(z,L,R),e(L,N),e(N,T),e(L,F),I=!0},i(z){I||(f($.$$.fragment,z),f(w.$$.fragment,z),I=!0)},o(z){_($.$$.fragment,z),_(w.$$.fragment,z),I=!1},d(z){z&&n(o),z&&n(b),C($,z),z&&n(x),z&&n(d),z&&n(k),C(w,z),z&&n(P),z&&n(L)}}}function mf(H){let o,v,g,y,D;return{c(){o=c("p"),v=s("\u270F\uFE0F "),g=c("strong"),y=s("\u0110\u1EBFn l\u01B0\u1EE3t b\u1EA1n!"),D=s(" H\xE3y th\u1EED m\u1ED9t ki\u1EBFn tr\xFAc m\xF4 h\xECnh kh\xE1c \u0111\u1EC3 xem li\u1EC7u n\xF3 c\xF3 ho\u1EA1t \u0111\u1ED9ng t\u1ED1t h\u01A1n trong t\xE1c v\u1EE5 n\xE0y kh\xF4ng!")},l(b){o=h(b,"P",{});var $=r(o);v=a($,"\u270F\uFE0F "),g=h($,"STRONG",{});var x=r(g);y=a(x,"\u0110\u1EBFn l\u01B0\u1EE3t b\u1EA1n!"),x.forEach(n),D=a($," H\xE3y th\u1EED m\u1ED9t ki\u1EBFn tr\xFAc m\xF4 h\xECnh kh\xE1c \u0111\u1EC3 xem li\u1EC7u n\xF3 c\xF3 ho\u1EA1t \u0111\u1ED9ng t\u1ED1t h\u01A1n trong t\xE1c v\u1EE5 n\xE0y kh\xF4ng!"),$.forEach(n)},m(b,$){i(b,o,$),e(o,v),e(o,g),e(g,y),e(o,D)},d(b){b&&n(o)}}}function Od(H){let o,v,g,y,D,b,$,x,d,B,k,w,P,L,N,T,F,I,z,R,G,V,J,U,O,K,Y,nt,W,ct,_t,Tt,at,en,Ft,Q,X,Dt,ie,sn,fn,ut,an,et,vt,mt,At,ks,Ht,ys,It,Pt,Le,_n,Da,xs,xt,$s,lt,ws,$t,ln,Fe,Vt,Aa,He,Ie,js,cn,Ve,Qe,Pa,Ge,qs,vn,Re,St,Es,wt,bn,le,kn,Cs,ot,Sa,Ke,Ts,yn,ce,bt,Ba,xn,Na,Ma,he,$n,Ds,Qt,As,st,Ps,Gt,Ss,wn,re,oe,Oa,pe,jn,Bs,kt,za,We,Ue,La,Xe,Je,Fa,Ns,Bt,gt,Ye,Rt,Ha,Ze,Ms,hn,qn,En,ts,dt,Cn,Os,Kt,zs,Tn,Ls,pt,Ia,ue,Dn,Fs,Wt,Hs,me,ns,Is,Ut,rn,jt,An,es,ss,Va,ge,Pn,Vs,Sn,de,Qs,Bn,Nn,as,Nt,Gs,ft,Mn,on,Z,Qa,On,Ga,Ra,zn,Ka,Wa,fe,Ln,Rs,Xt,Ks,_e,is,Ws,Fn,ve,be,Ua,ke,Hn,Us,pn,qt,ye,ls,Xs,Jt,Et,Js,Xa,In,Ja;return $=new nn({}),U=new nn({}),et=new S({props:{code:`from torch.utils.data import DataLoader
from transformers import default_data_collator

train_dataset.set_format("torch")
validation_set = validation_dataset.remove_columns(["example_id", "offset_mapping"])
validation_set.set_format("torch")

train_dataloader = DataLoader(
    train_dataset,
    shuffle=True,
    collate_fn=default_data_collator,
    batch_size=8,
)
eval_dataloader = DataLoader(
    validation_set, collate_fn=default_data_collator, batch_size=8
)`,highlighted:`<span class="hljs-keyword">from</span> torch.utils.data <span class="hljs-keyword">import</span> DataLoader
<span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> default_data_collator

train_dataset.set_format(<span class="hljs-string">&quot;torch&quot;</span>)
validation_set = validation_dataset.remove_columns([<span class="hljs-string">&quot;example_id&quot;</span>, <span class="hljs-string">&quot;offset_mapping&quot;</span>])
validation_set.set_format(<span class="hljs-string">&quot;torch&quot;</span>)

train_dataloader = DataLoader(
    train_dataset,
    shuffle=<span class="hljs-literal">True</span>,
    collate_fn=default_data_collator,
    batch_size=<span class="hljs-number">8</span>,
)
eval_dataloader = DataLoader(
    validation_set, collate_fn=default_data_collator, batch_size=<span class="hljs-number">8</span>
)`}}),Ht=new S({props:{code:"model = AutoModelForQuestionAnswering.from_pretrained(model_checkpoint)",highlighted:"model = AutoModelForQuestionAnswering.from_pretrained(model_checkpoint)"}}),xt=new S({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 S({props:{code:`from accelerate import Accelerator

accelerator = Accelerator(fp16=True)
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(fp16=<span class="hljs-literal">True</span>)
model, optimizer, train_dataloader, eval_dataloader = accelerator.prepare(
    model, optimizer, train_dataloader, eval_dataloader
)`}}),yn=new S({props:{code:`from transformers import get_scheduler

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

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

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

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

model_name = "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> Repository, get_full_repo_name

model_name = <span class="hljs-string">&quot;bert-finetuned-squad-accelerate&quot;</span>
repo_name = get_full_repo_name(model_name)
repo_name`}}),wn=new S({props:{code:"'sgugger/bert-finetuned-squad-accelerate'",highlighted:'<span class="hljs-string">&#x27;sgugger/bert-finetuned-squad-accelerate&#x27;</span>'}}),jn=new S({props:{code:`output_dir = "bert-finetuned-squad-accelerate"
repo = Repository(output_dir, clone_from=repo_name)`,highlighted:`output_dir = <span class="hljs-string">&quot;bert-finetuned-squad-accelerate&quot;</span>
repo = Repository(output_dir, clone_from=repo_name)`}}),Rt=new nn({}),Nn=new S({props:{code:`from tqdm.auto import tqdm
import torch

progress_bar = tqdm(range(num_training_steps))

for epoch in range(num_train_epochs):
    # 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()
    start_logits = []
    end_logits = []
    accelerator.print("Evaluation!")
    for batch in tqdm(eval_dataloader):
        with torch.no_grad():
            outputs = model(**batch)

        start_logits.append(accelerator.gather(outputs.start_logits).cpu().numpy())
        end_logits.append(accelerator.gather(outputs.end_logits).cpu().numpy())

    start_logits = np.concatenate(start_logits)
    end_logits = np.concatenate(end_logits)
    start_logits = start_logits[: len(validation_dataset)]
    end_logits = end_logits[: len(validation_dataset)]

    metrics = compute_metrics(
        start_logits, end_logits, validation_dataset, raw_datasets["validation"]
    )
    print(f"epoch {epoch}:", metrics)

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

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

<span class="hljs-keyword">for</span> epoch <span class="hljs-keyword">in</span> <span class="hljs-built_in">range</span>(num_train_epochs):
    <span class="hljs-comment"># Hu\u1EA5n luy\u1EC7n</span>
    model.train()
    <span class="hljs-keyword">for</span> 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>()
    start_logits = []
    end_logits = []
    accelerator.<span class="hljs-built_in">print</span>(<span class="hljs-string">&quot;Evaluation!&quot;</span>)
    <span class="hljs-keyword">for</span> batch <span class="hljs-keyword">in</span> tqdm(eval_dataloader):
        <span class="hljs-keyword">with</span> torch.no_grad():
            outputs = model(**batch)

        start_logits.append(accelerator.gather(outputs.start_logits).cpu().numpy())
        end_logits.append(accelerator.gather(outputs.end_logits).cpu().numpy())

    start_logits = np.concatenate(start_logits)
    end_logits = np.concatenate(end_logits)
    start_logits = start_logits[: <span class="hljs-built_in">len</span>(validation_dataset)]
    end_logits = end_logits[: <span class="hljs-built_in">len</span>(validation_dataset)]

    metrics = compute_metrics(
        start_logits, end_logits, validation_dataset, raw_datasets[<span class="hljs-string">&quot;validation&quot;</span>]
    )
    <span class="hljs-built_in">print</span>(<span class="hljs-string">f&quot;epoch <span class="hljs-subst">{epoch}</span>:&quot;</span>, metrics)

    <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>
        )`}}),Mn=new S({props:{code:`accelerator.wait_for_everyone()
unwrapped_model = accelerator.unwrap_model(model)
unwrapped_model.save_pretrained(output_dir, save_function=accelerator.save)`,highlighted:`accelerator.wait_for_everyone()
unwrapped_model = accelerator.unwrap_model(model)
unwrapped_model.save_pretrained(output_dir, save_function=accelerator.save)`}}),{c(){o=c("p"),v=s("N\u1EBFu b\u1EA1n mu\u1ED1n t\xECm hi\u1EC3u s\xE2u h\u01A1n m\u1ED9t ch\xFAt v\u1EC1 v\xF2ng hu\u1EA5n luy\u1EC7n, b\xE2y gi\u1EDD ch\xFAng t\xF4i s\u1EBD h\u01B0\u1EDBng d\u1EABn b\u1EA1n c\xE1ch th\u1EF1c hi\u1EC7n \u0111i\u1EC1u t\u01B0\u01A1ng t\u1EF1 b\u1EB1ng c\xE1ch s\u1EED d\u1EE5ng \u{1F917} Accelerate."),g=p(),y=c("h2"),D=c("a"),b=c("span"),j($.$$.fragment),x=p(),d=c("span"),B=s("M\u1ED9t v\xF2ng l\u1EB7p hu\u1EA5n luy\u1EC7n tu\u1EF3 ch\u1EC9nh"),k=p(),w=c("p"),P=s("B\xE2y gi\u1EDD ch\xFAng ta h\xE3y xem to\xE0n b\u1ED9 v\xF2ng l\u1EB7p hu\u1EA5n luy\u1EC7n, v\xEC v\u1EADy b\u1EA1n c\xF3 th\u1EC3 d\u1EC5 d\xE0ng t\xF9y ch\u1EC9nh c\xE1c ph\u1EA7n b\u1EA1n c\u1EA7n. N\xF3 s\u1EBD tr\xF4ng r\u1EA5t gi\u1ED1ng v\u1EDBi v\xF2ng l\u1EB7p hu\u1EA5n luy\u1EC7n trong "),L=c("a"),N=s("Ch\u01B0\u01A1ng 3"),T=s(", ngo\u1EA1i tr\u1EEB v\xF2ng l\u1EB7p \u0111\xE1nh gi\xE1. Ch\xFAng ta s\u1EBD c\xF3 th\u1EC3 \u0111\xE1nh gi\xE1 m\xF4 h\xECnh th\u01B0\u1EDDng xuy\xEAn v\xEC ta kh\xF4ng b\u1ECB h\u1EA1n ch\u1EBF b\u1EDFi l\u1EDBp "),F=c("code"),I=s("Trainer"),z=s(" n\u1EEFa."),R=p(),G=c("h3"),V=c("a"),J=c("span"),j(U.$$.fragment),O=p(),K=c("span"),Y=s("Chu\u1EA5n b\u1ECB m\u1ECDi th\u1EE9 cho hu\u1EA5n luy\u1EC7n"),nt=p(),W=c("p"),ct=s("\u0110\u1EA7u ti\xEAn, ch\xFAng ta c\u1EA7n x\xE2y d\u1EF1ng c\xE1c "),_t=c("code"),Tt=s("DataLoader"),at=s(" t\u1EEB c\xE1c t\u1EADp d\u1EEF li\u1EC7u c\u1EE7a m\xECnh. Ch\xFAng ta \u0111\u1EB7t \u0111\u1ECBnh d\u1EA1ng c\u1EE7a c\xE1c t\u1EADp d\u1EEF li\u1EC7u \u0111\xF3 th\xE0nh "),en=c("code"),Ft=s('"torch"'),Q=s(" v\xE0 x\xF3a c\xE1c c\u1ED9t trong t\u1EADp x\xE1c th\u1EF1c kh\xF4ng \u0111\u01B0\u1EE3c m\xF4 h\xECnh s\u1EED d\u1EE5ng. Sau \u0111\xF3, ch\xFAng ta c\xF3 th\u1EC3 s\u1EED d\u1EE5ng "),X=c("code"),Dt=s("default_data_collator"),ie=s(" \u0111\u01B0\u1EE3c cung c\u1EA5p b\u1EDFi Transformers d\u01B0\u1EDBi d\u1EA1ng "),sn=c("code"),fn=s("collate_fn"),ut=s(" v\xE0 x\xE1o tr\u1ED9n b\u1ED9 hu\u1EA5n luy\u1EC7n, nh\u01B0ng kh\xF4ng ph\u1EA3i b\u1ED9 ki\u1EC3m \u0111\u1ECBnh:"),an=p(),j(et.$$.fragment),vt=p(),mt=c("p"),At=s("Ti\u1EBFp theo, ch\xFAng ta kh\xF4i ph\u1EE5c m\xF4 h\xECnh c\u1EE7a m\xECnh, \u0111\u1EC3 \u0111\u1EA3m b\u1EA3o r\u1EB1ng ta kh\xF4ng ti\u1EBFp t\u1EE5c tinh ch\u1EC9nh t\u1EEB tr\u01B0\u1EDBc m\xE0 b\u1EAFt \u0111\u1EA7u l\u1EA1i t\u1EEB m\xF4 h\xECnh \u0111\u01B0\u1EE3c hu\u1EA5n luy\u1EC7n tr\u01B0\u1EDBc BERT:"),ks=p(),j(Ht.$$.fragment),ys=p(),It=c("p"),Pt=s("Sau \u0111\xF3, ch\xFAng ta s\u1EBD c\u1EA7n m\u1ED9t tr\xECnh t\u1ED1i \u01B0u h\xF3a. Nh\u01B0 th\u01B0\u1EDDng l\u1EC7, ta s\u1EED d\u1EE5ng "),Le=c("code"),_n=s("AdamW"),Da=s(" c\u1ED5 \u0111i\u1EC3n, gi\u1ED1ng nh\u01B0 Adam, nh\u01B0ng v\u1EDBi m\u1ED9t b\u1EA3n s\u1EEDa l\u1ED7i trong c\xE1ch ph\xE2n r\xE3 tr\u1ECDng s\u1ED1 \u0111\u01B0\u1EE3c \xE1p d\u1EE5ng:"),xs=p(),j(xt.$$.fragment),$s=p(),lt=c("p"),ws=s("Khi ch\xFAng ta c\xF3 t\u1EA5t c\u1EA3 c\xE1c \u0111\u1ED1i t\u01B0\u1EE3ng \u0111\xF3, ch\xFAng ta c\xF3 th\u1EC3 g\u1EEDi ch\xFAng \u0111\u1EBFn ph\u01B0\u01A1ng th\u1EE9c "),$t=c("code"),ln=s("accelerator.prepare()"),Fe=s(". H\xE3y nh\u1EDB r\u1EB1ng n\u1EBFu b\u1EA1n mu\u1ED1n hu\u1EA5n luy\u1EC7n v\u1EC1 TPU trong notebook Colab, b\u1EA1n s\u1EBD c\u1EA7n chuy\u1EC3n t\u1EA5t c\u1EA3 m\xE3 n\xE0y v\xE0o m\u1ED9t h\xE0m hu\u1EA5n luy\u1EC7n v\xE0 \u0111i\u1EC1u \u0111\xF3 s\u1EBD kh\xF4ng th\u1EF1c thi b\u1EA5t k\u1EF3 \xF4 kh\u1EDFi t\u1EA1o m\u1ED9t "),Vt=c("code"),Aa=s("Accelerator"),He=s(" n\xE0o. Ch\xFAng ta c\xF3 th\u1EC3 bu\u1ED9c hu\u1EA5n luy\u1EC7n \u0111\u1ED9 ch\xEDnh x\xE1c h\u1ED7n h\u1EE3p b\u1EB1ng c\xE1ch chuy\u1EC3n "),Ie=c("code"),js=s("fp16=True"),cn=s(" v\xE0o "),Ve=c("code"),Qe=s("Accelerator"),Pa=s(" (ho\u1EB7c, n\u1EBFu b\u1EA1n \u0111ang th\u1EF1c thi m\xE3 d\u01B0\u1EDBi d\u1EA1ng t\u1EADp l\u1EC7nh, ch\u1EC9 c\u1EA7n \u0111\u1EA3m b\u1EA3o \u0111i\u1EC1n v\xE0o \u{1F917} Accelerate "),Ge=c("code"),qs=s("config"),vn=s(" m\u1ED9t c\xE1ch th\xEDch h\u1EE3p)."),Re=p(),j(St.$$.fragment),Es=p(),wt=c("p"),bn=s("Nh\u01B0 b\u1EA1n \u0111\xE3 bi\u1EBFt t\u1EEB c\xE1c ph\u1EA7n tr\u01B0\u1EDBc, ch\xFAng ta ch\u1EC9 c\xF3 th\u1EC3 s\u1EED d\u1EE5ng \u0111\u1ED9 d\xE0i "),le=c("code"),kn=s("train_dataloader"),Cs=s(" \u0111\u1EC3 t\xEDnh s\u1ED1 b\u01B0\u1EDBc hu\u1EA5n luy\u1EC7n sau khi n\xF3 \u0111\xE3 tr\u1EA3i qua ph\u01B0\u01A1ng th\u1EE9c "),ot=c("code"),Sa=s("accelerator.prepare()"),Ke=s(". Ch\xFAng ta s\u1EED d\u1EE5ng c\xF9ng m\u1ED9t l\u1ECBch tr\xECnh tuy\u1EBFn t\xEDnh nh\u01B0 trong c\xE1c ph\u1EA7n tr\u01B0\u1EDBc:"),Ts=p(),j(yn.$$.fragment),ce=p(),bt=c("p"),Ba=s("\u0110\u1EC3 \u0111\u1EA9y m\xF4 h\xECnh c\u1EE7a m\xECnh l\xEAn Hub, ch\xFAng ta s\u1EBD c\u1EA7n t\u1EA1o m\u1ED9t \u0111\u1ED1i t\u01B0\u1EE3ng "),xn=c("code"),Na=s("Repository"),Ma=s(" trong m\u1ED9t th\u01B0 m\u1EE5c \u0111ang l\xE0m vi\u1EC7c. \u0110\u1EA7u ti\xEAn h\xE3y \u0111\u0103ng nh\u1EADp v\xE0o Hugging Face Hub, n\u1EBFu b\u1EA1n ch\u01B0a \u0111\u0103ng nh\u1EADp. Ch\xFAng ta s\u1EBD x\xE1c \u0111\u1ECBnh t\xEAn kho l\u01B0u tr\u1EEF t\u1EEB ID m\xF4 h\xECnh m\xE0 ta mu\u1ED1n cung c\u1EA5p cho m\xF4 h\xECnh c\u1EE7a m\xECnh (vui l\xF2ng thay th\u1EBF "),he=c("code"),$n=s("repo_name"),Ds=s(" b\u1EB1ng s\u1EF1 l\u1EF1a ch\u1ECDn c\u1EE7a ri\xEAng b\u1EA1n; n\xF3 ch\u1EC9 c\u1EA7n ch\u1EE9a t\xEAn ng\u01B0\u1EDDi d\xF9ng c\u1EE7a b\u1EA1n, \u0111\xF3 l\xE0 nh\u1EEFng g\xEC h\xE0m "),Qt=c("code"),As=s("get_full_repo_name()"),st=s(" th\u1EF1c hi\u1EC7n ):"),Ps=p(),j(Gt.$$.fragment),Ss=p(),j(wn.$$.fragment),re=p(),oe=c("p"),Oa=s("Sau \u0111\xF3, ch\xFAng ta c\xF3 th\u1EC3 sao ch\xE9p kho l\u01B0u tr\u1EEF \u0111\xF3 trong m\u1ED9t th\u01B0 m\u1EE5c c\u1EE5c b\u1ED9. N\u1EBFu n\xF3 \u0111\xE3 t\u1ED3n t\u1EA1i, th\u01B0 m\u1EE5c c\u1EE5c b\u1ED9 n\xE0y ph\u1EA3i l\xE0 b\u1EA3n sao c\u1EE7a kho l\u01B0u tr\u1EEF m\xE0 ta \u0111ang l\xE0m vi\u1EC7c:"),pe=p(),j(jn.$$.fragment),Bs=p(),kt=c("p"),za=s("Gi\u1EDD ta c\xF3 th\u1EC3 t\u1EA3i m\u1ECDi th\u1EED ta l\u01B0u trong "),We=c("code"),Ue=s("output_dir"),La=s(" b\u1EB1ng c\xE1ch g\u1ECDi ph\u01B0\u01A1ng th\u1EE9c "),Xe=c("code"),Je=s("repo.push_to_hub()"),Fa=s(". N\xF3 s\u1EBD gi\xFAp ta t\u1EA3i c\xE1c m\xF4 h\xECnh t\u1EE9c th\xEC \u1EDF cu\u1ED1i m\u1ED7i epoch."),Ns=p(),Bt=c("h2"),gt=c("a"),Ye=c("span"),j(Rt.$$.fragment),Ha=p(),Ze=c("span"),Ms=s("V\xF2ng l\u1EB7p hu\u1EA5n luy\u1EC7n"),hn=p(),qn=c("p"),En=s("B\xE2y gi\u1EDD ch\xFAng ta \u0111\xE3 s\u1EB5n s\xE0ng \u0111\u1EC3 vi\u1EBFt v\xF2ng l\u1EB7p hu\u1EA5n luy\u1EC7n \u0111\u1EA7y \u0111\u1EE7. Sau khi x\xE1c \u0111\u1ECBnh thanh ti\u1EBFn tr\xECnh \u0111\u1EC3 theo d\xF5i qu\xE1 tr\xECnh hu\u1EA5n luy\u1EC7n di\u1EC5n ra nh\u01B0 th\u1EBF n\xE0o, v\xF2ng l\u1EB7p c\xF3 ba ph\u1EA7n:"),ts=p(),dt=c("ul"),Cn=c("li"),Os=s("B\u1EA3n th\xE2n qu\xE1 tr\xECnh hu\u1EA5n luy\u1EC7n, l\xE0 s\u1EF1 l\u1EB7p l\u1EA1i c\u1ED5 \u0111i\u1EC3n tr\xEAn "),Kt=c("code"),zs=s("train_dataloader"),Tn=s(", truy\u1EC1n th\u1EB3ng qua m\xF4 h\xECnh, sau \u0111\xF3 truy\u1EC1n ng\u01B0\u1EE3c v\xE0 t\u1ED1i \u01B0u h\xF3a."),Ls=p(),pt=c("li"),Ia=s("B\u01B0\u1EDBc \u0111\xE1nh gi\xE1, trong \u0111\xF3 ta thu th\u1EADp t\u1EA5t c\u1EA3 c\xE1c gi\xE1 tr\u1ECB cho "),ue=c("code"),Dn=s("start_logits"),Fs=s(" v\xE0 "),Wt=c("code"),Hs=s("end_logits"),me=s(" tr\u01B0\u1EDBc khi chuy\u1EC3n \u0111\u1ED5i ch\xFAng th\xE0nh m\u1EA3ng NumPy. Khi v\xF2ng l\u1EB7p \u0111\xE1nh gi\xE1 k\u1EBFt th\xFAc, ch\xFAng ta n\u1ED1i t\u1EA5t c\u1EA3 c\xE1c k\u1EBFt qu\u1EA3. L\u01B0u \xFD r\u1EB1ng ch\xFAng ta c\u1EA7n c\u1EAFt b\u1EDBt v\xEC "),ns=c("code"),Is=s("Accelerator"),Ut=s(" c\xF3 th\u1EC3 \u0111\xE3 th\xEAm m\u1ED9t v\xE0i m\u1EABu v\xE0o cu\u1ED1i \u0111\u1EC3 \u0111\u1EA3m b\u1EA3o ch\xFAng ta c\xF3 c\xF9ng s\u1ED1 l\u01B0\u1EE3ng m\u1EABu trong m\u1ED7i quy tr\xECnh."),rn=p(),jt=c("li"),An=s("L\u01B0u v\xE0 t\u1EA3i l\xEAn, n\u01A1i tr\u01B0\u1EDBc ti\xEAn ch\xFAng ta l\u01B0u m\xF4 h\xECnh v\xE0 tr\xECnh m\xE3 h\xF3a, sau \u0111\xF3 g\u1ECDi "),es=c("code"),ss=s("repo.push_to_hub()"),Va=s(". Nh\u01B0 ch\xFAng ta \u0111\xE3 l\xE0m tr\u01B0\u1EDBc \u0111\xE2y, ch\xFAng ta s\u1EED d\u1EE5ng \u0111\u1ED1i s\u1ED1 "),ge=c("code"),Pn=s("blocking=False"),Vs=s(" \u0111\u1EC3 y\xEAu c\u1EA7u th\u01B0 vi\u1EC7n \u{1F917} Hub \u0111\u1EA9y v\xE0o m\u1ED9t qu\xE1 tr\xECnh kh\xF4ng \u0111\u1ED3ng b\u1ED9. B\u1EB1ng c\xE1ch n\xE0y, qu\xE1 tr\xECnh hu\u1EA5n luy\u1EC7n ti\u1EBFp t\u1EE5c di\u1EC5n ra b\xECnh th\u01B0\u1EDDng v\xE0 l\u1EC7nh (d\xE0i) n\xE0y \u0111\u01B0\u1EE3c th\u1EF1c thi \u1EDF ch\u1EBF \u0111\u1ED9 n\u1EC1n."),Sn=p(),de=c("p"),Qs=s("\u0110\xE2y l\xE0 m\xE3 ho\xE0n ch\u1EC9nh cho v\xF2ng l\u1EB7p hu\u1EA5n luy\u1EC7n:"),Bn=p(),j(Nn.$$.fragment),as=p(),Nt=c("p"),Gs=s("Trong tr\u01B0\u1EDDng h\u1EE3p \u0111\xE2y l\xE0 l\u1EA7n \u0111\u1EA7u ti\xEAn b\u1EA1n th\u1EA5y m\u1ED9t m\xF4 h\xECnh \u0111\u01B0\u1EE3c l\u01B0u b\u1EB1ng \u{1F917} Accelerate, h\xE3y d\xE0nh m\u1ED9t ch\xFAt th\u1EDDi gian \u0111\u1EC3 ki\u1EC3m tra ba d\xF2ng m\xE3 \u0111i k\xE8m v\u1EDBi n\xF3:"),ft=p(),j(Mn.$$.fragment),on=p(),Z=c("p"),Qa=s("D\xF2ng \u0111\u1EA7u ti\xEAn \u0111\xE3 t\u1EF1 gi\u1EA3i th\xEDch: n\xF3 cho t\u1EA5t c\u1EA3 c\xE1c qu\xE1 tr\xECnh ch\u1EDD cho \u0111\u1EBFn khi m\u1ECDi ng\u01B0\u1EDDi \u1EDF giai \u0111o\u1EA1n \u0111\xF3 tr\u01B0\u1EDBc khi ti\u1EBFp t\u1EE5c. \u0110i\u1EC1u n\xE0y l\xE0 \u0111\u1EC3 \u0111\u1EA3m b\u1EA3o r\u1EB1ng ch\xFAng ta c\xF3 c\xF9ng m\u1ED9t m\xF4 h\xECnh trong m\u1ECDi quy tr\xECnh tr\u01B0\u1EDBc khi l\u01B0u. Sau \u0111\xF3, ta l\u1EA5y "),On=c("code"),Ga=s("unwrapped_model"),Ra=s(", l\xE0 m\xF4 h\xECnh c\u01A1 s\u1EDF m\xE0 ta \u0111\xE3 x\xE1c \u0111\u1ECBnh. Ph\u01B0\u01A1ng th\u1EE9c "),zn=c("code"),Ka=s("accelerator.prepare()"),Wa=s(" thay \u0111\u1ED5i m\xF4 h\xECnh \u0111\u1EC3 ho\u1EA1t \u0111\u1ED9ng trong hu\u1EA5n luy\u1EC7n ph\xE2n t\xE1n, v\xEC v\u1EADy n\xF3 s\u1EBD kh\xF4ng c\xF3 ph\u01B0\u01A1ng th\u1EE9c "),fe=c("code"),Ln=s("save_pretrained()"),Rs=s(" n\u1EEFa; ph\u01B0\u01A1ng th\u1EE9c "),Xt=c("code"),Ks=s("accelerator.unwrap_model()"),_e=s(" ho\xE0n t\xE1c b\u01B0\u1EDBc \u0111\xF3. Cu\u1ED1i c\xF9ng, ch\xFAng ta g\u1ECDi "),is=c("code"),Ws=s("save_pretrained()"),Fn=s(" nh\u01B0ng y\xEAu c\u1EA7u ph\u01B0\u01A1ng th\u1EE9c \u0111\xF3 s\u1EED d\u1EE5ng "),ve=c("code"),be=s("accelerator.save()"),Ua=s(" thay v\xEC "),ke=c("code"),Hn=s("torch.save()"),Us=s("."),pn=p(),qt=c("p"),ye=s("Khi \u0111i\u1EC1u n\xE0y \u0111\u01B0\u1EE3c th\u1EF1c hi\u1EC7n, b\u1EA1n s\u1EBD c\xF3 m\u1ED9t m\xF4 h\xECnh t\u1EA1o ra k\u1EBFt qu\u1EA3 kh\xE1 gi\u1ED1ng v\u1EDBi m\xF4 h\xECnh \u0111\u01B0\u1EE3c hu\u1EA5n luy\u1EC7n v\u1EDBi "),ls=c("code"),Xs=s("Trainer"),Jt=s(". B\u1EA1n c\xF3 th\u1EC3 ki\u1EC3m tra m\xF4 h\xECnh m\xE0 ta \u0111\xE3 hu\u1EA5n luy\u1EC7n b\u1EB1ng c\xE1ch s\u1EED d\u1EE5ng m\xE3 n\xE0y t\u1EA1i "),Et=c("a"),Js=c("em"),Xa=s("huggingface-course/bert-finetuned-squad-accelerate"),In=s(". V\xE0 n\u1EBFu b\u1EA1n mu\u1ED1n ki\u1EC3m tra b\u1EA5t k\u1EF3 tinh ch\u1EC9nh n\xE0o \u0111\u1ED1i v\u1EDBi v\xF2ng l\u1EB7p hu\u1EA5n luy\u1EC7n, b\u1EA1n c\xF3 th\u1EC3 tr\u1EF1c ti\u1EBFp th\u1EF1c hi\u1EC7n ch\xFAng b\u1EB1ng c\xE1ch ch\u1EC9nh s\u1EEDa \u0111o\u1EA1n m\xE3 \u0111\u01B0\u1EE3c hi\u1EC3n th\u1ECB \u1EDF tr\xEAn!"),this.h()},l(m){o=h(m,"P",{});var M=r(o);v=a(M,"N\u1EBFu b\u1EA1n mu\u1ED1n t\xECm hi\u1EC3u s\xE2u h\u01A1n m\u1ED9t ch\xFAt v\u1EC1 v\xF2ng hu\u1EA5n luy\u1EC7n, b\xE2y gi\u1EDD ch\xFAng t\xF4i s\u1EBD h\u01B0\u1EDBng d\u1EABn b\u1EA1n c\xE1ch th\u1EF1c hi\u1EC7n \u0111i\u1EC1u t\u01B0\u01A1ng t\u1EF1 b\u1EB1ng c\xE1ch s\u1EED d\u1EE5ng \u{1F917} Accelerate."),M.forEach(n),g=u(m),y=h(m,"H2",{class:!0});var Ys=r(y);D=h(Ys,"A",{id:!0,class:!0,href:!0});var cs=r(D);b=h(cs,"SPAN",{});var nl=r(b);q($.$$.fragment,nl),nl.forEach(n),cs.forEach(n),x=u(Ys),d=h(Ys,"SPAN",{});var el=r(d);B=a(el,"M\u1ED9t v\xF2ng l\u1EB7p hu\u1EA5n luy\u1EC7n tu\u1EF3 ch\u1EC9nh"),el.forEach(n),Ys.forEach(n),k=u(m),w=h(m,"P",{});var un=r(w);P=a(un,"B\xE2y gi\u1EDD ch\xFAng ta h\xE3y xem to\xE0n b\u1ED9 v\xF2ng l\u1EB7p hu\u1EA5n luy\u1EC7n, v\xEC v\u1EADy b\u1EA1n c\xF3 th\u1EC3 d\u1EC5 d\xE0ng t\xF9y ch\u1EC9nh c\xE1c ph\u1EA7n b\u1EA1n c\u1EA7n. N\xF3 s\u1EBD tr\xF4ng r\u1EA5t gi\u1ED1ng v\u1EDBi v\xF2ng l\u1EB7p hu\u1EA5n luy\u1EC7n trong "),L=h(un,"A",{href:!0});var sl=r(L);N=a(sl,"Ch\u01B0\u01A1ng 3"),sl.forEach(n),T=a(un,", ngo\u1EA1i tr\u1EEB v\xF2ng l\u1EB7p \u0111\xE1nh gi\xE1. Ch\xFAng ta s\u1EBD c\xF3 th\u1EC3 \u0111\xE1nh gi\xE1 m\xF4 h\xECnh th\u01B0\u1EDDng xuy\xEAn v\xEC ta kh\xF4ng b\u1ECB h\u1EA1n ch\u1EBF b\u1EDFi l\u1EDBp "),F=h(un,"CODE",{});var al=r(F);I=a(al,"Trainer"),al.forEach(n),z=a(un," n\u1EEFa."),un.forEach(n),R=u(m),G=h(m,"H3",{class:!0});var hs=r(G);V=h(hs,"A",{id:!0,class:!0,href:!0});var rs=r(V);J=h(rs,"SPAN",{});var il=r(J);q(U.$$.fragment,il),il.forEach(n),rs.forEach(n),O=u(hs),K=h(hs,"SPAN",{});var Ya=r(K);Y=a(Ya,"Chu\u1EA5n b\u1ECB m\u1ECDi th\u1EE9 cho hu\u1EA5n luy\u1EC7n"),Ya.forEach(n),hs.forEach(n),nt=u(m),W=h(m,"P",{});var tt=r(W);ct=a(tt,"\u0110\u1EA7u ti\xEAn, ch\xFAng ta c\u1EA7n x\xE2y d\u1EF1ng c\xE1c "),_t=h(tt,"CODE",{});var os=r(_t);Tt=a(os,"DataLoader"),os.forEach(n),at=a(tt," t\u1EEB c\xE1c t\u1EADp d\u1EEF li\u1EC7u c\u1EE7a m\xECnh. Ch\xFAng ta \u0111\u1EB7t \u0111\u1ECBnh d\u1EA1ng c\u1EE7a c\xE1c t\u1EADp d\u1EEF li\u1EC7u \u0111\xF3 th\xE0nh "),en=h(tt,"CODE",{});var Zs=r(en);Ft=a(Zs,'"torch"'),Zs.forEach(n),Q=a(tt," v\xE0 x\xF3a c\xE1c c\u1ED9t trong t\u1EADp x\xE1c th\u1EF1c kh\xF4ng \u0111\u01B0\u1EE3c m\xF4 h\xECnh s\u1EED d\u1EE5ng. Sau \u0111\xF3, ch\xFAng ta c\xF3 th\u1EC3 s\u1EED d\u1EE5ng "),X=h(tt,"CODE",{});var ll=r(X);Dt=a(ll,"default_data_collator"),ll.forEach(n),ie=a(tt," \u0111\u01B0\u1EE3c cung c\u1EA5p b\u1EDFi Transformers d\u01B0\u1EDBi d\u1EA1ng "),sn=h(tt,"CODE",{});var cl=r(sn);fn=a(cl,"collate_fn"),cl.forEach(n),ut=a(tt," v\xE0 x\xE1o tr\u1ED9n b\u1ED9 hu\u1EA5n luy\u1EC7n, nh\u01B0ng kh\xF4ng ph\u1EA3i b\u1ED9 ki\u1EC3m \u0111\u1ECBnh:"),tt.forEach(n),an=u(m),q(et.$$.fragment,m),vt=u(m),mt=h(m,"P",{});var hl=r(mt);At=a(hl,"Ti\u1EBFp theo, ch\xFAng ta kh\xF4i ph\u1EE5c m\xF4 h\xECnh c\u1EE7a m\xECnh, \u0111\u1EC3 \u0111\u1EA3m b\u1EA3o r\u1EB1ng ta kh\xF4ng ti\u1EBFp t\u1EE5c tinh ch\u1EC9nh t\u1EEB tr\u01B0\u1EDBc m\xE0 b\u1EAFt \u0111\u1EA7u l\u1EA1i t\u1EEB m\xF4 h\xECnh \u0111\u01B0\u1EE3c hu\u1EA5n luy\u1EC7n tr\u01B0\u1EDBc BERT:"),hl.forEach(n),ks=u(m),q(Ht.$$.fragment,m),ys=u(m),It=h(m,"P",{});var Vn=r(It);Pt=a(Vn,"Sau \u0111\xF3, ch\xFAng ta s\u1EBD c\u1EA7n m\u1ED9t tr\xECnh t\u1ED1i \u01B0u h\xF3a. Nh\u01B0 th\u01B0\u1EDDng l\u1EC7, ta s\u1EED d\u1EE5ng "),Le=h(Vn,"CODE",{});var ta=r(Le);_n=a(ta,"AdamW"),ta.forEach(n),Da=a(Vn," c\u1ED5 \u0111i\u1EC3n, gi\u1ED1ng nh\u01B0 Adam, nh\u01B0ng v\u1EDBi m\u1ED9t b\u1EA3n s\u1EEDa l\u1ED7i trong c\xE1ch ph\xE2n r\xE3 tr\u1ECDng s\u1ED1 \u0111\u01B0\u1EE3c \xE1p d\u1EE5ng:"),Vn.forEach(n),xs=u(m),q(xt.$$.fragment,m),$s=u(m),lt=h(m,"P",{});var yt=r(lt);ws=a(yt,"Khi ch\xFAng ta c\xF3 t\u1EA5t c\u1EA3 c\xE1c \u0111\u1ED1i t\u01B0\u1EE3ng \u0111\xF3, ch\xFAng ta c\xF3 th\u1EC3 g\u1EEDi ch\xFAng \u0111\u1EBFn ph\u01B0\u01A1ng th\u1EE9c "),$t=h(yt,"CODE",{});var rl=r($t);ln=a(rl,"accelerator.prepare()"),rl.forEach(n),Fe=a(yt,". H\xE3y nh\u1EDB r\u1EB1ng n\u1EBFu b\u1EA1n mu\u1ED1n hu\u1EA5n luy\u1EC7n v\u1EC1 TPU trong notebook Colab, b\u1EA1n s\u1EBD c\u1EA7n chuy\u1EC3n t\u1EA5t c\u1EA3 m\xE3 n\xE0y v\xE0o m\u1ED9t h\xE0m hu\u1EA5n luy\u1EC7n v\xE0 \u0111i\u1EC1u \u0111\xF3 s\u1EBD kh\xF4ng th\u1EF1c thi b\u1EA5t k\u1EF3 \xF4 kh\u1EDFi t\u1EA1o m\u1ED9t "),Vt=h(yt,"CODE",{});var ol=r(Vt);Aa=a(ol,"Accelerator"),ol.forEach(n),He=a(yt," n\xE0o. Ch\xFAng ta c\xF3 th\u1EC3 bu\u1ED9c hu\u1EA5n luy\u1EC7n \u0111\u1ED9 ch\xEDnh x\xE1c h\u1ED7n h\u1EE3p b\u1EB1ng c\xE1ch chuy\u1EC3n "),Ie=h(yt,"CODE",{});var ps=r(Ie);js=a(ps,"fp16=True"),ps.forEach(n),cn=a(yt," v\xE0o "),Ve=h(yt,"CODE",{});var na=r(Ve);Qe=a(na,"Accelerator"),na.forEach(n),Pa=a(yt," (ho\u1EB7c, n\u1EBFu b\u1EA1n \u0111ang th\u1EF1c thi m\xE3 d\u01B0\u1EDBi d\u1EA1ng t\u1EADp l\u1EC7nh, ch\u1EC9 c\u1EA7n \u0111\u1EA3m b\u1EA3o \u0111i\u1EC1n v\xE0o \u{1F917} Accelerate "),Ge=h(yt,"CODE",{});var pl=r(Ge);qs=a(pl,"config"),pl.forEach(n),vn=a(yt," m\u1ED9t c\xE1ch th\xEDch h\u1EE3p)."),yt.forEach(n),Re=u(m),q(St.$$.fragment,m),Es=u(m),wt=h(m,"P",{});var xe=r(wt);bn=a(xe,"Nh\u01B0 b\u1EA1n \u0111\xE3 bi\u1EBFt t\u1EEB c\xE1c ph\u1EA7n tr\u01B0\u1EDBc, ch\xFAng ta ch\u1EC9 c\xF3 th\u1EC3 s\u1EED d\u1EE5ng \u0111\u1ED9 d\xE0i "),le=h(xe,"CODE",{});var ul=r(le);kn=a(ul,"train_dataloader"),ul.forEach(n),Cs=a(xe," \u0111\u1EC3 t\xEDnh s\u1ED1 b\u01B0\u1EDBc hu\u1EA5n luy\u1EC7n sau khi n\xF3 \u0111\xE3 tr\u1EA3i qua ph\u01B0\u01A1ng th\u1EE9c "),ot=h(xe,"CODE",{});var us=r(ot);Sa=a(us,"accelerator.prepare()"),us.forEach(n),Ke=a(xe,". Ch\xFAng ta s\u1EED d\u1EE5ng c\xF9ng m\u1ED9t l\u1ECBch tr\xECnh tuy\u1EBFn t\xEDnh nh\u01B0 trong c\xE1c ph\u1EA7n tr\u01B0\u1EDBc:"),xe.forEach(n),Ts=u(m),q(yn.$$.fragment,m),ce=u(m),bt=h(m,"P",{});var Mt=r(bt);Ba=a(Mt,"\u0110\u1EC3 \u0111\u1EA9y m\xF4 h\xECnh c\u1EE7a m\xECnh l\xEAn Hub, ch\xFAng ta s\u1EBD c\u1EA7n t\u1EA1o m\u1ED9t \u0111\u1ED1i t\u01B0\u1EE3ng "),xn=h(Mt,"CODE",{});var ml=r(xn);Na=a(ml,"Repository"),ml.forEach(n),Ma=a(Mt," trong m\u1ED9t th\u01B0 m\u1EE5c \u0111ang l\xE0m vi\u1EC7c. \u0110\u1EA7u ti\xEAn h\xE3y \u0111\u0103ng nh\u1EADp v\xE0o Hugging Face Hub, n\u1EBFu b\u1EA1n ch\u01B0a \u0111\u0103ng nh\u1EADp. Ch\xFAng ta s\u1EBD x\xE1c \u0111\u1ECBnh t\xEAn kho l\u01B0u tr\u1EEF t\u1EEB ID m\xF4 h\xECnh m\xE0 ta mu\u1ED1n cung c\u1EA5p cho m\xF4 h\xECnh c\u1EE7a m\xECnh (vui l\xF2ng thay th\u1EBF "),he=h(Mt,"CODE",{});var gl=r(he);$n=a(gl,"repo_name"),gl.forEach(n),Ds=a(Mt," b\u1EB1ng s\u1EF1 l\u1EF1a ch\u1ECDn c\u1EE7a ri\xEAng b\u1EA1n; n\xF3 ch\u1EC9 c\u1EA7n ch\u1EE9a t\xEAn ng\u01B0\u1EDDi d\xF9ng c\u1EE7a b\u1EA1n, \u0111\xF3 l\xE0 nh\u1EEFng g\xEC h\xE0m "),Qt=h(Mt,"CODE",{});var Za=r(Qt);As=a(Za,"get_full_repo_name()"),Za.forEach(n),st=a(Mt," th\u1EF1c hi\u1EC7n ):"),Mt.forEach(n),Ps=u(m),q(Gt.$$.fragment,m),Ss=u(m),q(wn.$$.fragment,m),re=u(m),oe=h(m,"P",{});var $e=r(oe);Oa=a($e,"Sau \u0111\xF3, ch\xFAng ta c\xF3 th\u1EC3 sao ch\xE9p kho l\u01B0u tr\u1EEF \u0111\xF3 trong m\u1ED9t th\u01B0 m\u1EE5c c\u1EE5c b\u1ED9. N\u1EBFu n\xF3 \u0111\xE3 t\u1ED3n t\u1EA1i, th\u01B0 m\u1EE5c c\u1EE5c b\u1ED9 n\xE0y ph\u1EA3i l\xE0 b\u1EA3n sao c\u1EE7a kho l\u01B0u tr\u1EEF m\xE0 ta \u0111ang l\xE0m vi\u1EC7c:"),$e.forEach(n),pe=u(m),q(jn.$$.fragment,m),Bs=u(m),kt=h(m,"P",{});var Qn=r(kt);za=a(Qn,"Gi\u1EDD ta c\xF3 th\u1EC3 t\u1EA3i m\u1ECDi th\u1EED ta l\u01B0u trong "),We=h(Qn,"CODE",{});var we=r(We);Ue=a(we,"output_dir"),we.forEach(n),La=a(Qn," b\u1EB1ng c\xE1ch g\u1ECDi ph\u01B0\u01A1ng th\u1EE9c "),Xe=h(Qn,"CODE",{});var ti=r(Xe);Je=a(ti,"repo.push_to_hub()"),ti.forEach(n),Fa=a(Qn,". N\xF3 s\u1EBD gi\xFAp ta t\u1EA3i c\xE1c m\xF4 h\xECnh t\u1EE9c th\xEC \u1EDF cu\u1ED1i m\u1ED7i epoch."),Qn.forEach(n),Ns=u(m),Bt=h(m,"H2",{class:!0});var Ct=r(Bt);gt=h(Ct,"A",{id:!0,class:!0,href:!0});var dl=r(gt);Ye=h(dl,"SPAN",{});var ea=r(Ye);q(Rt.$$.fragment,ea),ea.forEach(n),dl.forEach(n),Ha=u(Ct),Ze=h(Ct,"SPAN",{});var fl=r(Ze);Ms=a(fl,"V\xF2ng l\u1EB7p hu\u1EA5n luy\u1EC7n"),fl.forEach(n),Ct.forEach(n),hn=u(m),qn=h(m,"P",{});var _l=r(qn);En=a(_l,"B\xE2y gi\u1EDD ch\xFAng ta \u0111\xE3 s\u1EB5n s\xE0ng \u0111\u1EC3 vi\u1EBFt v\xF2ng l\u1EB7p hu\u1EA5n luy\u1EC7n \u0111\u1EA7y \u0111\u1EE7. Sau khi x\xE1c \u0111\u1ECBnh thanh ti\u1EBFn tr\xECnh \u0111\u1EC3 theo d\xF5i qu\xE1 tr\xECnh hu\u1EA5n luy\u1EC7n di\u1EC5n ra nh\u01B0 th\u1EBF n\xE0o, v\xF2ng l\u1EB7p c\xF3 ba ph\u1EA7n:"),_l.forEach(n),ts=u(m),dt=h(m,"UL",{});var mn=r(dt);Cn=h(mn,"LI",{});var sa=r(Cn);Os=a(sa,"B\u1EA3n th\xE2n qu\xE1 tr\xECnh hu\u1EA5n luy\u1EC7n, l\xE0 s\u1EF1 l\u1EB7p l\u1EA1i c\u1ED5 \u0111i\u1EC3n tr\xEAn "),Kt=h(sa,"CODE",{});var vl=r(Kt);zs=a(vl,"train_dataloader"),vl.forEach(n),Tn=a(sa,", truy\u1EC1n th\u1EB3ng qua m\xF4 h\xECnh, sau \u0111\xF3 truy\u1EC1n ng\u01B0\u1EE3c v\xE0 t\u1ED1i \u01B0u h\xF3a."),sa.forEach(n),Ls=u(mn),pt=h(mn,"LI",{});var Yt=r(pt);Ia=a(Yt,"B\u01B0\u1EDBc \u0111\xE1nh gi\xE1, trong \u0111\xF3 ta thu th\u1EADp t\u1EA5t c\u1EA3 c\xE1c gi\xE1 tr\u1ECB cho "),ue=h(Yt,"CODE",{});var Zt=r(ue);Dn=a(Zt,"start_logits"),Zt.forEach(n),Fs=a(Yt," v\xE0 "),Wt=h(Yt,"CODE",{});var bl=r(Wt);Hs=a(bl,"end_logits"),bl.forEach(n),me=a(Yt," tr\u01B0\u1EDBc khi chuy\u1EC3n \u0111\u1ED5i ch\xFAng th\xE0nh m\u1EA3ng NumPy. Khi v\xF2ng l\u1EB7p \u0111\xE1nh gi\xE1 k\u1EBFt th\xFAc, ch\xFAng ta n\u1ED1i t\u1EA5t c\u1EA3 c\xE1c k\u1EBFt qu\u1EA3. L\u01B0u \xFD r\u1EB1ng ch\xFAng ta c\u1EA7n c\u1EAFt b\u1EDBt v\xEC "),ns=h(Yt,"CODE",{});var ms=r(ns);Is=a(ms,"Accelerator"),ms.forEach(n),Ut=a(Yt," c\xF3 th\u1EC3 \u0111\xE3 th\xEAm m\u1ED9t v\xE0i m\u1EABu v\xE0o cu\u1ED1i \u0111\u1EC3 \u0111\u1EA3m b\u1EA3o ch\xFAng ta c\xF3 c\xF9ng s\u1ED1 l\u01B0\u1EE3ng m\u1EABu trong m\u1ED7i quy tr\xECnh."),Yt.forEach(n),rn=u(mn),jt=h(mn,"LI",{});var je=r(jt);An=a(je,"L\u01B0u v\xE0 t\u1EA3i l\xEAn, n\u01A1i tr\u01B0\u1EDBc ti\xEAn ch\xFAng ta l\u01B0u m\xF4 h\xECnh v\xE0 tr\xECnh m\xE3 h\xF3a, sau \u0111\xF3 g\u1ECDi "),es=h(je,"CODE",{});var kl=r(es);ss=a(kl,"repo.push_to_hub()"),kl.forEach(n),Va=a(je,". Nh\u01B0 ch\xFAng ta \u0111\xE3 l\xE0m tr\u01B0\u1EDBc \u0111\xE2y, ch\xFAng ta s\u1EED d\u1EE5ng \u0111\u1ED1i s\u1ED1 "),ge=h(je,"CODE",{});var aa=r(ge);Pn=a(aa,"blocking=False"),aa.forEach(n),Vs=a(je," \u0111\u1EC3 y\xEAu c\u1EA7u th\u01B0 vi\u1EC7n \u{1F917} Hub \u0111\u1EA9y v\xE0o m\u1ED9t qu\xE1 tr\xECnh kh\xF4ng \u0111\u1ED3ng b\u1ED9. B\u1EB1ng c\xE1ch n\xE0y, qu\xE1 tr\xECnh hu\u1EA5n luy\u1EC7n ti\u1EBFp t\u1EE5c di\u1EC5n ra b\xECnh th\u01B0\u1EDDng v\xE0 l\u1EC7nh (d\xE0i) n\xE0y \u0111\u01B0\u1EE3c th\u1EF1c thi \u1EDF ch\u1EBF \u0111\u1ED9 n\u1EC1n."),je.forEach(n),mn.forEach(n),Sn=u(m),de=h(m,"P",{});var yl=r(de);Qs=a(yl,"\u0110\xE2y l\xE0 m\xE3 ho\xE0n ch\u1EC9nh cho v\xF2ng l\u1EB7p hu\u1EA5n luy\u1EC7n:"),yl.forEach(n),Bn=u(m),q(Nn.$$.fragment,m),as=u(m),Nt=h(m,"P",{});var xl=r(Nt);Gs=a(xl,"Trong tr\u01B0\u1EDDng h\u1EE3p \u0111\xE2y l\xE0 l\u1EA7n \u0111\u1EA7u ti\xEAn b\u1EA1n th\u1EA5y m\u1ED9t m\xF4 h\xECnh \u0111\u01B0\u1EE3c l\u01B0u b\u1EB1ng \u{1F917} Accelerate, h\xE3y d\xE0nh m\u1ED9t ch\xFAt th\u1EDDi gian \u0111\u1EC3 ki\u1EC3m tra ba d\xF2ng m\xE3 \u0111i k\xE8m v\u1EDBi n\xF3:"),xl.forEach(n),ft=u(m),q(Mn.$$.fragment,m),on=u(m),Z=h(m,"P",{});var it=r(Z);Qa=a(it,"D\xF2ng \u0111\u1EA7u ti\xEAn \u0111\xE3 t\u1EF1 gi\u1EA3i th\xEDch: n\xF3 cho t\u1EA5t c\u1EA3 c\xE1c qu\xE1 tr\xECnh ch\u1EDD cho \u0111\u1EBFn khi m\u1ECDi ng\u01B0\u1EDDi \u1EDF giai \u0111o\u1EA1n \u0111\xF3 tr\u01B0\u1EDBc khi ti\u1EBFp t\u1EE5c. \u0110i\u1EC1u n\xE0y l\xE0 \u0111\u1EC3 \u0111\u1EA3m b\u1EA3o r\u1EB1ng ch\xFAng ta c\xF3 c\xF9ng m\u1ED9t m\xF4 h\xECnh trong m\u1ECDi quy tr\xECnh tr\u01B0\u1EDBc khi l\u01B0u. Sau \u0111\xF3, ta l\u1EA5y "),On=h(it,"CODE",{});var qe=r(On);Ga=a(qe,"unwrapped_model"),qe.forEach(n),Ra=a(it,", l\xE0 m\xF4 h\xECnh c\u01A1 s\u1EDF m\xE0 ta \u0111\xE3 x\xE1c \u0111\u1ECBnh. Ph\u01B0\u01A1ng th\u1EE9c "),zn=h(it,"CODE",{});var ni=r(zn);Ka=a(ni,"accelerator.prepare()"),ni.forEach(n),Wa=a(it," thay \u0111\u1ED5i m\xF4 h\xECnh \u0111\u1EC3 ho\u1EA1t \u0111\u1ED9ng trong hu\u1EA5n luy\u1EC7n ph\xE2n t\xE1n, v\xEC v\u1EADy n\xF3 s\u1EBD kh\xF4ng c\xF3 ph\u01B0\u01A1ng th\u1EE9c "),fe=h(it,"CODE",{});var Ee=r(fe);Ln=a(Ee,"save_pretrained()"),Ee.forEach(n),Rs=a(it," n\u1EEFa; ph\u01B0\u01A1ng th\u1EE9c "),Xt=h(it,"CODE",{});var ei=r(Xt);Ks=a(ei,"accelerator.unwrap_model()"),ei.forEach(n),_e=a(it," ho\xE0n t\xE1c b\u01B0\u1EDBc \u0111\xF3. Cu\u1ED1i c\xF9ng, ch\xFAng ta g\u1ECDi "),is=h(it,"CODE",{});var tn=r(is);Ws=a(tn,"save_pretrained()"),tn.forEach(n),Fn=a(it," nh\u01B0ng y\xEAu c\u1EA7u ph\u01B0\u01A1ng th\u1EE9c \u0111\xF3 s\u1EED d\u1EE5ng "),ve=h(it,"CODE",{});var $l=r(ve);be=a($l,"accelerator.save()"),$l.forEach(n),Ua=a(it," thay v\xEC "),ke=h(it,"CODE",{});var ia=r(ke);Hn=a(ia,"torch.save()"),ia.forEach(n),Us=a(it,"."),it.forEach(n),pn=u(m),qt=h(m,"P",{});var Ce=r(qt);ye=a(Ce,"Khi \u0111i\u1EC1u n\xE0y \u0111\u01B0\u1EE3c th\u1EF1c hi\u1EC7n, b\u1EA1n s\u1EBD c\xF3 m\u1ED9t m\xF4 h\xECnh t\u1EA1o ra k\u1EBFt qu\u1EA3 kh\xE1 gi\u1ED1ng v\u1EDBi m\xF4 h\xECnh \u0111\u01B0\u1EE3c hu\u1EA5n luy\u1EC7n v\u1EDBi "),ls=h(Ce,"CODE",{});var wl=r(ls);Xs=a(wl,"Trainer"),wl.forEach(n),Jt=a(Ce,". B\u1EA1n c\xF3 th\u1EC3 ki\u1EC3m tra m\xF4 h\xECnh m\xE0 ta \u0111\xE3 hu\u1EA5n luy\u1EC7n b\u1EB1ng c\xE1ch s\u1EED d\u1EE5ng m\xE3 n\xE0y t\u1EA1i "),Et=h(Ce,"A",{href:!0,rel:!0});var la=r(Et);Js=h(la,"EM",{});var jl=r(Js);Xa=a(jl,"huggingface-course/bert-finetuned-squad-accelerate"),jl.forEach(n),la.forEach(n),In=a(Ce,". V\xE0 n\u1EBFu b\u1EA1n mu\u1ED1n ki\u1EC3m tra b\u1EA5t k\u1EF3 tinh ch\u1EC9nh n\xE0o \u0111\u1ED1i v\u1EDBi v\xF2ng l\u1EB7p hu\u1EA5n luy\u1EC7n, b\u1EA1n c\xF3 th\u1EC3 tr\u1EF1c ti\u1EBFp th\u1EF1c hi\u1EC7n ch\xFAng b\u1EB1ng c\xE1ch ch\u1EC9nh s\u1EEDa \u0111o\u1EA1n m\xE3 \u0111\u01B0\u1EE3c hi\u1EC3n th\u1ECB \u1EDF tr\xEAn!"),Ce.forEach(n),this.h()},h(){A(D,"id","mt-vng-lp-hun-luyn-tu-chnh"),A(D,"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"),A(D,"href","#mt-vng-lp-hun-luyn-tu-chnh"),A(y,"class","relative group"),A(L,"href","/course/chapter3/4"),A(V,"id","chun-b-mi-th-cho-hun-luyn"),A(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"),A(V,"href","#chun-b-mi-th-cho-hun-luyn"),A(G,"class","relative group"),A(gt,"id","vng-lp-hun-luyn"),A(gt,"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"),A(gt,"href","#vng-lp-hun-luyn"),A(Bt,"class","relative group"),A(Et,"href","https://huggingface.co/huggingface-course/bert-finetuned-squad-accelerate"),A(Et,"rel","nofollow")},m(m,M){i(m,o,M),e(o,v),i(m,g,M),i(m,y,M),e(y,D),e(D,b),E($,b,null),e(y,x),e(y,d),e(d,B),i(m,k,M),i(m,w,M),e(w,P),e(w,L),e(L,N),e(w,T),e(w,F),e(F,I),e(w,z),i(m,R,M),i(m,G,M),e(G,V),e(V,J),E(U,J,null),e(G,O),e(G,K),e(K,Y),i(m,nt,M),i(m,W,M),e(W,ct),e(W,_t),e(_t,Tt),e(W,at),e(W,en),e(en,Ft),e(W,Q),e(W,X),e(X,Dt),e(W,ie),e(W,sn),e(sn,fn),e(W,ut),i(m,an,M),E(et,m,M),i(m,vt,M),i(m,mt,M),e(mt,At),i(m,ks,M),E(Ht,m,M),i(m,ys,M),i(m,It,M),e(It,Pt),e(It,Le),e(Le,_n),e(It,Da),i(m,xs,M),E(xt,m,M),i(m,$s,M),i(m,lt,M),e(lt,ws),e(lt,$t),e($t,ln),e(lt,Fe),e(lt,Vt),e(Vt,Aa),e(lt,He),e(lt,Ie),e(Ie,js),e(lt,cn),e(lt,Ve),e(Ve,Qe),e(lt,Pa),e(lt,Ge),e(Ge,qs),e(lt,vn),i(m,Re,M),E(St,m,M),i(m,Es,M),i(m,wt,M),e(wt,bn),e(wt,le),e(le,kn),e(wt,Cs),e(wt,ot),e(ot,Sa),e(wt,Ke),i(m,Ts,M),E(yn,m,M),i(m,ce,M),i(m,bt,M),e(bt,Ba),e(bt,xn),e(xn,Na),e(bt,Ma),e(bt,he),e(he,$n),e(bt,Ds),e(bt,Qt),e(Qt,As),e(bt,st),i(m,Ps,M),E(Gt,m,M),i(m,Ss,M),E(wn,m,M),i(m,re,M),i(m,oe,M),e(oe,Oa),i(m,pe,M),E(jn,m,M),i(m,Bs,M),i(m,kt,M),e(kt,za),e(kt,We),e(We,Ue),e(kt,La),e(kt,Xe),e(Xe,Je),e(kt,Fa),i(m,Ns,M),i(m,Bt,M),e(Bt,gt),e(gt,Ye),E(Rt,Ye,null),e(Bt,Ha),e(Bt,Ze),e(Ze,Ms),i(m,hn,M),i(m,qn,M),e(qn,En),i(m,ts,M),i(m,dt,M),e(dt,Cn),e(Cn,Os),e(Cn,Kt),e(Kt,zs),e(Cn,Tn),e(dt,Ls),e(dt,pt),e(pt,Ia),e(pt,ue),e(ue,Dn),e(pt,Fs),e(pt,Wt),e(Wt,Hs),e(pt,me),e(pt,ns),e(ns,Is),e(pt,Ut),e(dt,rn),e(dt,jt),e(jt,An),e(jt,es),e(es,ss),e(jt,Va),e(jt,ge),e(ge,Pn),e(jt,Vs),i(m,Sn,M),i(m,de,M),e(de,Qs),i(m,Bn,M),E(Nn,m,M),i(m,as,M),i(m,Nt,M),e(Nt,Gs),i(m,ft,M),E(Mn,m,M),i(m,on,M),i(m,Z,M),e(Z,Qa),e(Z,On),e(On,Ga),e(Z,Ra),e(Z,zn),e(zn,Ka),e(Z,Wa),e(Z,fe),e(fe,Ln),e(Z,Rs),e(Z,Xt),e(Xt,Ks),e(Z,_e),e(Z,is),e(is,Ws),e(Z,Fn),e(Z,ve),e(ve,be),e(Z,Ua),e(Z,ke),e(ke,Hn),e(Z,Us),i(m,pn,M),i(m,qt,M),e(qt,ye),e(qt,ls),e(ls,Xs),e(qt,Jt),e(qt,Et),e(Et,Js),e(Js,Xa),e(qt,In),Ja=!0},i(m){Ja||(f($.$$.fragment,m),f(U.$$.fragment,m),f(et.$$.fragment,m),f(Ht.$$.fragment,m),f(xt.$$.fragment,m),f(St.$$.fragment,m),f(yn.$$.fragment,m),f(Gt.$$.fragment,m),f(wn.$$.fragment,m),f(jn.$$.fragment,m),f(Rt.$$.fragment,m),f(Nn.$$.fragment,m),f(Mn.$$.fragment,m),Ja=!0)},o(m){_($.$$.fragment,m),_(U.$$.fragment,m),_(et.$$.fragment,m),_(Ht.$$.fragment,m),_(xt.$$.fragment,m),_(St.$$.fragment,m),_(yn.$$.fragment,m),_(Gt.$$.fragment,m),_(wn.$$.fragment,m),_(jn.$$.fragment,m),_(Rt.$$.fragment,m),_(Nn.$$.fragment,m),_(Mn.$$.fragment,m),Ja=!1},d(m){m&&n(o),m&&n(g),m&&n(y),C($),m&&n(k),m&&n(w),m&&n(R),m&&n(G),C(U),m&&n(nt),m&&n(W),m&&n(an),C(et,m),m&&n(vt),m&&n(mt),m&&n(ks),C(Ht,m),m&&n(ys),m&&n(It),m&&n(xs),C(xt,m),m&&n($s),m&&n(lt),m&&n(Re),C(St,m),m&&n(Es),m&&n(wt),m&&n(Ts),C(yn,m),m&&n(ce),m&&n(bt),m&&n(Ps),C(Gt,m),m&&n(Ss),C(wn,m),m&&n(re),m&&n(oe),m&&n(pe),C(jn,m),m&&n(Bs),m&&n(kt),m&&n(Ns),m&&n(Bt),C(Rt),m&&n(hn),m&&n(qn),m&&n(ts),m&&n(dt),m&&n(Sn),m&&n(de),m&&n(Bn),C(Nn,m),m&&n(as),m&&n(Nt),m&&n(ft),C(Mn,m),m&&n(on),m&&n(Z),m&&n(pn),m&&n(qt)}}}function gf(H){let o,v,g,y,D,b,$,x,d,B,k,w,P,L,N,T,F,I,z,R,G,V,J,U,O,K,Y,nt,W,ct,_t,Tt,at,en,Ft,Q,X,Dt,ie,sn,fn,ut,an,et,vt,mt,At,ks,Ht,ys,It,Pt,Le,_n,Da,xs,xt,$s,lt,ws,$t,ln,Fe,Vt,Aa,He,Ie,js,cn,Ve,Qe,Pa,Ge,qs,vn,Re,St,Es,wt,bn,le,kn,Cs,ot,Sa,Ke,Ts,yn,ce,bt,Ba,xn,Na,Ma,he,$n,Ds,Qt,As,st,Ps,Gt,Ss,wn,re,oe,Oa,pe,jn,Bs,kt,za,We,Ue,La,Xe,Je,Fa,Ns,Bt,gt,Ye,Rt,Ha,Ze,Ms,hn,qn,En,ts,dt,Cn,Os,Kt,zs,Tn,Ls,pt,Ia,ue,Dn,Fs,Wt,Hs,me,ns,Is,Ut,rn,jt,An,es,ss,Va,ge,Pn,Vs,Sn,de,Qs,Bn,Nn,as,Nt,Gs,ft,Mn,on,Z,Qa,On,Ga,Ra,zn,Ka,Wa,fe,Ln,Rs,Xt,Ks,_e,is,Ws,Fn,ve,be,Ua,ke,Hn,Us,pn,qt,ye,ls,Xs,Jt,Et,Js,Xa,In,Ja,m,M,Ys,cs,nl,el,un,sl,al,hs,rs,il,Ya,tt,os,Zs,ll,cl,hl,Vn,ta,yt,rl,ol,ps,na,pl,xe,ul,us,Mt,ml,gl,Za,$e,Qn,we,ti,Ct,dl,ea,fl,_l,mn,sa,vl,Yt,Zt,bl,ms,je,kl,aa,yl,xl,it,qe,ni,Ee,ei,tn,$l,ia,Ce,wl,la,jl,wo,kh,si,yh,ai,xh,ql,jo,$h,ii,wh,li,jh,El,qo,qh,Cl,Eo,Eh,ca,Tl,Ec,Co,To,Do,Te,Cc,Ao,Po,Tc,So,Bo,Dc,No,Mo,Ch,De,Oo,Ac,zo,Lo,Pc,Fo,Ho,Th,ha,Io,Sc,Vo,Qo,Dh,ci,Ah,hi,Ph,ra,Go,Bc,Ro,Ko,Sh,ri,Bh,oi,Nh,oa,Wo,Nc,Uo,Xo,Mh,pi,Oh,ui,zh,Dl,Jo,Lh,Al,Yo,Fh,Pl,Zo,Hh,pa,Ih,Sl,tp,Vh,mi,Qh,Bl,np,Gh,Ae,ep,Mc,sp,ap,Oc,ip,lp,Rh,gi,Kh,di,Wh,Nl,cp,Uh,gs,ua,zc,fi,hp,Lc,rp,Xh,Ml,op,Jh,Pe,pp,Fc,up,mp,Hc,gp,dp,Yh,_i,Zh,Ol,fp,tr,vi,nr,bi,er,zl,_p,sr,Ll,vp,ar,Gn,Rn,Fl,ds,ma,Ic,ki,bp,Vc,kp,ir,Kn,Wn,Hl,ga,yp,Il,Qc,xp,$p,lr,gn,Gc,wp,jp,Rc,qp,Ep,yi,Cp,Kc,Tp,Dp,Ap,fs,Pp,Wc,Sp,Bp,Uc,Np,Mp,cr,dn,Op,Xc,zp,Lp,Jc,Fp,Hp,Yc,Ip,Vp,hr,da,Qp,Zc,Gp,Rp,rr,xi,or,Vl,Kp,pr,$i,ur,fa,Wp,th,Up,Xp,mr,Un,Xn,Ql,Ot,Jp,nh,Yp,Zp,eh,tu,nu,sh,eu,su,ah,au,iu,gr,wi,dr,_a,lu,ih,cu,hu,fr,Se,lh,ru,ou,ch,pu,uu,ji,mu,hh,gu,du,_r,Gl,fu,vr,qi,br,Rl,_u,kr,Ei,yr,Kl,vu,xr,Ci,$r,Wl,bu,wr,Ti,jr,Di,qr,Ul,ku,Er,Ai,Cr,Pi,Tr,va,yu,Si,xu,$u,Dr,Xl,Bi,Ar,Jl,wu,Pr,Ni,Sr,Mi,Br,Yl,ju,Nr,_s,ba,rh,Oi,qu,oh,Eu,Mr,Jn,Yn,Zl,tc,Cu,Or,nc,Tu,zr,zi,Lr,ec,Du,Fr,Li,Hr,Zn,te,sc,zt,Au,ph,Pu,Su,uh,Bu,Nu,mh,Mu,Ou,gh,zu,Lu,Ir,ne,ee,ac,ic,Fu,Vr,se,ae,lc,Fi,Qr,cc,Hu,Gr,hc,rc,Iu,Rr,ka,Kr,oc,vs,ya,dh,Hi,Vu,fh,Qu,Wr,xa,Gu,_h,Ru,Ku,Ur,Ii,Xr,Vi,Jr,pc,Wu,Yr;g=new Qd({props:{fw:H[0]}}),x=new nn({});const nm=[Rd,Gd],Qi=[];function em(t,l){return t[0]==="pt"?0:1}P=em(H),L=Qi[P]=nm[P](H),O=new $o({props:{id:"ajPx5LwJD-I"}}),ut=new xo({props:{$$slots:{default:[Kd]},$$scope:{ctx:H}}}),At=new nn({}),Vt=new nn({}),vn=new S({props:{code:`from datasets import load_dataset

raw_datasets = load_dataset("squad")`,highlighted:`<span class="hljs-keyword">from</span> datasets <span class="hljs-keyword">import</span> load_dataset

raw_datasets = load_dataset(<span class="hljs-string">&quot;squad&quot;</span>)`}}),bn=new S({props:{code:"raw_datasets",highlighted:"raw_datasets"}}),kn=new S({props:{code:`DatasetDict({
    train: Dataset({
        features: ['id', 'title', 'context', 'question', 'answers'],
        num_rows: 87599
    })
    validation: Dataset({
        features: ['id', 'title', 'context', 'question', 'answers'],
        num_rows: 10570
    })
})`,highlighted:`DatasetDict({
    train: Dataset({
        features: [<span class="hljs-string">&#x27;id&#x27;</span>, <span class="hljs-string">&#x27;title&#x27;</span>, <span class="hljs-string">&#x27;context&#x27;</span>, <span class="hljs-string">&#x27;question&#x27;</span>, <span class="hljs-string">&#x27;answers&#x27;</span>],
        num_rows: <span class="hljs-number">87599</span>
    })
    validation: Dataset({
        features: [<span class="hljs-string">&#x27;id&#x27;</span>, <span class="hljs-string">&#x27;title&#x27;</span>, <span class="hljs-string">&#x27;context&#x27;</span>, <span class="hljs-string">&#x27;question&#x27;</span>, <span class="hljs-string">&#x27;answers&#x27;</span>],
        num_rows: <span class="hljs-number">10570</span>
    })
})`}}),$n=new S({props:{code:`print("Context: ", raw_datasets["train"][0]["context"])
print("Question: ", raw_datasets["train"][0]["question"])
print("Answer: ", raw_datasets["train"][0]["answers"])`,highlighted:`<span class="hljs-built_in">print</span>(<span class="hljs-string">&quot;Context: &quot;</span>, raw_datasets[<span class="hljs-string">&quot;train&quot;</span>][<span class="hljs-number">0</span>][<span class="hljs-string">&quot;context&quot;</span>])
<span class="hljs-built_in">print</span>(<span class="hljs-string">&quot;Question: &quot;</span>, raw_datasets[<span class="hljs-string">&quot;train&quot;</span>][<span class="hljs-number">0</span>][<span class="hljs-string">&quot;question&quot;</span>])
<span class="hljs-built_in">print</span>(<span class="hljs-string">&quot;Answer: &quot;</span>, raw_datasets[<span class="hljs-string">&quot;train&quot;</span>][<span class="hljs-number">0</span>][<span class="hljs-string">&quot;answers&quot;</span>])`}}),Qt=new S({props:{code:`Context: 'Architecturally, the school has a Catholic character. Atop the Main Building\\'s gold dome is a golden statue of the Virgin Mary. Immediately in front of the Main Building and facing it, is a copper statue of Christ with arms upraised with the legend "Venite Ad Me Omnes". Next to the Main Building is the Basilica of the Sacred Heart. Immediately behind the basilica is the Grotto, a Marian place of prayer and reflection. It is a replica of the grotto at Lourdes, France where the Virgin Mary reputedly appeared to Saint Bernadette Soubirous in 1858. At the end of the main drive (and in a direct line that connects through 3 statues and the Gold Dome), is a simple, modern stone statue of Mary.'
Question: 'To whom did the Virgin Mary allegedly appear in 1858 in Lourdes France?'
Answer: {'text': ['Saint Bernadette Soubirous'], 'answer_start': [515]}`,highlighted:`Context: <span class="hljs-string">&#x27;Architecturally, the school has a Catholic character. Atop the Main Building\\&#x27;s gold dome is a golden statue of the Virgin Mary. Immediately in front of the Main Building and facing it, is a copper statue of Christ with arms upraised with the legend &quot;Venite Ad Me Omnes&quot;. Next to the Main Building is the Basilica of the Sacred Heart. Immediately behind the basilica is the Grotto, a Marian place of prayer and reflection. It is a replica of the grotto at Lourdes, France where the Virgin Mary reputedly appeared to Saint Bernadette Soubirous in 1858. At the end of the main drive (and in a direct line that connects through 3 statues and the Gold Dome), is a simple, modern stone statue of Mary.&#x27;</span>
Question: <span class="hljs-string">&#x27;To whom did the Virgin Mary allegedly appear in 1858 in Lourdes France?&#x27;</span>
Answer: {<span class="hljs-string">&#x27;text&#x27;</span>: [<span class="hljs-string">&#x27;Saint Bernadette Soubirous&#x27;</span>], <span class="hljs-string">&#x27;answer_start&#x27;</span>: [<span class="hljs-number">515</span>]}`}}),hn=new S({props:{code:'raw_datasets["train"].filter(lambda x: len(x["answers"]["text"]) != 1)',highlighted:'raw_datasets[<span class="hljs-string">&quot;train&quot;</span>].<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;answers&quot;</span>][<span class="hljs-string">&quot;text&quot;</span>]) != <span class="hljs-number">1</span>)'}}),En=new S({props:{code:`Dataset({
    features: ['id', 'title', 'context', 'question', 'answers'],
    num_rows: 0
})`,highlighted:`Dataset({
    features: [<span class="hljs-string">&#x27;id&#x27;</span>, <span class="hljs-string">&#x27;title&#x27;</span>, <span class="hljs-string">&#x27;context&#x27;</span>, <span class="hljs-string">&#x27;question&#x27;</span>, <span class="hljs-string">&#x27;answers&#x27;</span>],
    num_rows: <span class="hljs-number">0</span>
})`}}),Kt=new S({props:{code:`print(raw_datasets["validation"][0]["answers"])
print(raw_datasets["validation"][2]["answers"])`,highlighted:`<span class="hljs-built_in">print</span>(raw_datasets[<span class="hljs-string">&quot;validation&quot;</span>][<span class="hljs-number">0</span>][<span class="hljs-string">&quot;answers&quot;</span>])
<span class="hljs-built_in">print</span>(raw_datasets[<span class="hljs-string">&quot;validation&quot;</span>][<span class="hljs-number">2</span>][<span class="hljs-string">&quot;answers&quot;</span>])`}}),Tn=new S({props:{code:`{'text': ['Denver Broncos', 'Denver Broncos', 'Denver Broncos'], 'answer_start': [177, 177, 177]}
{'text': ['Santa Clara, California', "Levi's Stadium", "Levi's Stadium in the San Francisco Bay Area at Santa Clara, California."], 'answer_start': [403, 355, 355]}`,highlighted:`{<span class="hljs-string">&#x27;text&#x27;</span>: [<span class="hljs-string">&#x27;Denver Broncos&#x27;</span>, <span class="hljs-string">&#x27;Denver Broncos&#x27;</span>, <span class="hljs-string">&#x27;Denver Broncos&#x27;</span>], <span class="hljs-string">&#x27;answer_start&#x27;</span>: [<span class="hljs-number">177</span>, <span class="hljs-number">177</span>, <span class="hljs-number">177</span>]}
{<span class="hljs-string">&#x27;text&#x27;</span>: [<span class="hljs-string">&#x27;Santa Clara, California&#x27;</span>, <span class="hljs-string">&quot;Levi&#x27;s Stadium&quot;</span>, <span class="hljs-string">&quot;Levi&#x27;s Stadium in the San Francisco Bay Area at Santa Clara, California.&quot;</span>], <span class="hljs-string">&#x27;answer_start&#x27;</span>: [<span class="hljs-number">403</span>, <span class="hljs-number">355</span>, <span class="hljs-number">355</span>]}`}}),Dn=new S({props:{code:`print(raw_datasets["validation"][2]["context"])
print(raw_datasets["validation"][2]["question"])`,highlighted:`<span class="hljs-built_in">print</span>(raw_datasets[<span class="hljs-string">&quot;validation&quot;</span>][<span class="hljs-number">2</span>][<span class="hljs-string">&quot;context&quot;</span>])
<span class="hljs-built_in">print</span>(raw_datasets[<span class="hljs-string">&quot;validation&quot;</span>][<span class="hljs-number">2</span>][<span class="hljs-string">&quot;question&quot;</span>])`}}),Wt=new S({props:{code:`'Super Bowl 50 was an American football game to determine the champion of the National Football League (NFL) for the 2015 season. The American Football Conference (AFC) champion Denver Broncos defeated the National Football Conference (NFC) champion Carolina Panthers 24\u201310 to earn their third Super Bowl title. The game was played on February 7, 2016, at Levi\\'s Stadium in the San Francisco Bay Area at Santa Clara, California. As this was the 50th Super Bowl, the league emphasized the "golden anniversary" with various gold-themed initiatives, as well as temporarily suspending the tradition of naming each Super Bowl game with Roman numerals (under which the game would have been known as "Super Bowl L"), so that the logo could prominently feature the Arabic numerals 50.'
'Where did Super Bowl 50 take place?'`,highlighted:`<span class="hljs-string">&#x27;Super Bowl 50 was an American football game to determine the champion of the National Football League (NFL) for the 2015 season. The American Football Conference (AFC) champion Denver Broncos defeated the National Football Conference (NFC) champion Carolina Panthers 24\u201310 to earn their third Super Bowl title. The game was played on February 7, 2016, at Levi\\&#x27;s Stadium in the San Francisco Bay Area at Santa Clara, California. As this was the 50th Super Bowl, the league emphasized the &quot;golden anniversary&quot; with various gold-themed initiatives, as well as temporarily suspending the tradition of naming each Super Bowl game with Roman numerals (under which the game would have been known as &quot;Super Bowl L&quot;), so that the logo could prominently feature the Arabic numerals 50.&#x27;</span>
<span class="hljs-string">&#x27;Where did Super Bowl 50 take place?&#x27;</span>`}}),An=new nn({}),Pn=new $o({props:{id:"qgaM0weJHpA"}}),Nt=new S({props:{code:`from transformers import AutoTokenizer

model_checkpoint = "bert-base-cased"
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;bert-base-cased&quot;</span>
tokenizer = AutoTokenizer.from_pretrained(model_checkpoint)`}}),Ln=new S({props:{code:"tokenizer.is_fast",highlighted:"tokenizer.is_fast"}}),Xt=new S({props:{code:"True",highlighted:'<span class="hljs-literal">True</span>'}}),Fn=new S({props:{code:"[CLS] question [SEP] context [SEP]",highlighted:'<span class="hljs-selector-attr">[CLS]</span> question <span class="hljs-selector-attr">[SEP]</span> context <span class="hljs-selector-attr">[SEP]</span>'}}),Hn=new S({props:{code:`context = raw_datasets["train"][0]["context"]
question = raw_datasets["train"][0]["question"]

inputs = tokenizer(question, context)
tokenizer.decode(inputs["input_ids"])`,highlighted:`context = raw_datasets[<span class="hljs-string">&quot;train&quot;</span>][<span class="hljs-number">0</span>][<span class="hljs-string">&quot;context&quot;</span>]
question = raw_datasets[<span class="hljs-string">&quot;train&quot;</span>][<span class="hljs-number">0</span>][<span class="hljs-string">&quot;question&quot;</span>]

inputs = tokenizer(question, context)
tokenizer.decode(inputs[<span class="hljs-string">&quot;input_ids&quot;</span>])`}}),pn=new S({props:{code:`'[CLS] To whom did the Virgin Mary allegedly appear in 1858 in Lourdes France? [SEP] Architecturally, '
'the school has a Catholic character. Atop the Main Building\\'s gold dome is a golden statue of the Virgin '
'Mary. Immediately in front of the Main Building and facing it, is a copper statue of Christ with arms '
'upraised with the legend " Venite Ad Me Omnes ". Next to the Main Building is the Basilica of the Sacred '
'Heart. Immediately behind the basilica is the Grotto, a Marian place of prayer and reflection. It is a '
'replica of the grotto at Lourdes, France where the Virgin Mary reputedly appeared to Saint Bernadette '
'Soubirous in 1858. At the end of the main drive ( and in a direct line that connects through 3 statues '
'and the Gold Dome ), is a simple, modern stone statue of Mary. [SEP]'`,highlighted:`<span class="hljs-string">&#x27;[CLS] To whom did the Virgin Mary allegedly appear in 1858 in Lourdes France? [SEP] Architecturally, &#x27;</span>
<span class="hljs-string">&#x27;the school has a Catholic character. Atop the Main Building\\&#x27;s gold dome is a golden statue of the Virgin &#x27;</span>
<span class="hljs-string">&#x27;Mary. Immediately in front of the Main Building and facing it, is a copper statue of Christ with arms &#x27;</span>
<span class="hljs-string">&#x27;upraised with the legend &quot; Venite Ad Me Omnes &quot;. Next to the Main Building is the Basilica of the Sacred &#x27;</span>
<span class="hljs-string">&#x27;Heart. Immediately behind the basilica is the Grotto, a Marian place of prayer and reflection. It is a &#x27;</span>
<span class="hljs-string">&#x27;replica of the grotto at Lourdes, France where the Virgin Mary reputedly appeared to Saint Bernadette &#x27;</span>
<span class="hljs-string">&#x27;Soubirous in 1858. At the end of the main drive ( and in a direct line that connects through 3 statues &#x27;</span>
<span class="hljs-string">&#x27;and the Gold Dome ), is a simple, modern stone statue of Mary. [SEP]&#x27;</span>`}}),$e=new S({props:{code:`inputs = tokenizer(
    question,
    context,
    max_length=100,
    truncation="only_second",
    stride=50,
    return_overflowing_tokens=True,
)

for ids in inputs["input_ids"]:
    print(tokenizer.decode(ids))`,highlighted:`inputs = tokenizer(
    question,
    context,
    max_length=<span class="hljs-number">100</span>,
    truncation=<span class="hljs-string">&quot;only_second&quot;</span>,
    stride=<span class="hljs-number">50</span>,
    return_overflowing_tokens=<span class="hljs-literal">True</span>,
)

<span class="hljs-keyword">for</span> ids <span class="hljs-keyword">in</span> inputs[<span class="hljs-string">&quot;input_ids&quot;</span>]:
    <span class="hljs-built_in">print</span>(tokenizer.decode(ids))`}}),we=new S({props:{code:`'[CLS] To whom did the Virgin Mary allegedly appear in 1858 in Lourdes France? [SEP] Architecturally, the school has a Catholic character. Atop the Main Building\\'s gold dome is a golden statue of the Virgin Mary. Immediately in front of the Main Building and facing it, is a copper statue of Christ with arms upraised with the legend " Venite Ad Me Omnes ". Next to the Main Building is the Basilica of the Sacred Heart. Immediately behind the basi [SEP]'
'[CLS] To whom did the Virgin Mary allegedly appear in 1858 in Lourdes France? [SEP] the Main Building and facing it, is a copper statue of Christ with arms upraised with the legend " Venite Ad Me Omnes ". Next to the Main Building is the Basilica of the Sacred Heart. Immediately behind the basilica is the Grotto, a Marian place of prayer and reflection. It is a replica of the grotto at Lourdes, France where the Virgin [SEP]'
'[CLS] To whom did the Virgin Mary allegedly appear in 1858 in Lourdes France? [SEP] Next to the Main Building is the Basilica of the Sacred Heart. Immediately behind the basilica is the Grotto, a Marian place of prayer and reflection. It is a replica of the grotto at Lourdes, France where the Virgin Mary reputedly appeared to Saint Bernadette Soubirous in 1858. At the end of the main drive ( and in a direct line that connects through 3 [SEP]'
'[CLS] To whom did the Virgin Mary allegedly appear in 1858 in Lourdes France? [SEP]. It is a replica of the grotto at Lourdes, France where the Virgin Mary reputedly appeared to Saint Bernadette Soubirous in 1858. At the end of the main drive ( and in a direct line that connects through 3 statues and the Gold Dome ), is a simple, modern stone statue of Mary. [SEP]'`,highlighted:`<span class="hljs-string">&#x27;[CLS] To whom did the Virgin Mary allegedly appear in 1858 in Lourdes France? [SEP] Architecturally, the school has a Catholic character. Atop the Main Building\\&#x27;s gold dome is a golden statue of the Virgin Mary. Immediately in front of the Main Building and facing it, is a copper statue of Christ with arms upraised with the legend &quot; Venite Ad Me Omnes &quot;. Next to the Main Building is the Basilica of the Sacred Heart. Immediately behind the basi [SEP]&#x27;</span>
<span class="hljs-string">&#x27;[CLS] To whom did the Virgin Mary allegedly appear in 1858 in Lourdes France? [SEP] the Main Building and facing it, is a copper statue of Christ with arms upraised with the legend &quot; Venite Ad Me Omnes &quot;. Next to the Main Building is the Basilica of the Sacred Heart. Immediately behind the basilica is the Grotto, a Marian place of prayer and reflection. It is a replica of the grotto at Lourdes, France where the Virgin [SEP]&#x27;</span>
<span class="hljs-string">&#x27;[CLS] To whom did the Virgin Mary allegedly appear in 1858 in Lourdes France? [SEP] Next to the Main Building is the Basilica of the Sacred Heart. Immediately behind the basilica is the Grotto, a Marian place of prayer and reflection. It is a replica of the grotto at Lourdes, France where the Virgin Mary reputedly appeared to Saint Bernadette Soubirous in 1858. At the end of the main drive ( and in a direct line that connects through 3 [SEP]&#x27;</span>
<span class="hljs-string">&#x27;[CLS] To whom did the Virgin Mary allegedly appear in 1858 in Lourdes France? [SEP]. It is a replica of the grotto at Lourdes, France where the Virgin Mary reputedly appeared to Saint Bernadette Soubirous in 1858. At the end of the main drive ( and in a direct line that connects through 3 statues and the Gold Dome ), is a simple, modern stone statue of Mary. [SEP]&#x27;</span>`}}),qe=new S({props:{code:`inputs = tokenizer(
    question,
    context,
    max_length=100,
    truncation="only_second",
    stride=50,
    return_overflowing_tokens=True,
    return_offsets_mapping=True,
)
inputs.keys()`,highlighted:`inputs = tokenizer(
    question,
    context,
    max_length=<span class="hljs-number">100</span>,
    truncation=<span class="hljs-string">&quot;only_second&quot;</span>,
    stride=<span class="hljs-number">50</span>,
    return_overflowing_tokens=<span class="hljs-literal">True</span>,
    return_offsets_mapping=<span class="hljs-literal">True</span>,
)
inputs.keys()`}}),Ee=new S({props:{code:"dict_keys(['input_ids', 'token_type_ids', 'attention_mask', 'offset_mapping', 'overflow_to_sample_mapping'])",highlighted:'dict_keys([<span class="hljs-string">&#x27;input_ids&#x27;</span>, <span class="hljs-string">&#x27;token_type_ids&#x27;</span>, <span class="hljs-string">&#x27;attention_mask&#x27;</span>, <span class="hljs-string">&#x27;offset_mapping&#x27;</span>, <span class="hljs-string">&#x27;overflow_to_sample_mapping&#x27;</span>])'}}),si=new S({props:{code:'inputs["overflow_to_sample_mapping"]',highlighted:'inputs[<span class="hljs-string">&quot;overflow_to_sample_mapping&quot;</span>]'}}),ai=new S({props:{code:"[0, 0, 0, 0]",highlighted:'[<span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>]'}}),ii=new S({props:{code:`inputs = tokenizer(
    raw_datasets["train"][2:6]["question"],
    raw_datasets["train"][2:6]["context"],
    max_length=100,
    truncation="only_second",
    stride=50,
    return_overflowing_tokens=True,
    return_offsets_mapping=True,
)

print(f"The 4 examples gave {len(inputs['input_ids'])} features.")
print(f"Here is where each comes from: {inputs['overflow_to_sample_mapping']}.")`,highlighted:`inputs = tokenizer(
    raw_datasets[<span class="hljs-string">&quot;train&quot;</span>][<span class="hljs-number">2</span>:<span class="hljs-number">6</span>][<span class="hljs-string">&quot;question&quot;</span>],
    raw_datasets[<span class="hljs-string">&quot;train&quot;</span>][<span class="hljs-number">2</span>:<span class="hljs-number">6</span>][<span class="hljs-string">&quot;context&quot;</span>],
    max_length=<span class="hljs-number">100</span>,
    truncation=<span class="hljs-string">&quot;only_second&quot;</span>,
    stride=<span class="hljs-number">50</span>,
    return_overflowing_tokens=<span class="hljs-literal">True</span>,
    return_offsets_mapping=<span class="hljs-literal">True</span>,
)

<span class="hljs-built_in">print</span>(<span class="hljs-string">f&quot;The 4 examples gave <span class="hljs-subst">{<span class="hljs-built_in">len</span>(inputs[<span class="hljs-string">&#x27;input_ids&#x27;</span>])}</span> features.&quot;</span>)
<span class="hljs-built_in">print</span>(<span class="hljs-string">f&quot;Here is where each comes from: <span class="hljs-subst">{inputs[<span class="hljs-string">&#x27;overflow_to_sample_mapping&#x27;</span>]}</span>.&quot;</span>)`}}),li=new S({props:{code:`'The 4 examples gave 19 features.'
'Here is where each comes from: [0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3].'`,highlighted:`<span class="hljs-string">&#x27;The 4 examples gave 19 features.&#x27;</span>
<span class="hljs-string">&#x27;Here is where each comes from: [0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3].&#x27;</span>`}}),ci=new S({props:{code:`answers = raw_datasets["train"][2:6]["answers"]
start_positions = []
end_positions = []

for i, offset in enumerate(inputs["offset_mapping"]):
    sample_idx = inputs["overflow_to_sample_mapping"][i]
    answer = answers[sample_idx]
    start_char = answer["answer_start"][0]
    end_char = answer["answer_start"][0] + len(answer["text"][0])
    sequence_ids = inputs.sequence_ids(i)

    # T\xECm \u0111i\u1EC3m b\u1EAFt \u0111\u1EA7u v\xE0 k\u1EBFt th\xFAc c\u1EE7a ng\u1EEF c\u1EA3nh
    while sequence_ids[idx] != 1:
        idx += 1
    context_start = idx
    while sequence_ids[idx] == 1:
        idx += 1
    context_end = idx - 1

    # N\u1EBFu c\xE2u tr\u1EA3 l\u1EDDi kh\xF4ng ho\xE0n to\xE0n n\u1EB1m trong ng\u1EEF c\u1EA3nh, nh\xE3n l\xE0 (0, 0)
    if offset[context_start][0] > start_char or offset[context_end][1] < end_char:
        start_positions.append(0)
        end_positions.append(0)
    else:
        # N\u1EBFu kh\xF4ng n\xF3 s\u1EBD l\xE0 v\u1ECB tr\xED b\u1EAFt \u0111\u1EA7u v\xE0 k\u1EBFt th\xFAc
        idx = context_start
        while idx <= context_end and offset[idx][0] <= start_char:
            idx += 1
        start_positions.append(idx - 1)

        idx = context_end
        while idx >= context_start and offset[idx][1] >= end_char:
            idx -= 1
        end_positions.append(idx + 1)

start_positions, end_positions`,highlighted:`answers = raw_datasets[<span class="hljs-string">&quot;train&quot;</span>][<span class="hljs-number">2</span>:<span class="hljs-number">6</span>][<span class="hljs-string">&quot;answers&quot;</span>]
start_positions = []
end_positions = []

<span class="hljs-keyword">for</span> i, offset <span class="hljs-keyword">in</span> <span class="hljs-built_in">enumerate</span>(inputs[<span class="hljs-string">&quot;offset_mapping&quot;</span>]):
    sample_idx = inputs[<span class="hljs-string">&quot;overflow_to_sample_mapping&quot;</span>][i]
    answer = answers[sample_idx]
    start_char = answer[<span class="hljs-string">&quot;answer_start&quot;</span>][<span class="hljs-number">0</span>]
    end_char = answer[<span class="hljs-string">&quot;answer_start&quot;</span>][<span class="hljs-number">0</span>] + <span class="hljs-built_in">len</span>(answer[<span class="hljs-string">&quot;text&quot;</span>][<span class="hljs-number">0</span>])
    sequence_ids = inputs.sequence_ids(i)

    <span class="hljs-comment"># T\xECm \u0111i\u1EC3m b\u1EAFt \u0111\u1EA7u v\xE0 k\u1EBFt th\xFAc c\u1EE7a ng\u1EEF c\u1EA3nh</span>
    <span class="hljs-keyword">while</span> sequence_ids[idx] != <span class="hljs-number">1</span>:
        idx += <span class="hljs-number">1</span>
    context_start = idx
    <span class="hljs-keyword">while</span> sequence_ids[idx] == <span class="hljs-number">1</span>:
        idx += <span class="hljs-number">1</span>
    context_end = idx - <span class="hljs-number">1</span>

    <span class="hljs-comment"># N\u1EBFu c\xE2u tr\u1EA3 l\u1EDDi kh\xF4ng ho\xE0n to\xE0n n\u1EB1m trong ng\u1EEF c\u1EA3nh, nh\xE3n l\xE0 (0, 0)</span>
    <span class="hljs-keyword">if</span> offset[context_start][<span class="hljs-number">0</span>] &gt; start_char <span class="hljs-keyword">or</span> offset[context_end][<span class="hljs-number">1</span>] &lt; end_char:
        start_positions.append(<span class="hljs-number">0</span>)
        end_positions.append(<span class="hljs-number">0</span>)
    <span class="hljs-keyword">else</span>:
        <span class="hljs-comment"># N\u1EBFu kh\xF4ng n\xF3 s\u1EBD l\xE0 v\u1ECB tr\xED b\u1EAFt \u0111\u1EA7u v\xE0 k\u1EBFt th\xFAc</span>
        idx = context_start
        <span class="hljs-keyword">while</span> idx &lt;= context_end <span class="hljs-keyword">and</span> offset[idx][<span class="hljs-number">0</span>] &lt;= start_char:
            idx += <span class="hljs-number">1</span>
        start_positions.append(idx - <span class="hljs-number">1</span>)

        idx = context_end
        <span class="hljs-keyword">while</span> idx &gt;= context_start <span class="hljs-keyword">and</span> offset[idx][<span class="hljs-number">1</span>] &gt;= end_char:
            idx -= <span class="hljs-number">1</span>
        end_positions.append(idx + <span class="hljs-number">1</span>)

start_positions, end_positions`}}),hi=new S({props:{code:`([83, 51, 19, 0, 0, 64, 27, 0, 34, 0, 0, 0, 67, 34, 0, 0, 0, 0, 0],
 [85, 53, 21, 0, 0, 70, 33, 0, 40, 0, 0, 0, 68, 35, 0, 0, 0, 0, 0])`,highlighted:`([<span class="hljs-number">83</span>, <span class="hljs-number">51</span>, <span class="hljs-number">19</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">64</span>, <span class="hljs-number">27</span>, <span class="hljs-number">0</span>, <span class="hljs-number">34</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">67</span>, <span class="hljs-number">34</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">85</span>, <span class="hljs-number">53</span>, <span class="hljs-number">21</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">70</span>, <span class="hljs-number">33</span>, <span class="hljs-number">0</span>, <span class="hljs-number">40</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">68</span>, <span class="hljs-number">35</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>])`}}),ri=new S({props:{code:`idx = 0
sample_idx = inputs["overflow_to_sample_mapping"][idx]
answer = answers[sample_idx]["text"][0]

start = start_positions[idx]
end = end_positions[idx]
labeled_answer = tokenizer.decode(inputs["input_ids"][idx][start : end + 1])

print(f"Theoretical answer: {answer}, labels give: {labeled_answer}")`,highlighted:`idx = <span class="hljs-number">0</span>
sample_idx = inputs[<span class="hljs-string">&quot;overflow_to_sample_mapping&quot;</span>][idx]
answer = answers[sample_idx][<span class="hljs-string">&quot;text&quot;</span>][<span class="hljs-number">0</span>]

start = start_positions[idx]
end = end_positions[idx]
labeled_answer = tokenizer.decode(inputs[<span class="hljs-string">&quot;input_ids&quot;</span>][idx][start : end + <span class="hljs-number">1</span>])

<span class="hljs-built_in">print</span>(<span class="hljs-string">f&quot;Theoretical answer: <span class="hljs-subst">{answer}</span>, labels give: <span class="hljs-subst">{labeled_answer}</span>&quot;</span>)`}}),oi=new S({props:{code:"'Theoretical answer: the Main Building, labels give: the Main Building'",highlighted:'<span class="hljs-string">&#x27;Theoretical answer: the Main Building, labels give: the Main Building&#x27;</span>'}}),pi=new S({props:{code:`idx = 4
sample_idx = inputs["overflow_to_sample_mapping"][idx]
answer = answers[sample_idx]["text"][0]

decoded_example = tokenizer.decode(inputs["input_ids"][idx])
print(f"Theoretical answer: {answer}, decoded example: {decoded_example}")`,highlighted:`idx = <span class="hljs-number">4</span>
sample_idx = inputs[<span class="hljs-string">&quot;overflow_to_sample_mapping&quot;</span>][idx]
answer = answers[sample_idx][<span class="hljs-string">&quot;text&quot;</span>][<span class="hljs-number">0</span>]

decoded_example = tokenizer.decode(inputs[<span class="hljs-string">&quot;input_ids&quot;</span>][idx])
<span class="hljs-built_in">print</span>(<span class="hljs-string">f&quot;Theoretical answer: <span class="hljs-subst">{answer}</span>, decoded example: <span class="hljs-subst">{decoded_example}</span>&quot;</span>)`}}),ui=new S({props:{code:`'Theoretical answer: a Marian place of prayer and reflection, decoded example: [CLS] What is the Grotto at Notre Dame? [SEP] Architecturally, the school has a Catholic character. Atop the Main Building\\'s gold dome is a golden statue of the Virgin Mary. Immediately in front of the Main Building and facing it, is a copper statue of Christ with arms upraised with the legend " Venite Ad Me Omnes ". Next to the Main Building is the Basilica of the Sacred Heart. Immediately behind the basilica is the Grot [SEP]'`,highlighted:'<span class="hljs-string">&#x27;Theoretical answer: a Marian place of prayer and reflection, decoded example: [CLS] What is the Grotto at Notre Dame? [SEP] Architecturally, the school has a Catholic character. Atop the Main Building\\&#x27;s gold dome is a golden statue of the Virgin Mary. Immediately in front of the Main Building and facing it, is a copper statue of Christ with arms upraised with the legend &quot; Venite Ad Me Omnes &quot;. Next to the Main Building is the Basilica of the Sacred Heart. Immediately behind the basilica is the Grot [SEP]&#x27;</span>'}}),pa=new xo({props:{$$slots:{default:[Wd]},$$scope:{ctx:H}}}),mi=new S({props:{code:`max_length = 384
stride = 128


def preprocess_training_examples(examples):
    questions = [q.strip() for q in examples["question"]]
    inputs = tokenizer(
        questions,
        examples["context"],
        max_length=max_length,
        truncation="only_second",
        stride=stride,
        return_overflowing_tokens=True,
        return_offsets_mapping=True,
        padding="max_length",
    )

    offset_mapping = inputs.pop("offset_mapping")
    sample_map = inputs.pop("overflow_to_sample_mapping")
    answers = examples["answers"]
    start_positions = []
    end_positions = []

    for i, offset in enumerate(offset_mapping):
        sample_idx = sample_map[i]
        answer = answers[sample_idx]
        start_char = answer["answer_start"][0]
        end_char = answer["answer_start"][0] + len(answer["text"][0])
        sequence_ids = inputs.sequence_ids(i)

        # T\xECm \u0111i\u1EC3m b\u1EAFt \u0111\u1EA7u v\xE0 k\u1EBFt th\xFAc c\u1EE7a ng\u1EEF c\u1EA3nh
        idx = 0
        while sequence_ids[idx] != 1:
            idx += 1
        context_start = idx
        while sequence_ids[idx] == 1:
            idx += 1
        context_end = idx - 1

        # N\u1EBFu c\xE2u tr\u1EA3 l\u1EDDi kh\xF4ng ho\xE0n to\xE0n n\u1EB1m trong ng\u1EEF c\u1EA3nh, nh\xE3n l\xE0 (0, 0)
        if offset[context_start][0] > start_char or offset[context_end][1] < end_char:
            start_positions.append(0)
            end_positions.append(0)
        else:
            # N\u1EBFu kh\xF4ng n\xF3 s\u1EBD l\xE0 v\u1ECB tr\xED token b\u1EAFt \u0111\u1EA7u v\xE0 k\u1EBFt th\xFAc
            idx = context_start
            while idx <= context_end and offset[idx][0] <= start_char:
                idx += 1
            start_positions.append(idx - 1)

            idx = context_end
            while idx >= context_start and offset[idx][1] >= end_char:
                idx -= 1
            end_positions.append(idx + 1)

    inputs["start_positions"] = start_positions
    inputs["end_positions"] = end_positions
    return inputs`,highlighted:`max_length = <span class="hljs-number">384</span>
stride = <span class="hljs-number">128</span>


<span class="hljs-keyword">def</span> <span class="hljs-title function_">preprocess_training_examples</span>(<span class="hljs-params">examples</span>):
    questions = [q.strip() <span class="hljs-keyword">for</span> q <span class="hljs-keyword">in</span> examples[<span class="hljs-string">&quot;question&quot;</span>]]
    inputs = tokenizer(
        questions,
        examples[<span class="hljs-string">&quot;context&quot;</span>],
        max_length=max_length,
        truncation=<span class="hljs-string">&quot;only_second&quot;</span>,
        stride=stride,
        return_overflowing_tokens=<span class="hljs-literal">True</span>,
        return_offsets_mapping=<span class="hljs-literal">True</span>,
        padding=<span class="hljs-string">&quot;max_length&quot;</span>,
    )

    offset_mapping = inputs.pop(<span class="hljs-string">&quot;offset_mapping&quot;</span>)
    sample_map = inputs.pop(<span class="hljs-string">&quot;overflow_to_sample_mapping&quot;</span>)
    answers = examples[<span class="hljs-string">&quot;answers&quot;</span>]
    start_positions = []
    end_positions = []

    <span class="hljs-keyword">for</span> i, offset <span class="hljs-keyword">in</span> <span class="hljs-built_in">enumerate</span>(offset_mapping):
        sample_idx = sample_map[i]
        answer = answers[sample_idx]
        start_char = answer[<span class="hljs-string">&quot;answer_start&quot;</span>][<span class="hljs-number">0</span>]
        end_char = answer[<span class="hljs-string">&quot;answer_start&quot;</span>][<span class="hljs-number">0</span>] + <span class="hljs-built_in">len</span>(answer[<span class="hljs-string">&quot;text&quot;</span>][<span class="hljs-number">0</span>])
        sequence_ids = inputs.sequence_ids(i)

        <span class="hljs-comment"># T\xECm \u0111i\u1EC3m b\u1EAFt \u0111\u1EA7u v\xE0 k\u1EBFt th\xFAc c\u1EE7a ng\u1EEF c\u1EA3nh</span>
        idx = <span class="hljs-number">0</span>
        <span class="hljs-keyword">while</span> sequence_ids[idx] != <span class="hljs-number">1</span>:
            idx += <span class="hljs-number">1</span>
        context_start = idx
        <span class="hljs-keyword">while</span> sequence_ids[idx] == <span class="hljs-number">1</span>:
            idx += <span class="hljs-number">1</span>
        context_end = idx - <span class="hljs-number">1</span>

        <span class="hljs-comment"># N\u1EBFu c\xE2u tr\u1EA3 l\u1EDDi kh\xF4ng ho\xE0n to\xE0n n\u1EB1m trong ng\u1EEF c\u1EA3nh, nh\xE3n l\xE0 (0, 0)</span>
        <span class="hljs-keyword">if</span> offset[context_start][<span class="hljs-number">0</span>] &gt; start_char <span class="hljs-keyword">or</span> offset[context_end][<span class="hljs-number">1</span>] &lt; end_char:
            start_positions.append(<span class="hljs-number">0</span>)
            end_positions.append(<span class="hljs-number">0</span>)
        <span class="hljs-keyword">else</span>:
            <span class="hljs-comment"># N\u1EBFu kh\xF4ng n\xF3 s\u1EBD l\xE0 v\u1ECB tr\xED token b\u1EAFt \u0111\u1EA7u v\xE0 k\u1EBFt th\xFAc</span>
            idx = context_start
            <span class="hljs-keyword">while</span> idx &lt;= context_end <span class="hljs-keyword">and</span> offset[idx][<span class="hljs-number">0</span>] &lt;= start_char:
                idx += <span class="hljs-number">1</span>
            start_positions.append(idx - <span class="hljs-number">1</span>)

            idx = context_end
            <span class="hljs-keyword">while</span> idx &gt;= context_start <span class="hljs-keyword">and</span> offset[idx][<span class="hljs-number">1</span>] &gt;= end_char:
                idx -= <span class="hljs-number">1</span>
            end_positions.append(idx + <span class="hljs-number">1</span>)

    inputs[<span class="hljs-string">&quot;start_positions&quot;</span>] = start_positions
    inputs[<span class="hljs-string">&quot;end_positions&quot;</span>] = end_positions
    <span class="hljs-keyword">return</span> inputs`}}),gi=new S({props:{code:`train_dataset = raw_datasets["train"].map(
    preprocess_training_examples,
    batched=True,
    remove_columns=raw_datasets["train"].column_names,
)
len(raw_datasets["train"]), len(train_dataset)`,highlighted:`train_dataset = raw_datasets[<span class="hljs-string">&quot;train&quot;</span>].<span class="hljs-built_in">map</span>(
    preprocess_training_examples,
    batched=<span class="hljs-literal">True</span>,
    remove_columns=raw_datasets[<span class="hljs-string">&quot;train&quot;</span>].column_names,
)
<span class="hljs-built_in">len</span>(raw_datasets[<span class="hljs-string">&quot;train&quot;</span>]), <span class="hljs-built_in">len</span>(train_dataset)`}}),di=new S({props:{code:"(87599, 88729)",highlighted:'(<span class="hljs-number">87599</span>, <span class="hljs-number">88729</span>)'}}),fi=new nn({}),_i=new S({props:{code:`def preprocess_validation_examples(examples):
    questions = [q.strip() for q in examples["question"]]
    inputs = tokenizer(
        questions,
        examples["context"],
        max_length=max_length,
        truncation="only_second",
        stride=stride,
        return_overflowing_tokens=True,
        return_offsets_mapping=True,
        padding="max_length",
    )

    sample_map = inputs.pop("overflow_to_sample_mapping")
    example_ids = []

    for i in range(len(inputs["input_ids"])):
        sample_idx = sample_map[i]
        example_ids.append(examples["id"][sample_idx])

        sequence_ids = inputs.sequence_ids(i)
        offset = inputs["offset_mapping"][i]
        inputs["offset_mapping"][i] = [
            o if sequence_ids[k] == 1 else None for k, o in enumerate(offset)
        ]

    inputs["example_id"] = example_ids
    return inputs`,highlighted:`<span class="hljs-keyword">def</span> <span class="hljs-title function_">preprocess_validation_examples</span>(<span class="hljs-params">examples</span>):
    questions = [q.strip() <span class="hljs-keyword">for</span> q <span class="hljs-keyword">in</span> examples[<span class="hljs-string">&quot;question&quot;</span>]]
    inputs = tokenizer(
        questions,
        examples[<span class="hljs-string">&quot;context&quot;</span>],
        max_length=max_length,
        truncation=<span class="hljs-string">&quot;only_second&quot;</span>,
        stride=stride,
        return_overflowing_tokens=<span class="hljs-literal">True</span>,
        return_offsets_mapping=<span class="hljs-literal">True</span>,
        padding=<span class="hljs-string">&quot;max_length&quot;</span>,
    )

    sample_map = inputs.pop(<span class="hljs-string">&quot;overflow_to_sample_mapping&quot;</span>)
    example_ids = []

    <span class="hljs-keyword">for</span> i <span class="hljs-keyword">in</span> <span class="hljs-built_in">range</span>(<span class="hljs-built_in">len</span>(inputs[<span class="hljs-string">&quot;input_ids&quot;</span>])):
        sample_idx = sample_map[i]
        example_ids.append(examples[<span class="hljs-string">&quot;id&quot;</span>][sample_idx])

        sequence_ids = inputs.sequence_ids(i)
        offset = inputs[<span class="hljs-string">&quot;offset_mapping&quot;</span>][i]
        inputs[<span class="hljs-string">&quot;offset_mapping&quot;</span>][i] = [
            o <span class="hljs-keyword">if</span> sequence_ids[k] == <span class="hljs-number">1</span> <span class="hljs-keyword">else</span> <span class="hljs-literal">None</span> <span class="hljs-keyword">for</span> k, o <span class="hljs-keyword">in</span> <span class="hljs-built_in">enumerate</span>(offset)
        ]

    inputs[<span class="hljs-string">&quot;example_id&quot;</span>] = example_ids
    <span class="hljs-keyword">return</span> inputs`}}),vi=new S({props:{code:`validation_dataset = raw_datasets["validation"].map(
    preprocess_validation_examples,
    batched=True,
    remove_columns=raw_datasets["validation"].column_names,
)
len(raw_datasets["validation"]), len(validation_dataset)`,highlighted:`validation_dataset = raw_datasets[<span class="hljs-string">&quot;validation&quot;</span>].<span class="hljs-built_in">map</span>(
    preprocess_validation_examples,
    batched=<span class="hljs-literal">True</span>,
    remove_columns=raw_datasets[<span class="hljs-string">&quot;validation&quot;</span>].column_names,
)
<span class="hljs-built_in">len</span>(raw_datasets[<span class="hljs-string">&quot;validation&quot;</span>]), <span class="hljs-built_in">len</span>(validation_dataset)`}}),bi=new S({props:{code:"(10570, 10822)",highlighted:'(<span class="hljs-number">10570</span>, <span class="hljs-number">10822</span>)'}});const sm=[Xd,Ud],Gi=[];function am(t,l){return t[0]==="pt"?0:1}Gn=am(H),Rn=Gi[Gn]=sm[Gn](H),ki=new nn({});const im=[Yd,Jd],Ri=[];function lm(t,l){return t[0]==="pt"?0:1}Kn=lm(H),Wn=Ri[Kn]=im[Kn](H),xi=new S({props:{code:`small_eval_set = raw_datasets["validation"].select(range(100))
trained_checkpoint = "distilbert-base-cased-distilled-squad"

tokenizer = AutoTokenizer.from_pretrained(trained_checkpoint)
eval_set = small_eval_set.map(
    preprocess_validation_examples,
    batched=True,
    remove_columns=raw_datasets["validation"].column_names,
)`,highlighted:`small_eval_set = raw_datasets[<span class="hljs-string">&quot;validation&quot;</span>].select(<span class="hljs-built_in">range</span>(<span class="hljs-number">100</span>))
trained_checkpoint = <span class="hljs-string">&quot;distilbert-base-cased-distilled-squad&quot;</span>

tokenizer = AutoTokenizer.from_pretrained(trained_checkpoint)
eval_set = small_eval_set.<span class="hljs-built_in">map</span>(
    preprocess_validation_examples,
    batched=<span class="hljs-literal">True</span>,
    remove_columns=raw_datasets[<span class="hljs-string">&quot;validation&quot;</span>].column_names,
)`}}),$i=new S({props:{code:"tokenizer = AutoTokenizer.from_pretrained(model_checkpoint)",highlighted:"tokenizer = AutoTokenizer.from_pretrained(model_checkpoint)"}});const cm=[tf,Zd],Ki=[];function hm(t,l){return t[0]==="pt"?0:1}Un=hm(H),Xn=Ki[Un]=cm[Un](H),wi=new S({props:{code:`import collections

example_to_features = collections.defaultdict(list)
for idx, feature in enumerate(eval_set):
    example_to_features[feature["example_id"]].append(idx)`,highlighted:`<span class="hljs-keyword">import</span> collections

example_to_features = collections.defaultdict(<span class="hljs-built_in">list</span>)
<span class="hljs-keyword">for</span> idx, feature <span class="hljs-keyword">in</span> <span class="hljs-built_in">enumerate</span>(eval_set):
    example_to_features[feature[<span class="hljs-string">&quot;example_id&quot;</span>]].append(idx)`}}),qi=new S({props:{code:`import numpy as np

n_best = 20
max_answer_length = 30
predicted_answers = []

for example in small_eval_set:
    example_id = example["id"]
    context = example["context"]
    answers = []

    for feature_index in example_to_features[example_id]:
        start_logit = start_logits[feature_index]
        end_logit = end_logits[feature_index]
        offsets = eval_set["offset_mapping"][feature_index]

        start_indexes = np.argsort(start_logit)[-1 : -n_best - 1 : -1].tolist()
        end_indexes = np.argsort(end_logit)[-1 : -n_best - 1 : -1].tolist()
        for start_index in start_indexes:
            for end_index in end_indexes:
                # B\u1ECF qua c\xE1c c\xE2u tr\u1EA3 l\u1EDDi kh\xF4ng \u0111\u1EA7u \u0111\u1EE7 trong ng\u1EEF c\u1EA3nh
                if offsets[start_index] is None or offsets[end_index] is None:
                    continue
                # B\u1ECF qua nh\u1EEFng c\xE2u tr\u1EA3 l\u1EDDi c\xF3 \u0111\u1ED9 d\xE0i < 0 ho\u1EB7c > max_answer_length.
                if (
                    end_index < start_index
                    or end_index - start_index + 1 > max_answer_length
                ):
                    continue

                answers.append(
                    {
                        "text": context[offsets[start_index][0] : offsets[end_index][1]],
                        "logit_score": start_logit[start_index] + end_logit[end_index],
                    }
                )

    best_answer = max(answers, key=lambda x: x["logit_score"])
    predicted_answers.append({"id": example_id, "prediction_text": best_answer["text"]})`,highlighted:`<span class="hljs-keyword">import</span> numpy <span class="hljs-keyword">as</span> np

n_best = <span class="hljs-number">20</span>
max_answer_length = <span class="hljs-number">30</span>
predicted_answers = []

<span class="hljs-keyword">for</span> example <span class="hljs-keyword">in</span> small_eval_set:
    example_id = example[<span class="hljs-string">&quot;id&quot;</span>]
    context = example[<span class="hljs-string">&quot;context&quot;</span>]
    answers = []

    <span class="hljs-keyword">for</span> feature_index <span class="hljs-keyword">in</span> example_to_features[example_id]:
        start_logit = start_logits[feature_index]
        end_logit = end_logits[feature_index]
        offsets = eval_set[<span class="hljs-string">&quot;offset_mapping&quot;</span>][feature_index]

        start_indexes = np.argsort(start_logit)[-<span class="hljs-number">1</span> : -n_best - <span class="hljs-number">1</span> : -<span class="hljs-number">1</span>].tolist()
        end_indexes = np.argsort(end_logit)[-<span class="hljs-number">1</span> : -n_best - <span class="hljs-number">1</span> : -<span class="hljs-number">1</span>].tolist()
        <span class="hljs-keyword">for</span> start_index <span class="hljs-keyword">in</span> start_indexes:
            <span class="hljs-keyword">for</span> end_index <span class="hljs-keyword">in</span> end_indexes:
                <span class="hljs-comment"># B\u1ECF qua c\xE1c c\xE2u tr\u1EA3 l\u1EDDi kh\xF4ng \u0111\u1EA7u \u0111\u1EE7 trong ng\u1EEF c\u1EA3nh</span>
                <span class="hljs-keyword">if</span> offsets[start_index] <span class="hljs-keyword">is</span> <span class="hljs-literal">None</span> <span class="hljs-keyword">or</span> offsets[end_index] <span class="hljs-keyword">is</span> <span class="hljs-literal">None</span>:
                    <span class="hljs-keyword">continue</span>
                <span class="hljs-comment"># B\u1ECF qua nh\u1EEFng c\xE2u tr\u1EA3 l\u1EDDi c\xF3 \u0111\u1ED9 d\xE0i &lt; 0 ho\u1EB7c &gt; max_answer_length.</span>
                <span class="hljs-keyword">if</span> (
                    end_index &lt; start_index
                    <span class="hljs-keyword">or</span> end_index - start_index + <span class="hljs-number">1</span> &gt; max_answer_length
                ):
                    <span class="hljs-keyword">continue</span>

                answers.append(
                    {
                        <span class="hljs-string">&quot;text&quot;</span>: context[offsets[start_index][<span class="hljs-number">0</span>] : offsets[end_index][<span class="hljs-number">1</span>]],
                        <span class="hljs-string">&quot;logit_score&quot;</span>: start_logit[start_index] + end_logit[end_index],
                    }
                )

    best_answer = <span class="hljs-built_in">max</span>(answers, key=<span class="hljs-keyword">lambda</span> x: x[<span class="hljs-string">&quot;logit_score&quot;</span>])
    predicted_answers.append({<span class="hljs-string">&quot;id&quot;</span>: example_id, <span class="hljs-string">&quot;prediction_text&quot;</span>: best_answer[<span class="hljs-string">&quot;text&quot;</span>]})`}}),Ei=new S({props:{code:`import evaluate

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

metric = evaluate.load(<span class="hljs-string">&quot;squad&quot;</span>)`}}),Ci=new S({props:{code:`theoretical_answers = [
    {"id": ex["id"], "answers": ex["answers"]} for ex in small_eval_set
]`,highlighted:`theoretical_answers = [
    {<span class="hljs-string">&quot;id&quot;</span>: ex[<span class="hljs-string">&quot;id&quot;</span>], <span class="hljs-string">&quot;answers&quot;</span>: ex[<span class="hljs-string">&quot;answers&quot;</span>]} <span class="hljs-keyword">for</span> ex <span class="hljs-keyword">in</span> small_eval_set
]`}}),Ti=new S({props:{code:`print(predicted_answers[0])
print(theoretical_answers[0])`,highlighted:`<span class="hljs-built_in">print</span>(predicted_answers[<span class="hljs-number">0</span>])
<span class="hljs-built_in">print</span>(theoretical_answers[<span class="hljs-number">0</span>])`}}),Di=new S({props:{code:`{'id': '56be4db0acb8001400a502ec', 'prediction_text': 'Denver Broncos'}
{'id': '56be4db0acb8001400a502ec', 'answers': {'text': ['Denver Broncos', 'Denver Broncos', 'Denver Broncos'], 'answer_start': [177, 177, 177]}}`,highlighted:`{<span class="hljs-string">&#x27;id&#x27;</span>: <span class="hljs-string">&#x27;56be4db0acb8001400a502ec&#x27;</span>, <span class="hljs-string">&#x27;prediction_text&#x27;</span>: <span class="hljs-string">&#x27;Denver Broncos&#x27;</span>}
{<span class="hljs-string">&#x27;id&#x27;</span>: <span class="hljs-string">&#x27;56be4db0acb8001400a502ec&#x27;</span>, <span class="hljs-string">&#x27;answers&#x27;</span>: {<span class="hljs-string">&#x27;text&#x27;</span>: [<span class="hljs-string">&#x27;Denver Broncos&#x27;</span>, <span class="hljs-string">&#x27;Denver Broncos&#x27;</span>, <span class="hljs-string">&#x27;Denver Broncos&#x27;</span>], <span class="hljs-string">&#x27;answer_start&#x27;</span>: [<span class="hljs-number">177</span>, <span class="hljs-number">177</span>, <span class="hljs-number">177</span>]}}`}}),Ai=new S({props:{code:"metric.compute(predictions=predicted_answers, references=theoretical_answers)",highlighted:"metric.compute(predictions=predicted_answers, references=theoretical_answers)"}}),Pi=new S({props:{code:"{'exact_match': 83.0, 'f1': 88.25}",highlighted:'{<span class="hljs-string">&#x27;exact_match&#x27;</span>: <span class="hljs-number">83.0</span>, <span class="hljs-string">&#x27;f1&#x27;</span>: <span class="hljs-number">88.25</span>}'}});function rm(t,l){return t[0]==="pt"?ef:nf}let Zr=rm(H),bs=Zr(H);Bi=new S({props:{code:`from tqdm.auto import tqdm


def compute_metrics(start_logits, end_logits, features, examples):
    example_to_features = collections.defaultdict(list)
    for idx, feature in enumerate(features):
        example_to_features[feature["example_id"]].append(idx)

    predicted_answers = []
    for example in tqdm(examples):
        example_id = example["id"]
        context = example["context"]
        answers = []

        # L\u1EB7p qua t\u1EA5t c\u1EA3 c\xE1c \u0111\u1EB7c tr\u01B0ng li\xEAn quan t\u1EDBi m\u1EABu \u0111\xF3
        for feature_index in example_to_features[example_id]:
            start_logit = start_logits[feature_index]
            end_logit = end_logits[feature_index]
            offsets = features[feature_index]["offset_mapping"]

            start_indexes = np.argsort(start_logit)[-1 : -n_best - 1 : -1].tolist()
            end_indexes = np.argsort(end_logit)[-1 : -n_best - 1 : -1].tolist()
            for start_index in start_indexes:
                for end_index in end_indexes:
                    # B\u1ECF qua c\xE2u tr\u1EA3 l\u1EDDi kh\xF4ng xu\u1EA5t hi\u1EC7n ho\xE0n to\xE0n trong ng\u1EEF c\u1EA3nh
                    if offsets[start_index] is None or offsets[end_index] is None:
                        continue
                    # B\u1ECF qua nh\u1EEFng c\xE2u tr\u1EA3 l\u1EDDi v\u1EDBi \u0111\u1ED9 d\xE0i < 0 ho\u1EB7c > max_answer_length
                    if (
                        end_index < start_index
                        or end_index - start_index + 1 > max_answer_length
                    ):
                        continue

                    answer = {
                        "text": context[offsets[start_index][0] : offsets[end_index][1]],
                        "logit_score": start_logit[start_index] + end_logit[end_index],
                    }
                    answers.append(answer)

        # Ch\u1ECDn c\xE2u tr\u1EA3 l\u1EDDi c\xF3 \u0111i\u1EC3m cao nh\u1EA5t
        if len(answers) > 0:
            best_answer = max(answers, key=lambda x: x["logit_score"])
            predicted_answers.append(
                {"id": example_id, "prediction_text": best_answer["text"]}
            )
        else:
            predicted_answers.append({"id": example_id, "prediction_text": ""})

    theoretical_answers = [{"id": ex["id"], "answers": ex["answers"]} for ex in examples]
    return metric.compute(predictions=predicted_answers, references=theoretical_answers)`,highlighted:`<span class="hljs-keyword">from</span> tqdm.auto <span class="hljs-keyword">import</span> tqdm


<span class="hljs-keyword">def</span> <span class="hljs-title function_">compute_metrics</span>(<span class="hljs-params">start_logits, end_logits, features, examples</span>):
    example_to_features = collections.defaultdict(<span class="hljs-built_in">list</span>)
    <span class="hljs-keyword">for</span> idx, feature <span class="hljs-keyword">in</span> <span class="hljs-built_in">enumerate</span>(features):
        example_to_features[feature[<span class="hljs-string">&quot;example_id&quot;</span>]].append(idx)

    predicted_answers = []
    <span class="hljs-keyword">for</span> example <span class="hljs-keyword">in</span> tqdm(examples):
        example_id = example[<span class="hljs-string">&quot;id&quot;</span>]
        context = example[<span class="hljs-string">&quot;context&quot;</span>]
        answers = []

        <span class="hljs-comment"># L\u1EB7p qua t\u1EA5t c\u1EA3 c\xE1c \u0111\u1EB7c tr\u01B0ng li\xEAn quan t\u1EDBi m\u1EABu \u0111\xF3</span>
        <span class="hljs-keyword">for</span> feature_index <span class="hljs-keyword">in</span> example_to_features[example_id]:
            start_logit = start_logits[feature_index]
            end_logit = end_logits[feature_index]
            offsets = features[feature_index][<span class="hljs-string">&quot;offset_mapping&quot;</span>]

            start_indexes = np.argsort(start_logit)[-<span class="hljs-number">1</span> : -n_best - <span class="hljs-number">1</span> : -<span class="hljs-number">1</span>].tolist()
            end_indexes = np.argsort(end_logit)[-<span class="hljs-number">1</span> : -n_best - <span class="hljs-number">1</span> : -<span class="hljs-number">1</span>].tolist()
            <span class="hljs-keyword">for</span> start_index <span class="hljs-keyword">in</span> start_indexes:
                <span class="hljs-keyword">for</span> end_index <span class="hljs-keyword">in</span> end_indexes:
                    <span class="hljs-comment"># B\u1ECF qua c\xE2u tr\u1EA3 l\u1EDDi kh\xF4ng xu\u1EA5t hi\u1EC7n ho\xE0n to\xE0n trong ng\u1EEF c\u1EA3nh</span>
                    <span class="hljs-keyword">if</span> offsets[start_index] <span class="hljs-keyword">is</span> <span class="hljs-literal">None</span> <span class="hljs-keyword">or</span> offsets[end_index] <span class="hljs-keyword">is</span> <span class="hljs-literal">None</span>:
                        <span class="hljs-keyword">continue</span>
                    <span class="hljs-comment"># B\u1ECF qua nh\u1EEFng c\xE2u tr\u1EA3 l\u1EDDi v\u1EDBi \u0111\u1ED9 d\xE0i &lt; 0 ho\u1EB7c &gt; max_answer_length</span>
                    <span class="hljs-keyword">if</span> (
                        end_index &lt; start_index
                        <span class="hljs-keyword">or</span> end_index - start_index + <span class="hljs-number">1</span> &gt; max_answer_length
                    ):
                        <span class="hljs-keyword">continue</span>

                    answer = {
                        <span class="hljs-string">&quot;text&quot;</span>: context[offsets[start_index][<span class="hljs-number">0</span>] : offsets[end_index][<span class="hljs-number">1</span>]],
                        <span class="hljs-string">&quot;logit_score&quot;</span>: start_logit[start_index] + end_logit[end_index],
                    }
                    answers.append(answer)

        <span class="hljs-comment"># Ch\u1ECDn c\xE2u tr\u1EA3 l\u1EDDi c\xF3 \u0111i\u1EC3m cao nh\u1EA5t</span>
        <span class="hljs-keyword">if</span> <span class="hljs-built_in">len</span>(answers) &gt; <span class="hljs-number">0</span>:
            best_answer = <span class="hljs-built_in">max</span>(answers, key=<span class="hljs-keyword">lambda</span> x: x[<span class="hljs-string">&quot;logit_score&quot;</span>])
            predicted_answers.append(
                {<span class="hljs-string">&quot;id&quot;</span>: example_id, <span class="hljs-string">&quot;prediction_text&quot;</span>: best_answer[<span class="hljs-string">&quot;text&quot;</span>]}
            )
        <span class="hljs-keyword">else</span>:
            predicted_answers.append({<span class="hljs-string">&quot;id&quot;</span>: example_id, <span class="hljs-string">&quot;prediction_text&quot;</span>: <span class="hljs-string">&quot;&quot;</span>})

    theoretical_answers = [{<span class="hljs-string">&quot;id&quot;</span>: ex[<span class="hljs-string">&quot;id&quot;</span>], <span class="hljs-string">&quot;answers&quot;</span>: ex[<span class="hljs-string">&quot;answers&quot;</span>]} <span class="hljs-keyword">for</span> ex <span class="hljs-keyword">in</span> examples]
    <span class="hljs-keyword">return</span> metric.compute(predictions=predicted_answers, references=theoretical_answers)`}}),Ni=new S({props:{code:"compute_metrics(start_logits, end_logits, eval_set, small_eval_set)",highlighted:"compute_metrics(start_logits, end_logits, eval_set, small_eval_set)"}}),Mi=new S({props:{code:"{'exact_match': 83.0, 'f1': 88.25}",highlighted:'{<span class="hljs-string">&#x27;exact_match&#x27;</span>: <span class="hljs-number">83.0</span>, <span class="hljs-string">&#x27;f1&#x27;</span>: <span class="hljs-number">88.25</span>}'}}),Oi=new nn({});const om=[af,sf],Wi=[];function pm(t,l){return t[0]==="pt"?0:1}Jn=pm(H),Yn=Wi[Jn]=om[Jn](H),zi=new S({props:{code:`from huggingface_hub import notebook_login

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

notebook_login()`}}),Li=new S({props:{code:"huggingface-cli login",highlighted:"huggingface-cli login"}});const um=[cf,lf],Ui=[];function mm(t,l){return t[0]==="pt"?0:1}Zn=mm(H),te=Ui[Zn]=um[Zn](H);const gm=[rf,hf],Xi=[];function dm(t,l){return t[0]==="pt"?0:1}ne=dm(H),ee=Xi[ne]=gm[ne](H);const fm=[uf,pf],Ji=[];function _m(t,l){return t[0]==="pt"?0:1}se=_m(H),ae=Ji[se]=fm[se](H),Fi=new S({props:{code:"{'exact_match': 81.18259224219489, 'f1': 88.67381321905516}",highlighted:'{<span class="hljs-string">&#x27;exact_match&#x27;</span>: <span class="hljs-number">81.18259224219489</span>, <span class="hljs-string">&#x27;f1&#x27;</span>: <span class="hljs-number">88.67381321905516</span>}'}});let ht=H[0]==="pt"&&Md();ka=new xo({props:{$$slots:{default:[mf]},$$scope:{ctx:H}}});let rt=H[0]==="pt"&&Od();return Hi=new nn({}),Ii=new S({props:{code:`from transformers import pipeline

# Thay th\u1EBF n\xF3 v\u1EDBi checkpoint c\u1EE7a b\u1EA1n
model_checkpoint = "huggingface-course/bert-finetuned-squad"
question_answerer = pipeline("question-answering", model=model_checkpoint)

context = """
\u{1F917} Transformers is backed by the three most popular deep learning libraries \u2014 Jax, PyTorch and TensorFlow \u2014 with a seamless integration
between them. It's straightforward to train your models with one before loading them for inference with the other.
"""
question = "Which deep learning libraries back \u{1F917} Transformers?"
question_answerer(question=question, context=context)`,highlighted:`<span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> pipeline

<span class="hljs-comment"># Thay th\u1EBF n\xF3 v\u1EDBi checkpoint c\u1EE7a b\u1EA1n</span>
model_checkpoint = <span class="hljs-string">&quot;huggingface-course/bert-finetuned-squad&quot;</span>
question_answerer = pipeline(<span class="hljs-string">&quot;question-answering&quot;</span>, model=model_checkpoint)

context = <span class="hljs-string">&quot;&quot;&quot;
\u{1F917} Transformers is backed by the three most popular deep learning libraries \u2014 Jax, PyTorch and TensorFlow \u2014 with a seamless integration
between them. It&#x27;s straightforward to train your models with one before loading them for inference with the other.
&quot;&quot;&quot;</span>
question = <span class="hljs-string">&quot;Which deep learning libraries back \u{1F917} Transformers?&quot;</span>
question_answerer(question=question, context=context)`}}),Vi=new S({props:{code:`{'score': 0.9979003071784973,
 'start': 78,
 'end': 105,
 'answer': 'Jax, PyTorch and TensorFlow'}`,highlighted:`{<span class="hljs-string">&#x27;score&#x27;</span>: <span class="hljs-number">0.9979003071784973</span>,
 <span class="hljs-string">&#x27;start&#x27;</span>: <span class="hljs-number">78</span>,
 <span class="hljs-string">&#x27;end&#x27;</span>: <span class="hljs-number">105</span>,
 <span class="hljs-string">&#x27;answer&#x27;</span>: <span class="hljs-string">&#x27;Jax, PyTorch and TensorFlow&#x27;</span>}`}}),{c(){o=c("meta"),v=p(),j(g.$$.fragment),y=p(),D=c("h1"),b=c("a"),$=c("span"),j(x.$$.fragment),d=p(),B=c("span"),k=s("H\u1ECFi \u0111\xE1p"),w=p(),L.c(),N=p(),T=c("p"),F=s("\u0110\xE3 \u0111\u1EBFn l\xFAc xem ph\u1EA7n h\u1ECFi \u0111\xE1p! T\xE1c v\u1EE5 n\xE0y c\xF3 nhi\u1EC1u lo\u1EA1i, nh\u01B0ng t\xE1c v\u1EE5 m\xE0 ch\xFAng ta s\u1EBD t\u1EADp trung v\xE0o trong ph\u1EA7n n\xE0y \u0111\u01B0\u1EE3c g\u1ECDi l\xE0 tr\u1EA3 l\u1EDDi c\xE2u h\u1ECFi "),I=c("em"),z=s("khai th\xE1c"),R=s(". \u0110i\u1EC1u n\xE0y li\xEAn quan \u0111\u1EBFn vi\u1EC7c \u0111\u1EB7t ra c\xE1c c\xE2u h\u1ECFi v\u1EC1 m\u1ED9t t\xE0i li\u1EC7u v\xE0 x\xE1c \u0111\u1ECBnh c\xE1c c\xE2u tr\u1EA3 l\u1EDDi d\u01B0\u1EDBi d\u1EA1ng "),G=c("em"),V=s("c\xE1c kho\u1EA3ng c\u1EE7a v\u0103n b\u1EA3n"),J=s(" trong ch\xEDnh t\xE0i li\u1EC7u \u0111\xF3."),U=p(),j(O.$$.fragment),K=p(),Y=c("p"),nt=s("Ch\xFAng ta s\u1EBD tinh ch\u1EC9nh m\xF4 h\xECnh BERT tr\xEAn "),W=c("a"),ct=s("b\u1ED9 d\u1EEF li\u1EC7u SQuAD"),_t=s(", bao g\u1ED3m c\xE1c c\xE2u h\u1ECFi do c\u1ED9ng \u0111\u1ED3ng \u0111\u1EB7t ra tr\xEAn m\u1ED9t t\u1EADp c\xE1c b\xE0i vi\u1EBFt tr\xEAn Wikipedia. \u0110i\u1EC1u n\xE0y s\u1EBD cung c\u1EA5p cho ch\xFAng ta m\u1ED9t m\xF4 h\xECnh c\xF3 th\u1EC3 t\xEDnh to\xE1n c\xE1c d\u1EF1 \u0111o\xE1n nh\u01B0 th\u1EBF n\xE0y:"),Tt=p(),at=c("iframe"),Ft=p(),Q=c("p"),X=s("\u0110\xE2y th\u1EF1c s\u1EF1 c\xE1ch m\xF4 h\xECnh \u0111\xE3 \u0111\u01B0\u1EE3c hu\u1EA5n luy\u1EC7n v\xE0 t\u1EA3i l\xEAn Hub b\u1EB1ng c\xE1ch s\u1EED d\u1EE5ng m\xE3 \u0111\u01B0\u1EE3c hi\u1EC3n th\u1ECB trong ph\u1EA7n n\xE0y. B\u1EA1n c\xF3 th\u1EC3 t\xECm th\u1EA5y n\xF3 v\xE0 ki\u1EC3m tra c\xE1c d\u1EF1 \u0111o\u1EA1n "),Dt=c("a"),ie=s("t\u1EA1i \u0111\xE2y"),sn=s("."),fn=p(),j(ut.$$.fragment),an=p(),et=c("h2"),vt=c("a"),mt=c("span"),j(At.$$.fragment),ks=p(),Ht=c("span"),ys=s("Chu\u1EA9n b\u1ECB d\u1EEF li\u1EC7u"),It=p(),Pt=c("p"),Le=s("T\u1EADp d\u1EEF li\u1EC7u \u0111\u01B0\u1EE3c s\u1EED d\u1EE5ng nhi\u1EC1u nh\u1EA5t l\xE0m ti\xEAu chu\u1EA9n h\u1ECDc thu\u1EADt \u0111\u1EC3 tr\u1EA3 l\u1EDDi c\xE2u h\u1ECFi khai th\xE1c l\xE0 "),_n=c("a"),Da=s("SQuAD"),xs=s(", v\xEC v\u1EADy \u0111\xF3 l\xE0 t\u1EADp ch\xFAng ta s\u1EBD s\u1EED d\u1EE5ng \u1EDF \u0111\xE2y. Ngo\xE0i ra c\xF2n c\xF3 m\u1ED9t \u0111i\u1EC3m chu\u1EA9n kh\xF3 h\u01A1n "),xt=c("a"),$s=s("SQuAD v2"),lt=s(", bao g\u1ED3m c\xE1c c\xE2u h\u1ECFi kh\xF4ng c\xF3 c\xE2u tr\u1EA3 l\u1EDDi. Mi\u1EC5n l\xE0 t\u1EADp d\u1EEF li\u1EC7u c\u1EE7a ri\xEAng b\u1EA1n ch\u1EE9a m\u1ED9t c\u1ED9t cho ng\u1EEF c\u1EA3nh, m\u1ED9t c\u1ED9t cho c\xE2u h\u1ECFi v\xE0 m\u1ED9t c\u1ED9t cho c\xE2u tr\u1EA3 l\u1EDDi, b\u1EA1n s\u1EBD c\xF3 th\u1EC3 \u0111i\u1EC1u ch\u1EC9nh c\xE1c b\u01B0\u1EDBc b\xEAn d\u01B0\u1EDBi."),ws=p(),$t=c("h3"),ln=c("a"),Fe=c("span"),j(Vt.$$.fragment),Aa=p(),He=c("span"),Ie=s("B\u1ED9 d\u1EEF li\u1EC7u SQuAD"),js=p(),cn=c("p"),Ve=s("Nh\u01B0 th\u01B0\u1EDDng l\u1EC7, ch\xFAng ta c\xF3 th\u1EC3 t\u1EA3i xu\u1ED1ng v\xE0 l\u01B0u b\u1ED9 d\u1EEF li\u1EC7u v\xE0o b\u1ED9 nh\u1EDB cache ch\u1EC9 trong m\u1ED9t b\u01B0\u1EDBc nh\u1EDD v\xE0o "),Qe=c("code"),Pa=s("load_dataset()"),Ge=s(":"),qs=p(),j(vn.$$.fragment),Re=p(),St=c("p"),Es=s("Sau \u0111\xF3, ch\xFAng ta c\xF3 th\u1EC3 xem x\xE9t \u0111\u1ED1i t\u01B0\u1EE3ng n\xE0y \u0111\u1EC3 t\xECm hi\u1EC3u th\xEAm v\u1EC1 t\u1EADp d\u1EEF li\u1EC7u SQuAD:"),wt=p(),j(bn.$$.fragment),le=p(),j(kn.$$.fragment),Cs=p(),ot=c("p"),Sa=s("C\xF3 v\u1EBB nh\u01B0 ch\xFAng ta c\xF3 m\u1ECDi th\u1EE9 ta c\u1EA7n v\u1EDBi c\xE1c tr\u01B0\u1EDDng "),Ke=c("code"),Ts=s("context"),yn=s(", "),ce=c("code"),bt=s("question"),Ba=s(", v\xE0 "),xn=c("code"),Na=s("answers"),Ma=s(", v\xEC v\u1EADy h\xE3y in ch\xFAng cho ph\u1EA7n t\u1EED \u0111\u1EA7u ti\xEAn c\u1EE7a t\u1EADp hu\u1EA5n luy\u1EC7n c\u1EE7a m\xECnh:"),he=p(),j($n.$$.fragment),Ds=p(),j(Qt.$$.fragment),As=p(),st=c("p"),Ps=s("C\xE1c tr\u01B0\u1EDDng "),Gt=c("code"),Ss=s("context"),wn=s(" v\xE0 "),re=c("code"),oe=s("question"),Oa=s(" r\u1EA5t d\u1EC5 s\u1EED d\u1EE5ng. Tr\u01B0\u1EDDng "),pe=c("code"),jn=s("answers"),Bs=s(" ph\u1EE9c t\u1EA1p h\u01A1n m\u1ED9t ch\xFAt v\xEC n\xF3 so s\xE1nh m\u1ED9t t\u1EEB \u0111i\u1EC3n v\u1EDBi hai tr\u01B0\u1EDDng \u0111\u1EC1u l\xE0 danh s\xE1ch. \u0110\xE2y l\xE0 \u0111\u1ECBnh d\u1EA1ng s\u1EBD \u0111\u01B0\u1EE3c mong \u0111\u1EE3i b\u1EDFi ch\u1EC9 s\u1ED1 "),kt=c("code"),za=s("squad"),We=s(" trong qu\xE1 tr\xECnh \u0111\xE1nh gi\xE1; n\u1EBFu b\u1EA1n \u0111ang s\u1EED d\u1EE5ng d\u1EEF li\u1EC7u c\u1EE7a ri\xEAng m\xECnh, b\u1EA1n kh\xF4ng nh\u1EA5t thi\u1EBFt ph\u1EA3i lo l\u1EAFng v\u1EC1 vi\u1EC7c \u0111\u1EB7t c\xE1c c\xE2u tr\u1EA3 l\u1EDDi \u1EDF c\xF9ng m\u1ED9t \u0111\u1ECBnh d\u1EA1ng. Tr\u01B0\u1EDDng "),Ue=c("code"),La=s("text"),Xe=s(" kh\xE1 r\xF5 r\xE0ng v\xE0 tr\u01B0\u1EDDng "),Je=c("code"),Fa=s("answer_start"),Ns=s(" ch\u1EE9a ch\u1EC9 m\u1EE5c k\xFD t\u1EF1 b\u1EAFt \u0111\u1EA7u c\u1EE7a m\u1ED7i c\xE2u tr\u1EA3 l\u1EDDi trong ng\u1EEF c\u1EA3nh."),Bt=p(),gt=c("p"),Ye=s("Trong qu\xE1 tr\xECnh hu\u1EA5n luy\u1EC7n, ch\u1EC9 c\xF3 m\u1ED9t c\xE2u tr\u1EA3 l\u1EDDi kh\u1EA3 d\u0129. Ch\xFAng ta c\xF3 th\u1EC3 ki\u1EC3m tra k\u1EF9 \u0111i\u1EC1u n\xE0y b\u1EB1ng c\xE1ch s\u1EED d\u1EE5ng ph\u01B0\u01A1ng th\u1EE9c "),Rt=c("code"),Ha=s("Dataset.filter()"),Ze=s(":"),Ms=p(),j(hn.$$.fragment),qn=p(),j(En.$$.fragment),ts=p(),dt=c("p"),Cn=s("Tuy nhi\xEAn, \u0111\u1EC3 \u0111\xE1nh gi\xE1, c\xF3 m\u1ED9t s\u1ED1 c\xE2u tr\u1EA3 l\u1EDDi c\xF3 th\u1EC3 c\xF3 cho m\u1ED7i m\u1EABu, c\xF3 th\u1EC3 gi\u1ED1ng ho\u1EB7c kh\xE1c nhau:"),Os=p(),j(Kt.$$.fragment),zs=p(),j(Tn.$$.fragment),Ls=p(),pt=c("p"),Ia=s("Ch\xFAng ta s\u1EBD kh\xF4ng \u0111i s\xE2u v\xE0o t\u1EADp l\u1EC7nh \u0111\xE1nh gi\xE1 v\xEC t\u1EA5t c\u1EA3 s\u1EBD \u0111\u01B0\u1EE3c bao b\u1ECDc b\u1EDFi ch\u1EC9 s\u1ED1 \u{1F917} Datasets, nh\u01B0ng phi\xEAn b\u1EA3n ng\u1EAFn l\xE0 m\u1ED9t s\u1ED1 c\xE2u h\u1ECFi c\xF3 m\u1ED9t s\u1ED1 c\xE2u tr\u1EA3 l\u1EDDi c\xF3 th\u1EC3 c\xF3 v\xE0 t\u1EADp l\u1EC7nh n\xE0y s\u1EBD so s\xE1nh m\u1ED9t c\xE2u tr\u1EA3 l\u1EDDi \u0111\u01B0\u1EE3c d\u1EF1 \u0111o\xE1n cho t\u1EA5t c\u1EA3 c\xE2u tr\u1EA3 l\u1EDDi c\xF3 th\u1EC3 ch\u1EA5p nh\u1EADn \u0111\u01B0\u1EE3c v\xE0 d\xE0nh \u0111i\u1EC3m cao nh\u1EA5t. V\xED d\u1EE5: n\u1EBFu ch\xFAng ta xem x\xE9t m\u1EABu \u1EDF ch\u1EC9 m\u1EE5c 2:"),ue=p(),j(Dn.$$.fragment),Fs=p(),j(Wt.$$.fragment),Hs=p(),me=c("p"),ns=s("ta c\xF3 th\u1EC3 th\u1EA5y c\xE2u tr\u1EA3 l\u1EDDi c\xF3 th\u1EC3 th\u1EF1c ra l\xE0 m\u1ED9t trong s\u1ED1 ba kh\u1EA3 n\u0103ng ta th\u1EA5y tr\u01B0\u1EDBc \u0111\xF3."),Is=p(),Ut=c("h3"),rn=c("a"),jt=c("span"),j(An.$$.fragment),es=p(),ss=c("span"),Va=s("X\u1EED l\xFD d\u1EEF li\u1EC7u hu\u1EA5n luy\u1EC7n"),ge=p(),j(Pn.$$.fragment),Vs=p(),Sn=c("p"),de=s("H\xE3y b\u1EAFt \u0111\u1EA7u v\u1EDBi vi\u1EC7c x\u1EED l\xFD tr\u01B0\u1EDBc d\u1EEF li\u1EC7u hu\u1EA5n luy\u1EC7n. Ph\u1EA7n kh\xF3 s\u1EBD l\xE0 t\u1EA1o nh\xE3n cho c\xE2u tr\u1EA3 l\u1EDDi c\u1EE7a c\xE2u h\u1ECFi, \u0111\xF3 s\u1EBD l\xE0 v\u1ECB tr\xED b\u1EAFt \u0111\u1EA7u v\xE0 k\u1EBFt th\xFAc c\u1EE7a c\xE1c th\u1EBB t\u01B0\u01A1ng \u1EE9ng v\u1EDBi c\xE2u tr\u1EA3 l\u1EDDi b\xEAn trong ng\u1EEF c\u1EA3nh."),Qs=p(),Bn=c("p"),Nn=s("Nh\u01B0ng ch\xFAng ta \u0111\u1EEBng v\u01B0\u1EE3t l\xEAn ch\xEDnh m\xECnh. \u0110\u1EA7u ti\xEAn, ch\xFAng ta c\u1EA7n chuy\u1EC3n \u0111\u1ED5i v\u0103n b\u1EA3n trong \u0111\u1EA7u v\xE0o th\xE0nh c\xE1c ID m\xE0 m\xF4 h\xECnh c\xF3 th\u1EC3 hi\u1EC3u \u0111\u01B0\u1EE3c, s\u1EED d\u1EE5ng tokenizer:"),as=p(),j(Nt.$$.fragment),Gs=p(),ft=c("p"),Mn=s("Nh\u01B0 \u0111\xE3 \u0111\u1EC1 c\u1EADp tr\u01B0\u1EDBc \u0111\xF3, ch\xFAng ta s\u1EBD tinh ch\u1EC9nh m\xF4 h\xECnh BERT, nh\u01B0ng b\u1EA1n c\xF3 th\u1EC3 s\u1EED d\u1EE5ng b\u1EA5t k\u1EF3 lo\u1EA1i m\xF4 h\xECnh n\xE0o kh\xE1c mi\u1EC5n l\xE0 n\xF3 c\xF3 tri\u1EC3n khai tr\xECnh tokenize nhanh. B\u1EA1n c\xF3 th\u1EC3 xem t\u1EA5t c\u1EA3 c\xE1c ki\u1EBFn tr\xFAc \u0111i k\xE8m v\u1EDBi phi\xEAn b\u1EA3n nhanh trong "),on=c("a"),Z=s("b\u1EA3ng l\u1EDBn n\xE0y"),Qa=s(" v\xE0 \u0111\u1EC3 ki\u1EC3m tra xem \u0111\u1ED1i t\u01B0\u1EE3ng "),On=c("code"),Ga=s("tokenizer"),Ra=s(" m\xE0 b\u1EA1n \u0111ang s\u1EED d\u1EE5ng c\xF3 th\u1EF1c s\u1EF1 l\xE0 \u0111\u01B0\u1EE3c h\u1ED7 tr\u1EE3 b\u1EDFi \u{1F917} Tokenizers, b\u1EA1n c\xF3 th\u1EC3 xem thu\u1ED9c t\xEDnh "),zn=c("code"),Ka=s("is_fast"),Wa=s(" c\u1EE7a n\xF3:"),fe=p(),j(Ln.$$.fragment),Rs=p(),j(Xt.$$.fragment),Ks=p(),_e=c("p"),is=s("Ch\xFAng ta c\xF3 th\u1EC3 truy\u1EC1n c\xE2u h\u1ECFi v\xE0 ng\u1EEF c\u1EA3nh cho tr\xECnh tokenizer c\u1EE7a m\xECnh v\xE0 n\xF3 s\u1EBD ch\xE8n \u0111\xFAng c\xE1c token \u0111\u1EB7c bi\u1EC7t \u0111\u1EC3 t\u1EA1o th\xE0nh m\u1ED9t c\xE2u nh\u01B0 sau:"),Ws=p(),j(Fn.$$.fragment),ve=p(),be=c("p"),Ua=s("H\xE3y c\xF9ng ki\u1EC3m tra n\xF3:"),ke=p(),j(Hn.$$.fragment),Us=p(),j(pn.$$.fragment),qt=p(),ye=c("p"),ls=s("C\xE1c nh\xE3n sau \u0111\xF3 s\u1EBD l\xE0 ch\u1EC9 m\u1EE5c c\u1EE7a c\xE1c token b\u1EAFt \u0111\u1EA7u v\xE0 k\u1EBFt th\xFAc c\xE2u tr\u1EA3 l\u1EDDi v\xE0 m\xF4 h\xECnh s\u1EBD c\xF3 nhi\u1EC7m v\u1EE5 d\u1EF1 \u0111o\xE1n m\u1ED9t logit b\u1EAFt \u0111\u1EA7u v\xE0 k\u1EBFt th\xFAc cho m\u1ED7i token trong \u0111\u1EA7u v\xE0o, v\u1EDBi c\xE1c nh\xE3n l\xFD thuy\u1EBFt nh\u01B0 sau:"),Xs=p(),Jt=c("div"),Et=c("img"),Xa=p(),In=c("img"),m=p(),M=c("p"),Ys=s("Trong tr\u01B0\u1EDDng h\u1EE3p n\xE0y, ng\u1EEF c\u1EA3nh kh\xF4ng qu\xE1 d\xE0i, nh\u01B0ng m\u1ED9t s\u1ED1 m\u1EABu trong t\u1EADp d\u1EEF li\u1EC7u c\xF3 ng\u1EEF c\u1EA3nh r\u1EA5t d\xE0i s\u1EBD v\u01B0\u1EE3t qu\xE1 \u0111\u1ED9 d\xE0i t\u1ED1i \u0111a m\xE0 ch\xFAng t\xF4i \u0111\u1EB7t (trong tr\u01B0\u1EDDng h\u1EE3p n\xE0y l\xE0 384). Nh\u01B0 ch\xFAng ta \u0111\xE3 th\u1EA5y trong "),cs=c("a"),nl=s("Ch\u01B0\u01A1ng 6"),el=s(" khi ch\xFAng ta kh\xE1m ph\xE1 ph\u1EA7n b\xEAn trong c\u1EE7a pipeline "),un=c("code"),sl=s("question-answering"),al=s(", ch\xFAng ta s\u1EBD \u0111\u1ED1i ph\xF3 v\u1EDBi c\xE1c ng\u1EEF c\u1EA3nh d\xE0i b\u1EB1ng c\xE1ch t\u1EA1o m\u1ED9t s\u1ED1 \u0111\u1EB7c tr\u01B0ng hu\u1EA5n luy\u1EC7n t\u1EEB m\u1ED9t m\u1EABu t\u1EADp d\u1EEF li\u1EC7u c\u1EE7a m\xECnh, v\u1EDBi c\u1EEDa s\u1ED5 tr\u01B0\u1EE3t gi\u1EEFa ch\xFAng."),hs=p(),rs=c("p"),il=s("\u0110\u1EC3 xem c\xE1ch n\xE0y ho\u1EA1t \u0111\u1ED9ng nh\u01B0 th\u1EBF n\xE0o b\u1EB1ng c\xE1ch s\u1EED d\u1EE5ng v\xED d\u1EE5 hi\u1EC7n t\u1EA1i, ch\xFAng ta c\xF3 th\u1EC3 gi\u1EDBi h\u1EA1n \u0111\u1ED9 d\xE0i \u1EDF 100 v\xE0 s\u1EED d\u1EE5ng c\u1EEDa s\u1ED5 tr\u01B0\u1EE3t g\u1ED3m 50 token. Xin nh\u1EAFc l\u1EA1i, ch\xFAng ta s\u1EED d\u1EE5ng:"),Ya=p(),tt=c("ul"),os=c("li"),Zs=c("code"),ll=s("max_length"),cl=s(" \u0111\u1EC3 \u0111\u1EB7t \u0111\u1ED9 d\xE0i t\u1ED1i \u0111a (\u1EDF \u0111\xE2y l\xE0 100)"),hl=p(),Vn=c("li"),ta=c("code"),yt=s('truncation="only_second"'),rl=s(" \u0111\u1EC3 c\u1EAFt ng\u1EAFn ng\u1EEF c\u1EA3nh (\u1EDF v\u1ECB tr\xED th\u1EE9 hai) khi c\xE2u h\u1ECFi c\xF3 ng\u1EEF c\u1EA3nh qu\xE1 d\xE0i"),ol=p(),ps=c("li"),na=c("code"),pl=s("stride"),xe=s(" \u0111\u1EC3 \u0111\u1EB7t s\u1ED1 l\u01B0\u1EE3ng token ch\u1ED3ng ch\xE9o gi\u1EEFa hai ph\u1EA7n li\xEAn ti\u1EBFp (\u1EDF \u0111\xE2y l\xE0 50)"),ul=p(),us=c("li"),Mt=c("code"),ml=s("return_overflowing_tokens=True"),gl=s(" \u0111\u1EC3 cho tr\xECnh tokenizer bi\u1EBFt ch\xFAng ta mu\u1ED1n c\xE1c token tr\xE0n"),Za=p(),j($e.$$.fragment),Qn=p(),j(we.$$.fragment),ti=p(),Ct=c("p"),dl=s("Nh\u01B0 ch\xFAng ta c\xF3 th\u1EC3 th\u1EA5y, v\xED d\u1EE5 c\u1EE7a ch\xFAng ta \u0111\xE3 \u0111\u01B0\u1EE3c chia th\xE0nh b\u1ED1n \u0111\u1EA7u v\xE0o, m\u1ED7i \u0111\u1EA7u v\xE0o ch\u1EE9a c\xE2u h\u1ECFi v\xE0 m\u1ED9t s\u1ED1 ph\u1EA7n c\u1EE7a ng\u1EEF c\u1EA3nh. L\u01B0u \xFD r\u1EB1ng c\xE2u tr\u1EA3 l\u1EDDi cho c\xE2u h\u1ECFi (\u201CBernadette Soubirous\u201D) ch\u1EC9 xu\u1EA5t hi\u1EC7n trong \u0111\u1EA7u v\xE0o th\u1EE9 ba v\xE0 cu\u1ED1i c\xF9ng, v\xEC v\u1EADy b\u1EB1ng c\xE1ch x\u1EED l\xFD c\xE1c ng\u1EEF c\u1EA3nh d\xE0i theo c\xE1ch n\xE0y, ch\xFAng ta s\u1EBD t\u1EA1o m\u1ED9t s\u1ED1 m\u1EABu hu\u1EA5n luy\u1EC7n trong \u0111\xF3 c\xE2u tr\u1EA3 l\u1EDDi kh\xF4ng \u0111\u01B0\u1EE3c \u0111\u01B0a v\xE0o ng\u1EEF c\u1EA3nh. \u0110\u1ED1i v\u1EDBi nh\u1EEFng v\xED d\u1EE5 \u0111\xF3, nh\xE3n s\u1EBD l\xE0 "),ea=c("code"),fl=s("start_position = end_position = 0"),_l=s(" (v\xEC v\u1EADy ch\xFAng t\xF4i d\u1EF1 \u0111o\xE1n token "),mn=c("code"),sa=s("[CLS]"),vl=s("). Ch\xFAng ta c\u0169ng s\u1EBD \u0111\u1EB7t c\xE1c nh\xE3n \u0111\xF3 trong tr\u01B0\u1EDDng h\u1EE3p kh\xF4ng may khi c\xE2u tr\u1EA3 l\u1EDDi \u0111\xE3 b\u1ECB c\u1EAFt b\u1EDBt \u0111\u1EC3 ch\xFAng ta ch\u1EC9 c\xF3 ph\u1EA7n \u0111\u1EA7u (ho\u1EB7c ph\u1EA7n cu\u1ED1i) c\u1EE7a c\xE2u tr\u1EA3 l\u1EDDi. \u0110\u1ED1i v\u1EDBi c\xE1c v\xED d\u1EE5 trong \u0111\xF3 c\xE2u tr\u1EA3 l\u1EDDi n\u1EB1m \u0111\u1EA7y \u0111\u1EE7 trong ng\u1EEF c\u1EA3nh, c\xE1c nh\xE3n s\u1EBD l\xE0 ch\u1EC9 m\u1EE5c c\u1EE7a token n\u01A1i c\xE2u tr\u1EA3 l\u1EDDi b\u1EAFt \u0111\u1EA7u v\xE0 ch\u1EC9 m\u1EE5c c\u1EE7a token n\u01A1i c\xE2u tr\u1EA3 l\u1EDDi k\u1EBFt th\xFAc."),Yt=p(),Zt=c("p"),bl=s("T\u1EADp d\u1EEF li\u1EC7u cung c\u1EA5p cho ch\xFAng ta k\xFD t\u1EF1 b\u1EAFt \u0111\u1EA7u c\u1EE7a c\xE2u tr\u1EA3 l\u1EDDi trong ng\u1EEF c\u1EA3nh v\xE0 b\u1EB1ng c\xE1ch th\xEAm \u0111\u1ED9 d\xE0i c\u1EE7a c\xE2u tr\u1EA3 l\u1EDDi, ch\xFAng ta c\xF3 th\u1EC3 t\xECm th\u1EA5y k\xFD t\u1EF1 k\u1EBFt th\xFAc trong ng\u1EEF c\u1EA3nh. \u0110\u1EC3 \xE1nh x\u1EA1 ch\xFAng v\u1EDBi c\xE1c ch\u1EC9 s\u1ED1 token, ch\xFAng ta s\u1EBD c\u1EA7n s\u1EED d\u1EE5ng \xE1nh x\u1EA1 offset m\xE0 ch\xFAng ta \u0111\xE3 nghi\xEAn c\u1EE9u trong "),ms=c("a"),je=s("Ch\u01B0\u01A1ng 6"),kl=s(". Ch\xFAng ta c\xF3 th\u1EC3 y\xEAu c\u1EA7u tokenizer tr\u1EA3 l\u1EA1i nh\u1EEFng th\u1EE9 n\xE0y b\u1EB1ng c\xE1ch truy\u1EC1n theo "),aa=c("code"),yl=s("return_offsets_mapping=True"),xl=s(":"),it=p(),j(qe.$$.fragment),ni=p(),j(Ee.$$.fragment),ei=p(),tn=c("p"),$l=s("Nh\u01B0 ch\xFAng ta c\xF3 th\u1EC3 th\u1EA5y, ch\xFAng ta l\u1EA5y l\u1EA1i c\xE1c ID \u0111\u1EA7u v\xE0o th\xF4ng th\u01B0\u1EDDng, token ID v\xE0 attention mask, c\u0169ng nh\u01B0 \xE1nh x\u1EA1 offset m\xE0 ch\xFAng ta y\xEAu c\u1EA7u v\xE0 m\u1ED9t kh\xF3a b\u1ED5 sung, "),ia=c("code"),Ce=s("overflow_to_sample_mapping"),wl=s(". Gi\xE1 tr\u1ECB t\u01B0\u01A1ng \u1EE9ng s\u1EBD \u0111\u01B0\u1EE3c s\u1EED d\u1EE5ng cho ch\xFAng ta khi tokenize nhi\u1EC1u v\u0103n b\u1EA3n c\xF9ng m\u1ED9t l\xFAc (ch\xFAng ta n\xEAn l\xE0m \u0111\u1EC3 h\u01B0\u1EDFng l\u1EE3i t\u1EEB th\u1EF1c t\u1EBF l\xE0 tr\xECnh tokenizer \u0111\u01B0\u1EE3c h\u1ED7 tr\u1EE3 b\u1EDFi Rust). V\xEC m\u1ED9t m\u1EABu c\xF3 th\u1EC3 cung c\u1EA5p m\u1ED9t s\u1ED1 \u0111\u1ED1i t\u01B0\u1EE3ng \u0111\u1ECBa l\xFD, n\xEAn n\xF3 \xE1nh x\u1EA1 t\u1EEBng \u0111\u1ED1i t\u01B0\u1EE3ng \u0111\u1ECBa l\xFD v\u1EDBi v\xED d\u1EE5 m\xE0 n\xF3 c\xF3 ngu\u1ED3n g\u1ED1c. B\u1EDFi v\xEC \u1EDF \u0111\xE2y ch\xFAng ta ch\u1EC9 tokenize m\u1ED9t v\xED d\u1EE5, ch\xFAng ta nh\u1EADn \u0111\u01B0\u1EE3c danh s\xE1ch c\xE1c "),la=c("code"),jl=s("0"),wo=s(":"),kh=p(),j(si.$$.fragment),yh=p(),j(ai.$$.fragment),xh=p(),ql=c("p"),jo=s("Nh\u01B0ng n\u1EBFu ch\xFAng ta m\xE3 h\xF3a nhi\u1EC1u m\u1EABu h\u01A1n, \u0111i\u1EC1u n\xE0y s\u1EBD tr\u1EDF n\xEAn h\u1EEFu \xEDch h\u01A1n:"),$h=p(),j(ii.$$.fragment),wh=p(),j(li.$$.fragment),jh=p(),El=c("p"),qo=s("Nh\u01B0 ch\xFAng ta c\xF3 th\u1EC3 th\u1EA5y, ba m\u1EABu \u0111\u1EA7u ti\xEAn (t\u1EA1i ch\u1EC9 s\u1ED1 2, 3 v\xE0 4 trong t\u1EADp hu\u1EA5n luy\u1EC7n) m\u1ED7i m\u1EABu \u0111\u01B0a ra b\u1ED1n \u0111\u1EB7c tr\u01B0ng v\xE0 m\u1EABu cu\u1ED1i c\xF9ng (t\u1EA1i ch\u1EC9 m\u1EE5c 5 trong t\u1EADp hu\u1EA5n luy\u1EC7n) \u0111\u01B0a ra 7 \u0111\u1EB7c tr\u01B0ng."),qh=p(),Cl=c("p"),Eo=s("Th\xF4ng tin n\xE0y s\u1EBD h\u1EEFu \xEDch \u0111\u1EC3 \xE1nh x\u1EA1 t\u1EEBng \u0111\u1ED1i t\u01B0\u1EE3ng m\xE0 ch\xFAng ta nh\u1EADn \u0111\u01B0\u1EE3c v\u1EDBi nh\xE3n t\u01B0\u01A1ng \u1EE9ng c\u1EE7a n\xF3. Nh\u01B0 \u0111\xE3 \u0111\u1EC1 c\u1EADp tr\u01B0\u1EDBc \u0111\xF3, c\xE1c nh\xE3n \u0111\xF3 l\xE0:"),Eh=p(),ca=c("ul"),Tl=c("li"),Ec=c("code"),Co=s("(0, 0)"),To=s(" n\u1EBFu c\xE2u tr\u1EA3 l\u1EDDi kh\xF4ng n\u1EB1m trong kho\u1EA3ng t\u01B0\u01A1ng \u1EE9ng c\u1EE7a ng\u1EEF c\u1EA3nh"),Do=p(),Te=c("li"),Cc=c("code"),Ao=s("(start_position, end_position)"),Po=s(" n\u1EBFu c\xE2u tr\u1EA3 l\u1EDDi n\u1EB1m trong kho\u1EA3ng t\u01B0\u01A1ng \u1EE9ng c\u1EE7a ng\u1EEF c\u1EA3nh, v\u1EDBi "),Tc=c("code"),So=s("start_position"),Bo=s(" l\xE0 ch\u1EC9 m\u1EE5c c\u1EE7a token (trong c\xE1c ID \u0111\u1EA7u v\xE0o) \u1EDF \u0111\u1EA7u c\xE2u tr\u1EA3 l\u1EDDi v\xE0 "),Dc=c("code"),No=s("end_position"),Mo=s(" l\xE0 ch\u1EC9 m\u1EE5c c\u1EE7a token (trong c\xE1c ID \u0111\u1EA7u v\xE0o) n\u01A1i c\xE2u tr\u1EA3 l\u1EDDi k\u1EBFt th\xFAc."),Ch=p(),De=c("p"),Oo=s("\u0110\u1EC3 x\xE1c \u0111\u1ECBnh \u0111\xE2y l\xE0 tr\u01B0\u1EDDng h\u1EE3p n\xE0o v\xE0 n\u1EBFu c\xF3 li\xEAn quan, v\u1ECB tr\xED c\u1EE7a c\xE1c token, tr\u01B0\u1EDBc ti\xEAn ch\xFAng ta t\xECm c\xE1c ch\u1EC9 s\u1ED1 b\u1EAFt \u0111\u1EA7u v\xE0 k\u1EBFt th\xFAc ng\u1EEF c\u1EA3nh trong c\xE1c ID \u0111\u1EA7u v\xE0o. Ch\xFAng ta c\xF3 th\u1EC3 s\u1EED d\u1EE5ng c\xE1c token ID \u0111\u1EC3 th\u1EF1c hi\u1EC7n vi\u1EC7c n\xE0y, nh\u01B0ng v\xEC ch\xFAng kh\xF4ng nh\u1EA5t thi\u1EBFt ph\u1EA3i t\u1ED3n t\u1EA1i cho t\u1EA5t c\u1EA3 c\xE1c m\xF4 h\xECnh (v\xED d\u1EE5: DistilBERT kh\xF4ng y\xEAu c\u1EA7u ch\xFAng), thay v\xE0o \u0111\xF3, ch\xFAng ta s\u1EBD s\u1EED d\u1EE5ng ph\u01B0\u01A1ng th\u1EE9c "),Ac=c("code"),zo=s("sequence_ids()"),Lo=s(" c\u1EE7a "),Pc=c("code"),Fo=s("BatchEncoding"),Ho=s(" m\xE0 tokenizer c\u1EE7a ta tr\u1EA3 v\u1EC1."),Th=p(),ha=c("p"),Io=s("Khi ta c\xF3 c\xE1c ch\u1EC9 m\u1EE5c token \u0111\xF3, ch\xFAng ta xem x\xE9t c\xE1c offset, l\xE0 c\xE1c b\u1ED9 gi\xE1 tr\u1ECB c\u1EE7a hai s\u1ED1 nguy\xEAn \u0111\u1EA1i di\u1EC7n cho kho\u1EA3ng k\xFD t\u1EF1 b\xEAn trong ng\u1EEF c\u1EA3nh ban \u0111\u1EA7u. Do \u0111\xF3, ch\xFAng ta c\xF3 th\u1EC3 ph\xE1t hi\u1EC7n xem \u0111o\u1EA1n ng\u1EEF c\u1EA3nh trong \u0111\u1EB7c tr\u01B0ng n\xE0y b\u1EAFt \u0111\u1EA7u sau c\xE2u tr\u1EA3 l\u1EDDi hay k\u1EBFt th\xFAc tr\u01B0\u1EDBc khi c\xE2u tr\u1EA3 l\u1EDDi b\u1EAFt \u0111\u1EA7u (trong tr\u01B0\u1EDDng h\u1EE3p \u0111\xF3 nh\xE3n l\xE0 "),Sc=c("code"),Vo=s("(0, 0)"),Qo=s("). N\u1EBFu kh\xF4ng ph\u1EA3i nh\u01B0 v\u1EADy, ch\xFAng ta l\u1EB7p l\u1EA1i \u0111\u1EC3 t\xECm m\xE3 token \u0111\u1EA7u ti\xEAn v\xE0 cu\u1ED1i c\xF9ng c\u1EE7a c\xE2u tr\u1EA3 l\u1EDDi:"),Dh=p(),j(ci.$$.fragment),Ah=p(),j(hi.$$.fragment),Ph=p(),ra=c("p"),Go=s("H\xE3y c\xF9ng xem m\u1ED9t v\xE0i k\u1EBFt qu\u1EA3 \u0111\u1EC3 x\xE1c minh r\u1EB1ng c\xE1ch ti\u1EBFp c\u1EADn c\u1EE7a ch\xFAng ta l\xE0 \u0111\xFAng. \u0110\u1ED1i v\u1EDBi \u0111\u1EB7c tr\u01B0ng \u0111\u1EA7u ti\xEAn ch\xFAng ta t\xECm th\u1EA5y "),Bc=c("code"),Ro=s("(83, 85)"),Ko=s(" d\u01B0\u1EDBi d\u1EA1ng nh\xE3n, h\xE3y so s\xE1nh c\xE2u tr\u1EA3 l\u1EDDi l\xFD thuy\u1EBFt v\u1EDBi kho\u1EA3ng token \u0111\u01B0\u1EE3c gi\u1EA3i m\xE3 t\u1EEB 83 \u0111\u1EBFn 85 (bao g\u1ED3m):"),Sh=p(),j(ri.$$.fragment),Bh=p(),j(oi.$$.fragment),Nh=p(),oa=c("p"),Wo=s("K\u1EBFt qu\u1EA3 kh\xE1 l\xE0 kh\u1EDBp nhau! B\xE2y gi\u1EDD ch\xFAng ta h\xE3y ki\u1EC3m tra ch\u1EC9 m\u1EE5c 4, n\u01A1i ch\xFAng ta \u0111\u1EB7t nh\xE3n th\xE0nh "),Nc=c("code"),Uo=s("(0, 0)"),Xo=s(", c\xF3 ngh\u0129a l\xE0 c\xE2u tr\u1EA3 l\u1EDDi kh\xF4ng n\u1EB1m trong ph\u1EA7n ng\u1EEF c\u1EA3nh c\u1EE7a \u0111\u1EB7c tr\u01B0ng \u0111\xF3:"),Mh=p(),j(pi.$$.fragment),Oh=p(),j(ui.$$.fragment),zh=p(),Dl=c("p"),Jo=s("</Tip>"),Lh=p(),Al=c("p"),Yo=s("B\xE2y gi\u1EDD ch\xFAng ta \u0111\xE3 th\u1EA5y t\u1EEBng b\u01B0\u1EDBc c\xE1ch ti\u1EC1n x\u1EED l\xFD d\u1EEF li\u1EC7u hu\u1EA5n luy\u1EC7n c\u1EE7a m\xECnh, ch\xFAng ta c\xF3 th\u1EC3 nh\xF3m n\xF3 trong m\u1ED9t h\xE0m m\xE0 ta s\u1EBD \xE1p d\u1EE5ng tr\xEAn to\xE0n b\u1ED9 t\u1EADp d\u1EEF li\u1EC7u hu\u1EA5n luy\u1EC7n. Ch\xFAng ta s\u1EBD \u0111\u1EC7m m\u1ECDi \u0111\u1EB7c tr\u01B0ng \u0111\u1EBFn \u0111\u1ED9 d\xE0i t\u1ED1i \u0111a m\xE0 ta \u0111\xE3 \u0111\u1EB7t, v\xEC h\u1EA7u h\u1EBFt c\xE1c ng\u1EEF c\u1EA3nh s\u1EBD d\xE0i (v\xE0 c\xE1c m\u1EABu t\u01B0\u01A1ng \u1EE9ng s\u1EBD \u0111\u01B0\u1EE3c chia th\xE0nh nhi\u1EC1u \u0111\u1EB7c tr\u01B0ng), v\xEC v\u1EADy kh\xF4ng c\xF3 l\u1EE3i \xEDch th\u1EF1c s\u1EF1 n\xE0o khi \xE1p d\u1EE5ng \u0111\u1EC7m \u0111\u1ED9ng \u1EDF \u0111\xE2y:"),Fh=p(),Pl=c("p"),Zo=s("Th\u1EADt v\u1EADy, ch\xFAng ta kh\xF4ng th\u1EA5y c\xE2u tr\u1EA3 l\u1EDDi b\xEAn trong ng\u1EEF c\u1EA3nh."),Hh=p(),j(pa.$$.fragment),Ih=p(),Sl=c("p"),tp=s("B\xE2y gi\u1EDD ch\xFAng ta \u0111\xE3 th\u1EA5y t\u1EEBng b\u01B0\u1EDBc c\xE1ch ti\u1EC1n x\u1EED l\xFD d\u1EEF li\u1EC7u hu\u1EA5n luy\u1EC7n c\u1EE7a m\xECnh, ch\xFAng ta c\xF3 th\u1EC3 nh\xF3m n\xF3 trong m\u1ED9t h\xE0m m\xE0 ch\xFAng ta s\u1EBD \xE1p d\u1EE5ng tr\xEAn to\xE0n b\u1ED9 t\u1EADp d\u1EEF li\u1EC7u hu\u1EA5n luy\u1EC7n. Ch\xFAng ta s\u1EBD \u0111\u1EC7m m\u1ECDi \u0111\u1EB7c tr\u01B0ng \u0111\u1EBFn \u0111\u1ED9 d\xE0i t\u1ED1i \u0111a m\xE0 ch\xFAng ta \u0111\xE3 \u0111\u1EB7t, v\xEC h\u1EA7u h\u1EBFt c\xE1c ng\u1EEF c\u1EA3nh s\u1EBD d\xE0i (v\xE0 c\xE1c m\u1EABu t\u01B0\u01A1ng \u1EE9ng s\u1EBD \u0111\u01B0\u1EE3c chia th\xE0nh nhi\u1EC1u \u0111\u1EB7c tr\u01B0ng), v\xEC v\u1EADy kh\xF4ng c\xF3 l\u1EE3i \xEDch th\u1EF1c s\u1EF1 n\xE0o khi \xE1p d\u1EE5ng \u0111\u1EC7m \u0111\u1ED9ng \u1EDF \u0111\xE2y:"),Vh=p(),j(mi.$$.fragment),Qh=p(),Bl=c("p"),np=s("L\u01B0u \xFD r\u1EB1ng ch\xFAng ta \u0111\xE3 x\xE1c \u0111\u1ECBnh hai h\u1EB1ng s\u1ED1 \u0111\u1EC3 x\xE1c \u0111\u1ECBnh \u0111\u1ED9 d\xE0i t\u1ED1i \u0111a \u0111\u01B0\u1EE3c s\u1EED d\u1EE5ng c\u0169ng nh\u01B0 \u0111\u1ED9 d\xE0i c\u1EE7a c\u1EEDa s\u1ED5 tr\u01B0\u1EE3t v\xE0 ta \u0111\xE3 th\xEAm m\u1ED9t ch\xFAt d\u1ECDn d\u1EB9p tr\u01B0\u1EDBc khi tokenize: m\u1ED9t s\u1ED1 c\xE2u h\u1ECFi trong t\u1EADp d\u1EEF li\u1EC7u SQuAD c\xF3 th\xEAm kho\u1EA3ng tr\u1EAFng \u1EDF \u0111\u1EA7u v\xE0 k\u1EBFt th\xFAc m\xE0 kh\xF4ng th\xEAm b\u1EA5t k\u1EF3 th\u1EE9 g\xEC (v\xE0 chi\u1EBFm dung l\u01B0\u1EE3ng khi \u0111\u01B0\u1EE3c tokenize n\u1EBFu b\u1EA1n s\u1EED d\u1EE5ng m\xF4 h\xECnh nh\u01B0 RoBERTa), v\xEC v\u1EADy ta \u0111\xE3 x\xF3a nh\u1EEFng kho\u1EA3ng tr\u1EAFng th\u1EEBa \u0111\xF3."),Gh=p(),Ae=c("p"),ep=s("\u0110\u1EC3 \xE1p d\u1EE5ng h\xE0m n\xE0y cho to\xE0n b\u1ED9 t\u1EADp hu\u1EA5n luy\u1EC7n, ch\xFAng ta s\u1EED d\u1EE5ng ph\u01B0\u01A1ng th\u1EE9c "),Mc=c("code"),sp=s("Dataset.map()"),ap=s(" v\u1EDBi "),Oc=c("code"),ip=s("batched=True"),lp=s(". \u0110i\u1EC1u n\xE0y c\u1EA7n thi\u1EBFt \u1EDF \u0111\xE2y v\xEC ta \u0111ang thay \u0111\u1ED5i \u0111\u1ED9 d\xE0i c\u1EE7a t\u1EADp d\u1EEF li\u1EC7u (v\xEC m\u1ED9t m\u1EABu c\xF3 th\u1EC3 cung c\u1EA5p m\u1ED9t s\u1ED1 \u0111\u1EB7c tr\u01B0ng hu\u1EA5n luy\u1EC7n):"),Rh=p(),j(gi.$$.fragment),Kh=p(),j(di.$$.fragment),Wh=p(),Nl=c("p"),cp=s("Nh\u01B0 ta c\xF3 th\u1EC3 th\u1EA5y, qu\xE1 tr\xECnh ti\u1EC1n x\u1EED l\xFD \u0111\xE3 th\xEAm kho\u1EA3ng 1,000 \u0111\u1EB7c tr\u01B0ng. B\u1ED9 hu\u1EA5n luy\u1EC7n hi\u1EC7n \u0111\xE3 s\u1EB5n s\xE0ng \u0111\u1EC3 s\u1EED d\u1EE5ng - h\xE3y c\xF9ng t\xECm hi\u1EC3u v\u1EC1 qu\xE1 tr\xECnh ti\u1EC1n x\u1EED l\xFD c\u1EE7a b\u1ED9 ki\u1EC3m \u0111\u1ECBnh!"),Uh=p(),gs=c("h3"),ua=c("a"),zc=c("span"),j(fi.$$.fragment),hp=p(),Lc=c("span"),rp=s("X\u1EED l\xFD d\u1EEF li\u1EC7u ki\u1EC3m \u0111\u1ECBnh"),Xh=p(),Ml=c("p"),op=s("Vi\u1EC7c x\u1EED l\xFD tr\u01B0\u1EDBc d\u1EEF li\u1EC7u ki\u1EC3m \u0111\u1ECBnh s\u1EBD d\u1EC5 d\xE0ng h\u01A1n m\u1ED9t ch\xFAt v\xEC ch\xFAng ta kh\xF4ng c\u1EA7n t\u1EA1o nh\xE3n (tr\u1EEB khi ch\xFAng ta mu\u1ED1n t\xEDnh to\xE1n m\u1EA5t m\xE1t ki\u1EC3m \u0111\u1ECBnh, nh\u01B0ng con s\u1ED1 \u0111\xF3 s\u1EBD kh\xF4ng th\u1EF1c s\u1EF1 gi\xFAp ch\xFAng ta hi\u1EC3u m\xF4 h\xECnh t\u1ED1t nh\u01B0 th\u1EBF n\xE0o). Ni\u1EC1m vui th\u1EF1c s\u1EF1 s\u1EBD l\xE0 di\u1EC5n gi\u1EA3i c\xE1c d\u1EF1 \u0111o\xE1n c\u1EE7a m\xF4 h\xECnh th\xE0nh c\xE1c kho\u1EA3ng c\u1EE7a b\u1ED1i c\u1EA3nh ban \u0111\u1EA7u. \u0110\u1ED1i v\u1EDBi \u0111i\u1EC1u n\xE0y, ch\xFAng ta s\u1EBD ch\u1EC9 c\u1EA7n l\u01B0u tr\u1EEF c\u1EA3 \xE1nh x\u1EA1 offset v\xE0 m\u1ED9t s\u1ED1 c\xE1ch \u0111\u1EC3 kh\u1EDBp t\u1EEBng \u0111\u1ED1i t\u01B0\u1EE3ng \u0111\xE3 t\u1EA1o v\u1EDBi v\xED d\u1EE5 ban \u0111\u1EA7u m\xE0 n\xF3 xu\u1EA5t ph\xE1t. V\xEC c\xF3 m\u1ED9t c\u1ED9t ID trong t\u1EADp d\u1EEF li\u1EC7u g\u1ED1c, ch\xFAng ta s\u1EBD s\u1EED d\u1EE5ng ID \u0111\xF3."),Jh=p(),Pe=c("p"),pp=s("\u0110i\u1EC1u duy nh\u1EA5t ch\xFAng ta s\u1EBD th\xEAm \u1EDF \u0111\xE2y l\xE0 m\u1ED9t ch\xFAt d\u1ECDn d\u1EB9p c\xE1c \xE1nh x\u1EA1 offset. Ch\xFAng s\u1EBD ch\u1EE9a c\xE1c ph\u1EA7n b\xF9 cho c\xE2u h\u1ECFi v\xE0 ng\u1EEF c\u1EA3nh, nh\u01B0ng khi ch\xFAng ta \u0111ang \u1EDF giai \u0111o\u1EA1n h\u1EADu x\u1EED l\xFD, ch\xFAng ta s\u1EBD kh\xF4ng c\xF3 c\xE1ch n\xE0o \u0111\u1EC3 bi\u1EBFt ph\u1EA7n n\xE0o c\u1EE7a ID \u0111\u1EA7u v\xE0o t\u01B0\u01A1ng \u1EE9ng v\u1EDBi ng\u1EEF c\u1EA3nh v\xE0 ph\u1EA7n n\xE0o l\xE0 c\xE2u h\u1ECFi (ph\u01B0\u01A1ng th\u1EE9c "),Fc=c("code"),up=s("sequence_ids()"),mp=s(" ta \u0111\xE3 s\u1EED d\u1EE5ng ch\u1EC9 c\xF3 s\u1EB5n cho \u0111\u1EA7u ra c\u1EE7a tokenizer). V\xEC v\u1EADy, ch\xFAng ta s\u1EBD \u0111\u1EB7t c\xE1c offset t\u01B0\u01A1ng \u1EE9ng v\u1EDBi c\xE2u h\u1ECFi th\xE0nh "),Hc=c("code"),gp=s("None"),dp=s(":"),Yh=p(),j(_i.$$.fragment),Zh=p(),Ol=c("p"),fp=s("Ch\xFAng ta c\xF3 th\u1EC3 \xE1p d\u1EE5ng h\xE0m n\xE0y tr\xEAn to\xE0n b\u1ED9 t\u1EADp d\u1EEF li\u1EC7u ki\u1EC3m \u0111\u1ECBnh nh\u01B0 tr\u01B0\u1EDBc \u0111\xE2y:"),tr=p(),j(vi.$$.fragment),nr=p(),j(bi.$$.fragment),er=p(),zl=c("p"),_p=s("Trong tr\u01B0\u1EDDng h\u1EE3p n\xE0y, ch\xFAng ta ch\u1EC9 th\xEAm m\u1ED9t v\xE0i tr\u0103m m\u1EABu, v\xEC v\u1EADy c\xF3 v\u1EBB nh\u01B0 c\xE1c ng\u1EEF c\u1EA3nh trong t\u1EADp d\u1EEF li\u1EC7u ki\u1EC3m \u0111\u1ECBnh ng\u1EAFn h\u01A1n m\u1ED9t ch\xFAt."),sr=p(),Ll=c("p"),vp=s("B\xE2y gi\u1EDD ch\xFAng ta \u0111\xE3 ti\u1EC1n x\u1EED l\xFD t\u1EA5t c\u1EA3 d\u1EEF li\u1EC7u, ch\xFAng ta c\xF3 th\u1EC3 tham gia kh\xF3a hu\u1EA5n luy\u1EC7n."),ar=p(),Rn.c(),Fl=p(),ds=c("h3"),ma=c("a"),Ic=c("span"),j(ki.$$.fragment),bp=p(),Vc=c("span"),kp=s("H\u1EADu x\u1EED l\xFD"),ir=p(),Wn.c(),Hl=p(),ga=c("p"),yp=s("M\xF4 h\xECnh s\u1EBD tr\u1EA3 v\u1EC1 c\xE1c logit \u0111\u1EA7u ra cho c\xE1c v\u1ECB tr\xED b\u1EAFt \u0111\u1EA7u v\xE0 k\u1EBFt th\xFAc c\u1EE7a c\xE2u tr\u1EA3 l\u1EDDi trong ID \u0111\u1EA7u v\xE0o, nh\u01B0 ch\xFAng ta \u0111\xE3 th\u1EA5y trong qu\xE1 tr\xECnh kh\xE1m ph\xE1 pipeline "),Il=c("a"),Qc=c("code"),xp=s("question-answering"),$p=s(". B\u01B0\u1EDBc ti\u1EC1n x\u1EED l\xFD s\u1EBD t\u01B0\u01A1ng t\u1EF1 nh\u01B0 nh\u1EEFng g\xEC ch\xFAng ta \u0111\xE3 l\xE0m \u1EDF \u0111\xF3, v\xEC v\u1EADy \u0111\xE2y l\xE0 l\u1EDDi nh\u1EAFc nhanh v\u1EC1 c\xE1c b\u01B0\u1EDBc ch\xFAng ta \u0111\xE3 th\u1EF1c hi\u1EC7n:"),lr=p(),gn=c("ul"),Gc=c("li"),wp=s("Ch\xFAng ta \u0111\xE3 che c\xE1c logit b\u1EAFt \u0111\u1EA7u v\xE0 k\u1EBFt th\xFAc t\u01B0\u01A1ng \u1EE9ng v\u1EDBi c\xE1c token b\xEAn ngo\xE0i ng\u1EEF c\u1EA3nh."),jp=p(),Rc=c("li"),qp=s("Sau \u0111\xF3, ch\xFAng ta chuy\u1EC3n \u0111\u1ED5i c\xE1c logit b\u1EAFt \u0111\u1EA7u v\xE0 k\u1EBFt th\xFAc th\xE0nh x\xE1c su\u1EA5t b\u1EB1ng c\xE1ch s\u1EED d\u1EE5ng softmax."),Ep=p(),yi=c("li"),Cp=s("Ch\xFAng ta quy \u0111i\u1EC3m cho t\u1EEBng c\u1EB7p "),Kc=c("code"),Tp=s("(start_token, end_token)"),Dp=s(" c\xE1ch l\u1EA5y t\xEDch c\u1EE7a hai x\xE1c su\u1EA5t t\u01B0\u01A1ng \u1EE9ng."),Ap=p(),fs=c("li"),Pp=s("Ch\xFAng ta \u0111\xE3 t\xECm ki\u1EBFm c\u1EB7p c\xF3 \u0111i\u1EC3m t\u1ED1i \u0111a mang l\u1EA1i c\xE2u tr\u1EA3 l\u1EDDi h\u1EE3p l\u1EC7 (v\xED d\u1EE5: "),Wc=c("code"),Sp=s("start_token"),Bp=s(" th\u1EA5p h\u01A1n "),Uc=c("code"),Np=s("end_token"),Mp=s(")."),cr=p(),dn=c("p"),Op=s("\u1EDE \u0111\xE2y, ch\xFAng ta s\u1EBD thay \u0111\u1ED5i quy tr\xECnh n\xE0y m\u1ED9t ch\xFAt v\xEC ch\xFAng ta kh\xF4ng c\u1EA7n t\xEDnh \u0111i\u1EC3m th\u1EF1c t\u1EBF (ch\u1EC9 l\xE0 c\xE2u tr\u1EA3 l\u1EDDi d\u1EF1 \u0111o\xE1n). \u0110i\u1EC1u n\xE0y c\xF3 ngh\u0129a l\xE0 ch\xFAng ta c\xF3 th\u1EC3 b\u1ECF qua b\u01B0\u1EDBc softmax. \u0110\u1EC3 \u0111i nhanh h\u01A1n, ch\xFAng ta c\u0169ng s\u1EBD kh\xF4ng t\xEDnh \u0111i\u1EC3m t\u1EA5t c\u1EA3 c\xE1c c\u1EB7p "),Xc=c("code"),zp=s("(start_token, end_token)"),Lp=s(" c\xF3 th\u1EC3, m\xE0 ch\u1EC9 nh\u1EEFng c\u1EB7p t\u01B0\u01A1ng \u1EE9ng v\u1EDBi logit "),Jc=c("code"),Fp=s("n_best"),Hp=s(" cao nh\u1EA5t (v\u1EDBi "),Yc=c("code"),Ip=s("n_best = 20"),Vp=s("). V\xEC ch\xFAng ta s\u1EBD b\u1ECF qua softmax, nh\u1EEFng \u0111i\u1EC3m \u0111\xF3 s\u1EBD l\xE0 \u0111i\u1EC3m logit v\xE0 s\u1EBD c\xF3 \u0111\u01B0\u1EE3c b\u1EB1ng c\xE1ch l\u1EA5y t\u1ED5ng c\u1EE7a logit b\u1EAFt \u0111\u1EA7u v\xE0 k\u1EBFt th\xFAc (thay v\xEC nh\xE2n, v\xEC quy t\u1EAFc (\\log(ab) = \\log(a) + \\log(b)\\))."),hr=p(),da=c("p"),Qp=s("\u0110\u1EC3 ch\u1EE9ng minh t\u1EA5t c\u1EA3 nh\u1EEFng \u0111i\u1EC1u n\xE0y, ch\xFAng ta s\u1EBD c\u1EA7n m\u1ED9t s\u1ED1 lo\u1EA1i d\u1EF1 \u0111o\xE1n. V\xEC ch\xFAng ta ch\u01B0a hu\u1EA5n luy\u1EC7n m\xF4 h\xECnh c\u1EE7a m\xECnh, ch\xFAng ta s\u1EBD s\u1EED d\u1EE5ng m\xF4 h\xECnh m\u1EB7c \u0111\u1ECBnh cho pipeline QA \u0111\u1EC3 t\u1EA1o ra m\u1ED9t s\u1ED1 d\u1EF1 \u0111o\xE1n tr\xEAn m\u1ED9t ph\u1EA7n nh\u1ECF c\u1EE7a t\u1EADp h\u1EE3p ki\u1EC3m. Ch\xFAng ta c\xF3 th\u1EC3 s\u1EED d\u1EE5ng ch\u1EE9c n\u0103ng x\u1EED l\xFD t\u01B0\u01A1ng t\u1EF1 nh\u01B0 tr\u01B0\u1EDBc \u0111\xE2y; b\u1EDFi v\xEC n\xF3 d\u1EF1a v\xE0o h\u1EB1ng s\u1ED1 to\xE0n c\u1EE5c "),Zc=c("code"),Gp=s("tokenizer"),Rp=s(", ch\xFAng ta ch\u1EC9 c\u1EA7n thay \u0111\u1ED5i \u0111\u1ED1i t\u01B0\u1EE3ng \u0111\xF3 th\xE0nh tokenizer c\u1EE7a m\xF4 h\xECnh m\xE0 ch\xFAng ta mu\u1ED1n s\u1EED d\u1EE5ng t\u1EA1m th\u1EDDi:"),rr=p(),j(xi.$$.fragment),or=p(),Vl=c("p"),Kp=s("B\xE2y gi\u1EDD, qu\xE1 tr\xECnh ti\u1EC1n x\u1EED l\xFD \u0111\xE3 ho\xE0n t\u1EA5t, ch\xFAng ta thay \u0111\u1ED5i tokenizer tr\u1EDF l\u1EA1i c\xE1i m\xE0 ch\xFAng ta \u0111\xE3 ch\u1ECDn ban \u0111\u1EA7u:"),pr=p(),j($i.$$.fragment),ur=p(),fa=c("p"),Wp=s("Sau \u0111\xF3, ch\xFAng ta lo\u1EA1i b\u1ECF c\xE1c c\u1ED9t c\u1EE7a "),th=c("code"),Up=s("eval_set"),Xp=s(" m\xE0 m\xF4 h\xECnh kh\xF4ng mong \u0111\u1EE3i, x\xE2y d\u1EF1ng m\u1ED9t l\xF4 v\u1EDBi t\u1EA5t c\u1EA3 b\u1ED9 ki\u1EC3m \u0111\u1ECBnh nh\u1ECF \u0111\xF3 v\xE0 chuy\u1EC3n n\xF3 qua m\xF4 h\xECnh. N\u1EBFu c\xF3 s\u1EB5n GPU, ch\xFAng ta s\u1EED d\u1EE5ng n\xF3 \u0111\u1EC3 ch\u1EA1y nhanh h\u01A1n:"),mr=p(),Xn.c(),Ql=p(),Ot=c("p"),Jp=s("B\xE2y gi\u1EDD, ch\xFAng ta c\u1EA7n t\xECm c\xE2u tr\u1EA3 l\u1EDDi d\u1EF1 \u0111o\xE1n cho t\u1EEBng v\xED d\u1EE5 trong "),nh=c("code"),Yp=s("small_eval_set"),Zp=s(" c\u1EE7a ch\xFAng ta. M\u1ED9t v\xED d\u1EE5 c\xF3 th\u1EC3 \u0111\xE3 \u0111\u01B0\u1EE3c chia th\xE0nh nhi\u1EC1u \u0111\u1EB7c tr\u01B0ng trong "),eh=c("code"),tu=s("eval_set"),nu=s(", v\xEC v\u1EADy b\u01B0\u1EDBc \u0111\u1EA7u ti\xEAn l\xE0 \xE1nh x\u1EA1 t\u1EEBng m\u1EABu trong "),sh=c("code"),eu=s("small_eval_set"),su=s(" v\u1EDBi c\xE1c \u0111\u1EB7c tr\u01B0ng t\u01B0\u01A1ng \u1EE9ng trong "),ah=c("code"),au=s("eval_set"),iu=s(":"),gr=p(),j(wi.$$.fragment),dr=p(),_a=c("p"),lu=s("V\u1EDBi \u0111i\u1EC1u n\xE0y trong tay, ch\xFAng ta th\u1EF1c s\u1EF1 c\xF3 th\u1EC3 b\u1EAFt \u0111\u1EA7u l\xE0m vi\u1EC7c b\u1EB1ng c\xE1ch l\u1EB7p l\u1EA1i t\u1EA5t c\u1EA3 c\xE1c m\u1EABu v\xE0, \u0111\u1ED1i v\u1EDBi m\u1ED7i m\u1EABu, th\xF4ng qua t\u1EA5t c\u1EA3 c\xE1c \u0111\u1EB7c tr\u01B0ng li\xEAn quan. Nh\u01B0 ch\xFAng ta \u0111\xE3 n\xF3i tr\u01B0\u1EDBc \u0111\xE2y, ch\xFAng ta s\u1EBD xem x\xE9t \u0111i\u1EC3m logit cho c\xE1c logit b\u1EAFt \u0111\u1EA7u v\xE0 k\u1EBFt th\xFAc c\u1EE7a "),ih=c("code"),cu=s("n_best"),hu=s(", ngo\u1EA1i tr\u1EEB c\xE1c v\u1ECB tr\xED cung c\u1EA5p:"),fr=p(),Se=c("ul"),lh=c("li"),ru=s("M\u1ED9t c\xE2u tr\u1EA3 l\u1EDDi s\u1EBD kh\xF4ng n\u1EB1m trong ng\u1EEF c\u1EA3nh"),ou=p(),ch=c("li"),pu=s("M\u1ED9t c\xE2u tr\u1EA3 l\u1EDDi c\xF3 \u0111\u1ED9 d\xE0i \xE2m"),uu=p(),ji=c("li"),mu=s("M\u1ED9t c\xE2u tr\u1EA3 l\u1EDDi qu\xE1 d\xE0i (ch\xFAng ta gi\u1EDBi h\u1EA1n kh\u1EA3 n\u0103ng \u1EDF m\u1EE9c "),hh=c("code"),gu=s("max_answer_length=30"),du=s(")"),_r=p(),Gl=c("p"),fu=s("Khi ch\xFAng ta c\xF3 t\u1EA5t c\u1EA3 c\xE1c c\xE2u tr\u1EA3 l\u1EDDi c\xF3 th\u1EC3 \u0111\u01B0\u1EE3c ghi cho m\u1ED9t m\u1EABu, ta ch\u1EC9 c\u1EA7n ch\u1ECDn m\u1ED9t c\xE2u c\xF3 \u0111i\u1EC3m logit t\u1ED1t nh\u1EA5t:"),vr=p(),j(qi.$$.fragment),br=p(),Rl=c("p"),_u=s("\u0110\u1ECBnh d\u1EA1ng cu\u1ED1i c\xF9ng c\u1EE7a c\xE1c c\xE2u tr\u1EA3 l\u1EDDi \u0111\u01B0\u1EE3c d\u1EF1 \u0111o\xE1n l\xE0 \u0111\u1ECBnh d\u1EA1ng s\u1EBD \u0111\u01B0\u1EE3c d\u1EF1 \u0111o\xE1n theo ch\u1EC9 s\u1ED1 m\xE0 ch\xFAng ta s\u1EBD s\u1EED d\u1EE5ng. Nh\u01B0 th\u01B0\u1EDDng l\u1EC7, ch\xFAng ta c\xF3 th\u1EC3 t\u1EA3i n\xF3 v\u1EDBi s\u1EF1 tr\u1EE3 gi\xFAp c\u1EE7a th\u01B0 vi\u1EC7n \u{1F917} Evaluate:"),kr=p(),j(Ei.$$.fragment),yr=p(),Kl=c("p"),vu=s("Th\u01B0\u1EDBc \u0111o n\xE0y mong \u0111\u1EE3i c\xE1c c\xE2u tr\u1EA3 l\u1EDDi \u0111\u01B0\u1EE3c d\u1EF1 \u0111o\xE1n \u1EDF \u0111\u1ECBnh d\u1EA1ng m\xE0 ch\xFAng ta \u0111\xE3 th\u1EA5y \u1EDF tr\xEAn (danh s\xE1ch c\xE1c t\u1EEB \u0111i\u1EC3n c\xF3 m\u1ED9t kh\xF3a cho ID c\u1EE7a m\u1EABu v\xE0 m\u1ED9t kh\xF3a cho v\u0103n b\u1EA3n \u0111\u01B0\u1EE3c d\u1EF1 \u0111o\xE1n) v\xE0 c\xE1c c\xE2u tr\u1EA3 l\u1EDDi l\xFD thuy\u1EBFt \u1EDF \u0111\u1ECBnh d\u1EA1ng b\xEAn d\u01B0\u1EDBi (danh s\xE1ch c\xE1c t\u1EEB \u0111i\u1EC3n c\xF3 m\u1ED9t kh\xF3a cho ID c\u1EE7a m\u1EABu v\xE0 m\u1ED9t kh\xF3a cho c\xE1c c\xE2u tr\u1EA3 l\u1EDDi c\xF3 th\u1EC3 c\xF3):"),xr=p(),j(Ci.$$.fragment),$r=p(),Wl=c("p"),bu=s("B\xE2y gi\u1EDD ch\xFAng ta c\xF3 th\u1EC3 ki\u1EC3m tra xem ta c\xF3 nh\u1EADn \u0111\u01B0\u1EE3c k\u1EBFt qu\u1EA3 h\u1EE3p l\xFD hay kh\xF4ng b\u1EB1ng c\xE1ch xem x\xE9t y\u1EBFu t\u1ED1 \u0111\u1EA7u ti\xEAn c\u1EE7a c\u1EA3 hai danh s\xE1ch:"),wr=p(),j(Ti.$$.fragment),jr=p(),j(Di.$$.fragment),qr=p(),Ul=c("p"),ku=s("Kh\xF4ng t\u1EC7 l\u1EAFm! B\xE2y gi\u1EDD ch\xFAng ta h\xE3y xem x\xE9t \u0111i\u1EC3m s\u1ED1 m\xE0 s\u1ED1 li\u1EC7u mang l\u1EA1i cho ch\xFAng ta:"),Er=p(),j(Ai.$$.fragment),Cr=p(),j(Pi.$$.fragment),Tr=p(),va=c("p"),yu=s("M\u1ED9t l\u1EA7n n\u1EEFa, \u0111i\u1EC1u \u0111\xF3 kh\xE1 t\u1ED1t theo "),Si=c("a"),xu=s("b\xE0i b\xE1o c\u1EE7a n\xF3"),$u=s(", DistilBERT \u0111\u01B0\u1EE3c tinh ch\u1EC9nh tr\xEAn SQuAD thu \u0111\u01B0\u1EE3c 79.1 v\xE0 86.9 tr\xEAn to\xE0n b\u1ED9 t\u1EADp d\u1EEF li\u1EC7u."),Dr=p(),bs.c(),Xl=p(),j(Bi.$$.fragment),Ar=p(),Jl=c("p"),wu=s("Ch\xFAng ta c\xF3 th\u1EC3 ki\u1EC3m tra n\xF3 ho\u1EA1t \u0111\u1ED9ng d\u1EF1a tr\xEAn d\u1EF1 \u0111o\xE1n c\u1EE7a m\xECnh:"),Pr=p(),j(Ni.$$.fragment),Sr=p(),j(Mi.$$.fragment),Br=p(),Yl=c("p"),ju=s("Tr\xF4ng kh\xE1 \u1ED5n! B\xE2y gi\u1EDD ch\xFAng ta h\xE3y s\u1EED d\u1EE5ng \u0111i\u1EC1u n\xE0y \u0111\u1EC3 tinh ch\u1EC9nh m\xF4 h\xECnh c\u1EE7a m\xECnh."),Nr=p(),_s=c("h3"),ba=c("a"),rh=c("span"),j(Oi.$$.fragment),qu=p(),oh=c("span"),Eu=s("Tinh ch\u1EC9nh m\xF4 h\xECnh"),Mr=p(),Yn.c(),Zl=p(),tc=c("p"),Cu=s("Nh\u01B0 th\u01B0\u1EDDng l\u1EC7, ch\xFAng ta nh\u1EADn \u0111\u01B0\u1EE3c c\u1EA3nh b\xE1o r\u1EB1ng m\u1ED9t s\u1ED1 tr\u1ECDng s\u1ED1 kh\xF4ng \u0111\u01B0\u1EE3c s\u1EED d\u1EE5ng (c\xE1c tr\u1ECDng s\u1ED1 t\u1EEB ph\u1EA7n \u0111\u1EA7u hu\u1EA5n luy\u1EC7n tr\u01B0\u1EDBc) v\xE0 m\u1ED9t s\u1ED1 tr\u1ECDng s\u1ED1 kh\xE1c \u0111\u01B0\u1EE3c kh\u1EDFi t\u1EA1o ng\u1EABu nhi\xEAn (c\xE1c tr\u1ECDng s\u1ED1 cho \u0111\u1EA7u tr\u1EA3 l\u1EDDi c\xE2u h\u1ECFi). B\xE2y gi\u1EDD b\u1EA1n n\xEAn quen v\u1EDBi \u0111i\u1EC1u n\xE0y, nh\u01B0ng \u0111i\u1EC1u \u0111\xF3 c\xF3 ngh\u0129a l\xE0 m\xF4 h\xECnh n\xE0y ch\u01B0a s\u1EB5n s\xE0ng \u0111\u1EC3 s\u1EED d\u1EE5ng v\xE0 c\u1EA7n \u0111\u01B0\u1EE3c tinh ch\u1EC9nh - \u0111i\u1EC1u t\u1ED1t l\xE0 ch\xFAng ta s\u1EAFp l\xE0m \u0111\u01B0\u1EE3c \u0111i\u1EC1u \u0111\xF3!"),Or=p(),nc=c("p"),Tu=s("\u0110\u1EC3 c\xF3 th\u1EC3 \u0111\u1EA9y m\xF4 h\xECnh c\u1EE7a m\xECnh l\xEAn Hub, ch\xFAng ta c\u1EA7n \u0111\u0103ng nh\u1EADp v\xE0o Hugging Face. 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, h\xE0m n\xE0y s\u1EBD hi\u1EC3n th\u1ECB m\u1ED9t ti\u1EC7n \xEDch m\xE0 b\u1EA1n c\xF3 th\u1EC3 nh\u1EADp th\xF4ng tin \u0111\u0103ng nh\u1EADp c\u1EE7a m\xECnh:"),zr=p(),j(zi.$$.fragment),Lr=p(),ec=c("p"),Du=s("N\u1EBFu b\u1EA1n kh\xF4ng l\xE0m vi\u1EC7c trong notebook, ch\u1EC9 c\u1EA7n nh\u1EADp d\xF2ng sau v\xE0o thi\u1EBFt b\u1ECB \u0111\u1EA7u cu\u1ED1i c\u1EE7a b\u1EA1n:"),Fr=p(),j(Li.$$.fragment),Hr=p(),te.c(),sc=p(),zt=c("p"),Au=s("M\u1EB7c \u0111\u1ECBnh, kho l\u01B0u tr\u1EEF \u0111\u01B0\u1EE3c s\u1EED d\u1EE5ng s\u1EBD n\u1EB1m trong kh\xF4ng gian t\xEAn c\u1EE7a b\u1EA1n v\xE0 \u0111\u01B0\u1EE3c \u0111\u1EB7t t\xEAn theo th\u01B0 m\u1EE5c \u0111\u1EA7u ra m\xE0 b\u1EA1n \u0111\xE3 \u0111\u1EB7t, v\xEC v\u1EADy trong tr\u01B0\u1EDDng h\u1EE3p c\u1EE7a m\xECnh, n\xF3 s\u1EBD n\u1EB1m trong "),ph=c("code"),Pu=s('"sgugger/bert-finetuned-squad"'),Su=s(". Ch\xFAng ta c\xF3 th\u1EC3 ghi \u0111\xE8 \u0111i\u1EC1u n\xE0y b\u1EB1ng c\xE1ch chuy\u1EC3n m\u1ED9t "),uh=c("code"),Bu=s("hub_model_id"),Nu=s("; v\xED d\u1EE5: \u0111\u1EC3 \u0111\u1EA9y m\xF4 h\xECnh v\xE0o t\u1ED5 ch\u1EE9c "),mh=c("code"),Mu=s("huggingface_course"),Ou=s(", ch\xFAng ta \u0111\xE3 s\u1EED d\u1EE5ng "),gh=c("code"),zu=s('hub_model_id="huggingface_course/bert-finetuned-squad"'),Lu=s(" (l\xE0 m\xF4 h\xECnh m\xE0 ta \u0111\xE3 li\xEAn k\u1EBFt \u1EDF \u0111\u1EA7u ph\u1EA7n n\xE0y)."),Ir=p(),ee.c(),ac=p(),ic=c("p"),Fu=s("L\u01B0u \xFD r\u1EB1ng trong khi qu\xE1 tr\xECnh hu\u1EA5n luy\u1EC7n di\u1EC5n ra, m\u1ED7i khi m\xF4 h\xECnh \u0111\u01B0\u1EE3c l\u01B0u (\u1EDF \u0111\xE2y, m\u1ED7i epoch), n\xF3 s\u1EBD \u0111\u01B0\u1EE3c t\u1EA3i l\xEAn Hub \u1EDF ch\u1EBF \u0111\u1ED9 n\u1EC1n. B\u1EB1ng c\xE1ch n\xE0y, b\u1EA1n s\u1EBD c\xF3 th\u1EC3 ti\u1EBFp t\u1EE5c hu\u1EA5n luy\u1EC7n c\u1EE7a m\xECnh tr\xEAn m\u1ED9t m\xE1y kh\xE1c n\u1EBFu c\u1EA7n. To\xE0n b\u1ED9 qu\xE1 tr\xECnh hu\u1EA5n luy\u1EC7n m\u1EA5t m\u1ED9t kho\u1EA3ng th\u1EDDi gian (h\u01A1n m\u1ED9t gi\u1EDD tr\xEAn Titan RTX), v\xEC v\u1EADy b\u1EA1n c\xF3 th\u1EC3 u\u1ED1ng m\u1ED9t ly c\xE0 ph\xEA ho\u1EB7c \u0111\u1ECDc l\u1EA1i m\u1ED9t s\u1ED1 ph\u1EA7n c\u1EE7a kh\xF3a h\u1ECDc m\xE0 b\u1EA1n th\u1EA5y kh\xF3 kh\u0103n h\u01A1n trong khi ti\u1EBFp t\u1EE5c. C\u0169ng l\u01B0u \xFD r\u1EB1ng ngay sau khi epoch \u0111\u1EA7u ti\xEAn k\u1EBFt th\xFAc, b\u1EA1n s\u1EBD th\u1EA5y m\u1ED9t s\u1ED1 tr\u1ECDng s\u1ED1 \u0111\u01B0\u1EE3c t\u1EA3i l\xEAn Hub v\xE0 b\u1EA1n c\xF3 th\u1EC3 b\u1EAFt \u0111\u1EA7u ch\u01A1i v\u1EDBi m\xF4 h\xECnh c\u1EE7a m\xECnh tr\xEAn trang c\u1EE7a n\xF3."),Vr=p(),ae.c(),lc=p(),j(Fi.$$.fragment),Qr=p(),cc=c("p"),Hu=s("Tuy\u1EC7t qu\xE1! \u0110\u1EC3 so s\xE1nh, \u0111i\u1EC3m c\u01A1 b\u1EA3n \u0111\u01B0\u1EE3c b\xE1o c\xE1o trong b\xE0i b\xE1o BERT cho m\xF4 h\xECnh n\xE0y l\xE0 80.8 v\xE0 88.5, v\xEC v\u1EADy ch\xFAng ta \u0111ang \u1EDF \u0111\xFAng v\u1ECB tr\xED c\u1EE7a m\xECnh."),Gr=p(),ht&&ht.c(),hc=p(),rc=c("p"),Iu=s("\u1EDE giai \u0111o\u1EA1n n\xE0y, b\u1EA1n c\xF3 th\u1EC3 s\u1EED d\u1EE5ng ti\u1EC7n \xEDch lu\u1EADn suy tr\xEAn Model Hub \u0111\u1EC3 ki\u1EC3m tra m\xF4 h\xECnh v\xE0 chia s\u1EBB m\xF4 h\xECnh \u0111\xF3 v\u1EDBi b\u1EA1n b\xE8, gia \u0111\xECnh v\xE0 v\u1EADt nu\xF4i y\xEAu th\xEDch c\u1EE7a b\u1EA1n. B\u1EA1n \u0111\xE3 tinh ch\u1EC9nh th\xE0nh c\xF4ng m\u1ED9t m\xF4 h\xECnh trong t\xE1c v\u1EE5 h\u1ECFi \u0111\xE1p - xin ch\xFAc m\u1EEBng!"),Rr=p(),j(ka.$$.fragment),Kr=p(),rt&&rt.c(),oc=p(),vs=c("h2"),ya=c("a"),dh=c("span"),j(Hi.$$.fragment),Vu=p(),fh=c("span"),Qu=s("S\u1EED d\u1EE5ng m\xF4 h\xECnh tinh ch\u1EC9nh"),Wr=p(),xa=c("p"),Gu=s("Ch\xFAng t\xF4i \u0111\xE3 ch\u1EC9 cho b\u1EA1n c\xE1ch b\u1EA1n c\xF3 th\u1EC3 s\u1EED d\u1EE5ng m\xF4 h\xECnh m\xE0 ch\xFAng ta \u0111\xE3 tinh ch\u1EC9nh tr\xEAn Model Hub b\u1EB1ng ti\u1EC7n \xEDch lu\u1EADn suy. \u0110\u1EC3 s\u1EED d\u1EE5ng n\xF3 c\u1EE5c b\u1ED9 trong m\u1ED9t "),_h=c("code"),Ru=s("pipeline"),Ku=s(", b\u1EA1n ch\u1EC9 c\u1EA7n ch\u1EC9 \u0111\u1ECBnh m\xE3 \u0111\u1ECBnh danh m\xF4 h\xECnh:"),Ur=p(),j(Ii.$$.fragment),Xr=p(),j(Vi.$$.fragment),Jr=p(),pc=c("p"),Wu=s("Tuy\u1EC7t qu\xE1! M\xF4 h\xECnh c\u1EE7a ch\xFAng ta \u0111ang ho\u1EA1t \u0111\u1ED9ng t\u1ED1t nh\u01B0 m\xF4 h\xECnh m\u1EB7c \u0111\u1ECBnh cho pipeline n\xE0y!"),this.h()},l(t){const l=Id('[data-svelte="svelte-1phssyn"]',document.head);o=h(l,"META",{name:!0,content:!0}),l.forEach(n),v=u(t),q(g.$$.fragment,t),y=u(t),D=h(t,"H1",{class:!0});var Yi=r(D);b=h(Yi,"A",{id:!0,class:!0,href:!0});var uc=r(b);$=h(uc,"SPAN",{});var vh=r($);q(x.$$.fragment,vh),vh.forEach(n),uc.forEach(n),d=u(Yi),B=h(Yi,"SPAN",{});var bh=r(B);k=a(bh,"H\u1ECFi \u0111\xE1p"),bh.forEach(n),Yi.forEach(n),w=u(t),L.l(t),N=u(t),T=h(t,"P",{});var Be=r(T);F=a(Be,"\u0110\xE3 \u0111\u1EBFn l\xFAc xem ph\u1EA7n h\u1ECFi \u0111\xE1p! T\xE1c v\u1EE5 n\xE0y c\xF3 nhi\u1EC1u lo\u1EA1i, nh\u01B0ng t\xE1c v\u1EE5 m\xE0 ch\xFAng ta s\u1EBD t\u1EADp trung v\xE0o trong ph\u1EA7n n\xE0y \u0111\u01B0\u1EE3c g\u1ECDi l\xE0 tr\u1EA3 l\u1EDDi c\xE2u h\u1ECFi "),I=h(Be,"EM",{});var mc=r(I);z=a(mc,"khai th\xE1c"),mc.forEach(n),R=a(Be,". \u0110i\u1EC1u n\xE0y li\xEAn quan \u0111\u1EBFn vi\u1EC7c \u0111\u1EB7t ra c\xE1c c\xE2u h\u1ECFi v\u1EC1 m\u1ED9t t\xE0i li\u1EC7u v\xE0 x\xE1c \u0111\u1ECBnh c\xE1c c\xE2u tr\u1EA3 l\u1EDDi d\u01B0\u1EDBi d\u1EA1ng "),G=h(Be,"EM",{});var gc=r(G);V=a(gc,"c\xE1c kho\u1EA3ng c\u1EE7a v\u0103n b\u1EA3n"),gc.forEach(n),J=a(Be," trong ch\xEDnh t\xE0i li\u1EC7u \u0111\xF3."),Be.forEach(n),U=u(t),q(O.$$.fragment,t),K=u(t),Y=h(t,"P",{});var $a=r(Y);nt=a($a,"Ch\xFAng ta s\u1EBD tinh ch\u1EC9nh m\xF4 h\xECnh BERT tr\xEAn "),W=h($a,"A",{href:!0,rel:!0});var dc=r(W);ct=a(dc,"b\u1ED9 d\u1EEF li\u1EC7u SQuAD"),dc.forEach(n),_t=a($a,", bao g\u1ED3m c\xE1c c\xE2u h\u1ECFi do c\u1ED9ng \u0111\u1ED3ng \u0111\u1EB7t ra tr\xEAn m\u1ED9t t\u1EADp c\xE1c b\xE0i vi\u1EBFt tr\xEAn Wikipedia. \u0110i\u1EC1u n\xE0y s\u1EBD cung c\u1EA5p cho ch\xFAng ta m\u1ED9t m\xF4 h\xECnh c\xF3 th\u1EC3 t\xEDnh to\xE1n c\xE1c d\u1EF1 \u0111o\xE1n nh\u01B0 th\u1EBF n\xE0y:"),$a.forEach(n),Tt=u(t),at=h(t,"IFRAME",{src:!0,frameborder:!0,height:!0,title:!0,class:!0,allow:!0,sandbox:!0}),r(at).forEach(n),Ft=u(t),Q=h(t,"P",{});var wa=r(Q);X=a(wa,"\u0110\xE2y th\u1EF1c s\u1EF1 c\xE1ch m\xF4 h\xECnh \u0111\xE3 \u0111\u01B0\u1EE3c hu\u1EA5n luy\u1EC7n v\xE0 t\u1EA3i l\xEAn Hub b\u1EB1ng c\xE1ch s\u1EED d\u1EE5ng m\xE3 \u0111\u01B0\u1EE3c hi\u1EC3n th\u1ECB trong ph\u1EA7n n\xE0y. B\u1EA1n c\xF3 th\u1EC3 t\xECm th\u1EA5y n\xF3 v\xE0 ki\u1EC3m tra c\xE1c d\u1EF1 \u0111o\u1EA1n "),Dt=h(wa,"A",{href:!0,rel:!0});var fc=r(Dt);ie=a(fc,"t\u1EA1i \u0111\xE2y"),fc.forEach(n),sn=a(wa,"."),wa.forEach(n),fn=u(t),q(ut.$$.fragment,t),an=u(t),et=h(t,"H2",{class:!0});var Zi=r(et);vt=h(Zi,"A",{id:!0,class:!0,href:!0});var vm=r(vt);mt=h(vm,"SPAN",{});var bm=r(mt);q(At.$$.fragment,bm),bm.forEach(n),vm.forEach(n),ks=u(Zi),Ht=h(Zi,"SPAN",{});var km=r(Ht);ys=a(km,"Chu\u1EA9n b\u1ECB d\u1EEF li\u1EC7u"),km.forEach(n),Zi.forEach(n),It=u(t),Pt=h(t,"P",{});var _c=r(Pt);Le=a(_c,"T\u1EADp d\u1EEF li\u1EC7u \u0111\u01B0\u1EE3c s\u1EED d\u1EE5ng nhi\u1EC1u nh\u1EA5t l\xE0m ti\xEAu chu\u1EA9n h\u1ECDc thu\u1EADt \u0111\u1EC3 tr\u1EA3 l\u1EDDi c\xE2u h\u1ECFi khai th\xE1c l\xE0 "),_n=h(_c,"A",{href:!0,rel:!0});var ym=r(_n);Da=a(ym,"SQuAD"),ym.forEach(n),xs=a(_c,", v\xEC v\u1EADy \u0111\xF3 l\xE0 t\u1EADp ch\xFAng ta s\u1EBD s\u1EED d\u1EE5ng \u1EDF \u0111\xE2y. Ngo\xE0i ra c\xF2n c\xF3 m\u1ED9t \u0111i\u1EC3m chu\u1EA9n kh\xF3 h\u01A1n "),xt=h(_c,"A",{href:!0,rel:!0});var xm=r(xt);$s=a(xm,"SQuAD v2"),xm.forEach(n),lt=a(_c,", bao g\u1ED3m c\xE1c c\xE2u h\u1ECFi kh\xF4ng c\xF3 c\xE2u tr\u1EA3 l\u1EDDi. Mi\u1EC5n l\xE0 t\u1EADp d\u1EEF li\u1EC7u c\u1EE7a ri\xEAng b\u1EA1n ch\u1EE9a m\u1ED9t c\u1ED9t cho ng\u1EEF c\u1EA3nh, m\u1ED9t c\u1ED9t cho c\xE2u h\u1ECFi v\xE0 m\u1ED9t c\u1ED9t cho c\xE2u tr\u1EA3 l\u1EDDi, b\u1EA1n s\u1EBD c\xF3 th\u1EC3 \u0111i\u1EC1u ch\u1EC9nh c\xE1c b\u01B0\u1EDBc b\xEAn d\u01B0\u1EDBi."),_c.forEach(n),ws=u(t),$t=h(t,"H3",{class:!0});var to=r($t);ln=h(to,"A",{id:!0,class:!0,href:!0});var $m=r(ln);Fe=h($m,"SPAN",{});var wm=r(Fe);q(Vt.$$.fragment,wm),wm.forEach(n),$m.forEach(n),Aa=u(to),He=h(to,"SPAN",{});var jm=r(He);Ie=a(jm,"B\u1ED9 d\u1EEF li\u1EC7u SQuAD"),jm.forEach(n),to.forEach(n),js=u(t),cn=h(t,"P",{});var no=r(cn);Ve=a(no,"Nh\u01B0 th\u01B0\u1EDDng l\u1EC7, ch\xFAng ta c\xF3 th\u1EC3 t\u1EA3i xu\u1ED1ng v\xE0 l\u01B0u b\u1ED9 d\u1EEF li\u1EC7u v\xE0o b\u1ED9 nh\u1EDB cache ch\u1EC9 trong m\u1ED9t b\u01B0\u1EDBc nh\u1EDD v\xE0o "),Qe=h(no,"CODE",{});var qm=r(Qe);Pa=a(qm,"load_dataset()"),qm.forEach(n),Ge=a(no,":"),no.forEach(n),qs=u(t),q(vn.$$.fragment,t),Re=u(t),St=h(t,"P",{});var Em=r(St);Es=a(Em,"Sau \u0111\xF3, ch\xFAng ta c\xF3 th\u1EC3 xem x\xE9t \u0111\u1ED1i t\u01B0\u1EE3ng n\xE0y \u0111\u1EC3 t\xECm hi\u1EC3u th\xEAm v\u1EC1 t\u1EADp d\u1EEF li\u1EC7u SQuAD:"),Em.forEach(n),wt=u(t),q(bn.$$.fragment,t),le=u(t),q(kn.$$.fragment,t),Cs=u(t),ot=h(t,"P",{});var ja=r(ot);Sa=a(ja,"C\xF3 v\u1EBB nh\u01B0 ch\xFAng ta c\xF3 m\u1ECDi th\u1EE9 ta c\u1EA7n v\u1EDBi c\xE1c tr\u01B0\u1EDDng "),Ke=h(ja,"CODE",{});var Cm=r(Ke);Ts=a(Cm,"context"),Cm.forEach(n),yn=a(ja,", "),ce=h(ja,"CODE",{});var Tm=r(ce);bt=a(Tm,"question"),Tm.forEach(n),Ba=a(ja,", v\xE0 "),xn=h(ja,"CODE",{});var Dm=r(xn);Na=a(Dm,"answers"),Dm.forEach(n),Ma=a(ja,", v\xEC v\u1EADy h\xE3y in ch\xFAng cho ph\u1EA7n t\u1EED \u0111\u1EA7u ti\xEAn c\u1EE7a t\u1EADp hu\u1EA5n luy\u1EC7n c\u1EE7a m\xECnh:"),ja.forEach(n),he=u(t),q($n.$$.fragment,t),Ds=u(t),q(Qt.$$.fragment,t),As=u(t),st=h(t,"P",{});var Lt=r(st);Ps=a(Lt,"C\xE1c tr\u01B0\u1EDDng "),Gt=h(Lt,"CODE",{});var Am=r(Gt);Ss=a(Am,"context"),Am.forEach(n),wn=a(Lt," v\xE0 "),re=h(Lt,"CODE",{});var Pm=r(re);oe=a(Pm,"question"),Pm.forEach(n),Oa=a(Lt," r\u1EA5t d\u1EC5 s\u1EED d\u1EE5ng. Tr\u01B0\u1EDDng "),pe=h(Lt,"CODE",{});var Sm=r(pe);jn=a(Sm,"answers"),Sm.forEach(n),Bs=a(Lt," ph\u1EE9c t\u1EA1p h\u01A1n m\u1ED9t ch\xFAt v\xEC n\xF3 so s\xE1nh m\u1ED9t t\u1EEB \u0111i\u1EC3n v\u1EDBi hai tr\u01B0\u1EDDng \u0111\u1EC1u l\xE0 danh s\xE1ch. \u0110\xE2y l\xE0 \u0111\u1ECBnh d\u1EA1ng s\u1EBD \u0111\u01B0\u1EE3c mong \u0111\u1EE3i b\u1EDFi ch\u1EC9 s\u1ED1 "),kt=h(Lt,"CODE",{});var Bm=r(kt);za=a(Bm,"squad"),Bm.forEach(n),We=a(Lt," trong qu\xE1 tr\xECnh \u0111\xE1nh gi\xE1; n\u1EBFu b\u1EA1n \u0111ang s\u1EED d\u1EE5ng d\u1EEF li\u1EC7u c\u1EE7a ri\xEAng m\xECnh, b\u1EA1n kh\xF4ng nh\u1EA5t thi\u1EBFt ph\u1EA3i lo l\u1EAFng v\u1EC1 vi\u1EC7c \u0111\u1EB7t c\xE1c c\xE2u tr\u1EA3 l\u1EDDi \u1EDF c\xF9ng m\u1ED9t \u0111\u1ECBnh d\u1EA1ng. Tr\u01B0\u1EDDng "),Ue=h(Lt,"CODE",{});var Nm=r(Ue);La=a(Nm,"text"),Nm.forEach(n),Xe=a(Lt," kh\xE1 r\xF5 r\xE0ng v\xE0 tr\u01B0\u1EDDng "),Je=h(Lt,"CODE",{});var Mm=r(Je);Fa=a(Mm,"answer_start"),Mm.forEach(n),Ns=a(Lt," ch\u1EE9a ch\u1EC9 m\u1EE5c k\xFD t\u1EF1 b\u1EAFt \u0111\u1EA7u c\u1EE7a m\u1ED7i c\xE2u tr\u1EA3 l\u1EDDi trong ng\u1EEF c\u1EA3nh."),Lt.forEach(n),Bt=u(t),gt=h(t,"P",{});var eo=r(gt);Ye=a(eo,"Trong qu\xE1 tr\xECnh hu\u1EA5n luy\u1EC7n, ch\u1EC9 c\xF3 m\u1ED9t c\xE2u tr\u1EA3 l\u1EDDi kh\u1EA3 d\u0129. Ch\xFAng ta c\xF3 th\u1EC3 ki\u1EC3m tra k\u1EF9 \u0111i\u1EC1u n\xE0y b\u1EB1ng c\xE1ch s\u1EED d\u1EE5ng ph\u01B0\u01A1ng th\u1EE9c "),Rt=h(eo,"CODE",{});var Om=r(Rt);Ha=a(Om,"Dataset.filter()"),Om.forEach(n),Ze=a(eo,":"),eo.forEach(n),Ms=u(t),q(hn.$$.fragment,t),qn=u(t),q(En.$$.fragment,t),ts=u(t),dt=h(t,"P",{});var zm=r(dt);Cn=a(zm,"Tuy nhi\xEAn, \u0111\u1EC3 \u0111\xE1nh gi\xE1, c\xF3 m\u1ED9t s\u1ED1 c\xE2u tr\u1EA3 l\u1EDDi c\xF3 th\u1EC3 c\xF3 cho m\u1ED7i m\u1EABu, c\xF3 th\u1EC3 gi\u1ED1ng ho\u1EB7c kh\xE1c nhau:"),zm.forEach(n),Os=u(t),q(Kt.$$.fragment,t),zs=u(t),q(Tn.$$.fragment,t),Ls=u(t),pt=h(t,"P",{});var Lm=r(pt);Ia=a(Lm,"Ch\xFAng ta s\u1EBD kh\xF4ng \u0111i s\xE2u v\xE0o t\u1EADp l\u1EC7nh \u0111\xE1nh gi\xE1 v\xEC t\u1EA5t c\u1EA3 s\u1EBD \u0111\u01B0\u1EE3c bao b\u1ECDc b\u1EDFi ch\u1EC9 s\u1ED1 \u{1F917} Datasets, nh\u01B0ng phi\xEAn b\u1EA3n ng\u1EAFn l\xE0 m\u1ED9t s\u1ED1 c\xE2u h\u1ECFi c\xF3 m\u1ED9t s\u1ED1 c\xE2u tr\u1EA3 l\u1EDDi c\xF3 th\u1EC3 c\xF3 v\xE0 t\u1EADp l\u1EC7nh n\xE0y s\u1EBD so s\xE1nh m\u1ED9t c\xE2u tr\u1EA3 l\u1EDDi \u0111\u01B0\u1EE3c d\u1EF1 \u0111o\xE1n cho t\u1EA5t c\u1EA3 c\xE2u tr\u1EA3 l\u1EDDi c\xF3 th\u1EC3 ch\u1EA5p nh\u1EADn \u0111\u01B0\u1EE3c v\xE0 d\xE0nh \u0111i\u1EC3m cao nh\u1EA5t. V\xED d\u1EE5: n\u1EBFu ch\xFAng ta xem x\xE9t m\u1EABu \u1EDF ch\u1EC9 m\u1EE5c 2:"),Lm.forEach(n),ue=u(t),q(Dn.$$.fragment,t),Fs=u(t),q(Wt.$$.fragment,t),Hs=u(t),me=h(t,"P",{});var Fm=r(me);ns=a(Fm,"ta c\xF3 th\u1EC3 th\u1EA5y c\xE2u tr\u1EA3 l\u1EDDi c\xF3 th\u1EC3 th\u1EF1c ra l\xE0 m\u1ED9t trong s\u1ED1 ba kh\u1EA3 n\u0103ng ta th\u1EA5y tr\u01B0\u1EDBc \u0111\xF3."),Fm.forEach(n),Is=u(t),Ut=h(t,"H3",{class:!0});var so=r(Ut);rn=h(so,"A",{id:!0,class:!0,href:!0});var Hm=r(rn);jt=h(Hm,"SPAN",{});var Im=r(jt);q(An.$$.fragment,Im),Im.forEach(n),Hm.forEach(n),es=u(so),ss=h(so,"SPAN",{});var Vm=r(ss);Va=a(Vm,"X\u1EED l\xFD d\u1EEF li\u1EC7u hu\u1EA5n luy\u1EC7n"),Vm.forEach(n),so.forEach(n),ge=u(t),q(Pn.$$.fragment,t),Vs=u(t),Sn=h(t,"P",{});var Qm=r(Sn);de=a(Qm,"H\xE3y b\u1EAFt \u0111\u1EA7u v\u1EDBi vi\u1EC7c x\u1EED l\xFD tr\u01B0\u1EDBc d\u1EEF li\u1EC7u hu\u1EA5n luy\u1EC7n. Ph\u1EA7n kh\xF3 s\u1EBD l\xE0 t\u1EA1o nh\xE3n cho c\xE2u tr\u1EA3 l\u1EDDi c\u1EE7a c\xE2u h\u1ECFi, \u0111\xF3 s\u1EBD l\xE0 v\u1ECB tr\xED b\u1EAFt \u0111\u1EA7u v\xE0 k\u1EBFt th\xFAc c\u1EE7a c\xE1c th\u1EBB t\u01B0\u01A1ng \u1EE9ng v\u1EDBi c\xE2u tr\u1EA3 l\u1EDDi b\xEAn trong ng\u1EEF c\u1EA3nh."),Qm.forEach(n),Qs=u(t),Bn=h(t,"P",{});var Gm=r(Bn);Nn=a(Gm,"Nh\u01B0ng ch\xFAng ta \u0111\u1EEBng v\u01B0\u1EE3t l\xEAn ch\xEDnh m\xECnh. \u0110\u1EA7u ti\xEAn, ch\xFAng ta c\u1EA7n chuy\u1EC3n \u0111\u1ED5i v\u0103n b\u1EA3n trong \u0111\u1EA7u v\xE0o th\xE0nh c\xE1c ID m\xE0 m\xF4 h\xECnh c\xF3 th\u1EC3 hi\u1EC3u \u0111\u01B0\u1EE3c, s\u1EED d\u1EE5ng tokenizer:"),Gm.forEach(n),as=u(t),q(Nt.$$.fragment,t),Gs=u(t),ft=h(t,"P",{});var qa=r(ft);Mn=a(qa,"Nh\u01B0 \u0111\xE3 \u0111\u1EC1 c\u1EADp tr\u01B0\u1EDBc \u0111\xF3, ch\xFAng ta s\u1EBD tinh ch\u1EC9nh m\xF4 h\xECnh BERT, nh\u01B0ng b\u1EA1n c\xF3 th\u1EC3 s\u1EED d\u1EE5ng b\u1EA5t k\u1EF3 lo\u1EA1i m\xF4 h\xECnh n\xE0o kh\xE1c mi\u1EC5n l\xE0 n\xF3 c\xF3 tri\u1EC3n khai tr\xECnh tokenize nhanh. B\u1EA1n c\xF3 th\u1EC3 xem t\u1EA5t c\u1EA3 c\xE1c ki\u1EBFn tr\xFAc \u0111i k\xE8m v\u1EDBi phi\xEAn b\u1EA3n nhanh trong "),on=h(qa,"A",{href:!0,rel:!0});var Rm=r(on);Z=a(Rm,"b\u1EA3ng l\u1EDBn n\xE0y"),Rm.forEach(n),Qa=a(qa," v\xE0 \u0111\u1EC3 ki\u1EC3m tra xem \u0111\u1ED1i t\u01B0\u1EE3ng "),On=h(qa,"CODE",{});var Km=r(On);Ga=a(Km,"tokenizer"),Km.forEach(n),Ra=a(qa," m\xE0 b\u1EA1n \u0111ang s\u1EED d\u1EE5ng c\xF3 th\u1EF1c s\u1EF1 l\xE0 \u0111\u01B0\u1EE3c h\u1ED7 tr\u1EE3 b\u1EDFi \u{1F917} Tokenizers, b\u1EA1n c\xF3 th\u1EC3 xem thu\u1ED9c t\xEDnh "),zn=h(qa,"CODE",{});var Wm=r(zn);Ka=a(Wm,"is_fast"),Wm.forEach(n),Wa=a(qa," c\u1EE7a n\xF3:"),qa.forEach(n),fe=u(t),q(Ln.$$.fragment,t),Rs=u(t),q(Xt.$$.fragment,t),Ks=u(t),_e=h(t,"P",{});var Um=r(_e);is=a(Um,"Ch\xFAng ta c\xF3 th\u1EC3 truy\u1EC1n c\xE2u h\u1ECFi v\xE0 ng\u1EEF c\u1EA3nh cho tr\xECnh tokenizer c\u1EE7a m\xECnh v\xE0 n\xF3 s\u1EBD ch\xE8n \u0111\xFAng c\xE1c token \u0111\u1EB7c bi\u1EC7t \u0111\u1EC3 t\u1EA1o th\xE0nh m\u1ED9t c\xE2u nh\u01B0 sau:"),Um.forEach(n),Ws=u(t),q(Fn.$$.fragment,t),ve=u(t),be=h(t,"P",{});var Xm=r(be);Ua=a(Xm,"H\xE3y c\xF9ng ki\u1EC3m tra n\xF3:"),Xm.forEach(n),ke=u(t),q(Hn.$$.fragment,t),Us=u(t),q(pn.$$.fragment,t),qt=u(t),ye=h(t,"P",{});var Jm=r(ye);ls=a(Jm,"C\xE1c nh\xE3n sau \u0111\xF3 s\u1EBD l\xE0 ch\u1EC9 m\u1EE5c c\u1EE7a c\xE1c token b\u1EAFt \u0111\u1EA7u v\xE0 k\u1EBFt th\xFAc c\xE2u tr\u1EA3 l\u1EDDi v\xE0 m\xF4 h\xECnh s\u1EBD c\xF3 nhi\u1EC7m v\u1EE5 d\u1EF1 \u0111o\xE1n m\u1ED9t logit b\u1EAFt \u0111\u1EA7u v\xE0 k\u1EBFt th\xFAc cho m\u1ED7i token trong \u0111\u1EA7u v\xE0o, v\u1EDBi c\xE1c nh\xE3n l\xFD thuy\u1EBFt nh\u01B0 sau:"),Jm.forEach(n),Xs=u(t),Jt=h(t,"DIV",{class:!0});var ao=r(Jt);Et=h(ao,"IMG",{class:!0,src:!0,alt:!0}),Xa=u(ao),In=h(ao,"IMG",{class:!0,src:!0,alt:!0}),ao.forEach(n),m=u(t),M=h(t,"P",{});var vc=r(M);Ys=a(vc,"Trong tr\u01B0\u1EDDng h\u1EE3p n\xE0y, ng\u1EEF c\u1EA3nh kh\xF4ng qu\xE1 d\xE0i, nh\u01B0ng m\u1ED9t s\u1ED1 m\u1EABu trong t\u1EADp d\u1EEF li\u1EC7u c\xF3 ng\u1EEF c\u1EA3nh r\u1EA5t d\xE0i s\u1EBD v\u01B0\u1EE3t qu\xE1 \u0111\u1ED9 d\xE0i t\u1ED1i \u0111a m\xE0 ch\xFAng t\xF4i \u0111\u1EB7t (trong tr\u01B0\u1EDDng h\u1EE3p n\xE0y l\xE0 384). Nh\u01B0 ch\xFAng ta \u0111\xE3 th\u1EA5y trong "),cs=h(vc,"A",{href:!0});var Ym=r(cs);nl=a(Ym,"Ch\u01B0\u01A1ng 6"),Ym.forEach(n),el=a(vc," khi ch\xFAng ta kh\xE1m ph\xE1 ph\u1EA7n b\xEAn trong c\u1EE7a pipeline "),un=h(vc,"CODE",{});var Zm=r(un);sl=a(Zm,"question-answering"),Zm.forEach(n),al=a(vc,", ch\xFAng ta s\u1EBD \u0111\u1ED1i ph\xF3 v\u1EDBi c\xE1c ng\u1EEF c\u1EA3nh d\xE0i b\u1EB1ng c\xE1ch t\u1EA1o m\u1ED9t s\u1ED1 \u0111\u1EB7c tr\u01B0ng hu\u1EA5n luy\u1EC7n t\u1EEB m\u1ED9t m\u1EABu t\u1EADp d\u1EEF li\u1EC7u c\u1EE7a m\xECnh, v\u1EDBi c\u1EEDa s\u1ED5 tr\u01B0\u1EE3t gi\u1EEFa ch\xFAng."),vc.forEach(n),hs=u(t),rs=h(t,"P",{});var tg=r(rs);il=a(tg,"\u0110\u1EC3 xem c\xE1ch n\xE0y ho\u1EA1t \u0111\u1ED9ng nh\u01B0 th\u1EBF n\xE0o b\u1EB1ng c\xE1ch s\u1EED d\u1EE5ng v\xED d\u1EE5 hi\u1EC7n t\u1EA1i, ch\xFAng ta c\xF3 th\u1EC3 gi\u1EDBi h\u1EA1n \u0111\u1ED9 d\xE0i \u1EDF 100 v\xE0 s\u1EED d\u1EE5ng c\u1EEDa s\u1ED5 tr\u01B0\u1EE3t g\u1ED3m 50 token. Xin nh\u1EAFc l\u1EA1i, ch\xFAng ta s\u1EED d\u1EE5ng:"),tg.forEach(n),Ya=u(t),tt=h(t,"UL",{});var Ea=r(tt);os=h(Ea,"LI",{});var Uu=r(os);Zs=h(Uu,"CODE",{});var ng=r(Zs);ll=a(ng,"max_length"),ng.forEach(n),cl=a(Uu," \u0111\u1EC3 \u0111\u1EB7t \u0111\u1ED9 d\xE0i t\u1ED1i \u0111a (\u1EDF \u0111\xE2y l\xE0 100)"),Uu.forEach(n),hl=u(Ea),Vn=h(Ea,"LI",{});var Xu=r(Vn);ta=h(Xu,"CODE",{});var eg=r(ta);yt=a(eg,'truncation="only_second"'),eg.forEach(n),rl=a(Xu," \u0111\u1EC3 c\u1EAFt ng\u1EAFn ng\u1EEF c\u1EA3nh (\u1EDF v\u1ECB tr\xED th\u1EE9 hai) khi c\xE2u h\u1ECFi c\xF3 ng\u1EEF c\u1EA3nh qu\xE1 d\xE0i"),Xu.forEach(n),ol=u(Ea),ps=h(Ea,"LI",{});var Ju=r(ps);na=h(Ju,"CODE",{});var sg=r(na);pl=a(sg,"stride"),sg.forEach(n),xe=a(Ju," \u0111\u1EC3 \u0111\u1EB7t s\u1ED1 l\u01B0\u1EE3ng token ch\u1ED3ng ch\xE9o gi\u1EEFa hai ph\u1EA7n li\xEAn ti\u1EBFp (\u1EDF \u0111\xE2y l\xE0 50)"),Ju.forEach(n),ul=u(Ea),us=h(Ea,"LI",{});var Yu=r(us);Mt=h(Yu,"CODE",{});var ag=r(Mt);ml=a(ag,"return_overflowing_tokens=True"),ag.forEach(n),gl=a(Yu," \u0111\u1EC3 cho tr\xECnh tokenizer bi\u1EBFt ch\xFAng ta mu\u1ED1n c\xE1c token tr\xE0n"),Yu.forEach(n),Ea.forEach(n),Za=u(t),q($e.$$.fragment,t),Qn=u(t),q(we.$$.fragment,t),ti=u(t),Ct=h(t,"P",{});var bc=r(Ct);dl=a(bc,"Nh\u01B0 ch\xFAng ta c\xF3 th\u1EC3 th\u1EA5y, v\xED d\u1EE5 c\u1EE7a ch\xFAng ta \u0111\xE3 \u0111\u01B0\u1EE3c chia th\xE0nh b\u1ED1n \u0111\u1EA7u v\xE0o, m\u1ED7i \u0111\u1EA7u v\xE0o ch\u1EE9a c\xE2u h\u1ECFi v\xE0 m\u1ED9t s\u1ED1 ph\u1EA7n c\u1EE7a ng\u1EEF c\u1EA3nh. L\u01B0u \xFD r\u1EB1ng c\xE2u tr\u1EA3 l\u1EDDi cho c\xE2u h\u1ECFi (\u201CBernadette Soubirous\u201D) ch\u1EC9 xu\u1EA5t hi\u1EC7n trong \u0111\u1EA7u v\xE0o th\u1EE9 ba v\xE0 cu\u1ED1i c\xF9ng, v\xEC v\u1EADy b\u1EB1ng c\xE1ch x\u1EED l\xFD c\xE1c ng\u1EEF c\u1EA3nh d\xE0i theo c\xE1ch n\xE0y, ch\xFAng ta s\u1EBD t\u1EA1o m\u1ED9t s\u1ED1 m\u1EABu hu\u1EA5n luy\u1EC7n trong \u0111\xF3 c\xE2u tr\u1EA3 l\u1EDDi kh\xF4ng \u0111\u01B0\u1EE3c \u0111\u01B0a v\xE0o ng\u1EEF c\u1EA3nh. \u0110\u1ED1i v\u1EDBi nh\u1EEFng v\xED d\u1EE5 \u0111\xF3, nh\xE3n s\u1EBD l\xE0 "),ea=h(bc,"CODE",{});var ig=r(ea);fl=a(ig,"start_position = end_position = 0"),ig.forEach(n),_l=a(bc," (v\xEC v\u1EADy ch\xFAng t\xF4i d\u1EF1 \u0111o\xE1n token "),mn=h(bc,"CODE",{});var lg=r(mn);sa=a(lg,"[CLS]"),lg.forEach(n),vl=a(bc,"). Ch\xFAng ta c\u0169ng s\u1EBD \u0111\u1EB7t c\xE1c nh\xE3n \u0111\xF3 trong tr\u01B0\u1EDDng h\u1EE3p kh\xF4ng may khi c\xE2u tr\u1EA3 l\u1EDDi \u0111\xE3 b\u1ECB c\u1EAFt b\u1EDBt \u0111\u1EC3 ch\xFAng ta ch\u1EC9 c\xF3 ph\u1EA7n \u0111\u1EA7u (ho\u1EB7c ph\u1EA7n cu\u1ED1i) c\u1EE7a c\xE2u tr\u1EA3 l\u1EDDi. \u0110\u1ED1i v\u1EDBi c\xE1c v\xED d\u1EE5 trong \u0111\xF3 c\xE2u tr\u1EA3 l\u1EDDi n\u1EB1m \u0111\u1EA7y \u0111\u1EE7 trong ng\u1EEF c\u1EA3nh, c\xE1c nh\xE3n s\u1EBD l\xE0 ch\u1EC9 m\u1EE5c c\u1EE7a token n\u01A1i c\xE2u tr\u1EA3 l\u1EDDi b\u1EAFt \u0111\u1EA7u v\xE0 ch\u1EC9 m\u1EE5c c\u1EE7a token n\u01A1i c\xE2u tr\u1EA3 l\u1EDDi k\u1EBFt th\xFAc."),bc.forEach(n),Yt=u(t),Zt=h(t,"P",{});var kc=r(Zt);bl=a(kc,"T\u1EADp d\u1EEF li\u1EC7u cung c\u1EA5p cho ch\xFAng ta k\xFD t\u1EF1 b\u1EAFt \u0111\u1EA7u c\u1EE7a c\xE2u tr\u1EA3 l\u1EDDi trong ng\u1EEF c\u1EA3nh v\xE0 b\u1EB1ng c\xE1ch th\xEAm \u0111\u1ED9 d\xE0i c\u1EE7a c\xE2u tr\u1EA3 l\u1EDDi, ch\xFAng ta c\xF3 th\u1EC3 t\xECm th\u1EA5y k\xFD t\u1EF1 k\u1EBFt th\xFAc trong ng\u1EEF c\u1EA3nh. \u0110\u1EC3 \xE1nh x\u1EA1 ch\xFAng v\u1EDBi c\xE1c ch\u1EC9 s\u1ED1 token, ch\xFAng ta s\u1EBD c\u1EA7n s\u1EED d\u1EE5ng \xE1nh x\u1EA1 offset m\xE0 ch\xFAng ta \u0111\xE3 nghi\xEAn c\u1EE9u trong "),ms=h(kc,"A",{href:!0});var cg=r(ms);je=a(cg,"Ch\u01B0\u01A1ng 6"),cg.forEach(n),kl=a(kc,". Ch\xFAng ta c\xF3 th\u1EC3 y\xEAu c\u1EA7u tokenizer tr\u1EA3 l\u1EA1i nh\u1EEFng th\u1EE9 n\xE0y b\u1EB1ng c\xE1ch truy\u1EC1n theo "),aa=h(kc,"CODE",{});var hg=r(aa);yl=a(hg,"return_offsets_mapping=True"),hg.forEach(n),xl=a(kc,":"),kc.forEach(n),it=u(t),q(qe.$$.fragment,t),ni=u(t),q(Ee.$$.fragment,t),ei=u(t),tn=h(t,"P",{});var yc=r(tn);$l=a(yc,"Nh\u01B0 ch\xFAng ta c\xF3 th\u1EC3 th\u1EA5y, ch\xFAng ta l\u1EA5y l\u1EA1i c\xE1c ID \u0111\u1EA7u v\xE0o th\xF4ng th\u01B0\u1EDDng, token ID v\xE0 attention mask, c\u0169ng nh\u01B0 \xE1nh x\u1EA1 offset m\xE0 ch\xFAng ta y\xEAu c\u1EA7u v\xE0 m\u1ED9t kh\xF3a b\u1ED5 sung, "),ia=h(yc,"CODE",{});var rg=r(ia);Ce=a(rg,"overflow_to_sample_mapping"),rg.forEach(n),wl=a(yc,". Gi\xE1 tr\u1ECB t\u01B0\u01A1ng \u1EE9ng s\u1EBD \u0111\u01B0\u1EE3c s\u1EED d\u1EE5ng cho ch\xFAng ta khi tokenize nhi\u1EC1u v\u0103n b\u1EA3n c\xF9ng m\u1ED9t l\xFAc (ch\xFAng ta n\xEAn l\xE0m \u0111\u1EC3 h\u01B0\u1EDFng l\u1EE3i t\u1EEB th\u1EF1c t\u1EBF l\xE0 tr\xECnh tokenizer \u0111\u01B0\u1EE3c h\u1ED7 tr\u1EE3 b\u1EDFi Rust). V\xEC m\u1ED9t m\u1EABu c\xF3 th\u1EC3 cung c\u1EA5p m\u1ED9t s\u1ED1 \u0111\u1ED1i t\u01B0\u1EE3ng \u0111\u1ECBa l\xFD, n\xEAn n\xF3 \xE1nh x\u1EA1 t\u1EEBng \u0111\u1ED1i t\u01B0\u1EE3ng \u0111\u1ECBa l\xFD v\u1EDBi v\xED d\u1EE5 m\xE0 n\xF3 c\xF3 ngu\u1ED3n g\u1ED1c. B\u1EDFi v\xEC \u1EDF \u0111\xE2y ch\xFAng ta ch\u1EC9 tokenize m\u1ED9t v\xED d\u1EE5, ch\xFAng ta nh\u1EADn \u0111\u01B0\u1EE3c danh s\xE1ch c\xE1c "),la=h(yc,"CODE",{});var og=r(la);jl=a(og,"0"),og.forEach(n),wo=a(yc,":"),yc.forEach(n),kh=u(t),q(si.$$.fragment,t),yh=u(t),q(ai.$$.fragment,t),xh=u(t),ql=h(t,"P",{});var pg=r(ql);jo=a(pg,"Nh\u01B0ng n\u1EBFu ch\xFAng ta m\xE3 h\xF3a nhi\u1EC1u m\u1EABu h\u01A1n, \u0111i\u1EC1u n\xE0y s\u1EBD tr\u1EDF n\xEAn h\u1EEFu \xEDch h\u01A1n:"),pg.forEach(n),$h=u(t),q(ii.$$.fragment,t),wh=u(t),q(li.$$.fragment,t),jh=u(t),El=h(t,"P",{});var ug=r(El);qo=a(ug,"Nh\u01B0 ch\xFAng ta c\xF3 th\u1EC3 th\u1EA5y, ba m\u1EABu \u0111\u1EA7u ti\xEAn (t\u1EA1i ch\u1EC9 s\u1ED1 2, 3 v\xE0 4 trong t\u1EADp hu\u1EA5n luy\u1EC7n) m\u1ED7i m\u1EABu \u0111\u01B0a ra b\u1ED1n \u0111\u1EB7c tr\u01B0ng v\xE0 m\u1EABu cu\u1ED1i c\xF9ng (t\u1EA1i ch\u1EC9 m\u1EE5c 5 trong t\u1EADp hu\u1EA5n luy\u1EC7n) \u0111\u01B0a ra 7 \u0111\u1EB7c tr\u01B0ng."),ug.forEach(n),qh=u(t),Cl=h(t,"P",{});var mg=r(Cl);Eo=a(mg,"Th\xF4ng tin n\xE0y s\u1EBD h\u1EEFu \xEDch \u0111\u1EC3 \xE1nh x\u1EA1 t\u1EEBng \u0111\u1ED1i t\u01B0\u1EE3ng m\xE0 ch\xFAng ta nh\u1EADn \u0111\u01B0\u1EE3c v\u1EDBi nh\xE3n t\u01B0\u01A1ng \u1EE9ng c\u1EE7a n\xF3. Nh\u01B0 \u0111\xE3 \u0111\u1EC1 c\u1EADp tr\u01B0\u1EDBc \u0111\xF3, c\xE1c nh\xE3n \u0111\xF3 l\xE0:"),mg.forEach(n),Eh=u(t),ca=h(t,"UL",{});var io=r(ca);Tl=h(io,"LI",{});var Zu=r(Tl);Ec=h(Zu,"CODE",{});var gg=r(Ec);Co=a(gg,"(0, 0)"),gg.forEach(n),To=a(Zu," n\u1EBFu c\xE2u tr\u1EA3 l\u1EDDi kh\xF4ng n\u1EB1m trong kho\u1EA3ng t\u01B0\u01A1ng \u1EE9ng c\u1EE7a ng\u1EEF c\u1EA3nh"),Zu.forEach(n),Do=u(io),Te=h(io,"LI",{});var tl=r(Te);Cc=h(tl,"CODE",{});var dg=r(Cc);Ao=a(dg,"(start_position, end_position)"),dg.forEach(n),Po=a(tl," n\u1EBFu c\xE2u tr\u1EA3 l\u1EDDi n\u1EB1m trong kho\u1EA3ng t\u01B0\u01A1ng \u1EE9ng c\u1EE7a ng\u1EEF c\u1EA3nh, v\u1EDBi "),Tc=h(tl,"CODE",{});var fg=r(Tc);So=a(fg,"start_position"),fg.forEach(n),Bo=a(tl," l\xE0 ch\u1EC9 m\u1EE5c c\u1EE7a token (trong c\xE1c ID \u0111\u1EA7u v\xE0o) \u1EDF \u0111\u1EA7u c\xE2u tr\u1EA3 l\u1EDDi v\xE0 "),Dc=h(tl,"CODE",{});var _g=r(Dc);No=a(_g,"end_position"),_g.forEach(n),Mo=a(tl," l\xE0 ch\u1EC9 m\u1EE5c c\u1EE7a token (trong c\xE1c ID \u0111\u1EA7u v\xE0o) n\u01A1i c\xE2u tr\u1EA3 l\u1EDDi k\u1EBFt th\xFAc."),tl.forEach(n),io.forEach(n),Ch=u(t),De=h(t,"P",{});var xc=r(De);Oo=a(xc,"\u0110\u1EC3 x\xE1c \u0111\u1ECBnh \u0111\xE2y l\xE0 tr\u01B0\u1EDDng h\u1EE3p n\xE0o v\xE0 n\u1EBFu c\xF3 li\xEAn quan, v\u1ECB tr\xED c\u1EE7a c\xE1c token, tr\u01B0\u1EDBc ti\xEAn ch\xFAng ta t\xECm c\xE1c ch\u1EC9 s\u1ED1 b\u1EAFt \u0111\u1EA7u v\xE0 k\u1EBFt th\xFAc ng\u1EEF c\u1EA3nh trong c\xE1c ID \u0111\u1EA7u v\xE0o. Ch\xFAng ta c\xF3 th\u1EC3 s\u1EED d\u1EE5ng c\xE1c token ID \u0111\u1EC3 th\u1EF1c hi\u1EC7n vi\u1EC7c n\xE0y, nh\u01B0ng v\xEC ch\xFAng kh\xF4ng nh\u1EA5t thi\u1EBFt ph\u1EA3i t\u1ED3n t\u1EA1i cho t\u1EA5t c\u1EA3 c\xE1c m\xF4 h\xECnh (v\xED d\u1EE5: DistilBERT kh\xF4ng y\xEAu c\u1EA7u ch\xFAng), thay v\xE0o \u0111\xF3, ch\xFAng ta s\u1EBD s\u1EED d\u1EE5ng ph\u01B0\u01A1ng th\u1EE9c "),Ac=h(xc,"CODE",{});var vg=r(Ac);zo=a(vg,"sequence_ids()"),vg.forEach(n),Lo=a(xc," c\u1EE7a "),Pc=h(xc,"CODE",{});var bg=r(Pc);Fo=a(bg,"BatchEncoding"),bg.forEach(n),Ho=a(xc," m\xE0 tokenizer c\u1EE7a ta tr\u1EA3 v\u1EC1."),xc.forEach(n),Th=u(t),ha=h(t,"P",{});var lo=r(ha);Io=a(lo,"Khi ta c\xF3 c\xE1c ch\u1EC9 m\u1EE5c token \u0111\xF3, ch\xFAng ta xem x\xE9t c\xE1c offset, l\xE0 c\xE1c b\u1ED9 gi\xE1 tr\u1ECB c\u1EE7a hai s\u1ED1 nguy\xEAn \u0111\u1EA1i di\u1EC7n cho kho\u1EA3ng k\xFD t\u1EF1 b\xEAn trong ng\u1EEF c\u1EA3nh ban \u0111\u1EA7u. Do \u0111\xF3, ch\xFAng ta c\xF3 th\u1EC3 ph\xE1t hi\u1EC7n xem \u0111o\u1EA1n ng\u1EEF c\u1EA3nh trong \u0111\u1EB7c tr\u01B0ng n\xE0y b\u1EAFt \u0111\u1EA7u sau c\xE2u tr\u1EA3 l\u1EDDi hay k\u1EBFt th\xFAc tr\u01B0\u1EDBc khi c\xE2u tr\u1EA3 l\u1EDDi b\u1EAFt \u0111\u1EA7u (trong tr\u01B0\u1EDDng h\u1EE3p \u0111\xF3 nh\xE3n l\xE0 "),Sc=h(lo,"CODE",{});var kg=r(Sc);Vo=a(kg,"(0, 0)"),kg.forEach(n),Qo=a(lo,"). N\u1EBFu kh\xF4ng ph\u1EA3i nh\u01B0 v\u1EADy, ch\xFAng ta l\u1EB7p l\u1EA1i \u0111\u1EC3 t\xECm m\xE3 token \u0111\u1EA7u ti\xEAn v\xE0 cu\u1ED1i c\xF9ng c\u1EE7a c\xE2u tr\u1EA3 l\u1EDDi:"),lo.forEach(n),Dh=u(t),q(ci.$$.fragment,t),Ah=u(t),q(hi.$$.fragment,t),Ph=u(t),ra=h(t,"P",{});var co=r(ra);Go=a(co,"H\xE3y c\xF9ng xem m\u1ED9t v\xE0i k\u1EBFt qu\u1EA3 \u0111\u1EC3 x\xE1c minh r\u1EB1ng c\xE1ch ti\u1EBFp c\u1EADn c\u1EE7a ch\xFAng ta l\xE0 \u0111\xFAng. \u0110\u1ED1i v\u1EDBi \u0111\u1EB7c tr\u01B0ng \u0111\u1EA7u ti\xEAn ch\xFAng ta t\xECm th\u1EA5y "),Bc=h(co,"CODE",{});var yg=r(Bc);Ro=a(yg,"(83, 85)"),yg.forEach(n),Ko=a(co," d\u01B0\u1EDBi d\u1EA1ng nh\xE3n, h\xE3y so s\xE1nh c\xE2u tr\u1EA3 l\u1EDDi l\xFD thuy\u1EBFt v\u1EDBi kho\u1EA3ng token \u0111\u01B0\u1EE3c gi\u1EA3i m\xE3 t\u1EEB 83 \u0111\u1EBFn 85 (bao g\u1ED3m):"),co.forEach(n),Sh=u(t),q(ri.$$.fragment,t),Bh=u(t),q(oi.$$.fragment,t),Nh=u(t),oa=h(t,"P",{});var ho=r(oa);Wo=a(ho,"K\u1EBFt qu\u1EA3 kh\xE1 l\xE0 kh\u1EDBp nhau! B\xE2y gi\u1EDD ch\xFAng ta h\xE3y ki\u1EC3m tra ch\u1EC9 m\u1EE5c 4, n\u01A1i ch\xFAng ta \u0111\u1EB7t nh\xE3n th\xE0nh "),Nc=h(ho,"CODE",{});var xg=r(Nc);Uo=a(xg,"(0, 0)"),xg.forEach(n),Xo=a(ho,", c\xF3 ngh\u0129a l\xE0 c\xE2u tr\u1EA3 l\u1EDDi kh\xF4ng n\u1EB1m trong ph\u1EA7n ng\u1EEF c\u1EA3nh c\u1EE7a \u0111\u1EB7c tr\u01B0ng \u0111\xF3:"),ho.forEach(n),Mh=u(t),q(pi.$$.fragment,t),Oh=u(t),q(ui.$$.fragment,t),zh=u(t),Dl=h(t,"P",{});var $g=r(Dl);Jo=a($g,"</Tip>"),$g.forEach(n),Lh=u(t),Al=h(t,"P",{});var wg=r(Al);Yo=a(wg,"B\xE2y gi\u1EDD ch\xFAng ta \u0111\xE3 th\u1EA5y t\u1EEBng b\u01B0\u1EDBc c\xE1ch ti\u1EC1n x\u1EED l\xFD d\u1EEF li\u1EC7u hu\u1EA5n luy\u1EC7n c\u1EE7a m\xECnh, ch\xFAng ta c\xF3 th\u1EC3 nh\xF3m n\xF3 trong m\u1ED9t h\xE0m m\xE0 ta s\u1EBD \xE1p d\u1EE5ng tr\xEAn to\xE0n b\u1ED9 t\u1EADp d\u1EEF li\u1EC7u hu\u1EA5n luy\u1EC7n. Ch\xFAng ta s\u1EBD \u0111\u1EC7m m\u1ECDi \u0111\u1EB7c tr\u01B0ng \u0111\u1EBFn \u0111\u1ED9 d\xE0i t\u1ED1i \u0111a m\xE0 ta \u0111\xE3 \u0111\u1EB7t, v\xEC h\u1EA7u h\u1EBFt c\xE1c ng\u1EEF c\u1EA3nh s\u1EBD d\xE0i (v\xE0 c\xE1c m\u1EABu t\u01B0\u01A1ng \u1EE9ng s\u1EBD \u0111\u01B0\u1EE3c chia th\xE0nh nhi\u1EC1u \u0111\u1EB7c tr\u01B0ng), v\xEC v\u1EADy kh\xF4ng c\xF3 l\u1EE3i \xEDch th\u1EF1c s\u1EF1 n\xE0o khi \xE1p d\u1EE5ng \u0111\u1EC7m \u0111\u1ED9ng \u1EDF \u0111\xE2y:"),wg.forEach(n),Fh=u(t),Pl=h(t,"P",{});var jg=r(Pl);Zo=a(jg,"Th\u1EADt v\u1EADy, ch\xFAng ta kh\xF4ng th\u1EA5y c\xE2u tr\u1EA3 l\u1EDDi b\xEAn trong ng\u1EEF c\u1EA3nh."),jg.forEach(n),Hh=u(t),q(pa.$$.fragment,t),Ih=u(t),Sl=h(t,"P",{});var qg=r(Sl);tp=a(qg,"B\xE2y gi\u1EDD ch\xFAng ta \u0111\xE3 th\u1EA5y t\u1EEBng b\u01B0\u1EDBc c\xE1ch ti\u1EC1n x\u1EED l\xFD d\u1EEF li\u1EC7u hu\u1EA5n luy\u1EC7n c\u1EE7a m\xECnh, ch\xFAng ta c\xF3 th\u1EC3 nh\xF3m n\xF3 trong m\u1ED9t h\xE0m m\xE0 ch\xFAng ta s\u1EBD \xE1p d\u1EE5ng tr\xEAn to\xE0n b\u1ED9 t\u1EADp d\u1EEF li\u1EC7u hu\u1EA5n luy\u1EC7n. Ch\xFAng ta s\u1EBD \u0111\u1EC7m m\u1ECDi \u0111\u1EB7c tr\u01B0ng \u0111\u1EBFn \u0111\u1ED9 d\xE0i t\u1ED1i \u0111a m\xE0 ch\xFAng ta \u0111\xE3 \u0111\u1EB7t, v\xEC h\u1EA7u h\u1EBFt c\xE1c ng\u1EEF c\u1EA3nh s\u1EBD d\xE0i (v\xE0 c\xE1c m\u1EABu t\u01B0\u01A1ng \u1EE9ng s\u1EBD \u0111\u01B0\u1EE3c chia th\xE0nh nhi\u1EC1u \u0111\u1EB7c tr\u01B0ng), v\xEC v\u1EADy kh\xF4ng c\xF3 l\u1EE3i \xEDch th\u1EF1c s\u1EF1 n\xE0o khi \xE1p d\u1EE5ng \u0111\u1EC7m \u0111\u1ED9ng \u1EDF \u0111\xE2y:"),qg.forEach(n),Vh=u(t),q(mi.$$.fragment,t),Qh=u(t),Bl=h(t,"P",{});var Eg=r(Bl);np=a(Eg,"L\u01B0u \xFD r\u1EB1ng ch\xFAng ta \u0111\xE3 x\xE1c \u0111\u1ECBnh hai h\u1EB1ng s\u1ED1 \u0111\u1EC3 x\xE1c \u0111\u1ECBnh \u0111\u1ED9 d\xE0i t\u1ED1i \u0111a \u0111\u01B0\u1EE3c s\u1EED d\u1EE5ng c\u0169ng nh\u01B0 \u0111\u1ED9 d\xE0i c\u1EE7a c\u1EEDa s\u1ED5 tr\u01B0\u1EE3t v\xE0 ta \u0111\xE3 th\xEAm m\u1ED9t ch\xFAt d\u1ECDn d\u1EB9p tr\u01B0\u1EDBc khi tokenize: m\u1ED9t s\u1ED1 c\xE2u h\u1ECFi trong t\u1EADp d\u1EEF li\u1EC7u SQuAD c\xF3 th\xEAm kho\u1EA3ng tr\u1EAFng \u1EDF \u0111\u1EA7u v\xE0 k\u1EBFt th\xFAc m\xE0 kh\xF4ng th\xEAm b\u1EA5t k\u1EF3 th\u1EE9 g\xEC (v\xE0 chi\u1EBFm dung l\u01B0\u1EE3ng khi \u0111\u01B0\u1EE3c tokenize n\u1EBFu b\u1EA1n s\u1EED d\u1EE5ng m\xF4 h\xECnh nh\u01B0 RoBERTa), v\xEC v\u1EADy ta \u0111\xE3 x\xF3a nh\u1EEFng kho\u1EA3ng tr\u1EAFng th\u1EEBa \u0111\xF3."),Eg.forEach(n),Gh=u(t),Ae=h(t,"P",{});var $c=r(Ae);ep=a($c,"\u0110\u1EC3 \xE1p d\u1EE5ng h\xE0m n\xE0y cho to\xE0n b\u1ED9 t\u1EADp hu\u1EA5n luy\u1EC7n, ch\xFAng ta s\u1EED d\u1EE5ng ph\u01B0\u01A1ng th\u1EE9c "),Mc=h($c,"CODE",{});var Cg=r(Mc);sp=a(Cg,"Dataset.map()"),Cg.forEach(n),ap=a($c," v\u1EDBi "),Oc=h($c,"CODE",{});var Tg=r(Oc);ip=a(Tg,"batched=True"),Tg.forEach(n),lp=a($c,". \u0110i\u1EC1u n\xE0y c\u1EA7n thi\u1EBFt \u1EDF \u0111\xE2y v\xEC ta \u0111ang thay \u0111\u1ED5i \u0111\u1ED9 d\xE0i c\u1EE7a t\u1EADp d\u1EEF li\u1EC7u (v\xEC m\u1ED9t m\u1EABu c\xF3 th\u1EC3 cung c\u1EA5p m\u1ED9t s\u1ED1 \u0111\u1EB7c tr\u01B0ng hu\u1EA5n luy\u1EC7n):"),$c.forEach(n),Rh=u(t),q(gi.$$.fragment,t),Kh=u(t),q(di.$$.fragment,t),Wh=u(t),Nl=h(t,"P",{});var Dg=r(Nl);cp=a(Dg,"Nh\u01B0 ta c\xF3 th\u1EC3 th\u1EA5y, qu\xE1 tr\xECnh ti\u1EC1n x\u1EED l\xFD \u0111\xE3 th\xEAm kho\u1EA3ng 1,000 \u0111\u1EB7c tr\u01B0ng. B\u1ED9 hu\u1EA5n luy\u1EC7n hi\u1EC7n \u0111\xE3 s\u1EB5n s\xE0ng \u0111\u1EC3 s\u1EED d\u1EE5ng - h\xE3y c\xF9ng t\xECm hi\u1EC3u v\u1EC1 qu\xE1 tr\xECnh ti\u1EC1n x\u1EED l\xFD c\u1EE7a b\u1ED9 ki\u1EC3m \u0111\u1ECBnh!"),Dg.forEach(n),Uh=u(t),gs=h(t,"H3",{class:!0});var ro=r(gs);ua=h(ro,"A",{id:!0,class:!0,href:!0});var Ag=r(ua);zc=h(Ag,"SPAN",{});var Pg=r(zc);q(fi.$$.fragment,Pg),Pg.forEach(n),Ag.forEach(n),hp=u(ro),Lc=h(ro,"SPAN",{});var Sg=r(Lc);rp=a(Sg,"X\u1EED l\xFD d\u1EEF li\u1EC7u ki\u1EC3m \u0111\u1ECBnh"),Sg.forEach(n),ro.forEach(n),Xh=u(t),Ml=h(t,"P",{});var Bg=r(Ml);op=a(Bg,"Vi\u1EC7c x\u1EED l\xFD tr\u01B0\u1EDBc d\u1EEF li\u1EC7u ki\u1EC3m \u0111\u1ECBnh s\u1EBD d\u1EC5 d\xE0ng h\u01A1n m\u1ED9t ch\xFAt v\xEC ch\xFAng ta kh\xF4ng c\u1EA7n t\u1EA1o nh\xE3n (tr\u1EEB khi ch\xFAng ta mu\u1ED1n t\xEDnh to\xE1n m\u1EA5t m\xE1t ki\u1EC3m \u0111\u1ECBnh, nh\u01B0ng con s\u1ED1 \u0111\xF3 s\u1EBD kh\xF4ng th\u1EF1c s\u1EF1 gi\xFAp ch\xFAng ta hi\u1EC3u m\xF4 h\xECnh t\u1ED1t nh\u01B0 th\u1EBF n\xE0o). Ni\u1EC1m vui th\u1EF1c s\u1EF1 s\u1EBD l\xE0 di\u1EC5n gi\u1EA3i c\xE1c d\u1EF1 \u0111o\xE1n c\u1EE7a m\xF4 h\xECnh th\xE0nh c\xE1c kho\u1EA3ng c\u1EE7a b\u1ED1i c\u1EA3nh ban \u0111\u1EA7u. \u0110\u1ED1i v\u1EDBi \u0111i\u1EC1u n\xE0y, ch\xFAng ta s\u1EBD ch\u1EC9 c\u1EA7n l\u01B0u tr\u1EEF c\u1EA3 \xE1nh x\u1EA1 offset v\xE0 m\u1ED9t s\u1ED1 c\xE1ch \u0111\u1EC3 kh\u1EDBp t\u1EEBng \u0111\u1ED1i t\u01B0\u1EE3ng \u0111\xE3 t\u1EA1o v\u1EDBi v\xED d\u1EE5 ban \u0111\u1EA7u m\xE0 n\xF3 xu\u1EA5t ph\xE1t. V\xEC c\xF3 m\u1ED9t c\u1ED9t ID trong t\u1EADp d\u1EEF li\u1EC7u g\u1ED1c, ch\xFAng ta s\u1EBD s\u1EED d\u1EE5ng ID \u0111\xF3."),Bg.forEach(n),Jh=u(t),Pe=h(t,"P",{});var wc=r(Pe);pp=a(wc,"\u0110i\u1EC1u duy nh\u1EA5t ch\xFAng ta s\u1EBD th\xEAm \u1EDF \u0111\xE2y l\xE0 m\u1ED9t ch\xFAt d\u1ECDn d\u1EB9p c\xE1c \xE1nh x\u1EA1 offset. Ch\xFAng s\u1EBD ch\u1EE9a c\xE1c ph\u1EA7n b\xF9 cho c\xE2u h\u1ECFi v\xE0 ng\u1EEF c\u1EA3nh, nh\u01B0ng khi ch\xFAng ta \u0111ang \u1EDF giai \u0111o\u1EA1n h\u1EADu x\u1EED l\xFD, ch\xFAng ta s\u1EBD kh\xF4ng c\xF3 c\xE1ch n\xE0o \u0111\u1EC3 bi\u1EBFt ph\u1EA7n n\xE0o c\u1EE7a ID \u0111\u1EA7u v\xE0o t\u01B0\u01A1ng \u1EE9ng v\u1EDBi ng\u1EEF c\u1EA3nh v\xE0 ph\u1EA7n n\xE0o l\xE0 c\xE2u h\u1ECFi (ph\u01B0\u01A1ng th\u1EE9c "),Fc=h(wc,"CODE",{});var Ng=r(Fc);up=a(Ng,"sequence_ids()"),Ng.forEach(n),mp=a(wc," ta \u0111\xE3 s\u1EED d\u1EE5ng ch\u1EC9 c\xF3 s\u1EB5n cho \u0111\u1EA7u ra c\u1EE7a tokenizer). V\xEC v\u1EADy, ch\xFAng ta s\u1EBD \u0111\u1EB7t c\xE1c offset t\u01B0\u01A1ng \u1EE9ng v\u1EDBi c\xE2u h\u1ECFi th\xE0nh "),Hc=h(wc,"CODE",{});var Mg=r(Hc);gp=a(Mg,"None"),Mg.forEach(n),dp=a(wc,":"),wc.forEach(n),Yh=u(t),q(_i.$$.fragment,t),Zh=u(t),Ol=h(t,"P",{});var Og=r(Ol);fp=a(Og,"Ch\xFAng ta c\xF3 th\u1EC3 \xE1p d\u1EE5ng h\xE0m n\xE0y tr\xEAn to\xE0n b\u1ED9 t\u1EADp d\u1EEF li\u1EC7u ki\u1EC3m \u0111\u1ECBnh nh\u01B0 tr\u01B0\u1EDBc \u0111\xE2y:"),Og.forEach(n),tr=u(t),q(vi.$$.fragment,t),nr=u(t),q(bi.$$.fragment,t),er=u(t),zl=h(t,"P",{});var zg=r(zl);_p=a(zg,"Trong tr\u01B0\u1EDDng h\u1EE3p n\xE0y, ch\xFAng ta ch\u1EC9 th\xEAm m\u1ED9t v\xE0i tr\u0103m m\u1EABu, v\xEC v\u1EADy c\xF3 v\u1EBB nh\u01B0 c\xE1c ng\u1EEF c\u1EA3nh trong t\u1EADp d\u1EEF li\u1EC7u ki\u1EC3m \u0111\u1ECBnh ng\u1EAFn h\u01A1n m\u1ED9t ch\xFAt."),zg.forEach(n),sr=u(t),Ll=h(t,"P",{});var Lg=r(Ll);vp=a(Lg,"B\xE2y gi\u1EDD ch\xFAng ta \u0111\xE3 ti\u1EC1n x\u1EED l\xFD t\u1EA5t c\u1EA3 d\u1EEF li\u1EC7u, ch\xFAng ta c\xF3 th\u1EC3 tham gia kh\xF3a hu\u1EA5n luy\u1EC7n."),Lg.forEach(n),ar=u(t),Rn.l(t),Fl=u(t),ds=h(t,"H3",{class:!0});var oo=r(ds);ma=h(oo,"A",{id:!0,class:!0,href:!0});var Fg=r(ma);Ic=h(Fg,"SPAN",{});var Hg=r(Ic);q(ki.$$.fragment,Hg),Hg.forEach(n),Fg.forEach(n),bp=u(oo),Vc=h(oo,"SPAN",{});var Ig=r(Vc);kp=a(Ig,"H\u1EADu x\u1EED l\xFD"),Ig.forEach(n),oo.forEach(n),ir=u(t),Wn.l(t),Hl=u(t),ga=h(t,"P",{});var po=r(ga);yp=a(po,"M\xF4 h\xECnh s\u1EBD tr\u1EA3 v\u1EC1 c\xE1c logit \u0111\u1EA7u ra cho c\xE1c v\u1ECB tr\xED b\u1EAFt \u0111\u1EA7u v\xE0 k\u1EBFt th\xFAc c\u1EE7a c\xE2u tr\u1EA3 l\u1EDDi trong ID \u0111\u1EA7u v\xE0o, nh\u01B0 ch\xFAng ta \u0111\xE3 th\u1EA5y trong qu\xE1 tr\xECnh kh\xE1m ph\xE1 pipeline "),Il=h(po,"A",{href:!0});var Vg=r(Il);Qc=h(Vg,"CODE",{});var Qg=r(Qc);xp=a(Qg,"question-answering"),Qg.forEach(n),Vg.forEach(n),$p=a(po,". B\u01B0\u1EDBc ti\u1EC1n x\u1EED l\xFD s\u1EBD t\u01B0\u01A1ng t\u1EF1 nh\u01B0 nh\u1EEFng g\xEC ch\xFAng ta \u0111\xE3 l\xE0m \u1EDF \u0111\xF3, v\xEC v\u1EADy \u0111\xE2y l\xE0 l\u1EDDi nh\u1EAFc nhanh v\u1EC1 c\xE1c b\u01B0\u1EDBc ch\xFAng ta \u0111\xE3 th\u1EF1c hi\u1EC7n:"),po.forEach(n),lr=u(t),gn=h(t,"UL",{});var Ca=r(gn);Gc=h(Ca,"LI",{});var Gg=r(Gc);wp=a(Gg,"Ch\xFAng ta \u0111\xE3 che c\xE1c logit b\u1EAFt \u0111\u1EA7u v\xE0 k\u1EBFt th\xFAc t\u01B0\u01A1ng \u1EE9ng v\u1EDBi c\xE1c token b\xEAn ngo\xE0i ng\u1EEF c\u1EA3nh."),Gg.forEach(n),jp=u(Ca),Rc=h(Ca,"LI",{});var Rg=r(Rc);qp=a(Rg,"Sau \u0111\xF3, ch\xFAng ta chuy\u1EC3n \u0111\u1ED5i c\xE1c logit b\u1EAFt \u0111\u1EA7u v\xE0 k\u1EBFt th\xFAc th\xE0nh x\xE1c su\u1EA5t b\u1EB1ng c\xE1ch s\u1EED d\u1EE5ng softmax."),Rg.forEach(n),Ep=u(Ca),yi=h(Ca,"LI",{});var uo=r(yi);Cp=a(uo,"Ch\xFAng ta quy \u0111i\u1EC3m cho t\u1EEBng c\u1EB7p "),Kc=h(uo,"CODE",{});var Kg=r(Kc);Tp=a(Kg,"(start_token, end_token)"),Kg.forEach(n),Dp=a(uo," c\xE1ch l\u1EA5y t\xEDch c\u1EE7a hai x\xE1c su\u1EA5t t\u01B0\u01A1ng \u1EE9ng."),uo.forEach(n),Ap=u(Ca),fs=h(Ca,"LI",{});var jc=r(fs);Pp=a(jc,"Ch\xFAng ta \u0111\xE3 t\xECm ki\u1EBFm c\u1EB7p c\xF3 \u0111i\u1EC3m t\u1ED1i \u0111a mang l\u1EA1i c\xE2u tr\u1EA3 l\u1EDDi h\u1EE3p l\u1EC7 (v\xED d\u1EE5: "),Wc=h(jc,"CODE",{});var Wg=r(Wc);Sp=a(Wg,"start_token"),Wg.forEach(n),Bp=a(jc," th\u1EA5p h\u01A1n "),Uc=h(jc,"CODE",{});var Ug=r(Uc);Np=a(Ug,"end_token"),Ug.forEach(n),Mp=a(jc,")."),jc.forEach(n),Ca.forEach(n),cr=u(t),dn=h(t,"P",{});var Ta=r(dn);Op=a(Ta,"\u1EDE \u0111\xE2y, ch\xFAng ta s\u1EBD thay \u0111\u1ED5i quy tr\xECnh n\xE0y m\u1ED9t ch\xFAt v\xEC ch\xFAng ta kh\xF4ng c\u1EA7n t\xEDnh \u0111i\u1EC3m th\u1EF1c t\u1EBF (ch\u1EC9 l\xE0 c\xE2u tr\u1EA3 l\u1EDDi d\u1EF1 \u0111o\xE1n). \u0110i\u1EC1u n\xE0y c\xF3 ngh\u0129a l\xE0 ch\xFAng ta c\xF3 th\u1EC3 b\u1ECF qua b\u01B0\u1EDBc softmax. \u0110\u1EC3 \u0111i nhanh h\u01A1n, ch\xFAng ta c\u0169ng s\u1EBD kh\xF4ng t\xEDnh \u0111i\u1EC3m t\u1EA5t c\u1EA3 c\xE1c c\u1EB7p "),Xc=h(Ta,"CODE",{});var Xg=r(Xc);zp=a(Xg,"(start_token, end_token)"),Xg.forEach(n),Lp=a(Ta," c\xF3 th\u1EC3, m\xE0 ch\u1EC9 nh\u1EEFng c\u1EB7p t\u01B0\u01A1ng \u1EE9ng v\u1EDBi logit "),Jc=h(Ta,"CODE",{});var Jg=r(Jc);Fp=a(Jg,"n_best"),Jg.forEach(n),Hp=a(Ta," cao nh\u1EA5t (v\u1EDBi "),Yc=h(Ta,"CODE",{});var Yg=r(Yc);Ip=a(Yg,"n_best = 20"),Yg.forEach(n),Vp=a(Ta,"). V\xEC ch\xFAng ta s\u1EBD b\u1ECF qua softmax, nh\u1EEFng \u0111i\u1EC3m \u0111\xF3 s\u1EBD l\xE0 \u0111i\u1EC3m logit v\xE0 s\u1EBD c\xF3 \u0111\u01B0\u1EE3c b\u1EB1ng c\xE1ch l\u1EA5y t\u1ED5ng c\u1EE7a logit b\u1EAFt \u0111\u1EA7u v\xE0 k\u1EBFt th\xFAc (thay v\xEC nh\xE2n, v\xEC quy t\u1EAFc (\\log(ab) = \\log(a) + \\log(b)\\))."),Ta.forEach(n),hr=u(t),da=h(t,"P",{});var mo=r(da);Qp=a(mo,"\u0110\u1EC3 ch\u1EE9ng minh t\u1EA5t c\u1EA3 nh\u1EEFng \u0111i\u1EC1u n\xE0y, ch\xFAng ta s\u1EBD c\u1EA7n m\u1ED9t s\u1ED1 lo\u1EA1i d\u1EF1 \u0111o\xE1n. V\xEC ch\xFAng ta ch\u01B0a hu\u1EA5n luy\u1EC7n m\xF4 h\xECnh c\u1EE7a m\xECnh, ch\xFAng ta s\u1EBD s\u1EED d\u1EE5ng m\xF4 h\xECnh m\u1EB7c \u0111\u1ECBnh cho pipeline QA \u0111\u1EC3 t\u1EA1o ra m\u1ED9t s\u1ED1 d\u1EF1 \u0111o\xE1n tr\xEAn m\u1ED9t ph\u1EA7n nh\u1ECF c\u1EE7a t\u1EADp h\u1EE3p ki\u1EC3m. Ch\xFAng ta c\xF3 th\u1EC3 s\u1EED d\u1EE5ng ch\u1EE9c n\u0103ng x\u1EED l\xFD t\u01B0\u01A1ng t\u1EF1 nh\u01B0 tr\u01B0\u1EDBc \u0111\xE2y; b\u1EDFi v\xEC n\xF3 d\u1EF1a v\xE0o h\u1EB1ng s\u1ED1 to\xE0n c\u1EE5c "),Zc=h(mo,"CODE",{});var Zg=r(Zc);Gp=a(Zg,"tokenizer"),Zg.forEach(n),Rp=a(mo,", ch\xFAng ta ch\u1EC9 c\u1EA7n thay \u0111\u1ED5i \u0111\u1ED1i t\u01B0\u1EE3ng \u0111\xF3 th\xE0nh tokenizer c\u1EE7a m\xF4 h\xECnh m\xE0 ch\xFAng ta mu\u1ED1n s\u1EED d\u1EE5ng t\u1EA1m th\u1EDDi:"),mo.forEach(n),rr=u(t),q(xi.$$.fragment,t),or=u(t),Vl=h(t,"P",{});var td=r(Vl);Kp=a(td,"B\xE2y gi\u1EDD, qu\xE1 tr\xECnh ti\u1EC1n x\u1EED l\xFD \u0111\xE3 ho\xE0n t\u1EA5t, ch\xFAng ta thay \u0111\u1ED5i tokenizer tr\u1EDF l\u1EA1i c\xE1i m\xE0 ch\xFAng ta \u0111\xE3 ch\u1ECDn ban \u0111\u1EA7u:"),td.forEach(n),pr=u(t),q($i.$$.fragment,t),ur=u(t),fa=h(t,"P",{});var go=r(fa);Wp=a(go,"Sau \u0111\xF3, ch\xFAng ta lo\u1EA1i b\u1ECF c\xE1c c\u1ED9t c\u1EE7a "),th=h(go,"CODE",{});var nd=r(th);Up=a(nd,"eval_set"),nd.forEach(n),Xp=a(go," m\xE0 m\xF4 h\xECnh kh\xF4ng mong \u0111\u1EE3i, x\xE2y d\u1EF1ng m\u1ED9t l\xF4 v\u1EDBi t\u1EA5t c\u1EA3 b\u1ED9 ki\u1EC3m \u0111\u1ECBnh nh\u1ECF \u0111\xF3 v\xE0 chuy\u1EC3n n\xF3 qua m\xF4 h\xECnh. N\u1EBFu c\xF3 s\u1EB5n GPU, ch\xFAng ta s\u1EED d\u1EE5ng n\xF3 \u0111\u1EC3 ch\u1EA1y nhanh h\u01A1n:"),go.forEach(n),mr=u(t),Xn.l(t),Ql=u(t),Ot=h(t,"P",{});var Ne=r(Ot);Jp=a(Ne,"B\xE2y gi\u1EDD, ch\xFAng ta c\u1EA7n t\xECm c\xE2u tr\u1EA3 l\u1EDDi d\u1EF1 \u0111o\xE1n cho t\u1EEBng v\xED d\u1EE5 trong "),nh=h(Ne,"CODE",{});var ed=r(nh);Yp=a(ed,"small_eval_set"),ed.forEach(n),Zp=a(Ne," c\u1EE7a ch\xFAng ta. M\u1ED9t v\xED d\u1EE5 c\xF3 th\u1EC3 \u0111\xE3 \u0111\u01B0\u1EE3c chia th\xE0nh nhi\u1EC1u \u0111\u1EB7c tr\u01B0ng trong "),eh=h(Ne,"CODE",{});var sd=r(eh);tu=a(sd,"eval_set"),sd.forEach(n),nu=a(Ne,", v\xEC v\u1EADy b\u01B0\u1EDBc \u0111\u1EA7u ti\xEAn l\xE0 \xE1nh x\u1EA1 t\u1EEBng m\u1EABu trong "),sh=h(Ne,"CODE",{});var ad=r(sh);eu=a(ad,"small_eval_set"),ad.forEach(n),su=a(Ne," v\u1EDBi c\xE1c \u0111\u1EB7c tr\u01B0ng t\u01B0\u01A1ng \u1EE9ng trong "),ah=h(Ne,"CODE",{});var id=r(ah);au=a(id,"eval_set"),id.forEach(n),iu=a(Ne,":"),Ne.forEach(n),gr=u(t),q(wi.$$.fragment,t),dr=u(t),_a=h(t,"P",{});var fo=r(_a);lu=a(fo,"V\u1EDBi \u0111i\u1EC1u n\xE0y trong tay, ch\xFAng ta th\u1EF1c s\u1EF1 c\xF3 th\u1EC3 b\u1EAFt \u0111\u1EA7u l\xE0m vi\u1EC7c b\u1EB1ng c\xE1ch l\u1EB7p l\u1EA1i t\u1EA5t c\u1EA3 c\xE1c m\u1EABu v\xE0, \u0111\u1ED1i v\u1EDBi m\u1ED7i m\u1EABu, th\xF4ng qua t\u1EA5t c\u1EA3 c\xE1c \u0111\u1EB7c tr\u01B0ng li\xEAn quan. Nh\u01B0 ch\xFAng ta \u0111\xE3 n\xF3i tr\u01B0\u1EDBc \u0111\xE2y, ch\xFAng ta s\u1EBD xem x\xE9t \u0111i\u1EC3m logit cho c\xE1c logit b\u1EAFt \u0111\u1EA7u v\xE0 k\u1EBFt th\xFAc c\u1EE7a "),ih=h(fo,"CODE",{});var ld=r(ih);cu=a(ld,"n_best"),ld.forEach(n),hu=a(fo,", ngo\u1EA1i tr\u1EEB c\xE1c v\u1ECB tr\xED cung c\u1EA5p:"),fo.forEach(n),fr=u(t),Se=h(t,"UL",{});var qc=r(Se);lh=h(qc,"LI",{});var cd=r(lh);ru=a(cd,"M\u1ED9t c\xE2u tr\u1EA3 l\u1EDDi s\u1EBD kh\xF4ng n\u1EB1m trong ng\u1EEF c\u1EA3nh"),cd.forEach(n),ou=u(qc),ch=h(qc,"LI",{});var hd=r(ch);pu=a(hd,"M\u1ED9t c\xE2u tr\u1EA3 l\u1EDDi c\xF3 \u0111\u1ED9 d\xE0i \xE2m"),hd.forEach(n),uu=u(qc),ji=h(qc,"LI",{});var _o=r(ji);mu=a(_o,"M\u1ED9t c\xE2u tr\u1EA3 l\u1EDDi qu\xE1 d\xE0i (ch\xFAng ta gi\u1EDBi h\u1EA1n kh\u1EA3 n\u0103ng \u1EDF m\u1EE9c "),hh=h(_o,"CODE",{});var rd=r(hh);gu=a(rd,"max_answer_length=30"),rd.forEach(n),du=a(_o,")"),_o.forEach(n),qc.forEach(n),_r=u(t),Gl=h(t,"P",{});var od=r(Gl);fu=a(od,"Khi ch\xFAng ta c\xF3 t\u1EA5t c\u1EA3 c\xE1c c\xE2u tr\u1EA3 l\u1EDDi c\xF3 th\u1EC3 \u0111\u01B0\u1EE3c ghi cho m\u1ED9t m\u1EABu, ta ch\u1EC9 c\u1EA7n ch\u1ECDn m\u1ED9t c\xE2u c\xF3 \u0111i\u1EC3m logit t\u1ED1t nh\u1EA5t:"),od.forEach(n),vr=u(t),q(qi.$$.fragment,t),br=u(t),Rl=h(t,"P",{});var pd=r(Rl);_u=a(pd,"\u0110\u1ECBnh d\u1EA1ng cu\u1ED1i c\xF9ng c\u1EE7a c\xE1c c\xE2u tr\u1EA3 l\u1EDDi \u0111\u01B0\u1EE3c d\u1EF1 \u0111o\xE1n l\xE0 \u0111\u1ECBnh d\u1EA1ng s\u1EBD \u0111\u01B0\u1EE3c d\u1EF1 \u0111o\xE1n theo ch\u1EC9 s\u1ED1 m\xE0 ch\xFAng ta s\u1EBD s\u1EED d\u1EE5ng. Nh\u01B0 th\u01B0\u1EDDng l\u1EC7, ch\xFAng ta c\xF3 th\u1EC3 t\u1EA3i n\xF3 v\u1EDBi s\u1EF1 tr\u1EE3 gi\xFAp c\u1EE7a th\u01B0 vi\u1EC7n \u{1F917} Evaluate:"),pd.forEach(n),kr=u(t),q(Ei.$$.fragment,t),yr=u(t),Kl=h(t,"P",{});var ud=r(Kl);vu=a(ud,"Th\u01B0\u1EDBc \u0111o n\xE0y mong \u0111\u1EE3i c\xE1c c\xE2u tr\u1EA3 l\u1EDDi \u0111\u01B0\u1EE3c d\u1EF1 \u0111o\xE1n \u1EDF \u0111\u1ECBnh d\u1EA1ng m\xE0 ch\xFAng ta \u0111\xE3 th\u1EA5y \u1EDF tr\xEAn (danh s\xE1ch c\xE1c t\u1EEB \u0111i\u1EC3n c\xF3 m\u1ED9t kh\xF3a cho ID c\u1EE7a m\u1EABu v\xE0 m\u1ED9t kh\xF3a cho v\u0103n b\u1EA3n \u0111\u01B0\u1EE3c d\u1EF1 \u0111o\xE1n) v\xE0 c\xE1c c\xE2u tr\u1EA3 l\u1EDDi l\xFD thuy\u1EBFt \u1EDF \u0111\u1ECBnh d\u1EA1ng b\xEAn d\u01B0\u1EDBi (danh s\xE1ch c\xE1c t\u1EEB \u0111i\u1EC3n c\xF3 m\u1ED9t kh\xF3a cho ID c\u1EE7a m\u1EABu v\xE0 m\u1ED9t kh\xF3a cho c\xE1c c\xE2u tr\u1EA3 l\u1EDDi c\xF3 th\u1EC3 c\xF3):"),ud.forEach(n),xr=u(t),q(Ci.$$.fragment,t),$r=u(t),Wl=h(t,"P",{});var md=r(Wl);bu=a(md,"B\xE2y gi\u1EDD ch\xFAng ta c\xF3 th\u1EC3 ki\u1EC3m tra xem ta c\xF3 nh\u1EADn \u0111\u01B0\u1EE3c k\u1EBFt qu\u1EA3 h\u1EE3p l\xFD hay kh\xF4ng b\u1EB1ng c\xE1ch xem x\xE9t y\u1EBFu t\u1ED1 \u0111\u1EA7u ti\xEAn c\u1EE7a c\u1EA3 hai danh s\xE1ch:"),md.forEach(n),wr=u(t),q(Ti.$$.fragment,t),jr=u(t),q(Di.$$.fragment,t),qr=u(t),Ul=h(t,"P",{});var gd=r(Ul);ku=a(gd,"Kh\xF4ng t\u1EC7 l\u1EAFm! B\xE2y gi\u1EDD ch\xFAng ta h\xE3y xem x\xE9t \u0111i\u1EC3m s\u1ED1 m\xE0 s\u1ED1 li\u1EC7u mang l\u1EA1i cho ch\xFAng ta:"),gd.forEach(n),Er=u(t),q(Ai.$$.fragment,t),Cr=u(t),q(Pi.$$.fragment,t),Tr=u(t),va=h(t,"P",{});var vo=r(va);yu=a(vo,"M\u1ED9t l\u1EA7n n\u1EEFa, \u0111i\u1EC1u \u0111\xF3 kh\xE1 t\u1ED1t theo "),Si=h(vo,"A",{href:!0,rel:!0});var dd=r(Si);xu=a(dd,"b\xE0i b\xE1o c\u1EE7a n\xF3"),dd.forEach(n),$u=a(vo,", DistilBERT \u0111\u01B0\u1EE3c tinh ch\u1EC9nh tr\xEAn SQuAD thu \u0111\u01B0\u1EE3c 79.1 v\xE0 86.9 tr\xEAn to\xE0n b\u1ED9 t\u1EADp d\u1EEF li\u1EC7u."),vo.forEach(n),Dr=u(t),bs.l(t),Xl=u(t),q(Bi.$$.fragment,t),Ar=u(t),Jl=h(t,"P",{});var fd=r(Jl);wu=a(fd,"Ch\xFAng ta c\xF3 th\u1EC3 ki\u1EC3m tra n\xF3 ho\u1EA1t \u0111\u1ED9ng d\u1EF1a tr\xEAn d\u1EF1 \u0111o\xE1n c\u1EE7a m\xECnh:"),fd.forEach(n),Pr=u(t),q(Ni.$$.fragment,t),Sr=u(t),q(Mi.$$.fragment,t),Br=u(t),Yl=h(t,"P",{});var _d=r(Yl);ju=a(_d,"Tr\xF4ng kh\xE1 \u1ED5n! B\xE2y gi\u1EDD ch\xFAng ta h\xE3y s\u1EED d\u1EE5ng \u0111i\u1EC1u n\xE0y \u0111\u1EC3 tinh ch\u1EC9nh m\xF4 h\xECnh c\u1EE7a m\xECnh."),_d.forEach(n),Nr=u(t),_s=h(t,"H3",{class:!0});var bo=r(_s);ba=h(bo,"A",{id:!0,class:!0,href:!0});var vd=r(ba);rh=h(vd,"SPAN",{});var bd=r(rh);q(Oi.$$.fragment,bd),bd.forEach(n),vd.forEach(n),qu=u(bo),oh=h(bo,"SPAN",{});var kd=r(oh);Eu=a(kd,"Tinh ch\u1EC9nh m\xF4 h\xECnh"),kd.forEach(n),bo.forEach(n),Mr=u(t),Yn.l(t),Zl=u(t),tc=h(t,"P",{});var yd=r(tc);Cu=a(yd,"Nh\u01B0 th\u01B0\u1EDDng l\u1EC7, ch\xFAng ta nh\u1EADn \u0111\u01B0\u1EE3c c\u1EA3nh b\xE1o r\u1EB1ng m\u1ED9t s\u1ED1 tr\u1ECDng s\u1ED1 kh\xF4ng \u0111\u01B0\u1EE3c s\u1EED d\u1EE5ng (c\xE1c tr\u1ECDng s\u1ED1 t\u1EEB ph\u1EA7n \u0111\u1EA7u hu\u1EA5n luy\u1EC7n tr\u01B0\u1EDBc) v\xE0 m\u1ED9t s\u1ED1 tr\u1ECDng s\u1ED1 kh\xE1c \u0111\u01B0\u1EE3c kh\u1EDFi t\u1EA1o ng\u1EABu nhi\xEAn (c\xE1c tr\u1ECDng s\u1ED1 cho \u0111\u1EA7u tr\u1EA3 l\u1EDDi c\xE2u h\u1ECFi). B\xE2y gi\u1EDD b\u1EA1n n\xEAn quen v\u1EDBi \u0111i\u1EC1u n\xE0y, nh\u01B0ng \u0111i\u1EC1u \u0111\xF3 c\xF3 ngh\u0129a l\xE0 m\xF4 h\xECnh n\xE0y ch\u01B0a s\u1EB5n s\xE0ng \u0111\u1EC3 s\u1EED d\u1EE5ng v\xE0 c\u1EA7n \u0111\u01B0\u1EE3c tinh ch\u1EC9nh - \u0111i\u1EC1u t\u1ED1t l\xE0 ch\xFAng ta s\u1EAFp l\xE0m \u0111\u01B0\u1EE3c \u0111i\u1EC1u \u0111\xF3!"),yd.forEach(n),Or=u(t),nc=h(t,"P",{});var xd=r(nc);Tu=a(xd,"\u0110\u1EC3 c\xF3 th\u1EC3 \u0111\u1EA9y m\xF4 h\xECnh c\u1EE7a m\xECnh l\xEAn Hub, ch\xFAng ta c\u1EA7n \u0111\u0103ng nh\u1EADp v\xE0o Hugging Face. 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, h\xE0m n\xE0y s\u1EBD hi\u1EC3n th\u1ECB m\u1ED9t ti\u1EC7n \xEDch m\xE0 b\u1EA1n c\xF3 th\u1EC3 nh\u1EADp th\xF4ng tin \u0111\u0103ng nh\u1EADp c\u1EE7a m\xECnh:"),xd.forEach(n),zr=u(t),q(zi.$$.fragment,t),Lr=u(t),ec=h(t,"P",{});var $d=r(ec);Du=a($d,"N\u1EBFu b\u1EA1n kh\xF4ng l\xE0m vi\u1EC7c trong notebook, ch\u1EC9 c\u1EA7n nh\u1EADp d\xF2ng sau v\xE0o thi\u1EBFt b\u1ECB \u0111\u1EA7u cu\u1ED1i c\u1EE7a b\u1EA1n:"),$d.forEach(n),Fr=u(t),q(Li.$$.fragment,t),Hr=u(t),te.l(t),sc=u(t),zt=h(t,"P",{});var Me=r(zt);Au=a(Me,"M\u1EB7c \u0111\u1ECBnh, kho l\u01B0u tr\u1EEF \u0111\u01B0\u1EE3c s\u1EED d\u1EE5ng s\u1EBD n\u1EB1m trong kh\xF4ng gian t\xEAn c\u1EE7a b\u1EA1n v\xE0 \u0111\u01B0\u1EE3c \u0111\u1EB7t t\xEAn theo th\u01B0 m\u1EE5c \u0111\u1EA7u ra m\xE0 b\u1EA1n \u0111\xE3 \u0111\u1EB7t, v\xEC v\u1EADy trong tr\u01B0\u1EDDng h\u1EE3p c\u1EE7a m\xECnh, n\xF3 s\u1EBD n\u1EB1m trong "),ph=h(Me,"CODE",{});var wd=r(ph);Pu=a(wd,'"sgugger/bert-finetuned-squad"'),wd.forEach(n),Su=a(Me,". Ch\xFAng ta c\xF3 th\u1EC3 ghi \u0111\xE8 \u0111i\u1EC1u n\xE0y b\u1EB1ng c\xE1ch chuy\u1EC3n m\u1ED9t "),uh=h(Me,"CODE",{});var jd=r(uh);Bu=a(jd,"hub_model_id"),jd.forEach(n),Nu=a(Me,"; v\xED d\u1EE5: \u0111\u1EC3 \u0111\u1EA9y m\xF4 h\xECnh v\xE0o t\u1ED5 ch\u1EE9c "),mh=h(Me,"CODE",{});var qd=r(mh);Mu=a(qd,"huggingface_course"),qd.forEach(n),Ou=a(Me,", ch\xFAng ta \u0111\xE3 s\u1EED d\u1EE5ng "),gh=h(Me,"CODE",{});var Ed=r(gh);zu=a(Ed,'hub_model_id="huggingface_course/bert-finetuned-squad"'),Ed.forEach(n),Lu=a(Me," (l\xE0 m\xF4 h\xECnh m\xE0 ta \u0111\xE3 li\xEAn k\u1EBFt \u1EDF \u0111\u1EA7u ph\u1EA7n n\xE0y)."),Me.forEach(n),Ir=u(t),ee.l(t),ac=u(t),ic=h(t,"P",{});var Cd=r(ic);Fu=a(Cd,"L\u01B0u \xFD r\u1EB1ng trong khi qu\xE1 tr\xECnh hu\u1EA5n luy\u1EC7n di\u1EC5n ra, m\u1ED7i khi m\xF4 h\xECnh \u0111\u01B0\u1EE3c l\u01B0u (\u1EDF \u0111\xE2y, m\u1ED7i epoch), n\xF3 s\u1EBD \u0111\u01B0\u1EE3c t\u1EA3i l\xEAn Hub \u1EDF ch\u1EBF \u0111\u1ED9 n\u1EC1n. B\u1EB1ng c\xE1ch n\xE0y, b\u1EA1n s\u1EBD c\xF3 th\u1EC3 ti\u1EBFp t\u1EE5c hu\u1EA5n luy\u1EC7n c\u1EE7a m\xECnh tr\xEAn m\u1ED9t m\xE1y kh\xE1c n\u1EBFu c\u1EA7n. To\xE0n b\u1ED9 qu\xE1 tr\xECnh hu\u1EA5n luy\u1EC7n m\u1EA5t m\u1ED9t kho\u1EA3ng th\u1EDDi gian (h\u01A1n m\u1ED9t gi\u1EDD tr\xEAn Titan RTX), v\xEC v\u1EADy b\u1EA1n c\xF3 th\u1EC3 u\u1ED1ng m\u1ED9t ly c\xE0 ph\xEA ho\u1EB7c \u0111\u1ECDc l\u1EA1i m\u1ED9t s\u1ED1 ph\u1EA7n c\u1EE7a kh\xF3a h\u1ECDc m\xE0 b\u1EA1n th\u1EA5y kh\xF3 kh\u0103n h\u01A1n trong khi ti\u1EBFp t\u1EE5c. C\u0169ng l\u01B0u \xFD r\u1EB1ng ngay sau khi epoch \u0111\u1EA7u ti\xEAn k\u1EBFt th\xFAc, b\u1EA1n s\u1EBD th\u1EA5y m\u1ED9t s\u1ED1 tr\u1ECDng s\u1ED1 \u0111\u01B0\u1EE3c t\u1EA3i l\xEAn Hub v\xE0 b\u1EA1n c\xF3 th\u1EC3 b\u1EAFt \u0111\u1EA7u ch\u01A1i v\u1EDBi m\xF4 h\xECnh c\u1EE7a m\xECnh tr\xEAn trang c\u1EE7a n\xF3."),Cd.forEach(n),Vr=u(t),ae.l(t),lc=u(t),q(Fi.$$.fragment,t),Qr=u(t),cc=h(t,"P",{});var Td=r(cc);Hu=a(Td,"Tuy\u1EC7t qu\xE1! \u0110\u1EC3 so s\xE1nh, \u0111i\u1EC3m c\u01A1 b\u1EA3n \u0111\u01B0\u1EE3c b\xE1o c\xE1o trong b\xE0i b\xE1o BERT cho m\xF4 h\xECnh n\xE0y l\xE0 80.8 v\xE0 88.5, v\xEC v\u1EADy ch\xFAng ta \u0111ang \u1EDF \u0111\xFAng v\u1ECB tr\xED c\u1EE7a m\xECnh."),Td.forEach(n),Gr=u(t),ht&&ht.l(t),hc=u(t),rc=h(t,"P",{});var Dd=r(rc);Iu=a(Dd,"\u1EDE giai \u0111o\u1EA1n n\xE0y, b\u1EA1n c\xF3 th\u1EC3 s\u1EED d\u1EE5ng ti\u1EC7n \xEDch lu\u1EADn suy tr\xEAn Model Hub \u0111\u1EC3 ki\u1EC3m tra m\xF4 h\xECnh v\xE0 chia s\u1EBB m\xF4 h\xECnh \u0111\xF3 v\u1EDBi b\u1EA1n b\xE8, gia \u0111\xECnh v\xE0 v\u1EADt nu\xF4i y\xEAu th\xEDch c\u1EE7a b\u1EA1n. B\u1EA1n \u0111\xE3 tinh ch\u1EC9nh th\xE0nh c\xF4ng m\u1ED9t m\xF4 h\xECnh trong t\xE1c v\u1EE5 h\u1ECFi \u0111\xE1p - xin ch\xFAc m\u1EEBng!"),Dd.forEach(n),Rr=u(t),q(ka.$$.fragment,t),Kr=u(t),rt&&rt.l(t),oc=u(t),vs=h(t,"H2",{class:!0});var ko=r(vs);ya=h(ko,"A",{id:!0,class:!0,href:!0});var Ad=r(ya);dh=h(Ad,"SPAN",{});var Pd=r(dh);q(Hi.$$.fragment,Pd),Pd.forEach(n),Ad.forEach(n),Vu=u(ko),fh=h(ko,"SPAN",{});var Sd=r(fh);Qu=a(Sd,"S\u1EED d\u1EE5ng m\xF4 h\xECnh tinh ch\u1EC9nh"),Sd.forEach(n),ko.forEach(n),Wr=u(t),xa=h(t,"P",{});var yo=r(xa);Gu=a(yo,"Ch\xFAng t\xF4i \u0111\xE3 ch\u1EC9 cho b\u1EA1n c\xE1ch b\u1EA1n c\xF3 th\u1EC3 s\u1EED d\u1EE5ng m\xF4 h\xECnh m\xE0 ch\xFAng ta \u0111\xE3 tinh ch\u1EC9nh tr\xEAn Model Hub b\u1EB1ng ti\u1EC7n \xEDch lu\u1EADn suy. \u0110\u1EC3 s\u1EED d\u1EE5ng n\xF3 c\u1EE5c b\u1ED9 trong m\u1ED9t "),_h=h(yo,"CODE",{});var Bd=r(_h);Ru=a(Bd,"pipeline"),Bd.forEach(n),Ku=a(yo,", b\u1EA1n ch\u1EC9 c\u1EA7n ch\u1EC9 \u0111\u1ECBnh m\xE3 \u0111\u1ECBnh danh m\xF4 h\xECnh:"),yo.forEach(n),Ur=u(t),q(Ii.$$.fragment,t),Xr=u(t),q(Vi.$$.fragment,t),Jr=u(t),pc=h(t,"P",{});var Nd=r(pc);Wu=a(Nd,"Tuy\u1EC7t qu\xE1! M\xF4 h\xECnh c\u1EE7a ch\xFAng ta \u0111ang ho\u1EA1t \u0111\u1ED9ng t\u1ED1t nh\u01B0 m\xF4 h\xECnh m\u1EB7c \u0111\u1ECBnh cho pipeline n\xE0y!"),Nd.forEach(n),this.h()},h(){A(o,"name","hf:doc:metadata"),A(o,"content",JSON.stringify(df)),A(b,"id","hi-p"),A(b,"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"),A(b,"href","#hi-p"),A(D,"class","relative group"),A(W,"href","https://rajpurkar.github.io/SQuAD-explorer/"),A(W,"rel","nofollow"),tm(at.src,en="https://hf.space/gradioiframe/course-demos/bert-finetuned-squad/+")||A(at,"src",en),A(at,"frameborder","0"),A(at,"height","450"),A(at,"title","Gradio app"),A(at,"class","block dark:hidden container p-0 flex-grow space-iframe"),A(at,"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"),A(at,"sandbox","allow-forms allow-modals allow-popups allow-popups-to-escape-sandbox allow-same-origin allow-scripts allow-downloads"),A(Dt,"href","https://huggingface.co/huggingface-course/bert-finetuned-squad?context=%F0%9F%A4%97+Transformers+is+backed+by+the+three+most+popular+deep+learning+libraries+%E2%80%94+Jax%2C+PyTorch+and+TensorFlow+%E2%80%94+with+a+seamless+integration+between+them.+It%27s+straightforward+to+train+your+models+with+one+before+loading+them+for+inference+with+the+other.&question=Which+deep+learning+libraries+back+%F0%9F%A4%97+Transformers%3F"),A(Dt,"rel","nofollow"),A(vt,"id","chun-b-d-liu"),A(vt,"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"),A(vt,"href","#chun-b-d-liu"),A(et,"class","relative group"),A(_n,"href","https://rajpurkar.github.io/SQuAD-explorer/"),A(_n,"rel","nofollow"),A(xt,"href","https://huggingface.co/datasets/squad_v2"),A(xt,"rel","nofollow"),A(ln,"id","b-d-liu-squad"),A(ln,"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"),A(ln,"href","#b-d-liu-squad"),A($t,"class","relative group"),A(rn,"id","x-l-d-liu-hun-luyn"),A(rn,"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"),A(rn,"href","#x-l-d-liu-hun-luyn"),A(Ut,"class","relative group"),A(on,"href","https://huggingface.co/transformers/#supported-frameworks"),A(on,"rel","nofollow"),A(Et,"class","block dark:hidden"),tm(Et.src,Js="https://huggingface.co/datasets/huggingface-course/documentation-images/resolve/main/en/chapter7/qa_labels.svg")||A(Et,"src",Js),A(Et,"alt","One-hot encoded labels for question answering."),A(In,"class","hidden dark:block"),tm(In.src,Ja="https://huggingface.co/datasets/huggingface-course/documentation-images/resolve/main/en/chapter7/qa_labels-dark.svg")||A(In,"src",Ja),A(In,"alt","One-hot encoded labels for question answering."),A(Jt,"class","flex justify-center"),A(cs,"href","/course/chapter6/4"),A(ms,"href","/course/chapter6/4"),A(ua,"id","x-l-d-liu-kim-nh"),A(ua,"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"),A(ua,"href","#x-l-d-liu-kim-nh"),A(gs,"class","relative group"),A(ma,"id","hu-x-l"),A(ma,"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"),A(ma,"href","#hu-x-l"),A(ds,"class","relative group"),A(Il,"href","/course/chapter6/3b"),A(Si,"href","https://arxiv.org/abs/1910.01108v2"),A(Si,"rel","nofollow"),A(ba,"id","tinh-chnh-m-hnh"),A(ba,"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"),A(ba,"href","#tinh-chnh-m-hnh"),A(_s,"class","relative group"),A(ya,"id","s-dng-m-hnh-tinh-chnh"),A(ya,"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"),A(ya,"href","#s-dng-m-hnh-tinh-chnh"),A(vs,"class","relative group")},m(t,l){e(document.head,o),i(t,v,l),E(g,t,l),i(t,y,l),i(t,D,l),e(D,b),e(b,$),E(x,$,null),e(D,d),e(D,B),e(B,k),i(t,w,l),Qi[P].m(t,l),i(t,N,l),i(t,T,l),e(T,F),e(T,I),e(I,z),e(T,R),e(T,G),e(G,V),e(T,J),i(t,U,l),E(O,t,l),i(t,K,l),i(t,Y,l),e(Y,nt),e(Y,W),e(W,ct),e(Y,_t),i(t,Tt,l),i(t,at,l),i(t,Ft,l),i(t,Q,l),e(Q,X),e(Q,Dt),e(Dt,ie),e(Q,sn),i(t,fn,l),E(ut,t,l),i(t,an,l),i(t,et,l),e(et,vt),e(vt,mt),E(At,mt,null),e(et,ks),e(et,Ht),e(Ht,ys),i(t,It,l),i(t,Pt,l),e(Pt,Le),e(Pt,_n),e(_n,Da),e(Pt,xs),e(Pt,xt),e(xt,$s),e(Pt,lt),i(t,ws,l),i(t,$t,l),e($t,ln),e(ln,Fe),E(Vt,Fe,null),e($t,Aa),e($t,He),e(He,Ie),i(t,js,l),i(t,cn,l),e(cn,Ve),e(cn,Qe),e(Qe,Pa),e(cn,Ge),i(t,qs,l),E(vn,t,l),i(t,Re,l),i(t,St,l),e(St,Es),i(t,wt,l),E(bn,t,l),i(t,le,l),E(kn,t,l),i(t,Cs,l),i(t,ot,l),e(ot,Sa),e(ot,Ke),e(Ke,Ts),e(ot,yn),e(ot,ce),e(ce,bt),e(ot,Ba),e(ot,xn),e(xn,Na),e(ot,Ma),i(t,he,l),E($n,t,l),i(t,Ds,l),E(Qt,t,l),i(t,As,l),i(t,st,l),e(st,Ps),e(st,Gt),e(Gt,Ss),e(st,wn),e(st,re),e(re,oe),e(st,Oa),e(st,pe),e(pe,jn),e(st,Bs),e(st,kt),e(kt,za),e(st,We),e(st,Ue),e(Ue,La),e(st,Xe),e(st,Je),e(Je,Fa),e(st,Ns),i(t,Bt,l),i(t,gt,l),e(gt,Ye),e(gt,Rt),e(Rt,Ha),e(gt,Ze),i(t,Ms,l),E(hn,t,l),i(t,qn,l),E(En,t,l),i(t,ts,l),i(t,dt,l),e(dt,Cn),i(t,Os,l),E(Kt,t,l),i(t,zs,l),E(Tn,t,l),i(t,Ls,l),i(t,pt,l),e(pt,Ia),i(t,ue,l),E(Dn,t,l),i(t,Fs,l),E(Wt,t,l),i(t,Hs,l),i(t,me,l),e(me,ns),i(t,Is,l),i(t,Ut,l),e(Ut,rn),e(rn,jt),E(An,jt,null),e(Ut,es),e(Ut,ss),e(ss,Va),i(t,ge,l),E(Pn,t,l),i(t,Vs,l),i(t,Sn,l),e(Sn,de),i(t,Qs,l),i(t,Bn,l),e(Bn,Nn),i(t,as,l),E(Nt,t,l),i(t,Gs,l),i(t,ft,l),e(ft,Mn),e(ft,on),e(on,Z),e(ft,Qa),e(ft,On),e(On,Ga),e(ft,Ra),e(ft,zn),e(zn,Ka),e(ft,Wa),i(t,fe,l),E(Ln,t,l),i(t,Rs,l),E(Xt,t,l),i(t,Ks,l),i(t,_e,l),e(_e,is),i(t,Ws,l),E(Fn,t,l),i(t,ve,l),i(t,be,l),e(be,Ua),i(t,ke,l),E(Hn,t,l),i(t,Us,l),E(pn,t,l),i(t,qt,l),i(t,ye,l),e(ye,ls),i(t,Xs,l),i(t,Jt,l),e(Jt,Et),e(Jt,Xa),e(Jt,In),i(t,m,l),i(t,M,l),e(M,Ys),e(M,cs),e(cs,nl),e(M,el),e(M,un),e(un,sl),e(M,al),i(t,hs,l),i(t,rs,l),e(rs,il),i(t,Ya,l),i(t,tt,l),e(tt,os),e(os,Zs),e(Zs,ll),e(os,cl),e(tt,hl),e(tt,Vn),e(Vn,ta),e(ta,yt),e(Vn,rl),e(tt,ol),e(tt,ps),e(ps,na),e(na,pl),e(ps,xe),e(tt,ul),e(tt,us),e(us,Mt),e(Mt,ml),e(us,gl),i(t,Za,l),E($e,t,l),i(t,Qn,l),E(we,t,l),i(t,ti,l),i(t,Ct,l),e(Ct,dl),e(Ct,ea),e(ea,fl),e(Ct,_l),e(Ct,mn),e(mn,sa),e(Ct,vl),i(t,Yt,l),i(t,Zt,l),e(Zt,bl),e(Zt,ms),e(ms,je),e(Zt,kl),e(Zt,aa),e(aa,yl),e(Zt,xl),i(t,it,l),E(qe,t,l),i(t,ni,l),E(Ee,t,l),i(t,ei,l),i(t,tn,l),e(tn,$l),e(tn,ia),e(ia,Ce),e(tn,wl),e(tn,la),e(la,jl),e(tn,wo),i(t,kh,l),E(si,t,l),i(t,yh,l),E(ai,t,l),i(t,xh,l),i(t,ql,l),e(ql,jo),i(t,$h,l),E(ii,t,l),i(t,wh,l),E(li,t,l),i(t,jh,l),i(t,El,l),e(El,qo),i(t,qh,l),i(t,Cl,l),e(Cl,Eo),i(t,Eh,l),i(t,ca,l),e(ca,Tl),e(Tl,Ec),e(Ec,Co),e(Tl,To),e(ca,Do),e(ca,Te),e(Te,Cc),e(Cc,Ao),e(Te,Po),e(Te,Tc),e(Tc,So),e(Te,Bo),e(Te,Dc),e(Dc,No),e(Te,Mo),i(t,Ch,l),i(t,De,l),e(De,Oo),e(De,Ac),e(Ac,zo),e(De,Lo),e(De,Pc),e(Pc,Fo),e(De,Ho),i(t,Th,l),i(t,ha,l),e(ha,Io),e(ha,Sc),e(Sc,Vo),e(ha,Qo),i(t,Dh,l),E(ci,t,l),i(t,Ah,l),E(hi,t,l),i(t,Ph,l),i(t,ra,l),e(ra,Go),e(ra,Bc),e(Bc,Ro),e(ra,Ko),i(t,Sh,l),E(ri,t,l),i(t,Bh,l),E(oi,t,l),i(t,Nh,l),i(t,oa,l),e(oa,Wo),e(oa,Nc),e(Nc,Uo),e(oa,Xo),i(t,Mh,l),E(pi,t,l),i(t,Oh,l),E(ui,t,l),i(t,zh,l),i(t,Dl,l),e(Dl,Jo),i(t,Lh,l),i(t,Al,l),e(Al,Yo),i(t,Fh,l),i(t,Pl,l),e(Pl,Zo),i(t,Hh,l),E(pa,t,l),i(t,Ih,l),i(t,Sl,l),e(Sl,tp),i(t,Vh,l),E(mi,t,l),i(t,Qh,l),i(t,Bl,l),e(Bl,np),i(t,Gh,l),i(t,Ae,l),e(Ae,ep),e(Ae,Mc),e(Mc,sp),e(Ae,ap),e(Ae,Oc),e(Oc,ip),e(Ae,lp),i(t,Rh,l),E(gi,t,l),i(t,Kh,l),E(di,t,l),i(t,Wh,l),i(t,Nl,l),e(Nl,cp),i(t,Uh,l),i(t,gs,l),e(gs,ua),e(ua,zc),E(fi,zc,null),e(gs,hp),e(gs,Lc),e(Lc,rp),i(t,Xh,l),i(t,Ml,l),e(Ml,op),i(t,Jh,l),i(t,Pe,l),e(Pe,pp),e(Pe,Fc),e(Fc,up),e(Pe,mp),e(Pe,Hc),e(Hc,gp),e(Pe,dp),i(t,Yh,l),E(_i,t,l),i(t,Zh,l),i(t,Ol,l),e(Ol,fp),i(t,tr,l),E(vi,t,l),i(t,nr,l),E(bi,t,l),i(t,er,l),i(t,zl,l),e(zl,_p),i(t,sr,l),i(t,Ll,l),e(Ll,vp),i(t,ar,l),Gi[Gn].m(t,l),i(t,Fl,l),i(t,ds,l),e(ds,ma),e(ma,Ic),E(ki,Ic,null),e(ds,bp),e(ds,Vc),e(Vc,kp),i(t,ir,l),Ri[Kn].m(t,l),i(t,Hl,l),i(t,ga,l),e(ga,yp),e(ga,Il),e(Il,Qc),e(Qc,xp),e(ga,$p),i(t,lr,l),i(t,gn,l),e(gn,Gc),e(Gc,wp),e(gn,jp),e(gn,Rc),e(Rc,qp),e(gn,Ep),e(gn,yi),e(yi,Cp),e(yi,Kc),e(Kc,Tp),e(yi,Dp),e(gn,Ap),e(gn,fs),e(fs,Pp),e(fs,Wc),e(Wc,Sp),e(fs,Bp),e(fs,Uc),e(Uc,Np),e(fs,Mp),i(t,cr,l),i(t,dn,l),e(dn,Op),e(dn,Xc),e(Xc,zp),e(dn,Lp),e(dn,Jc),e(Jc,Fp),e(dn,Hp),e(dn,Yc),e(Yc,Ip),e(dn,Vp),i(t,hr,l),i(t,da,l),e(da,Qp),e(da,Zc),e(Zc,Gp),e(da,Rp),i(t,rr,l),E(xi,t,l),i(t,or,l),i(t,Vl,l),e(Vl,Kp),i(t,pr,l),E($i,t,l),i(t,ur,l),i(t,fa,l),e(fa,Wp),e(fa,th),e(th,Up),e(fa,Xp),i(t,mr,l),Ki[Un].m(t,l),i(t,Ql,l),i(t,Ot,l),e(Ot,Jp),e(Ot,nh),e(nh,Yp),e(Ot,Zp),e(Ot,eh),e(eh,tu),e(Ot,nu),e(Ot,sh),e(sh,eu),e(Ot,su),e(Ot,ah),e(ah,au),e(Ot,iu),i(t,gr,l),E(wi,t,l),i(t,dr,l),i(t,_a,l),e(_a,lu),e(_a,ih),e(ih,cu),e(_a,hu),i(t,fr,l),i(t,Se,l),e(Se,lh),e(lh,ru),e(Se,ou),e(Se,ch),e(ch,pu),e(Se,uu),e(Se,ji),e(ji,mu),e(ji,hh),e(hh,gu),e(ji,du),i(t,_r,l),i(t,Gl,l),e(Gl,fu),i(t,vr,l),E(qi,t,l),i(t,br,l),i(t,Rl,l),e(Rl,_u),i(t,kr,l),E(Ei,t,l),i(t,yr,l),i(t,Kl,l),e(Kl,vu),i(t,xr,l),E(Ci,t,l),i(t,$r,l),i(t,Wl,l),e(Wl,bu),i(t,wr,l),E(Ti,t,l),i(t,jr,l),E(Di,t,l),i(t,qr,l),i(t,Ul,l),e(Ul,ku),i(t,Er,l),E(Ai,t,l),i(t,Cr,l),E(Pi,t,l),i(t,Tr,l),i(t,va,l),e(va,yu),e(va,Si),e(Si,xu),e(va,$u),i(t,Dr,l),bs.m(t,l),i(t,Xl,l),E(Bi,t,l),i(t,Ar,l),i(t,Jl,l),e(Jl,wu),i(t,Pr,l),E(Ni,t,l),i(t,Sr,l),E(Mi,t,l),i(t,Br,l),i(t,Yl,l),e(Yl,ju),i(t,Nr,l),i(t,_s,l),e(_s,ba),e(ba,rh),E(Oi,rh,null),e(_s,qu),e(_s,oh),e(oh,Eu),i(t,Mr,l),Wi[Jn].m(t,l),i(t,Zl,l),i(t,tc,l),e(tc,Cu),i(t,Or,l),i(t,nc,l),e(nc,Tu),i(t,zr,l),E(zi,t,l),i(t,Lr,l),i(t,ec,l),e(ec,Du),i(t,Fr,l),E(Li,t,l),i(t,Hr,l),Ui[Zn].m(t,l),i(t,sc,l),i(t,zt,l),e(zt,Au),e(zt,ph),e(ph,Pu),e(zt,Su),e(zt,uh),e(uh,Bu),e(zt,Nu),e(zt,mh),e(mh,Mu),e(zt,Ou),e(zt,gh),e(gh,zu),e(zt,Lu),i(t,Ir,l),Xi[ne].m(t,l),i(t,ac,l),i(t,ic,l),e(ic,Fu),i(t,Vr,l),Ji[se].m(t,l),i(t,lc,l),E(Fi,t,l),i(t,Qr,l),i(t,cc,l),e(cc,Hu),i(t,Gr,l),ht&&ht.m(t,l),i(t,hc,l),i(t,rc,l),e(rc,Iu),i(t,Rr,l),E(ka,t,l),i(t,Kr,l),rt&&rt.m(t,l),i(t,oc,l),i(t,vs,l),e(vs,ya),e(ya,dh),E(Hi,dh,null),e(vs,Vu),e(vs,fh),e(fh,Qu),i(t,Wr,l),i(t,xa,l),e(xa,Gu),e(xa,_h),e(_h,Ru),e(xa,Ku),i(t,Ur,l),E(Ii,t,l),i(t,Xr,l),E(Vi,t,l),i(t,Jr,l),i(t,pc,l),e(pc,Wu),Yr=!0},p(t,[l]){const Yi={};l&1&&(Yi.fw=t[0]),g.$set(Yi);let uc=P;P=em(t),P!==uc&&(ze(),_(Qi[uc],1,1,()=>{Qi[uc]=null}),Oe(),L=Qi[P],L||(L=Qi[P]=nm[P](t),L.c()),f(L,1),L.m(N.parentNode,N));const vh={};l&2&&(vh.$$scope={dirty:l,ctx:t}),ut.$set(vh);const bh={};l&2&&(bh.$$scope={dirty:l,ctx:t}),pa.$set(bh);let Be=Gn;Gn=am(t),Gn!==Be&&(ze(),_(Gi[Be],1,1,()=>{Gi[Be]=null}),Oe(),Rn=Gi[Gn],Rn||(Rn=Gi[Gn]=sm[Gn](t),Rn.c()),f(Rn,1),Rn.m(Fl.parentNode,Fl));let mc=Kn;Kn=lm(t),Kn!==mc&&(ze(),_(Ri[mc],1,1,()=>{Ri[mc]=null}),Oe(),Wn=Ri[Kn],Wn||(Wn=Ri[Kn]=im[Kn](t),Wn.c()),f(Wn,1),Wn.m(Hl.parentNode,Hl));let gc=Un;Un=hm(t),Un!==gc&&(ze(),_(Ki[gc],1,1,()=>{Ki[gc]=null}),Oe(),Xn=Ki[Un],Xn||(Xn=Ki[Un]=cm[Un](t),Xn.c()),f(Xn,1),Xn.m(Ql.parentNode,Ql)),Zr!==(Zr=rm(t))&&(bs.d(1),bs=Zr(t),bs&&(bs.c(),bs.m(Xl.parentNode,Xl)));let $a=Jn;Jn=pm(t),Jn!==$a&&(ze(),_(Wi[$a],1,1,()=>{Wi[$a]=null}),Oe(),Yn=Wi[Jn],Yn||(Yn=Wi[Jn]=om[Jn](t),Yn.c()),f(Yn,1),Yn.m(Zl.parentNode,Zl));let dc=Zn;Zn=mm(t),Zn!==dc&&(ze(),_(Ui[dc],1,1,()=>{Ui[dc]=null}),Oe(),te=Ui[Zn],te||(te=Ui[Zn]=um[Zn](t),te.c()),f(te,1),te.m(sc.parentNode,sc));let wa=ne;ne=dm(t),ne!==wa&&(ze(),_(Xi[wa],1,1,()=>{Xi[wa]=null}),Oe(),ee=Xi[ne],ee||(ee=Xi[ne]=gm[ne](t),ee.c()),f(ee,1),ee.m(ac.parentNode,ac));let fc=se;se=_m(t),se!==fc&&(ze(),_(Ji[fc],1,1,()=>{Ji[fc]=null}),Oe(),ae=Ji[se],ae||(ae=Ji[se]=fm[se](t),ae.c()),f(ae,1),ae.m(lc.parentNode,lc)),t[0]==="pt"?ht?l&1&&f(ht,1):(ht=Md(),ht.c(),f(ht,1),ht.m(hc.parentNode,hc)):ht&&(ze(),_(ht,1,1,()=>{ht=null}),Oe());const Zi={};l&2&&(Zi.$$scope={dirty:l,ctx:t}),ka.$set(Zi),t[0]==="pt"?rt?l&1&&f(rt,1):(rt=Od(),rt.c(),f(rt,1),rt.m(oc.parentNode,oc)):rt&&(ze(),_(rt,1,1,()=>{rt=null}),Oe())},i(t){Yr||(f(g.$$.fragment,t),f(x.$$.fragment,t),f(L),f(O.$$.fragment,t),f(ut.$$.fragment,t),f(At.$$.fragment,t),f(Vt.$$.fragment,t),f(vn.$$.fragment,t),f(bn.$$.fragment,t),f(kn.$$.fragment,t),f($n.$$.fragment,t),f(Qt.$$.fragment,t),f(hn.$$.fragment,t),f(En.$$.fragment,t),f(Kt.$$.fragment,t),f(Tn.$$.fragment,t),f(Dn.$$.fragment,t),f(Wt.$$.fragment,t),f(An.$$.fragment,t),f(Pn.$$.fragment,t),f(Nt.$$.fragment,t),f(Ln.$$.fragment,t),f(Xt.$$.fragment,t),f(Fn.$$.fragment,t),f(Hn.$$.fragment,t),f(pn.$$.fragment,t),f($e.$$.fragment,t),f(we.$$.fragment,t),f(qe.$$.fragment,t),f(Ee.$$.fragment,t),f(si.$$.fragment,t),f(ai.$$.fragment,t),f(ii.$$.fragment,t),f(li.$$.fragment,t),f(ci.$$.fragment,t),f(hi.$$.fragment,t),f(ri.$$.fragment,t),f(oi.$$.fragment,t),f(pi.$$.fragment,t),f(ui.$$.fragment,t),f(pa.$$.fragment,t),f(mi.$$.fragment,t),f(gi.$$.fragment,t),f(di.$$.fragment,t),f(fi.$$.fragment,t),f(_i.$$.fragment,t),f(vi.$$.fragment,t),f(bi.$$.fragment,t),f(Rn),f(ki.$$.fragment,t),f(Wn),f(xi.$$.fragment,t),f($i.$$.fragment,t),f(Xn),f(wi.$$.fragment,t),f(qi.$$.fragment,t),f(Ei.$$.fragment,t),f(Ci.$$.fragment,t),f(Ti.$$.fragment,t),f(Di.$$.fragment,t),f(Ai.$$.fragment,t),f(Pi.$$.fragment,t),f(Bi.$$.fragment,t),f(Ni.$$.fragment,t),f(Mi.$$.fragment,t),f(Oi.$$.fragment,t),f(Yn),f(zi.$$.fragment,t),f(Li.$$.fragment,t),f(te),f(ee),f(ae),f(Fi.$$.fragment,t),f(ht),f(ka.$$.fragment,t),f(rt),f(Hi.$$.fragment,t),f(Ii.$$.fragment,t),f(Vi.$$.fragment,t),Yr=!0)},o(t){_(g.$$.fragment,t),_(x.$$.fragment,t),_(L),_(O.$$.fragment,t),_(ut.$$.fragment,t),_(At.$$.fragment,t),_(Vt.$$.fragment,t),_(vn.$$.fragment,t),_(bn.$$.fragment,t),_(kn.$$.fragment,t),_($n.$$.fragment,t),_(Qt.$$.fragment,t),_(hn.$$.fragment,t),_(En.$$.fragment,t),_(Kt.$$.fragment,t),_(Tn.$$.fragment,t),_(Dn.$$.fragment,t),_(Wt.$$.fragment,t),_(An.$$.fragment,t),_(Pn.$$.fragment,t),_(Nt.$$.fragment,t),_(Ln.$$.fragment,t),_(Xt.$$.fragment,t),_(Fn.$$.fragment,t),_(Hn.$$.fragment,t),_(pn.$$.fragment,t),_($e.$$.fragment,t),_(we.$$.fragment,t),_(qe.$$.fragment,t),_(Ee.$$.fragment,t),_(si.$$.fragment,t),_(ai.$$.fragment,t),_(ii.$$.fragment,t),_(li.$$.fragment,t),_(ci.$$.fragment,t),_(hi.$$.fragment,t),_(ri.$$.fragment,t),_(oi.$$.fragment,t),_(pi.$$.fragment,t),_(ui.$$.fragment,t),_(pa.$$.fragment,t),_(mi.$$.fragment,t),_(gi.$$.fragment,t),_(di.$$.fragment,t),_(fi.$$.fragment,t),_(_i.$$.fragment,t),_(vi.$$.fragment,t),_(bi.$$.fragment,t),_(Rn),_(ki.$$.fragment,t),_(Wn),_(xi.$$.fragment,t),_($i.$$.fragment,t),_(Xn),_(wi.$$.fragment,t),_(qi.$$.fragment,t),_(Ei.$$.fragment,t),_(Ci.$$.fragment,t),_(Ti.$$.fragment,t),_(Di.$$.fragment,t),_(Ai.$$.fragment,t),_(Pi.$$.fragment,t),_(Bi.$$.fragment,t),_(Ni.$$.fragment,t),_(Mi.$$.fragment,t),_(Oi.$$.fragment,t),_(Yn),_(zi.$$.fragment,t),_(Li.$$.fragment,t),_(te),_(ee),_(ae),_(Fi.$$.fragment,t),_(ht),_(ka.$$.fragment,t),_(rt),_(Hi.$$.fragment,t),_(Ii.$$.fragment,t),_(Vi.$$.fragment,t),Yr=!1},d(t){n(o),t&&n(v),C(g,t),t&&n(y),t&&n(D),C(x),t&&n(w),Qi[P].d(t),t&&n(N),t&&n(T),t&&n(U),C(O,t),t&&n(K),t&&n(Y),t&&n(Tt),t&&n(at),t&&n(Ft),t&&n(Q),t&&n(fn),C(ut,t),t&&n(an),t&&n(et),C(At),t&&n(It),t&&n(Pt),t&&n(ws),t&&n($t),C(Vt),t&&n(js),t&&n(cn),t&&n(qs),C(vn,t),t&&n(Re),t&&n(St),t&&n(wt),C(bn,t),t&&n(le),C(kn,t),t&&n(Cs),t&&n(ot),t&&n(he),C($n,t),t&&n(Ds),C(Qt,t),t&&n(As),t&&n(st),t&&n(Bt),t&&n(gt),t&&n(Ms),C(hn,t),t&&n(qn),C(En,t),t&&n(ts),t&&n(dt),t&&n(Os),C(Kt,t),t&&n(zs),C(Tn,t),t&&n(Ls),t&&n(pt),t&&n(ue),C(Dn,t),t&&n(Fs),C(Wt,t),t&&n(Hs),t&&n(me),t&&n(Is),t&&n(Ut),C(An),t&&n(ge),C(Pn,t),t&&n(Vs),t&&n(Sn),t&&n(Qs),t&&n(Bn),t&&n(as),C(Nt,t),t&&n(Gs),t&&n(ft),t&&n(fe),C(Ln,t),t&&n(Rs),C(Xt,t),t&&n(Ks),t&&n(_e),t&&n(Ws),C(Fn,t),t&&n(ve),t&&n(be),t&&n(ke),C(Hn,t),t&&n(Us),C(pn,t),t&&n(qt),t&&n(ye),t&&n(Xs),t&&n(Jt),t&&n(m),t&&n(M),t&&n(hs),t&&n(rs),t&&n(Ya),t&&n(tt),t&&n(Za),C($e,t),t&&n(Qn),C(we,t),t&&n(ti),t&&n(Ct),t&&n(Yt),t&&n(Zt),t&&n(it),C(qe,t),t&&n(ni),C(Ee,t),t&&n(ei),t&&n(tn),t&&n(kh),C(si,t),t&&n(yh),C(ai,t),t&&n(xh),t&&n(ql),t&&n($h),C(ii,t),t&&n(wh),C(li,t),t&&n(jh),t&&n(El),t&&n(qh),t&&n(Cl),t&&n(Eh),t&&n(ca),t&&n(Ch),t&&n(De),t&&n(Th),t&&n(ha),t&&n(Dh),C(ci,t),t&&n(Ah),C(hi,t),t&&n(Ph),t&&n(ra),t&&n(Sh),C(ri,t),t&&n(Bh),C(oi,t),t&&n(Nh),t&&n(oa),t&&n(Mh),C(pi,t),t&&n(Oh),C(ui,t),t&&n(zh),t&&n(Dl),t&&n(Lh),t&&n(Al),t&&n(Fh),t&&n(Pl),t&&n(Hh),C(pa,t),t&&n(Ih),t&&n(Sl),t&&n(Vh),C(mi,t),t&&n(Qh),t&&n(Bl),t&&n(Gh),t&&n(Ae),t&&n(Rh),C(gi,t),t&&n(Kh),C(di,t),t&&n(Wh),t&&n(Nl),t&&n(Uh),t&&n(gs),C(fi),t&&n(Xh),t&&n(Ml),t&&n(Jh),t&&n(Pe),t&&n(Yh),C(_i,t),t&&n(Zh),t&&n(Ol),t&&n(tr),C(vi,t),t&&n(nr),C(bi,t),t&&n(er),t&&n(zl),t&&n(sr),t&&n(Ll),t&&n(ar),Gi[Gn].d(t),t&&n(Fl),t&&n(ds),C(ki),t&&n(ir),Ri[Kn].d(t),t&&n(Hl),t&&n(ga),t&&n(lr),t&&n(gn),t&&n(cr),t&&n(dn),t&&n(hr),t&&n(da),t&&n(rr),C(xi,t),t&&n(or),t&&n(Vl),t&&n(pr),C($i,t),t&&n(ur),t&&n(fa),t&&n(mr),Ki[Un].d(t),t&&n(Ql),t&&n(Ot),t&&n(gr),C(wi,t),t&&n(dr),t&&n(_a),t&&n(fr),t&&n(Se),t&&n(_r),t&&n(Gl),t&&n(vr),C(qi,t),t&&n(br),t&&n(Rl),t&&n(kr),C(Ei,t),t&&n(yr),t&&n(Kl),t&&n(xr),C(Ci,t),t&&n($r),t&&n(Wl),t&&n(wr),C(Ti,t),t&&n(jr),C(Di,t),t&&n(qr),t&&n(Ul),t&&n(Er),C(Ai,t),t&&n(Cr),C(Pi,t),t&&n(Tr),t&&n(va),t&&n(Dr),bs.d(t),t&&n(Xl),C(Bi,t),t&&n(Ar),t&&n(Jl),t&&n(Pr),C(Ni,t),t&&n(Sr),C(Mi,t),t&&n(Br),t&&n(Yl),t&&n(Nr),t&&n(_s),C(Oi),t&&n(Mr),Wi[Jn].d(t),t&&n(Zl),t&&n(tc),t&&n(Or),t&&n(nc),t&&n(zr),C(zi,t),t&&n(Lr),t&&n(ec),t&&n(Fr),C(Li,t),t&&n(Hr),Ui[Zn].d(t),t&&n(sc),t&&n(zt),t&&n(Ir),Xi[ne].d(t),t&&n(ac),t&&n(ic),t&&n(Vr),Ji[se].d(t),t&&n(lc),C(Fi,t),t&&n(Qr),t&&n(cc),t&&n(Gr),ht&&ht.d(t),t&&n(hc),t&&n(rc),t&&n(Rr),C(ka,t),t&&n(Kr),rt&&rt.d(t),t&&n(oc),t&&n(vs),C(Hi),t&&n(Wr),t&&n(xa),t&&n(Ur),C(Ii,t),t&&n(Xr),C(Vi,t),t&&n(Jr),t&&n(pc)}}}const df={local:"hi-p",sections:[{local:"chun-b-d-liu",sections:[{local:"b-d-liu-squad",title:"B\u1ED9 d\u1EEF li\u1EC7u SQuAD"},{local:"x-l-d-liu-hun-luyn",title:"X\u1EED l\xFD d\u1EEF li\u1EC7u hu\u1EA5n luy\u1EC7n"},{local:"x-l-d-liu-kim-nh",title:"X\u1EED l\xFD d\u1EEF li\u1EC7u ki\u1EC3m \u0111\u1ECBnh"}],title:"Chu\u1EA9n b\u1ECB d\u1EEF li\u1EC7u"},{local:"tinh-chnh-m-hn-vi-api-trainer",title:"Tinh ch\u1EC9nh m\xF4 h\xECn v\u1EDBi API `Trainer`"},{local:"tinh-chnh-m-hn-vi-keras",sections:[{local:"hu-x-l",title:"H\u1EADu x\u1EED l\xFD"},{local:"tinh-chnh-m-hnh",title:"Tinh ch\u1EC9nh m\xF4 h\xECnh"}],title:"Tinh ch\u1EC9nh m\xF4 h\xECn v\u1EDBi Keras"},{local:"mt-vng-lp-hun-luyn-tu-chnh",sections:[{local:"chun-b-mi-th-cho-hun-luyn",title:"Chu\u1EA5n b\u1ECB m\u1ECDi th\u1EE9 cho hu\u1EA5n luy\u1EC7n"}],title:"M\u1ED9t v\xF2ng l\u1EB7p hu\u1EA5n luy\u1EC7n tu\u1EF3 ch\u1EC9nh"},{local:"vng-lp-hun-luyn",title:"V\xF2ng l\u1EB7p hu\u1EA5n luy\u1EC7n"},{local:"s-dng-m-hnh-tinh-chnh",title:"S\u1EED d\u1EE5ng m\xF4 h\xECnh tinh ch\u1EC9nh"}],title:"H\u1ECFi \u0111\xE1p"};function ff(H,o,v){let g="pt";return Vd(()=>{const y=new URLSearchParams(window.location.search);v(0,g=y.get("fw")||"pt")}),[g]}class wf extends Ld{constructor(o){super();Fd(this,o,ff,gf,Hd,{})}}export{wf as default,df as metadata};
