import{S as Ou,i as qu,s as Du,e as h,w as E,k as o,t as s,c,a as r,x as w,d as e,m as p,h as a,b as y,g as i,G as n,y as x,q as _,o as b,B as C,M as Tu,N as mo,p as Th,v as Pu,n as Ph,L as ju}from"../../chunks/vendor-hf-doc-builder.js";import{T as zh}from"../../chunks/Tip-hf-doc-builder.js";import{Y as Eu}from"../../chunks/Youtube-hf-doc-builder.js";import{I as St}from"../../chunks/IconCopyLink-hf-doc-builder.js";import{C as P}from"../../chunks/CodeBlock-hf-doc-builder.js";import{D as Cu}from"../../chunks/DocNotebookDropdown-hf-doc-builder.js";import{F as zu}from"../../chunks/FrameworkSwitchCourse-hf-doc-builder.js";function Au(X){let m,v;return m=new Cu({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/section2_tf.ipynb"},{label:"Aws Studio",value:"https://studiolab.sagemaker.aws/import/github/huggingface/notebooks/blob/master/course/vi/chapter7/section2_tf.ipynb"}]}}),{c(){E(m.$$.fragment)},l(f){w(m.$$.fragment,f)},m(f,$){x(m,f,$),v=!0},i(f){v||(_(m.$$.fragment,f),v=!0)},o(f){b(m.$$.fragment,f),v=!1},d(f){C(m,f)}}}function Nu(X){let m,v;return m=new Cu({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/section2_pt.ipynb"},{label:"Aws Studio",value:"https://studiolab.sagemaker.aws/import/github/huggingface/notebooks/blob/master/course/vi/chapter7/section2_pt.ipynb"}]}}),{c(){E(m.$$.fragment)},l(f){w(m.$$.fragment,f)},m(f,$){x(m,f,$),v=!0},i(f){v||(_(m.$$.fragment,f),v=!0)},o(f){b(m.$$.fragment,f),v=!1},d(f){C(m,f)}}}function Bu(X){let m,v,f,$,O,k,j,q;return{c(){m=h("p"),v=s("\u{1F4A1} Mi\u1EC5n l\xE0 t\u1EADp d\u1EEF li\u1EC7u c\u1EE7a b\u1EA1n bao g\u1ED3m c\xE1c v\u0103n b\u1EA3n \u0111\u01B0\u1EE3c chia th\xE0nh c\xE1c t\u1EEB v\u1EDBi nh\xE3n t\u01B0\u01A1ng \u1EE9ng c\u1EE7a ch\xFAng, b\u1EA1n s\u1EBD c\xF3 th\u1EC3 \u0111i\u1EC1u ch\u1EC9nh c\xE1c quy tr\xECnh x\u1EED l\xFD d\u1EEF li\u1EC7u \u0111\u01B0\u1EE3c m\xF4 t\u1EA3 \u1EDF \u0111\xE2y v\u1EDBi t\u1EADp d\u1EEF li\u1EC7u c\u1EE7a ri\xEAng b\u1EA1n. Tham kh\u1EA3o l\u1EA1i "),f=h("a"),$=s("Chapter 5"),O=s(" n\u1EBFu b\u1EA1n c\u1EA7n c\u1EADp nh\u1EADt v\u1EC1 c\xE1ch t\u1EA3i d\u1EEF li\u1EC7u t\xF9y ch\u1EC9nh c\u1EE7a ri\xEAng b\u1EA1n trong "),k=h("code"),j=s("Dataset"),q=s("."),this.h()},l(D){m=c(D,"P",{});var z=r(m);v=a(z,"\u{1F4A1} Mi\u1EC5n l\xE0 t\u1EADp d\u1EEF li\u1EC7u c\u1EE7a b\u1EA1n bao g\u1ED3m c\xE1c v\u0103n b\u1EA3n \u0111\u01B0\u1EE3c chia th\xE0nh c\xE1c t\u1EEB v\u1EDBi nh\xE3n t\u01B0\u01A1ng \u1EE9ng c\u1EE7a ch\xFAng, b\u1EA1n s\u1EBD c\xF3 th\u1EC3 \u0111i\u1EC1u ch\u1EC9nh c\xE1c quy tr\xECnh x\u1EED l\xFD d\u1EEF li\u1EC7u \u0111\u01B0\u1EE3c m\xF4 t\u1EA3 \u1EDF \u0111\xE2y v\u1EDBi t\u1EADp d\u1EEF li\u1EC7u c\u1EE7a ri\xEAng b\u1EA1n. Tham kh\u1EA3o l\u1EA1i "),f=c(z,"A",{href:!0});var I=r(f);$=a(I,"Chapter 5"),I.forEach(e),O=a(z," n\u1EBFu b\u1EA1n c\u1EA7n c\u1EADp nh\u1EADt v\u1EC1 c\xE1ch t\u1EA3i d\u1EEF li\u1EC7u t\xF9y ch\u1EC9nh c\u1EE7a ri\xEAng b\u1EA1n trong "),k=c(z,"CODE",{});var A=r(k);j=a(A,"Dataset"),A.forEach(e),q=a(z,"."),z.forEach(e),this.h()},h(){y(f,"href","/course/chapter5")},m(D,z){i(D,m,z),n(m,v),n(m,f),n(f,$),n(m,O),n(m,k),n(k,j),n(m,q)},d(D){D&&e(m)}}}function Su(X){let m,v,f,$,O;return{c(){m=h("p"),v=s("\u270F\uFE0F "),f=h("strong"),$=s("\u0110\u1EBFn l\u01B0\u1EE3t b\u1EA1n!"),O=s(" In hai c\xE2u gi\u1ED1ng nhau b\u1EB1ng nh\xE3n POS ho\u1EB7c ph\xE2n kh\xFAc c\u1EE7a ch\xFAng.")},l(k){m=c(k,"P",{});var j=r(m);v=a(j,"\u270F\uFE0F "),f=c(j,"STRONG",{});var q=r(f);$=a(q,"\u0110\u1EBFn l\u01B0\u1EE3t b\u1EA1n!"),q.forEach(e),O=a(j," In hai c\xE2u gi\u1ED1ng nhau b\u1EB1ng nh\xE3n POS ho\u1EB7c ph\xE2n kh\xFAc c\u1EE7a ch\xFAng."),j.forEach(e)},m(k,j){i(k,m,j),n(m,v),n(m,f),n(f,$),n(m,O)},d(k){k&&e(m)}}}function Iu(X){let m,v,f,$,O,k,j,q;return{c(){m=h("p"),v=s("\u270F\uFE0F "),f=h("strong"),$=s("\u0110\u1EBFn l\u01B0\u1EE3t b\u1EA1n!"),O=s(" M\u1ED9t s\u1ED1 nh\xE0 nghi\xEAn c\u1EE9u ch\u1EC9 th\xEDch g\xE1n m\u1ED9t nh\xE3n cho m\u1ED7i t\u1EEB v\xE0 g\xE1n "),k=h("code"),j=s("-100"),q=s(" cho c\xE1c token con kh\xE1c trong m\u1ED9t t\u1EEB nh\u1EA5t \u0111\u1ECBnh. \u0110i\u1EC1u n\xE0y l\xE0 \u0111\u1EC3 tr\xE1nh c\xE1c t\u1EEB d\xE0i \u0111\u01B0\u1EE3c chia th\xE0nh nhi\u1EC1u token ph\u1EE5 g\xF3p ph\u1EA7n l\u1EDBn v\xE0o h\xE0m m\u1EA5t m\xE1t. Thay \u0111\u1ED5i ch\u1EE9c n\u0103ng tr\u01B0\u1EDBc \u0111\xF3 \u0111\u1EC3 c\u0103n ch\u1EC9nh nh\xE3n v\u1EDBi ID \u0111\u1EA7u v\xE0o b\u1EB1ng c\xE1ch tu\xE2n theo quy t\u1EAFc n\xE0y.")},l(D){m=c(D,"P",{});var z=r(m);v=a(z,"\u270F\uFE0F "),f=c(z,"STRONG",{});var I=r(f);$=a(I,"\u0110\u1EBFn l\u01B0\u1EE3t b\u1EA1n!"),I.forEach(e),O=a(z," M\u1ED9t s\u1ED1 nh\xE0 nghi\xEAn c\u1EE9u ch\u1EC9 th\xEDch g\xE1n m\u1ED9t nh\xE3n cho m\u1ED7i t\u1EEB v\xE0 g\xE1n "),k=c(z,"CODE",{});var A=r(k);j=a(A,"-100"),A.forEach(e),q=a(z," cho c\xE1c token con kh\xE1c trong m\u1ED9t t\u1EEB nh\u1EA5t \u0111\u1ECBnh. \u0110i\u1EC1u n\xE0y l\xE0 \u0111\u1EC3 tr\xE1nh c\xE1c t\u1EEB d\xE0i \u0111\u01B0\u1EE3c chia th\xE0nh nhi\u1EC1u token ph\u1EE5 g\xF3p ph\u1EA7n l\u1EDBn v\xE0o h\xE0m m\u1EA5t m\xE1t. Thay \u0111\u1ED5i ch\u1EE9c n\u0103ng tr\u01B0\u1EDBc \u0111\xF3 \u0111\u1EC3 c\u0103n ch\u1EC9nh nh\xE3n v\u1EDBi ID \u0111\u1EA7u v\xE0o b\u1EB1ng c\xE1ch tu\xE2n theo quy t\u1EAFc n\xE0y."),z.forEach(e)},m(D,z){i(D,m,z),n(m,v),n(m,f),n(f,$),n(m,O),n(m,k),n(k,j),n(m,q)},d(D){D&&e(m)}}}function Mu(X){let m,v,f,$,O,k,j,q,D,z,I;return $=new St({}),{c(){m=h("h2"),v=h("a"),f=h("span"),E($.$$.fragment),O=o(),k=h("span"),j=s("Tinh ch\u1EC9nh m\xF4 h\xECnh v\u1EDBi Keras"),q=o(),D=h("p"),z=s("M\xE3 th\u1EF1c s\u1EED d\u1EE5ng Keras s\u1EBD gi\u1ED1ng nh\u01B0 tr\u01B0\u1EDBc \u0111\xE2y; nh\u1EEFng thay \u0111\u1ED5i duy nh\u1EA5t l\xE0 c\xE1ch d\u1EEF li\u1EC7u \u0111\u01B0\u1EE3c \u0111\u1ED1i chi\u1EBFu th\xE0nh m\u1ED9t l\xF4 v\xE0 ch\u1EE9c n\u0103ng t\xEDnh to\xE1n s\u1ED1 li\u1EC7u."),this.h()},l(A){m=c(A,"H2",{class:!0});var N=r(m);v=c(N,"A",{id:!0,class:!0,href:!0});var V=r(v);f=c(V,"SPAN",{});var B=r(f);w($.$$.fragment,B),B.forEach(e),V.forEach(e),O=p(N),k=c(N,"SPAN",{});var R=r(k);j=a(R,"Tinh ch\u1EC9nh m\xF4 h\xECnh v\u1EDBi Keras"),R.forEach(e),N.forEach(e),q=p(A),D=c(A,"P",{});var F=r(D);z=a(F,"M\xE3 th\u1EF1c s\u1EED d\u1EE5ng Keras s\u1EBD gi\u1ED1ng nh\u01B0 tr\u01B0\u1EDBc \u0111\xE2y; nh\u1EEFng thay \u0111\u1ED5i duy nh\u1EA5t l\xE0 c\xE1ch d\u1EEF li\u1EC7u \u0111\u01B0\u1EE3c \u0111\u1ED1i chi\u1EBFu th\xE0nh m\u1ED9t l\xF4 v\xE0 ch\u1EE9c n\u0103ng t\xEDnh to\xE1n s\u1ED1 li\u1EC7u."),F.forEach(e),this.h()},h(){y(v,"id","tinh-chnh-m-hnh-vi-keras"),y(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"),y(v,"href","#tinh-chnh-m-hnh-vi-keras"),y(m,"class","relative group")},m(A,N){i(A,m,N),n(m,v),n(v,f),x($,f,null),n(m,O),n(m,k),n(k,j),i(A,q,N),i(A,D,N),n(D,z),I=!0},i(A){I||(_($.$$.fragment,A),I=!0)},o(A){b($.$$.fragment,A),I=!1},d(A){A&&e(m),C($),A&&e(q),A&&e(D)}}}function Lu(X){let m,v,f,$,O,k,j,q,D,z,I,A,N,V,B,R;return $=new St({}),{c(){m=h("h2"),v=h("a"),f=h("span"),E($.$$.fragment),O=o(),k=h("span"),j=s("Tinh ch\u1EC9nh m\xF4 h\xECnh trong API "),q=h("code"),D=s("Trainer"),z=o(),I=h("p"),A=s("M\xE3 th\u1EF1c s\u1EED d\u1EE5ng "),N=h("code"),V=s("Trainer"),B=s(" s\u1EBD gi\u1ED1ng nh\u01B0 tr\u01B0\u1EDBc \u0111\xE2y; nh\u1EEFng thay \u0111\u1ED5i duy nh\u1EA5t l\xE0 c\xE1ch d\u1EEF li\u1EC7u \u0111\u01B0\u1EE3c \u0111\u1ED1i chi\u1EBFu th\xE0nh m\u1ED9t l\xF4 v\xE0 ch\u1EE9c n\u0103ng t\xEDnh to\xE1n s\u1ED1 li\u1EC7u."),this.h()},l(F){m=c(F,"H2",{class:!0});var M=r(m);v=c(M,"A",{id:!0,class:!0,href:!0});var W=r(v);f=c(W,"SPAN",{});var T=r(f);w($.$$.fragment,T),T.forEach(e),W.forEach(e),O=p(M),k=c(M,"SPAN",{});var U=r(k);j=a(U,"Tinh ch\u1EC9nh m\xF4 h\xECnh trong API "),q=c(U,"CODE",{});var L=r(q);D=a(L,"Trainer"),L.forEach(e),U.forEach(e),M.forEach(e),z=p(F),I=c(F,"P",{});var K=r(I);A=a(K,"M\xE3 th\u1EF1c s\u1EED d\u1EE5ng "),N=c(K,"CODE",{});var nn=r(N);V=a(nn,"Trainer"),nn.forEach(e),B=a(K," s\u1EBD gi\u1ED1ng nh\u01B0 tr\u01B0\u1EDBc \u0111\xE2y; nh\u1EEFng thay \u0111\u1ED5i duy nh\u1EA5t l\xE0 c\xE1ch d\u1EEF li\u1EC7u \u0111\u01B0\u1EE3c \u0111\u1ED1i chi\u1EBFu th\xE0nh m\u1ED9t l\xF4 v\xE0 ch\u1EE9c n\u0103ng t\xEDnh to\xE1n s\u1ED1 li\u1EC7u."),K.forEach(e),this.h()},h(){y(v,"id","tinh-chnh-m-hnh-trong-api-trainer"),y(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"),y(v,"href","#tinh-chnh-m-hnh-trong-api-trainer"),y(m,"class","relative group")},m(F,M){i(F,m,M),n(m,v),n(v,f),x($,f,null),n(m,O),n(m,k),n(k,j),n(k,q),n(q,D),i(F,z,M),i(F,I,M),n(I,A),n(I,N),n(N,V),n(I,B),R=!0},i(F){R||(_($.$$.fragment,F),R=!0)},o(F){b($.$$.fragment,F),R=!1},d(F){F&&e(m),C($),F&&e(z),F&&e(I)}}}function Hu(X){let m,v;return m=new P({props:{code:`from transformers import DataCollatorForTokenClassification

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

data_collator = DataCollatorForTokenClassification(
    tokenizer=tokenizer, return_tensors=<span class="hljs-string">&quot;tf&quot;</span>
)`}}),{c(){E(m.$$.fragment)},l(f){w(m.$$.fragment,f)},m(f,$){x(m,f,$),v=!0},i(f){v||(_(m.$$.fragment,f),v=!0)},o(f){b(m.$$.fragment,f),v=!1},d(f){C(m,f)}}}function Ru(X){let m,v;return m=new P({props:{code:`from transformers import DataCollatorForTokenClassification

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

data_collator = DataCollatorForTokenClassification(tokenizer=tokenizer)`}}),{c(){E(m.$$.fragment)},l(f){w(m.$$.fragment,f)},m(f,$){x(m,f,$),v=!0},i(f){v||(_(m.$$.fragment,f),v=!0)},o(f){b(m.$$.fragment,f),v=!1},d(f){C(m,f)}}}function Fu(X){let m,v,f,$,O,k,j,q,D,z,I,A,N,V;return z=new P({props:{code:`tf_train_dataset = tokenized_datasets["train"].to_tf_dataset(
    columns=["attention_mask", "input_ids", "labels", "token_type_ids"],
    collate_fn=data_collator,
    shuffle=True,
    batch_size=16,
)

tf_eval_dataset = tokenized_datasets["validation"].to_tf_dataset(
    columns=["attention_mask", "input_ids", "labels", "token_type_ids"],
    collate_fn=data_collator,
    shuffle=False,
    batch_size=16,
)`,highlighted:`tf_train_dataset = tokenized_datasets[<span class="hljs-string">&quot;train&quot;</span>].to_tf_dataset(
    columns=[<span class="hljs-string">&quot;attention_mask&quot;</span>, <span class="hljs-string">&quot;input_ids&quot;</span>, <span class="hljs-string">&quot;labels&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 = tokenized_datasets[<span class="hljs-string">&quot;validation&quot;</span>].to_tf_dataset(
    columns=[<span class="hljs-string">&quot;attention_mask&quot;</span>, <span class="hljs-string">&quot;input_ids&quot;</span>, <span class="hljs-string">&quot;labels&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>,
)`}}),{c(){m=h("p"),v=s("Tr\xECnh \u0111\u1ED1i chi\u1EBFu d\u1EEF li\u1EC7u c\u1EE7a ch\xFAng ta \u0111\xE3 s\u1EB5n s\xE0ng ho\u1EA1t \u0111\u1ED9ng! B\xE2y gi\u1EDD h\xE3y s\u1EED d\u1EE5ng n\xF3 \u0111\u1EC3 t\u1EA1o m\u1ED9t "),f=h("code"),$=s("tf.data.Dataset"),O=s(" v\u1EDBi ph\u01B0\u01A1ng th\u1EE9c "),k=h("code"),j=s("to_tf_dataset()"),q=s("."),D=o(),E(z.$$.fragment),I=o(),A=h("p"),N=s("\u0110i\u1EC3m d\u1EEBng ti\u1EBFp theo: ch\xEDnh l\xE0 m\xF4 h\xECnh.")},l(B){m=c(B,"P",{});var R=r(m);v=a(R,"Tr\xECnh \u0111\u1ED1i chi\u1EBFu d\u1EEF li\u1EC7u c\u1EE7a ch\xFAng ta \u0111\xE3 s\u1EB5n s\xE0ng ho\u1EA1t \u0111\u1ED9ng! B\xE2y gi\u1EDD h\xE3y s\u1EED d\u1EE5ng n\xF3 \u0111\u1EC3 t\u1EA1o m\u1ED9t "),f=c(R,"CODE",{});var F=r(f);$=a(F,"tf.data.Dataset"),F.forEach(e),O=a(R," v\u1EDBi ph\u01B0\u01A1ng th\u1EE9c "),k=c(R,"CODE",{});var M=r(k);j=a(M,"to_tf_dataset()"),M.forEach(e),q=a(R,"."),R.forEach(e),D=p(B),w(z.$$.fragment,B),I=p(B),A=c(B,"P",{});var W=r(A);N=a(W,"\u0110i\u1EC3m d\u1EEBng ti\u1EBFp theo: ch\xEDnh l\xE0 m\xF4 h\xECnh."),W.forEach(e)},m(B,R){i(B,m,R),n(m,v),n(m,f),n(f,$),n(m,O),n(m,k),n(k,j),n(m,q),i(B,D,R),x(z,B,R),i(B,I,R),i(B,A,R),n(A,N),V=!0},i(B){V||(_(z.$$.fragment,B),V=!0)},o(B){b(z.$$.fragment,B),V=!1},d(B){B&&e(m),B&&e(D),C(z,B),B&&e(I),B&&e(A)}}}function Gu(X){let m,v,f,$,O;return{c(){m=h("p"),v=s("Nh\u01B0 ch\xFAng ta c\xF3 th\u1EC3 th\u1EA5y, t\u1EADp h\u1EE3p nh\xE3n th\u1EE9 hai \u0111\xE3 \u0111\u01B0\u1EE3c \u0111\u1EC7m b\u1EB1ng \u0111\u1ED9 d\xE0i c\u1EE7a t\u1EADp \u0111\u1EA7u ti\xEAn b\u1EB1ng c\xE1ch s\u1EED d\u1EE5ng "),f=h("code"),$=s("-100"),O=s(".")},l(k){m=c(k,"P",{});var j=r(m);v=a(j,"Nh\u01B0 ch\xFAng ta c\xF3 th\u1EC3 th\u1EA5y, t\u1EADp h\u1EE3p nh\xE3n th\u1EE9 hai \u0111\xE3 \u0111\u01B0\u1EE3c \u0111\u1EC7m b\u1EB1ng \u0111\u1ED9 d\xE0i c\u1EE7a t\u1EADp \u0111\u1EA7u ti\xEAn b\u1EB1ng c\xE1ch s\u1EED d\u1EE5ng "),f=c(j,"CODE",{});var q=r(f);$=a(q,"-100"),q.forEach(e),O=a(j,"."),j.forEach(e)},m(k,j){i(k,m,j),n(m,v),n(m,f),n(f,$),n(m,O)},i:ju,o:ju,d(k){k&&e(m)}}}function wu(X){let m,v,f,$,O,k,j,q,D,z,I,A,N,V,B,R,F,M,W,T,U,L,K,nn,an,ln,Z,un,Q,G,H,en,mn,kn,sn,Bn,Y,at,on,ft,le,lt,Qe,It,he,bn,De,En,gn,Vn,ce,tn,pn,re,Sn,Mt,ie,Je,Un,In,Lt,oe,Ht,Te,yn,wn,Rt,$n,bs,Ft,Xn,Pe,cn,Gt,Wn,dt,vs,_t,bt,ns,xn,Cn,pe,J,Vt,vt,Kn,ts,On,ks,ze,ht,Ae,es,kt,Mn,yt,Ne,$t,ys,ss,Zn,jt,fn,Et,Yn,ct,wt,rt,Ut,$s,as,it,Xt,Be,qn,ls,xt,Qn,Jn,ue,Wt,Kt,me,vn,Se,Dn;return $=new St({}),Z=new P({props:{code:`id2label = {i: label for i, label in enumerate(label_names)}
label2id = {v: k for k, v in id2label.items()}`,highlighted:`id2label = {i: label <span class="hljs-keyword">for</span> i, label <span class="hljs-keyword">in</span> <span class="hljs-built_in">enumerate</span>(label_names)}
label2id = {v: k <span class="hljs-keyword">for</span> k, v <span class="hljs-keyword">in</span> id2label.items()}`}}),sn=new P({props:{code:`from transformers import TFAutoModelForTokenClassification

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

model = TFAutoModelForTokenClassification.from_pretrained(
    model_checkpoint,
    id2label=id2label,
    label2id=label2id,
)`}}),bn=new P({props:{code:"model.config.num_labels",highlighted:"model.config.num_labels"}}),En=new P({props:{code:"9",highlighted:'<span class="hljs-number">9</span>'}}),Vn=new zh({props:{warning:!0,$$slots:{default:[Vu]},$$scope:{ctx:X}}}),Sn=new St({}),Ht=new P({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()`}}),Xn=new P({props:{code:"huggingface-cli login",highlighted:"huggingface-cli login"}}),Vt=new P({props:{code:`from transformers import create_optimizer
import tensorflow as tf

# Hu\u1EA5n luy\u1EC7n trong mixed-precision float16
# B\xECnh lu\u1EADn d\xF2ng n\xE0y n\u1EBFu b\u1EA1n \u0111ang s\u1EED d\u1EE5ng GPU n\xEAn kh\xF4ng \u0111\u01B0\u1EE3c h\u01B0\u1EDFng l\u1EE3i t\u1EEB \u0111i\u1EC1u n\xE0y
tf.keras.mixed_precision.set_global_policy("mixed_float16")

# 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 s\u1ED1 epoch. L\u01B0u \xFD r\u1EB1ng tf_train_dataset \u1EDF \u0111\xE2y l\xE0 l\xF4 tf.data.Dataset,
# kh\xF4ng ph\u1EA3i Hugging Face Dataset g\u1ED1c, n\xEAn len() c\u1EE7a n\xF3 v\u1ED1n l\xE0 num_samples // batch_size.
num_epochs = 3
num_train_steps = len(tf_train_dataset) * num_epochs

optimizer, schedule = create_optimizer(
    init_lr=2e-5,
    num_warmup_steps=0,
    num_train_steps=num_train_steps,
    weight_decay_rate=0.01,
)
model.compile(optimizer=optimizer)`,highlighted:`<span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> create_optimizer
<span class="hljs-keyword">import</span> tensorflow <span class="hljs-keyword">as</span> tf

<span class="hljs-comment"># Hu\u1EA5n luy\u1EC7n trong mixed-precision float16</span>
<span class="hljs-comment"># B\xECnh lu\u1EADn d\xF2ng n\xE0y n\u1EBFu b\u1EA1n \u0111ang s\u1EED d\u1EE5ng GPU n\xEAn kh\xF4ng \u0111\u01B0\u1EE3c h\u01B0\u1EDFng l\u1EE3i t\u1EEB \u0111i\u1EC1u n\xE0y</span>
tf.keras.mixed_precision.set_global_policy(<span class="hljs-string">&quot;mixed_float16&quot;</span>)

<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 s\u1ED1 epoch. L\u01B0u \xFD r\u1EB1ng tf_train_dataset \u1EDF \u0111\xE2y l\xE0 l\xF4 tf.data.Dataset,</span>
<span class="hljs-comment"># kh\xF4ng ph\u1EA3i Hugging Face Dataset g\u1ED1c, n\xEAn len() c\u1EE7a n\xF3 v\u1ED1n l\xE0 num_samples // batch_size.</span>
num_epochs = <span class="hljs-number">3</span>
num_train_steps = <span class="hljs-built_in">len</span>(tf_train_dataset) * num_epochs

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

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

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

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

model.fit(
    tf_train_dataset,
    validation_data=tf_eval_dataset,
    callbacks=[callback],
    epochs=num_epochs,
)`}}),Jn=new zh({props:{$$slots:{default:[Uu]},$$scope:{ctx:X}}}),{c(){m=h("h3"),v=h("a"),f=h("span"),E($.$$.fragment),O=o(),k=h("span"),j=s("\u0110\u1ECBnh ngh\u0129a m\xF4 h\xECnh"),q=o(),D=h("p"),z=s("V\xEC ch\xFAng t\xF4i \u0111ang gi\u1EA3i quy\u1EBFt v\u1EA5n \u0111\u1EC1 ph\xE2n lo\u1EA1i token, ch\xFAng ta s\u1EBD s\u1EED d\u1EE5ng l\u1EDBp "),I=h("code"),A=s("TFAutoModelForTokenClassification"),N=s(". \u0110i\u1EC1u ch\xEDnh c\u1EA7n nh\u1EDB khi x\xE1c \u0111\u1ECBnh m\xF4 h\xECnh n\xE0y l\xE0 truy\u1EC1n m\u1ED9t s\u1ED1 th\xF4ng tin v\u1EC1 s\u1ED1 l\u01B0\u1EE3ng nh\xE3n m\xE0 ch\xFAng ta c\xF3. C\xE1ch d\u1EC5 nh\u1EA5t \u0111\u1EC3 l\xE0m \u0111i\u1EC1u n\xE0y l\xE0 truy\u1EC1n v\xE0o tham s\u1ED1 "),V=h("code"),B=s("num_labels"),R=s(", nh\u01B0ng n\u1EBFu ch\xFAng ta mu\u1ED1n m\u1ED9t ti\u1EC7n \xEDch lu\u1EADn suy \u0111\u1EB9p ho\u1EA1t \u0111\u1ED9ng gi\u1ED1ng nh\u01B0 ti\u1EC7n \xEDch ch\xFAng ta \u0111\xE3 th\u1EA5y \u1EDF \u0111\u1EA7u ph\u1EA7n n\xE0y, t\u1ED1t h\u01A1n n\xEAn \u0111\u1EB7t c\xE1c nh\xE3n t\u01B0\u01A1ng \u1EE9ng ch\xEDnh x\xE1c thay th\u1EBF."),F=o(),M=h("p"),W=s("Ch\xFAng ph\u1EA3i \u0111\u01B0\u1EE3c \u0111\u1EB7t b\u1EDFi hai t\u1EEB \u0111i\u1EC3n, "),T=h("code"),U=s("id2label"),L=s(" v\xE0 "),K=h("code"),nn=s("label2id"),an=s(", ch\u1EE9a \xE1nh x\u1EA1 t\u1EEB ID \u0111\u1EBFn nh\xE3n v\xE0 ng\u01B0\u1EE3c l\u1EA1i:"),ln=o(),E(Z.$$.fragment),un=o(),Q=h("p"),G=s("B\xE2y gi\u1EDD ch\xFAng ta c\xF3 th\u1EC3 chuy\u1EC3n ch\xFAng \u0111\u1EBFn ph\u01B0\u01A1ng th\u1EE9c "),H=h("code"),en=s("TFAutoModelForTokenClassification.from_pretrained()"),mn=s(" v\xE0 ch\xFAng s\u1EBD \u0111\u01B0\u1EE3c \u0111\u1EB7t trong c\u1EA5u h\xECnh c\u1EE7a m\xF4 h\xECnh, sau \u0111\xF3 \u0111\u01B0\u1EE3c l\u01B0u v\xE0 t\u1EA3i l\xEAn Hub m\u1ED9t c\xE1ch ch\xEDnh x\xE1c:"),kn=o(),E(sn.$$.fragment),Bn=o(),Y=h("p"),at=s("Gi\u1ED1ng nh\u01B0 khi ch\xFAng t\xF4i \u0111\u1ECBnh ngh\u0129a "),on=h("code"),ft=s("TFAutoModelForSequenceClassification"),le=s(" c\u1EE7a m\xECnh trong "),lt=h("a"),Qe=s("Ch\u01B0\u01A1ng 3"),It=s(", vi\u1EC7c t\u1EA1o m\xF4 h\xECnh \u0111\u01B0a ra c\u1EA3nh b\xE1o r\u1EB1ng m\u1ED9t s\u1ED1 tr\u1ECDng s\u1ED1 kh\xF4ng \u0111\u01B0\u1EE3c s\u1EED d\u1EE5ng (nh\u1EEFng tr\u1ECDng s\u1ED1 t\u1EEB \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 (nh\u1EEFng tr\u1ECDng s\u1ED1 t\u1EEB \u0111\u1EA7u ph\xE2n lo\u1EA1i token m\u1EDBi) v\xE0 m\xF4 h\xECnh n\xE0y n\xEAn \u0111\u01B0\u1EE3c hu\u1EA5n luy\u1EC7n. Ch\xFAng ta s\u1EBD l\xE0m \u0111i\u1EC1u \u0111\xF3 sau m\u1ED9t ph\xFAt, nh\u01B0ng tr\u01B0\u1EDBc ti\xEAn h\xE3y ki\u1EC3m tra k\u1EF9 xem m\xF4 h\xECnh c\u1EE7a ch\xFAng ta c\xF3 \u0111\xFAng s\u1ED1 l\u01B0\u1EE3ng nh\xE3n hay kh\xF4ng:"),he=o(),E(bn.$$.fragment),De=o(),E(En.$$.fragment),gn=o(),E(Vn.$$.fragment),ce=o(),tn=h("h3"),pn=h("a"),re=h("span"),E(Sn.$$.fragment),Mt=o(),ie=h("span"),Je=s("Tinh ch\u1EC9nh m\u1ED9t m\xF4 h\xECnh"),Un=o(),In=h("p"),Lt=s("B\xE2y gi\u1EDD ch\xFAng t\xF4i \u0111\xE3 s\u1EB5n s\xE0ng \u0111\u1EC3 hu\u1EA5n luy\u1EC7n m\xF4 h\xECnh c\u1EE7a m\xECnh! Tuy nhi\xEAn, ch\xFAng ta ch\u1EC9 c\u1EA7n l\xE0m th\xEAm m\u1ED9t ch\xFAt c\xF4ng vi\u1EC7c tr\u01B0\u1EDBc ti\xEAn: ch\xFAng ta n\xEAn \u0111\u0103ng nh\u1EADp v\xE0o Hugging Face v\xE0 x\xE1c \u0111\u1ECBnh c\xE1c si\xEAu tham s\u1ED1 hu\u1EA5n luy\u1EC7n c\u1EE7a m\xECnh. N\u1EBFu b\u1EA1n \u0111ang l\xE0m vi\u1EC7c tr\xEAn notebook, c\xF3 m\u1ED9t ch\u1EE9c n\u0103ng ti\u1EC7n l\u1EE3i \u0111\u1EC3 gi\xFAp b\u1EA1n l\xE0m \u0111i\u1EC1u n\xE0y:"),oe=o(),E(Ht.$$.fragment),Te=o(),yn=h("p"),wn=s("Thao t\xE1c n\xE0y s\u1EBD hi\u1EC3n th\u1ECB m\u1ED9t ti\u1EC7n \xEDch m\xE0 b\u1EA1n c\xF3 th\u1EC3 nh\u1EADp th\xF4ng tin \u0111\u0103ng nh\u1EADp  Hugging Face c\u1EE7a m\xECnh."),Rt=o(),$n=h("p"),bs=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:"),Ft=o(),E(Xn.$$.fragment),Pe=o(),cn=h("p"),Gt=s("Sau khi \u0111\u0103ng nh\u1EADp, ch\xFAng ta c\xF3 th\u1EC3 chu\u1EA9n b\u1ECB m\u1ECDi th\u1EE9 c\u1EA7n thi\u1EBFt \u0111\u1EC3 bi\xEAn d\u1ECBch m\xF4 h\xECnh c\u1EE7a m\xECnh. \u{1F917} Transformers cung c\u1EA5p m\u1ED9t h\xE0m "),Wn=h("code"),dt=s("create_optimizer()"),vs=s(" thu\u1EADn ti\u1EC7n s\u1EBD cung c\u1EA5p cho b\u1EA1n tr\xECnh t\u1ED1i \u01B0u h\xF3a "),_t=h("code"),bt=s("AdamW"),ns=s(" v\u1EDBi c\xE1c c\xE0i \u0111\u1EB7t th\xEDch h\u1EE3p cho gi\u1EA3m tr\u1ECDng l\u01B0\u1EE3ng v\xE0 gi\u1EA3m t\u1ED1c \u0111\u1ED9 h\u1ECDc t\u1EADp, c\u1EA3 hai \u0111\u1EC1u s\u1EBD c\u1EA3i thi\u1EC7n hi\u1EC7u su\u1EA5t m\xF4 h\xECnh c\u1EE7a b\u1EA1n so v\u1EDBi tr\xECnh t\u1ED1i \u01B0u h\xF3a "),xn=h("code"),Cn=s("Adam"),pe=s(" t\xEDch h\u1EE3p s\u1EB5n:"),J=o(),E(Vt.$$.fragment),vt=o(),Kn=h("p"),ts=s("C\u0169ng l\u01B0u \xFD r\u1EB1ng ch\xFAng ta kh\xF4ng cung c\u1EA5p tham s\u1ED1 "),On=h("code"),ks=s("loss"),ze=s(" cho "),ht=h("code"),Ae=s("compile()"),es=s(". \u0110i\u1EC1u n\xE0y l\xE0 do c\xE1c m\xF4 h\xECnh th\u1EF1c s\u1EF1 c\xF3 th\u1EC3 t\xEDnh to\xE1n m\u1EA5t m\xE1t b\xEAn trong - n\u1EBFu b\u1EA1n bi\xEAn d\u1ECBch m\xE0 kh\xF4ng m\u1EA5t m\xE1t v\xE0 cung c\u1EA5p c\xE1c nh\xE3n c\u1EE7a b\u1EA1n trong t\u1EEB \u0111i\u1EC3n \u0111\u1EA7u v\xE0o (nh\u01B0 ch\xFAng ta l\xE0m trong b\u1ED9 d\u1EEF li\u1EC7u c\u1EE7a m\xECnh), th\xEC m\xF4 h\xECnh s\u1EBD hu\u1EA5n luy\u1EC7n b\u1EB1ng c\xE1ch s\u1EED d\u1EE5ng m\u1EA5t m\xE1t n\u1ED9i b\u1ED9 \u0111\xF3, \u0111i\u1EC1u n\xE0y s\u1EBD th\xEDch h\u1EE3p cho t\xE1c v\u1EE5 v\xE0 lo\u1EA1i m\xF4 h\xECnh b\u1EA1n \u0111\xE3 ch\u1ECDn."),kt=o(),Mn=h("p"),yt=s("Ti\u1EBFp theo, ch\xFAng ta x\xE1c \u0111\u1ECBnh m\u1ED9t "),Ne=h("code"),$t=s("PushToHubCallback"),ys=s(" \u0111\u1EC3 t\u1EA3i m\xF4 h\xECnh l\xEAn Hub trong qu\xE1 tr\xECnh hu\u1EA5n luy\u1EC7n v\xE0 ph\xF9 h\u1EE3p v\u1EDBi m\xF4 h\xECnh v\u1EDBi l\u1EC7nh g\u1ECDi l\u1EA1i \u0111\xF3:"),ss=o(),E(Zn.$$.fragment),jt=o(),fn=h("p"),Et=s("B\u1EA1n c\xF3 th\u1EC3 ch\u1EC9 \u0111\u1ECBnh t\xEAn \u0111\u1EA7y \u0111\u1EE7 c\u1EE7a kho l\u01B0u tr\u1EEF m\xE0 b\u1EA1n mu\u1ED1n \u0111\u1EA9y \u0111\u1EBFn b\u1EB1ng tham s\u1ED1 "),Yn=h("code"),ct=s("hub_model_id"),wt=s(" (\u0111\u1EB7c bi\u1EC7t, b\u1EA1n s\u1EBD ph\u1EA3i s\u1EED d\u1EE5ng tham s\u1ED1 n\xE0y \u0111\u1EC3 \u0111\u1EA9y \u0111\u1EBFn m\u1ED9t t\u1ED5 ch\u1EE9c). V\xED d\u1EE5: khi ch\xFAng ta \u0111\u1EA9y m\xF4 h\xECnh v\xE0o t\u1ED5 ch\u1EE9c "),rt=h("a"),Ut=h("code"),$s=s("huggingface-course"),as=s(", ch\xFAng ta \u0111\xE3 th\xEAm "),it=h("code"),Xt=s('hub_model_id="huggingface-course/bert-finetuned-ner"'),Be=s(". Theo m\u1EB7c \u0111\u1ECBnh, kho l\u01B0u tr\u1EEF \u0111\u01B0\u1EE3c s\u1EED d\u1EE5ng s\u1EBD n\u1EB1m trong kh\xF4ng gian t\xEAn c\u1EE7a b\u1EA1n v\xE0 \u0111\u01B0\u1EE3c \u0111\u1EB7t t\xEAn theo th\u01B0 m\u1EE5c \u0111\u1EA7u ra m\xE0 b\u1EA1n \u0111\xE3 \u0111\u1EB7t, v\xED d\u1EE5: "),qn=h("code"),ls=s('"cool_huggingface_user/bert-finetuned-ner"'),xt=s("."),Qn=o(),E(Jn.$$.fragment),ue=o(),Wt=h("p"),Kt=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 qu\xE1 tr\xECnh hu\u1EA5n luy\u1EC7n c\u1EE7a m\xECnh tr\xEAn m\u1ED9t m\xE1y kh\xE1c n\u1EBFu c\u1EA7n."),me=o(),vn=h("p"),Se=s("\u1EDE giai \u0111o\u1EA1n n\xE0y, b\u1EA1n c\xF3 th\u1EC3 s\u1EED d\u1EE5ng ti\u1EC7n \xEDch lu\u1EADn suy tr\xEAn Model Hub \u0111\u1EC3 ki\u1EC3m tra m\xF4 h\xECnh c\u1EE7a m\xECnh v\xE0 chia s\u1EBB v\u1EDBi b\u1EA1n b\xE8. B\u1EA1n \u0111\xE3 tinh ch\u1EC9nh th\xE0nh c\xF4ng m\u1ED9t m\xF4 h\xECnh trong t\xE1c v\u1EE5 ph\xE2n lo\u1EA1i token - xin ch\xFAc m\u1EEBng! Nh\u01B0ng m\xF4 h\xECnh c\u1EE7a ch\xFAng ta th\u1EF1c s\u1EF1 t\u1ED1t \u0111\u1EBFn m\u1EE9c n\xE0o? Ch\xFAng ta n\xEAn c\xF3 m\u1ED9t s\u1ED1 ch\u1EC9 s\u1ED1 hay th\u01B0\u1EDBc \u0111o \u0111\u1EC3 \u0111\xE1nh gi\xE1."),this.h()},l(g){m=c(g,"H3",{class:!0});var S=r(m);v=c(S,"A",{id:!0,class:!0,href:!0});var ge=r(v);f=c(ge,"SPAN",{});var js=r(f);w($.$$.fragment,js),js.forEach(e),ge.forEach(e),O=p(S),k=c(S,"SPAN",{});var Zt=r(k);j=a(Zt,"\u0110\u1ECBnh ngh\u0129a m\xF4 h\xECnh"),Zt.forEach(e),S.forEach(e),q=p(g),D=c(g,"P",{});var Tn=r(D);z=a(Tn,"V\xEC ch\xFAng t\xF4i \u0111ang gi\u1EA3i quy\u1EBFt v\u1EA5n \u0111\u1EC1 ph\xE2n lo\u1EA1i token, ch\xFAng ta s\u1EBD s\u1EED d\u1EE5ng l\u1EDBp "),I=c(Tn,"CODE",{});var Es=r(I);A=a(Es,"TFAutoModelForTokenClassification"),Es.forEach(e),N=a(Tn,". \u0110i\u1EC1u ch\xEDnh c\u1EA7n nh\u1EDB khi x\xE1c \u0111\u1ECBnh m\xF4 h\xECnh n\xE0y l\xE0 truy\u1EC1n m\u1ED9t s\u1ED1 th\xF4ng tin v\u1EC1 s\u1ED1 l\u01B0\u1EE3ng nh\xE3n m\xE0 ch\xFAng ta c\xF3. C\xE1ch d\u1EC5 nh\u1EA5t \u0111\u1EC3 l\xE0m \u0111i\u1EC1u n\xE0y l\xE0 truy\u1EC1n v\xE0o tham s\u1ED1 "),V=c(Tn,"CODE",{});var fe=r(V);B=a(fe,"num_labels"),fe.forEach(e),R=a(Tn,", nh\u01B0ng n\u1EBFu ch\xFAng ta mu\u1ED1n m\u1ED9t ti\u1EC7n \xEDch lu\u1EADn suy \u0111\u1EB9p ho\u1EA1t \u0111\u1ED9ng gi\u1ED1ng nh\u01B0 ti\u1EC7n \xEDch ch\xFAng ta \u0111\xE3 th\u1EA5y \u1EDF \u0111\u1EA7u ph\u1EA7n n\xE0y, t\u1ED1t h\u01A1n n\xEAn \u0111\u1EB7t c\xE1c nh\xE3n t\u01B0\u01A1ng \u1EE9ng ch\xEDnh x\xE1c thay th\u1EBF."),Tn.forEach(e),F=p(g),M=c(g,"P",{});var Ct=r(M);W=a(Ct,"Ch\xFAng ph\u1EA3i \u0111\u01B0\u1EE3c \u0111\u1EB7t b\u1EDFi hai t\u1EEB \u0111i\u1EC3n, "),T=c(Ct,"CODE",{});var rn=r(T);U=a(rn,"id2label"),rn.forEach(e),L=a(Ct," v\xE0 "),K=c(Ct,"CODE",{});var oa=r(K);nn=a(oa,"label2id"),oa.forEach(e),an=a(Ct,", ch\u1EE9a \xE1nh x\u1EA1 t\u1EEB ID \u0111\u1EBFn nh\xE3n v\xE0 ng\u01B0\u1EE3c l\u1EA1i:"),Ct.forEach(e),ln=p(g),w(Z.$$.fragment,g),un=p(g),Q=c(g,"P",{});var Yt=r(Q);G=a(Yt,"B\xE2y gi\u1EDD ch\xFAng ta c\xF3 th\u1EC3 chuy\u1EC3n ch\xFAng \u0111\u1EBFn ph\u01B0\u01A1ng th\u1EE9c "),H=c(Yt,"CODE",{});var Ot=r(H);en=a(Ot,"TFAutoModelForTokenClassification.from_pretrained()"),Ot.forEach(e),mn=a(Yt," v\xE0 ch\xFAng s\u1EBD \u0111\u01B0\u1EE3c \u0111\u1EB7t trong c\u1EA5u h\xECnh c\u1EE7a m\xF4 h\xECnh, sau \u0111\xF3 \u0111\u01B0\u1EE3c l\u01B0u v\xE0 t\u1EA3i l\xEAn Hub m\u1ED9t c\xE1ch ch\xEDnh x\xE1c:"),Yt.forEach(e),kn=p(g),w(sn.$$.fragment,g),Bn=p(g),Y=c(g,"P",{});var Ln=r(Y);at=a(Ln,"Gi\u1ED1ng nh\u01B0 khi ch\xFAng t\xF4i \u0111\u1ECBnh ngh\u0129a "),on=c(Ln,"CODE",{});var de=r(on);ft=a(de,"TFAutoModelForSequenceClassification"),de.forEach(e),le=a(Ln," c\u1EE7a m\xECnh trong "),lt=c(Ln,"A",{href:!0});var _e=r(lt);Qe=a(_e,"Ch\u01B0\u01A1ng 3"),_e.forEach(e),It=a(Ln,", vi\u1EC7c t\u1EA1o m\xF4 h\xECnh \u0111\u01B0a ra c\u1EA3nh b\xE1o r\u1EB1ng m\u1ED9t s\u1ED1 tr\u1ECDng s\u1ED1 kh\xF4ng \u0111\u01B0\u1EE3c s\u1EED d\u1EE5ng (nh\u1EEFng tr\u1ECDng s\u1ED1 t\u1EEB \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 (nh\u1EEFng tr\u1ECDng s\u1ED1 t\u1EEB \u0111\u1EA7u ph\xE2n lo\u1EA1i token m\u1EDBi) v\xE0 m\xF4 h\xECnh n\xE0y n\xEAn \u0111\u01B0\u1EE3c hu\u1EA5n luy\u1EC7n. Ch\xFAng ta s\u1EBD l\xE0m \u0111i\u1EC1u \u0111\xF3 sau m\u1ED9t ph\xFAt, nh\u01B0ng tr\u01B0\u1EDBc ti\xEAn h\xE3y ki\u1EC3m tra k\u1EF9 xem m\xF4 h\xECnh c\u1EE7a ch\xFAng ta c\xF3 \u0111\xFAng s\u1ED1 l\u01B0\u1EE3ng nh\xE3n hay kh\xF4ng:"),Ln.forEach(e),he=p(g),w(bn.$$.fragment,g),De=p(g),w(En.$$.fragment,g),gn=p(g),w(Vn.$$.fragment,g),ce=p(g),tn=c(g,"H3",{class:!0});var hs=r(tn);pn=c(hs,"A",{id:!0,class:!0,href:!0});var be=r(pn);re=c(be,"SPAN",{});var pa=r(re);w(Sn.$$.fragment,pa),pa.forEach(e),be.forEach(e),Mt=p(hs),ie=c(hs,"SPAN",{});var ws=r(ie);Je=a(ws,"Tinh ch\u1EC9nh m\u1ED9t m\xF4 h\xECnh"),ws.forEach(e),hs.forEach(e),Un=p(g),In=c(g,"P",{});var ot=r(In);Lt=a(ot,"B\xE2y gi\u1EDD ch\xFAng t\xF4i \u0111\xE3 s\u1EB5n s\xE0ng \u0111\u1EC3 hu\u1EA5n luy\u1EC7n m\xF4 h\xECnh c\u1EE7a m\xECnh! Tuy nhi\xEAn, ch\xFAng ta ch\u1EC9 c\u1EA7n l\xE0m th\xEAm m\u1ED9t ch\xFAt c\xF4ng vi\u1EC7c tr\u01B0\u1EDBc ti\xEAn: ch\xFAng ta n\xEAn \u0111\u0103ng nh\u1EADp v\xE0o Hugging Face v\xE0 x\xE1c \u0111\u1ECBnh c\xE1c si\xEAu tham s\u1ED1 hu\u1EA5n luy\u1EC7n c\u1EE7a m\xECnh. N\u1EBFu b\u1EA1n \u0111ang l\xE0m vi\u1EC7c tr\xEAn notebook, c\xF3 m\u1ED9t ch\u1EE9c n\u0103ng ti\u1EC7n l\u1EE3i \u0111\u1EC3 gi\xFAp b\u1EA1n l\xE0m \u0111i\u1EC1u n\xE0y:"),ot.forEach(e),oe=p(g),w(Ht.$$.fragment,g),Te=p(g),yn=c(g,"P",{});var ua=r(yn);wn=a(ua,"Thao t\xE1c n\xE0y s\u1EBD hi\u1EC3n th\u1ECB m\u1ED9t ti\u1EC7n \xEDch m\xE0 b\u1EA1n c\xF3 th\u1EC3 nh\u1EADp th\xF4ng tin \u0111\u0103ng nh\u1EADp  Hugging Face c\u1EE7a m\xECnh."),ua.forEach(e),Rt=p(g),$n=c(g,"P",{});var Ie=r($n);bs=a(Ie,"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:"),Ie.forEach(e),Ft=p(g),w(Xn.$$.fragment,g),Pe=p(g),cn=c(g,"P",{});var nt=r(cn);Gt=a(nt,"Sau khi \u0111\u0103ng nh\u1EADp, ch\xFAng ta c\xF3 th\u1EC3 chu\u1EA9n b\u1ECB m\u1ECDi th\u1EE9 c\u1EA7n thi\u1EBFt \u0111\u1EC3 bi\xEAn d\u1ECBch m\xF4 h\xECnh c\u1EE7a m\xECnh. \u{1F917} Transformers cung c\u1EA5p m\u1ED9t h\xE0m "),Wn=c(nt,"CODE",{});var ma=r(Wn);dt=a(ma,"create_optimizer()"),ma.forEach(e),vs=a(nt," thu\u1EADn ti\u1EC7n s\u1EBD cung c\u1EA5p cho b\u1EA1n tr\xECnh t\u1ED1i \u01B0u h\xF3a "),_t=c(nt,"CODE",{});var xs=r(_t);bt=a(xs,"AdamW"),xs.forEach(e),ns=a(nt," v\u1EDBi c\xE1c c\xE0i \u0111\u1EB7t th\xEDch h\u1EE3p cho gi\u1EA3m tr\u1ECDng l\u01B0\u1EE3ng v\xE0 gi\u1EA3m t\u1ED1c \u0111\u1ED9 h\u1ECDc t\u1EADp, c\u1EA3 hai \u0111\u1EC1u s\u1EBD c\u1EA3i thi\u1EC7n hi\u1EC7u su\u1EA5t m\xF4 h\xECnh c\u1EE7a b\u1EA1n so v\u1EDBi tr\xECnh t\u1ED1i \u01B0u h\xF3a "),xn=c(nt,"CODE",{});var pt=r(xn);Cn=a(pt,"Adam"),pt.forEach(e),pe=a(nt," t\xEDch h\u1EE3p s\u1EB5n:"),nt.forEach(e),J=p(g),w(Vt.$$.fragment,g),vt=p(g),Kn=c(g,"P",{});var dn=r(Kn);ts=a(dn,"C\u0169ng l\u01B0u \xFD r\u1EB1ng ch\xFAng ta kh\xF4ng cung c\u1EA5p tham s\u1ED1 "),On=c(dn,"CODE",{});var Me=r(On);ks=a(Me,"loss"),Me.forEach(e),ze=a(dn," cho "),ht=c(dn,"CODE",{});var tt=r(ht);Ae=a(tt,"compile()"),tt.forEach(e),es=a(dn,". \u0110i\u1EC1u n\xE0y l\xE0 do c\xE1c m\xF4 h\xECnh th\u1EF1c s\u1EF1 c\xF3 th\u1EC3 t\xEDnh to\xE1n m\u1EA5t m\xE1t b\xEAn trong - n\u1EBFu b\u1EA1n bi\xEAn d\u1ECBch m\xE0 kh\xF4ng m\u1EA5t m\xE1t v\xE0 cung c\u1EA5p c\xE1c nh\xE3n c\u1EE7a b\u1EA1n trong t\u1EEB \u0111i\u1EC3n \u0111\u1EA7u v\xE0o (nh\u01B0 ch\xFAng ta l\xE0m trong b\u1ED9 d\u1EEF li\u1EC7u c\u1EE7a m\xECnh), th\xEC m\xF4 h\xECnh s\u1EBD hu\u1EA5n luy\u1EC7n b\u1EB1ng c\xE1ch s\u1EED d\u1EE5ng m\u1EA5t m\xE1t n\u1ED9i b\u1ED9 \u0111\xF3, \u0111i\u1EC1u n\xE0y s\u1EBD th\xEDch h\u1EE3p cho t\xE1c v\u1EE5 v\xE0 lo\u1EA1i m\xF4 h\xECnh b\u1EA1n \u0111\xE3 ch\u1ECDn."),dn.forEach(e),kt=p(g),Mn=c(g,"P",{});var Le=r(Mn);yt=a(Le,"Ti\u1EBFp theo, ch\xFAng ta x\xE1c \u0111\u1ECBnh m\u1ED9t "),Ne=c(Le,"CODE",{});var Hn=r(Ne);$t=a(Hn,"PushToHubCallback"),Hn.forEach(e),ys=a(Le," \u0111\u1EC3 t\u1EA3i m\xF4 h\xECnh l\xEAn Hub trong qu\xE1 tr\xECnh hu\u1EA5n luy\u1EC7n v\xE0 ph\xF9 h\u1EE3p v\u1EDBi m\xF4 h\xECnh v\u1EDBi l\u1EC7nh g\u1ECDi l\u1EA1i \u0111\xF3:"),Le.forEach(e),ss=p(g),w(Zn.$$.fragment,g),jt=p(g),fn=c(g,"P",{});var et=r(fn);Et=a(et,"B\u1EA1n c\xF3 th\u1EC3 ch\u1EC9 \u0111\u1ECBnh t\xEAn \u0111\u1EA7y \u0111\u1EE7 c\u1EE7a kho l\u01B0u tr\u1EEF m\xE0 b\u1EA1n mu\u1ED1n \u0111\u1EA9y \u0111\u1EBFn b\u1EB1ng tham s\u1ED1 "),Yn=c(et,"CODE",{});var He=r(Yn);ct=a(He,"hub_model_id"),He.forEach(e),wt=a(et," (\u0111\u1EB7c bi\u1EC7t, b\u1EA1n s\u1EBD ph\u1EA3i s\u1EED d\u1EE5ng tham s\u1ED1 n\xE0y \u0111\u1EC3 \u0111\u1EA9y \u0111\u1EBFn m\u1ED9t t\u1ED5 ch\u1EE9c). V\xED d\u1EE5: khi ch\xFAng ta \u0111\u1EA9y m\xF4 h\xECnh v\xE0o t\u1ED5 ch\u1EE9c "),rt=c(et,"A",{href:!0,rel:!0});var Rn=r(rt);Ut=c(Rn,"CODE",{});var ga=r(Ut);$s=a(ga,"huggingface-course"),ga.forEach(e),Rn.forEach(e),as=a(et,", ch\xFAng ta \u0111\xE3 th\xEAm "),it=c(et,"CODE",{});var Qt=r(it);Xt=a(Qt,'hub_model_id="huggingface-course/bert-finetuned-ner"'),Qt.forEach(e),Be=a(et,". Theo m\u1EB7c \u0111\u1ECBnh, kho l\u01B0u tr\u1EEF \u0111\u01B0\u1EE3c s\u1EED d\u1EE5ng s\u1EBD n\u1EB1m trong kh\xF4ng gian t\xEAn c\u1EE7a b\u1EA1n v\xE0 \u0111\u01B0\u1EE3c \u0111\u1EB7t t\xEAn theo th\u01B0 m\u1EE5c \u0111\u1EA7u ra m\xE0 b\u1EA1n \u0111\xE3 \u0111\u1EB7t, v\xED d\u1EE5: "),qn=c(et,"CODE",{});var fa=r(qn);ls=a(fa,'"cool_huggingface_user/bert-finetuned-ner"'),fa.forEach(e),xt=a(et,"."),et.forEach(e),Qn=p(g),w(Jn.$$.fragment,g),ue=p(g),Wt=c(g,"P",{});var da=r(Wt);Kt=a(da,"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 qu\xE1 tr\xECnh hu\u1EA5n luy\u1EC7n c\u1EE7a m\xECnh tr\xEAn m\u1ED9t m\xE1y kh\xE1c n\u1EBFu c\u1EA7n."),da.forEach(e),me=p(g),vn=c(g,"P",{});var Re=r(vn);Se=a(Re,"\u1EDE giai \u0111o\u1EA1n n\xE0y, b\u1EA1n c\xF3 th\u1EC3 s\u1EED d\u1EE5ng ti\u1EC7n \xEDch lu\u1EADn suy tr\xEAn Model Hub \u0111\u1EC3 ki\u1EC3m tra m\xF4 h\xECnh c\u1EE7a m\xECnh v\xE0 chia s\u1EBB v\u1EDBi b\u1EA1n b\xE8. B\u1EA1n \u0111\xE3 tinh ch\u1EC9nh th\xE0nh c\xF4ng m\u1ED9t m\xF4 h\xECnh trong t\xE1c v\u1EE5 ph\xE2n lo\u1EA1i token - xin ch\xFAc m\u1EEBng! Nh\u01B0ng m\xF4 h\xECnh c\u1EE7a ch\xFAng ta th\u1EF1c s\u1EF1 t\u1ED1t \u0111\u1EBFn m\u1EE9c n\xE0o? Ch\xFAng ta n\xEAn c\xF3 m\u1ED9t s\u1ED1 ch\u1EC9 s\u1ED1 hay th\u01B0\u1EDBc \u0111o \u0111\u1EC3 \u0111\xE1nh gi\xE1."),Re.forEach(e),this.h()},h(){y(v,"id","nh-ngha-m-hnh"),y(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"),y(v,"href","#nh-ngha-m-hnh"),y(m,"class","relative group"),y(lt,"href","/course/chapter3"),y(pn,"id","tinh-chnh-mt-m-hnh"),y(pn,"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"),y(pn,"href","#tinh-chnh-mt-m-hnh"),y(tn,"class","relative group"),y(rt,"href","https://huggingface.co/huggingface-course"),y(rt,"rel","nofollow")},m(g,S){i(g,m,S),n(m,v),n(v,f),x($,f,null),n(m,O),n(m,k),n(k,j),i(g,q,S),i(g,D,S),n(D,z),n(D,I),n(I,A),n(D,N),n(D,V),n(V,B),n(D,R),i(g,F,S),i(g,M,S),n(M,W),n(M,T),n(T,U),n(M,L),n(M,K),n(K,nn),n(M,an),i(g,ln,S),x(Z,g,S),i(g,un,S),i(g,Q,S),n(Q,G),n(Q,H),n(H,en),n(Q,mn),i(g,kn,S),x(sn,g,S),i(g,Bn,S),i(g,Y,S),n(Y,at),n(Y,on),n(on,ft),n(Y,le),n(Y,lt),n(lt,Qe),n(Y,It),i(g,he,S),x(bn,g,S),i(g,De,S),x(En,g,S),i(g,gn,S),x(Vn,g,S),i(g,ce,S),i(g,tn,S),n(tn,pn),n(pn,re),x(Sn,re,null),n(tn,Mt),n(tn,ie),n(ie,Je),i(g,Un,S),i(g,In,S),n(In,Lt),i(g,oe,S),x(Ht,g,S),i(g,Te,S),i(g,yn,S),n(yn,wn),i(g,Rt,S),i(g,$n,S),n($n,bs),i(g,Ft,S),x(Xn,g,S),i(g,Pe,S),i(g,cn,S),n(cn,Gt),n(cn,Wn),n(Wn,dt),n(cn,vs),n(cn,_t),n(_t,bt),n(cn,ns),n(cn,xn),n(xn,Cn),n(cn,pe),i(g,J,S),x(Vt,g,S),i(g,vt,S),i(g,Kn,S),n(Kn,ts),n(Kn,On),n(On,ks),n(Kn,ze),n(Kn,ht),n(ht,Ae),n(Kn,es),i(g,kt,S),i(g,Mn,S),n(Mn,yt),n(Mn,Ne),n(Ne,$t),n(Mn,ys),i(g,ss,S),x(Zn,g,S),i(g,jt,S),i(g,fn,S),n(fn,Et),n(fn,Yn),n(Yn,ct),n(fn,wt),n(fn,rt),n(rt,Ut),n(Ut,$s),n(fn,as),n(fn,it),n(it,Xt),n(fn,Be),n(fn,qn),n(qn,ls),n(fn,xt),i(g,Qn,S),x(Jn,g,S),i(g,ue,S),i(g,Wt,S),n(Wt,Kt),i(g,me,S),i(g,vn,S),n(vn,Se),Dn=!0},i(g){Dn||(_($.$$.fragment,g),_(Z.$$.fragment,g),_(sn.$$.fragment,g),_(bn.$$.fragment,g),_(En.$$.fragment,g),_(Vn.$$.fragment,g),_(Sn.$$.fragment,g),_(Ht.$$.fragment,g),_(Xn.$$.fragment,g),_(Vt.$$.fragment,g),_(Zn.$$.fragment,g),_(Jn.$$.fragment,g),Dn=!0)},o(g){b($.$$.fragment,g),b(Z.$$.fragment,g),b(sn.$$.fragment,g),b(bn.$$.fragment,g),b(En.$$.fragment,g),b(Vn.$$.fragment,g),b(Sn.$$.fragment,g),b(Ht.$$.fragment,g),b(Xn.$$.fragment,g),b(Vt.$$.fragment,g),b(Zn.$$.fragment,g),b(Jn.$$.fragment,g),Dn=!1},d(g){g&&e(m),C($),g&&e(q),g&&e(D),g&&e(F),g&&e(M),g&&e(ln),C(Z,g),g&&e(un),g&&e(Q),g&&e(kn),C(sn,g),g&&e(Bn),g&&e(Y),g&&e(he),C(bn,g),g&&e(De),C(En,g),g&&e(gn),C(Vn,g),g&&e(ce),g&&e(tn),C(Sn),g&&e(Un),g&&e(In),g&&e(oe),C(Ht,g),g&&e(Te),g&&e(yn),g&&e(Rt),g&&e($n),g&&e(Ft),C(Xn,g),g&&e(Pe),g&&e(cn),g&&e(J),C(Vt,g),g&&e(vt),g&&e(Kn),g&&e(kt),g&&e(Mn),g&&e(ss),C(Zn,g),g&&e(jt),g&&e(fn),g&&e(Qn),C(Jn,g),g&&e(ue),g&&e(Wt),g&&e(me),g&&e(vn)}}}function Vu(X){let m,v,f,$,O;return{c(){m=h("p"),v=s("\u26A0\uFE0F N\u1EBFu b\u1EA1n c\xF3 m\u1ED9t m\xF4 h\xECnh c\xF3 s\u1ED1 nh\xE3n sai, b\u1EA1n s\u1EBD g\u1EB7p l\u1ED7i kh\xF3 hi\u1EC3u khi g\u1ECDi "),f=h("code"),$=s("model.fit()"),O=s(" sau n\xE0y. \u0110i\u1EC1u n\xE0y c\xF3 th\u1EC3 g\xE2y kh\xF3 ch\u1ECBu khi g\u1EE1 l\u1ED7i, v\xEC v\u1EADy h\xE3y \u0111\u1EA3m b\u1EA3o b\u1EA1n th\u1EF1c hi\u1EC7n ki\u1EC3m tra n\xE0y \u0111\u1EC3 x\xE1c nh\u1EADn r\u1EB1ng b\u1EA1n c\xF3 s\u1ED1 l\u01B0\u1EE3ng nh\xE3n d\u1EF1 ki\u1EBFn.")},l(k){m=c(k,"P",{});var j=r(m);v=a(j,"\u26A0\uFE0F N\u1EBFu b\u1EA1n c\xF3 m\u1ED9t m\xF4 h\xECnh c\xF3 s\u1ED1 nh\xE3n sai, b\u1EA1n s\u1EBD g\u1EB7p l\u1ED7i kh\xF3 hi\u1EC3u khi g\u1ECDi "),f=c(j,"CODE",{});var q=r(f);$=a(q,"model.fit()"),q.forEach(e),O=a(j," sau n\xE0y. \u0110i\u1EC1u n\xE0y c\xF3 th\u1EC3 g\xE2y kh\xF3 ch\u1ECBu khi g\u1EE1 l\u1ED7i, v\xEC v\u1EADy h\xE3y \u0111\u1EA3m b\u1EA3o b\u1EA1n th\u1EF1c hi\u1EC7n ki\u1EC3m tra n\xE0y \u0111\u1EC3 x\xE1c nh\u1EADn r\u1EB1ng b\u1EA1n c\xF3 s\u1ED1 l\u01B0\u1EE3ng nh\xE3n d\u1EF1 ki\u1EBFn."),j.forEach(e)},m(k,j){i(k,m,j),n(m,v),n(m,f),n(f,$),n(m,O)},d(k){k&&e(m)}}}function Uu(X){let m,v,f,$,O;return{c(){m=h("p"),v=s("\u{1F4A1} N\u1EBFu th\u01B0 m\u1EE5c \u0111\u1EA7u ra b\u1EA1n \u0111ang s\u1EED d\u1EE5ng \u0111\xE3 t\u1ED3n t\u1EA1i, n\xF3 c\u1EA7n ph\u1EA3i l\xE0 b\u1EA3n sao c\u1EE5c b\u1ED9 c\u1EE7a kho l\u01B0u tr\u1EEF m\xE0 b\u1EA1n mu\u1ED1n \u0111\u1EA9y \u0111\u1EBFn. N\u1EBFu kh\xF4ng, b\u1EA1n s\u1EBD g\u1EB7p l\u1ED7i khi g\u1ECDi "),f=h("code"),$=s("model.fit()"),O=s(" v\xE0 s\u1EBD c\u1EA7n \u0111\u1EB7t t\xEAn m\u1EDBi.")},l(k){m=c(k,"P",{});var j=r(m);v=a(j,"\u{1F4A1} N\u1EBFu th\u01B0 m\u1EE5c \u0111\u1EA7u ra b\u1EA1n \u0111ang s\u1EED d\u1EE5ng \u0111\xE3 t\u1ED3n t\u1EA1i, n\xF3 c\u1EA7n ph\u1EA3i l\xE0 b\u1EA3n sao c\u1EE5c b\u1ED9 c\u1EE7a kho l\u01B0u tr\u1EEF m\xE0 b\u1EA1n mu\u1ED1n \u0111\u1EA9y \u0111\u1EBFn. N\u1EBFu kh\xF4ng, b\u1EA1n s\u1EBD g\u1EB7p l\u1ED7i khi g\u1ECDi "),f=c(j,"CODE",{});var q=r(f);$=a(q,"model.fit()"),q.forEach(e),O=a(j," v\xE0 s\u1EBD c\u1EA7n \u0111\u1EB7t t\xEAn m\u1EDBi."),j.forEach(e)},m(k,j){i(k,m,j),n(m,v),n(m,f),n(f,$),n(m,O)},d(k){k&&e(m)}}}function Xu(X){let m,v,f,$,O,k,j,q,D,z,I,A,N,V,B,R,F,M,W,T,U;return I=new P({props:{code:"!pip install seqeval",highlighted:"!pip install seqeval"}}),{c(){m=h("p"),v=s("Khung truy\u1EC1n th\u1ED1ng \u0111\u01B0\u1EE3c s\u1EED d\u1EE5ng \u0111\u1EC3 \u0111\xE1nh gi\xE1 ph\xE2n lo\u1EA1i token l\xE0 "),f=h("a"),$=h("em"),O=s("seqeval"),k=s(". \u0110\u1EC3 s\u1EED d\u1EE5ng th\u01B0\u1EDBc \u0111o n\xE0y, ta s\u1EBD c\u1EA7n c\xE0i \u0111\u1EB7t th\u01B0 vi\u1EC7n "),j=h("em"),q=s("seqeval"),D=s(":"),z=o(),E(I.$$.fragment),A=o(),N=h("p"),V=s("Ch\xFAng ta c\xF3 th\u1EC3 t\u1EA3i n\xF3 qua h\xE0m "),B=h("code"),R=s("evaluate.load()"),F=s(" nh\u01B0 \u0111\xE3 l\xE0m \u1EDF "),M=h("a"),W=s("Ch\u01B0\u01A1ng 3 3"),T=s(":"),this.h()},l(L){m=c(L,"P",{});var K=r(m);v=a(K,"Khung truy\u1EC1n th\u1ED1ng \u0111\u01B0\u1EE3c s\u1EED d\u1EE5ng \u0111\u1EC3 \u0111\xE1nh gi\xE1 ph\xE2n lo\u1EA1i token l\xE0 "),f=c(K,"A",{href:!0,rel:!0});var nn=r(f);$=c(nn,"EM",{});var an=r($);O=a(an,"seqeval"),an.forEach(e),nn.forEach(e),k=a(K,". \u0110\u1EC3 s\u1EED d\u1EE5ng th\u01B0\u1EDBc \u0111o n\xE0y, ta s\u1EBD c\u1EA7n c\xE0i \u0111\u1EB7t th\u01B0 vi\u1EC7n "),j=c(K,"EM",{});var ln=r(j);q=a(ln,"seqeval"),ln.forEach(e),D=a(K,":"),K.forEach(e),z=p(L),w(I.$$.fragment,L),A=p(L),N=c(L,"P",{});var Z=r(N);V=a(Z,"Ch\xFAng ta c\xF3 th\u1EC3 t\u1EA3i n\xF3 qua h\xE0m "),B=c(Z,"CODE",{});var un=r(B);R=a(un,"evaluate.load()"),un.forEach(e),F=a(Z," nh\u01B0 \u0111\xE3 l\xE0m \u1EDF "),M=c(Z,"A",{href:!0});var Q=r(M);W=a(Q,"Ch\u01B0\u01A1ng 3 3"),Q.forEach(e),T=a(Z,":"),Z.forEach(e),this.h()},h(){y(f,"href","https://github.com/chakki-works/seqeval"),y(f,"rel","nofollow"),y(M,"href","/course/chapter3")},m(L,K){i(L,m,K),n(m,v),n(m,f),n(f,$),n($,O),n(m,k),n(m,j),n(j,q),n(m,D),i(L,z,K),x(I,L,K),i(L,A,K),i(L,N,K),n(N,V),n(N,B),n(B,R),n(N,F),n(N,M),n(M,W),n(N,T),U=!0},i(L){U||(_(I.$$.fragment,L),U=!0)},o(L){b(I.$$.fragment,L),U=!1},d(L){L&&e(m),L&&e(z),C(I,L),L&&e(A),L&&e(N)}}}function Wu(X){let m,v,f,$,O,k,j,q,D,z,I,A,N,V,B,R,F,M,W,T,U,L,K,nn,an,ln,Z,un,Q,G;return T=new P({props:{code:"!pip install seqeval",highlighted:"!pip install seqeval"}}),{c(){m=h("p"),v=s("\u0110\u1EC3 "),f=h("code"),$=s("Trainer"),O=s(" t\xEDnh to\xE1n m\u1ED9t th\u01B0\u1EDBc \u0111o cho m\u1ED7i epoch, ta s\u1EBD c\u1EA7n \u0111\u1ECBnh ngh\u0129a h\xE0m "),k=h("code"),j=s("compute_metrics()"),q=s(" nh\u1EADn m\u1ED9t array c\xE1c d\u1EF1 \u0111o\xE1n v\xE0 nh\xE3n, v\xE0 tr\u1EA3 v\u1EC1 m\u1ED9t t\u1EEB \u0111i\u1EC3n v\u1EDBi t\xEAn c\xE1c th\u01B0\u1EDBc \u0111o v\xE0 gi\xE1 tr\u1ECB t\u01B0\u01A1ng \u1EE9ng."),D=o(),z=h("p"),I=s("Khung truy\u1EC1n th\u1ED1ng \u0111\u01B0\u1EE3c s\u1EED d\u1EE5ng \u0111\u1EC3 \u0111\xE1nh gi\xE1 ph\xE2n lo\u1EA1i token l\xE0 "),A=h("a"),N=h("em"),V=s("seqeval"),B=s(". \u0110\u1EC3 s\u1EED d\u1EE5ng th\u01B0\u1EDBc \u0111o n\xE0y, ta s\u1EBD c\u1EA7n c\xE0i \u0111\u1EB7t th\u01B0 vi\u1EC7n "),R=h("em"),F=s("seqeval"),M=s(":"),W=o(),E(T.$$.fragment),U=o(),L=h("p"),K=s("Ch\xFAng ta c\xF3 th\u1EC3 t\u1EA3i n\xF3 qua h\xE0m "),nn=h("code"),an=s("evaluate.load()"),ln=s(" nh\u01B0 \u0111\xE3 l\xE0m \u1EDF "),Z=h("a"),un=s("Ch\u01B0\u01A1ng 3 3"),Q=s(":"),this.h()},l(H){m=c(H,"P",{});var en=r(m);v=a(en,"\u0110\u1EC3 "),f=c(en,"CODE",{});var mn=r(f);$=a(mn,"Trainer"),mn.forEach(e),O=a(en," t\xEDnh to\xE1n m\u1ED9t th\u01B0\u1EDBc \u0111o cho m\u1ED7i epoch, ta s\u1EBD c\u1EA7n \u0111\u1ECBnh ngh\u0129a h\xE0m "),k=c(en,"CODE",{});var kn=r(k);j=a(kn,"compute_metrics()"),kn.forEach(e),q=a(en," nh\u1EADn m\u1ED9t array c\xE1c d\u1EF1 \u0111o\xE1n v\xE0 nh\xE3n, v\xE0 tr\u1EA3 v\u1EC1 m\u1ED9t t\u1EEB \u0111i\u1EC3n v\u1EDBi t\xEAn c\xE1c th\u01B0\u1EDBc \u0111o v\xE0 gi\xE1 tr\u1ECB t\u01B0\u01A1ng \u1EE9ng."),en.forEach(e),D=p(H),z=c(H,"P",{});var sn=r(z);I=a(sn,"Khung truy\u1EC1n th\u1ED1ng \u0111\u01B0\u1EE3c s\u1EED d\u1EE5ng \u0111\u1EC3 \u0111\xE1nh gi\xE1 ph\xE2n lo\u1EA1i token l\xE0 "),A=c(sn,"A",{href:!0,rel:!0});var Bn=r(A);N=c(Bn,"EM",{});var Y=r(N);V=a(Y,"seqeval"),Y.forEach(e),Bn.forEach(e),B=a(sn,". \u0110\u1EC3 s\u1EED d\u1EE5ng th\u01B0\u1EDBc \u0111o n\xE0y, ta s\u1EBD c\u1EA7n c\xE0i \u0111\u1EB7t th\u01B0 vi\u1EC7n "),R=c(sn,"EM",{});var at=r(R);F=a(at,"seqeval"),at.forEach(e),M=a(sn,":"),sn.forEach(e),W=p(H),w(T.$$.fragment,H),U=p(H),L=c(H,"P",{});var on=r(L);K=a(on,"Ch\xFAng ta c\xF3 th\u1EC3 t\u1EA3i n\xF3 qua h\xE0m "),nn=c(on,"CODE",{});var ft=r(nn);an=a(ft,"evaluate.load()"),ft.forEach(e),ln=a(on," nh\u01B0 \u0111\xE3 l\xE0m \u1EDF "),Z=c(on,"A",{href:!0});var le=r(Z);un=a(le,"Ch\u01B0\u01A1ng 3 3"),le.forEach(e),Q=a(on,":"),on.forEach(e),this.h()},h(){y(A,"href","https://github.com/chakki-works/seqeval"),y(A,"rel","nofollow"),y(Z,"href","/course/chapter3")},m(H,en){i(H,m,en),n(m,v),n(m,f),n(f,$),n(m,O),n(m,k),n(k,j),n(m,q),i(H,D,en),i(H,z,en),n(z,I),n(z,A),n(A,N),n(N,V),n(z,B),n(z,R),n(R,F),n(z,M),i(H,W,en),x(T,H,en),i(H,U,en),i(H,L,en),n(L,K),n(L,nn),n(nn,an),n(L,ln),n(L,Z),n(Z,un),n(L,Q),G=!0},i(H){G||(_(T.$$.fragment,H),G=!0)},o(H){b(T.$$.fragment,H),G=!1},d(H){H&&e(m),H&&e(D),H&&e(z),H&&e(W),C(T,H),H&&e(U),H&&e(L)}}}function Ku(X){let m,v,f,$,O,k,j,q,D,z,I,A,N,V,B,R,F,M,W;return N=new P({props:{code:`import numpy as np

all_predictions = []
all_labels = []
for batch in tf_eval_dataset:
    logits = model.predict(batch)["logits"]
    labels = batch["labels"]
    predictions = np.argmax(logits, axis=-1)
    for prediction, label in zip(predictions, labels):
        for predicted_idx, label_idx in zip(prediction, label):
            if label_idx == -100:
                continue
            all_predictions.append(label_names[predicted_idx])
            all_labels.append(label_names[label_idx])
metric.compute(predictions=[all_predictions], references=[all_labels])`,highlighted:`<span class="hljs-keyword">import</span> numpy <span class="hljs-keyword">as</span> np

all_predictions = []
all_labels = []
<span class="hljs-keyword">for</span> batch <span class="hljs-keyword">in</span> tf_eval_dataset:
    logits = model.predict(batch)[<span class="hljs-string">&quot;logits&quot;</span>]
    labels = batch[<span class="hljs-string">&quot;labels&quot;</span>]
    predictions = np.argmax(logits, axis=-<span class="hljs-number">1</span>)
    <span class="hljs-keyword">for</span> prediction, label <span class="hljs-keyword">in</span> <span class="hljs-built_in">zip</span>(predictions, labels):
        <span class="hljs-keyword">for</span> predicted_idx, label_idx <span class="hljs-keyword">in</span> <span class="hljs-built_in">zip</span>(prediction, label):
            <span class="hljs-keyword">if</span> label_idx == -<span class="hljs-number">100</span>:
                <span class="hljs-keyword">continue</span>
            all_predictions.append(label_names[predicted_idx])
            all_labels.append(label_names[label_idx])
metric.compute(predictions=[all_predictions], references=[all_labels])`}}),B=new P({props:{code:`{'LOC': {'precision': 0.91, 'recall': 0.92, 'f1': 0.91, 'number': 1668},
 'MISC': {'precision': 0.70, 'recall': 0.79, 'f1': 0.74, 'number': 702},
 'ORG': {'precision': 0.85, 'recall': 0.90, 'f1': 0.88, 'number': 1661},
 'PER': {'precision': 0.95, 'recall': 0.95, 'f1': 0.95, 'number': 1617},
 'overall_precision': 0.87,
 'overall_recall': 0.91,
 'overall_f1': 0.89,
 'overall_accuracy': 0.97}`,highlighted:`{<span class="hljs-string">&#x27;LOC&#x27;</span>: {<span class="hljs-string">&#x27;precision&#x27;</span>: <span class="hljs-number">0.91</span>, <span class="hljs-string">&#x27;recall&#x27;</span>: <span class="hljs-number">0.92</span>, <span class="hljs-string">&#x27;f1&#x27;</span>: <span class="hljs-number">0.91</span>, <span class="hljs-string">&#x27;number&#x27;</span>: <span class="hljs-number">1668</span>},
 <span class="hljs-string">&#x27;MISC&#x27;</span>: {<span class="hljs-string">&#x27;precision&#x27;</span>: <span class="hljs-number">0.70</span>, <span class="hljs-string">&#x27;recall&#x27;</span>: <span class="hljs-number">0.79</span>, <span class="hljs-string">&#x27;f1&#x27;</span>: <span class="hljs-number">0.74</span>, <span class="hljs-string">&#x27;number&#x27;</span>: <span class="hljs-number">702</span>},
 <span class="hljs-string">&#x27;ORG&#x27;</span>: {<span class="hljs-string">&#x27;precision&#x27;</span>: <span class="hljs-number">0.85</span>, <span class="hljs-string">&#x27;recall&#x27;</span>: <span class="hljs-number">0.90</span>, <span class="hljs-string">&#x27;f1&#x27;</span>: <span class="hljs-number">0.88</span>, <span class="hljs-string">&#x27;number&#x27;</span>: <span class="hljs-number">1661</span>},
 <span class="hljs-string">&#x27;PER&#x27;</span>: {<span class="hljs-string">&#x27;precision&#x27;</span>: <span class="hljs-number">0.95</span>, <span class="hljs-string">&#x27;recall&#x27;</span>: <span class="hljs-number">0.95</span>, <span class="hljs-string">&#x27;f1&#x27;</span>: <span class="hljs-number">0.95</span>, <span class="hljs-string">&#x27;number&#x27;</span>: <span class="hljs-number">1617</span>},
 <span class="hljs-string">&#x27;overall_precision&#x27;</span>: <span class="hljs-number">0.87</span>,
 <span class="hljs-string">&#x27;overall_recall&#x27;</span>: <span class="hljs-number">0.91</span>,
 <span class="hljs-string">&#x27;overall_f1&#x27;</span>: <span class="hljs-number">0.89</span>,
 <span class="hljs-string">&#x27;overall_accuracy&#x27;</span>: <span class="hljs-number">0.97</span>}`}}),{c(){m=h("p"),v=s("\u0110i\u1EC1u n\xE0y \u0111ang g\u1EEDi l\u1EA1i r\u1EA5t nhi\u1EC1u th\xF4ng tin! Ch\xFAng ta nh\u1EADn \u0111\u01B0\u1EE3c precision, recall, v\xE0 \u0111i\u1EC3m F1 cho t\u1EEBng th\u1EF1c th\u1EC3 ri\xEAng bi\u1EC7t, c\u0169ng nh\u01B0 t\u1ED5ng th\u1EC3. H\xE3y c\u0169ng xem chuy\u1EC7n g\xEC x\u1EA3y ra n\xEAu sta th\u1EED s\u1EED d\u1EE5ng gi\xE1 tr\u1ECB d\u1EF1 \u0111o\xE1n th\u1EF1c c\u1EE7a m\xF4 h\xECnh \u0111\u1EC3 t\xEDnh ra \u0111i\u1EC3m s\u1ED1 th\u1EF1c."),f=o(),$=h("p"),O=s("TensorFlow kh\xF4ng gi\u1ED1ng nh\u01B0 vi\u1EC7c n\u1ED1i c\xE1c d\u1EF1 \u0111o\xE1n c\u1EE7a ch\xFAng ta l\u1EA1i v\u1EDBi nhau, b\u1EDFi v\xEC ch\xFAng c\xF3 \u0111\u1ED9 d\xE0i chu\u1ED7i thay \u0111\u1ED5i. \u0110i\u1EC1u n\xE0y c\xF3 ngh\u0129a l\xE0 ch\xFAng ta kh\xF4ng th\u1EC3 ch\u1EC9 s\u1EED d\u1EE5ng "),k=h("code"),j=s("model.predict()"),q=s(" \u2014  h\u01B0ng \u0111i\u1EC1u \u0111\xF3 s\u1EBD kh\xF4ng ng\u0103n c\u1EA3n ch\xFAng ta. Ch\xFAng ta s\u1EBD nh\u1EADn \u0111\u01B0\u1EE3c m\u1ED9t s\u1ED1 d\u1EF1 \u0111o\xE1n t\u1EA1i m\u1ED9t th\u1EDDi \u0111i\u1EC3m v\xE0 n\u1ED1i ch\xFAng th\xE0nh m\u1ED9t danh s\xE1ch d\xE0i l\u1EDBn khi ti\u1EBFp t\u1EE5c, b\u1ECF c\xE1c token "),D=h("code"),z=s("-100"),I=s(" t\u01B0\u01A1ng \u1EE9ng b\u1ECB \u1EA9n \u0111i ho\u1EB7c \u0111\u1EC7m, sau \u0111\xF3 t\xEDnh to\xE1n c\xE1c s\u1ED1 li\u1EC7u tr\xEAn danh s\xE1ch \u1EDF cu\u1ED1i:"),A=o(),E(N.$$.fragment),V=o(),E(B.$$.fragment),R=o(),F=h("p"),M=s("M\xF4 h\xECnh c\u1EE7a b\u1EA1n \u0111\xE3 l\xE0m nh\u01B0 th\u1EBF n\xE0o, so v\u1EDBi m\xF4 h\xECnh c\u1EE7a ch\xFAng t\xF4i? N\u1EBFu b\u1EA1n c\xF3 nh\u1EEFng con s\u1ED1 t\u01B0\u01A1ng t\u1EF1, kh\xF3a \u0111\xE0o t\u1EA1o c\u1EE7a b\u1EA1n \u0111\xE3 th\xE0nh c\xF4ng!")},l(T){m=c(T,"P",{});var U=r(m);v=a(U,"\u0110i\u1EC1u n\xE0y \u0111ang g\u1EEDi l\u1EA1i r\u1EA5t nhi\u1EC1u th\xF4ng tin! Ch\xFAng ta nh\u1EADn \u0111\u01B0\u1EE3c precision, recall, v\xE0 \u0111i\u1EC3m F1 cho t\u1EEBng th\u1EF1c th\u1EC3 ri\xEAng bi\u1EC7t, c\u0169ng nh\u01B0 t\u1ED5ng th\u1EC3. H\xE3y c\u0169ng xem chuy\u1EC7n g\xEC x\u1EA3y ra n\xEAu sta th\u1EED s\u1EED d\u1EE5ng gi\xE1 tr\u1ECB d\u1EF1 \u0111o\xE1n th\u1EF1c c\u1EE7a m\xF4 h\xECnh \u0111\u1EC3 t\xEDnh ra \u0111i\u1EC3m s\u1ED1 th\u1EF1c."),U.forEach(e),f=p(T),$=c(T,"P",{});var L=r($);O=a(L,"TensorFlow kh\xF4ng gi\u1ED1ng nh\u01B0 vi\u1EC7c n\u1ED1i c\xE1c d\u1EF1 \u0111o\xE1n c\u1EE7a ch\xFAng ta l\u1EA1i v\u1EDBi nhau, b\u1EDFi v\xEC ch\xFAng c\xF3 \u0111\u1ED9 d\xE0i chu\u1ED7i thay \u0111\u1ED5i. \u0110i\u1EC1u n\xE0y c\xF3 ngh\u0129a l\xE0 ch\xFAng ta kh\xF4ng th\u1EC3 ch\u1EC9 s\u1EED d\u1EE5ng "),k=c(L,"CODE",{});var K=r(k);j=a(K,"model.predict()"),K.forEach(e),q=a(L," \u2014  h\u01B0ng \u0111i\u1EC1u \u0111\xF3 s\u1EBD kh\xF4ng ng\u0103n c\u1EA3n ch\xFAng ta. Ch\xFAng ta s\u1EBD nh\u1EADn \u0111\u01B0\u1EE3c m\u1ED9t s\u1ED1 d\u1EF1 \u0111o\xE1n t\u1EA1i m\u1ED9t th\u1EDDi \u0111i\u1EC3m v\xE0 n\u1ED1i ch\xFAng th\xE0nh m\u1ED9t danh s\xE1ch d\xE0i l\u1EDBn khi ti\u1EBFp t\u1EE5c, b\u1ECF c\xE1c token "),D=c(L,"CODE",{});var nn=r(D);z=a(nn,"-100"),nn.forEach(e),I=a(L," t\u01B0\u01A1ng \u1EE9ng b\u1ECB \u1EA9n \u0111i ho\u1EB7c \u0111\u1EC7m, sau \u0111\xF3 t\xEDnh to\xE1n c\xE1c s\u1ED1 li\u1EC7u tr\xEAn danh s\xE1ch \u1EDF cu\u1ED1i:"),L.forEach(e),A=p(T),w(N.$$.fragment,T),V=p(T),w(B.$$.fragment,T),R=p(T),F=c(T,"P",{});var an=r(F);M=a(an,"M\xF4 h\xECnh c\u1EE7a b\u1EA1n \u0111\xE3 l\xE0m nh\u01B0 th\u1EBF n\xE0o, so v\u1EDBi m\xF4 h\xECnh c\u1EE7a ch\xFAng t\xF4i? N\u1EBFu b\u1EA1n c\xF3 nh\u1EEFng con s\u1ED1 t\u01B0\u01A1ng t\u1EF1, kh\xF3a \u0111\xE0o t\u1EA1o c\u1EE7a b\u1EA1n \u0111\xE3 th\xE0nh c\xF4ng!"),an.forEach(e)},m(T,U){i(T,m,U),n(m,v),i(T,f,U),i(T,$,U),n($,O),n($,k),n(k,j),n($,q),n($,D),n(D,z),n($,I),i(T,A,U),x(N,T,U),i(T,V,U),x(B,T,U),i(T,R,U),i(T,F,U),n(F,M),W=!0},i(T){W||(_(N.$$.fragment,T),_(B.$$.fragment,T),W=!0)},o(T){b(N.$$.fragment,T),b(B.$$.fragment,T),W=!1},d(T){T&&e(m),T&&e(f),T&&e($),T&&e(A),C(N,T),T&&e(V),C(B,T),T&&e(R),T&&e(F)}}}function Zu(X){let m,v,f,$,O,k,j,q,D,z,I,A,N,V,B,R,F,M,W,T,U,L,K,nn,an,ln,Z,un,Q;return W=new P({props:{code:`import numpy as np


def compute_metrics(eval_preds):
    logits, labels = eval_preds
    predictions = np.argmax(logits, axis=-1)

    # Xo\xE1 nh\u1EEFng ch\u1EC9 m\u1EE5c b\u1ECB ng\xF3 l\u01A1 (token \u0111\u1EB7c bi\u1EC7t) v\xE0 chuy\u1EC3n ch\xFAng th\xE0nh nh\xE3n
    true_labels = [[label_names[l] for l in label if l != -100] for label in labels]
    true_predictions = [
        [label_names[p] for (p, l) in zip(prediction, label) if l != -100]
        for prediction, label in zip(predictions, labels)
    ]
    all_metrics = metric.compute(predictions=true_predictions, references=true_labels)
    return {
        "precision": all_metrics["overall_precision"],
        "recall": all_metrics["overall_recall"],
        "f1": all_metrics["overall_f1"],
        "accuracy": all_metrics["overall_accuracy"],
    }`,highlighted:`<span class="hljs-keyword">import</span> numpy <span class="hljs-keyword">as</span> np


<span class="hljs-keyword">def</span> <span class="hljs-title function_">compute_metrics</span>(<span class="hljs-params">eval_preds</span>):
    logits, labels = eval_preds
    predictions = np.argmax(logits, axis=-<span class="hljs-number">1</span>)

    <span class="hljs-comment"># Xo\xE1 nh\u1EEFng ch\u1EC9 m\u1EE5c b\u1ECB ng\xF3 l\u01A1 (token \u0111\u1EB7c bi\u1EC7t) v\xE0 chuy\u1EC3n ch\xFAng th\xE0nh nh\xE3n</span>
    true_labels = [[label_names[l] <span class="hljs-keyword">for</span> l <span class="hljs-keyword">in</span> label <span class="hljs-keyword">if</span> l != -<span class="hljs-number">100</span>] <span class="hljs-keyword">for</span> label <span class="hljs-keyword">in</span> labels]
    true_predictions = [
        [label_names[p] <span class="hljs-keyword">for</span> (p, l) <span class="hljs-keyword">in</span> <span class="hljs-built_in">zip</span>(prediction, label) <span class="hljs-keyword">if</span> l != -<span class="hljs-number">100</span>]
        <span class="hljs-keyword">for</span> prediction, label <span class="hljs-keyword">in</span> <span class="hljs-built_in">zip</span>(predictions, labels)
    ]
    all_metrics = metric.compute(predictions=true_predictions, references=true_labels)
    <span class="hljs-keyword">return</span> {
        <span class="hljs-string">&quot;precision&quot;</span>: all_metrics[<span class="hljs-string">&quot;overall_precision&quot;</span>],
        <span class="hljs-string">&quot;recall&quot;</span>: all_metrics[<span class="hljs-string">&quot;overall_recall&quot;</span>],
        <span class="hljs-string">&quot;f1&quot;</span>: all_metrics[<span class="hljs-string">&quot;overall_f1&quot;</span>],
        <span class="hljs-string">&quot;accuracy&quot;</span>: all_metrics[<span class="hljs-string">&quot;overall_accuracy&quot;</span>],
    }`}}),{c(){m=h("p"),v=s("\u0110i\u1EC1u n\xE0y \u0111ang g\u1EEDi l\u1EA1i r\u1EA5t nhi\u1EC1u th\xF4ng tin! Ch\xFAng ta nh\u1EADn \u0111\u01B0\u1EE3c precision, recall, v\xE0 \u0111i\u1EC3m F1 cho t\u1EEBng th\u1EF1c th\u1EC3 ri\xEAng bi\u1EC7t, c\u0169ng nh\u01B0 t\u1ED5ng th\u1EC3. \u0110\u1ED1i v\u1EDBi t\xEDnh to\xE1n s\u1ED1 li\u1EC7u c\u1EE7a m\xECnh, ch\xFAng ta s\u1EBD ch\u1EC9 gi\u1EEF l\u1EA1i \u0111i\u1EC3m t\u1ED5ng th\u1EC3, nh\u01B0ng h\xE3y tinh ch\u1EC9nh ch\u1EE9c n\u0103ng "),f=h("code"),$=s("compute_metrics()"),O=s(" \u0111\u1EC3 tr\u1EA3 v\u1EC1 t\u1EA5t c\u1EA3 c\xE1c s\u1ED1 li\u1EC7u b\u1EA1n mu\u1ED1n b\xE1o c\xE1o."),k=o(),j=h("p"),q=s("H\xE0m "),D=h("code"),z=s("compute_metrics()"),I=s(" n\xE0y tr\u01B0\u1EDBc ti\xEAn l\u1EA5y argmax c\u1EE7a logits \u0111\u1EC3 chuy\u1EC3n ch\xFAng th\xE0nh c\xE1c d\u1EF1 \u0111o\xE1n (nh\u01B0 th\u01B0\u1EDDng l\u1EC7, logits v\xE0 x\xE1c su\u1EA5t theo c\xF9ng m\u1ED9t th\u1EE9 t\u1EF1, v\xEC v\u1EADy ch\xFAng ta kh\xF4ng c\u1EA7n \xE1p d\u1EE5ng softmax). Sau \u0111\xF3, ch\xFAng ta ph\u1EA3i chuy\u1EC3n \u0111\u1ED5i c\u1EA3 nh\xE3n v\xE0 d\u1EF1 \u0111o\xE1n t\u1EEB s\u1ED1 nguy\xEAn sang chu\u1ED7i. Ch\xFAng ta x\xF3a t\u1EA5t c\u1EA3 c\xE1c gi\xE1 tr\u1ECB c\xF3 nh\xE3n l\xE0 "),A=h("code"),N=s("-100"),V=s(", sau \u0111\xF3 chuy\u1EC3n k\u1EBFt qu\u1EA3 \u0111\u1EBFn ph\u01B0\u01A1ng th\u1EE9c "),B=h("code"),R=s("metric.compute()"),F=s(":"),M=o(),E(W.$$.fragment),T=o(),U=h("p"),L=s("B\xE2y gi\u1EDD \u0111i\u1EC1u n\xE0y \u0111\xE3 \u0111\u01B0\u1EE3c th\u1EF1c hi\u1EC7n, ch\xFAng ta g\u1EA7n nh\u01B0 \u0111\xE3 s\u1EB5n s\xE0ng \u0111\u1EC3 x\xE1c \u0111\u1ECBnh "),K=h("code"),nn=s("Trainer"),an=s(" c\u1EE7a m\xECnh. Ch\xFAng ta ch\u1EC9 c\u1EA7n m\u1ED9t "),ln=h("code"),Z=s("model"),un=s("  \u0111\u1EC3 tinh ch\u1EC9nh!")},l(G){m=c(G,"P",{});var H=r(m);v=a(H,"\u0110i\u1EC1u n\xE0y \u0111ang g\u1EEDi l\u1EA1i r\u1EA5t nhi\u1EC1u th\xF4ng tin! Ch\xFAng ta nh\u1EADn \u0111\u01B0\u1EE3c precision, recall, v\xE0 \u0111i\u1EC3m F1 cho t\u1EEBng th\u1EF1c th\u1EC3 ri\xEAng bi\u1EC7t, c\u0169ng nh\u01B0 t\u1ED5ng th\u1EC3. \u0110\u1ED1i v\u1EDBi t\xEDnh to\xE1n s\u1ED1 li\u1EC7u c\u1EE7a m\xECnh, ch\xFAng ta s\u1EBD ch\u1EC9 gi\u1EEF l\u1EA1i \u0111i\u1EC3m t\u1ED5ng th\u1EC3, nh\u01B0ng h\xE3y tinh ch\u1EC9nh ch\u1EE9c n\u0103ng "),f=c(H,"CODE",{});var en=r(f);$=a(en,"compute_metrics()"),en.forEach(e),O=a(H," \u0111\u1EC3 tr\u1EA3 v\u1EC1 t\u1EA5t c\u1EA3 c\xE1c s\u1ED1 li\u1EC7u b\u1EA1n mu\u1ED1n b\xE1o c\xE1o."),H.forEach(e),k=p(G),j=c(G,"P",{});var mn=r(j);q=a(mn,"H\xE0m "),D=c(mn,"CODE",{});var kn=r(D);z=a(kn,"compute_metrics()"),kn.forEach(e),I=a(mn," n\xE0y tr\u01B0\u1EDBc ti\xEAn l\u1EA5y argmax c\u1EE7a logits \u0111\u1EC3 chuy\u1EC3n ch\xFAng th\xE0nh c\xE1c d\u1EF1 \u0111o\xE1n (nh\u01B0 th\u01B0\u1EDDng l\u1EC7, logits v\xE0 x\xE1c su\u1EA5t theo c\xF9ng m\u1ED9t th\u1EE9 t\u1EF1, v\xEC v\u1EADy ch\xFAng ta kh\xF4ng c\u1EA7n \xE1p d\u1EE5ng softmax). Sau \u0111\xF3, ch\xFAng ta ph\u1EA3i chuy\u1EC3n \u0111\u1ED5i c\u1EA3 nh\xE3n v\xE0 d\u1EF1 \u0111o\xE1n t\u1EEB s\u1ED1 nguy\xEAn sang chu\u1ED7i. Ch\xFAng ta x\xF3a t\u1EA5t c\u1EA3 c\xE1c gi\xE1 tr\u1ECB c\xF3 nh\xE3n l\xE0 "),A=c(mn,"CODE",{});var sn=r(A);N=a(sn,"-100"),sn.forEach(e),V=a(mn,", sau \u0111\xF3 chuy\u1EC3n k\u1EBFt qu\u1EA3 \u0111\u1EBFn ph\u01B0\u01A1ng th\u1EE9c "),B=c(mn,"CODE",{});var Bn=r(B);R=a(Bn,"metric.compute()"),Bn.forEach(e),F=a(mn,":"),mn.forEach(e),M=p(G),w(W.$$.fragment,G),T=p(G),U=c(G,"P",{});var Y=r(U);L=a(Y,"B\xE2y gi\u1EDD \u0111i\u1EC1u n\xE0y \u0111\xE3 \u0111\u01B0\u1EE3c th\u1EF1c hi\u1EC7n, ch\xFAng ta g\u1EA7n nh\u01B0 \u0111\xE3 s\u1EB5n s\xE0ng \u0111\u1EC3 x\xE1c \u0111\u1ECBnh "),K=c(Y,"CODE",{});var at=r(K);nn=a(at,"Trainer"),at.forEach(e),an=a(Y," c\u1EE7a m\xECnh. Ch\xFAng ta ch\u1EC9 c\u1EA7n m\u1ED9t "),ln=c(Y,"CODE",{});var on=r(ln);Z=a(on,"model"),on.forEach(e),un=a(Y,"  \u0111\u1EC3 tinh ch\u1EC9nh!"),Y.forEach(e)},m(G,H){i(G,m,H),n(m,v),n(m,f),n(f,$),n(m,O),i(G,k,H),i(G,j,H),n(j,q),n(j,D),n(D,z),n(j,I),n(j,A),n(A,N),n(j,V),n(j,B),n(B,R),n(j,F),i(G,M,H),x(W,G,H),i(G,T,H),i(G,U,H),n(U,L),n(U,K),n(K,nn),n(U,an),n(U,ln),n(ln,Z),n(U,un),Q=!0},i(G){Q||(_(W.$$.fragment,G),Q=!0)},o(G){b(W.$$.fragment,G),Q=!1},d(G){G&&e(m),G&&e(k),G&&e(j),G&&e(M),C(W,G),G&&e(T),G&&e(U)}}}function xu(X){let m,v,f,$,O,k,j,q,D,z,I,A,N,V,B,R,F,M,W,T,U,L,K,nn,an,ln,Z,un,Q,G,H,en,mn,kn,sn,Bn,Y,at,on,ft,le,lt,Qe,It,he,bn,De,En,gn,Vn,ce,tn,pn,re,Sn,Mt,ie,Je,Un,In,Lt,oe,Ht,Te,yn,wn,Rt,$n,bs,Ft,Xn,Pe,cn,Gt,Wn,dt,vs,_t,bt,ns,xn,Cn,pe,J,Vt,vt,Kn,ts,On,ks,ze,ht,Ae,es,kt,Mn,yt,Ne,$t,ys,ss,Zn,jt,fn,Et,Yn,ct,wt,rt,Ut,$s,as,it,Xt,Be,qn,ls,xt,Qn,Jn,ue,Wt,Kt,me,vn,Se,Dn,g,S,ge,js,Zt,Tn,Es,fe,Ct,rn,oa,Yt,Ot,Ln,de,_e,hs,be,pa,ws,ot,ua,Ie,nt,ma,xs,pt,dn,Me,tt,Le,Hn,et,He,Rn,ga,Qt,fa,da,Re,st,_a,Cs,Ah,Nh,Vl,Pn,ba,va,Bh,ka,Os,Ul,qt,Sh,hl,cl,Ih,rl,Mh,Dt,ya,qs,Xl,ve,Lh,il,ol,Hh,Wl,Fe,Kl,Ds,Zl,_n,pl,ul,Rh,ml,gl,Fh,fl,Yl,Ts,$a,Tt,Gh,dl,Pt,_l,bl,Vh,vl,kl,Uh,yl,Ql,Ps,ja,zs,Jl,As,Ea,nh,cs,rs,Jt,Ns,wa,ke,Xh,Bs,Wh,Kh,xa,Ge,is,Ca,ne,th,zt,Zh,Oa,ye,Yh,Ss,Qh,Jh,qa,os,eh,$e,At,Da,je,nc,Ta,Ee,ps,Is,Pa,we,tc,za,ut,ec,Ms,sc,ac,Aa,us,lc,Ls,hc,cc,Na,Hs,sh,zn,Ve,$l,jl,rc,Rs,El,ic,Fs,ah,Ba,wl,lh,Gs,Sa,Ia,oc,xl,te,Cl,hn,hh,Nt,pc,Ol,ql,uc,Dl,Tl,mc,ch,Ue,rh,Vs,Ma,An,gc,Us,fc,dc,Xs,_c,bc,La,xe,vc,Ws,kc,yc,Xe,Pl,$c,ih,We;return $=new St({}),Z=new P({props:{code:`id2label = {i: label for i, label in enumerate(label_names)}
label2id = {v: k for k, v in id2label.items()}`,highlighted:`id2label = {i: label <span class="hljs-keyword">for</span> i, label <span class="hljs-keyword">in</span> <span class="hljs-built_in">enumerate</span>(label_names)}
label2id = {v: k <span class="hljs-keyword">for</span> k, v <span class="hljs-keyword">in</span> id2label.items()}`}}),sn=new P({props:{code:`from transformers import AutoModelForTokenClassification

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

model = AutoModelForTokenClassification.from_pretrained(
    model_checkpoint,
    id2label=id2label,
    label2id=label2id,
)`}}),bn=new P({props:{code:"model.config.num_labels",highlighted:"model.config.num_labels"}}),En=new P({props:{code:"9",highlighted:'<span class="hljs-number">9</span>'}}),Vn=new zh({props:{warning:!0,$$slots:{default:[Yu]},$$scope:{ctx:X}}}),Sn=new St({}),wn=new P({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()`}}),Gt=new P({props:{code:"huggingface-cli login",highlighted:"huggingface-cli login"}}),Cn=new P({props:{code:`from transformers import TrainingArguments

args = TrainingArguments(
    "bert-finetuned-ner",
    evaluation_strategy="epoch",
    save_strategy="epoch",
    learning_rate=2e-5,
    num_train_epochs=3,
    weight_decay=0.01,
    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-ner&quot;</span>,
    evaluation_strategy=<span class="hljs-string">&quot;epoch&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>,
    push_to_hub=<span class="hljs-literal">True</span>,
)`}}),Yn=new zh({props:{$$slots:{default:[Qu]},$$scope:{ctx:X}}}),Xt=new P({props:{code:`from transformers import Trainer

trainer = Trainer(
    model=model,
    args=args,
    train_dataset=tokenized_datasets["train"],
    eval_dataset=tokenized_datasets["validation"],
    data_collator=data_collator,
    compute_metrics=compute_metrics,
    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=tokenized_datasets[<span class="hljs-string">&quot;train&quot;</span>],
    eval_dataset=tokenized_datasets[<span class="hljs-string">&quot;validation&quot;</span>],
    data_collator=data_collator,
    compute_metrics=compute_metrics,
    tokenizer=tokenizer,
)
trainer.train()`}}),vn=new P({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>)'}}),ge=new P({props:{code:"'https://huggingface.co/sgugger/bert-finetuned-ner/commit/26ab21e5b1568f9afeccdaed2d8715f571d786ed'",highlighted:'<span class="hljs-string">&#x27;https://huggingface.co/sgugger/bert-finetuned-ner/commit/26ab21e5b1568f9afeccdaed2d8715f571d786ed&#x27;</span>'}}),_e=new St({}),tt=new St({}),Pn=new P({props:{code:`from torch.utils.data import DataLoader

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

train_dataloader = DataLoader(
    tokenized_datasets[<span class="hljs-string">&quot;train&quot;</span>],
    shuffle=<span class="hljs-literal">True</span>,
    collate_fn=data_collator,
    batch_size=<span class="hljs-number">8</span>,
)
eval_dataloader = DataLoader(
    tokenized_datasets[<span class="hljs-string">&quot;validation&quot;</span>], collate_fn=data_collator, batch_size=<span class="hljs-number">8</span>
)`}}),Os=new P({props:{code:`model = AutoModelForTokenClassification.from_pretrained(
    model_checkpoint,
    id2label=id2label,
    label2id=label2id,
)`,highlighted:`model = AutoModelForTokenClassification.from_pretrained(
    model_checkpoint,
    id2label=id2label,
    label2id=label2id,
)`}}),qs=new P({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>)`}}),Fe=new P({props:{code:`from accelerate import Accelerator

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

accelerator = Accelerator()
model, optimizer, train_dataloader, eval_dataloader = accelerator.prepare(
    model, optimizer, train_dataloader, eval_dataloader
)`}}),Ds=new zh({props:{$$slots:{default:[Ju]},$$scope:{ctx:X}}}),Ts=new P({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,
)`}}),Ps=new P({props:{code:`from huggingface_hub import Repository, get_full_repo_name

model_name = "bert-finetuned-ner-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-ner-accelerate&quot;</span>
repo_name = get_full_repo_name(model_name)
repo_name`}}),zs=new P({props:{code:"'sgugger/bert-finetuned-ner-accelerate'",highlighted:'<span class="hljs-string">&#x27;sgugger/bert-finetuned-ner-accelerate&#x27;</span>'}}),cs=new P({props:{code:`output_dir = "bert-finetuned-ner-accelerate"
repo = Repository(output_dir, clone_from=repo_name)`,highlighted:`output_dir = <span class="hljs-string">&quot;bert-finetuned-ner-accelerate&quot;</span>
repo = Repository(output_dir, clone_from=repo_name)`}}),ne=new St({}),At=new P({props:{code:`def postprocess(predictions, labels):
    predictions = predictions.detach().cpu().clone().numpy()
    labels = labels.detach().cpu().clone().numpy()

    # Lo\u1EA1i b\u1ECF c\xE1c ch\u1EC9 m\u1EE5c b\u1ECB ng\xF3 l\u01A1 (c\xE1c token \u0111\u1EB7c bi\u1EC7t) v\xE0 chuy\u1EC3n ch\xFAng th\xE0nh nh\xE3n
    true_labels = [[label_names[l] for l in label if l != -100] for label in labels]
    true_predictions = [
        [label_names[p] for (p, l) in zip(prediction, label) if l != -100]
        for prediction, label in zip(predictions, labels)
    ]
    return true_labels, true_predictions`,highlighted:`<span class="hljs-keyword">def</span> <span class="hljs-title function_">postprocess</span>(<span class="hljs-params">predictions, labels</span>):
    predictions = predictions.detach().cpu().clone().numpy()
    labels = labels.detach().cpu().clone().numpy()

    <span class="hljs-comment"># Lo\u1EA1i b\u1ECF c\xE1c ch\u1EC9 m\u1EE5c b\u1ECB ng\xF3 l\u01A1 (c\xE1c token \u0111\u1EB7c bi\u1EC7t) v\xE0 chuy\u1EC3n ch\xFAng th\xE0nh nh\xE3n</span>
    true_labels = [[label_names[l] <span class="hljs-keyword">for</span> l <span class="hljs-keyword">in</span> label <span class="hljs-keyword">if</span> l != -<span class="hljs-number">100</span>] <span class="hljs-keyword">for</span> label <span class="hljs-keyword">in</span> labels]
    true_predictions = [
        [label_names[p] <span class="hljs-keyword">for</span> (p, l) <span class="hljs-keyword">in</span> <span class="hljs-built_in">zip</span>(prediction, label) <span class="hljs-keyword">if</span> l != -<span class="hljs-number">100</span>]
        <span class="hljs-keyword">for</span> prediction, label <span class="hljs-keyword">in</span> <span class="hljs-built_in">zip</span>(predictions, labels)
    ]
    <span class="hljs-keyword">return</span> true_labels, true_predictions`}}),Gs=new P({props:{code:`from tqdm.auto import tqdm
import torch

progress_bar = tqdm(range(num_training_steps))

for epoch in range(num_train_epochs):
    # Hu\u1EA5n luy\u1EC7n
    model.train()
    for batch in train_dataloader:
        outputs = model(**batch)
        loss = outputs.loss
        accelerator.backward(loss)

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

    # \u0110\xE1nh gi\xE1
    model.eval()
    for batch in eval_dataloader:
        with torch.no_grad():
            outputs = model(**batch)

        predictions = outputs.logits.argmax(dim=-1)
        labels = batch["labels"]

        # C\u1EA7n \u0111\u1EC7m c\xE1c d\u1EF1 \u0111o\xE1n v\xE0 nh\xE3n \u0111\u1EC3 t\u1EADp h\u1EE3p
        predictions = accelerator.pad_across_processes(predictions, dim=1, pad_index=-100)
        labels = accelerator.pad_across_processes(labels, dim=1, pad_index=-100)

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

        true_predictions, true_labels = postprocess(predictions_gathered, labels_gathered)
        metric.add_batch(predictions=true_predictions, references=true_labels)

    results = metric.compute()
    print(
        f"epoch {epoch}:",
        {
            key: results[f"overall_{key}"]
            for key in ["precision", "recall", "f1", "accuracy"]
        },
    )

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

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

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

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

    <span class="hljs-comment"># \u0110\xE1nh gi\xE1</span>
    model.<span class="hljs-built_in">eval</span>()
    <span class="hljs-keyword">for</span> batch <span class="hljs-keyword">in</span> eval_dataloader:
        <span class="hljs-keyword">with</span> torch.no_grad():
            outputs = model(**batch)

        predictions = outputs.logits.argmax(dim=-<span class="hljs-number">1</span>)
        labels = batch[<span class="hljs-string">&quot;labels&quot;</span>]

        <span class="hljs-comment"># C\u1EA7n \u0111\u1EC7m c\xE1c d\u1EF1 \u0111o\xE1n v\xE0 nh\xE3n \u0111\u1EC3 t\u1EADp h\u1EE3p</span>
        predictions = accelerator.pad_across_processes(predictions, dim=<span class="hljs-number">1</span>, pad_index=-<span class="hljs-number">100</span>)
        labels = accelerator.pad_across_processes(labels, dim=<span class="hljs-number">1</span>, pad_index=-<span class="hljs-number">100</span>)

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

        true_predictions, true_labels = postprocess(predictions_gathered, labels_gathered)
        metric.add_batch(predictions=true_predictions, references=true_labels)

    results = metric.compute()
    <span class="hljs-built_in">print</span>(
        <span class="hljs-string">f&quot;epoch <span class="hljs-subst">{epoch}</span>:&quot;</span>,
        {
            key: results[<span class="hljs-string">f&quot;overall_<span class="hljs-subst">{key}</span>&quot;</span>]
            <span class="hljs-keyword">for</span> key <span class="hljs-keyword">in</span> [<span class="hljs-string">&quot;precision&quot;</span>, <span class="hljs-string">&quot;recall&quot;</span>, <span class="hljs-string">&quot;f1&quot;</span>, <span class="hljs-string">&quot;accuracy&quot;</span>]
        },
    )

    <span class="hljs-comment"># L\u01B0u v\xE0 t\u1EA3i</span>
    accelerator.wait_for_everyone()
    unwrapped_model = accelerator.unwrap_model(model)
    unwrapped_model.save_pretrained(output_dir, save_function=accelerator.save)
    <span class="hljs-keyword">if</span> accelerator.is_main_process:
        tokenizer.save_pretrained(output_dir)
        repo.push_to_hub(
            commit_message=<span class="hljs-string">f&quot;Training in progress epoch <span class="hljs-subst">{epoch}</span>&quot;</span>, blocking=<span class="hljs-literal">False</span>
        )`}}),te=new P({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(){m=h("h3"),v=h("a"),f=h("span"),E($.$$.fragment),O=o(),k=h("span"),j=s("\u0110\u1ECBnh ngh\u0129a m\xF4 h\xECnh"),q=o(),D=h("p"),z=s("V\xEC ch\xFAng ta \u0111ang gi\u1EA3i quy\u1EBFt v\u1EA5n \u0111\u1EC1 ph\xE2n lo\u1EA1i token, ch\xFAng ta s\u1EBD s\u1EED d\u1EE5ng l\u1EDBp "),I=h("code"),A=s("AutoModelForTokenClassification"),N=s(". \u0110i\u1EC1u ch\xEDnh c\u1EA7n nh\u1EDB khi x\xE1c \u0111\u1ECBnh m\xF4 h\xECnh n\xE0y l\xE0 truy\u1EC1n m\u1ED9t s\u1ED1 th\xF4ng tin v\u1EC1 s\u1ED1 l\u01B0\u1EE3ng nh\xE3n m\xE0 ch\xFAng ta c\xF3. C\xE1ch d\u1EC5 nh\u1EA5t \u0111\u1EC3 l\xE0m \u0111i\u1EC1u n\xE0y l\xE0 truy\u1EC1n v\xE0o tham s\u1ED1 "),V=h("code"),B=s("num_labels"),R=s(", nh\u01B0ng n\u1EBFu ch\xFAng ta mu\u1ED1n m\u1ED9t ti\u1EC7n \xEDch lu\u1EADn suy ho\u1EA1t \u0111\u1ED9ng gi\u1ED1ng nh\u01B0 ti\u1EC7n \xEDch ch\xFAng ta \u0111\xE3 th\u1EA5y \u1EDF \u0111\u1EA7u ph\u1EA7n n\xE0y, t\u1ED1t h\u01A1n n\xEAn \u0111\u1EB7t c\xE1c nh\xE3n t\u01B0\u01A1ng \u1EE9ng ch\xEDnh x\xE1c thay th\u1EBF."),F=o(),M=h("p"),W=s("Ch\xFAng ph\u1EA3i \u0111\u01B0\u1EE3c \u0111\u1EB7t b\u1EDFi hai t\u1EEB \u0111i\u1EC3n, "),T=h("code"),U=s("id2label"),L=s(" v\xE0 "),K=h("code"),nn=s("label2id"),an=s(", ch\u1EE9a c\xE1c \xE1nh x\u1EA1 t\u1EEB ID \u0111\u1EBFn nh\xE3n v\xE0 ng\u01B0\u1EE3c l\u1EA1i:"),ln=o(),E(Z.$$.fragment),un=o(),Q=h("p"),G=s("Gi\u1EDD ta c\xF3 th\u1EC3 truy\u1EC1n ch\xFAng v\xE0o ph\u01B0\u01A1ng th\u1EE9c "),H=h("code"),en=s("AutoModelForTokenClassification.from_pretrained()"),mn=s(", v\xE0 ch\xFAng s\u1EBD \u0111\u01B0\u1EE3c thi\u1EBFt l\u1EADp trong c\u1EA5u h\xECnh m\xF4 h\xECnh v\xE0 sau \u0111\xF3 \u0111\u01B0\u1EE3c l\u01B0u v\u1EA3 t\u1EA3i l\xEAn Hub:"),kn=o(),E(sn.$$.fragment),Bn=o(),Y=h("p"),at=s("Gi\u1ED1ng nh\u01B0 khi ch\xFAng t\xF4i \u0111\u1ECBnh ngh\u0129a "),on=h("code"),ft=s("AutoModelForSequenceClassification"),le=s(" c\u1EE7a m\xECnh trong "),lt=h("a"),Qe=s("Ch\u01B0\u01A1ng 3"),It=s(", vi\u1EC7c t\u1EA1o m\xF4 h\xECnh \u0111\u01B0a ra c\u1EA3nh b\xE1o r\u1EB1ng m\u1ED9t s\u1ED1 tr\u1ECDng s\u1ED1 kh\xF4ng \u0111\u01B0\u1EE3c s\u1EED d\u1EE5ng (nh\u1EEFng tr\u1ECDng s\u1ED1 t\u1EEB \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 (nh\u1EEFng tr\u1ECDng s\u1ED1 t\u1EEB \u0111\u1EA7u ph\xE2n lo\u1EA1i token m\u1EDBi) v\xE0 m\xF4 h\xECnh n\xE0y n\xEAn \u0111\u01B0\u1EE3c hu\u1EA5n luy\u1EC7n. Ch\xFAng ta s\u1EBD l\xE0m \u0111i\u1EC1u \u0111\xF3 sau m\u1ED9t ph\xFAt, nh\u01B0ng tr\u01B0\u1EDBc ti\xEAn h\xE3y ki\u1EC3m tra k\u1EF9 xem m\xF4 h\xECnh c\u1EE7a ch\xFAng ta c\xF3 \u0111\xFAng s\u1ED1 l\u01B0\u1EE3ng nh\xE3n hay kh\xF4ng:"),he=o(),E(bn.$$.fragment),De=o(),E(En.$$.fragment),gn=o(),E(Vn.$$.fragment),ce=o(),tn=h("h3"),pn=h("a"),re=h("span"),E(Sn.$$.fragment),Mt=o(),ie=h("span"),Je=s("Tinh ch\u1EC9nh m\xF4 h\xECnh"),Un=o(),In=h("p"),Lt=s("Gi\u1EDD ta \u0111\xE3 s\u1EB5n s\xE0ng \u0111\u1EC3 hu\u1EA5n luy\u1EC7n m\xF4 h\xECnh c\u1EE7a m\xECnh! Ch\xFAng ta ch\u1EC9 c\u1EA7n l\xE0m hai \u0111i\u1EC1u tr\u01B0\u1EDBc khi \u0111\u1ECBnh ngh\u0129a "),oe=h("code"),Ht=s("Trainer"),Te=s(":  \u0111\u0103ng nh\u1EADp v\xE0o Hugging Face v\xE0 \u0111\u1ECBnh ngh\u0129a c\xE1c tham s\u1ED1 hu\u1EA5n luy\u1EC7n. N\u1EBFu b\u1EA1n \u0111ang l\xE0m vi\u1EC7c v\u1EDBi notebook, c\xF3 m\u1ED9t h\xE0m thu\u1EADn ti\u1EC7n c\xF3 th\u1EC3 gi\xFAp b\u1EA1n:"),yn=o(),E(wn.$$.fragment),Rt=o(),$n=h("p"),bs=s("Thao t\xE1c n\xE0y s\u1EBD hi\u1EC3n th\u1ECB m\u1ED9t ti\u1EC7n \xEDch m\xE0 b\u1EA1n c\xF3 th\u1EC3 nh\u1EADp th\xF4ng tin \u0111\u0103ng nh\u1EADp Hugging Facec\u1EE7a m\xECnh."),Ft=o(),Xn=h("p"),Pe=s("N\u1EBFu b\u1EA1n kh\xF4ng l\xE0m vi\u1EC7c trong s\u1ED5 ghi ch\xE9p, ch\u1EC9 c\u1EA7n nh\u1EADp d\xF2ng sau v\xE0o thi\u1EBFt b\u1ECB \u0111\u1EA7u cu\u1ED1i c\u1EE7a b\u1EA1n:"),cn=o(),E(Gt.$$.fragment),Wn=o(),dt=h("p"),vs=s("Once this is done, we can define our "),_t=h("code"),bt=s("TrainingArguments"),ns=s(":"),xn=o(),E(Cn.$$.fragment),pe=o(),J=h("p"),Vt=s("B\u1EA1n \u0111\xE3 t\u1EEBng th\u1EA5y h\u1EA7u h\u1EBFt nh\u1EEFng \u0111i\u1EC1u \u0111\xF3 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 c\u1EA7n luy\u1EC7n t\u1EADp v\xE0 gi\u1EA3m tr\u1ECDng l\u01B0\u1EE3ng) v\xE0 ch\xFAng ta ch\u1EC9 \u0111\u1ECBnh "),vt=h("code"),Kn=s("push_to_hub=True"),ts=s(" \u0111\u1EC3 ch\u1EC9 ra r\u1EB1ng ch\xFAng ta mu\u1ED1n l\u01B0u m\xF4 h\xECnh v\xE0 \u0111\xE1nh gi\xE1 n\xF3 v\xE0o cu\u1ED1i m\u1ED7i epoch v\xE0 r\u1EB1ng ch\xFAng ta mu\u1ED1n t\u1EA3i k\u1EBFt qu\u1EA3 c\u1EE7a m\xECnh l\xEAn Model Hub. L\u01B0u \xFD r\u1EB1ng b\u1EA1n c\xF3 th\u1EC3 ch\u1EC9 \u0111\u1ECBnh t\xEAn c\u1EE7a kho l\u01B0u tr\u1EEF m\xE0 b\u1EA1n mu\u1ED1n \u0111\u1EA9y \u0111\u1EBFn b\u1EB1ng tham s\u1ED1 "),On=h("code"),ks=s("hub_model_id"),ze=s(" (c\u1EE5 th\u1EC3 l\xE0 b\u1EA1n s\u1EBD ph\u1EA3i s\u1EED d\u1EE5ng tham s\u1ED1 n\xE0y \u0111\u1EC3 \u0111\u1EA9y \u0111\u1EBFn m\u1ED9t t\u1ED5 ch\u1EE9c). V\xED d\u1EE5: khi \u0111\u1EA9y m\xF4 h\xECnh v\xE0o t\u1ED5 ch\u1EE9c "),ht=h("a"),Ae=h("code"),es=s("huggingface-course"),kt=s(" ch\xFAng ta \u0111\xE3 th\xEAm "),Mn=h("code"),yt=s('hub_model_id="huggingface-course/bert-finetuned-ner"'),Ne=s(" v\xE0o "),$t=h("code"),ys=s("TrainingArguments"),ss=s(". Theo m\u1EB7c \u0111\u1ECBnh, kho l\u01B0u tr\u1EEF \u0111\u01B0\u1EE3c s\u1EED d\u1EE5ng s\u1EBD n\u1EB1m trong kh\xF4ng gian t\xEAn c\u1EE7a b\u1EA1n v\xE0 \u0111\u01B0\u1EE3c \u0111\u1EB7t t\xEAn theo th\u01B0 m\u1EE5c \u0111\u1EA7u ra m\xE0 b\u1EA1n \u0111\xE3 \u0111\u1EB7t, v\xEC v\u1EADy trong tr\u01B0\u1EDDng h\u1EE3p c\u1EE7a ch\xFAng t\xF4i, n\xF3 s\u1EBD l\xE0 "),Zn=h("code"),jt=s('"sgugger/bert-finetuned-ner"'),fn=s("."),Et=o(),E(Yn.$$.fragment),ct=o(),wt=h("p"),rt=s("Cu\u1ED1i c\xF9ng, ch\xFAng ta ch\u1EC9 c\u1EA7n truy\u1EC1n m\u1ECDi th\u1EE9 cho  "),Ut=h("code"),$s=s("Trainer"),as=s(" v\xE0 b\u1EAFt \u0111\u1EA7u hu\u1EA5n luy\u1EC7n:"),it=o(),E(Xt.$$.fragment),Be=o(),qn=h("p"),ls=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."),xt=o(),Qn=h("p"),Jn=s("Sau khi qu\xE1 tr\xECnh hu\u1EA5n luy\u1EC7n ho\xE0n t\u1EA5t, ch\xFAng ta s\u1EED d\u1EE5ng ph\u01B0\u01A1ng th\u1EE9c "),ue=h("code"),Wt=s("push_to_hub()"),Kt=s(" \u0111\u1EC3 \u0111\u1EA3m b\u1EA3o ch\xFAng ta t\u1EA3i l\xEAn phi\xEAn b\u1EA3n m\u1EDBi nh\u1EA5t c\u1EE7a m\xF4 h\xECnh:"),me=o(),E(vn.$$.fragment),Se=o(),Dn=h("p"),g=s("C\xE2u l\u1EC7nh n\xE0y tr\u1EA3 v\u1EC1 URL c\u1EE7a cam kh\u1EBFt n\xF3 v\u1EEBa l\xE0m, n\u1EBFu b\u1EA1n mu\u1ED1n ki\u1EC3m tra n\xF3:"),S=o(),E(ge.$$.fragment),js=o(),Zt=h("p"),Tn=h("code"),Es=s("Trainer"),fe=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. \u1EDE giai \u0111o\u1EA1n n\xE0y, b\u1EA1n c\xF3 th\u1EC3 s\u1EED d\u1EE5ng ti\u1EC7n \xEDch lu\u1EADn suy tr\xEAn Model Hub \u0111\u1EC3 ki\u1EC3m tra m\xF4 h\xECnh c\u1EE7a m\xECnh v\xE0 chia s\u1EBB v\u1EDBi b\u1EA1n b\xE8. B\u1EA1n \u0111\xE3 tinh ch\u1EC9nh th\xE0nh c\xF4ng m\u1ED9t m\xF4 h\xECnh trong t\xE1c v\u1EE5 ph\xE2n lo\u1EA1i token - xin ch\xFAc m\u1EEBng!"),Ct=o(),rn=h("p"),oa=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."),Yt=o(),Ot=h("h2"),Ln=h("a"),de=h("span"),E(_e.$$.fragment),hs=o(),be=h("span"),pa=s("M\u1ED9t v\xF2ng hu\u1EA5n luy\u1EC7n tu\u1EF3 ch\u1EC9nh"),ws=o(),ot=h("p"),ua=s("B\xE2y gi\u1EDD ch\xFAng ta h\xE3y xem to\xE0n b\u1ED9 v\xF2ng l\u1EB7p hu\u1EA5n luy\u1EC7n, v\xEC v\u1EADy b\u1EA1n c\xF3 th\u1EC3 d\u1EC5 d\xE0ng t\xF9y ch\u1EC9nh c\xE1c ph\u1EA7n b\u1EA1n c\u1EA7n. N\xF3 s\u1EBD tr\xF4ng r\u1EA5t gi\u1ED1ng nh\u1EEFng g\xEC ch\xFAng ta \u0111\xE3 l\xE0m trong "),Ie=h("a"),nt=s("Ch\u01B0\u01A1ng 3"),ma=s(", v\u1EDBi m\u1ED9t v\xE0i thay \u0111\u1ED5i cho ph\u1EA7n \u0111\xE1nh gi\xE1."),xs=o(),pt=h("h3"),dn=h("a"),Me=h("span"),E(tt.$$.fragment),Le=o(),Hn=h("span"),et=s("Chu\u1EA9n b\u1ECB m\u1ECDi th\u1EE9 \u0111\u1EC3 hu\u1EA5n luy\u1EC7n"),He=o(),Rn=h("p"),ga=s("\u0110\u1EA7u ti\xEAn, ch\xFAng ta c\u1EA7n x\xE2y d\u1EF1ng c\xE1c "),Qt=h("code"),fa=s("DataLoader"),da=s(" t\u1EEB c\xE1c t\u1EADp d\u1EEF li\u1EC7u c\u1EE7a m\xECnh. Ch\xFAng ta s\u1EBD s\u1EED d\u1EE5ng l\u1EA1i "),Re=h("code"),st=s("data_collator"),_a=s(" c\u1EE7a m\xECnh d\u01B0\u1EDBi d\u1EA1ng "),Cs=h("code"),Ah=s("collate_fn"),Nh=s(" v\xE0 x\xE1o tr\u1ED9n t\u1EADp hu\u1EA5n luy\u1EC7n, nh\u01B0ng kh\xF4ng ph\u1EA3i t\u1EADp ki\u1EC3m \u0111\u1ECBnh:"),Vl=o(),E(Pn.$$.fragment),ba=o(),va=h("p"),Bh=s("Ti\u1EBFp theo, ch\xFAng ta kh\xF4i ph\u1EE5c m\xF4 h\xECnh c\u1EE7a m\xECnh, \u0111\u1EC3 \u0111\u1EA3m b\u1EA3o r\u1EB1ng ch\xFAng ta kh\xF4ng ti\u1EBFp t\u1EE5c tinh ch\u1EC9nh t\u1EEB tr\u01B0\u1EDBc m\xE0 b\u1EAFt \u0111\u1EA7u l\u1EA1i t\u1EEB m\xF4 h\xECnh \u0111\u01B0\u1EE3c hu\u1EA5n luy\u1EC7n tr\u01B0\u1EDBc BERT:"),ka=o(),E(Os.$$.fragment),Ul=o(),qt=h("p"),Sh=s("Sau \u0111\xF3, ch\xFAng t\xF4i s\u1EBD c\u1EA7n m\u1ED9t tr\xECnh t\u1ED1i \u01B0u h\xF3a. Ch\xFAng ta s\u1EBD s\u1EED d\u1EE5ng "),hl=h("code"),cl=s("AdamW"),Ih=s(" c\u1ED5 \u0111i\u1EC3n, gi\u1ED1ng nh\u01B0 "),rl=h("code"),Mh=s("Adam"),Dt=s(", nh\u01B0ng v\u1EDBi m\u1ED9t b\u1EA3n s\u1EEDa l\u1ED7i trong c\xE1ch \xE1p d\u1EE5ng weight decay (ph\xE2n r\xE3 tr\u1ECDng s\u1ED1):"),ya=o(),E(qs.$$.fragment),Xl=o(),ve=h("p"),Lh=s("Once we have all those objects, we can send them to the "),il=h("code"),ol=s("accelerator.prepare()"),Hh=s(" method:"),Wl=o(),E(Fe.$$.fragment),Kl=o(),E(Ds.$$.fragment),Zl=o(),_n=h("p"),pl=s("B\xE2y gi\u1EDD, ch\xFAng ta \u0111\xE3 g\u1EEDi "),ul=h("code"),Rh=s("train_dataloader"),ml=s(" c\u1EE7a m\xECnh t\u1EDBi "),gl=h("code"),Fh=s("speedrator.prepare()"),fl=s(", ch\xFAng ta c\xF3 th\u1EC3 s\u1EED d\u1EE5ng \u0111\u1ED9 d\xE0i c\u1EE7a n\xF3 \u0111\u1EC3 t\xEDnh s\u1ED1 b\u01B0\u1EDBc hu\u1EA5n luy\u1EC7n. H\xE3y nh\u1EDB r\u1EB1ng ch\xFAng ta ph\u1EA3i lu\xF4n l\xE0m \u0111i\u1EC1u n\xE0y sau khi chu\u1EA9n b\u1ECB dataloader, v\xEC ph\u01B0\u01A1ng th\u1EE9c \u0111\xF3 s\u1EBD thay \u0111\u1ED5i \u0111\u1ED9 d\xE0i c\u1EE7a n\xF3. Ch\xFAng ta s\u1EED d\u1EE5ng m\u1ED9t l\u1ECBch tr\xECnh tuy\u1EBFn t\xEDnh c\u1ED5 \u0111i\u1EC3n t\u1EEB t\u1ED1c \u0111\u1ED9 h\u1ECDc \u0111\u1EBFn 0:"),Yl=o(),E(Ts.$$.fragment),$a=o(),Tt=h("p"),Gh=s("Cu\u1ED1i c\xF9ng, \u0111\u1EC3 \u0111\u1EA9y m\xF4 h\xECnh c\u1EE7a ch\xFAng ta l\xEAn Hub, ch\xFAng ta s\u1EBD c\u1EA7n t\u1EA1o m\u1ED9t \u0111\u1ED1i t\u01B0\u1EE3ng "),dl=h("code"),Pt=s("Repository"),_l=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, 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 "),bl=h("code"),Vh=s("repo_name"),vl=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 "),kl=h("code"),Uh=s("get_full_repo_name ()"),yl=s(" th\u1EF1c hi\u1EC7n):"),Ql=o(),E(Ps.$$.fragment),ja=o(),E(zs.$$.fragment),Jl=o(),As=h("p"),Ea=s("Sau \u0111\xF3, 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 hi\u1EC7n c\xF3 c\u1EE7a kho l\u01B0u tr\u1EEF m\xE0 ch\xFAng ta \u0111ang l\xE0m vi\u1EC7c:"),nh=o(),E(cs.$$.fragment),rs=o(),Jt=h("p"),Ns=s("Gi\u1EDD ta c\xF3 th\u1EC3 t\u1EA3i m\u1ECDi th\u1EE9 ta l\u01B0u trong "),wa=h("code"),ke=s("output_dir"),Xh=s(" b\u1EB1ng c\xE1ch g\u1ECDi ph\u01B0\u01A1ng th\u1EE9c "),Bs=h("code"),Wh=s("repo.push_to_hub()"),Kh=s(". \u0110i\u1EC1u n\xE0y s\u1EBD gi\xFAp ta t\u1EA3i ngay l\u1EADp t\u1EE9c m\xF4 h\xECnh \u1EDF cu\u1ED1i m\u1ED7i epoch."),xa=o(),Ge=h("h3"),is=h("a"),Ca=h("span"),E(ne.$$.fragment),th=o(),zt=h("span"),Zh=s("V\xF2ng l\u1EB7p hu\u1EA5n luy\u1EC7n"),Oa=o(),ye=h("p"),Yh=s("B\xE2y gi\u1EDD ch\xFAng ta \u0111\xE3 s\u1EB5n s\xE0ng \u0111\u1EC3 vi\u1EBFt v\xF2ng l\u1EB7p  hu\u1EA5n luy\u1EC7n \u0111\u1EA7y \u0111\u1EE7. \u0110\u1EC3 \u0111\u01A1n gi\u1EA3n h\xF3a ph\u1EA7n \u0111\xE1nh gi\xE1 c\u1EE7a n\xF3, ch\xFAng ta \u0111\u1ECBnh ngh\u0129a h\xE0m "),Ss=h("code"),Qh=s("postprocess()"),Jh=s(" l\u1EA5y c\xE1c d\u1EF1 \u0111o\xE1n v\xE0 nh\xE3n v\xE0 chuy\u1EC3n \u0111\u1ED5i ch\xFAng th\xE0nh danh s\xE1ch c\xE1c chu\u1ED7i, gi\u1ED1ng nh\u01B0 \u0111\u1ED1i t\u01B0\u1EE3ng "),qa=h("code"),os=s("metric"),eh=s(" mong \u0111\u1EE3i:"),$e=o(),E(At.$$.fragment),Da=o(),je=h("p"),nc=s("Sau \u0111\xF3, ch\xFAng ta c\xF3 th\u1EC3 vi\u1EBFt v\xF2ng l\u1EB7p hu\u1EA5n luy\u1EC7n. Sau khi x\xE1c \u0111\u1ECBnh m\u1ED9t 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:"),Ta=o(),Ee=h("ul"),ps=h("li"),Is=s("B\u1EA3n th\xE2n qu\xE1 tr\xECnh hu\u1EA5n luy\u1EC7n, l\xE0 v\xF2ng l\u1EB7p c\u1ED5 \u0111i\u1EC3n tr\xEAn "),Pa=h("code"),we=s("train_dataloader"),tc=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."),za=o(),ut=h("li"),ec=s("\u0110\xE1nh gi\xE1, trong \u0111\xF3 c\xF3 m\u1ED9t \u0111i\u1EC3m m\u1EDBi sau khi nh\u1EADn \u0111\u01B0\u1EE3c k\u1EBFt qu\u1EA3 \u0111\u1EA7u ra c\u1EE7a m\xF4 h\xECnh tr\xEAn m\u1ED9t l\xF4: v\xEC hai quy tr\xECnh c\xF3 th\u1EC3 \u0111\xE3 \u0111\u1ED9n c\xE1c \u0111\u1EA7u v\xE0o v\xE0 nh\xE3n th\xE0nh c\xE1c h\xECnh d\u1EA1ng kh\xE1c nhau, ch\xFAng ta c\u1EA7n s\u1EED d\u1EE5ng "),Ms=h("code"),sc=s("accelerator.pad_across_processes()"),ac=s("\u0111\u1EC3 \u0111\u01B0a ra d\u1EF1 \u0111o\xE1n v\xE0 d\xE1n nh\xE3n cho c\xF9ng m\u1ED9t h\xECnh d\u1EA1ng tr\u01B0\u1EDBc khi g\u1ECDi ph\u01B0\u01A1ng th\u1EE9c "),Aa=h("code"),us=s("collect()"),lc=s(". N\u1EBFu kh\xF4ng l\xE0m \u0111i\u1EC1u n\xE0y, \u0111\xE1nh gi\xE1 s\u1EBD b\u1ECB l\u1ED7i ho\u1EB7c b\u1ECB treo v\u0129nh vi\u1EC5n. Sau \u0111\xF3, ch\xFAng ta g\u1EEDi k\u1EBFt qu\u1EA3 \u0111\u1EBFn "),Ls=h("code"),hc=s("metric.add_batch()"),cc=s(" v\xE0 g\u1ECDi "),Na=h("code"),Hs=s("metric.compute()"),sh=s(" khi v\xF2ng l\u1EB7p \u0111\xE1nh gi\xE1 k\u1EBFt th\xFAc."),zn=o(),Ve=h("li"),$l=s("L\u01B0u v\xE0 t\u1EA3i l\xEAn, n\u01A1i \u0111\u1EA7u ti\xEAn ch\xFAng ta l\u01B0u m\xF4 h\xECnh v\xE0 tr\xECnh tokenize, sau \u0111\xF3 g\u1ECDi "),jl=h("code"),rc=s("repo.push_to_hub()"),Rs=s(". L\u01B0u \xFD r\u1EB1ng ch\xFAng ta s\u1EED d\u1EE5ng \u0111\u1ED1i s\u1ED1 "),El=h("code"),ic=s("blocks=False"),Fs=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."),ah=o(),Ba=h("p"),wl=s("\u0110\xE2y l\xE0 m\xE3 ho\xE0n ch\u1EC9nh cho v\xF2ng l\u1EB7p hu\u1EA5n luy\u1EC7n:"),lh=o(),E(Gs.$$.fragment),Sa=o(),Ia=h("p"),oc=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:"),xl=o(),E(te.$$.fragment),Cl=o(),hn=h("p"),hh=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 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, ch\xFAng ta l\u1EA5y "),Nt=h("code"),pc=s("unwrapped_model"),Ol=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 "),ql=h("code"),uc=s("accelerator.prepare()"),Dl=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 "),Tl=h("code"),mc=s("save_pretrained()"),ch=s(" n\u1EEFa; ph\u01B0\u01A1ng th\u1EE9c "),Ue=h("code"),rh=s("accelerator.unwrap_model()"),Vs=s(" ho\xE0n t\xE1c b\u01B0\u1EDBc \u0111\xF3. Cu\u1ED1i c\xF9ng, ch\xFAng ta g\u1ECDi l\xE0 "),Ma=h("code"),An=s("save_pretrained()"),gc=s(" nh\u01B0ng y\xEAu c\u1EA7u ph\u01B0\u01A1ng th\u1EE9c \u0111\xF3 s\u1EED d\u1EE5ng "),Us=h("code"),fc=s("accelerator.save()"),dc=s(" thay v\xEC "),Xs=h("code"),_c=s("torch.save()"),bc=s("."),La=o(),xe=h("p"),vc=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 "),Ws=h("code"),kc=s("Trainer"),yc=s(". B\u1EA1n c\xF3 th\u1EC3 ki\u1EC3m tra m\xF4 h\xECnh m\xE0 ch\xFAng ta \u0111\xE3 hu\u1EA5n luy\u1EC7n b\u1EB1ng c\xE1ch s\u1EED d\u1EE5ng \u0111o\u1EA1n m\xE3 n\xE0y t\u1EA1i "),Xe=h("a"),Pl=h("em"),$c=s("huggingface-course/bert-finetuned-ner-accelerate"),ih=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(l){m=c(l,"H3",{class:!0});var d=r(m);v=c(d,"A",{id:!0,class:!0,href:!0});var sr=r(v);f=c(sr,"SPAN",{});var ar=r(f);w($.$$.fragment,ar),ar.forEach(e),sr.forEach(e),O=p(d),k=c(d,"SPAN",{});var jc=r(k);j=a(jc,"\u0110\u1ECBnh ngh\u0129a m\xF4 h\xECnh"),jc.forEach(e),d.forEach(e),q=p(l),D=c(l,"P",{});var Ce=r(D);z=a(Ce,"V\xEC ch\xFAng ta \u0111ang gi\u1EA3i quy\u1EBFt v\u1EA5n \u0111\u1EC1 ph\xE2n lo\u1EA1i token, ch\xFAng ta s\u1EBD s\u1EED d\u1EE5ng l\u1EDBp "),I=c(Ce,"CODE",{});var Ec=r(I);A=a(Ec,"AutoModelForTokenClassification"),Ec.forEach(e),N=a(Ce,". \u0110i\u1EC1u ch\xEDnh c\u1EA7n nh\u1EDB khi x\xE1c \u0111\u1ECBnh m\xF4 h\xECnh n\xE0y l\xE0 truy\u1EC1n m\u1ED9t s\u1ED1 th\xF4ng tin v\u1EC1 s\u1ED1 l\u01B0\u1EE3ng nh\xE3n m\xE0 ch\xFAng ta c\xF3. C\xE1ch d\u1EC5 nh\u1EA5t \u0111\u1EC3 l\xE0m \u0111i\u1EC1u n\xE0y l\xE0 truy\u1EC1n v\xE0o tham s\u1ED1 "),V=c(Ce,"CODE",{});var Ha=r(V);B=a(Ha,"num_labels"),Ha.forEach(e),R=a(Ce,", nh\u01B0ng n\u1EBFu ch\xFAng ta mu\u1ED1n m\u1ED9t ti\u1EC7n \xEDch lu\u1EADn suy ho\u1EA1t \u0111\u1ED9ng gi\u1ED1ng nh\u01B0 ti\u1EC7n \xEDch ch\xFAng ta \u0111\xE3 th\u1EA5y \u1EDF \u0111\u1EA7u ph\u1EA7n n\xE0y, t\u1ED1t h\u01A1n n\xEAn \u0111\u1EB7t c\xE1c nh\xE3n t\u01B0\u01A1ng \u1EE9ng ch\xEDnh x\xE1c thay th\u1EBF."),Ce.forEach(e),F=p(l),M=c(l,"P",{});var Ks=r(M);W=a(Ks,"Ch\xFAng ph\u1EA3i \u0111\u01B0\u1EE3c \u0111\u1EB7t b\u1EDFi hai t\u1EEB \u0111i\u1EC3n, "),T=c(Ks,"CODE",{});var mt=r(T);U=a(mt,"id2label"),mt.forEach(e),L=a(Ks," v\xE0 "),K=c(Ks,"CODE",{});var lr=r(K);nn=a(lr,"label2id"),lr.forEach(e),an=a(Ks,", ch\u1EE9a c\xE1c \xE1nh x\u1EA1 t\u1EEB ID \u0111\u1EBFn nh\xE3n v\xE0 ng\u01B0\u1EE3c l\u1EA1i:"),Ks.forEach(e),ln=p(l),w(Z.$$.fragment,l),un=p(l),Q=c(l,"P",{});var Ra=r(Q);G=a(Ra,"Gi\u1EDD ta c\xF3 th\u1EC3 truy\u1EC1n ch\xFAng v\xE0o ph\u01B0\u01A1ng th\u1EE9c "),H=c(Ra,"CODE",{});var hr=r(H);en=a(hr,"AutoModelForTokenClassification.from_pretrained()"),hr.forEach(e),mn=a(Ra,", v\xE0 ch\xFAng s\u1EBD \u0111\u01B0\u1EE3c thi\u1EBFt l\u1EADp trong c\u1EA5u h\xECnh m\xF4 h\xECnh v\xE0 sau \u0111\xF3 \u0111\u01B0\u1EE3c l\u01B0u v\u1EA3 t\u1EA3i l\xEAn Hub:"),Ra.forEach(e),kn=p(l),w(sn.$$.fragment,l),Bn=p(l),Y=c(l,"P",{});var Fa=r(Y);at=a(Fa,"Gi\u1ED1ng nh\u01B0 khi ch\xFAng t\xF4i \u0111\u1ECBnh ngh\u0129a "),on=c(Fa,"CODE",{});var oh=r(on);ft=a(oh,"AutoModelForSequenceClassification"),oh.forEach(e),le=a(Fa," c\u1EE7a m\xECnh trong "),lt=c(Fa,"A",{href:!0});var cr=r(lt);Qe=a(cr,"Ch\u01B0\u01A1ng 3"),cr.forEach(e),It=a(Fa,", vi\u1EC7c t\u1EA1o m\xF4 h\xECnh \u0111\u01B0a ra c\u1EA3nh b\xE1o r\u1EB1ng m\u1ED9t s\u1ED1 tr\u1ECDng s\u1ED1 kh\xF4ng \u0111\u01B0\u1EE3c s\u1EED d\u1EE5ng (nh\u1EEFng tr\u1ECDng s\u1ED1 t\u1EEB \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 (nh\u1EEFng tr\u1ECDng s\u1ED1 t\u1EEB \u0111\u1EA7u ph\xE2n lo\u1EA1i token m\u1EDBi) v\xE0 m\xF4 h\xECnh n\xE0y n\xEAn \u0111\u01B0\u1EE3c hu\u1EA5n luy\u1EC7n. Ch\xFAng ta s\u1EBD l\xE0m \u0111i\u1EC1u \u0111\xF3 sau m\u1ED9t ph\xFAt, nh\u01B0ng tr\u01B0\u1EDBc ti\xEAn h\xE3y ki\u1EC3m tra k\u1EF9 xem m\xF4 h\xECnh c\u1EE7a ch\xFAng ta c\xF3 \u0111\xFAng s\u1ED1 l\u01B0\u1EE3ng nh\xE3n hay kh\xF4ng:"),Fa.forEach(e),he=p(l),w(bn.$$.fragment,l),De=p(l),w(En.$$.fragment,l),gn=p(l),w(Vn.$$.fragment,l),ce=p(l),tn=c(l,"H3",{class:!0});var ph=r(tn);pn=c(ph,"A",{id:!0,class:!0,href:!0});var uh=r(pn);re=c(uh,"SPAN",{});var rr=r(re);w(Sn.$$.fragment,rr),rr.forEach(e),uh.forEach(e),Mt=p(ph),ie=c(ph,"SPAN",{});var ir=r(ie);Je=a(ir,"Tinh ch\u1EC9nh m\xF4 h\xECnh"),ir.forEach(e),ph.forEach(e),Un=p(l),In=c(l,"P",{});var Ga=r(In);Lt=a(Ga,"Gi\u1EDD ta \u0111\xE3 s\u1EB5n s\xE0ng \u0111\u1EC3 hu\u1EA5n luy\u1EC7n m\xF4 h\xECnh c\u1EE7a m\xECnh! Ch\xFAng ta ch\u1EC9 c\u1EA7n l\xE0m hai \u0111i\u1EC1u tr\u01B0\u1EDBc khi \u0111\u1ECBnh ngh\u0129a "),oe=c(Ga,"CODE",{});var or=r(oe);Ht=a(or,"Trainer"),or.forEach(e),Te=a(Ga,":  \u0111\u0103ng nh\u1EADp v\xE0o Hugging Face v\xE0 \u0111\u1ECBnh ngh\u0129a c\xE1c tham s\u1ED1 hu\u1EA5n luy\u1EC7n. N\u1EBFu b\u1EA1n \u0111ang l\xE0m vi\u1EC7c v\u1EDBi notebook, c\xF3 m\u1ED9t h\xE0m thu\u1EADn ti\u1EC7n c\xF3 th\u1EC3 gi\xFAp b\u1EA1n:"),Ga.forEach(e),yn=p(l),w(wn.$$.fragment,l),Rt=p(l),$n=c(l,"P",{});var pr=r($n);bs=a(pr,"Thao t\xE1c n\xE0y s\u1EBD hi\u1EC3n th\u1ECB m\u1ED9t ti\u1EC7n \xEDch m\xE0 b\u1EA1n c\xF3 th\u1EC3 nh\u1EADp th\xF4ng tin \u0111\u0103ng nh\u1EADp Hugging Facec\u1EE7a m\xECnh."),pr.forEach(e),Ft=p(l),Xn=c(l,"P",{});var wc=r(Xn);Pe=a(wc,"N\u1EBFu b\u1EA1n kh\xF4ng l\xE0m vi\u1EC7c trong s\u1ED5 ghi ch\xE9p, ch\u1EC9 c\u1EA7n nh\u1EADp d\xF2ng sau v\xE0o thi\u1EBFt b\u1ECB \u0111\u1EA7u cu\u1ED1i c\u1EE7a b\u1EA1n:"),wc.forEach(e),cn=p(l),w(Gt.$$.fragment,l),Wn=p(l),dt=c(l,"P",{});var ms=r(dt);vs=a(ms,"Once this is done, we can define our "),_t=c(ms,"CODE",{});var xc=r(_t);bt=a(xc,"TrainingArguments"),xc.forEach(e),ns=a(ms,":"),ms.forEach(e),xn=p(l),w(Cn.$$.fragment,l),pe=p(l),J=c(l,"P",{});var jn=r(J);Vt=a(jn,"B\u1EA1n \u0111\xE3 t\u1EEBng th\u1EA5y h\u1EA7u h\u1EBFt nh\u1EEFng \u0111i\u1EC1u \u0111\xF3 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 c\u1EA7n luy\u1EC7n t\u1EADp v\xE0 gi\u1EA3m tr\u1ECDng l\u01B0\u1EE3ng) v\xE0 ch\xFAng ta ch\u1EC9 \u0111\u1ECBnh "),vt=c(jn,"CODE",{});var ur=r(vt);Kn=a(ur,"push_to_hub=True"),ur.forEach(e),ts=a(jn," \u0111\u1EC3 ch\u1EC9 ra r\u1EB1ng ch\xFAng ta mu\u1ED1n l\u01B0u m\xF4 h\xECnh v\xE0 \u0111\xE1nh gi\xE1 n\xF3 v\xE0o cu\u1ED1i m\u1ED7i epoch v\xE0 r\u1EB1ng ch\xFAng ta mu\u1ED1n t\u1EA3i k\u1EBFt qu\u1EA3 c\u1EE7a m\xECnh l\xEAn Model Hub. L\u01B0u \xFD r\u1EB1ng b\u1EA1n c\xF3 th\u1EC3 ch\u1EC9 \u0111\u1ECBnh t\xEAn c\u1EE7a kho l\u01B0u tr\u1EEF m\xE0 b\u1EA1n mu\u1ED1n \u0111\u1EA9y \u0111\u1EBFn b\u1EB1ng tham s\u1ED1 "),On=c(jn,"CODE",{});var Cc=r(On);ks=a(Cc,"hub_model_id"),Cc.forEach(e),ze=a(jn," (c\u1EE5 th\u1EC3 l\xE0 b\u1EA1n s\u1EBD ph\u1EA3i s\u1EED d\u1EE5ng tham s\u1ED1 n\xE0y \u0111\u1EC3 \u0111\u1EA9y \u0111\u1EBFn m\u1ED9t t\u1ED5 ch\u1EE9c). V\xED d\u1EE5: khi \u0111\u1EA9y m\xF4 h\xECnh v\xE0o t\u1ED5 ch\u1EE9c "),ht=c(jn,"A",{href:!0,rel:!0});var Va=r(ht);Ae=c(Va,"CODE",{});var Oc=r(Ae);es=a(Oc,"huggingface-course"),Oc.forEach(e),Va.forEach(e),kt=a(jn," ch\xFAng ta \u0111\xE3 th\xEAm "),Mn=c(jn,"CODE",{});var Ua=r(Mn);yt=a(Ua,'hub_model_id="huggingface-course/bert-finetuned-ner"'),Ua.forEach(e),Ne=a(jn," v\xE0o "),$t=c(jn,"CODE",{});var qc=r($t);ys=a(qc,"TrainingArguments"),qc.forEach(e),ss=a(jn,". Theo m\u1EB7c \u0111\u1ECBnh, kho l\u01B0u tr\u1EEF \u0111\u01B0\u1EE3c s\u1EED d\u1EE5ng s\u1EBD n\u1EB1m trong kh\xF4ng gian t\xEAn c\u1EE7a b\u1EA1n v\xE0 \u0111\u01B0\u1EE3c \u0111\u1EB7t t\xEAn theo th\u01B0 m\u1EE5c \u0111\u1EA7u ra m\xE0 b\u1EA1n \u0111\xE3 \u0111\u1EB7t, v\xEC v\u1EADy trong tr\u01B0\u1EDDng h\u1EE3p c\u1EE7a ch\xFAng t\xF4i, n\xF3 s\u1EBD l\xE0 "),Zn=c(jn,"CODE",{});var Ke=r(Zn);jt=a(Ke,'"sgugger/bert-finetuned-ner"'),Ke.forEach(e),fn=a(jn,"."),jn.forEach(e),Et=p(l),w(Yn.$$.fragment,l),ct=p(l),wt=c(l,"P",{});var mh=r(wt);rt=a(mh,"Cu\u1ED1i c\xF9ng, ch\xFAng ta ch\u1EC9 c\u1EA7n truy\u1EC1n m\u1ECDi th\u1EE9 cho  "),Ut=c(mh,"CODE",{});var gh=r(Ut);$s=a(gh,"Trainer"),gh.forEach(e),as=a(mh," v\xE0 b\u1EAFt \u0111\u1EA7u hu\u1EA5n luy\u1EC7n:"),mh.forEach(e),it=p(l),w(Xt.$$.fragment,l),Be=p(l),qn=c(l,"P",{});var mr=r(qn);ls=a(mr,"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."),mr.forEach(e),xt=p(l),Qn=c(l,"P",{});var fh=r(Qn);Jn=a(fh,"Sau khi qu\xE1 tr\xECnh hu\u1EA5n luy\u1EC7n ho\xE0n t\u1EA5t, ch\xFAng ta s\u1EED d\u1EE5ng ph\u01B0\u01A1ng th\u1EE9c "),ue=c(fh,"CODE",{});var dh=r(ue);Wt=a(dh,"push_to_hub()"),dh.forEach(e),Kt=a(fh," \u0111\u1EC3 \u0111\u1EA3m b\u1EA3o ch\xFAng ta t\u1EA3i l\xEAn phi\xEAn b\u1EA3n m\u1EDBi nh\u1EA5t c\u1EE7a m\xF4 h\xECnh:"),fh.forEach(e),me=p(l),w(vn.$$.fragment,l),Se=p(l),Dn=c(l,"P",{});var gr=r(Dn);g=a(gr,"C\xE2u l\u1EC7nh n\xE0y tr\u1EA3 v\u1EC1 URL c\u1EE7a cam kh\u1EBFt n\xF3 v\u1EEBa l\xE0m, n\u1EBFu b\u1EA1n mu\u1ED1n ki\u1EC3m tra n\xF3:"),gr.forEach(e),S=p(l),w(ge.$$.fragment,l),js=p(l),Zt=c(l,"P",{});var Dc=r(Zt);Tn=c(Dc,"CODE",{});var Tc=r(Tn);Es=a(Tc,"Trainer"),Tc.forEach(e),fe=a(Dc," 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. \u1EDE giai \u0111o\u1EA1n n\xE0y, b\u1EA1n c\xF3 th\u1EC3 s\u1EED d\u1EE5ng ti\u1EC7n \xEDch lu\u1EADn suy tr\xEAn Model Hub \u0111\u1EC3 ki\u1EC3m tra m\xF4 h\xECnh c\u1EE7a m\xECnh v\xE0 chia s\u1EBB v\u1EDBi b\u1EA1n b\xE8. B\u1EA1n \u0111\xE3 tinh ch\u1EC9nh th\xE0nh c\xF4ng m\u1ED9t m\xF4 h\xECnh trong t\xE1c v\u1EE5 ph\xE2n lo\u1EA1i token - xin ch\xFAc m\u1EEBng!"),Dc.forEach(e),Ct=p(l),rn=c(l,"P",{});var Zs=r(rn);oa=a(Zs,"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."),Zs.forEach(e),Yt=p(l),Ot=c(l,"H2",{class:!0});var zl=r(Ot);Ln=c(zl,"A",{id:!0,class:!0,href:!0});var gt=r(Ln);de=c(gt,"SPAN",{});var fr=r(de);w(_e.$$.fragment,fr),fr.forEach(e),gt.forEach(e),hs=p(zl),be=c(zl,"SPAN",{});var _h=r(be);pa=a(_h,"M\u1ED9t v\xF2ng hu\u1EA5n luy\u1EC7n tu\u1EF3 ch\u1EC9nh"),_h.forEach(e),zl.forEach(e),ws=p(l),ot=c(l,"P",{});var bh=r(ot);ua=a(bh,"B\xE2y gi\u1EDD ch\xFAng ta h\xE3y xem to\xE0n b\u1ED9 v\xF2ng l\u1EB7p hu\u1EA5n luy\u1EC7n, v\xEC v\u1EADy b\u1EA1n c\xF3 th\u1EC3 d\u1EC5 d\xE0ng t\xF9y ch\u1EC9nh c\xE1c ph\u1EA7n b\u1EA1n c\u1EA7n. N\xF3 s\u1EBD tr\xF4ng r\u1EA5t gi\u1ED1ng nh\u1EEFng g\xEC ch\xFAng ta \u0111\xE3 l\xE0m trong "),Ie=c(bh,"A",{href:!0});var dr=r(Ie);nt=a(dr,"Ch\u01B0\u01A1ng 3"),dr.forEach(e),ma=a(bh,", v\u1EDBi m\u1ED9t v\xE0i thay \u0111\u1ED5i cho ph\u1EA7n \u0111\xE1nh gi\xE1."),bh.forEach(e),xs=p(l),pt=c(l,"H3",{class:!0});var Xa=r(pt);dn=c(Xa,"A",{id:!0,class:!0,href:!0});var _r=r(dn);Me=c(_r,"SPAN",{});var br=r(Me);w(tt.$$.fragment,br),br.forEach(e),_r.forEach(e),Le=p(Xa),Hn=c(Xa,"SPAN",{});var vh=r(Hn);et=a(vh,"Chu\u1EA9n b\u1ECB m\u1ECDi th\u1EE9 \u0111\u1EC3 hu\u1EA5n luy\u1EC7n"),vh.forEach(e),Xa.forEach(e),He=p(l),Rn=c(l,"P",{});var gs=r(Rn);ga=a(gs,"\u0110\u1EA7u ti\xEAn, ch\xFAng ta c\u1EA7n x\xE2y d\u1EF1ng c\xE1c "),Qt=c(gs,"CODE",{});var vr=r(Qt);fa=a(vr,"DataLoader"),vr.forEach(e),da=a(gs," t\u1EEB c\xE1c t\u1EADp d\u1EEF li\u1EC7u c\u1EE7a m\xECnh. Ch\xFAng ta s\u1EBD s\u1EED d\u1EE5ng l\u1EA1i "),Re=c(gs,"CODE",{});var kh=r(Re);st=a(kh,"data_collator"),kh.forEach(e),_a=a(gs," c\u1EE7a m\xECnh d\u01B0\u1EDBi d\u1EA1ng "),Cs=c(gs,"CODE",{});var kr=r(Cs);Ah=a(kr,"collate_fn"),kr.forEach(e),Nh=a(gs," v\xE0 x\xE1o tr\u1ED9n t\u1EADp hu\u1EA5n luy\u1EC7n, nh\u01B0ng kh\xF4ng ph\u1EA3i t\u1EADp ki\u1EC3m \u0111\u1ECBnh:"),gs.forEach(e),Vl=p(l),w(Pn.$$.fragment,l),ba=p(l),va=c(l,"P",{});var yr=r(va);Bh=a(yr,"Ti\u1EBFp theo, ch\xFAng ta kh\xF4i ph\u1EE5c m\xF4 h\xECnh c\u1EE7a m\xECnh, \u0111\u1EC3 \u0111\u1EA3m b\u1EA3o r\u1EB1ng ch\xFAng ta kh\xF4ng ti\u1EBFp t\u1EE5c tinh ch\u1EC9nh t\u1EEB tr\u01B0\u1EDBc m\xE0 b\u1EAFt \u0111\u1EA7u l\u1EA1i t\u1EEB m\xF4 h\xECnh \u0111\u01B0\u1EE3c hu\u1EA5n luy\u1EC7n tr\u01B0\u1EDBc BERT:"),yr.forEach(e),ka=p(l),w(Os.$$.fragment,l),Ul=p(l),qt=c(l,"P",{});var Ys=r(qt);Sh=a(Ys,"Sau \u0111\xF3, ch\xFAng t\xF4i s\u1EBD c\u1EA7n m\u1ED9t tr\xECnh t\u1ED1i \u01B0u h\xF3a. Ch\xFAng ta s\u1EBD s\u1EED d\u1EE5ng "),hl=c(Ys,"CODE",{});var Wa=r(hl);cl=a(Wa,"AdamW"),Wa.forEach(e),Ih=a(Ys," c\u1ED5 \u0111i\u1EC3n, gi\u1ED1ng nh\u01B0 "),rl=c(Ys,"CODE",{});var Pc=r(rl);Mh=a(Pc,"Adam"),Pc.forEach(e),Dt=a(Ys,", nh\u01B0ng v\u1EDBi m\u1ED9t b\u1EA3n s\u1EEDa l\u1ED7i trong c\xE1ch \xE1p d\u1EE5ng weight decay (ph\xE2n r\xE3 tr\u1ECDng s\u1ED1):"),Ys.forEach(e),ya=p(l),w(qs.$$.fragment,l),Xl=p(l),ve=c(l,"P",{});var Qs=r(ve);Lh=a(Qs,"Once we have all those objects, we can send them to the "),il=c(Qs,"CODE",{});var $r=r(il);ol=a($r,"accelerator.prepare()"),$r.forEach(e),Hh=a(Qs," method:"),Qs.forEach(e),Wl=p(l),w(Fe.$$.fragment,l),Kl=p(l),w(Ds.$$.fragment,l),Zl=p(l),_n=c(l,"P",{});var Js=r(_n);pl=a(Js,"B\xE2y gi\u1EDD, ch\xFAng ta \u0111\xE3 g\u1EEDi "),ul=c(Js,"CODE",{});var Al=r(ul);Rh=a(Al,"train_dataloader"),Al.forEach(e),ml=a(Js," c\u1EE7a m\xECnh t\u1EDBi "),gl=c(Js,"CODE",{});var jr=r(gl);Fh=a(jr,"speedrator.prepare()"),jr.forEach(e),fl=a(Js,", ch\xFAng ta c\xF3 th\u1EC3 s\u1EED d\u1EE5ng \u0111\u1ED9 d\xE0i c\u1EE7a n\xF3 \u0111\u1EC3 t\xEDnh s\u1ED1 b\u01B0\u1EDBc hu\u1EA5n luy\u1EC7n. H\xE3y nh\u1EDB r\u1EB1ng ch\xFAng ta ph\u1EA3i lu\xF4n l\xE0m \u0111i\u1EC1u n\xE0y sau khi chu\u1EA9n b\u1ECB dataloader, v\xEC ph\u01B0\u01A1ng th\u1EE9c \u0111\xF3 s\u1EBD thay \u0111\u1ED5i \u0111\u1ED9 d\xE0i c\u1EE7a n\xF3. Ch\xFAng ta s\u1EED d\u1EE5ng m\u1ED9t l\u1ECBch tr\xECnh tuy\u1EBFn t\xEDnh c\u1ED5 \u0111i\u1EC3n t\u1EEB t\u1ED1c \u0111\u1ED9 h\u1ECDc \u0111\u1EBFn 0:"),Js.forEach(e),Yl=p(l),w(Ts.$$.fragment,l),$a=p(l),Tt=c(l,"P",{});var Ze=r(Tt);Gh=a(Ze,"Cu\u1ED1i c\xF9ng, \u0111\u1EC3 \u0111\u1EA9y m\xF4 h\xECnh c\u1EE7a ch\xFAng ta l\xEAn Hub, ch\xFAng ta s\u1EBD c\u1EA7n t\u1EA1o m\u1ED9t \u0111\u1ED1i t\u01B0\u1EE3ng "),dl=c(Ze,"CODE",{});var Ka=r(dl);Pt=a(Ka,"Repository"),Ka.forEach(e),_l=a(Ze," 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, 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 "),bl=c(Ze,"CODE",{});var zc=r(bl);Vh=a(zc,"repo_name"),zc.forEach(e),vl=a(Ze," 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 "),kl=c(Ze,"CODE",{});var na=r(kl);Uh=a(na,"get_full_repo_name ()"),na.forEach(e),yl=a(Ze," th\u1EF1c hi\u1EC7n):"),Ze.forEach(e),Ql=p(l),w(Ps.$$.fragment,l),ja=p(l),w(zs.$$.fragment,l),Jl=p(l),As=c(l,"P",{});var Er=r(As);Ea=a(Er,"Sau \u0111\xF3, 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 hi\u1EC7n c\xF3 c\u1EE7a kho l\u01B0u tr\u1EEF m\xE0 ch\xFAng ta \u0111ang l\xE0m vi\u1EC7c:"),Er.forEach(e),nh=p(l),w(cs.$$.fragment,l),rs=p(l),Jt=c(l,"P",{});var Ye=r(Jt);Ns=a(Ye,"Gi\u1EDD ta c\xF3 th\u1EC3 t\u1EA3i m\u1ECDi th\u1EE9 ta l\u01B0u trong "),wa=c(Ye,"CODE",{});var wr=r(wa);ke=a(wr,"output_dir"),wr.forEach(e),Xh=a(Ye," b\u1EB1ng c\xE1ch g\u1ECDi ph\u01B0\u01A1ng th\u1EE9c "),Bs=c(Ye,"CODE",{});var xr=r(Bs);Wh=a(xr,"repo.push_to_hub()"),xr.forEach(e),Kh=a(Ye,". \u0110i\u1EC1u n\xE0y s\u1EBD gi\xFAp ta t\u1EA3i ngay l\u1EADp t\u1EE9c m\xF4 h\xECnh \u1EDF cu\u1ED1i m\u1ED7i epoch."),Ye.forEach(e),xa=p(l),Ge=c(l,"H3",{class:!0});var Nl=r(Ge);is=c(Nl,"A",{id:!0,class:!0,href:!0});var Oe=r(is);Ca=c(Oe,"SPAN",{});var qe=r(Ca);w(ne.$$.fragment,qe),qe.forEach(e),Oe.forEach(e),th=p(Nl),zt=c(Nl,"SPAN",{});var Bl=r(zt);Zh=a(Bl,"V\xF2ng l\u1EB7p hu\u1EA5n luy\u1EC7n"),Bl.forEach(e),Nl.forEach(e),Oa=p(l),ye=c(l,"P",{});var Bt=r(ye);Yh=a(Bt,"B\xE2y gi\u1EDD ch\xFAng ta \u0111\xE3 s\u1EB5n s\xE0ng \u0111\u1EC3 vi\u1EBFt v\xF2ng l\u1EB7p  hu\u1EA5n luy\u1EC7n \u0111\u1EA7y \u0111\u1EE7. \u0110\u1EC3 \u0111\u01A1n gi\u1EA3n h\xF3a ph\u1EA7n \u0111\xE1nh gi\xE1 c\u1EE7a n\xF3, ch\xFAng ta \u0111\u1ECBnh ngh\u0129a h\xE0m "),Ss=c(Bt,"CODE",{});var ta=r(Ss);Qh=a(ta,"postprocess()"),ta.forEach(e),Jh=a(Bt," l\u1EA5y c\xE1c d\u1EF1 \u0111o\xE1n v\xE0 nh\xE3n v\xE0 chuy\u1EC3n \u0111\u1ED5i ch\xFAng th\xE0nh danh s\xE1ch c\xE1c chu\u1ED7i, gi\u1ED1ng nh\u01B0 \u0111\u1ED1i t\u01B0\u1EE3ng "),qa=c(Bt,"CODE",{});var yh=r(qa);os=a(yh,"metric"),yh.forEach(e),eh=a(Bt," mong \u0111\u1EE3i:"),Bt.forEach(e),$e=p(l),w(At.$$.fragment,l),Da=p(l),je=c(l,"P",{});var Za=r(je);nc=a(Za,"Sau \u0111\xF3, ch\xFAng ta c\xF3 th\u1EC3 vi\u1EBFt v\xF2ng l\u1EB7p hu\u1EA5n luy\u1EC7n. Sau khi x\xE1c \u0111\u1ECBnh m\u1ED9t 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:"),Za.forEach(e),Ta=p(l),Ee=c(l,"UL",{});var Ya=r(Ee);ps=c(Ya,"LI",{});var Qa=r(ps);Is=a(Qa,"B\u1EA3n th\xE2n qu\xE1 tr\xECnh hu\u1EA5n luy\u1EC7n, l\xE0 v\xF2ng l\u1EB7p c\u1ED5 \u0111i\u1EC3n tr\xEAn "),Pa=c(Qa,"CODE",{});var Cr=r(Pa);we=a(Cr,"train_dataloader"),Cr.forEach(e),tc=a(Qa,", truy\u1EC1n th\u1EB3ng qua m\xF4 h\xECnh, sau \u0111\xF3 truy\u1EC1n ng\u01B0\u1EE3c v\xE0 t\u1ED1i \u01B0u h\xF3a."),Qa.forEach(e),za=p(Ya),ut=c(Ya,"LI",{});var ee=r(ut);ec=a(ee,"\u0110\xE1nh gi\xE1, trong \u0111\xF3 c\xF3 m\u1ED9t \u0111i\u1EC3m m\u1EDBi sau khi nh\u1EADn \u0111\u01B0\u1EE3c k\u1EBFt qu\u1EA3 \u0111\u1EA7u ra c\u1EE7a m\xF4 h\xECnh tr\xEAn m\u1ED9t l\xF4: v\xEC hai quy tr\xECnh c\xF3 th\u1EC3 \u0111\xE3 \u0111\u1ED9n c\xE1c \u0111\u1EA7u v\xE0o v\xE0 nh\xE3n th\xE0nh c\xE1c h\xECnh d\u1EA1ng kh\xE1c nhau, ch\xFAng ta c\u1EA7n s\u1EED d\u1EE5ng "),Ms=c(ee,"CODE",{});var se=r(Ms);sc=a(se,"accelerator.pad_across_processes()"),se.forEach(e),ac=a(ee,"\u0111\u1EC3 \u0111\u01B0a ra d\u1EF1 \u0111o\xE1n v\xE0 d\xE1n nh\xE3n cho c\xF9ng m\u1ED9t h\xECnh d\u1EA1ng tr\u01B0\u1EDBc khi g\u1ECDi ph\u01B0\u01A1ng th\u1EE9c "),Aa=c(ee,"CODE",{});var Or=r(Aa);us=a(Or,"collect()"),Or.forEach(e),lc=a(ee,". N\u1EBFu kh\xF4ng l\xE0m \u0111i\u1EC1u n\xE0y, \u0111\xE1nh gi\xE1 s\u1EBD b\u1ECB l\u1ED7i ho\u1EB7c b\u1ECB treo v\u0129nh vi\u1EC5n. Sau \u0111\xF3, ch\xFAng ta g\u1EEDi k\u1EBFt qu\u1EA3 \u0111\u1EBFn "),Ls=c(ee,"CODE",{});var $h=r(Ls);hc=a($h,"metric.add_batch()"),$h.forEach(e),cc=a(ee," v\xE0 g\u1ECDi "),Na=c(ee,"CODE",{});var qr=r(Na);Hs=a(qr,"metric.compute()"),qr.forEach(e),sh=a(ee," khi v\xF2ng l\u1EB7p \u0111\xE1nh gi\xE1 k\u1EBFt th\xFAc."),ee.forEach(e),zn=p(Ya),Ve=c(Ya,"LI",{});var Ja=r(Ve);$l=a(Ja,"L\u01B0u v\xE0 t\u1EA3i l\xEAn, n\u01A1i \u0111\u1EA7u ti\xEAn ch\xFAng ta l\u01B0u m\xF4 h\xECnh v\xE0 tr\xECnh tokenize, sau \u0111\xF3 g\u1ECDi "),jl=c(Ja,"CODE",{});var Sl=r(jl);rc=a(Sl,"repo.push_to_hub()"),Sl.forEach(e),Rs=a(Ja,". L\u01B0u \xFD r\u1EB1ng ch\xFAng ta s\u1EED d\u1EE5ng \u0111\u1ED1i s\u1ED1 "),El=c(Ja,"CODE",{});var Dr=r(El);ic=a(Dr,"blocks=False"),Dr.forEach(e),Fs=a(Ja," \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."),Ja.forEach(e),Ya.forEach(e),ah=p(l),Ba=c(l,"P",{});var Tr=r(Ba);wl=a(Tr,"\u0110\xE2y l\xE0 m\xE3 ho\xE0n ch\u1EC9nh cho v\xF2ng l\u1EB7p hu\u1EA5n luy\u1EC7n:"),Tr.forEach(e),lh=p(l),w(Gs.$$.fragment,l),Sa=p(l),Ia=c(l,"P",{});var jh=r(Ia);oc=a(jh,"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:"),jh.forEach(e),xl=p(l),w(te.$$.fragment,l),Cl=p(l),hn=c(l,"P",{});var Nn=r(hn);hh=a(Nn,"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 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, ch\xFAng ta l\u1EA5y "),Nt=c(Nn,"CODE",{});var Pr=r(Nt);pc=a(Pr,"unwrapped_model"),Pr.forEach(e),Ol=a(Nn,", l\xE0 m\xF4 h\xECnh c\u01A1 s\u1EDF m\xE0 ta \u0111\xE3 x\xE1c \u0111\u1ECBnh. Ph\u01B0\u01A1ng th\u1EE9c "),ql=c(Nn,"CODE",{});var Ac=r(ql);uc=a(Ac,"accelerator.prepare()"),Ac.forEach(e),Dl=a(Nn," 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 "),Tl=c(Nn,"CODE",{});var ae=r(Tl);mc=a(ae,"save_pretrained()"),ae.forEach(e),ch=a(Nn," n\u1EEFa; ph\u01B0\u01A1ng th\u1EE9c "),Ue=c(Nn,"CODE",{});var zr=r(Ue);rh=a(zr,"accelerator.unwrap_model()"),zr.forEach(e),Vs=a(Nn," ho\xE0n t\xE1c b\u01B0\u1EDBc \u0111\xF3. Cu\u1ED1i c\xF9ng, ch\xFAng ta g\u1ECDi l\xE0 "),Ma=c(Nn,"CODE",{});var nl=r(Ma);An=a(nl,"save_pretrained()"),nl.forEach(e),gc=a(Nn," nh\u01B0ng y\xEAu c\u1EA7u ph\u01B0\u01A1ng th\u1EE9c \u0111\xF3 s\u1EED d\u1EE5ng "),Us=c(Nn,"CODE",{});var Eh=r(Us);fc=a(Eh,"accelerator.save()"),Eh.forEach(e),dc=a(Nn," thay v\xEC "),Xs=c(Nn,"CODE",{});var Ar=r(Xs);_c=a(Ar,"torch.save()"),Ar.forEach(e),bc=a(Nn,"."),Nn.forEach(e),La=p(l),xe=c(l,"P",{});var tl=r(xe);vc=a(tl,"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 "),Ws=c(tl,"CODE",{});var wh=r(Ws);kc=a(wh,"Trainer"),wh.forEach(e),yc=a(tl,". B\u1EA1n c\xF3 th\u1EC3 ki\u1EC3m tra m\xF4 h\xECnh m\xE0 ch\xFAng ta \u0111\xE3 hu\u1EA5n luy\u1EC7n b\u1EB1ng c\xE1ch s\u1EED d\u1EE5ng \u0111o\u1EA1n m\xE3 n\xE0y t\u1EA1i "),Xe=c(tl,"A",{href:!0,rel:!0});var Nr=r(Xe);Pl=c(Nr,"EM",{});var Br=r(Pl);$c=a(Br,"huggingface-course/bert-finetuned-ner-accelerate"),Br.forEach(e),Nr.forEach(e),ih=a(tl,". 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!"),tl.forEach(e),this.h()},h(){y(v,"id","nh-ngha-m-hnh"),y(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"),y(v,"href","#nh-ngha-m-hnh"),y(m,"class","relative group"),y(lt,"href","/course/chapter3"),y(pn,"id","tinh-chnh-m-hnh"),y(pn,"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"),y(pn,"href","#tinh-chnh-m-hnh"),y(tn,"class","relative group"),y(ht,"href","https://huggingface.co/huggingface-course"),y(ht,"rel","nofollow"),y(Ln,"id","mt-vng-hun-luyn-tu-chnh"),y(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"),y(Ln,"href","#mt-vng-hun-luyn-tu-chnh"),y(Ot,"class","relative group"),y(Ie,"href","/course/chapter3/4"),y(dn,"id","chun-b-mi-th-hun-luyn"),y(dn,"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"),y(dn,"href","#chun-b-mi-th-hun-luyn"),y(pt,"class","relative group"),y(is,"id","vng-lp-hun-luyn"),y(is,"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"),y(is,"href","#vng-lp-hun-luyn"),y(Ge,"class","relative group"),y(Xe,"href","https://huggingface.co/huggingface-course/bert-finetuned-ner-accelerate"),y(Xe,"rel","nofollow")},m(l,d){i(l,m,d),n(m,v),n(v,f),x($,f,null),n(m,O),n(m,k),n(k,j),i(l,q,d),i(l,D,d),n(D,z),n(D,I),n(I,A),n(D,N),n(D,V),n(V,B),n(D,R),i(l,F,d),i(l,M,d),n(M,W),n(M,T),n(T,U),n(M,L),n(M,K),n(K,nn),n(M,an),i(l,ln,d),x(Z,l,d),i(l,un,d),i(l,Q,d),n(Q,G),n(Q,H),n(H,en),n(Q,mn),i(l,kn,d),x(sn,l,d),i(l,Bn,d),i(l,Y,d),n(Y,at),n(Y,on),n(on,ft),n(Y,le),n(Y,lt),n(lt,Qe),n(Y,It),i(l,he,d),x(bn,l,d),i(l,De,d),x(En,l,d),i(l,gn,d),x(Vn,l,d),i(l,ce,d),i(l,tn,d),n(tn,pn),n(pn,re),x(Sn,re,null),n(tn,Mt),n(tn,ie),n(ie,Je),i(l,Un,d),i(l,In,d),n(In,Lt),n(In,oe),n(oe,Ht),n(In,Te),i(l,yn,d),x(wn,l,d),i(l,Rt,d),i(l,$n,d),n($n,bs),i(l,Ft,d),i(l,Xn,d),n(Xn,Pe),i(l,cn,d),x(Gt,l,d),i(l,Wn,d),i(l,dt,d),n(dt,vs),n(dt,_t),n(_t,bt),n(dt,ns),i(l,xn,d),x(Cn,l,d),i(l,pe,d),i(l,J,d),n(J,Vt),n(J,vt),n(vt,Kn),n(J,ts),n(J,On),n(On,ks),n(J,ze),n(J,ht),n(ht,Ae),n(Ae,es),n(J,kt),n(J,Mn),n(Mn,yt),n(J,Ne),n(J,$t),n($t,ys),n(J,ss),n(J,Zn),n(Zn,jt),n(J,fn),i(l,Et,d),x(Yn,l,d),i(l,ct,d),i(l,wt,d),n(wt,rt),n(wt,Ut),n(Ut,$s),n(wt,as),i(l,it,d),x(Xt,l,d),i(l,Be,d),i(l,qn,d),n(qn,ls),i(l,xt,d),i(l,Qn,d),n(Qn,Jn),n(Qn,ue),n(ue,Wt),n(Qn,Kt),i(l,me,d),x(vn,l,d),i(l,Se,d),i(l,Dn,d),n(Dn,g),i(l,S,d),x(ge,l,d),i(l,js,d),i(l,Zt,d),n(Zt,Tn),n(Tn,Es),n(Zt,fe),i(l,Ct,d),i(l,rn,d),n(rn,oa),i(l,Yt,d),i(l,Ot,d),n(Ot,Ln),n(Ln,de),x(_e,de,null),n(Ot,hs),n(Ot,be),n(be,pa),i(l,ws,d),i(l,ot,d),n(ot,ua),n(ot,Ie),n(Ie,nt),n(ot,ma),i(l,xs,d),i(l,pt,d),n(pt,dn),n(dn,Me),x(tt,Me,null),n(pt,Le),n(pt,Hn),n(Hn,et),i(l,He,d),i(l,Rn,d),n(Rn,ga),n(Rn,Qt),n(Qt,fa),n(Rn,da),n(Rn,Re),n(Re,st),n(Rn,_a),n(Rn,Cs),n(Cs,Ah),n(Rn,Nh),i(l,Vl,d),x(Pn,l,d),i(l,ba,d),i(l,va,d),n(va,Bh),i(l,ka,d),x(Os,l,d),i(l,Ul,d),i(l,qt,d),n(qt,Sh),n(qt,hl),n(hl,cl),n(qt,Ih),n(qt,rl),n(rl,Mh),n(qt,Dt),i(l,ya,d),x(qs,l,d),i(l,Xl,d),i(l,ve,d),n(ve,Lh),n(ve,il),n(il,ol),n(ve,Hh),i(l,Wl,d),x(Fe,l,d),i(l,Kl,d),x(Ds,l,d),i(l,Zl,d),i(l,_n,d),n(_n,pl),n(_n,ul),n(ul,Rh),n(_n,ml),n(_n,gl),n(gl,Fh),n(_n,fl),i(l,Yl,d),x(Ts,l,d),i(l,$a,d),i(l,Tt,d),n(Tt,Gh),n(Tt,dl),n(dl,Pt),n(Tt,_l),n(Tt,bl),n(bl,Vh),n(Tt,vl),n(Tt,kl),n(kl,Uh),n(Tt,yl),i(l,Ql,d),x(Ps,l,d),i(l,ja,d),x(zs,l,d),i(l,Jl,d),i(l,As,d),n(As,Ea),i(l,nh,d),x(cs,l,d),i(l,rs,d),i(l,Jt,d),n(Jt,Ns),n(Jt,wa),n(wa,ke),n(Jt,Xh),n(Jt,Bs),n(Bs,Wh),n(Jt,Kh),i(l,xa,d),i(l,Ge,d),n(Ge,is),n(is,Ca),x(ne,Ca,null),n(Ge,th),n(Ge,zt),n(zt,Zh),i(l,Oa,d),i(l,ye,d),n(ye,Yh),n(ye,Ss),n(Ss,Qh),n(ye,Jh),n(ye,qa),n(qa,os),n(ye,eh),i(l,$e,d),x(At,l,d),i(l,Da,d),i(l,je,d),n(je,nc),i(l,Ta,d),i(l,Ee,d),n(Ee,ps),n(ps,Is),n(ps,Pa),n(Pa,we),n(ps,tc),n(Ee,za),n(Ee,ut),n(ut,ec),n(ut,Ms),n(Ms,sc),n(ut,ac),n(ut,Aa),n(Aa,us),n(ut,lc),n(ut,Ls),n(Ls,hc),n(ut,cc),n(ut,Na),n(Na,Hs),n(ut,sh),n(Ee,zn),n(Ee,Ve),n(Ve,$l),n(Ve,jl),n(jl,rc),n(Ve,Rs),n(Ve,El),n(El,ic),n(Ve,Fs),i(l,ah,d),i(l,Ba,d),n(Ba,wl),i(l,lh,d),x(Gs,l,d),i(l,Sa,d),i(l,Ia,d),n(Ia,oc),i(l,xl,d),x(te,l,d),i(l,Cl,d),i(l,hn,d),n(hn,hh),n(hn,Nt),n(Nt,pc),n(hn,Ol),n(hn,ql),n(ql,uc),n(hn,Dl),n(hn,Tl),n(Tl,mc),n(hn,ch),n(hn,Ue),n(Ue,rh),n(hn,Vs),n(hn,Ma),n(Ma,An),n(hn,gc),n(hn,Us),n(Us,fc),n(hn,dc),n(hn,Xs),n(Xs,_c),n(hn,bc),i(l,La,d),i(l,xe,d),n(xe,vc),n(xe,Ws),n(Ws,kc),n(xe,yc),n(xe,Xe),n(Xe,Pl),n(Pl,$c),n(xe,ih),We=!0},i(l){We||(_($.$$.fragment,l),_(Z.$$.fragment,l),_(sn.$$.fragment,l),_(bn.$$.fragment,l),_(En.$$.fragment,l),_(Vn.$$.fragment,l),_(Sn.$$.fragment,l),_(wn.$$.fragment,l),_(Gt.$$.fragment,l),_(Cn.$$.fragment,l),_(Yn.$$.fragment,l),_(Xt.$$.fragment,l),_(vn.$$.fragment,l),_(ge.$$.fragment,l),_(_e.$$.fragment,l),_(tt.$$.fragment,l),_(Pn.$$.fragment,l),_(Os.$$.fragment,l),_(qs.$$.fragment,l),_(Fe.$$.fragment,l),_(Ds.$$.fragment,l),_(Ts.$$.fragment,l),_(Ps.$$.fragment,l),_(zs.$$.fragment,l),_(cs.$$.fragment,l),_(ne.$$.fragment,l),_(At.$$.fragment,l),_(Gs.$$.fragment,l),_(te.$$.fragment,l),We=!0)},o(l){b($.$$.fragment,l),b(Z.$$.fragment,l),b(sn.$$.fragment,l),b(bn.$$.fragment,l),b(En.$$.fragment,l),b(Vn.$$.fragment,l),b(Sn.$$.fragment,l),b(wn.$$.fragment,l),b(Gt.$$.fragment,l),b(Cn.$$.fragment,l),b(Yn.$$.fragment,l),b(Xt.$$.fragment,l),b(vn.$$.fragment,l),b(ge.$$.fragment,l),b(_e.$$.fragment,l),b(tt.$$.fragment,l),b(Pn.$$.fragment,l),b(Os.$$.fragment,l),b(qs.$$.fragment,l),b(Fe.$$.fragment,l),b(Ds.$$.fragment,l),b(Ts.$$.fragment,l),b(Ps.$$.fragment,l),b(zs.$$.fragment,l),b(cs.$$.fragment,l),b(ne.$$.fragment,l),b(At.$$.fragment,l),b(Gs.$$.fragment,l),b(te.$$.fragment,l),We=!1},d(l){l&&e(m),C($),l&&e(q),l&&e(D),l&&e(F),l&&e(M),l&&e(ln),C(Z,l),l&&e(un),l&&e(Q),l&&e(kn),C(sn,l),l&&e(Bn),l&&e(Y),l&&e(he),C(bn,l),l&&e(De),C(En,l),l&&e(gn),C(Vn,l),l&&e(ce),l&&e(tn),C(Sn),l&&e(Un),l&&e(In),l&&e(yn),C(wn,l),l&&e(Rt),l&&e($n),l&&e(Ft),l&&e(Xn),l&&e(cn),C(Gt,l),l&&e(Wn),l&&e(dt),l&&e(xn),C(Cn,l),l&&e(pe),l&&e(J),l&&e(Et),C(Yn,l),l&&e(ct),l&&e(wt),l&&e(it),C(Xt,l),l&&e(Be),l&&e(qn),l&&e(xt),l&&e(Qn),l&&e(me),C(vn,l),l&&e(Se),l&&e(Dn),l&&e(S),C(ge,l),l&&e(js),l&&e(Zt),l&&e(Ct),l&&e(rn),l&&e(Yt),l&&e(Ot),C(_e),l&&e(ws),l&&e(ot),l&&e(xs),l&&e(pt),C(tt),l&&e(He),l&&e(Rn),l&&e(Vl),C(Pn,l),l&&e(ba),l&&e(va),l&&e(ka),C(Os,l),l&&e(Ul),l&&e(qt),l&&e(ya),C(qs,l),l&&e(Xl),l&&e(ve),l&&e(Wl),C(Fe,l),l&&e(Kl),C(Ds,l),l&&e(Zl),l&&e(_n),l&&e(Yl),C(Ts,l),l&&e($a),l&&e(Tt),l&&e(Ql),C(Ps,l),l&&e(ja),C(zs,l),l&&e(Jl),l&&e(As),l&&e(nh),C(cs,l),l&&e(rs),l&&e(Jt),l&&e(xa),l&&e(Ge),C(ne),l&&e(Oa),l&&e(ye),l&&e($e),C(At,l),l&&e(Da),l&&e(je),l&&e(Ta),l&&e(Ee),l&&e(ah),l&&e(Ba),l&&e(lh),C(Gs,l),l&&e(Sa),l&&e(Ia),l&&e(xl),C(te,l),l&&e(Cl),l&&e(hn),l&&e(La),l&&e(xe)}}}function Yu(X){let m,v,f,$,O;return{c(){m=h("p"),v=s("\u26A0\uFE0F N\u1EBFu b\u1EA1n c\xF3 m\xF4 h\xECnh v\u1EDBi s\u1ED1 l\u01B0\u1EE3ng nh\xE3n sai, b\u1EA1n s\u1EBD nh\u1EADn m\u1ED9t l\u1ED7i kh\xF3 hi\u1EC3u khi g\u1ECDi h\xE0m "),f=h("code"),$=s("Trainer.train()"),O=s(" sau \u0111\xF3 (gi\u1ED1ng nh\u01B0 \u201CCUDA error: device-side assert triggered\u201D). \u0110\xE2y l\xE0 nguy\xEAn nh\xE2n s\u1ED1 m\u1ED9t g\xE2y ra l\u1ED7i do ng\u01B0\u1EDDi d\xF9ng b\xE1o c\xE1o v\u1EC1 nh\u1EEFng l\u1ED7i nh\u01B0 v\u1EADy, v\xEC v\u1EADy h\xE3y \u0111\u1EA3m b\u1EA3o b\u1EA1n th\u1EF1c hi\u1EC7n ki\u1EC3m tra n\xE0y \u0111\u1EC3 x\xE1c nh\u1EADn r\u1EB1ng b\u1EA1n c\xF3 s\u1ED1 l\u01B0\u1EE3ng nh\xE3n d\u1EF1 ki\u1EBFn.")},l(k){m=c(k,"P",{});var j=r(m);v=a(j,"\u26A0\uFE0F N\u1EBFu b\u1EA1n c\xF3 m\xF4 h\xECnh v\u1EDBi s\u1ED1 l\u01B0\u1EE3ng nh\xE3n sai, b\u1EA1n s\u1EBD nh\u1EADn m\u1ED9t l\u1ED7i kh\xF3 hi\u1EC3u khi g\u1ECDi h\xE0m "),f=c(j,"CODE",{});var q=r(f);$=a(q,"Trainer.train()"),q.forEach(e),O=a(j," sau \u0111\xF3 (gi\u1ED1ng nh\u01B0 \u201CCUDA error: device-side assert triggered\u201D). \u0110\xE2y l\xE0 nguy\xEAn nh\xE2n s\u1ED1 m\u1ED9t g\xE2y ra l\u1ED7i do ng\u01B0\u1EDDi d\xF9ng b\xE1o c\xE1o v\u1EC1 nh\u1EEFng l\u1ED7i nh\u01B0 v\u1EADy, v\xEC v\u1EADy h\xE3y \u0111\u1EA3m b\u1EA3o b\u1EA1n th\u1EF1c hi\u1EC7n ki\u1EC3m tra n\xE0y \u0111\u1EC3 x\xE1c nh\u1EADn r\u1EB1ng b\u1EA1n c\xF3 s\u1ED1 l\u01B0\u1EE3ng nh\xE3n d\u1EF1 ki\u1EBFn."),j.forEach(e)},m(k,j){i(k,m,j),n(m,v),n(m,f),n(f,$),n(m,O)},d(k){k&&e(m)}}}function Qu(X){let m,v,f,$,O;return{c(){m=h("p"),v=s("\u{1F4A1} N\u1EBFu th\u01B0 m\u1EE5c \u0111\u1EA7u ra b\u1EA1n \u0111ang s\u1EED d\u1EE5ng \u0111\xE3 t\u1ED3n t\u1EA1i, n\xF3 c\u1EA7n ph\u1EA3i l\xE0 b\u1EA3n sao c\u1EE5c b\u1ED9 c\u1EE7a kho l\u01B0u tr\u1EEF m\xE0 b\u1EA1n mu\u1ED1n \u0111\u1EA9y \u0111\u1EBFn. N\u1EBFu kh\xF4ng, b\u1EA1n s\u1EBD g\u1EB7p l\u1ED7i khi x\xE1c \u0111\u1ECBnh "),f=h("code"),$=s("Trainer"),O=s(" c\u1EE7a m\xECnh v\xE0 s\u1EBD c\u1EA7n \u0111\u1EB7t m\u1ED9t t\xEAn m\u1EDBi.")},l(k){m=c(k,"P",{});var j=r(m);v=a(j,"\u{1F4A1} N\u1EBFu th\u01B0 m\u1EE5c \u0111\u1EA7u ra b\u1EA1n \u0111ang s\u1EED d\u1EE5ng \u0111\xE3 t\u1ED3n t\u1EA1i, n\xF3 c\u1EA7n ph\u1EA3i l\xE0 b\u1EA3n sao c\u1EE5c b\u1ED9 c\u1EE7a kho l\u01B0u tr\u1EEF m\xE0 b\u1EA1n mu\u1ED1n \u0111\u1EA9y \u0111\u1EBFn. N\u1EBFu kh\xF4ng, b\u1EA1n s\u1EBD g\u1EB7p l\u1ED7i khi x\xE1c \u0111\u1ECBnh "),f=c(j,"CODE",{});var q=r(f);$=a(q,"Trainer"),q.forEach(e),O=a(j," c\u1EE7a m\xECnh v\xE0 s\u1EBD c\u1EA7n \u0111\u1EB7t m\u1ED9t t\xEAn m\u1EDBi."),j.forEach(e)},m(k,j){i(k,m,j),n(m,v),n(m,f),n(f,$),n(m,O)},d(k){k&&e(m)}}}function Ju(X){let m,v,f,$,O;return{c(){m=h("p"),v=s("\u{1F6A8} N\u1EBFu b\u1EA1n hu\u1EA5n luy\u1EC7n tr\xEAn TPU, b\u1EA1n s\u1EBD c\u1EA7n chuy\u1EC3n t\u1EA5t c\u1EA3 c\xE1c \u0111o\u1EA1n m\xE3 \u1EDF tr\xEAn th\xE0nh m\u1ED9t h\xE0m hu\u1EA5n luy\u1EC7n. Xem "),f=h("a"),$=s("Ch\u01B0\u01A1ng 3"),O=s(" \u0111\u1EC3 bi\u1EBFt th\xEAm chi ti\u1EBFt."),this.h()},l(k){m=c(k,"P",{});var j=r(m);v=a(j,"\u{1F6A8} N\u1EBFu b\u1EA1n hu\u1EA5n luy\u1EC7n tr\xEAn TPU, b\u1EA1n s\u1EBD c\u1EA7n chuy\u1EC3n t\u1EA5t c\u1EA3 c\xE1c \u0111o\u1EA1n m\xE3 \u1EDF tr\xEAn th\xE0nh m\u1ED9t h\xE0m hu\u1EA5n luy\u1EC7n. Xem "),f=c(j,"A",{href:!0});var q=r(f);$=a(q,"Ch\u01B0\u01A1ng 3"),q.forEach(e),O=a(j," \u0111\u1EC3 bi\u1EBFt th\xEAm chi ti\u1EBFt."),j.forEach(e),this.h()},h(){y(f,"href","/course/chapter3")},m(k,j){i(k,m,j),n(m,v),n(m,f),n(f,$),n(m,O)},d(k){k&&e(m)}}}function nm(X){let m,v,f,$,O,k,j,q,D,z,I,A,N,V,B,R,F,M,W,T,U,L,K,nn,an,ln,Z,un,Q,G,H,en,mn,kn,sn,Bn,Y,at,on,ft,le,lt,Qe,It,he,bn,De,En,gn,Vn,ce,tn,pn,re,Sn,Mt,ie,Je,Un,In,Lt,oe,Ht,Te,yn,wn,Rt,$n,bs,Ft,Xn,Pe,cn,Gt,Wn,dt,vs,_t,bt,ns,xn,Cn,pe,J,Vt,vt,Kn,ts,On,ks,ze,ht,Ae,es,kt,Mn,yt,Ne,$t,ys,ss,Zn,jt,fn,Et,Yn,ct,wt,rt,Ut,$s,as,it,Xt,Be,qn,ls,xt,Qn,Jn,ue,Wt,Kt,me,vn,Se,Dn,g,S,ge,js,Zt,Tn,Es,fe,Ct,rn,oa,Yt,Ot,Ln,de,_e,hs,be,pa,ws,ot,ua,Ie,nt,ma,xs,pt,dn,Me,tt,Le,Hn,et,He,Rn,ga,Qt,fa,da,Re,st,_a,Cs,Ah,Nh,Vl,Pn,ba,va,Bh,ka,Os,Ul,qt,Sh,hl,cl,Ih,rl,Mh,Dt,ya,qs,Xl,ve,Lh,il,ol,Hh,Wl,Fe,Kl,Ds,Zl,_n,pl,ul,Rh,ml,gl,Fh,fl,Yl,Ts,$a,Tt,Gh,dl,Pt,_l,bl,Vh,vl,kl,Uh,yl,Ql,Ps,ja,zs,Jl,As,Ea,nh,cs,rs,Jt,Ns,wa,ke,Xh,Bs,Wh,Kh,xa,Ge,is,Ca,ne,th,zt,Zh,Oa,ye,Yh,Ss,Qh,Jh,qa,os,eh,$e,At,Da,je,nc,Ta,Ee,ps,Is,Pa,we,tc,za,ut,ec,Ms,sc,ac,Aa,us,lc,Ls,hc,cc,Na,Hs,sh,zn,Ve,$l,jl,rc,Rs,El,ic,Fs,ah,Ba,wl,lh,Gs,Sa,Ia,oc,xl,te,Cl,hn,hh,Nt,pc,Ol,ql,uc,Dl,Tl,mc,ch,Ue,rh,Vs,Ma,An,gc,Us,fc,dc,Xs,_c,bc,La,xe,vc,Ws,kc,yc,Xe,Pl,$c,ih,We,l,d,sr,ar,jc,Ce,Ec,Ha,Ks,mt,lr,Ra,hr,Fa,oh,cr,ph,uh,rr,ir,Ga,or,pr,wc,ms,xc,jn,ur,Cc,Va,Oc,Ua,qc,Ke,mh,gh,mr,fh,dh,gr,Dc,Tc,Zs,zl,gt,fr,_h,bh,dr,Xa,_r,br,vh,gs,vr,kh,kr,yr,Ys,Wa,Pc,Qs,$r,Js,Al,jr,Ze,Ka,zc,na,Er,Ye,wr,xr,Nl,Oe,qe,Bl,Bt,ta,yh,Za,Ya,Qa,Cr,ee,se,Or,$h,qr,Ja,Sl,Dr,Tr,jh,Nn,Pr,Ac,ae,zr,nl,Eh,Ar,tl,wh,Nr,Br,ai,Yi,Qi,mi,ea,sa,Sr,Ir,Ji,gi,Nc,fi,Bc,di,Mr,no,_i,Sc,bi,Ic,vi,aa,la,Lr,Hr,Il,xh,li,Mc,to,hi,eo,ki,ha,ca,Rr,Lc,yi,Fr,so,$i,Hc,ji,Rc,Ei,Gr,ao,wi,Fc,xi,Vr,lo,Ci,Gc,Oi,ra,ia,Ur,Xr,Ml,Ch,ci,Vc,ho,ri,co,qi,Oh,ro,ii,io,oo,Di,Uc,Ti,Xc,Pi,Wr,po,zi;f=new zu({props:{fw:X[0]}}),q=new St({});const go=[Nu,Au],Wc=[];function fo(t,u){return t[0]==="pt"?0:1}N=fo(X),V=Wc[N]=go[N](X),It=new Eu({props:{id:"wVHdVlPScxA"}}),$n=new St({}),bt=new zh({props:{$$slots:{default:[Bu]},$$scope:{ctx:X}}}),J=new St({}),kt=new P({props:{code:`from datasets import load_dataset

raw_datasets = load_dataset("conll2003")`,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;conll2003&quot;</span>)`}}),jt=new P({props:{code:"raw_datasets",highlighted:"raw_datasets"}}),Et=new P({props:{code:`DatasetDict({
    train: Dataset({
        features: ['chunk_tags', 'id', 'ner_tags', 'pos_tags', 'tokens'],
        num_rows: 14041
    })
    validation: Dataset({
        features: ['chunk_tags', 'id', 'ner_tags', 'pos_tags', 'tokens'],
        num_rows: 3250
    })
    test: Dataset({
        features: ['chunk_tags', 'id', 'ner_tags', 'pos_tags', 'tokens'],
        num_rows: 3453
    })
})`,highlighted:`DatasetDict({
    train: Dataset({
        features: [<span class="hljs-string">&#x27;chunk_tags&#x27;</span>, <span class="hljs-string">&#x27;id&#x27;</span>, <span class="hljs-string">&#x27;ner_tags&#x27;</span>, <span class="hljs-string">&#x27;pos_tags&#x27;</span>, <span class="hljs-string">&#x27;tokens&#x27;</span>],
        num_rows: <span class="hljs-number">14041</span>
    })
    validation: Dataset({
        features: [<span class="hljs-string">&#x27;chunk_tags&#x27;</span>, <span class="hljs-string">&#x27;id&#x27;</span>, <span class="hljs-string">&#x27;ner_tags&#x27;</span>, <span class="hljs-string">&#x27;pos_tags&#x27;</span>, <span class="hljs-string">&#x27;tokens&#x27;</span>],
        num_rows: <span class="hljs-number">3250</span>
    })
    test: Dataset({
        features: [<span class="hljs-string">&#x27;chunk_tags&#x27;</span>, <span class="hljs-string">&#x27;id&#x27;</span>, <span class="hljs-string">&#x27;ner_tags&#x27;</span>, <span class="hljs-string">&#x27;pos_tags&#x27;</span>, <span class="hljs-string">&#x27;tokens&#x27;</span>],
        num_rows: <span class="hljs-number">3453</span>
    })
})`}}),qn=new P({props:{code:'raw_datasets["train"][0]["tokens"]',highlighted:'raw_datasets[<span class="hljs-string">&quot;train&quot;</span>][<span class="hljs-number">0</span>][<span class="hljs-string">&quot;tokens&quot;</span>]'}}),xt=new P({props:{code:"['EU', 'rejects', 'German', 'call', 'to', 'boycott', 'British', 'lamb', '.']",highlighted:'[<span class="hljs-string">&#x27;EU&#x27;</span>, <span class="hljs-string">&#x27;rejects&#x27;</span>, <span class="hljs-string">&#x27;German&#x27;</span>, <span class="hljs-string">&#x27;call&#x27;</span>, <span class="hljs-string">&#x27;to&#x27;</span>, <span class="hljs-string">&#x27;boycott&#x27;</span>, <span class="hljs-string">&#x27;British&#x27;</span>, <span class="hljs-string">&#x27;lamb&#x27;</span>, <span class="hljs-string">&#x27;.&#x27;</span>]'}}),Kt=new P({props:{code:'raw_datasets["train"][0]["ner_tags"]',highlighted:'raw_datasets[<span class="hljs-string">&quot;train&quot;</span>][<span class="hljs-number">0</span>][<span class="hljs-string">&quot;ner_tags&quot;</span>]'}}),vn=new P({props:{code:"[3, 0, 7, 0, 0, 0, 7, 0, 0]",highlighted:'[<span class="hljs-number">3</span>, <span class="hljs-number">0</span>, <span class="hljs-number">7</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">7</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>]'}}),Tn=new P({props:{code:`ner_feature = raw_datasets["train"].features["ner_tags"]
ner_feature`,highlighted:`ner_feature = raw_datasets[<span class="hljs-string">&quot;train&quot;</span>].features[<span class="hljs-string">&quot;ner_tags&quot;</span>]
ner_feature`}}),fe=new P({props:{code:"Sequence(feature=ClassLabel(num_classes=9, names=['O', 'B-PER', 'I-PER', 'B-ORG', 'I-ORG', 'B-LOC', 'I-LOC', 'B-MISC', 'I-MISC'], names_file=None, id=None), length=-1, id=None)",highlighted:'<span class="hljs-type">Sequence</span>(feature=ClassLabel(num_classes=<span class="hljs-number">9</span>, names=[<span class="hljs-string">&#x27;O&#x27;</span>, <span class="hljs-string">&#x27;B-PER&#x27;</span>, <span class="hljs-string">&#x27;I-PER&#x27;</span>, <span class="hljs-string">&#x27;B-ORG&#x27;</span>, <span class="hljs-string">&#x27;I-ORG&#x27;</span>, <span class="hljs-string">&#x27;B-LOC&#x27;</span>, <span class="hljs-string">&#x27;I-LOC&#x27;</span>, <span class="hljs-string">&#x27;B-MISC&#x27;</span>, <span class="hljs-string">&#x27;I-MISC&#x27;</span>], names_file=<span class="hljs-literal">None</span>, <span class="hljs-built_in">id</span>=<span class="hljs-literal">None</span>), length=-<span class="hljs-number">1</span>, <span class="hljs-built_in">id</span>=<span class="hljs-literal">None</span>)'}}),dn=new P({props:{code:`label_names = ner_feature.feature.names
label_names`,highlighted:`label_names = ner_feature.feature.names
label_names`}}),tt=new P({props:{code:"['O', 'B-PER', 'I-PER', 'B-ORG', 'I-ORG', 'B-LOC', 'I-LOC', 'B-MISC', 'I-MISC']",highlighted:'[<span class="hljs-string">&#x27;O&#x27;</span>, <span class="hljs-string">&#x27;B-PER&#x27;</span>, <span class="hljs-string">&#x27;I-PER&#x27;</span>, <span class="hljs-string">&#x27;B-ORG&#x27;</span>, <span class="hljs-string">&#x27;I-ORG&#x27;</span>, <span class="hljs-string">&#x27;B-LOC&#x27;</span>, <span class="hljs-string">&#x27;I-LOC&#x27;</span>, <span class="hljs-string">&#x27;B-MISC&#x27;</span>, <span class="hljs-string">&#x27;I-MISC&#x27;</span>]'}}),rs=new P({props:{code:`words = raw_datasets["train"][0]["tokens"]
labels = raw_datasets["train"][0]["ner_tags"]
line1 = ""
line2 = ""
for word, label in zip(words, labels):
    full_label = label_names[label]
    max_length = max(len(word), len(full_label))
    line1 += word + " " * (max_length - len(word) + 1)
    line2 += full_label + " " * (max_length - len(full_label) + 1)

print(line1)
print(line2)`,highlighted:`words = raw_datasets[<span class="hljs-string">&quot;train&quot;</span>][<span class="hljs-number">0</span>][<span class="hljs-string">&quot;tokens&quot;</span>]
labels = raw_datasets[<span class="hljs-string">&quot;train&quot;</span>][<span class="hljs-number">0</span>][<span class="hljs-string">&quot;ner_tags&quot;</span>]
line1 = <span class="hljs-string">&quot;&quot;</span>
line2 = <span class="hljs-string">&quot;&quot;</span>
<span class="hljs-keyword">for</span> word, label <span class="hljs-keyword">in</span> <span class="hljs-built_in">zip</span>(words, labels):
    full_label = label_names[label]
    max_length = <span class="hljs-built_in">max</span>(<span class="hljs-built_in">len</span>(word), <span class="hljs-built_in">len</span>(full_label))
    line1 += word + <span class="hljs-string">&quot; &quot;</span> * (max_length - <span class="hljs-built_in">len</span>(word) + <span class="hljs-number">1</span>)
    line2 += full_label + <span class="hljs-string">&quot; &quot;</span> * (max_length - <span class="hljs-built_in">len</span>(full_label) + <span class="hljs-number">1</span>)

<span class="hljs-built_in">print</span>(line1)
<span class="hljs-built_in">print</span>(line2)`}}),Ns=new P({props:{code:`'EU    rejects German call to boycott British lamb .'
'B-ORG O       B-MISC O    O  O       B-MISC  O    O'`,highlighted:`<span class="hljs-string">&#x27;EU    rejects German call to boycott British lamb .&#x27;</span>
<span class="hljs-string">&#x27;B-ORG O       B-MISC O    O  O       B-MISC  O    O&#x27;</span>`}}),ne=new P({props:{code:`'Germany \\'s representative to the European Union \\'s veterinary committee Werner Zwingmann said on Wednesday consumers should buy sheepmeat from countries other than Britain until the scientific advice was clearer .'
'B-LOC   O  O              O  O   B-ORG    I-ORG O  O          O         B-PER  I-PER     O    O  O         O         O      O   O         O    O         O     O    B-LOC   O     O   O          O      O   O       O'`,highlighted:`<span class="hljs-string">&#x27;Germany \\&#x27;s representative to the European Union \\&#x27;s veterinary committee Werner Zwingmann said on Wednesday consumers should buy sheepmeat from countries other than Britain until the scientific advice was clearer .&#x27;</span>
<span class="hljs-string">&#x27;B-LOC   O  O              O  O   B-ORG    I-ORG O  O          O         B-PER  I-PER     O    O  O         O         O      O   O         O    O         O     O    B-LOC   O     O   O          O      O   O       O&#x27;</span>`}}),os=new zh({props:{$$slots:{default:[Su]},$$scope:{ctx:X}}}),je=new St({}),Is=new Eu({props:{id:"iY2AZYdZAr0"}}),Hs=new P({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)`}}),te=new P({props:{code:"tokenizer.is_fast",highlighted:"tokenizer.is_fast"}}),hn=new P({props:{code:"True",highlighted:'<span class="hljs-literal">True</span>'}}),Ue=new P({props:{code:`inputs = tokenizer(raw_datasets["train"][0]["tokens"], is_split_into_words=True)
inputs.tokens()`,highlighted:`inputs = tokenizer(raw_datasets[<span class="hljs-string">&quot;train&quot;</span>][<span class="hljs-number">0</span>][<span class="hljs-string">&quot;tokens&quot;</span>], is_split_into_words=<span class="hljs-literal">True</span>)
inputs.tokens()`}}),Vs=new P({props:{code:"['[CLS]', 'EU', 'rejects', 'German', 'call', 'to', 'boycott', 'British', 'la', '##mb', '.', '[SEP]']",highlighted:'[<span class="hljs-string">&#x27;[CLS]&#x27;</span>, <span class="hljs-string">&#x27;EU&#x27;</span>, <span class="hljs-string">&#x27;rejects&#x27;</span>, <span class="hljs-string">&#x27;German&#x27;</span>, <span class="hljs-string">&#x27;call&#x27;</span>, <span class="hljs-string">&#x27;to&#x27;</span>, <span class="hljs-string">&#x27;boycott&#x27;</span>, <span class="hljs-string">&#x27;British&#x27;</span>, <span class="hljs-string">&#x27;la&#x27;</span>, <span class="hljs-string">&#x27;##mb&#x27;</span>, <span class="hljs-string">&#x27;.&#x27;</span>, <span class="hljs-string">&#x27;[SEP]&#x27;</span>]'}}),Ce=new P({props:{code:"inputs.word_ids()",highlighted:"inputs.word_ids()"}}),Ha=new P({props:{code:"[None, 0, 1, 2, 3, 4, 5, 6, 7, 7, 8, None]",highlighted:'[<span class="hljs-literal">None</span>, <span class="hljs-number">0</span>, <span class="hljs-number">1</span>, <span class="hljs-number">2</span>, <span class="hljs-number">3</span>, <span class="hljs-number">4</span>, <span class="hljs-number">5</span>, <span class="hljs-number">6</span>, <span class="hljs-number">7</span>, <span class="hljs-number">7</span>, <span class="hljs-number">8</span>, <span class="hljs-literal">None</span>]'}}),ms=new P({props:{code:`def align_labels_with_tokens(labels, word_ids):
    new_labels = []
    current_word = None
    for word_id in word_ids:
        if word_id != current_word:
            # B\u1EAFt \u0111\u1EA7u m\u1ED9t t\u1EEB m\u1EDBi!
            current_word = word_id
            label = -100 if word_id is None else labels[word_id]
            new_labels.append(label)
        elif word_id is None:
            # Token \u0111\u1EB7c bi\u1EC7t
            new_labels.append(-100)
        else:
            # T\u1EEB gi\u1ED1ng v\u1EDBi token tr\u01B0\u1EDBc \u0111\xF3
            label = labels[word_id]
            # N\u1EBFu nh\xE3n l\xE0 B-XXX, ta \u0111\u1ED5i sang I-XXX
            if label % 2 == 1:
                label += 1
            new_labels.append(label)

    return new_labels`,highlighted:`<span class="hljs-keyword">def</span> <span class="hljs-title function_">align_labels_with_tokens</span>(<span class="hljs-params">labels, word_ids</span>):
    new_labels = []
    current_word = <span class="hljs-literal">None</span>
    <span class="hljs-keyword">for</span> word_id <span class="hljs-keyword">in</span> word_ids:
        <span class="hljs-keyword">if</span> word_id != current_word:
            <span class="hljs-comment"># B\u1EAFt \u0111\u1EA7u m\u1ED9t t\u1EEB m\u1EDBi!</span>
            current_word = word_id
            label = -<span class="hljs-number">100</span> <span class="hljs-keyword">if</span> word_id <span class="hljs-keyword">is</span> <span class="hljs-literal">None</span> <span class="hljs-keyword">else</span> labels[word_id]
            new_labels.append(label)
        <span class="hljs-keyword">elif</span> word_id <span class="hljs-keyword">is</span> <span class="hljs-literal">None</span>:
            <span class="hljs-comment"># Token \u0111\u1EB7c bi\u1EC7t</span>
            new_labels.append(-<span class="hljs-number">100</span>)
        <span class="hljs-keyword">else</span>:
            <span class="hljs-comment"># T\u1EEB gi\u1ED1ng v\u1EDBi token tr\u01B0\u1EDBc \u0111\xF3</span>
            label = labels[word_id]
            <span class="hljs-comment"># N\u1EBFu nh\xE3n l\xE0 B-XXX, ta \u0111\u1ED5i sang I-XXX</span>
            <span class="hljs-keyword">if</span> label % <span class="hljs-number">2</span> == <span class="hljs-number">1</span>:
                label += <span class="hljs-number">1</span>
            new_labels.append(label)

    <span class="hljs-keyword">return</span> new_labels`}}),Va=new P({props:{code:`labels = raw_datasets["train"][0]["ner_tags"]
word_ids = inputs.word_ids()
print(labels)
print(align_labels_with_tokens(labels, word_ids))`,highlighted:`labels = raw_datasets[<span class="hljs-string">&quot;train&quot;</span>][<span class="hljs-number">0</span>][<span class="hljs-string">&quot;ner_tags&quot;</span>]
word_ids = inputs.word_ids()
<span class="hljs-built_in">print</span>(labels)
<span class="hljs-built_in">print</span>(align_labels_with_tokens(labels, word_ids))`}}),Ua=new P({props:{code:`[3, 0, 7, 0, 0, 0, 7, 0, 0]
[-100, 3, 0, 7, 0, 0, 0, 7, 0, 0, 0, -100]`,highlighted:`[<span class="hljs-number">3</span>, <span class="hljs-number">0</span>, <span class="hljs-number">7</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">7</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>]
[-<span class="hljs-number">100</span>, <span class="hljs-number">3</span>, <span class="hljs-number">0</span>, <span class="hljs-number">7</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">7</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>, -<span class="hljs-number">100</span>]`}}),Zs=new zh({props:{$$slots:{default:[Iu]},$$scope:{ctx:X}}}),Wa=new P({props:{code:`def tokenize_and_align_labels(examples):
    tokenized_inputs = tokenizer(
        examples["tokens"], truncation=True, is_split_into_words=True
    )
    all_labels = examples["ner_tags"]
    new_labels = []
    for i, labels in enumerate(all_labels):
        word_ids = tokenized_inputs.word_ids(i)
        new_labels.append(align_labels_with_tokens(labels, word_ids))

    tokenized_inputs["labels"] = new_labels
    return tokenized_inputs`,highlighted:`<span class="hljs-keyword">def</span> <span class="hljs-title function_">tokenize_and_align_labels</span>(<span class="hljs-params">examples</span>):
    tokenized_inputs = tokenizer(
        examples[<span class="hljs-string">&quot;tokens&quot;</span>], truncation=<span class="hljs-literal">True</span>, is_split_into_words=<span class="hljs-literal">True</span>
    )
    all_labels = examples[<span class="hljs-string">&quot;ner_tags&quot;</span>]
    new_labels = []
    <span class="hljs-keyword">for</span> i, labels <span class="hljs-keyword">in</span> <span class="hljs-built_in">enumerate</span>(all_labels):
        word_ids = tokenized_inputs.word_ids(i)
        new_labels.append(align_labels_with_tokens(labels, word_ids))

    tokenized_inputs[<span class="hljs-string">&quot;labels&quot;</span>] = new_labels
    <span class="hljs-keyword">return</span> tokenized_inputs`}}),Ka=new P({props:{code:`tokenized_datasets = raw_datasets.map(
    tokenize_and_align_labels,
    batched=True,
    remove_columns=raw_datasets["train"].column_names,
)`,highlighted:`tokenized_datasets = raw_datasets.<span class="hljs-built_in">map</span>(
    tokenize_and_align_labels,
    batched=<span class="hljs-literal">True</span>,
    remove_columns=raw_datasets[<span class="hljs-string">&quot;train&quot;</span>].column_names,
)`}});const _o=[Lu,Mu],Kc=[];function bo(t,u){return t[0]==="pt"?0:1}Oe=bo(X),qe=Kc[Oe]=_o[Oe](X),Za=new St({});const vo=[Ru,Hu],Zc=[];function ko(t,u){return t[0]==="pt"?0:1}ea=ko(X),sa=Zc[ea]=vo[ea](X),Nc=new P({props:{code:`batch = data_collator([tokenized_datasets["train"][i] for i in range(2)])
batch["labels"]`,highlighted:`batch = data_collator([tokenized_datasets[<span class="hljs-string">&quot;train&quot;</span>][i] <span class="hljs-keyword">for</span> i <span class="hljs-keyword">in</span> <span class="hljs-built_in">range</span>(<span class="hljs-number">2</span>)])
batch[<span class="hljs-string">&quot;labels&quot;</span>]`}}),Bc=new P({props:{code:`tensor([[-100,    3,    0,    7,    0,    0,    0,    7,    0,    0,    0, -100],
        [-100,    1,    2, -100, -100, -100, -100, -100, -100, -100, -100, -100]])`,highlighted:`tensor([[-<span class="hljs-number">100</span>,    <span class="hljs-number">3</span>,    <span class="hljs-number">0</span>,    <span class="hljs-number">7</span>,    <span class="hljs-number">0</span>,    <span class="hljs-number">0</span>,    <span class="hljs-number">0</span>,    <span class="hljs-number">7</span>,    <span class="hljs-number">0</span>,    <span class="hljs-number">0</span>,    <span class="hljs-number">0</span>, -<span class="hljs-number">100</span>],
        [-<span class="hljs-number">100</span>,    <span class="hljs-number">1</span>,    <span class="hljs-number">2</span>, -<span class="hljs-number">100</span>, -<span class="hljs-number">100</span>, -<span class="hljs-number">100</span>, -<span class="hljs-number">100</span>, -<span class="hljs-number">100</span>, -<span class="hljs-number">100</span>, -<span class="hljs-number">100</span>, -<span class="hljs-number">100</span>, -<span class="hljs-number">100</span>]])`}}),Sc=new P({props:{code:`for i in range(2):
    print(tokenized_datasets["train"][i]["labels"])`,highlighted:`<span class="hljs-keyword">for</span> i <span class="hljs-keyword">in</span> <span class="hljs-built_in">range</span>(<span class="hljs-number">2</span>):
    <span class="hljs-built_in">print</span>(tokenized_datasets[<span class="hljs-string">&quot;train&quot;</span>][i][<span class="hljs-string">&quot;labels&quot;</span>])`}}),Ic=new P({props:{code:`[-100, 3, 0, 7, 0, 0, 0, 7, 0, 0, 0, -100]
[-100, 1, 2, -100]`,highlighted:`[-<span class="hljs-number">100</span>, <span class="hljs-number">3</span>, <span class="hljs-number">0</span>, <span class="hljs-number">7</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">7</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>, -<span class="hljs-number">100</span>]
[-<span class="hljs-number">100</span>, <span class="hljs-number">1</span>, <span class="hljs-number">2</span>, -<span class="hljs-number">100</span>]`}});const yo=[Gu,Fu],Yc=[];function $o(t,u){return t[0]==="pt"?0:1}aa=$o(X),la=Yc[aa]=yo[aa](X);let Fn=X[0]==="tf"&&wu(X);Mc=new St({});const jo=[Wu,Xu],Qc=[];function Eo(t,u){return t[0]==="pt"?0:1}ha=Eo(X),ca=Qc[ha]=jo[ha](X),Lc=new P({props:{code:`import evaluate

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

metric = evaluate.load(<span class="hljs-string">&quot;seqeval&quot;</span>)`}}),Hc=new P({props:{code:`labels = raw_datasets["train"][0]["ner_tags"]
labels = [label_names[i] for i in labels]
labels`,highlighted:`labels = raw_datasets[<span class="hljs-string">&quot;train&quot;</span>][<span class="hljs-number">0</span>][<span class="hljs-string">&quot;ner_tags&quot;</span>]
labels = [label_names[i] <span class="hljs-keyword">for</span> i <span class="hljs-keyword">in</span> labels]
labels`}}),Rc=new P({props:{code:"['B-ORG', 'O', 'B-MISC', 'O', 'O', 'O', 'B-MISC', 'O', 'O']",highlighted:'[<span class="hljs-string">&#x27;B-ORG&#x27;</span>, <span class="hljs-string">&#x27;O&#x27;</span>, <span class="hljs-string">&#x27;B-MISC&#x27;</span>, <span class="hljs-string">&#x27;O&#x27;</span>, <span class="hljs-string">&#x27;O&#x27;</span>, <span class="hljs-string">&#x27;O&#x27;</span>, <span class="hljs-string">&#x27;B-MISC&#x27;</span>, <span class="hljs-string">&#x27;O&#x27;</span>, <span class="hljs-string">&#x27;O&#x27;</span>]'}}),Fc=new P({props:{code:`predictions = labels.copy()
predictions[2] = "O"
metric.compute(predictions=[predictions], references=[labels])`,highlighted:`predictions = labels.copy()
predictions[<span class="hljs-number">2</span>] = <span class="hljs-string">&quot;O&quot;</span>
metric.compute(predictions=[predictions], references=[labels])`}}),Gc=new P({props:{code:`{'MISC': {'precision': 1.0, 'recall': 0.5, 'f1': 0.67, 'number': 2},
 'ORG': {'precision': 1.0, 'recall': 1.0, 'f1': 1.0, 'number': 1},
 'overall_precision': 1.0,
 'overall_recall': 0.67,
 'overall_f1': 0.8,
 'overall_accuracy': 0.89}`,highlighted:`{<span class="hljs-string">&#x27;MISC&#x27;</span>: {<span class="hljs-string">&#x27;precision&#x27;</span>: <span class="hljs-number">1.0</span>, <span class="hljs-string">&#x27;recall&#x27;</span>: <span class="hljs-number">0.5</span>, <span class="hljs-string">&#x27;f1&#x27;</span>: <span class="hljs-number">0.67</span>, <span class="hljs-string">&#x27;number&#x27;</span>: <span class="hljs-number">2</span>},
 <span class="hljs-string">&#x27;ORG&#x27;</span>: {<span class="hljs-string">&#x27;precision&#x27;</span>: <span class="hljs-number">1.0</span>, <span class="hljs-string">&#x27;recall&#x27;</span>: <span class="hljs-number">1.0</span>, <span class="hljs-string">&#x27;f1&#x27;</span>: <span class="hljs-number">1.0</span>, <span class="hljs-string">&#x27;number&#x27;</span>: <span class="hljs-number">1</span>},
 <span class="hljs-string">&#x27;overall_precision&#x27;</span>: <span class="hljs-number">1.0</span>,
 <span class="hljs-string">&#x27;overall_recall&#x27;</span>: <span class="hljs-number">0.67</span>,
 <span class="hljs-string">&#x27;overall_f1&#x27;</span>: <span class="hljs-number">0.8</span>,
 <span class="hljs-string">&#x27;overall_accuracy&#x27;</span>: <span class="hljs-number">0.89</span>}`}});const wo=[Zu,Ku],Jc=[];function xo(t,u){return t[0]==="pt"?0:1}ra=xo(X),ia=Jc[ra]=wo[ra](X);let Gn=X[0]==="pt"&&xu(X);return Vc=new St({}),Uc=new P({props:{code:`from transformers import pipeline

# Thay th\u1EBF n\xF3 v\u1EDBi checkpoint c\u1EE7a ta
model_checkpoint = "huggingface-course/bert-finetuned-ner"
token_classifier = pipeline(
    "token-classification", model=model_checkpoint, aggregation_strategy="simple"
)
token_classifier("My name is Sylvain and I work at Hugging Face in Brooklyn.")`,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 ta</span>
model_checkpoint = <span class="hljs-string">&quot;huggingface-course/bert-finetuned-ner&quot;</span>
token_classifier = pipeline(
    <span class="hljs-string">&quot;token-classification&quot;</span>, model=model_checkpoint, aggregation_strategy=<span class="hljs-string">&quot;simple&quot;</span>
)
token_classifier(<span class="hljs-string">&quot;My name is Sylvain and I work at Hugging Face in Brooklyn.&quot;</span>)`}}),Xc=new P({props:{code:`[{'entity_group': 'PER', 'score': 0.9988506, 'word': 'Sylvain', 'start': 11, 'end': 18},
 {'entity_group': 'ORG', 'score': 0.9647625, 'word': 'Hugging Face', 'start': 33, 'end': 45},
 {'entity_group': 'LOC', 'score': 0.9986118, 'word': 'Brooklyn', 'start': 49, 'end': 57}]`,highlighted:`[{<span class="hljs-string">&#x27;entity_group&#x27;</span>: <span class="hljs-string">&#x27;PER&#x27;</span>, <span class="hljs-string">&#x27;score&#x27;</span>: <span class="hljs-number">0.9988506</span>, <span class="hljs-string">&#x27;word&#x27;</span>: <span class="hljs-string">&#x27;Sylvain&#x27;</span>, <span class="hljs-string">&#x27;start&#x27;</span>: <span class="hljs-number">11</span>, <span class="hljs-string">&#x27;end&#x27;</span>: <span class="hljs-number">18</span>},
 {<span class="hljs-string">&#x27;entity_group&#x27;</span>: <span class="hljs-string">&#x27;ORG&#x27;</span>, <span class="hljs-string">&#x27;score&#x27;</span>: <span class="hljs-number">0.9647625</span>, <span class="hljs-string">&#x27;word&#x27;</span>: <span class="hljs-string">&#x27;Hugging Face&#x27;</span>, <span class="hljs-string">&#x27;start&#x27;</span>: <span class="hljs-number">33</span>, <span class="hljs-string">&#x27;end&#x27;</span>: <span class="hljs-number">45</span>},
 {<span class="hljs-string">&#x27;entity_group&#x27;</span>: <span class="hljs-string">&#x27;LOC&#x27;</span>, <span class="hljs-string">&#x27;score&#x27;</span>: <span class="hljs-number">0.9986118</span>, <span class="hljs-string">&#x27;word&#x27;</span>: <span class="hljs-string">&#x27;Brooklyn&#x27;</span>, <span class="hljs-string">&#x27;start&#x27;</span>: <span class="hljs-number">49</span>, <span class="hljs-string">&#x27;end&#x27;</span>: <span class="hljs-number">57</span>}]`}}),{c(){m=h("meta"),v=o(),E(f.$$.fragment),$=o(),O=h("h1"),k=h("a"),j=h("span"),E(q.$$.fragment),D=o(),z=h("span"),I=s("Ph\xE2n lo\u1EA1i token"),A=o(),V.c(),B=o(),R=h("p"),F=s("\u1EE8ng d\u1EE5ng \u0111\u1EA7u ti\xEAn ch\xFAng ta s\u1EBD c\xF9ng kh\xE1m ph\xE1 l\xE0 ph\xE2n lo\u1EA1i token. T\xE1c v\u1EE5 chung n\xE0y bao g\u1ED3m b\u1EA5t k\u1EF3 v\u1EA5n \u0111\u1EC1 n\xE0o c\xF3 th\u1EC3 \u0111\u01B0\u1EE3c x\xE2y d\u1EF1ng d\u01B0\u1EDBi d\u1EA1ng \u201Cg\xE1n nh\xE3n cho m\u1ED7i token trong m\u1ED9t c\xE2u\u201D, ch\u1EB3ng h\u1EA1n nh\u01B0:"),M=o(),W=h("ul"),T=h("li"),U=h("strong"),L=s("Nh\u1EADn d\u1EA1ng th\u1EF1c th\u1EC3 \u0111\u01B0\u1EE3c \u0111\u1EB7t t\xEAn (NER)"),K=s(": T\xECm c\xE1c th\u1EF1c th\u1EC3 (ch\u1EB3ng h\u1EA1n nh\u01B0 ng\u01B0\u1EDDi, \u0111\u1ECBa \u0111i\u1EC3m ho\u1EB7c t\u1ED5 ch\u1EE9c) trong m\u1ED9t c\xE2u. \u0110i\u1EC1u n\xE0y c\xF3 th\u1EC3 \u0111\u01B0\u1EE3c x\xE2y d\u1EF1ng nh\u01B0 l\xE0 g\xE1n nh\xE3n cho m\u1ED7i token b\u1EB1ng c\xE1ch c\xF3 m\u1ED9t nh\xE3n cho m\u1ED7i th\u1EF1c th\u1EC3 v\xE0 m\u1ED9t nh\xE3n cho \u201Ckh\xF4ng c\xF3 th\u1EF1c th\u1EC3\u201D."),nn=o(),an=h("li"),ln=h("strong"),Z=s("G\xE1n nh\xE3n t\u1EEB lo\u1EA1i (POS)"),un=s(": \u0110\xE1nh d\u1EA5u m\u1ED7i t\u1EEB trong c\xE2u t\u01B0\u01A1ng \u1EE9ng v\u1EDBi m\u1ED9t t\u1EEB lo\u1EA1i c\u1EE5 th\u1EC3 c\u1EE7a v\u0103n b\u1EA3n (ch\u1EB3ng h\u1EA1n nh\u01B0 danh t\u1EEB, \u0111\u1ED9ng t\u1EEB, t\xEDnh t\u1EEB, v.v.)."),Q=o(),G=h("li"),H=h("strong"),en=s("Ph\xE2n kh\xFAc"),mn=s(": T\xECm c\xE1c token thu\u1ED9c c\xF9ng m\u1ED9t th\u1EF1c th\u1EC3. T\xE1c v\u1EE5 n\xE0y (c\xF3 th\u1EC3 \u0111\u01B0\u1EE3c k\u1EBFt h\u1EE3p v\u1EDBi POS ho\u1EB7c NER) c\xF3 th\u1EC3 \u0111\u01B0\u1EE3c x\xE2y d\u1EF1ng d\u01B0\u1EDBi d\u1EA1ng g\xE1n m\u1ED9t nh\xE3n (th\u01B0\u1EDDng l\xE0 "),kn=h("code"),sn=s("B-"),Bn=s(") cho b\u1EA5t k\u1EF3 token n\xE0o \u1EDF \u0111\u1EA7u m\u1ED9t \u0111o\u1EA1n, m\u1ED9t nh\xE3n kh\xE1c (th\u01B0\u1EDDng l\xE0 "),Y=h("code"),at=s("I-"),on=s(") cho c\xE1c token \u0111\xF3 n\u1EB1m b\xEAn trong m\u1ED9t \u0111o\u1EA1n v\xE0 m\u1ED9t nh\xE3n th\u1EE9 ba (th\u01B0\u1EDDng l\xE0 "),ft=h("code"),le=s("O"),lt=s(") token kh\xF4ng thu\u1ED9c b\u1EA5t k\u1EF3 \u0111o\u1EA1n n\xE0o."),Qe=o(),E(It.$$.fragment),he=o(),bn=h("p"),De=s("T\u1EA5t nhi\xEAn, c\xF3 nhi\u1EC1u lo\u1EA1i v\u1EA5n \u0111\u1EC1 ph\xE2n lo\u1EA1i token kh\xE1c; \u0111\xF3 ch\u1EC9 l\xE0 m\u1ED9t v\xE0i v\xED d\u1EE5 ti\xEAu bi\u1EC3u. Trong ph\u1EA7n n\xE0y, ch\xFAng ta s\u1EBD tinh ch\u1EC9nh m\u1ED9t m\xF4 h\xECnh (BERT) tr\xEAn m\u1ED9t t\xE1c v\u1EE5 NER, sau \u0111\xF3 s\u1EBD c\xF3 th\u1EC3 t\xEDnh to\xE1n c\xE1c d\u1EF1 \u0111o\xE1n nh\u01B0 sau:"),En=o(),gn=h("iframe"),ce=o(),tn=h("a"),pn=h("img"),Sn=o(),Mt=h("img"),Je=o(),Un=h("p"),In=s("B\u1EA1n c\xF3 th\u1EC3 t\xECm m\xF4 h\xECnh ta s\u1EBD hu\u1EA5n luy\u1EC7n v\xE0 t\u1EA3i l\xEAn Hub v\xE0 ki\u1EC3m tra l\u1EA1i c\xE1c d\u1EF1 \u0111o\xE1n "),Lt=h("a"),oe=s("t\u1EA1i \u0111\xE2y"),Ht=s("."),Te=o(),yn=h("h2"),wn=h("a"),Rt=h("span"),E($n.$$.fragment),bs=o(),Ft=h("span"),Xn=s("Chu\u1EA9n b\u1ECB d\u1EEF li\u1EC7u"),Pe=o(),cn=h("p"),Gt=s("\u0110\u1EA7u ti\xEAn, ta c\u1EA7n b\u1ED9 d\u1EEF li\u1EC7u chu\u1EA9n b\u1ECB cho ph\xE2n lo\u1EA1i token. Trong ch\u01B0\u01A1ng n\xE0y, ch\xFAng ta s\u1EBD s\u1EED d\u1EE5ng b\u1ED9 d\u1EEF li\u1EC7u "),Wn=h("a"),dt=s("CoNLL-2003"),vs=s(", bao g\u1ED3m c\xE1c c\xE2u chuy\u1EC7n tin t\u1EE9c t\u1EEB Reuters."),_t=o(),E(bt.$$.fragment),ns=o(),xn=h("h3"),Cn=h("a"),pe=h("span"),E(J.$$.fragment),Vt=o(),vt=h("span"),Kn=s("T\u1EADp d\u1EEF li\u1EC7u CoNLL-2003"),ts=o(),On=h("p"),ks=s("\u0110\u1EC3 t\u1EA3i b\u1ED9 d\u1EEF li\u1EC7u CoNLL-2003, ta c\u1EA7n s\u1EED d\u1EE5ng ph\u01B0\u01A1ng th\u1EE9c "),ze=h("code"),ht=s("load_dataset()"),Ae=s(" t\u1EEB th\u01B0 vi\u1EC7n \u{1F917} Datasets:"),es=o(),E(kt.$$.fragment),Mn=o(),yt=h("p"),Ne=s("Ta s\u1EBD t\u1EA3i v\xE0 l\u01B0u b\u1ED9 d\u1EEF li\u1EC7u v\xE0o cache, nh\u01B0 ta \u0111\xE3 th\u1EA5y trong "),$t=h("a"),ys=s("Ch\u01B0\u01A1ng 3"),ss=s(" cho b\u1ED9 d\u1EEF li\u1EC7u GLUE MRPC. Vi\u1EC7c ki\u1EC3m tra \u0111\u1ED1i t\u01B0\u1EE3ng n\xE0y cho ch\xFAng ta th\u1EA5y c\xE1c c\u1ED9t hi\u1EC7n c\xF3 v\xE0 s\u1EF1 ph\xE2n chia gi\u1EEFa c\xE1c t\u1EADp hu\u1EA5n luy\u1EC7n, ki\u1EC3m \u0111\u1ECBnh v\xE0 ki\u1EC3m th\u1EED:"),Zn=o(),E(jt.$$.fragment),fn=o(),E(Et.$$.fragment),Yn=o(),ct=h("p"),wt=s("\u0110\u1EB7c bi\u1EC7t, ch\xFAng ta c\xF3 th\u1EC3 th\u1EA5y t\u1EADp d\u1EEF li\u1EC7u ch\u1EE9a c\xE1c nh\xE3n cho ba t\xE1c v\u1EE5 m\xE0 ch\xFAng ta \u0111\xE3 \u0111\u1EC1 c\u1EADp tr\u01B0\u1EDBc \u0111\xF3: NER, POS v\xE0 chunking. M\u1ED9t s\u1EF1 kh\xE1c bi\u1EC7t l\u1EDBn so v\u1EDBi c\xE1c b\u1ED9 d\u1EEF li\u1EC7u kh\xE1c l\xE0 c\xE1c v\u0103n b\u1EA3n \u0111\u1EA7u v\xE0o kh\xF4ng \u0111\u01B0\u1EE3c tr\xECnh b\xE0y d\u01B0\u1EDBi d\u1EA1ng c\xE2u ho\u1EB7c t\xE0i li\u1EC7u, m\xE0 l\xE0 danh s\xE1ch c\xE1c t\u1EEB (c\u1ED9t cu\u1ED1i c\xF9ng \u0111\u01B0\u1EE3c g\u1ECDi l\xE0 "),rt=h("code"),Ut=s("tokens"),$s=s(", nh\u01B0ng n\xF3 ch\u1EE9a c\xE1c t\u1EEB theo ngh\u0129a \u0111\xE2y l\xE0 c\xE1c \u0111\u1EA7u v\xE0o \u0111\u01B0\u1EE3c tokenize tr\u01B0\u1EDBc v\u1EABn c\u1EA7n \u0111\u1EC3 \u0111i qua tr\xECnh tokenize \u0111\u1EC3 tokenize t\u1EEB ph\u1EE5)."),as=o(),it=h("p"),Xt=s("H\xE3y xem ph\u1EA7n t\u1EED \u0111\u1EA7u ti\xEAn c\u1EE7a t\u1EADp hu\u1EA5n luy\u1EC7n:"),Be=o(),E(qn.$$.fragment),ls=o(),E(xt.$$.fragment),Qn=o(),Jn=h("p"),ue=s("V\xEC ta mu\u1ED1n th\u1EF1c hi\u1EC7n nh\u1EADn d\u1EA1ng th\u1EF1c th\u1EC3 \u0111\u01B0\u1EE3c \u0111\u1EB7t t\xEAn, ch\xFAng ta s\u1EBD nh\xECn v\xE0o c\xE1c th\u1EBB NER:"),Wt=o(),E(Kt.$$.fragment),me=o(),E(vn.$$.fragment),Se=o(),Dn=h("p"),g=s("\u0110\xF3 l\xE0 nh\u1EEFng nh\xE3n d\u01B0\u1EDBi d\u1EA1ng s\u1ED1 nguy\xEAn s\u1EB5n s\xE0ng \u0111\u1EC3 hu\u1EA5n luy\u1EC7n, nh\u01B0ng ch\xFAng kh\xF4ng nh\u1EA5t thi\u1EBFt h\u1EEFu \xEDch khi ch\xFAng ta mu\u1ED1n ki\u1EC3m tra d\u1EEF li\u1EC7u. Gi\u1ED1ng nh\u01B0 ph\xE2n lo\u1EA1i v\u0103n b\u1EA3n, ch\xFAng ta c\xF3 th\u1EC3 truy c\u1EADp s\u1EF1 t\u01B0\u01A1ng \u1EE9ng gi\u1EEFa c\xE1c s\u1ED1 nguy\xEAn \u0111\xF3 v\xE0 t\xEAn nh\xE3n b\u1EB1ng c\xE1ch xem thu\u1ED9c t\xEDnh "),S=h("code"),ge=s("features"),js=s(" c\u1EE7a t\u1EADp d\u1EEF li\u1EC7u:"),Zt=o(),E(Tn.$$.fragment),Es=o(),E(fe.$$.fragment),Ct=o(),rn=h("p"),oa=s("V\xEC v\u1EADy, c\u1ED9t n\xE0y ch\u1EE9a c\xE1c ph\u1EA7n t\u1EED l\xE0 chu\u1ED7i c\u1EE7a "),Yt=h("code"),Ot=s("ClassLabel"),Ln=s(". Lo\u1EA1i ph\u1EA7n t\u1EED c\u1EE7a chu\u1ED7i n\u1EB1m trong thu\u1ED9c t\xEDnh "),de=h("code"),_e=s("feature"),hs=s(" c\u1EE7a "),be=h("code"),pa=s("ner_feature"),ws=s(" n\xE0y, v\xE0 ch\xFAng ta c\xF3 th\u1EC3 truy c\u1EADp danh s\xE1ch t\xEAn b\u1EB1ng c\xE1ch xem thu\u1ED9c t\xEDnh "),ot=h("code"),ua=s("names"),Ie=s(" c\u1EE7a "),nt=h("code"),ma=s("feature"),xs=s(" \u0111\xF3:"),pt=o(),E(dn.$$.fragment),Me=o(),E(tt.$$.fragment),Le=o(),Hn=h("p"),et=s("Ch\xFAng ta \u0111\xE3 th\u1EA5y c\xE1c nh\xE3n khi \u0111\xE0o s\xE2u v\xE0o pipeline "),He=h("code"),Rn=s("token-classification"),ga=s(" trong "),Qt=h("a"),fa=s("Ch\u01B0\u01A1ng 6"),da=s(", nh\u01B0ng \u0111\u1EC3 c\u1EADp nh\u1EADt nhanh:"),Re=o(),st=h("ul"),_a=h("li"),Cs=h("code"),Ah=s("O"),Nh=s(" ngh\u0129a l\xE0 t\u1EEB kh\xF4ng thu\u1ED9c b\u1EA5t k\xEC th\u1EF1c th\u1EC3 n\xE0o."),Vl=o(),Pn=h("li"),ba=h("code"),va=s("B-PER"),Bh=s("/"),ka=h("code"),Os=s("I-PER"),Ul=s(" ngh\u0129a l\xE0 t\u1EEB t\u01B0\u01A1ng \u1EE9ng ph\u1EA7n b\u1EAFt \u0111\u1EA7u/ n\u1EB1m b\xEAn trong c\u1EE7a th\u1EF1c th\u1EC3 "),qt=h("em"),Sh=s("person"),hl=s(" hay "),cl=h("em"),Ih=s("con ng\u01B0\u1EDDi"),rl=s("."),Mh=o(),Dt=h("li"),ya=h("code"),qs=s("B-ORG"),Xl=s("/"),ve=h("code"),Lh=s("I-ORG"),il=s(" ngh\u0129a l\xE0 t\u1EEB t\u01B0\u01A1ng \u1EE9ng ph\u1EA7n b\u1EAFt \u0111\u1EA7u/ n\u1EB1m b\xEAn trong c\u1EE7a th\u1EF1c th\u1EC3 "),ol=h("em"),Hh=s("organization"),Wl=s(" hay "),Fe=h("em"),Kl=s("t\u1ED5 ch\u1EE9c"),Ds=s("."),Zl=o(),_n=h("li"),pl=h("code"),ul=s("B-LOC"),Rh=s("/"),ml=h("code"),gl=s("I-LOC"),Fh=s(" ngh\u0129a l\xE0 t\u1EEB t\u01B0\u01A1ng \u1EE9ng ph\u1EA7n b\u1EAFt \u0111\u1EA7u/ n\u1EB1m b\xEAn trong c\u1EE7a th\u1EF1c th\u1EC3 "),fl=h("em"),Yl=s("location"),Ts=s(" hay "),$a=h("em"),Tt=s("\u0111\u1ECBa \u0111i\u1EC3m"),Gh=s("."),dl=o(),Pt=h("li"),_l=h("code"),bl=s("B-MISC"),Vh=s("/"),vl=h("code"),kl=s("I-MISC"),Uh=s(" ngh\u0129a l\xE0 t\u1EEB t\u01B0\u01A1ng \u1EE9ng ph\u1EA7n b\u1EAFt \u0111\u1EA7u/ n\u1EB1m b\xEAn trong c\u1EE7a th\u1EF1c th\u1EC3 "),yl=h("em"),Ql=s("miscellaneous"),Ps=s(" hay "),ja=h("em"),zs=s("l\u1ED9n x\u1ED9n"),Jl=s("."),As=o(),Ea=h("p"),nh=s("Gi\u1EDD khi gi\u1EA3i m\xE3 c\xE1c nh\xE3n, ta th\u1EA5y ch\xFAng cho ta:"),cs=o(),E(rs.$$.fragment),Jt=o(),E(Ns.$$.fragment),wa=o(),ke=h("p"),Xh=s("V\xE0 \u0111\u1ED1i v\u1EDBi m\u1ED9t v\xED d\u1EE5 tr\u1ED9n nh\xE3n "),Bs=h("code"),Wh=s("B-"),Kh=s(" v\xE0 "),xa=h("code"),Ge=s("I-"),is=s(", \u0111\xE2y l\xE0 nh\u1EEFng g\xEC m\xE0 c\xF9ng m\u1ED9t \u0111o\u1EA1n m\xE3 cung c\u1EA5p cho ch\xFAng ta v\u1EC1 ph\u1EA7n t\u1EED c\u1EE7a t\u1EADp hu\u1EA5n luy\u1EC7n \u1EDF ch\u1EC9 m\u1EE5c 4:"),Ca=o(),E(ne.$$.fragment),th=o(),zt=h("p"),Zh=s("Nh\u01B0 ch\xFAng ta c\xF3 th\u1EC3 th\u1EA5y, c\xE1c th\u1EF1c th\u1EC3 bao g\u1ED3m hai t\u1EEB, nh\u01B0 \u201CEuropean Union\u201D v\xE0 \u201CWerner Zwingmann\u201D, \u0111\u01B0\u1EE3c g\xE1n nh\xE3n "),Oa=h("code"),ye=s("B-"),Yh=s(" cho t\u1EEB \u0111\u1EA7u ti\xEAn v\xE0 nh\xE3n "),Ss=h("code"),Qh=s("I-"),Jh=s(" cho t\u1EEB th\u1EE9 hai."),qa=o(),E(os.$$.fragment),eh=o(),$e=h("h3"),At=h("a"),Da=h("span"),E(je.$$.fragment),nc=o(),Ta=h("span"),Ee=s("X\u1EED l\xFD d\u1EEF li\u1EC7u"),ps=o(),E(Is.$$.fragment),Pa=o(),we=h("p"),tc=s("Nh\u01B0 th\u01B0\u1EDDng l\u1EC7, c\xE1c v\u0103n b\u1EA3n c\u1EE7a ch\xFAng ta c\u1EA7n \u0111\u01B0\u1EE3c chuy\u1EC3n \u0111\u1ED5i sang token ID tr\u01B0\u1EDBc khi m\xF4 h\xECnh c\xF3 th\u1EC3 hi\u1EC3u \u0111\u01B0\u1EE3c ch\xFAng. Nh\u01B0 ch\xFAng ta \u0111\xE3 th\u1EA5y trong "),za=h("a"),ut=s("Ch\u01B0\u01A1ng 6"),ec=s(", m\u1ED9t s\u1EF1 kh\xE1c bi\u1EC7t l\u1EDBn trong tr\u01B0\u1EDDng h\u1EE3p t\xE1c v\u1EE5 ph\xE2n lo\u1EA1i token l\xE0 ch\xFAng ta c\xF3 c\xE1c \u0111\u1EA7u v\xE0o \u0111\u01B0\u1EE3c tokenize tr\u01B0\u1EDBc. May m\u1EAFn thay, API tokenizer c\xF3 th\u1EC3 gi\u1EA3i quy\u1EBFt v\u1EA5n \u0111\u1EC1 \u0111\xF3 kh\xE1 d\u1EC5 d\xE0ng; ch\xFAng ta ch\u1EC9 c\u1EA7n b\xE1o "),Ms=h("code"),sc=s("tokenizer"),ac=s(" b\u1EB1ng m\u1ED9t l\xE1 c\u1EDD \u0111\u1EB7c bi\u1EC7t."),Aa=o(),us=h("p"),lc=s("\u0110\u1EC3 b\u1EAFt \u0111\u1EA7u, h\xE3y t\u1EA1o \u0111\u1ED1i t\u01B0\u1EE3ng "),Ls=h("code"),hc=s("tokenizer"),cc=s(" c\u1EE7a ch\xFAng ta. Nh\u01B0 ch\xFAng t\xF4i \u0111\xE3 n\xF3i tr\u01B0\u1EDBc \u0111\xE2y, ch\xFAng ta s\u1EBD s\u1EED d\u1EE5ng m\xF4 h\xECnh hu\u1EA5n luy\u1EC7n tr\u01B0\u1EDBc BERT, v\xEC v\u1EADy ch\xFAng ta s\u1EBD b\u1EAFt \u0111\u1EA7u b\u1EB1ng c\xE1ch t\u1EA3i xu\u1ED1ng v\xE0 l\u01B0u v\xE0o b\u1ED9 nh\u1EDB \u0111\u1EC7m c\u1EE7a tokenizer li\xEAn quan:"),Na=o(),E(Hs.$$.fragment),sh=o(),zn=h("p"),Ve=s("B\u1EA1n c\xF3 th\u1EC3 thay th\u1EBF "),$l=h("code"),jl=s("model_checkpoint"),rc=s(" b\u1EB1ng b\u1EA5t k\u1EF3 m\xF4 h\xECnh n\xE0o kh\xE1c m\xE0 b\u1EA1n th\xEDch t\u1EEB "),Rs=h("a"),El=s("Hub"),ic=s(" ho\u1EB7c b\u1EB1ng m\u1ED9t th\u01B0 m\u1EE5c c\u1EE5c b\u1ED9 trong \u0111\xF3 b\u1EA1n \u0111\xE3 l\u01B0u m\u1ED9t m\xF4 h\xECnh \u0111\u01B0\u1EE3c hu\u1EA5n luy\u1EC7n tr\u01B0\u1EDBc v\xE0 m\u1ED9t tr\xECnh tokenize. H\u1EA1n ch\u1EBF duy nh\u1EA5t l\xE0 tokenizer c\u1EA7n \u0111\u01B0\u1EE3c h\u1ED7 tr\u1EE3 b\u1EDFi th\u01B0 vi\u1EC7n \u{1F917} Tokenizers, v\xEC v\u1EADy s\u1EBD c\xF3 phi\xEAn b\u1EA3n \u201Cnhanh\u201D. 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 "),Fs=h("a"),ah=s("b\u1EA3ng l\u1EDBn n\xE0y"),Ba=s(" v\xE0 \u0111\u1EC3 ki\u1EC3m tra xem \u0111\u1ED1i t\u01B0\u1EE3ng "),wl=h("code"),lh=s("tokenizer"),Gs=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 "),Sa=h("code"),Ia=s("is_fast"),oc=s(" c\u1EE7a n\xF3:"),xl=o(),E(te.$$.fragment),Cl=o(),E(hn.$$.fragment),hh=o(),Nt=h("p"),pc=s("\u0110\u1EC3 tokenize d\u1EEF li\u1EC7u \u0111\u1EA7u v\xE0o \u0111\xE3 ti\u1EC1n tokenize, ta c\xF3 th\u1EC3 s\u1EED d\u1EE5ng "),Ol=h("code"),ql=s("tokenizer"),uc=s(" nh\u01B0 th\u01B0\u1EDDng l\u1EC7 v\xE0 ch\u1EC9 th\xEAm "),Dl=h("code"),Tl=s("is_split_into_words=True"),mc=s(":"),ch=o(),E(Ue.$$.fragment),rh=o(),E(Vs.$$.fragment),Ma=o(),An=h("p"),gc=s("Nh\u01B0 ch\xFAng ta c\xF3 th\u1EC3 th\u1EA5y, tr\xECnh tokenizer \u0111\xE3 th\xEAm c\xE1c token \u0111\u1EB7c bi\u1EC7t \u0111\u01B0\u1EE3c s\u1EED d\u1EE5ng b\u1EDFi m\xF4 h\xECnh ("),Us=h("code"),fc=s("[CLS]"),dc=s(" \u1EDF \u0111\u1EA7u v\xE0 "),Xs=h("code"),_c=s("[SEP]"),bc=s(" \u1EDF cu\u1ED1i) v\xE0 \u0111\u1EC3 nguy\xEAn h\u1EA7u h\u1EBFt c\xE1c t\u1EEB. Tuy nhi\xEAn, t\u1EEB "),La=h("code"),xe=s("lamb"),vc=s(" \u0111\xE3 \u0111\u01B0\u1EE3c tokenize th\xE0nh hai t\u1EEB ph\u1EE5, "),Ws=h("code"),kc=s("la"),yc=s(" v\xE0 "),Xe=h("code"),Pl=s("##mb"),$c=s(". \u0110i\u1EC1u n\xE0y d\u1EABn \u0111\u1EBFn s\u1EF1 kh\xF4ng kh\u1EDBp gi\u1EEFa \u0111\u1EA7u v\xE0o v\xE0 c\xE1c nh\xE3n: danh s\xE1ch nh\xE3n ch\u1EC9 c\xF3 9 ph\u1EA7n t\u1EED, trong khi \u0111\u1EA7u v\xE0o c\u1EE7a ch\xFAng ta hi\u1EC7n c\xF3 12 token. Vi\u1EC7c t\xEDnh to\xE1n c\xE1c token \u0111\u1EB7c bi\u1EC7t r\u1EA5t d\u1EC5 d\xE0ng (ch\xFAng ta bi\u1EBFt ch\xFAng n\u1EB1m \u1EDF \u0111\u1EA7u v\xE0 cu\u1ED1i), nh\u01B0ng ch\xFAng ta c\u0169ng c\u1EA7n \u0111\u1EA3m b\u1EA3o r\u1EB1ng ch\xFAng ta s\u1EAFp x\u1EBFp t\u1EA5t c\u1EA3 c\xE1c nh\xE3n v\u1EDBi c\xE1c t\u1EEB th\xEDch h\u1EE3p."),ih=o(),We=h("p"),l=s("May m\u1EAFn thay, b\u1EDFi v\xEC ch\xFAng ta \u0111ang s\u1EED d\u1EE5ng m\u1ED9t tokenizer nhanh, ch\xFAng ta c\xF3 quy\u1EC1n truy c\u1EADp v\xE0o s\u1EE9c m\u1EA1nh si\xEAu c\u01B0\u1EDDng \u{1F917} Tokenizers, c\xF3 ngh\u0129a l\xE0 ch\xFAng ta c\xF3 th\u1EC3 d\u1EC5 d\xE0ng \xE1nh x\u1EA1 t\u1EEBng token v\u1EDBi t\u1EEB t\u01B0\u01A1ng \u1EE9ng c\u1EE7a n\xF3 (nh\u01B0 \u0111\xE3 th\u1EA5y trong "),d=h("a"),sr=s("Ch\u01B0\u01A1ng 6"),ar=s("):"),jc=o(),E(Ce.$$.fragment),Ec=o(),E(Ha.$$.fragment),Ks=o(),mt=h("p"),lr=s("V\u1EDBi m\u1ED9t ch\xFAt c\xF4ng vi\u1EC7c, sau \u0111\xF3 ch\xFAng ta c\xF3 th\u1EC3 m\u1EDF r\u1ED9ng danh s\xE1ch nh\xE3n c\u1EE7a m\xECnh \u0111\u1EC3 ph\xF9 h\u1EE3p v\u1EDBi c\xE1c token. Quy t\u1EAFc \u0111\u1EA7u ti\xEAn ch\xFAng ta s\u1EBD \xE1p d\u1EE5ng l\xE0 c\xE1c token \u0111\u1EB7c bi\u1EC7t c\xF3 nh\xE3n l\xE0 "),Ra=h("code"),hr=s("-100"),Fa=s(". \u0110i\u1EC1u n\xE0y l\xE0 do theo m\u1EB7c \u0111\u1ECBnh "),oh=h("code"),cr=s("-100"),ph=s(" l\xE0 ch\u1EC9 s\u1ED1 b\u1ECB b\u1ECF qua trong h\xE0m m\u1EA5t m\xE1t m\xE0 ch\xFAng ta s\u1EBD s\u1EED d\u1EE5ng (entropy ch\xE9o). Sau \u0111\xF3, m\u1ED7i token c\xF3 c\xF9ng nh\xE3n v\u1EDBi token b\u1EAFt \u0111\u1EA7u t\u1EEB b\xEAn trong n\xF3, v\xEC ch\xFAng l\xE0 m\u1ED9t ph\u1EA7n c\u1EE7a c\xF9ng m\u1ED9t th\u1EF1c th\u1EC3. \u0110\u1ED1i v\u1EDBi c\xE1c token b\xEAn trong m\u1ED9t t\u1EEB nh\u01B0ng kh\xF4ng \u1EDF \u0111\u1EA7u, ch\xFAng ta thay th\u1EBF "),uh=h("code"),rr=s("B-"),ir=s(" b\u1EB1ng "),Ga=h("code"),or=s("I-"),pr=s(" (v\xEC token kh\xF4ng b\u1EAFt \u0111\u1EA7u th\u1EF1c th\u1EC3):"),wc=o(),E(ms.$$.fragment),xc=o(),jn=h("p"),ur=s("H\xE3y c\xF9ng th\u1EED v\u1EDBi c\xE2u \u0111\u1EA7u ti\xEAn:"),Cc=o(),E(Va.$$.fragment),Oc=o(),E(Ua.$$.fragment),qc=o(),Ke=h("p"),mh=s("Nh\u01B0 ch\xFAng ta c\xF3 th\u1EC3 th\u1EA5y, h\xE0m \u0111\xE3 th\xEAm "),gh=h("code"),mr=s("-100"),fh=s(" cho hai token \u0111\u1EB7c bi\u1EC7t \u1EDF \u0111\u1EA7u v\xE0 cu\u1ED1i, v\xE0 d\u1EA5u "),dh=h("code"),gr=s("0"),Dc=s(" m\u1EDBi cho t\u1EEB c\u1EE7a ch\xFAng ta \u0111\xE3 \u0111\u01B0\u1EE3c chia th\xE0nh hai token."),Tc=o(),E(Zs.$$.fragment),zl=o(),gt=h("p"),fr=s("\u0110\u1EC3 x\u1EED l\xFD tr\u01B0\u1EDBc to\xE0n b\u1ED9 t\u1EADp d\u1EEF li\u1EC7u c\u1EE7a m\xECnh, ch\xFAng ta c\u1EA7n tokenize t\u1EA5t c\u1EA3 c\xE1c \u0111\u1EA7u v\xE0o v\xE0 \xE1p d\u1EE5ng "),_h=h("code"),bh=s("align_labels_with_tokens()"),dr=s(" tr\xEAn t\u1EA5t c\u1EA3 c\xE1c nh\xE3n. \u0110\u1EC3 t\u1EADn d\u1EE5ng t\u1ED1c \u0111\u1ED9 c\u1EE7a tr\xECnh tokenize nhanh c\u1EE7a m\xECnh, t\u1ED1t nh\u1EA5t b\u1EA1n n\xEAn tokenize nhi\u1EC1u v\u0103n b\u1EA3n c\xF9ng m\u1ED9t l\xFAc, v\xEC v\u1EADy ch\xFAng ta s\u1EBD vi\u1EBFt m\u1ED9t h\xE0m x\u1EED l\xFD danh s\xE1ch c\xE1c v\xED d\u1EE5 v\xE0 s\u1EED d\u1EE5ng ph\u01B0\u01A1ng th\u1EE9c "),Xa=h("code"),_r=s("Dataset.map()"),br=s(" v\u1EDBi t\xF9y ch\u1ECDn "),vh=h("code"),gs=s("batched=True"),vr=s(". \u0110i\u1EC1u duy nh\u1EA5t kh\xE1c v\u1EDBi v\xED d\u1EE5 tr\u01B0\u1EDBc l\xE0 h\xE0m "),kh=h("code"),kr=s("word_ids()"),yr=s(" c\u1EA7n l\u1EA5y ch\u1EC9 m\u1EE5c c\u1EE7a m\u1EABu m\xE0 ch\xFAng ta mu\u1ED1n c\xE1c ID t\u1EEB khi c\xE1c \u0111\u1EA7u v\xE0o cho tokenizer l\xE0 danh s\xE1ch v\u0103n b\u1EA3n (ho\u1EB7c trong tr\u01B0\u1EDDng h\u1EE3p c\u1EE7a ch\xFAng ta l\xE0 danh s\xE1ch danh s\xE1ch c\xE1c t\u1EEB), v\xEC v\u1EADy ch\xFAng ta c\u0169ng th\xEAm v\xE0o \u0111\xF3:"),Ys=o(),E(Wa.$$.fragment),Pc=o(),Qs=h("p"),$r=s("L\u01B0u \xFD r\u1EB1ng ch\xFAng ta ch\u01B0a \u0111\u1EC7m v\xE0o c\u1EE7a m\xECnh; ch\xFAng ta s\u1EBD l\xE0m \u0111i\u1EC1u \u0111\xF3 sau, khi t\u1EA1o c\xE1c l\xF4 b\u1EB1ng tr\xECnh \u0111\u1ED1i chi\u1EBFu d\u1EEF li\u1EC7u."),Js=o(),Al=h("p"),jr=s("B\xE2y gi\u1EDD ch\xFAng ta c\xF3 th\u1EC3 \xE1p d\u1EE5ng t\u1EA5t c\u1EA3 ti\u1EC1n x\u1EED l\xFD \u0111\xF3 trong m\u1ED9t l\u1EA7n v\xE0o c\xE1c ph\u1EA7n kh\xE1c c\u1EE7a t\u1EADp d\u1EEF li\u1EC7u c\u1EE7a m\xECnh:"),Ze=o(),E(Ka.$$.fragment),zc=o(),na=h("p"),Er=s("Ch\xFAng ta \u0111\xE3 ho\xE0n th\xE0nh ph\u1EA7n kh\xF3 nh\u1EA5t! B\xE2y gi\u1EDD, d\u1EEF li\u1EC7u \u0111\xE3 \u0111\u01B0\u1EE3c ti\u1EC1n x\u1EED l\xFD, qu\xE1 tr\xECnh hu\u1EA5n luy\u1EC7n th\u1EF1c t\u1EBF s\u1EBD gi\u1ED1ng nh\u01B0 nh\u1EEFng g\xEC ch\xFAng ta \u0111\xE3 l\xE0m trong "),Ye=h("a"),wr=s("Ch\u01B0\u01A1ng 3"),xr=s("."),Nl=o(),qe.c(),Bl=o(),Bt=h("h3"),ta=h("a"),yh=h("span"),E(Za.$$.fragment),Ya=o(),Qa=h("span"),Cr=s("\u0110\u1ED1i chi\u1EBFu d\u1EEF li\u1EC7u"),ee=o(),se=h("p"),Or=s("Ch\xFAng ta kh\xF4ng th\u1EC3 ch\u1EC9 s\u1EED d\u1EE5ng m\u1ED9t "),$h=h("code"),qr=s("DataCollatorWithPadding"),Ja=s(" nh\u01B0 trong "),Sl=h("a"),Dr=s("Ch\u01B0\u01A1ng 3"),Tr=s(" v\xEC n\xF3 ch\u1EC9 \u0111\u1EC7m c\xE1c \u0111\u1EA7u v\xE0o (ID \u0111\u1EA7u v\xE0o, attention mask v\xE0 lo\u1EA1i token ID). \u1EDE \u0111\xE2y, c\xE1c nh\xE3n c\u1EE7a ch\xFAng ta n\xEAn \u0111\u01B0\u1EE3c \u0111\u1EC7m theo c\xF9ng m\u1ED9t c\xE1ch gi\u1ED1ng nh\u01B0 c\xE1c \u0111\u1EA7u v\xE0o \u0111\u1EC3 ch\xFAng gi\u1EEF nguy\xEAn k\xEDch th\u01B0\u1EDBc, s\u1EED d\u1EE5ng "),jh=h("code"),Nn=s("-100"),Pr=s(" l\xE0m gi\xE1 tr\u1ECB \u0111\u1EC3 c\xE1c d\u1EF1 \u0111o\xE1n t\u01B0\u01A1ng \u1EE9ng b\u1ECB b\u1ECF qua trong t\xEDnh to\xE1n t\u1ED5n th\u1EA5t."),Ac=o(),ae=h("p"),zr=s("T\u1EA5t c\u1EA3 \u0111i\u1EC1u n\xE0y \u0111\u01B0\u1EE3c th\u1EF1c hi\u1EC7n b\u1EDFi "),nl=h("a"),Eh=h("code"),Ar=s("DataCollatorForTokenClassification"),tl=s(". Gi\u1ED1ng nh\u01B0 "),wh=h("code"),Nr=s("DataCollatorWithPadding"),Br=s(", n\xF3 s\u1EED d\u1EE5ng "),ai=h("code"),Yi=s("tokenizer"),Qi=s(" \u0111\u1EC3 x\u1EED l\xFD tr\u01B0\u1EDBc c\xE1c \u0111\u1EA7u v\xE0o:"),mi=o(),sa.c(),Sr=o(),Ir=h("p"),Ji=s("\u0110\u1EC3 ki\u1EC3m tra n\xF3 tr\xEAn v\xE0i m\u1EABu, ta c\xF3 th\u1EC3 g\u1ECDi n\xF3 tr\xEAn danh s\xE1ch c\xE1c m\u1EABu t\u1EEB t\u1EADp hu\u1EA5n luy\u1EC7n \u0111\xE3 \u0111\u01B0\u1EE3c tokenize:"),gi=o(),E(Nc.$$.fragment),fi=o(),E(Bc.$$.fragment),di=o(),Mr=h("p"),no=s("H\xE3y so s\xE1nh \u0111i\u1EC1u n\xE0y v\u1EDBi c\xE1c nh\xE3n cho ph\u1EA7n t\u1EED \u0111\u1EA7u ti\xEAn v\xE0 th\u1EE9 hai trong t\u1EADp d\u1EEF li\u1EC7u c\u1EE7a m\xECnh:"),_i=o(),E(Sc.$$.fragment),bi=o(),E(Ic.$$.fragment),vi=o(),la.c(),Lr=o(),Fn&&Fn.c(),Hr=o(),Il=h("h3"),xh=h("a"),li=h("span"),E(Mc.$$.fragment),to=o(),hi=h("span"),eo=s("Th\u01B0\u1EDBc \u0111o"),ki=o(),ca.c(),Rr=o(),E(Lc.$$.fragment),yi=o(),Fr=h("p"),so=s("Th\u01B0\u1EDBc \u0111o n\xE0y kh\xF4ng gi\u1ED1ng nh\u01B0 c\xE1c th\u01B0\u1EDBc \u0111o \u0111\u1ED9 ch\xEDnh x\xE1c th\xF4ng th\u01B0\u01A1ng: n\xF3 s\u1EBD nh\u1EADn m\u1ED9t danh s\xE1ch c\xE1c nh\xE3n nh\u01B0 l\xE0 chu\u1ED7i v\u0103n b\u1EA3n, kh\xF4ng ph\u1EA3i s\u1ED1 nguy\xEAn, n\xEAn ta s\u1EBD c\u1EA7n gi\u1EA3i m\xE3 to\xE0n b\u1ED9 nh\u1EEFng d\u1EF1 \u0111o\xE1n v\xE0 nh\xE3n tr\u01B0\u1EDBc khi truy\u1EC1n ch\xFAng v\xE0o th\u01B0\u1EDBc \u0111o. H\xE3y c\xF9ng xem n\xF3 ho\u1EA1t \u0111\u1ED9ng ra sao. \u0110\u1EA7u ti\xEAn, ta s\u1EBD l\u1EA5y nh\u1EEFng nh\xE3n t\u1EEB m\u1EABu hu\u1EA5n luy\u1EC7n \u0111\u1EA7u ti\xEAn:"),$i=o(),E(Hc.$$.fragment),ji=o(),E(Rc.$$.fragment),Ei=o(),Gr=h("p"),ao=s("Ta c\xF3 th\u1EC3 t\u1EA1o ra nh\u1EEFng d\u1EF1 \u0111o\xE1n gi\u1EA3 cho ch\xFAng b\u1EB1ng c\xE1ch thay \u0111\u1ED5i gi\xE1 tr\u1ECB \u1EDF ch\u1EC9 m\u1EE5c 2:"),wi=o(),E(Fc.$$.fragment),xi=o(),Vr=h("p"),lo=s("L\u01B0u \xFD r\u1EB1ng th\u01B0\u1EDBc \u0111o nh\u1EADn danh s\xE1ch c\xE1c d\u1EF1 \u0111o\xE1n (kh\xF4ng ch\u1EC9 m\u1ED9t) v\xE0 danh s\xE1ch c\xE1c nh\xE3n. \u0110\xE2y l\xE0 \u0111\u1EA7u ra:"),Ci=o(),E(Gc.$$.fragment),Oi=o(),ia.c(),Ur=o(),Gn&&Gn.c(),Xr=o(),Ml=h("h2"),Ch=h("a"),ci=h("span"),E(Vc.$$.fragment),ho=o(),ri=h("span"),co=s("S\u1EED d\u1EE5ng m\xF4 h\xECnh \u0111\xE3 \u0111\u01B0\u1EE3c tinh ch\u1EC9nh"),qi=o(),Oh=h("p"),ro=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 "),ii=h("code"),io=s("pipeline"),oo=s(", b\u1EA1n ch\u1EC9 c\u1EA7n ch\u1EC9 \u0111\u1ECBnh m\xE3 \u0111\u1ECBnh danh m\xF4 h\xECnh th\xEDch h\u1EE3p:"),Di=o(),E(Uc.$$.fragment),Ti=o(),E(Xc.$$.fragment),Pi=o(),Wr=h("p"),po=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 u=Tu('[data-svelte="svelte-1phssyn"]',document.head);m=c(u,"META",{name:!0,content:!0}),u.forEach(e),v=p(t),w(f.$$.fragment,t),$=p(t),O=c(t,"H1",{class:!0});var nr=r(O);k=c(nr,"A",{id:!0,class:!0,href:!0});var Kr=r(k);j=c(Kr,"SPAN",{});var oi=r(j);w(q.$$.fragment,oi),oi.forEach(e),Kr.forEach(e),D=p(nr),z=c(nr,"SPAN",{});var pi=r(z);I=a(pi,"Ph\xE2n lo\u1EA1i token"),pi.forEach(e),nr.forEach(e),A=p(t),V.l(t),B=p(t),R=c(t,"P",{});var ui=r(R);F=a(ui,"\u1EE8ng d\u1EE5ng \u0111\u1EA7u ti\xEAn ch\xFAng ta s\u1EBD c\xF9ng kh\xE1m ph\xE1 l\xE0 ph\xE2n lo\u1EA1i token. T\xE1c v\u1EE5 chung n\xE0y bao g\u1ED3m b\u1EA5t k\u1EF3 v\u1EA5n \u0111\u1EC1 n\xE0o c\xF3 th\u1EC3 \u0111\u01B0\u1EE3c x\xE2y d\u1EF1ng d\u01B0\u1EDBi d\u1EA1ng \u201Cg\xE1n nh\xE3n cho m\u1ED7i token trong m\u1ED9t c\xE2u\u201D, ch\u1EB3ng h\u1EA1n nh\u01B0:"),ui.forEach(e),M=p(t),W=c(t,"UL",{});var el=r(W);T=c(el,"LI",{});var tr=r(T);U=c(tr,"STRONG",{});var Zr=r(U);L=a(Zr,"Nh\u1EADn d\u1EA1ng th\u1EF1c th\u1EC3 \u0111\u01B0\u1EE3c \u0111\u1EB7t t\xEAn (NER)"),Zr.forEach(e),K=a(tr,": T\xECm c\xE1c th\u1EF1c th\u1EC3 (ch\u1EB3ng h\u1EA1n nh\u01B0 ng\u01B0\u1EDDi, \u0111\u1ECBa \u0111i\u1EC3m ho\u1EB7c t\u1ED5 ch\u1EE9c) trong m\u1ED9t c\xE2u. \u0110i\u1EC1u n\xE0y c\xF3 th\u1EC3 \u0111\u01B0\u1EE3c x\xE2y d\u1EF1ng nh\u01B0 l\xE0 g\xE1n nh\xE3n cho m\u1ED7i token b\u1EB1ng c\xE1ch c\xF3 m\u1ED9t nh\xE3n cho m\u1ED7i th\u1EF1c th\u1EC3 v\xE0 m\u1ED9t nh\xE3n cho \u201Ckh\xF4ng c\xF3 th\u1EF1c th\u1EC3\u201D."),tr.forEach(e),nn=p(el),an=c(el,"LI",{});var er=r(an);ln=c(er,"STRONG",{});var Yr=r(ln);Z=a(Yr,"G\xE1n nh\xE3n t\u1EEB lo\u1EA1i (POS)"),Yr.forEach(e),un=a(er,": \u0110\xE1nh d\u1EA5u m\u1ED7i t\u1EEB trong c\xE2u t\u01B0\u01A1ng \u1EE9ng v\u1EDBi m\u1ED9t t\u1EEB lo\u1EA1i c\u1EE5 th\u1EC3 c\u1EE7a v\u0103n b\u1EA3n (ch\u1EB3ng h\u1EA1n nh\u01B0 danh t\u1EEB, \u0111\u1ED9ng t\u1EEB, t\xEDnh t\u1EEB, v.v.)."),er.forEach(e),Q=p(el),G=c(el,"LI",{});var Ll=r(G);H=c(Ll,"STRONG",{});var Co=r(H);en=a(Co,"Ph\xE2n kh\xFAc"),Co.forEach(e),mn=a(Ll,": T\xECm c\xE1c token thu\u1ED9c c\xF9ng m\u1ED9t th\u1EF1c th\u1EC3. T\xE1c v\u1EE5 n\xE0y (c\xF3 th\u1EC3 \u0111\u01B0\u1EE3c k\u1EBFt h\u1EE3p v\u1EDBi POS ho\u1EB7c NER) c\xF3 th\u1EC3 \u0111\u01B0\u1EE3c x\xE2y d\u1EF1ng d\u01B0\u1EDBi d\u1EA1ng g\xE1n m\u1ED9t nh\xE3n (th\u01B0\u1EDDng l\xE0 "),kn=c(Ll,"CODE",{});var Oo=r(kn);sn=a(Oo,"B-"),Oo.forEach(e),Bn=a(Ll,") cho b\u1EA5t k\u1EF3 token n\xE0o \u1EDF \u0111\u1EA7u m\u1ED9t \u0111o\u1EA1n, m\u1ED9t nh\xE3n kh\xE1c (th\u01B0\u1EDDng l\xE0 "),Y=c(Ll,"CODE",{});var qo=r(Y);at=a(qo,"I-"),qo.forEach(e),on=a(Ll,") cho c\xE1c token \u0111\xF3 n\u1EB1m b\xEAn trong m\u1ED9t \u0111o\u1EA1n v\xE0 m\u1ED9t nh\xE3n th\u1EE9 ba (th\u01B0\u1EDDng l\xE0 "),ft=c(Ll,"CODE",{});var Do=r(ft);le=a(Do,"O"),Do.forEach(e),lt=a(Ll,") token kh\xF4ng thu\u1ED9c b\u1EA5t k\u1EF3 \u0111o\u1EA1n n\xE0o."),Ll.forEach(e),el.forEach(e),Qe=p(t),w(It.$$.fragment,t),he=p(t),bn=c(t,"P",{});var To=r(bn);De=a(To,"T\u1EA5t nhi\xEAn, c\xF3 nhi\u1EC1u lo\u1EA1i v\u1EA5n \u0111\u1EC1 ph\xE2n lo\u1EA1i token kh\xE1c; \u0111\xF3 ch\u1EC9 l\xE0 m\u1ED9t v\xE0i v\xED d\u1EE5 ti\xEAu bi\u1EC3u. Trong ph\u1EA7n n\xE0y, ch\xFAng ta s\u1EBD tinh ch\u1EC9nh m\u1ED9t m\xF4 h\xECnh (BERT) tr\xEAn m\u1ED9t t\xE1c v\u1EE5 NER, sau \u0111\xF3 s\u1EBD c\xF3 th\u1EC3 t\xEDnh to\xE1n c\xE1c d\u1EF1 \u0111o\xE1n nh\u01B0 sau:"),To.forEach(e),En=p(t),gn=c(t,"IFRAME",{src:!0,frameborder:!0,height:!0,title:!0,class:!0,allow:!0,sandbox:!0}),r(gn).forEach(e),ce=p(t),tn=c(t,"A",{class:!0,href:!0});var Ai=r(tn);pn=c(Ai,"IMG",{class:!0,src:!0,alt:!0}),Sn=p(Ai),Mt=c(Ai,"IMG",{class:!0,src:!0,alt:!0}),Ai.forEach(e),Je=p(t),Un=c(t,"P",{});var Ni=r(Un);In=a(Ni,"B\u1EA1n c\xF3 th\u1EC3 t\xECm m\xF4 h\xECnh ta s\u1EBD hu\u1EA5n luy\u1EC7n v\xE0 t\u1EA3i l\xEAn Hub v\xE0 ki\u1EC3m tra l\u1EA1i c\xE1c d\u1EF1 \u0111o\xE1n "),Lt=c(Ni,"A",{href:!0,rel:!0});var Po=r(Lt);oe=a(Po,"t\u1EA1i \u0111\xE2y"),Po.forEach(e),Ht=a(Ni,"."),Ni.forEach(e),Te=p(t),yn=c(t,"H2",{class:!0});var Bi=r(yn);wn=c(Bi,"A",{id:!0,class:!0,href:!0});var zo=r(wn);Rt=c(zo,"SPAN",{});var Ao=r(Rt);w($n.$$.fragment,Ao),Ao.forEach(e),zo.forEach(e),bs=p(Bi),Ft=c(Bi,"SPAN",{});var No=r(Ft);Xn=a(No,"Chu\u1EA9n b\u1ECB d\u1EEF li\u1EC7u"),No.forEach(e),Bi.forEach(e),Pe=p(t),cn=c(t,"P",{});var Si=r(cn);Gt=a(Si,"\u0110\u1EA7u ti\xEAn, ta c\u1EA7n b\u1ED9 d\u1EEF li\u1EC7u chu\u1EA9n b\u1ECB cho ph\xE2n lo\u1EA1i token. Trong ch\u01B0\u01A1ng n\xE0y, ch\xFAng ta s\u1EBD s\u1EED d\u1EE5ng b\u1ED9 d\u1EEF li\u1EC7u "),Wn=c(Si,"A",{href:!0,rel:!0});var Bo=r(Wn);dt=a(Bo,"CoNLL-2003"),Bo.forEach(e),vs=a(Si,", bao g\u1ED3m c\xE1c c\xE2u chuy\u1EC7n tin t\u1EE9c t\u1EEB Reuters."),Si.forEach(e),_t=p(t),w(bt.$$.fragment,t),ns=p(t),xn=c(t,"H3",{class:!0});var Ii=r(xn);Cn=c(Ii,"A",{id:!0,class:!0,href:!0});var So=r(Cn);pe=c(So,"SPAN",{});var Io=r(pe);w(J.$$.fragment,Io),Io.forEach(e),So.forEach(e),Vt=p(Ii),vt=c(Ii,"SPAN",{});var Mo=r(vt);Kn=a(Mo,"T\u1EADp d\u1EEF li\u1EC7u CoNLL-2003"),Mo.forEach(e),Ii.forEach(e),ts=p(t),On=c(t,"P",{});var Mi=r(On);ks=a(Mi,"\u0110\u1EC3 t\u1EA3i b\u1ED9 d\u1EEF li\u1EC7u CoNLL-2003, ta c\u1EA7n s\u1EED d\u1EE5ng ph\u01B0\u01A1ng th\u1EE9c "),ze=c(Mi,"CODE",{});var Lo=r(ze);ht=a(Lo,"load_dataset()"),Lo.forEach(e),Ae=a(Mi," t\u1EEB th\u01B0 vi\u1EC7n \u{1F917} Datasets:"),Mi.forEach(e),es=p(t),w(kt.$$.fragment,t),Mn=p(t),yt=c(t,"P",{});var Li=r(yt);Ne=a(Li,"Ta s\u1EBD t\u1EA3i v\xE0 l\u01B0u b\u1ED9 d\u1EEF li\u1EC7u v\xE0o cache, nh\u01B0 ta \u0111\xE3 th\u1EA5y trong "),$t=c(Li,"A",{href:!0});var Ho=r($t);ys=a(Ho,"Ch\u01B0\u01A1ng 3"),Ho.forEach(e),ss=a(Li," cho b\u1ED9 d\u1EEF li\u1EC7u GLUE MRPC. Vi\u1EC7c ki\u1EC3m tra \u0111\u1ED1i t\u01B0\u1EE3ng n\xE0y cho ch\xFAng ta th\u1EA5y c\xE1c c\u1ED9t hi\u1EC7n c\xF3 v\xE0 s\u1EF1 ph\xE2n chia gi\u1EEFa c\xE1c t\u1EADp hu\u1EA5n luy\u1EC7n, ki\u1EC3m \u0111\u1ECBnh v\xE0 ki\u1EC3m th\u1EED:"),Li.forEach(e),Zn=p(t),w(jt.$$.fragment,t),fn=p(t),w(Et.$$.fragment,t),Yn=p(t),ct=c(t,"P",{});var Hi=r(ct);wt=a(Hi,"\u0110\u1EB7c bi\u1EC7t, ch\xFAng ta c\xF3 th\u1EC3 th\u1EA5y t\u1EADp d\u1EEF li\u1EC7u ch\u1EE9a c\xE1c nh\xE3n cho ba t\xE1c v\u1EE5 m\xE0 ch\xFAng ta \u0111\xE3 \u0111\u1EC1 c\u1EADp tr\u01B0\u1EDBc \u0111\xF3: NER, POS v\xE0 chunking. M\u1ED9t s\u1EF1 kh\xE1c bi\u1EC7t l\u1EDBn so v\u1EDBi c\xE1c b\u1ED9 d\u1EEF li\u1EC7u kh\xE1c l\xE0 c\xE1c v\u0103n b\u1EA3n \u0111\u1EA7u v\xE0o kh\xF4ng \u0111\u01B0\u1EE3c tr\xECnh b\xE0y d\u01B0\u1EDBi d\u1EA1ng c\xE2u ho\u1EB7c t\xE0i li\u1EC7u, m\xE0 l\xE0 danh s\xE1ch c\xE1c t\u1EEB (c\u1ED9t cu\u1ED1i c\xF9ng \u0111\u01B0\u1EE3c g\u1ECDi l\xE0 "),rt=c(Hi,"CODE",{});var Ro=r(rt);Ut=a(Ro,"tokens"),Ro.forEach(e),$s=a(Hi,", nh\u01B0ng n\xF3 ch\u1EE9a c\xE1c t\u1EEB theo ngh\u0129a \u0111\xE2y l\xE0 c\xE1c \u0111\u1EA7u v\xE0o \u0111\u01B0\u1EE3c tokenize tr\u01B0\u1EDBc v\u1EABn c\u1EA7n \u0111\u1EC3 \u0111i qua tr\xECnh tokenize \u0111\u1EC3 tokenize t\u1EEB ph\u1EE5)."),Hi.forEach(e),as=p(t),it=c(t,"P",{});var Fo=r(it);Xt=a(Fo,"H\xE3y xem ph\u1EA7n t\u1EED \u0111\u1EA7u ti\xEAn c\u1EE7a t\u1EADp hu\u1EA5n luy\u1EC7n:"),Fo.forEach(e),Be=p(t),w(qn.$$.fragment,t),ls=p(t),w(xt.$$.fragment,t),Qn=p(t),Jn=c(t,"P",{});var Go=r(Jn);ue=a(Go,"V\xEC ta mu\u1ED1n th\u1EF1c hi\u1EC7n nh\u1EADn d\u1EA1ng th\u1EF1c th\u1EC3 \u0111\u01B0\u1EE3c \u0111\u1EB7t t\xEAn, ch\xFAng ta s\u1EBD nh\xECn v\xE0o c\xE1c th\u1EBB NER:"),Go.forEach(e),Wt=p(t),w(Kt.$$.fragment,t),me=p(t),w(vn.$$.fragment,t),Se=p(t),Dn=c(t,"P",{});var Ri=r(Dn);g=a(Ri,"\u0110\xF3 l\xE0 nh\u1EEFng nh\xE3n d\u01B0\u1EDBi d\u1EA1ng s\u1ED1 nguy\xEAn s\u1EB5n s\xE0ng \u0111\u1EC3 hu\u1EA5n luy\u1EC7n, nh\u01B0ng ch\xFAng kh\xF4ng nh\u1EA5t thi\u1EBFt h\u1EEFu \xEDch khi ch\xFAng ta mu\u1ED1n ki\u1EC3m tra d\u1EEF li\u1EC7u. Gi\u1ED1ng nh\u01B0 ph\xE2n lo\u1EA1i v\u0103n b\u1EA3n, ch\xFAng ta c\xF3 th\u1EC3 truy c\u1EADp s\u1EF1 t\u01B0\u01A1ng \u1EE9ng gi\u1EEFa c\xE1c s\u1ED1 nguy\xEAn \u0111\xF3 v\xE0 t\xEAn nh\xE3n b\u1EB1ng c\xE1ch xem thu\u1ED9c t\xEDnh "),S=c(Ri,"CODE",{});var Vo=r(S);ge=a(Vo,"features"),Vo.forEach(e),js=a(Ri," c\u1EE7a t\u1EADp d\u1EEF li\u1EC7u:"),Ri.forEach(e),Zt=p(t),w(Tn.$$.fragment,t),Es=p(t),w(fe.$$.fragment,t),Ct=p(t),rn=c(t,"P",{});var fs=r(rn);oa=a(fs,"V\xEC v\u1EADy, c\u1ED9t n\xE0y ch\u1EE9a c\xE1c ph\u1EA7n t\u1EED l\xE0 chu\u1ED7i c\u1EE7a "),Yt=c(fs,"CODE",{});var Uo=r(Yt);Ot=a(Uo,"ClassLabel"),Uo.forEach(e),Ln=a(fs,". Lo\u1EA1i ph\u1EA7n t\u1EED c\u1EE7a chu\u1ED7i n\u1EB1m trong thu\u1ED9c t\xEDnh "),de=c(fs,"CODE",{});var Xo=r(de);_e=a(Xo,"feature"),Xo.forEach(e),hs=a(fs," c\u1EE7a "),be=c(fs,"CODE",{});var Wo=r(be);pa=a(Wo,"ner_feature"),Wo.forEach(e),ws=a(fs," n\xE0y, v\xE0 ch\xFAng ta c\xF3 th\u1EC3 truy c\u1EADp danh s\xE1ch t\xEAn b\u1EB1ng c\xE1ch xem thu\u1ED9c t\xEDnh "),ot=c(fs,"CODE",{});var Ko=r(ot);ua=a(Ko,"names"),Ko.forEach(e),Ie=a(fs," c\u1EE7a "),nt=c(fs,"CODE",{});var Zo=r(nt);ma=a(Zo,"feature"),Zo.forEach(e),xs=a(fs," \u0111\xF3:"),fs.forEach(e),pt=p(t),w(dn.$$.fragment,t),Me=p(t),w(tt.$$.fragment,t),Le=p(t),Hn=c(t,"P",{});var Qr=r(Hn);et=a(Qr,"Ch\xFAng ta \u0111\xE3 th\u1EA5y c\xE1c nh\xE3n khi \u0111\xE0o s\xE2u v\xE0o pipeline "),He=c(Qr,"CODE",{});var Yo=r(He);Rn=a(Yo,"token-classification"),Yo.forEach(e),ga=a(Qr," trong "),Qt=c(Qr,"A",{href:!0});var Qo=r(Qt);fa=a(Qo,"Ch\u01B0\u01A1ng 6"),Qo.forEach(e),da=a(Qr,", nh\u01B0ng \u0111\u1EC3 c\u1EADp nh\u1EADt nhanh:"),Qr.forEach(e),Re=p(t),st=c(t,"UL",{});var sl=r(st);_a=c(sl,"LI",{});var uo=r(_a);Cs=c(uo,"CODE",{});var Jo=r(Cs);Ah=a(Jo,"O"),Jo.forEach(e),Nh=a(uo," ngh\u0129a l\xE0 t\u1EEB kh\xF4ng thu\u1ED9c b\u1EA5t k\xEC th\u1EF1c th\u1EC3 n\xE0o."),uo.forEach(e),Vl=p(sl),Pn=c(sl,"LI",{});var Hl=r(Pn);ba=c(Hl,"CODE",{});var np=r(ba);va=a(np,"B-PER"),np.forEach(e),Bh=a(Hl,"/"),ka=c(Hl,"CODE",{});var tp=r(ka);Os=a(tp,"I-PER"),tp.forEach(e),Ul=a(Hl," ngh\u0129a l\xE0 t\u1EEB t\u01B0\u01A1ng \u1EE9ng ph\u1EA7n b\u1EAFt \u0111\u1EA7u/ n\u1EB1m b\xEAn trong c\u1EE7a th\u1EF1c th\u1EC3 "),qt=c(Hl,"EM",{});var ep=r(qt);Sh=a(ep,"person"),ep.forEach(e),hl=a(Hl," hay "),cl=c(Hl,"EM",{});var sp=r(cl);Ih=a(sp,"con ng\u01B0\u1EDDi"),sp.forEach(e),rl=a(Hl,"."),Hl.forEach(e),Mh=p(sl),Dt=c(sl,"LI",{});var Rl=r(Dt);ya=c(Rl,"CODE",{});var ap=r(ya);qs=a(ap,"B-ORG"),ap.forEach(e),Xl=a(Rl,"/"),ve=c(Rl,"CODE",{});var lp=r(ve);Lh=a(lp,"I-ORG"),lp.forEach(e),il=a(Rl," ngh\u0129a l\xE0 t\u1EEB t\u01B0\u01A1ng \u1EE9ng ph\u1EA7n b\u1EAFt \u0111\u1EA7u/ n\u1EB1m b\xEAn trong c\u1EE7a th\u1EF1c th\u1EC3 "),ol=c(Rl,"EM",{});var hp=r(ol);Hh=a(hp,"organization"),hp.forEach(e),Wl=a(Rl," hay "),Fe=c(Rl,"EM",{});var cp=r(Fe);Kl=a(cp,"t\u1ED5 ch\u1EE9c"),cp.forEach(e),Ds=a(Rl,"."),Rl.forEach(e),Zl=p(sl),_n=c(sl,"LI",{});var Fl=r(_n);pl=c(Fl,"CODE",{});var rp=r(pl);ul=a(rp,"B-LOC"),rp.forEach(e),Rh=a(Fl,"/"),ml=c(Fl,"CODE",{});var ip=r(ml);gl=a(ip,"I-LOC"),ip.forEach(e),Fh=a(Fl," ngh\u0129a l\xE0 t\u1EEB t\u01B0\u01A1ng \u1EE9ng ph\u1EA7n b\u1EAFt \u0111\u1EA7u/ n\u1EB1m b\xEAn trong c\u1EE7a th\u1EF1c th\u1EC3 "),fl=c(Fl,"EM",{});var op=r(fl);Yl=a(op,"location"),op.forEach(e),Ts=a(Fl," hay "),$a=c(Fl,"EM",{});var pp=r($a);Tt=a(pp,"\u0111\u1ECBa \u0111i\u1EC3m"),pp.forEach(e),Gh=a(Fl,"."),Fl.forEach(e),dl=p(sl),Pt=c(sl,"LI",{});var Gl=r(Pt);_l=c(Gl,"CODE",{});var up=r(_l);bl=a(up,"B-MISC"),up.forEach(e),Vh=a(Gl,"/"),vl=c(Gl,"CODE",{});var mp=r(vl);kl=a(mp,"I-MISC"),mp.forEach(e),Uh=a(Gl," ngh\u0129a l\xE0 t\u1EEB t\u01B0\u01A1ng \u1EE9ng ph\u1EA7n b\u1EAFt \u0111\u1EA7u/ n\u1EB1m b\xEAn trong c\u1EE7a th\u1EF1c th\u1EC3 "),yl=c(Gl,"EM",{});var gp=r(yl);Ql=a(gp,"miscellaneous"),gp.forEach(e),Ps=a(Gl," hay "),ja=c(Gl,"EM",{});var fp=r(ja);zs=a(fp,"l\u1ED9n x\u1ED9n"),fp.forEach(e),Jl=a(Gl,"."),Gl.forEach(e),sl.forEach(e),As=p(t),Ea=c(t,"P",{});var dp=r(Ea);nh=a(dp,"Gi\u1EDD khi gi\u1EA3i m\xE3 c\xE1c nh\xE3n, ta th\u1EA5y ch\xFAng cho ta:"),dp.forEach(e),cs=p(t),w(rs.$$.fragment,t),Jt=p(t),w(Ns.$$.fragment,t),wa=p(t),ke=c(t,"P",{});var Jr=r(ke);Xh=a(Jr,"V\xE0 \u0111\u1ED1i v\u1EDBi m\u1ED9t v\xED d\u1EE5 tr\u1ED9n nh\xE3n "),Bs=c(Jr,"CODE",{});var _p=r(Bs);Wh=a(_p,"B-"),_p.forEach(e),Kh=a(Jr," v\xE0 "),xa=c(Jr,"CODE",{});var bp=r(xa);Ge=a(bp,"I-"),bp.forEach(e),is=a(Jr,", \u0111\xE2y l\xE0 nh\u1EEFng g\xEC m\xE0 c\xF9ng m\u1ED9t \u0111o\u1EA1n m\xE3 cung c\u1EA5p cho ch\xFAng ta v\u1EC1 ph\u1EA7n t\u1EED c\u1EE7a t\u1EADp hu\u1EA5n luy\u1EC7n \u1EDF ch\u1EC9 m\u1EE5c 4:"),Jr.forEach(e),Ca=p(t),w(ne.$$.fragment,t),th=p(t),zt=c(t,"P",{});var ni=r(zt);Zh=a(ni,"Nh\u01B0 ch\xFAng ta c\xF3 th\u1EC3 th\u1EA5y, c\xE1c th\u1EF1c th\u1EC3 bao g\u1ED3m hai t\u1EEB, nh\u01B0 \u201CEuropean Union\u201D v\xE0 \u201CWerner Zwingmann\u201D, \u0111\u01B0\u1EE3c g\xE1n nh\xE3n "),Oa=c(ni,"CODE",{});var vp=r(Oa);ye=a(vp,"B-"),vp.forEach(e),Yh=a(ni," cho t\u1EEB \u0111\u1EA7u ti\xEAn v\xE0 nh\xE3n "),Ss=c(ni,"CODE",{});var kp=r(Ss);Qh=a(kp,"I-"),kp.forEach(e),Jh=a(ni," cho t\u1EEB th\u1EE9 hai."),ni.forEach(e),qa=p(t),w(os.$$.fragment,t),eh=p(t),$e=c(t,"H3",{class:!0});var Fi=r($e);At=c(Fi,"A",{id:!0,class:!0,href:!0});var yp=r(At);Da=c(yp,"SPAN",{});var $p=r(Da);w(je.$$.fragment,$p),$p.forEach(e),yp.forEach(e),nc=p(Fi),Ta=c(Fi,"SPAN",{});var jp=r(Ta);Ee=a(jp,"X\u1EED l\xFD d\u1EEF li\u1EC7u"),jp.forEach(e),Fi.forEach(e),ps=p(t),w(Is.$$.fragment,t),Pa=p(t),we=c(t,"P",{});var ti=r(we);tc=a(ti,"Nh\u01B0 th\u01B0\u1EDDng l\u1EC7, c\xE1c v\u0103n b\u1EA3n c\u1EE7a ch\xFAng ta c\u1EA7n \u0111\u01B0\u1EE3c chuy\u1EC3n \u0111\u1ED5i sang token ID tr\u01B0\u1EDBc khi m\xF4 h\xECnh c\xF3 th\u1EC3 hi\u1EC3u \u0111\u01B0\u1EE3c ch\xFAng. Nh\u01B0 ch\xFAng ta \u0111\xE3 th\u1EA5y trong "),za=c(ti,"A",{href:!0});var Ep=r(za);ut=a(Ep,"Ch\u01B0\u01A1ng 6"),Ep.forEach(e),ec=a(ti,", m\u1ED9t s\u1EF1 kh\xE1c bi\u1EC7t l\u1EDBn trong tr\u01B0\u1EDDng h\u1EE3p t\xE1c v\u1EE5 ph\xE2n lo\u1EA1i token l\xE0 ch\xFAng ta c\xF3 c\xE1c \u0111\u1EA7u v\xE0o \u0111\u01B0\u1EE3c tokenize tr\u01B0\u1EDBc. May m\u1EAFn thay, API tokenizer c\xF3 th\u1EC3 gi\u1EA3i quy\u1EBFt v\u1EA5n \u0111\u1EC1 \u0111\xF3 kh\xE1 d\u1EC5 d\xE0ng; ch\xFAng ta ch\u1EC9 c\u1EA7n b\xE1o "),Ms=c(ti,"CODE",{});var wp=r(Ms);sc=a(wp,"tokenizer"),wp.forEach(e),ac=a(ti," b\u1EB1ng m\u1ED9t l\xE1 c\u1EDD \u0111\u1EB7c bi\u1EC7t."),ti.forEach(e),Aa=p(t),us=c(t,"P",{});var Gi=r(us);lc=a(Gi,"\u0110\u1EC3 b\u1EAFt \u0111\u1EA7u, h\xE3y t\u1EA1o \u0111\u1ED1i t\u01B0\u1EE3ng "),Ls=c(Gi,"CODE",{});var xp=r(Ls);hc=a(xp,"tokenizer"),xp.forEach(e),cc=a(Gi," c\u1EE7a ch\xFAng ta. Nh\u01B0 ch\xFAng t\xF4i \u0111\xE3 n\xF3i tr\u01B0\u1EDBc \u0111\xE2y, ch\xFAng ta s\u1EBD s\u1EED d\u1EE5ng m\xF4 h\xECnh hu\u1EA5n luy\u1EC7n tr\u01B0\u1EDBc BERT, v\xEC v\u1EADy ch\xFAng ta s\u1EBD b\u1EAFt \u0111\u1EA7u b\u1EB1ng c\xE1ch t\u1EA3i xu\u1ED1ng v\xE0 l\u01B0u v\xE0o b\u1ED9 nh\u1EDB \u0111\u1EC7m c\u1EE7a tokenizer li\xEAn quan:"),Gi.forEach(e),Na=p(t),w(Hs.$$.fragment,t),sh=p(t),zn=c(t,"P",{});var ds=r(zn);Ve=a(ds,"B\u1EA1n c\xF3 th\u1EC3 thay th\u1EBF "),$l=c(ds,"CODE",{});var Cp=r($l);jl=a(Cp,"model_checkpoint"),Cp.forEach(e),rc=a(ds," b\u1EB1ng b\u1EA5t k\u1EF3 m\xF4 h\xECnh n\xE0o kh\xE1c m\xE0 b\u1EA1n th\xEDch t\u1EEB "),Rs=c(ds,"A",{href:!0,rel:!0});var Op=r(Rs);El=a(Op,"Hub"),Op.forEach(e),ic=a(ds," ho\u1EB7c b\u1EB1ng m\u1ED9t th\u01B0 m\u1EE5c c\u1EE5c b\u1ED9 trong \u0111\xF3 b\u1EA1n \u0111\xE3 l\u01B0u m\u1ED9t m\xF4 h\xECnh \u0111\u01B0\u1EE3c hu\u1EA5n luy\u1EC7n tr\u01B0\u1EDBc v\xE0 m\u1ED9t tr\xECnh tokenize. H\u1EA1n ch\u1EBF duy nh\u1EA5t l\xE0 tokenizer c\u1EA7n \u0111\u01B0\u1EE3c h\u1ED7 tr\u1EE3 b\u1EDFi th\u01B0 vi\u1EC7n \u{1F917} Tokenizers, v\xEC v\u1EADy s\u1EBD c\xF3 phi\xEAn b\u1EA3n \u201Cnhanh\u201D. 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 "),Fs=c(ds,"A",{href:!0,rel:!0});var qp=r(Fs);ah=a(qp,"b\u1EA3ng l\u1EDBn n\xE0y"),qp.forEach(e),Ba=a(ds," v\xE0 \u0111\u1EC3 ki\u1EC3m tra xem \u0111\u1ED1i t\u01B0\u1EE3ng "),wl=c(ds,"CODE",{});var Dp=r(wl);lh=a(Dp,"tokenizer"),Dp.forEach(e),Gs=a(ds," 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 "),Sa=c(ds,"CODE",{});var Tp=r(Sa);Ia=a(Tp,"is_fast"),Tp.forEach(e),oc=a(ds," c\u1EE7a n\xF3:"),ds.forEach(e),xl=p(t),w(te.$$.fragment,t),Cl=p(t),w(hn.$$.fragment,t),hh=p(t),Nt=c(t,"P",{});var ei=r(Nt);pc=a(ei,"\u0110\u1EC3 tokenize d\u1EEF li\u1EC7u \u0111\u1EA7u v\xE0o \u0111\xE3 ti\u1EC1n tokenize, ta c\xF3 th\u1EC3 s\u1EED d\u1EE5ng "),Ol=c(ei,"CODE",{});var Pp=r(Ol);ql=a(Pp,"tokenizer"),Pp.forEach(e),uc=a(ei," nh\u01B0 th\u01B0\u1EDDng l\u1EC7 v\xE0 ch\u1EC9 th\xEAm "),Dl=c(ei,"CODE",{});var zp=r(Dl);Tl=a(zp,"is_split_into_words=True"),zp.forEach(e),mc=a(ei,":"),ei.forEach(e),ch=p(t),w(Ue.$$.fragment,t),rh=p(t),w(Vs.$$.fragment,t),Ma=p(t),An=c(t,"P",{});var _s=r(An);gc=a(_s,"Nh\u01B0 ch\xFAng ta c\xF3 th\u1EC3 th\u1EA5y, tr\xECnh tokenizer \u0111\xE3 th\xEAm c\xE1c token \u0111\u1EB7c bi\u1EC7t \u0111\u01B0\u1EE3c s\u1EED d\u1EE5ng b\u1EDFi m\xF4 h\xECnh ("),Us=c(_s,"CODE",{});var Ap=r(Us);fc=a(Ap,"[CLS]"),Ap.forEach(e),dc=a(_s," \u1EDF \u0111\u1EA7u v\xE0 "),Xs=c(_s,"CODE",{});var Np=r(Xs);_c=a(Np,"[SEP]"),Np.forEach(e),bc=a(_s," \u1EDF cu\u1ED1i) v\xE0 \u0111\u1EC3 nguy\xEAn h\u1EA7u h\u1EBFt c\xE1c t\u1EEB. Tuy nhi\xEAn, t\u1EEB "),La=c(_s,"CODE",{});var Bp=r(La);xe=a(Bp,"lamb"),Bp.forEach(e),vc=a(_s," \u0111\xE3 \u0111\u01B0\u1EE3c tokenize th\xE0nh hai t\u1EEB ph\u1EE5, "),Ws=c(_s,"CODE",{});var Sp=r(Ws);kc=a(Sp,"la"),Sp.forEach(e),yc=a(_s," v\xE0 "),Xe=c(_s,"CODE",{});var Ip=r(Xe);Pl=a(Ip,"##mb"),Ip.forEach(e),$c=a(_s,". \u0110i\u1EC1u n\xE0y d\u1EABn \u0111\u1EBFn s\u1EF1 kh\xF4ng kh\u1EDBp gi\u1EEFa \u0111\u1EA7u v\xE0o v\xE0 c\xE1c nh\xE3n: danh s\xE1ch nh\xE3n ch\u1EC9 c\xF3 9 ph\u1EA7n t\u1EED, trong khi \u0111\u1EA7u v\xE0o c\u1EE7a ch\xFAng ta hi\u1EC7n c\xF3 12 token. Vi\u1EC7c t\xEDnh to\xE1n c\xE1c token \u0111\u1EB7c bi\u1EC7t r\u1EA5t d\u1EC5 d\xE0ng (ch\xFAng ta bi\u1EBFt ch\xFAng n\u1EB1m \u1EDF \u0111\u1EA7u v\xE0 cu\u1ED1i), nh\u01B0ng ch\xFAng ta c\u0169ng c\u1EA7n \u0111\u1EA3m b\u1EA3o r\u1EB1ng ch\xFAng ta s\u1EAFp x\u1EBFp t\u1EA5t c\u1EA3 c\xE1c nh\xE3n v\u1EDBi c\xE1c t\u1EEB th\xEDch h\u1EE3p."),_s.forEach(e),ih=p(t),We=c(t,"P",{});var Vi=r(We);l=a(Vi,"May m\u1EAFn thay, b\u1EDFi v\xEC ch\xFAng ta \u0111ang s\u1EED d\u1EE5ng m\u1ED9t tokenizer nhanh, ch\xFAng ta c\xF3 quy\u1EC1n truy c\u1EADp v\xE0o s\u1EE9c m\u1EA1nh si\xEAu c\u01B0\u1EDDng \u{1F917} Tokenizers, c\xF3 ngh\u0129a l\xE0 ch\xFAng ta c\xF3 th\u1EC3 d\u1EC5 d\xE0ng \xE1nh x\u1EA1 t\u1EEBng token v\u1EDBi t\u1EEB t\u01B0\u01A1ng \u1EE9ng c\u1EE7a n\xF3 (nh\u01B0 \u0111\xE3 th\u1EA5y trong "),d=c(Vi,"A",{href:!0});var Mp=r(d);sr=a(Mp,"Ch\u01B0\u01A1ng 6"),Mp.forEach(e),ar=a(Vi,"):"),Vi.forEach(e),jc=p(t),w(Ce.$$.fragment,t),Ec=p(t),w(Ha.$$.fragment,t),Ks=p(t),mt=c(t,"P",{});var al=r(mt);lr=a(al,"V\u1EDBi m\u1ED9t ch\xFAt c\xF4ng vi\u1EC7c, sau \u0111\xF3 ch\xFAng ta c\xF3 th\u1EC3 m\u1EDF r\u1ED9ng danh s\xE1ch nh\xE3n c\u1EE7a m\xECnh \u0111\u1EC3 ph\xF9 h\u1EE3p v\u1EDBi c\xE1c token. Quy t\u1EAFc \u0111\u1EA7u ti\xEAn ch\xFAng ta s\u1EBD \xE1p d\u1EE5ng l\xE0 c\xE1c token \u0111\u1EB7c bi\u1EC7t c\xF3 nh\xE3n l\xE0 "),Ra=c(al,"CODE",{});var Lp=r(Ra);hr=a(Lp,"-100"),Lp.forEach(e),Fa=a(al,". \u0110i\u1EC1u n\xE0y l\xE0 do theo m\u1EB7c \u0111\u1ECBnh "),oh=c(al,"CODE",{});var Hp=r(oh);cr=a(Hp,"-100"),Hp.forEach(e),ph=a(al," l\xE0 ch\u1EC9 s\u1ED1 b\u1ECB b\u1ECF qua trong h\xE0m m\u1EA5t m\xE1t m\xE0 ch\xFAng ta s\u1EBD s\u1EED d\u1EE5ng (entropy ch\xE9o). Sau \u0111\xF3, m\u1ED7i token c\xF3 c\xF9ng nh\xE3n v\u1EDBi token b\u1EAFt \u0111\u1EA7u t\u1EEB b\xEAn trong n\xF3, v\xEC ch\xFAng l\xE0 m\u1ED9t ph\u1EA7n c\u1EE7a c\xF9ng m\u1ED9t th\u1EF1c th\u1EC3. \u0110\u1ED1i v\u1EDBi c\xE1c token b\xEAn trong m\u1ED9t t\u1EEB nh\u01B0ng kh\xF4ng \u1EDF \u0111\u1EA7u, ch\xFAng ta thay th\u1EBF "),uh=c(al,"CODE",{});var Rp=r(uh);rr=a(Rp,"B-"),Rp.forEach(e),ir=a(al," b\u1EB1ng "),Ga=c(al,"CODE",{});var Fp=r(Ga);or=a(Fp,"I-"),Fp.forEach(e),pr=a(al," (v\xEC token kh\xF4ng b\u1EAFt \u0111\u1EA7u th\u1EF1c th\u1EC3):"),al.forEach(e),wc=p(t),w(ms.$$.fragment,t),xc=p(t),jn=c(t,"P",{});var Gp=r(jn);ur=a(Gp,"H\xE3y c\xF9ng th\u1EED v\u1EDBi c\xE2u \u0111\u1EA7u ti\xEAn:"),Gp.forEach(e),Cc=p(t),w(Va.$$.fragment,t),Oc=p(t),w(Ua.$$.fragment,t),qc=p(t),Ke=c(t,"P",{});var si=r(Ke);mh=a(si,"Nh\u01B0 ch\xFAng ta c\xF3 th\u1EC3 th\u1EA5y, h\xE0m \u0111\xE3 th\xEAm "),gh=c(si,"CODE",{});var Vp=r(gh);mr=a(Vp,"-100"),Vp.forEach(e),fh=a(si," cho hai token \u0111\u1EB7c bi\u1EC7t \u1EDF \u0111\u1EA7u v\xE0 cu\u1ED1i, v\xE0 d\u1EA5u "),dh=c(si,"CODE",{});var Up=r(dh);gr=a(Up,"0"),Up.forEach(e),Dc=a(si," m\u1EDBi cho t\u1EEB c\u1EE7a ch\xFAng ta \u0111\xE3 \u0111\u01B0\u1EE3c chia th\xE0nh hai token."),si.forEach(e),Tc=p(t),w(Zs.$$.fragment,t),zl=p(t),gt=c(t,"P",{});var ll=r(gt);fr=a(ll,"\u0110\u1EC3 x\u1EED l\xFD tr\u01B0\u1EDBc to\xE0n b\u1ED9 t\u1EADp d\u1EEF li\u1EC7u c\u1EE7a m\xECnh, ch\xFAng ta c\u1EA7n tokenize t\u1EA5t c\u1EA3 c\xE1c \u0111\u1EA7u v\xE0o v\xE0 \xE1p d\u1EE5ng "),_h=c(ll,"CODE",{});var Xp=r(_h);bh=a(Xp,"align_labels_with_tokens()"),Xp.forEach(e),dr=a(ll," tr\xEAn t\u1EA5t c\u1EA3 c\xE1c nh\xE3n. \u0110\u1EC3 t\u1EADn d\u1EE5ng t\u1ED1c \u0111\u1ED9 c\u1EE7a tr\xECnh tokenize nhanh c\u1EE7a m\xECnh, t\u1ED1t nh\u1EA5t b\u1EA1n n\xEAn tokenize nhi\u1EC1u v\u0103n b\u1EA3n c\xF9ng m\u1ED9t l\xFAc, v\xEC v\u1EADy ch\xFAng ta s\u1EBD vi\u1EBFt m\u1ED9t h\xE0m x\u1EED l\xFD danh s\xE1ch c\xE1c v\xED d\u1EE5 v\xE0 s\u1EED d\u1EE5ng ph\u01B0\u01A1ng th\u1EE9c "),Xa=c(ll,"CODE",{});var Wp=r(Xa);_r=a(Wp,"Dataset.map()"),Wp.forEach(e),br=a(ll," v\u1EDBi t\xF9y ch\u1ECDn "),vh=c(ll,"CODE",{});var Kp=r(vh);gs=a(Kp,"batched=True"),Kp.forEach(e),vr=a(ll,". \u0110i\u1EC1u duy nh\u1EA5t kh\xE1c v\u1EDBi v\xED d\u1EE5 tr\u01B0\u1EDBc l\xE0 h\xE0m "),kh=c(ll,"CODE",{});var Zp=r(kh);kr=a(Zp,"word_ids()"),Zp.forEach(e),yr=a(ll," c\u1EA7n l\u1EA5y ch\u1EC9 m\u1EE5c c\u1EE7a m\u1EABu m\xE0 ch\xFAng ta mu\u1ED1n c\xE1c ID t\u1EEB khi c\xE1c \u0111\u1EA7u v\xE0o cho tokenizer l\xE0 danh s\xE1ch v\u0103n b\u1EA3n (ho\u1EB7c trong tr\u01B0\u1EDDng h\u1EE3p c\u1EE7a ch\xFAng ta l\xE0 danh s\xE1ch danh s\xE1ch c\xE1c t\u1EEB), v\xEC v\u1EADy ch\xFAng ta c\u0169ng th\xEAm v\xE0o \u0111\xF3:"),ll.forEach(e),Ys=p(t),w(Wa.$$.fragment,t),Pc=p(t),Qs=c(t,"P",{});var Yp=r(Qs);$r=a(Yp,"L\u01B0u \xFD r\u1EB1ng ch\xFAng ta ch\u01B0a \u0111\u1EC7m v\xE0o c\u1EE7a m\xECnh; ch\xFAng ta s\u1EBD l\xE0m \u0111i\u1EC1u \u0111\xF3 sau, khi t\u1EA1o c\xE1c l\xF4 b\u1EB1ng tr\xECnh \u0111\u1ED1i chi\u1EBFu d\u1EEF li\u1EC7u."),Yp.forEach(e),Js=p(t),Al=c(t,"P",{});var Qp=r(Al);jr=a(Qp,"B\xE2y gi\u1EDD ch\xFAng ta c\xF3 th\u1EC3 \xE1p d\u1EE5ng t\u1EA5t c\u1EA3 ti\u1EC1n x\u1EED l\xFD \u0111\xF3 trong m\u1ED9t l\u1EA7n v\xE0o c\xE1c ph\u1EA7n kh\xE1c c\u1EE7a t\u1EADp d\u1EEF li\u1EC7u c\u1EE7a m\xECnh:"),Qp.forEach(e),Ze=p(t),w(Ka.$$.fragment,t),zc=p(t),na=c(t,"P",{});var Ui=r(na);Er=a(Ui,"Ch\xFAng ta \u0111\xE3 ho\xE0n th\xE0nh ph\u1EA7n kh\xF3 nh\u1EA5t! B\xE2y gi\u1EDD, d\u1EEF li\u1EC7u \u0111\xE3 \u0111\u01B0\u1EE3c ti\u1EC1n x\u1EED l\xFD, qu\xE1 tr\xECnh hu\u1EA5n luy\u1EC7n th\u1EF1c t\u1EBF s\u1EBD gi\u1ED1ng nh\u01B0 nh\u1EEFng g\xEC ch\xFAng ta \u0111\xE3 l\xE0m trong "),Ye=c(Ui,"A",{href:!0});var Jp=r(Ye);wr=a(Jp,"Ch\u01B0\u01A1ng 3"),Jp.forEach(e),xr=a(Ui,"."),Ui.forEach(e),Nl=p(t),qe.l(t),Bl=p(t),Bt=c(t,"H3",{class:!0});var Xi=r(Bt);ta=c(Xi,"A",{id:!0,class:!0,href:!0});var nu=r(ta);yh=c(nu,"SPAN",{});var tu=r(yh);w(Za.$$.fragment,tu),tu.forEach(e),nu.forEach(e),Ya=p(Xi),Qa=c(Xi,"SPAN",{});var eu=r(Qa);Cr=a(eu,"\u0110\u1ED1i chi\u1EBFu d\u1EEF li\u1EC7u"),eu.forEach(e),Xi.forEach(e),ee=p(t),se=c(t,"P",{});var qh=r(se);Or=a(qh,"Ch\xFAng ta kh\xF4ng th\u1EC3 ch\u1EC9 s\u1EED d\u1EE5ng m\u1ED9t "),$h=c(qh,"CODE",{});var su=r($h);qr=a(su,"DataCollatorWithPadding"),su.forEach(e),Ja=a(qh," nh\u01B0 trong "),Sl=c(qh,"A",{href:!0});var au=r(Sl);Dr=a(au,"Ch\u01B0\u01A1ng 3"),au.forEach(e),Tr=a(qh," v\xEC n\xF3 ch\u1EC9 \u0111\u1EC7m c\xE1c \u0111\u1EA7u v\xE0o (ID \u0111\u1EA7u v\xE0o, attention mask v\xE0 lo\u1EA1i token ID). \u1EDE \u0111\xE2y, c\xE1c nh\xE3n c\u1EE7a ch\xFAng ta n\xEAn \u0111\u01B0\u1EE3c \u0111\u1EC7m theo c\xF9ng m\u1ED9t c\xE1ch gi\u1ED1ng nh\u01B0 c\xE1c \u0111\u1EA7u v\xE0o \u0111\u1EC3 ch\xFAng gi\u1EEF nguy\xEAn k\xEDch th\u01B0\u1EDBc, s\u1EED d\u1EE5ng "),jh=c(qh,"CODE",{});var lu=r(jh);Nn=a(lu,"-100"),lu.forEach(e),Pr=a(qh," l\xE0m gi\xE1 tr\u1ECB \u0111\u1EC3 c\xE1c d\u1EF1 \u0111o\xE1n t\u01B0\u01A1ng \u1EE9ng b\u1ECB b\u1ECF qua trong t\xEDnh to\xE1n t\u1ED5n th\u1EA5t."),qh.forEach(e),Ac=p(t),ae=c(t,"P",{});var Dh=r(ae);zr=a(Dh,"T\u1EA5t c\u1EA3 \u0111i\u1EC1u n\xE0y \u0111\u01B0\u1EE3c th\u1EF1c hi\u1EC7n b\u1EDFi "),nl=c(Dh,"A",{href:!0,rel:!0});var hu=r(nl);Eh=c(hu,"CODE",{});var cu=r(Eh);Ar=a(cu,"DataCollatorForTokenClassification"),cu.forEach(e),hu.forEach(e),tl=a(Dh,". Gi\u1ED1ng nh\u01B0 "),wh=c(Dh,"CODE",{});var ru=r(wh);Nr=a(ru,"DataCollatorWithPadding"),ru.forEach(e),Br=a(Dh,", n\xF3 s\u1EED d\u1EE5ng "),ai=c(Dh,"CODE",{});var iu=r(ai);Yi=a(iu,"tokenizer"),iu.forEach(e),Qi=a(Dh," \u0111\u1EC3 x\u1EED l\xFD tr\u01B0\u1EDBc c\xE1c \u0111\u1EA7u v\xE0o:"),Dh.forEach(e),mi=p(t),sa.l(t),Sr=p(t),Ir=c(t,"P",{});var ou=r(Ir);Ji=a(ou,"\u0110\u1EC3 ki\u1EC3m tra n\xF3 tr\xEAn v\xE0i m\u1EABu, ta c\xF3 th\u1EC3 g\u1ECDi n\xF3 tr\xEAn danh s\xE1ch c\xE1c m\u1EABu t\u1EEB t\u1EADp hu\u1EA5n luy\u1EC7n \u0111\xE3 \u0111\u01B0\u1EE3c tokenize:"),ou.forEach(e),gi=p(t),w(Nc.$$.fragment,t),fi=p(t),w(Bc.$$.fragment,t),di=p(t),Mr=c(t,"P",{});var pu=r(Mr);no=a(pu,"H\xE3y so s\xE1nh \u0111i\u1EC1u n\xE0y v\u1EDBi c\xE1c nh\xE3n cho ph\u1EA7n t\u1EED \u0111\u1EA7u ti\xEAn v\xE0 th\u1EE9 hai trong t\u1EADp d\u1EEF li\u1EC7u c\u1EE7a m\xECnh:"),pu.forEach(e),_i=p(t),w(Sc.$$.fragment,t),bi=p(t),w(Ic.$$.fragment,t),vi=p(t),la.l(t),Lr=p(t),Fn&&Fn.l(t),Hr=p(t),Il=c(t,"H3",{class:!0});var Wi=r(Il);xh=c(Wi,"A",{id:!0,class:!0,href:!0});var uu=r(xh);li=c(uu,"SPAN",{});var mu=r(li);w(Mc.$$.fragment,mu),mu.forEach(e),uu.forEach(e),to=p(Wi),hi=c(Wi,"SPAN",{});var gu=r(hi);eo=a(gu,"Th\u01B0\u1EDBc \u0111o"),gu.forEach(e),Wi.forEach(e),ki=p(t),ca.l(t),Rr=p(t),w(Lc.$$.fragment,t),yi=p(t),Fr=c(t,"P",{});var fu=r(Fr);so=a(fu,"Th\u01B0\u1EDBc \u0111o n\xE0y kh\xF4ng gi\u1ED1ng nh\u01B0 c\xE1c th\u01B0\u1EDBc \u0111o \u0111\u1ED9 ch\xEDnh x\xE1c th\xF4ng th\u01B0\u01A1ng: n\xF3 s\u1EBD nh\u1EADn m\u1ED9t danh s\xE1ch c\xE1c nh\xE3n nh\u01B0 l\xE0 chu\u1ED7i v\u0103n b\u1EA3n, kh\xF4ng ph\u1EA3i s\u1ED1 nguy\xEAn, n\xEAn ta s\u1EBD c\u1EA7n gi\u1EA3i m\xE3 to\xE0n b\u1ED9 nh\u1EEFng d\u1EF1 \u0111o\xE1n v\xE0 nh\xE3n tr\u01B0\u1EDBc khi truy\u1EC1n ch\xFAng v\xE0o th\u01B0\u1EDBc \u0111o. H\xE3y c\xF9ng xem n\xF3 ho\u1EA1t \u0111\u1ED9ng ra sao. \u0110\u1EA7u ti\xEAn, ta s\u1EBD l\u1EA5y nh\u1EEFng nh\xE3n t\u1EEB m\u1EABu hu\u1EA5n luy\u1EC7n \u0111\u1EA7u ti\xEAn:"),fu.forEach(e),$i=p(t),w(Hc.$$.fragment,t),ji=p(t),w(Rc.$$.fragment,t),Ei=p(t),Gr=c(t,"P",{});var du=r(Gr);ao=a(du,"Ta c\xF3 th\u1EC3 t\u1EA1o ra nh\u1EEFng d\u1EF1 \u0111o\xE1n gi\u1EA3 cho ch\xFAng b\u1EB1ng c\xE1ch thay \u0111\u1ED5i gi\xE1 tr\u1ECB \u1EDF ch\u1EC9 m\u1EE5c 2:"),du.forEach(e),wi=p(t),w(Fc.$$.fragment,t),xi=p(t),Vr=c(t,"P",{});var _u=r(Vr);lo=a(_u,"L\u01B0u \xFD r\u1EB1ng th\u01B0\u1EDBc \u0111o nh\u1EADn danh s\xE1ch c\xE1c d\u1EF1 \u0111o\xE1n (kh\xF4ng ch\u1EC9 m\u1ED9t) v\xE0 danh s\xE1ch c\xE1c nh\xE3n. \u0110\xE2y l\xE0 \u0111\u1EA7u ra:"),_u.forEach(e),Ci=p(t),w(Gc.$$.fragment,t),Oi=p(t),ia.l(t),Ur=p(t),Gn&&Gn.l(t),Xr=p(t),Ml=c(t,"H2",{class:!0});var Ki=r(Ml);Ch=c(Ki,"A",{id:!0,class:!0,href:!0});var bu=r(Ch);ci=c(bu,"SPAN",{});var vu=r(ci);w(Vc.$$.fragment,vu),vu.forEach(e),bu.forEach(e),ho=p(Ki),ri=c(Ki,"SPAN",{});var ku=r(ri);co=a(ku,"S\u1EED d\u1EE5ng m\xF4 h\xECnh \u0111\xE3 \u0111\u01B0\u1EE3c tinh ch\u1EC9nh"),ku.forEach(e),Ki.forEach(e),qi=p(t),Oh=c(t,"P",{});var Zi=r(Oh);ro=a(Zi,"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 "),ii=c(Zi,"CODE",{});var yu=r(ii);io=a(yu,"pipeline"),yu.forEach(e),oo=a(Zi,", b\u1EA1n ch\u1EC9 c\u1EA7n ch\u1EC9 \u0111\u1ECBnh m\xE3 \u0111\u1ECBnh danh m\xF4 h\xECnh th\xEDch h\u1EE3p:"),Zi.forEach(e),Di=p(t),w(Uc.$$.fragment,t),Ti=p(t),w(Xc.$$.fragment,t),Pi=p(t),Wr=c(t,"P",{});var $u=r(Wr);po=a($u,"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!"),$u.forEach(e),this.h()},h(){y(m,"name","hf:doc:metadata"),y(m,"content",JSON.stringify(tm)),y(k,"id","phn-loi-token"),y(k,"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"),y(k,"href","#phn-loi-token"),y(O,"class","relative group"),mo(gn.src,Vn="https://hf.space/gradioiframe/course-demos/bert-finetuned-ner/+")||y(gn,"src",Vn),y(gn,"frameborder","0"),y(gn,"height","350"),y(gn,"title","Gradio app"),y(gn,"class","block dark:hidden container p-0 flex-grow space-iframe"),y(gn,"allow","accelerometer; ambient-light-sensor; autoplay; battery; camera; document-domain; encrypted-media; fullscreen; geolocation; gyroscope; layout-animations; legacy-image-formats; magnetometer; microphone; midi; oversized-images; payment; picture-in-picture; publickey-credentials-get; sync-xhr; usb; vr ; wake-lock; xr-spatial-tracking"),y(gn,"sandbox","allow-forms allow-modals allow-popups allow-popups-to-escape-sandbox allow-same-origin allow-scripts allow-downloads"),y(pn,"class","block dark:hidden lg:w-3/5"),mo(pn.src,re="https://huggingface.co/datasets/huggingface-course/documentation-images/resolve/main/en/chapter7/model-eval-bert-finetuned-ner.png")||y(pn,"src",re),y(pn,"alt","One-hot encoded labels for question answering."),y(Mt,"class","hidden dark:block lg:w-3/5"),mo(Mt.src,ie="https://huggingface.co/datasets/huggingface-course/documentation-images/resolve/main/en/chapter7/model-eval-bert-finetuned-ner-dark.png")||y(Mt,"src",ie),y(Mt,"alt","One-hot encoded labels for question answering."),y(tn,"class","flex justify-center"),y(tn,"href","/huggingface-course/bert-finetuned-ner"),y(Lt,"href","https://huggingface.co/huggingface-course/bert-finetuned-ner?text=My+name+is+Sylvain+and+I+work+at+Hugging+Face+in+Brooklyn"),y(Lt,"rel","nofollow"),y(wn,"id","chun-b-d-liu"),y(wn,"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"),y(wn,"href","#chun-b-d-liu"),y(yn,"class","relative group"),y(Wn,"href","https://huggingface.co/datasets/conll2003"),y(Wn,"rel","nofollow"),y(Cn,"id","tp-d-liu-conll2003"),y(Cn,"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"),y(Cn,"href","#tp-d-liu-conll2003"),y(xn,"class","relative group"),y($t,"href","/course/chapter3"),y(Qt,"href","/course/chapter6/3"),y(At,"id","x-l-d-liu"),y(At,"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"),y(At,"href","#x-l-d-liu"),y($e,"class","relative group"),y(za,"href","/course/chapter6/"),y(Rs,"href","https://huggingface.co/models"),y(Rs,"rel","nofollow"),y(Fs,"href","https://huggingface.co/transformers/#supported-frameworks"),y(Fs,"rel","nofollow"),y(d,"href","/course/chapter6/3"),y(Ye,"href","/course/chapter3"),y(ta,"id","i-chiu-d-liu"),y(ta,"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"),y(ta,"href","#i-chiu-d-liu"),y(Bt,"class","relative group"),y(Sl,"href","/course/chapter3"),y(nl,"href","https://huggingface.co/transformers/main_classes/data_collator.html#datacollatorfortokenclassification"),y(nl,"rel","nofollow"),y(xh,"id","thc-o"),y(xh,"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"),y(xh,"href","#thc-o"),y(Il,"class","relative group"),y(Ch,"id","s-dng-m-hnh-c-tinh-chnh"),y(Ch,"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"),y(Ch,"href","#s-dng-m-hnh-c-tinh-chnh"),y(Ml,"class","relative group")},m(t,u){n(document.head,m),i(t,v,u),x(f,t,u),i(t,$,u),i(t,O,u),n(O,k),n(k,j),x(q,j,null),n(O,D),n(O,z),n(z,I),i(t,A,u),Wc[N].m(t,u),i(t,B,u),i(t,R,u),n(R,F),i(t,M,u),i(t,W,u),n(W,T),n(T,U),n(U,L),n(T,K),n(W,nn),n(W,an),n(an,ln),n(ln,Z),n(an,un),n(W,Q),n(W,G),n(G,H),n(H,en),n(G,mn),n(G,kn),n(kn,sn),n(G,Bn),n(G,Y),n(Y,at),n(G,on),n(G,ft),n(ft,le),n(G,lt),i(t,Qe,u),x(It,t,u),i(t,he,u),i(t,bn,u),n(bn,De),i(t,En,u),i(t,gn,u),i(t,ce,u),i(t,tn,u),n(tn,pn),n(tn,Sn),n(tn,Mt),i(t,Je,u),i(t,Un,u),n(Un,In),n(Un,Lt),n(Lt,oe),n(Un,Ht),i(t,Te,u),i(t,yn,u),n(yn,wn),n(wn,Rt),x($n,Rt,null),n(yn,bs),n(yn,Ft),n(Ft,Xn),i(t,Pe,u),i(t,cn,u),n(cn,Gt),n(cn,Wn),n(Wn,dt),n(cn,vs),i(t,_t,u),x(bt,t,u),i(t,ns,u),i(t,xn,u),n(xn,Cn),n(Cn,pe),x(J,pe,null),n(xn,Vt),n(xn,vt),n(vt,Kn),i(t,ts,u),i(t,On,u),n(On,ks),n(On,ze),n(ze,ht),n(On,Ae),i(t,es,u),x(kt,t,u),i(t,Mn,u),i(t,yt,u),n(yt,Ne),n(yt,$t),n($t,ys),n(yt,ss),i(t,Zn,u),x(jt,t,u),i(t,fn,u),x(Et,t,u),i(t,Yn,u),i(t,ct,u),n(ct,wt),n(ct,rt),n(rt,Ut),n(ct,$s),i(t,as,u),i(t,it,u),n(it,Xt),i(t,Be,u),x(qn,t,u),i(t,ls,u),x(xt,t,u),i(t,Qn,u),i(t,Jn,u),n(Jn,ue),i(t,Wt,u),x(Kt,t,u),i(t,me,u),x(vn,t,u),i(t,Se,u),i(t,Dn,u),n(Dn,g),n(Dn,S),n(S,ge),n(Dn,js),i(t,Zt,u),x(Tn,t,u),i(t,Es,u),x(fe,t,u),i(t,Ct,u),i(t,rn,u),n(rn,oa),n(rn,Yt),n(Yt,Ot),n(rn,Ln),n(rn,de),n(de,_e),n(rn,hs),n(rn,be),n(be,pa),n(rn,ws),n(rn,ot),n(ot,ua),n(rn,Ie),n(rn,nt),n(nt,ma),n(rn,xs),i(t,pt,u),x(dn,t,u),i(t,Me,u),x(tt,t,u),i(t,Le,u),i(t,Hn,u),n(Hn,et),n(Hn,He),n(He,Rn),n(Hn,ga),n(Hn,Qt),n(Qt,fa),n(Hn,da),i(t,Re,u),i(t,st,u),n(st,_a),n(_a,Cs),n(Cs,Ah),n(_a,Nh),n(st,Vl),n(st,Pn),n(Pn,ba),n(ba,va),n(Pn,Bh),n(Pn,ka),n(ka,Os),n(Pn,Ul),n(Pn,qt),n(qt,Sh),n(Pn,hl),n(Pn,cl),n(cl,Ih),n(Pn,rl),n(st,Mh),n(st,Dt),n(Dt,ya),n(ya,qs),n(Dt,Xl),n(Dt,ve),n(ve,Lh),n(Dt,il),n(Dt,ol),n(ol,Hh),n(Dt,Wl),n(Dt,Fe),n(Fe,Kl),n(Dt,Ds),n(st,Zl),n(st,_n),n(_n,pl),n(pl,ul),n(_n,Rh),n(_n,ml),n(ml,gl),n(_n,Fh),n(_n,fl),n(fl,Yl),n(_n,Ts),n(_n,$a),n($a,Tt),n(_n,Gh),n(st,dl),n(st,Pt),n(Pt,_l),n(_l,bl),n(Pt,Vh),n(Pt,vl),n(vl,kl),n(Pt,Uh),n(Pt,yl),n(yl,Ql),n(Pt,Ps),n(Pt,ja),n(ja,zs),n(Pt,Jl),i(t,As,u),i(t,Ea,u),n(Ea,nh),i(t,cs,u),x(rs,t,u),i(t,Jt,u),x(Ns,t,u),i(t,wa,u),i(t,ke,u),n(ke,Xh),n(ke,Bs),n(Bs,Wh),n(ke,Kh),n(ke,xa),n(xa,Ge),n(ke,is),i(t,Ca,u),x(ne,t,u),i(t,th,u),i(t,zt,u),n(zt,Zh),n(zt,Oa),n(Oa,ye),n(zt,Yh),n(zt,Ss),n(Ss,Qh),n(zt,Jh),i(t,qa,u),x(os,t,u),i(t,eh,u),i(t,$e,u),n($e,At),n(At,Da),x(je,Da,null),n($e,nc),n($e,Ta),n(Ta,Ee),i(t,ps,u),x(Is,t,u),i(t,Pa,u),i(t,we,u),n(we,tc),n(we,za),n(za,ut),n(we,ec),n(we,Ms),n(Ms,sc),n(we,ac),i(t,Aa,u),i(t,us,u),n(us,lc),n(us,Ls),n(Ls,hc),n(us,cc),i(t,Na,u),x(Hs,t,u),i(t,sh,u),i(t,zn,u),n(zn,Ve),n(zn,$l),n($l,jl),n(zn,rc),n(zn,Rs),n(Rs,El),n(zn,ic),n(zn,Fs),n(Fs,ah),n(zn,Ba),n(zn,wl),n(wl,lh),n(zn,Gs),n(zn,Sa),n(Sa,Ia),n(zn,oc),i(t,xl,u),x(te,t,u),i(t,Cl,u),x(hn,t,u),i(t,hh,u),i(t,Nt,u),n(Nt,pc),n(Nt,Ol),n(Ol,ql),n(Nt,uc),n(Nt,Dl),n(Dl,Tl),n(Nt,mc),i(t,ch,u),x(Ue,t,u),i(t,rh,u),x(Vs,t,u),i(t,Ma,u),i(t,An,u),n(An,gc),n(An,Us),n(Us,fc),n(An,dc),n(An,Xs),n(Xs,_c),n(An,bc),n(An,La),n(La,xe),n(An,vc),n(An,Ws),n(Ws,kc),n(An,yc),n(An,Xe),n(Xe,Pl),n(An,$c),i(t,ih,u),i(t,We,u),n(We,l),n(We,d),n(d,sr),n(We,ar),i(t,jc,u),x(Ce,t,u),i(t,Ec,u),x(Ha,t,u),i(t,Ks,u),i(t,mt,u),n(mt,lr),n(mt,Ra),n(Ra,hr),n(mt,Fa),n(mt,oh),n(oh,cr),n(mt,ph),n(mt,uh),n(uh,rr),n(mt,ir),n(mt,Ga),n(Ga,or),n(mt,pr),i(t,wc,u),x(ms,t,u),i(t,xc,u),i(t,jn,u),n(jn,ur),i(t,Cc,u),x(Va,t,u),i(t,Oc,u),x(Ua,t,u),i(t,qc,u),i(t,Ke,u),n(Ke,mh),n(Ke,gh),n(gh,mr),n(Ke,fh),n(Ke,dh),n(dh,gr),n(Ke,Dc),i(t,Tc,u),x(Zs,t,u),i(t,zl,u),i(t,gt,u),n(gt,fr),n(gt,_h),n(_h,bh),n(gt,dr),n(gt,Xa),n(Xa,_r),n(gt,br),n(gt,vh),n(vh,gs),n(gt,vr),n(gt,kh),n(kh,kr),n(gt,yr),i(t,Ys,u),x(Wa,t,u),i(t,Pc,u),i(t,Qs,u),n(Qs,$r),i(t,Js,u),i(t,Al,u),n(Al,jr),i(t,Ze,u),x(Ka,t,u),i(t,zc,u),i(t,na,u),n(na,Er),n(na,Ye),n(Ye,wr),n(na,xr),i(t,Nl,u),Kc[Oe].m(t,u),i(t,Bl,u),i(t,Bt,u),n(Bt,ta),n(ta,yh),x(Za,yh,null),n(Bt,Ya),n(Bt,Qa),n(Qa,Cr),i(t,ee,u),i(t,se,u),n(se,Or),n(se,$h),n($h,qr),n(se,Ja),n(se,Sl),n(Sl,Dr),n(se,Tr),n(se,jh),n(jh,Nn),n(se,Pr),i(t,Ac,u),i(t,ae,u),n(ae,zr),n(ae,nl),n(nl,Eh),n(Eh,Ar),n(ae,tl),n(ae,wh),n(wh,Nr),n(ae,Br),n(ae,ai),n(ai,Yi),n(ae,Qi),i(t,mi,u),Zc[ea].m(t,u),i(t,Sr,u),i(t,Ir,u),n(Ir,Ji),i(t,gi,u),x(Nc,t,u),i(t,fi,u),x(Bc,t,u),i(t,di,u),i(t,Mr,u),n(Mr,no),i(t,_i,u),x(Sc,t,u),i(t,bi,u),x(Ic,t,u),i(t,vi,u),Yc[aa].m(t,u),i(t,Lr,u),Fn&&Fn.m(t,u),i(t,Hr,u),i(t,Il,u),n(Il,xh),n(xh,li),x(Mc,li,null),n(Il,to),n(Il,hi),n(hi,eo),i(t,ki,u),Qc[ha].m(t,u),i(t,Rr,u),x(Lc,t,u),i(t,yi,u),i(t,Fr,u),n(Fr,so),i(t,$i,u),x(Hc,t,u),i(t,ji,u),x(Rc,t,u),i(t,Ei,u),i(t,Gr,u),n(Gr,ao),i(t,wi,u),x(Fc,t,u),i(t,xi,u),i(t,Vr,u),n(Vr,lo),i(t,Ci,u),x(Gc,t,u),i(t,Oi,u),Jc[ra].m(t,u),i(t,Ur,u),Gn&&Gn.m(t,u),i(t,Xr,u),i(t,Ml,u),n(Ml,Ch),n(Ch,ci),x(Vc,ci,null),n(Ml,ho),n(Ml,ri),n(ri,co),i(t,qi,u),i(t,Oh,u),n(Oh,ro),n(Oh,ii),n(ii,io),n(Oh,oo),i(t,Di,u),x(Uc,t,u),i(t,Ti,u),x(Xc,t,u),i(t,Pi,u),i(t,Wr,u),n(Wr,po),zi=!0},p(t,[u]){const nr={};u&1&&(nr.fw=t[0]),f.$set(nr);let Kr=N;N=fo(t),N!==Kr&&(Ph(),b(Wc[Kr],1,1,()=>{Wc[Kr]=null}),Th(),V=Wc[N],V||(V=Wc[N]=go[N](t),V.c()),_(V,1),V.m(B.parentNode,B));const oi={};u&2&&(oi.$$scope={dirty:u,ctx:t}),bt.$set(oi);const pi={};u&2&&(pi.$$scope={dirty:u,ctx:t}),os.$set(pi);const ui={};u&2&&(ui.$$scope={dirty:u,ctx:t}),Zs.$set(ui);let el=Oe;Oe=bo(t),Oe!==el&&(Ph(),b(Kc[el],1,1,()=>{Kc[el]=null}),Th(),qe=Kc[Oe],qe||(qe=Kc[Oe]=_o[Oe](t),qe.c()),_(qe,1),qe.m(Bl.parentNode,Bl));let tr=ea;ea=ko(t),ea!==tr&&(Ph(),b(Zc[tr],1,1,()=>{Zc[tr]=null}),Th(),sa=Zc[ea],sa||(sa=Zc[ea]=vo[ea](t),sa.c()),_(sa,1),sa.m(Sr.parentNode,Sr));let Zr=aa;aa=$o(t),aa!==Zr&&(Ph(),b(Yc[Zr],1,1,()=>{Yc[Zr]=null}),Th(),la=Yc[aa],la||(la=Yc[aa]=yo[aa](t),la.c()),_(la,1),la.m(Lr.parentNode,Lr)),t[0]==="tf"?Fn?u&1&&_(Fn,1):(Fn=wu(t),Fn.c(),_(Fn,1),Fn.m(Hr.parentNode,Hr)):Fn&&(Ph(),b(Fn,1,1,()=>{Fn=null}),Th());let er=ha;ha=Eo(t),ha!==er&&(Ph(),b(Qc[er],1,1,()=>{Qc[er]=null}),Th(),ca=Qc[ha],ca||(ca=Qc[ha]=jo[ha](t),ca.c()),_(ca,1),ca.m(Rr.parentNode,Rr));let Yr=ra;ra=xo(t),ra!==Yr&&(Ph(),b(Jc[Yr],1,1,()=>{Jc[Yr]=null}),Th(),ia=Jc[ra],ia||(ia=Jc[ra]=wo[ra](t),ia.c()),_(ia,1),ia.m(Ur.parentNode,Ur)),t[0]==="pt"?Gn?u&1&&_(Gn,1):(Gn=xu(t),Gn.c(),_(Gn,1),Gn.m(Xr.parentNode,Xr)):Gn&&(Ph(),b(Gn,1,1,()=>{Gn=null}),Th())},i(t){zi||(_(f.$$.fragment,t),_(q.$$.fragment,t),_(V),_(It.$$.fragment,t),_($n.$$.fragment,t),_(bt.$$.fragment,t),_(J.$$.fragment,t),_(kt.$$.fragment,t),_(jt.$$.fragment,t),_(Et.$$.fragment,t),_(qn.$$.fragment,t),_(xt.$$.fragment,t),_(Kt.$$.fragment,t),_(vn.$$.fragment,t),_(Tn.$$.fragment,t),_(fe.$$.fragment,t),_(dn.$$.fragment,t),_(tt.$$.fragment,t),_(rs.$$.fragment,t),_(Ns.$$.fragment,t),_(ne.$$.fragment,t),_(os.$$.fragment,t),_(je.$$.fragment,t),_(Is.$$.fragment,t),_(Hs.$$.fragment,t),_(te.$$.fragment,t),_(hn.$$.fragment,t),_(Ue.$$.fragment,t),_(Vs.$$.fragment,t),_(Ce.$$.fragment,t),_(Ha.$$.fragment,t),_(ms.$$.fragment,t),_(Va.$$.fragment,t),_(Ua.$$.fragment,t),_(Zs.$$.fragment,t),_(Wa.$$.fragment,t),_(Ka.$$.fragment,t),_(qe),_(Za.$$.fragment,t),_(sa),_(Nc.$$.fragment,t),_(Bc.$$.fragment,t),_(Sc.$$.fragment,t),_(Ic.$$.fragment,t),_(la),_(Fn),_(Mc.$$.fragment,t),_(ca),_(Lc.$$.fragment,t),_(Hc.$$.fragment,t),_(Rc.$$.fragment,t),_(Fc.$$.fragment,t),_(Gc.$$.fragment,t),_(ia),_(Gn),_(Vc.$$.fragment,t),_(Uc.$$.fragment,t),_(Xc.$$.fragment,t),zi=!0)},o(t){b(f.$$.fragment,t),b(q.$$.fragment,t),b(V),b(It.$$.fragment,t),b($n.$$.fragment,t),b(bt.$$.fragment,t),b(J.$$.fragment,t),b(kt.$$.fragment,t),b(jt.$$.fragment,t),b(Et.$$.fragment,t),b(qn.$$.fragment,t),b(xt.$$.fragment,t),b(Kt.$$.fragment,t),b(vn.$$.fragment,t),b(Tn.$$.fragment,t),b(fe.$$.fragment,t),b(dn.$$.fragment,t),b(tt.$$.fragment,t),b(rs.$$.fragment,t),b(Ns.$$.fragment,t),b(ne.$$.fragment,t),b(os.$$.fragment,t),b(je.$$.fragment,t),b(Is.$$.fragment,t),b(Hs.$$.fragment,t),b(te.$$.fragment,t),b(hn.$$.fragment,t),b(Ue.$$.fragment,t),b(Vs.$$.fragment,t),b(Ce.$$.fragment,t),b(Ha.$$.fragment,t),b(ms.$$.fragment,t),b(Va.$$.fragment,t),b(Ua.$$.fragment,t),b(Zs.$$.fragment,t),b(Wa.$$.fragment,t),b(Ka.$$.fragment,t),b(qe),b(Za.$$.fragment,t),b(sa),b(Nc.$$.fragment,t),b(Bc.$$.fragment,t),b(Sc.$$.fragment,t),b(Ic.$$.fragment,t),b(la),b(Fn),b(Mc.$$.fragment,t),b(ca),b(Lc.$$.fragment,t),b(Hc.$$.fragment,t),b(Rc.$$.fragment,t),b(Fc.$$.fragment,t),b(Gc.$$.fragment,t),b(ia),b(Gn),b(Vc.$$.fragment,t),b(Uc.$$.fragment,t),b(Xc.$$.fragment,t),zi=!1},d(t){e(m),t&&e(v),C(f,t),t&&e($),t&&e(O),C(q),t&&e(A),Wc[N].d(t),t&&e(B),t&&e(R),t&&e(M),t&&e(W),t&&e(Qe),C(It,t),t&&e(he),t&&e(bn),t&&e(En),t&&e(gn),t&&e(ce),t&&e(tn),t&&e(Je),t&&e(Un),t&&e(Te),t&&e(yn),C($n),t&&e(Pe),t&&e(cn),t&&e(_t),C(bt,t),t&&e(ns),t&&e(xn),C(J),t&&e(ts),t&&e(On),t&&e(es),C(kt,t),t&&e(Mn),t&&e(yt),t&&e(Zn),C(jt,t),t&&e(fn),C(Et,t),t&&e(Yn),t&&e(ct),t&&e(as),t&&e(it),t&&e(Be),C(qn,t),t&&e(ls),C(xt,t),t&&e(Qn),t&&e(Jn),t&&e(Wt),C(Kt,t),t&&e(me),C(vn,t),t&&e(Se),t&&e(Dn),t&&e(Zt),C(Tn,t),t&&e(Es),C(fe,t),t&&e(Ct),t&&e(rn),t&&e(pt),C(dn,t),t&&e(Me),C(tt,t),t&&e(Le),t&&e(Hn),t&&e(Re),t&&e(st),t&&e(As),t&&e(Ea),t&&e(cs),C(rs,t),t&&e(Jt),C(Ns,t),t&&e(wa),t&&e(ke),t&&e(Ca),C(ne,t),t&&e(th),t&&e(zt),t&&e(qa),C(os,t),t&&e(eh),t&&e($e),C(je),t&&e(ps),C(Is,t),t&&e(Pa),t&&e(we),t&&e(Aa),t&&e(us),t&&e(Na),C(Hs,t),t&&e(sh),t&&e(zn),t&&e(xl),C(te,t),t&&e(Cl),C(hn,t),t&&e(hh),t&&e(Nt),t&&e(ch),C(Ue,t),t&&e(rh),C(Vs,t),t&&e(Ma),t&&e(An),t&&e(ih),t&&e(We),t&&e(jc),C(Ce,t),t&&e(Ec),C(Ha,t),t&&e(Ks),t&&e(mt),t&&e(wc),C(ms,t),t&&e(xc),t&&e(jn),t&&e(Cc),C(Va,t),t&&e(Oc),C(Ua,t),t&&e(qc),t&&e(Ke),t&&e(Tc),C(Zs,t),t&&e(zl),t&&e(gt),t&&e(Ys),C(Wa,t),t&&e(Pc),t&&e(Qs),t&&e(Js),t&&e(Al),t&&e(Ze),C(Ka,t),t&&e(zc),t&&e(na),t&&e(Nl),Kc[Oe].d(t),t&&e(Bl),t&&e(Bt),C(Za),t&&e(ee),t&&e(se),t&&e(Ac),t&&e(ae),t&&e(mi),Zc[ea].d(t),t&&e(Sr),t&&e(Ir),t&&e(gi),C(Nc,t),t&&e(fi),C(Bc,t),t&&e(di),t&&e(Mr),t&&e(_i),C(Sc,t),t&&e(bi),C(Ic,t),t&&e(vi),Yc[aa].d(t),t&&e(Lr),Fn&&Fn.d(t),t&&e(Hr),t&&e(Il),C(Mc),t&&e(ki),Qc[ha].d(t),t&&e(Rr),C(Lc,t),t&&e(yi),t&&e(Fr),t&&e($i),C(Hc,t),t&&e(ji),C(Rc,t),t&&e(Ei),t&&e(Gr),t&&e(wi),C(Fc,t),t&&e(xi),t&&e(Vr),t&&e(Ci),C(Gc,t),t&&e(Oi),Jc[ra].d(t),t&&e(Ur),Gn&&Gn.d(t),t&&e(Xr),t&&e(Ml),C(Vc),t&&e(qi),t&&e(Oh),t&&e(Di),C(Uc,t),t&&e(Ti),C(Xc,t),t&&e(Pi),t&&e(Wr)}}}const tm={local:"phn-loi-token",sections:[{local:"chun-b-d-liu",sections:[{local:"tp-d-liu-conll2003",title:"T\u1EADp d\u1EEF li\u1EC7u CoNLL-2003"},{local:"x-l-d-liu",title:"X\u1EED l\xFD d\u1EEF li\u1EC7u"}],title:"Chu\u1EA9n b\u1ECB d\u1EEF li\u1EC7u"},{local:"tinh-chnh-m-hnh-trong-api-trainer",title:"Tinh ch\u1EC9nh m\xF4 h\xECnh trong API `Trainer`"},{local:"tinh-chnh-m-hnh-vi-keras",sections:[{local:"i-chiu-d-liu",title:"\u0110\u1ED1i chi\u1EBFu d\u1EEF li\u1EC7u"},{local:"nh-ngha-m-hnh",title:"\u0110\u1ECBnh ngh\u0129a m\xF4 h\xECnh"},{local:"tinh-chnh-mt-m-hnh",title:"Tinh ch\u1EC9nh m\u1ED9t m\xF4 h\xECnh"},{local:"thc-o",title:"Th\u01B0\u1EDBc \u0111o"},{local:"nh-ngha-m-hnh",title:"\u0110\u1ECBnh ngh\u0129a m\xF4 h\xECnh"},{local:"tinh-chnh-m-hnh",title:"Tinh ch\u1EC9nh m\xF4 h\xECnh"}],title:"Tinh ch\u1EC9nh m\xF4 h\xECnh v\u1EDBi Keras"},{local:"mt-vng-hun-luyn-tu-chnh",sections:[{local:"chun-b-mi-th-hun-luyn",title:"Chu\u1EA9n b\u1ECB m\u1ECDi th\u1EE9 \u0111\u1EC3 hu\u1EA5n luy\u1EC7n"},{local:"vng-lp-hun-luyn",title:"V\xF2ng l\u1EB7p hu\u1EA5n luy\u1EC7n"}],title:"M\u1ED9t v\xF2ng hu\u1EA5n luy\u1EC7n tu\u1EF3 ch\u1EC9nh"},{local:"s-dng-m-hnh-c-tinh-chnh",title:"S\u1EED d\u1EE5ng m\xF4 h\xECnh \u0111\xE3 \u0111\u01B0\u1EE3c tinh ch\u1EC9nh"}],title:"Ph\xE2n lo\u1EA1i token"};function em(X,m,v){let f="pt";return Pu(()=>{const $=new URLSearchParams(window.location.search);v(0,f=$.get("fw")||"pt")}),[f]}class om extends Ou{constructor(m){super();qu(this,m,em,nm,Du,{})}}export{om as default,tm as metadata};
