import{S as oo,i as io,s as so,e as r,k as l,w as f,t as h,M as lo,c as a,d as e,m as p,x as v,a as o,h as c,b as u,G as n,g as s,y as _,q as y,o as b,B as $,v as po}from"../../chunks/vendor-hf-doc-builder.js";import{T as ao}from"../../chunks/Tip-hf-doc-builder.js";import{Y as mo}from"../../chunks/Youtube-hf-doc-builder.js";import{I as Fr}from"../../chunks/IconCopyLink-hf-doc-builder.js";import{C as N}from"../../chunks/CodeBlock-hf-doc-builder.js";import{C as uo}from"../../chunks/CourseFloatingBanner-hf-doc-builder.js";import{F as go}from"../../chunks/FrameworkSwitchCourse-hf-doc-builder.js";import"../../chunks/DocNotebookDropdown-hf-doc-builder.js";function fo(vt){let m,O,d,j,C,k,T,A,K,tt;return{c(){m=r("p"),O=h("\u{1F4A1} N\u1EBFu b\u1EA1n mu\u1ED1n t\u1EF1 \u0111\u1ED9ng t\u1EA3i m\xF4 h\xECnh c\u1EE7a m\xECnh l\xEAn Hub trong qu\xE1 tr\xECnh hu\u1EA5n luy\u1EC7n, h\xE3y chuy\u1EC3n sang ph\u1EA7n "),d=r("code"),j=h("push_to_hub=True"),C=h(" trong ph\u1EA7n "),k=r("code"),T=h("TrainingArguments"),A=h(". Ch\xFAng ta s\u1EBD t\xECm hi\u1EC3u th\xEAm v\u1EC1 \u0111i\u1EC1u n\xE0y trong "),K=r("a"),tt=h("Ch\u01B0\u01A1ng 4"),this.h()},l(nt){m=a(nt,"P",{});var z=o(m);O=c(z,"\u{1F4A1} N\u1EBFu b\u1EA1n mu\u1ED1n t\u1EF1 \u0111\u1ED9ng t\u1EA3i m\xF4 h\xECnh c\u1EE7a m\xECnh l\xEAn Hub trong qu\xE1 tr\xECnh hu\u1EA5n luy\u1EC7n, h\xE3y chuy\u1EC3n sang ph\u1EA7n "),d=a(z,"CODE",{});var W=o(d);j=c(W,"push_to_hub=True"),W.forEach(e),C=c(z," trong ph\u1EA7n "),k=a(z,"CODE",{});var _t=o(k);T=c(_t,"TrainingArguments"),_t.forEach(e),A=c(z,". Ch\xFAng ta s\u1EBD t\xECm hi\u1EC3u th\xEAm v\u1EC1 \u0111i\u1EC1u n\xE0y trong "),K=a(z,"A",{href:!0});var V=o(K);tt=c(V,"Ch\u01B0\u01A1ng 4"),V.forEach(e),z.forEach(e),this.h()},h(){u(K,"href","/course/chapter4/3")},m(nt,z){s(nt,m,z),n(m,O),n(m,d),n(d,j),n(m,C),n(m,k),n(k,T),n(m,A),n(m,K),n(K,tt)},d(nt){nt&&e(m)}}}function vo(vt){let m,O,d,j,C;return{c(){m=r("p"),O=h("\u270F\uFE0F "),d=r("strong"),j=h("Th\u1EED nghi\u1EC7m th\xF4i!"),C=h(" Tinh ch\u1EC9nh m\xF4 h\xECnh tr\xEAn t\u1EADp d\u1EEF li\u1EC7u GLUE SST-2, s\u1EED d\u1EE5ng qu\xE1 tr\xECnh x\u1EED l\xFD d\u1EEF li\u1EC7u b\u1EA1n \u0111\xE3 th\u1EF1c hi\u1EC7n trong ph\u1EA7n 2.")},l(k){m=a(k,"P",{});var T=o(m);O=c(T,"\u270F\uFE0F "),d=a(T,"STRONG",{});var A=o(d);j=c(A,"Th\u1EED nghi\u1EC7m th\xF4i!"),A.forEach(e),C=c(T," Tinh ch\u1EC9nh m\xF4 h\xECnh tr\xEAn t\u1EADp d\u1EEF li\u1EC7u GLUE SST-2, s\u1EED d\u1EE5ng qu\xE1 tr\xECnh x\u1EED l\xFD d\u1EEF li\u1EC7u b\u1EA1n \u0111\xE3 th\u1EF1c hi\u1EC7n trong ph\u1EA7n 2."),T.forEach(e)},m(k,T){s(k,m,T),n(m,O),n(m,d),n(d,j),n(m,C)},d(k){k&&e(m)}}}function _o(vt){let m,O,d,j,C,k,T,A,K,tt,nt,z,W,_t,V,ae,S,Je,Jt,Xe,Qe,Xt,Ze,th,Qt,nh,eh,yt,hh,ch,oe,Mt,rh,ie,bt,se,et,at,Zt,$t,ah,tn,oh,le,G,ih,nn,sh,lh,en,ph,mh,hn,uh,dh,pe,kt,me,ot,ue,Y,gh,Ut,fh,vh,cn,_h,yh,de,Et,ge,it,bh,Ft,$h,kh,fe,w,Eh,rn,Ch,Th,an,wh,qh,on,Ph,Dh,sn,xh,Oh,ln,jh,Ah,ve,Ct,_e,q,zh,pn,Sh,Nh,mn,Gh,Mh,un,Uh,Fh,dn,Lh,Bh,gn,Hh,Ih,ye,J,Rh,fn,Kh,Wh,vn,Vh,Yh,be,Tt,$e,Lt,Jh,ke,st,x,Xh,_n,Qh,Zh,yn,tc,nc,bn,ec,hc,$n,cc,rc,kn,ac,oc,ic,ht,sc,En,lc,pc,Cn,mc,uc,Ee,ct,lt,Tn,wt,dc,wn,gc,Ce,P,fc,qn,vc,_c,Pn,yc,bc,Dn,$c,kc,xn,Ec,Cc,On,Tc,wc,Te,qt,we,Pt,qe,g,qc,jn,Pc,Dc,An,xc,Oc,zn,jc,Ac,Sn,zc,Sc,Nn,Nc,Gc,Gn,Mc,Uc,Mn,Fc,Lc,Un,Bc,Hc,Pe,M,Ic,Fn,Rc,Kc,Ln,Wc,Vc,Bt,Yc,Jc,De,Dt,xe,D,Xc,Bn,Qc,Zc,Hn,tr,nr,xt,er,hr,In,cr,rr,Rn,ar,or,Oe,Ot,je,jt,Ae,U,ir,At,sr,lr,Kn,pr,mr,Wn,ur,dr,ze,pt,gr,Vn,fr,vr,Se,zt,Ne,X,_r,Yn,yr,br,Jn,$r,kr,Ge,St,Me,F,Er,Xn,Cr,Tr,Qn,wr,qr,Zn,Pr,Dr,Ue,Nt,Fe,Ht,xr,Le,rt,te,Or,jr,ne,Ar,zr,Be,Q,Sr,ee,Nr,Gr,It,Mr,Ur,He,mt,Ie;return d=new go({props:{fw:vt[0]}}),A=new Fr({}),W=new uo({props:{chapter:3,classNames:"absolute z-10 right-0 top-0",notebooks:[{label:"Google Colab",value:"https://colab.research.google.com/github/huggingface/notebooks/blob/master/course/vi/chapter3/section3.ipynb"},{label:"Aws Studio",value:"https://studiolab.sagemaker.aws/import/github/huggingface/notebooks/blob/master/course/vi/chapter3/section3.ipynb"}]}}),V=new mo({props:{id:"nvBXf7s7vTI"}}),bt=new N({props:{code:`from datasets import load_dataset
from transformers import AutoTokenizer, DataCollatorWithPadding

raw_datasets = load_dataset("glue", "mrpc")
checkpoint = "bert-base-uncased"
tokenizer = AutoTokenizer.from_pretrained(checkpoint)


def tokenize_function(example):
    return tokenizer(example["sentence1"], example["sentence2"], truncation=True)


tokenized_datasets = raw_datasets.map(tokenize_function, batched=True)
data_collator = DataCollatorWithPadding(tokenizer=tokenizer)`,highlighted:`<span class="hljs-keyword">from</span> datasets <span class="hljs-keyword">import</span> load_dataset
<span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoTokenizer, DataCollatorWithPadding

raw_datasets = load_dataset(<span class="hljs-string">&quot;glue&quot;</span>, <span class="hljs-string">&quot;mrpc&quot;</span>)
checkpoint = <span class="hljs-string">&quot;bert-base-uncased&quot;</span>
tokenizer = AutoTokenizer.from_pretrained(checkpoint)


<span class="hljs-keyword">def</span> <span class="hljs-title function_">tokenize_function</span>(<span class="hljs-params">example</span>):
    <span class="hljs-keyword">return</span> tokenizer(example[<span class="hljs-string">&quot;sentence1&quot;</span>], example[<span class="hljs-string">&quot;sentence2&quot;</span>], truncation=<span class="hljs-literal">True</span>)


tokenized_datasets = raw_datasets.<span class="hljs-built_in">map</span>(tokenize_function, batched=<span class="hljs-literal">True</span>)
data_collator = DataCollatorWithPadding(tokenizer=tokenizer)`}}),$t=new Fr({}),kt=new N({props:{code:`from transformers import TrainingArguments

training_args = TrainingArguments("test-trainer")`,highlighted:`<span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> TrainingArguments

training_args = TrainingArguments(<span class="hljs-string">&quot;test-trainer&quot;</span>)`}}),ot=new ao({props:{$$slots:{default:[fo]},$$scope:{ctx:vt}}}),Et=new N({props:{code:`from transformers import AutoModelForSequenceClassification

model = AutoModelForSequenceClassification.from_pretrained(checkpoint, num_labels=2)`,highlighted:`<span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoModelForSequenceClassification

model = AutoModelForSequenceClassification.from_pretrained(checkpoint, num_labels=<span class="hljs-number">2</span>)`}}),Ct=new N({props:{code:`from transformers import Trainer

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

trainer = Trainer(
    model,
    training_args,
    train_dataset=tokenized_datasets[<span class="hljs-string">&quot;train&quot;</span>],
    eval_dataset=tokenized_datasets[<span class="hljs-string">&quot;validation&quot;</span>],
    data_collator=data_collator,
    tokenizer=tokenizer,
)`}}),Tt=new N({props:{code:"trainer.train()",highlighted:"trainer.train()"}}),wt=new Fr({}),qt=new N({props:{code:`predictions = trainer.predict(tokenized_datasets["validation"])
print(predictions.predictions.shape, predictions.label_ids.shape)`,highlighted:`predictions = trainer.predict(tokenized_datasets[<span class="hljs-string">&quot;validation&quot;</span>])
<span class="hljs-built_in">print</span>(predictions.predictions.shape, predictions.label_ids.shape)`}}),Pt=new N({props:{code:"(408, 2) (408,)",highlighted:'(<span class="hljs-number">408</span>, <span class="hljs-number">2</span>) (<span class="hljs-number">408</span>,)'}}),Dt=new N({props:{code:`import numpy as np

preds = np.argmax(predictions.predictions, axis=-1)`,highlighted:`<span class="hljs-keyword">import</span> numpy <span class="hljs-keyword">as</span> np

preds = np.argmax(predictions.predictions, axis=-<span class="hljs-number">1</span>)`}}),Ot=new N({props:{code:`import evaluate

metric = evaluate.load("glue", "mrpc")
metric.compute(predictions=preds, references=predictions.label_ids)`,highlighted:`<span class="hljs-keyword">import</span> evaluate

metric = evaluate.load(<span class="hljs-string">&quot;glue&quot;</span>, <span class="hljs-string">&quot;mrpc&quot;</span>)
metric.compute(predictions=preds, references=predictions.label_ids)`}}),jt=new N({props:{code:"{'accuracy': 0.8578431372549019, 'f1': 0.8996539792387542}",highlighted:'{<span class="hljs-string">&#x27;accuracy&#x27;</span>: <span class="hljs-number">0.8578431372549019</span>, <span class="hljs-string">&#x27;f1&#x27;</span>: <span class="hljs-number">0.8996539792387542</span>}'}}),zt=new N({props:{code:`def compute_metrics(eval_preds):
    metric = evaluate.load("glue", "mrpc")
    logits, labels = eval_preds
    predictions = np.argmax(logits, axis=-1)
    return metric.compute(predictions=predictions, references=labels)`,highlighted:`<span class="hljs-keyword">def</span> <span class="hljs-title function_">compute_metrics</span>(<span class="hljs-params">eval_preds</span>):
    metric = evaluate.load(<span class="hljs-string">&quot;glue&quot;</span>, <span class="hljs-string">&quot;mrpc&quot;</span>)
    logits, labels = eval_preds
    predictions = np.argmax(logits, axis=-<span class="hljs-number">1</span>)
    <span class="hljs-keyword">return</span> metric.compute(predictions=predictions, references=labels)`}}),St=new N({props:{code:`training_args = TrainingArguments("test-trainer", evaluation_strategy="epoch")
model = AutoModelForSequenceClassification.from_pretrained(checkpoint, num_labels=2)

trainer = Trainer(
    model,
    training_args,
    train_dataset=tokenized_datasets["train"],
    eval_dataset=tokenized_datasets["validation"],
    data_collator=data_collator,
    tokenizer=tokenizer,
    compute_metrics=compute_metrics,
)`,highlighted:`training_args = TrainingArguments(<span class="hljs-string">&quot;test-trainer&quot;</span>, evaluation_strategy=<span class="hljs-string">&quot;epoch&quot;</span>)
model = AutoModelForSequenceClassification.from_pretrained(checkpoint, num_labels=<span class="hljs-number">2</span>)

trainer = Trainer(
    model,
    training_args,
    train_dataset=tokenized_datasets[<span class="hljs-string">&quot;train&quot;</span>],
    eval_dataset=tokenized_datasets[<span class="hljs-string">&quot;validation&quot;</span>],
    data_collator=data_collator,
    tokenizer=tokenizer,
    compute_metrics=compute_metrics,
)`}}),Nt=new N({props:{code:"trainer.train()",highlighted:'trainer.trai<span class="hljs-meta">n</span>()'}}),mt=new ao({props:{$$slots:{default:[vo]},$$scope:{ctx:vt}}}),{c(){m=r("meta"),O=l(),f(d.$$.fragment),j=l(),C=r("h1"),k=r("a"),T=r("span"),f(A.$$.fragment),K=l(),tt=r("span"),nt=h("Tinh ch\u1EC9nh m\u1ED9t m\xF4 h\xECnh v\u1EDBi Trainer API"),z=l(),f(W.$$.fragment),_t=l(),f(V.$$.fragment),ae=l(),S=r("p"),Je=h("\u{1F917} Transformers cung c\u1EA5p l\u1EDBp "),Jt=r("code"),Xe=h("Trainer"),Qe=h(" \u0111\u1EC3 gi\xFAp b\u1EA1n tinh ch\u1EC9nh b\u1EA5t k\u1EF3 m\xF4 h\xECnh hu\u1EA5n luy\u1EC7n tr\u01B0\u1EDBc n\xE0o m\xE0 n\xF3 cung c\u1EA5p tr\xEAn t\u1EADp d\u1EEF li\u1EC7u c\u1EE7a b\u1EA1n. Khi b\u1EA1n \u0111\xE3 ho\xE0n th\xE0nh t\u1EA5t c\u1EA3 c\xF4ng vi\u1EC7c ti\u1EC1n x\u1EED l\xFD d\u1EEF li\u1EC7u trong ph\u1EA7n cu\u1ED1i c\xF9ng, b\u1EA1n ch\u1EC9 c\xF2n m\u1ED9t v\xE0i b\u01B0\u1EDBc \u0111\u1EC3 \u0111\u1ECBnh ngh\u0129a "),Xt=r("code"),Ze=h("Trainer"),th=h(". Ph\u1EA7n kh\xF3 nh\u1EA5t c\xF3 th\u1EC3 l\xE0 chu\u1EA9n b\u1ECB m\xF4i tr\u01B0\u1EDDng \u0111\u1EC3 ch\u1EA1y "),Qt=r("code"),nh=h("Trainer.train()"),eh=h(", v\xEC n\xF3 s\u1EBD ch\u1EA1y r\u1EA5t ch\u1EADm tr\xEAn CPU. N\u1EBFu b\u1EA1n ch\u01B0a thi\u1EBFt l\u1EADp GPU, b\u1EA1n c\xF3 th\u1EC3 c\xF3 quy\u1EC1n truy c\u1EADp v\xE0o GPU ho\u1EB7c TPU mi\u1EC5n ph\xED tr\xEAn "),yt=r("a"),hh=h("Google Colab"),ch=h("."),oe=l(),Mt=r("p"),rh=h("C\xE1c v\xED d\u1EE5 m\xE3 b\xEAn d\u01B0\u1EDBi gi\u1EA3 s\u1EED b\u1EA1n \u0111\xE3 th\u1EF1c hi\u1EC7n c\xE1c v\xED d\u1EE5 trong ph\u1EA7n tr\u01B0\u1EDBc. D\u01B0\u1EDBi \u0111\xE2y l\xE0 m\u1ED9t b\u1EA3n t\xF3m t\u1EAFt ng\u1EAFn t\xF3m t\u1EAFt l\u1EA1i nh\u1EEFng g\xEC b\u1EA1n c\u1EA7n:"),ie=l(),f(bt.$$.fragment),se=l(),et=r("h3"),at=r("a"),Zt=r("span"),f($t.$$.fragment),ah=l(),tn=r("span"),oh=h("Hu\u1EA5n luy\u1EC7n"),le=l(),G=r("p"),ih=h("B\u01B0\u1EDBc \u0111\u1EA7u ti\xEAn tr\u01B0\u1EDBc khi ch\xFAng ta c\xF3 th\u1EC3 \u0111\u1ECBnh ngh\u0129a "),nn=r("code"),sh=h("Trainer"),lh=h(" c\u1EE7a m\xECnh l\xE0 \u0111\u1ECBnh ngh\u0129a m\u1ED9t l\u1EDBp "),en=r("code"),ph=h("TrainingArguments"),mh=h(" s\u1EBD ch\u1EE9a t\u1EA5t c\u1EA3 c\xE1c si\xEAu tham s\u1ED1 m\xE0 "),hn=r("code"),uh=h("Trainer"),dh=h(" s\u1EBD s\u1EED d\u1EE5ng \u0111\u1EC3 hu\u1EA5n luy\u1EC7n v\xE0 \u0111\xE1nh gi\xE1. Tham s\u1ED1 duy nh\u1EA5t b\u1EA1n ph\u1EA3i cung c\u1EA5p l\xE0 m\u1ED9t th\u01B0 m\u1EE5c n\u01A1i m\xF4 h\xECnh \u0111\u01B0\u1EE3c hu\u1EA5n luy\u1EC7n s\u1EBD \u0111\u01B0\u1EE3c l\u01B0u, c\u0169ng nh\u01B0 c\xE1c checkpoint \u0111i k\xE8m. \u0110\u1ED1i v\u1EDBi t\u1EA5t c\u1EA3 ph\u1EA7n c\xF2n l\u1EA1i, b\u1EA1n c\xF3 th\u1EC3 \u0111\u1EC3 m\u1EB7c \u0111\u1ECBnh, n\xF3 s\u1EBD ho\u1EA1t \u0111\u1ED9ng kh\xE1 t\u1ED1t v\u1EDBi tinh ch\u1EC9nh c\u01A1 b\u1EA3n."),pe=l(),f(kt.$$.fragment),me=l(),f(ot.$$.fragment),ue=l(),Y=r("p"),gh=h("B\u01B0\u1EDBc th\u1EE9 hai l\xE0 x\xE1c \u0111\u1ECBnh m\xF4 h\xECnh c\u1EE7a ch\xFAng ta. Nh\u01B0 trong "),Ut=r("a"),fh=h("ch\u01B0\u01A1ng tr\u01B0\u1EDBc"),vh=h(", ch\xFAng ta s\u1EBD s\u1EED d\u1EE5ng l\u1EDBp "),cn=r("code"),_h=h("AutoModelForSequenceClassification"),yh=h(", v\u1EDBi hai nh\xE3n:"),de=l(),f(Et.$$.fragment),ge=l(),it=r("p"),bh=h("B\u1EA1n s\u1EBD nh\u1EADn th\u1EA5y r\u1EB1ng kh\xF4ng nh\u01B0 trong "),Ft=r("a"),$h=h("Ch\u01B0\u01A1ng 2"),kh=h(", b\u1EA1n nh\u1EADn \u0111\u01B0\u1EE3c m\u1ED9t c\u1EA3nh b\xE1o sau khi kh\u1EDFi t\u1EA1o m\xF4 h\xECnh \u0111\u01B0\u1EE3c hu\u1EA5n luy\u1EC7n tr\u01B0\u1EDBc n\xE0y. \u0110\xE2y l\xE0 do BERT ch\u01B0a \u0111\u01B0\u1EE3c hu\u1EA5n luy\u1EC7n tr\u01B0\u1EDBc v\u1EC1 ph\xE2n lo\u1EA1i c\xE1c c\u1EB7p c\xE2u, v\xEC v\u1EADy ph\u1EA7n \u0111\u1EA7u c\u1EE7a m\xF4 h\xECnh \u0111\u01B0\u1EE3c hu\u1EA5n luy\u1EC7n tr\u01B0\u1EDBc \u0111\xE3 b\u1ECB lo\u1EA1i b\u1ECF v\xE0 ph\u1EA7n \u0111\u1EA7u m\u1EDBi ph\xF9 h\u1EE3p \u0111\u1EC3 ph\xE2n lo\u1EA1i chu\u1ED7i \u0111\xE3 \u0111\u01B0\u1EE3c ch\xE8n v\xE0o thay th\u1EBF. C\xE1c c\u1EA3nh b\xE1o ch\u1EC9 ra r\u1EB1ng m\u1ED9t s\u1ED1 tr\u1ECDng s\u1ED1 \u0111\xE3 kh\xF4ng \u0111\u01B0\u1EE3c s\u1EED d\u1EE5ng (nh\u1EEFng tr\u1ECDng s\u1ED1 t\u01B0\u01A1ng \u1EE9ng v\u1EDBi \u0111\u1EA7u hu\u1EA5n luy\u1EC7n tr\u01B0\u1EDBc b\u1ECB r\u1EE5ng) v\xE0 m\u1ED9t s\u1ED1 tr\u1ECDng s\u1ED1 kh\xE1c kh\xE1c \u0111\u01B0\u1EE3c kh\u1EDFi t\u1EA1o ng\u1EABu nhi\xEAn (nh\u1EEFng tr\u1ECDng s\u1ED1 d\xE0nh cho \u0111\u1EA7u m\u1EDBi). N\xF3 k\u1EBFt th\xFAc b\u1EB1ng c\xE1ch khuy\u1EBFn kh\xEDch b\u1EA1n hu\u1EA5n luy\u1EC7n m\xF4 h\xECnh, \u0111\xF3 ch\xEDnh x\xE1c l\xE0 nh\u1EEFng g\xEC ch\xFAng ta s\u1EBD l\xE0m b\xE2y gi\u1EDD."),fe=l(),w=r("p"),Eh=h("Khi ch\xFAng ta c\xF3 m\xF4 h\xECnh c\u1EE7a m\xECnh, ch\xFAng ta c\xF3 th\u1EC3 x\xE1c \u0111\u1ECBnh m\u1ED9t "),rn=r("code"),Ch=h("Trainer"),Th=h(" b\u1EB1ng c\xE1ch truy\u1EC1n v\xE0o t\u1EA5t c\u1EA3 c\xE1c \u0111\u1ED1i t\u01B0\u1EE3ng \u0111\u01B0\u1EE3c x\xE2y d\u1EF1ng t\u1EEB tr\u01B0\u1EDBc \u0111\u1EBFn nay - "),an=r("code"),wh=h("model"),qh=h(", "),on=r("code"),Ph=h("training_args"),Dh=h(", t\u1EADp hu\u1EA5n luy\u1EC7n v\xE0 ki\u1EC3m \u0111\u1ECBnh,"),sn=r("code"),xh=h("data_collator"),Oh=h(" v\xE0 "),ln=r("code"),jh=h("tokenizer"),Ah=h(":"),ve=l(),f(Ct.$$.fragment),_e=l(),q=r("p"),zh=h("L\u01B0u \xFD r\u1EB1ng khi b\u1EA1n truy\u1EC1n "),pn=r("code"),Sh=h("tokenizer"),Nh=h(" nh\u01B0 ch\xFAng ta \u0111\xE3 l\xE0m \u1EDF \u0111\xE2y, m\u1EB7c \u0111\u1ECBnh "),mn=r("code"),Gh=h("data_collator"),Mh=h(" \u0111\u01B0\u1EE3c s\u1EED d\u1EE5ng b\u1EDFi "),un=r("code"),Uh=h("Trainer"),Fh=h(" s\u1EBD l\xE0 "),dn=r("code"),Lh=h("DataCollatorWithPadding"),Bh=h(" nh\u01B0 \u0111\xE3 \u0111\u1ECBnh ngh\u0129a tr\u01B0\u1EDBc \u0111\xF3, v\xEC v\u1EADy b\u1EA1n c\xF3 th\u1EC3 b\u1ECF qua d\xF2ng "),gn=r("code"),Hh=h("data_collator = data_collator"),Ih=h(" trong l\u1EC7nh g\u1ECDi n\xE0y. \u0110i\u1EC1u quan tr\u1ECDng l\xE0 ph\u1EA3i cho b\u1EA1n th\u1EA5y ph\u1EA7n n\xE0y c\u1EE7a qu\xE1 tr\xECnh trong ph\u1EA7n 2!"),ye=l(),J=r("p"),Rh=h("\u0110\u1EC3 tinh ch\u1EC9nh m\xF4 h\xECnh tr\xEAn t\u1EADp d\u1EEF li\u1EC7u, ch\xFAng ta ch\u1EC9 c\u1EA7n g\u1ECDi ph\u01B0\u01A1ng th\u1EE9c "),fn=r("code"),Kh=h("train()"),Wh=h(" c\u1EE7a "),vn=r("code"),Vh=h("Trainer"),Yh=h(":"),be=l(),f(Tt.$$.fragment),$e=l(),Lt=r("p"),Jh=h("Thao t\xE1c n\xE0y s\u1EBD b\u1EAFt \u0111\u1EA7u qu\xE1 tr\xECnh tinh ch\u1EC9nh (s\u1EBD m\u1EA5t v\xE0i ph\xFAt tr\xEAn GPU) v\xE0 b\xE1o c\xE1o l\u1ED7i \u0111\xE0o t\u1EA1o sau m\u1ED7i 500 b\u01B0\u1EDBc. Tuy nhi\xEAn, n\xF3 s\u1EBD kh\xF4ng cho b\u1EA1n bi\u1EBFt m\xF4 h\xECnh c\u1EE7a b\u1EA1n \u0111ang ho\u1EA1t \u0111\u1ED9ng t\u1ED1t (ho\u1EB7c t\u1ED3i t\u1EC7 nh\u01B0 th\u1EBF n\xE0o). \u0110i\u1EC1u n\xE0y l\xE0 do:"),ke=l(),st=r("ol"),x=r("li"),Xh=h("Ch\xFAng ta \u0111\xE3 kh\xF4ng y\xEAu c\u1EA7u "),_n=r("code"),Qh=h("Trainer"),Zh=h(" \u0111\xE1nh gi\xE1 trong qu\xE1 tr\xECnh hu\u1EA5n luy\u1EC7n b\u1EB1ng c\xE1ch c\xE0i \u0111\u1EB7t "),yn=r("code"),tc=h("eval_strategy"),nc=h(" th\xE0nh "),bn=r("code"),ec=h('"steps"'),hc=h(" (\u0111\xE1nh gi\xE1 m\u1ECDi "),$n=r("code"),cc=h("eval_steps"),rc=h(") ho\u1EB7c "),kn=r("code"),ac=h('"epoch"'),oc=h(" (\u0111\xE1nh gi\xE1 v\xE0o cu\u1ED1i m\u1ED7i epoch)."),ic=l(),ht=r("li"),sc=h("Ch\xFAng ta \u0111\xE3 kh\xF4ng cung c\u1EA5p cho "),En=r("code"),lc=h("Trainer"),pc=h(" m\u1ED9t h\xE0m "),Cn=r("code"),mc=h("compute_metrics()"),uc=h(" \u0111\u1EC3 t\xEDnh to\xE1n ch\u1EC9 s\u1ED1 trong qu\xE1 tr\xECnh \u0111\xE1nh gi\xE1 n\xF3i tr\xEAn (n\u1EBFu kh\xF4ng, \u0111\xE1nh gi\xE1 s\u1EBD ch\u1EC9 in ra l\u1ED7, \u0111\xE2y kh\xF4ng ph\u1EA3i l\xE0 m\u1ED9t ch\u1EC9 s\u1ED1 tr\u1EF1c quan cho l\u1EAFm)."),Ee=l(),ct=r("h3"),lt=r("a"),Tn=r("span"),f(wt.$$.fragment),dc=l(),wn=r("span"),gc=h("\u0110\xE1nh gi\xE1"),Ce=l(),P=r("p"),fc=h("H\xE3y xem c\xE1ch ch\xFAng ta c\xF3 th\u1EC3 x\xE2y d\u1EF1ng m\u1ED9t h\xE0m "),qn=r("code"),vc=h("compute_metrics()"),_c=h(" h\u1EEFu \xEDch v\xE0 s\u1EED d\u1EE5ng n\xF3 trong l\u1EA7n hu\u1EA5n luy\u1EC7n ti\u1EBFp theo. H\xE0m ph\u1EA3i nh\u1EADn m\u1ED9t \u0111\u1ED1i t\u01B0\u1EE3ng "),Pn=r("code"),yc=h("EvalPrediction"),bc=h(" (l\xE0 m\u1ED9t tuple \u0111\u01B0\u1EE3c \u0111\u1EB7t t\xEAn v\u1EDBi tr\u01B0\u1EDDng "),Dn=r("code"),$c=h("predictions"),kc=h(" v\xE0 tr\u01B0\u1EDDng "),xn=r("code"),Ec=h("label_ids"),Cc=h(") v\xE0 s\u1EBD tr\u1EA3 v\u1EC1 m\u1ED9t chu\u1ED7i \xE1nh x\u1EA1 t\u1EEB th\xE0nh s\u1ED1 th\u1EF1c (c\xE1c chu\u1ED7i l\xE0 t\xEAn c\u1EE7a c\xE1c ch\u1EC9 s\u1ED1 \u0111\u01B0\u1EE3c tr\u1EA3 v\u1EC1 v\xE0 c\xE1c gi\xE1 tr\u1ECB c\u1EE7a ch\xFAng \xE9p v\u1EC1 ki\u1EC3u s\u1ED1 th\u1EF1c). \u0110\u1EC3 nh\u1EADn \u0111\u01B0\u1EE3c d\u1EF1 \u0111o\xE1n t\u1EEB m\xF4 h\xECnh, ch\xFAng ta c\xF3 th\u1EC3 s\u1EED d\u1EE5ng l\u1EC7nh "),On=r("code"),Tc=h("Trainer.predict()"),wc=h(":"),Te=l(),f(qt.$$.fragment),we=l(),f(Pt.$$.fragment),qe=l(),g=r("p"),qc=h("\u0110\u1EA7u ra c\u1EE7a ph\u01B0\u01A1ng th\u1EE9c "),jn=r("code"),Pc=h("predict()"),Dc=h(" l\xE0 m\u1ED9t tuple c\xF3 t\xEAn kh\xE1c v\u1EDBi ba tr\u01B0\u1EDDng: "),An=r("code"),xc=h("predictions"),Oc=h(", "),zn=r("code"),jc=h("label_ids"),Ac=h(", v\xE0 "),Sn=r("code"),zc=h("metrics"),Sc=h(". Tr\u01B0\u1EDDng "),Nn=r("code"),Nc=h("metrics"),Gc=h(" s\u1EBD ch\u1EC9 ch\u1EE9a s\u1EF1 m\u1EA5t m\xE1t tr\xEAn t\u1EADp d\u1EEF li\u1EC7u \u0111\xE3 truy\u1EC1n v\xE0o, c\u0169ng nh\u01B0 m\u1ED9t s\u1ED1 ch\u1EC9 s\u1ED1 th\u1EDDi gian (t\u1ED5ng c\u1ED9ng v\xE0 trung b\xECnh m\u1EA5t bao l\xE2u \u0111\u1EC3 d\u1EF1 \u0111o\xE1n). Sau khi ch\xFAng ta ho\xE0n th\xE0nh h\xE0m "),Gn=r("code"),Mc=h("compute_metrics()"),Uc=h(" v\xE0 truy\u1EC1n n\xF3 v\xE0o "),Mn=r("code"),Fc=h("Trainer"),Lc=h(", tr\u01B0\u1EDDng \u0111\xF3 c\u0169ng s\u1EBD ch\u1EE9a c\xE1c ch\u1EC9 s\u1ED1 \u0111\u01B0\u1EE3c tr\u1EA3 v\u1EC1 b\u1EDFi"),Un=r("code"),Bc=h("compute_metrics()"),Hc=h("."),Pe=l(),M=r("p"),Ic=h("Nh\u01B0 b\u1EA1n c\xF3 th\u1EC3 th\u1EA5y, "),Fn=r("code"),Rc=h("predictions"),Kc=h(" l\xE0 m\u1ED9t m\u1EA3ng hai chi\u1EC1u c\xF3 h\xECnh d\u1EA1ng 408 x 2 (408 l\xE0 s\u1ED1 ph\u1EA7n t\u1EED trong t\u1EADp d\u1EEF li\u1EC7u ta \u0111\xE3 s\u1EED d\u1EE5ng). \u0110\xF3 l\xE0 c\xE1c logit cho t\u1EEBng ph\u1EA7n t\u1EED c\u1EE7a t\u1EADp d\u1EEF li\u1EC7u m\xE0 ch\xFAng ta \u0111\xE3 truy\u1EC1n v\xE0o cho"),Ln=r("code"),Wc=h("predict()"),Vc=h(" ( nh\u01B0 b\u1EA1n \u0111\xE3 th\u1EA5y trong "),Bt=r("a"),Yc=h("ch\u01B0\u01A1ng tr\u01B0\u1EDBc"),Jc=h(", t\u1EA5t c\u1EA3 c\xE1c m\xF4 h\xECnh Transformer \u0111\u1EC1u tr\u1EA3 v\u1EC1 logit). \u0110\u1EC3 chuy\u1EC3n \u0111\u1ED5i ch\xFAng th\xE0nh c\xE1c d\u1EF1 \u0111o\xE1n m\xE0 ch\xFAng ta c\xF3 th\u1EC3 so s\xE1nh v\u1EDBi c\xE1c nh\xE3n c\u1EE7a m\xECnh, ch\xFAng ta c\u1EA7n l\u1EA5y ch\u1EC9 s\u1ED1 c\xF3 gi\xE1 tr\u1ECB l\u1EDBn nh\u1EA5t tr\xEAn tr\u1EE5c th\u1EE9 hai:"),De=l(),f(Dt.$$.fragment),xe=l(),D=r("p"),Xc=h("Gi\u1EDD ch\xFAng ta c\xF3 th\u1EC3 so s\xE1nh c\xE1c "),Bn=r("code"),Qc=h("preds"),Zc=h(" \u0111\xF3 v\u1EDBi c\xE1c nh\xE3n. \u0110\u1EC3 x\xE2y d\u1EF1ng h\xE0m "),Hn=r("code"),tr=h("compute_metric()"),nr=h(", ch\xFAng ta s\u1EBD d\u1EF1a v\xE0o c\xE1c ch\u1EC9 s\u1ED1 t\u1EEB th\u01B0 vi\u1EC7n \u{1F917} "),xt=r("a"),er=h("\u0110\xE1nh gi\xE1"),hr=h(". Ch\xFAng ta c\xF3 th\u1EC3 t\u1EA3i c\xE1c ch\u1EC9 s\u1ED1 \u0111\u01B0\u1EE3c li\xEAn k\u1EBFt v\u1EDBi t\u1EADp d\u1EEF li\u1EC7u MRPC d\u1EC5 d\xE0ng nh\u01B0 khi ch\xFAng ta t\u1EA3i t\u1EADp d\u1EEF li\u1EC7u, l\u1EA7n n\xE0y l\xE0 v\u1EDBi h\xE0m "),In=r("code"),cr=h("evaluate.load()"),rr=h(". \u0110\u1ED1i t\u01B0\u1EE3ng \u0111\u01B0\u1EE3c tr\u1EA3 v\u1EC1 c\xF3 ph\u01B0\u01A1ng th\u1EE9c "),Rn=r("code"),ar=h("compute()"),or=h(" m\xE0 ch\xFAng ta c\xF3 th\u1EC3 s\u1EED d\u1EE5ng \u0111\u1EC3 th\u1EF1c hi\u1EC7n t\xEDnh to\xE1n s\u1ED1 li\u1EC7u:"),Oe=l(),f(Ot.$$.fragment),je=l(),f(jt.$$.fragment),Ae=l(),U=r("p"),ir=h("K\u1EBFt qu\u1EA3 ch\xEDnh x\xE1c b\u1EA1n nh\u1EADn \u0111\u01B0\u1EE3c c\xF3 th\u1EC3 kh\xE1c nhau, v\xEC vi\u1EC7c kh\u1EDFi t\u1EA1o ng\u1EABu nhi\xEAn ph\u1EA7n \u0111\u1EA7u m\xF4 h\xECnh c\xF3 th\u1EC3 thay \u0111\u1ED5i c\xE1c ch\u1EC9 s\u1ED1 m\xE0 n\xF3 \u0111\u1EA1t \u0111\u01B0\u1EE3c. \u1EDE \u0111\xE2y, ch\xFAng ta c\xF3 th\u1EC3 th\u1EA5y m\xF4 h\xECnh c\xF3 \u0111\u1ED9 ch\xEDnh x\xE1c 85.78% tr\xEAn t\u1EADp ki\u1EC3m \u0111\u1ECBnh v\xE0 \u0111i\u1EC3m F1 l\xE0 89.97. \u0110\xF3 l\xE0 hai ch\u1EC9 s\u1ED1 \u0111\u01B0\u1EE3c s\u1EED d\u1EE5ng \u0111\u1EC3 \u0111\xE1nh gi\xE1 k\u1EBFt qu\u1EA3 tr\xEAn t\u1EADp d\u1EEF li\u1EC7u MRPC theo \u0111i\u1EC3m chu\u1EA9n GLUE. B\u1EA3ng trong "),At=r("a"),sr=h("b\xE0i b\xE1o BERT"),lr=h(" b\xE1o c\xE1o \u0111i\u1EC3m F1 l\xE0 88.9 cho m\xF4 h\xECnh c\u01A1 s\u1EDF. \u0110\xF3 l\xE0 m\xF4 h\xECnh "),Kn=r("code"),pr=h("kh\xF4ng ph\xE2n bi\u1EC7t"),mr=h(" vi\u1EBFt hoa vi\u1EBFt th\u01B0\u1EDDng trong khi ch\xFAng ta hi\u1EC7n \u0111ang s\u1EED d\u1EE5ng m\xF4 h\xECnh "),Wn=r("code"),ur=h("c\xF3 ph\xE2n bi\u1EC7t"),dr=h(", \u0111i\u1EC1u n\xE0y gi\u1EA3i th\xEDch k\u1EBFt qu\u1EA3 t\u1ED1t h\u01A1n."),ze=l(),pt=r("p"),gr=h("K\u1EBFt h\u1EE3p m\u1ECDi th\u1EE9 l\u1EA1i v\u1EDBi nhau, ch\xFAng ta nh\u1EADn \u0111\u01B0\u1EE3c h\xE0m "),Vn=r("code"),fr=h("compute_metrics()"),vr=h(":"),Se=l(),f(zt.$$.fragment),Ne=l(),X=r("p"),_r=h("V\xE0 \u0111\u1EC3 xem n\xF3 \u0111\u01B0\u1EE3c s\u1EED d\u1EE5ng trong th\u1EF1c ti\u1EC5n \u0111\u1EC3 b\xE1o c\xE1o c\xE1c ch\u1EC9 s\u1ED1 \u1EDF cu\u1ED1i m\u1ED7i epoch nh\u01B0 th\u1EBF n\xE0o, \u0111\xE2y l\xE0 c\xE1ch ch\xFAng t\xF4i \u0111\u1ECBnh ngh\u0129a m\u1ED9t "),Yn=r("code"),yr=h("Trainer"),br=h(" m\u1EDBi v\u1EDBi h\xE0m "),Jn=r("code"),$r=h("compute_metrics()"),kr=h(" n\xE0y:"),Ge=l(),f(St.$$.fragment),Me=l(),F=r("p"),Er=h("L\u01B0u \xFD r\u1EB1ng ch\xFAng ta t\u1EA1o m\u1ED9t "),Xn=r("code"),Cr=h("TrainingArguments"),Tr=h(" m\u1EDBi v\u1EDBi "),Qn=r("code"),wr=h("eval_strategy"),qr=h(" c\u1EE7a n\xF3 \u0111\u01B0\u1EE3c \u0111\u1EB7t th\xE0nh "),Zn=r("code"),Pr=h('"epoch"'),Dr=h(" v\xE0 m\u1ED9t m\xF4 h\xECnh m\u1EDBi - n\u1EBFu kh\xF4ng, ch\xFAng ta s\u1EBD ti\u1EBFp t\u1EE5c hu\u1EA5n luy\u1EC7n m\xF4 h\xECnh ta \u0111\xE3 hu\u1EA5n luy\u1EC7n. \u0110\u1EC3 kh\u1EDFi ch\u1EA1y m\u1ED9t \u0111\u1EE3t hu\u1EA5n luy\u1EC7n m\u1EDBi, ch\xFAng ta th\u1EF1c hi\u1EC7n:"),Ue=l(),f(Nt.$$.fragment),Fe=l(),Ht=r("p"),xr=h("L\u1EA7n n\xE0y, n\xF3 s\u1EBD b\xE1o c\xE1o th\xF4ng s\u1ED1 m\u1EA5t m\xE1t ki\u1EC3m \u0111\u1ECBnh v\xE0 ch\u1EC9 s\u1ED1 \u1EDF cu\u1ED1i m\u1ED7i epoch \xEAn c\u1EA1nh th\xF4ng s\u1ED1 m\u1EA5t m\xE1t tr\xEAn t\u1EADp hu\u1EA5n luy\u1EC7n. M\u1ED9t l\u1EA7n n\u1EEFa, \u0111\u1ED9 ch\xEDnh x\xE1c tuy\u1EC7t \u0111\u1ED1i/\u0111i\u1EC3m F1 m\xE0 b\u1EA1n \u0111\u1EA1t \u0111\u01B0\u1EE3c c\xF3 th\u1EC3 h\u01A1i kh\xE1c so v\u1EDBi nh\u1EEFng g\xEC ch\xFAng t\xF4i t\xECm th\u1EA5y, do vi\u1EC7c kh\u1EDFi t\u1EA1o \u0111\u1EA7u ng\u1EABu nhi\xEAn c\u1EE7a m\xF4 h\xECnh, nh\u01B0ng n\xF3 ph\u1EA3i \u1EDF trong c\xF9ng m\u1ED9t kho\u1EA3ng."),Le=l(),rt=r("p"),te=r("code"),Or=h("Trainer"),jr=h(" s\u1EBD ho\u1EA1t \u0111\u1ED9ng hi\u1EC7u qu\u1EA3 tr\xEAn nhi\u1EC1u GPU ho\u1EB7c TPU v\xE0 cung c\u1EA5p nhi\u1EC1u t\xF9y ch\u1ECDn, ch\u1EB3ng h\u1EA1n nh\u01B0 hu\u1EA5n luy\u1EC7n v\u1EC1 \u0111\u1ED9 ch\xEDnh x\xE1c h\u1ED7n h\u1EE3p (s\u1EED d\u1EE5ng "),ne=r("code"),Ar=h("fp16=True"),zr=h(" trong tham s\u1ED1 hu\u1EA5n luy\u1EC7n c\u1EE7a b\u1EA1n). Ch\xFAng ta s\u1EBD xem x\xE9t m\u1ECDi th\u1EE9 m\xE0 n\xF3 h\u1ED7 tr\u1EE3 trong Ch\u01B0\u01A1ng 10."),Be=l(),Q=r("p"),Sr=h("Ph\u1EA7n n\xE0y k\u1EBFt th\xFAc ph\u1EA7n gi\u1EDBi thi\u1EC7u v\u1EC1 c\xE1ch tinh ch\u1EC9nh b\u1EB1ng API "),ee=r("code"),Nr=h("Trainer"),Gr=h(". M\u1ED9t v\xED d\u1EE5 v\u1EC1 vi\u1EC7c th\u1EF1c hi\u1EC7n \u0111i\u1EC1u n\xE0y \u0111\u1ED1i v\u1EDBi h\u1EA7u h\u1EBFt c\xE1c t\xE1c v\u1EE5 NLP ph\u1ED5 bi\u1EBFn s\u1EBD \u0111\u01B0\u1EE3c \u0111\u01B0a ra trong "),It=r("a"),Mr=h("Ch\u01B0\u01A1ng 7"),Ur=h(", nh\u01B0ng \u1EDF th\u1EDDi \u0111i\u1EC3m n\xE0y ch\xFAng ta h\xE3y xem c\xE1ch th\u1EF1c hi\u1EC7n \u0111i\u1EC1u t\u01B0\u01A1ng t\u1EF1 trong PyTorch thu\u1EA7n t\xFAy."),He=l(),f(mt.$$.fragment),this.h()},l(t){const i=lo('[data-svelte="svelte-1phssyn"]',document.head);m=a(i,"META",{name:!0,content:!0}),i.forEach(e),O=p(t),v(d.$$.fragment,t),j=p(t),C=a(t,"H1",{class:!0});var Gt=o(C);k=a(Gt,"A",{id:!0,class:!0,href:!0});var he=o(k);T=a(he,"SPAN",{});var ce=o(T);v(A.$$.fragment,ce),ce.forEach(e),he.forEach(e),K=p(Gt),tt=a(Gt,"SPAN",{});var Lr=o(tt);nt=c(Lr,"Tinh ch\u1EC9nh m\u1ED9t m\xF4 h\xECnh v\u1EDBi Trainer API"),Lr.forEach(e),Gt.forEach(e),z=p(t),v(W.$$.fragment,t),_t=p(t),v(V.$$.fragment,t),ae=p(t),S=a(t,"P",{});var Z=o(S);Je=c(Z,"\u{1F917} Transformers cung c\u1EA5p l\u1EDBp "),Jt=a(Z,"CODE",{});var Br=o(Jt);Xe=c(Br,"Trainer"),Br.forEach(e),Qe=c(Z," \u0111\u1EC3 gi\xFAp b\u1EA1n tinh ch\u1EC9nh b\u1EA5t k\u1EF3 m\xF4 h\xECnh hu\u1EA5n luy\u1EC7n tr\u01B0\u1EDBc n\xE0o m\xE0 n\xF3 cung c\u1EA5p tr\xEAn t\u1EADp d\u1EEF li\u1EC7u c\u1EE7a b\u1EA1n. Khi b\u1EA1n \u0111\xE3 ho\xE0n th\xE0nh t\u1EA5t c\u1EA3 c\xF4ng vi\u1EC7c ti\u1EC1n x\u1EED l\xFD d\u1EEF li\u1EC7u trong ph\u1EA7n cu\u1ED1i c\xF9ng, b\u1EA1n ch\u1EC9 c\xF2n m\u1ED9t v\xE0i b\u01B0\u1EDBc \u0111\u1EC3 \u0111\u1ECBnh ngh\u0129a "),Xt=a(Z,"CODE",{});var Hr=o(Xt);Ze=c(Hr,"Trainer"),Hr.forEach(e),th=c(Z,". Ph\u1EA7n kh\xF3 nh\u1EA5t c\xF3 th\u1EC3 l\xE0 chu\u1EA9n b\u1ECB m\xF4i tr\u01B0\u1EDDng \u0111\u1EC3 ch\u1EA1y "),Qt=a(Z,"CODE",{});var Ir=o(Qt);nh=c(Ir,"Trainer.train()"),Ir.forEach(e),eh=c(Z,", v\xEC n\xF3 s\u1EBD ch\u1EA1y r\u1EA5t ch\u1EADm tr\xEAn CPU. N\u1EBFu b\u1EA1n ch\u01B0a thi\u1EBFt l\u1EADp GPU, b\u1EA1n c\xF3 th\u1EC3 c\xF3 quy\u1EC1n truy c\u1EADp v\xE0o GPU ho\u1EB7c TPU mi\u1EC5n ph\xED tr\xEAn "),yt=a(Z,"A",{href:!0,rel:!0});var Rr=o(yt);hh=c(Rr,"Google Colab"),Rr.forEach(e),ch=c(Z,"."),Z.forEach(e),oe=p(t),Mt=a(t,"P",{});var Kr=o(Mt);rh=c(Kr,"C\xE1c v\xED d\u1EE5 m\xE3 b\xEAn d\u01B0\u1EDBi gi\u1EA3 s\u1EED b\u1EA1n \u0111\xE3 th\u1EF1c hi\u1EC7n c\xE1c v\xED d\u1EE5 trong ph\u1EA7n tr\u01B0\u1EDBc. D\u01B0\u1EDBi \u0111\xE2y l\xE0 m\u1ED9t b\u1EA3n t\xF3m t\u1EAFt ng\u1EAFn t\xF3m t\u1EAFt l\u1EA1i nh\u1EEFng g\xEC b\u1EA1n c\u1EA7n:"),Kr.forEach(e),ie=p(t),v(bt.$$.fragment,t),se=p(t),et=a(t,"H3",{class:!0});var Re=o(et);at=a(Re,"A",{id:!0,class:!0,href:!0});var Wr=o(at);Zt=a(Wr,"SPAN",{});var Vr=o(Zt);v($t.$$.fragment,Vr),Vr.forEach(e),Wr.forEach(e),ah=p(Re),tn=a(Re,"SPAN",{});var Yr=o(tn);oh=c(Yr,"Hu\u1EA5n luy\u1EC7n"),Yr.forEach(e),Re.forEach(e),le=p(t),G=a(t,"P",{});var ut=o(G);ih=c(ut,"B\u01B0\u1EDBc \u0111\u1EA7u ti\xEAn tr\u01B0\u1EDBc khi ch\xFAng ta c\xF3 th\u1EC3 \u0111\u1ECBnh ngh\u0129a "),nn=a(ut,"CODE",{});var Jr=o(nn);sh=c(Jr,"Trainer"),Jr.forEach(e),lh=c(ut," c\u1EE7a m\xECnh l\xE0 \u0111\u1ECBnh ngh\u0129a m\u1ED9t l\u1EDBp "),en=a(ut,"CODE",{});var Xr=o(en);ph=c(Xr,"TrainingArguments"),Xr.forEach(e),mh=c(ut," s\u1EBD ch\u1EE9a t\u1EA5t c\u1EA3 c\xE1c si\xEAu tham s\u1ED1 m\xE0 "),hn=a(ut,"CODE",{});var Qr=o(hn);uh=c(Qr,"Trainer"),Qr.forEach(e),dh=c(ut," s\u1EBD s\u1EED d\u1EE5ng \u0111\u1EC3 hu\u1EA5n luy\u1EC7n v\xE0 \u0111\xE1nh gi\xE1. Tham s\u1ED1 duy nh\u1EA5t b\u1EA1n ph\u1EA3i cung c\u1EA5p l\xE0 m\u1ED9t th\u01B0 m\u1EE5c n\u01A1i m\xF4 h\xECnh \u0111\u01B0\u1EE3c hu\u1EA5n luy\u1EC7n s\u1EBD \u0111\u01B0\u1EE3c l\u01B0u, c\u0169ng nh\u01B0 c\xE1c checkpoint \u0111i k\xE8m. \u0110\u1ED1i v\u1EDBi t\u1EA5t c\u1EA3 ph\u1EA7n c\xF2n l\u1EA1i, b\u1EA1n c\xF3 th\u1EC3 \u0111\u1EC3 m\u1EB7c \u0111\u1ECBnh, n\xF3 s\u1EBD ho\u1EA1t \u0111\u1ED9ng kh\xE1 t\u1ED1t v\u1EDBi tinh ch\u1EC9nh c\u01A1 b\u1EA3n."),ut.forEach(e),pe=p(t),v(kt.$$.fragment,t),me=p(t),v(ot.$$.fragment,t),ue=p(t),Y=a(t,"P",{});var Rt=o(Y);gh=c(Rt,"B\u01B0\u1EDBc th\u1EE9 hai l\xE0 x\xE1c \u0111\u1ECBnh m\xF4 h\xECnh c\u1EE7a ch\xFAng ta. Nh\u01B0 trong "),Ut=a(Rt,"A",{href:!0});var Zr=o(Ut);fh=c(Zr,"ch\u01B0\u01A1ng tr\u01B0\u1EDBc"),Zr.forEach(e),vh=c(Rt,", ch\xFAng ta s\u1EBD s\u1EED d\u1EE5ng l\u1EDBp "),cn=a(Rt,"CODE",{});var ta=o(cn);_h=c(ta,"AutoModelForSequenceClassification"),ta.forEach(e),yh=c(Rt,", v\u1EDBi hai nh\xE3n:"),Rt.forEach(e),de=p(t),v(Et.$$.fragment,t),ge=p(t),it=a(t,"P",{});var Ke=o(it);bh=c(Ke,"B\u1EA1n s\u1EBD nh\u1EADn th\u1EA5y r\u1EB1ng kh\xF4ng nh\u01B0 trong "),Ft=a(Ke,"A",{href:!0});var na=o(Ft);$h=c(na,"Ch\u01B0\u01A1ng 2"),na.forEach(e),kh=c(Ke,", b\u1EA1n nh\u1EADn \u0111\u01B0\u1EE3c m\u1ED9t c\u1EA3nh b\xE1o sau khi kh\u1EDFi t\u1EA1o m\xF4 h\xECnh \u0111\u01B0\u1EE3c hu\u1EA5n luy\u1EC7n tr\u01B0\u1EDBc n\xE0y. \u0110\xE2y l\xE0 do BERT ch\u01B0a \u0111\u01B0\u1EE3c hu\u1EA5n luy\u1EC7n tr\u01B0\u1EDBc v\u1EC1 ph\xE2n lo\u1EA1i c\xE1c c\u1EB7p c\xE2u, v\xEC v\u1EADy ph\u1EA7n \u0111\u1EA7u c\u1EE7a m\xF4 h\xECnh \u0111\u01B0\u1EE3c hu\u1EA5n luy\u1EC7n tr\u01B0\u1EDBc \u0111\xE3 b\u1ECB lo\u1EA1i b\u1ECF v\xE0 ph\u1EA7n \u0111\u1EA7u m\u1EDBi ph\xF9 h\u1EE3p \u0111\u1EC3 ph\xE2n lo\u1EA1i chu\u1ED7i \u0111\xE3 \u0111\u01B0\u1EE3c ch\xE8n v\xE0o thay th\u1EBF. C\xE1c c\u1EA3nh b\xE1o ch\u1EC9 ra r\u1EB1ng m\u1ED9t s\u1ED1 tr\u1ECDng s\u1ED1 \u0111\xE3 kh\xF4ng \u0111\u01B0\u1EE3c s\u1EED d\u1EE5ng (nh\u1EEFng tr\u1ECDng s\u1ED1 t\u01B0\u01A1ng \u1EE9ng v\u1EDBi \u0111\u1EA7u hu\u1EA5n luy\u1EC7n tr\u01B0\u1EDBc b\u1ECB r\u1EE5ng) v\xE0 m\u1ED9t s\u1ED1 tr\u1ECDng s\u1ED1 kh\xE1c kh\xE1c \u0111\u01B0\u1EE3c kh\u1EDFi t\u1EA1o ng\u1EABu nhi\xEAn (nh\u1EEFng tr\u1ECDng s\u1ED1 d\xE0nh cho \u0111\u1EA7u m\u1EDBi). N\xF3 k\u1EBFt th\xFAc b\u1EB1ng c\xE1ch khuy\u1EBFn kh\xEDch b\u1EA1n hu\u1EA5n luy\u1EC7n m\xF4 h\xECnh, \u0111\xF3 ch\xEDnh x\xE1c l\xE0 nh\u1EEFng g\xEC ch\xFAng ta s\u1EBD l\xE0m b\xE2y gi\u1EDD."),Ke.forEach(e),fe=p(t),w=a(t,"P",{});var L=o(w);Eh=c(L,"Khi ch\xFAng ta c\xF3 m\xF4 h\xECnh c\u1EE7a m\xECnh, ch\xFAng ta c\xF3 th\u1EC3 x\xE1c \u0111\u1ECBnh m\u1ED9t "),rn=a(L,"CODE",{});var ea=o(rn);Ch=c(ea,"Trainer"),ea.forEach(e),Th=c(L," b\u1EB1ng c\xE1ch truy\u1EC1n v\xE0o t\u1EA5t c\u1EA3 c\xE1c \u0111\u1ED1i t\u01B0\u1EE3ng \u0111\u01B0\u1EE3c x\xE2y d\u1EF1ng t\u1EEB tr\u01B0\u1EDBc \u0111\u1EBFn nay - "),an=a(L,"CODE",{});var ha=o(an);wh=c(ha,"model"),ha.forEach(e),qh=c(L,", "),on=a(L,"CODE",{});var ca=o(on);Ph=c(ca,"training_args"),ca.forEach(e),Dh=c(L,", t\u1EADp hu\u1EA5n luy\u1EC7n v\xE0 ki\u1EC3m \u0111\u1ECBnh,"),sn=a(L,"CODE",{});var ra=o(sn);xh=c(ra,"data_collator"),ra.forEach(e),Oh=c(L," v\xE0 "),ln=a(L,"CODE",{});var aa=o(ln);jh=c(aa,"tokenizer"),aa.forEach(e),Ah=c(L,":"),L.forEach(e),ve=p(t),v(Ct.$$.fragment,t),_e=p(t),q=a(t,"P",{});var B=o(q);zh=c(B,"L\u01B0u \xFD r\u1EB1ng khi b\u1EA1n truy\u1EC1n "),pn=a(B,"CODE",{});var oa=o(pn);Sh=c(oa,"tokenizer"),oa.forEach(e),Nh=c(B," nh\u01B0 ch\xFAng ta \u0111\xE3 l\xE0m \u1EDF \u0111\xE2y, m\u1EB7c \u0111\u1ECBnh "),mn=a(B,"CODE",{});var ia=o(mn);Gh=c(ia,"data_collator"),ia.forEach(e),Mh=c(B," \u0111\u01B0\u1EE3c s\u1EED d\u1EE5ng b\u1EDFi "),un=a(B,"CODE",{});var sa=o(un);Uh=c(sa,"Trainer"),sa.forEach(e),Fh=c(B," s\u1EBD l\xE0 "),dn=a(B,"CODE",{});var la=o(dn);Lh=c(la,"DataCollatorWithPadding"),la.forEach(e),Bh=c(B," nh\u01B0 \u0111\xE3 \u0111\u1ECBnh ngh\u0129a tr\u01B0\u1EDBc \u0111\xF3, v\xEC v\u1EADy b\u1EA1n c\xF3 th\u1EC3 b\u1ECF qua d\xF2ng "),gn=a(B,"CODE",{});var pa=o(gn);Hh=c(pa,"data_collator = data_collator"),pa.forEach(e),Ih=c(B," trong l\u1EC7nh g\u1ECDi n\xE0y. \u0110i\u1EC1u quan tr\u1ECDng l\xE0 ph\u1EA3i cho b\u1EA1n th\u1EA5y ph\u1EA7n n\xE0y c\u1EE7a qu\xE1 tr\xECnh trong ph\u1EA7n 2!"),B.forEach(e),ye=p(t),J=a(t,"P",{});var Kt=o(J);Rh=c(Kt,"\u0110\u1EC3 tinh ch\u1EC9nh m\xF4 h\xECnh tr\xEAn t\u1EADp d\u1EEF li\u1EC7u, ch\xFAng ta ch\u1EC9 c\u1EA7n g\u1ECDi ph\u01B0\u01A1ng th\u1EE9c "),fn=a(Kt,"CODE",{});var ma=o(fn);Kh=c(ma,"train()"),ma.forEach(e),Wh=c(Kt," c\u1EE7a "),vn=a(Kt,"CODE",{});var ua=o(vn);Vh=c(ua,"Trainer"),ua.forEach(e),Yh=c(Kt,":"),Kt.forEach(e),be=p(t),v(Tt.$$.fragment,t),$e=p(t),Lt=a(t,"P",{});var da=o(Lt);Jh=c(da,"Thao t\xE1c n\xE0y s\u1EBD b\u1EAFt \u0111\u1EA7u qu\xE1 tr\xECnh tinh ch\u1EC9nh (s\u1EBD m\u1EA5t v\xE0i ph\xFAt tr\xEAn GPU) v\xE0 b\xE1o c\xE1o l\u1ED7i \u0111\xE0o t\u1EA1o sau m\u1ED7i 500 b\u01B0\u1EDBc. Tuy nhi\xEAn, n\xF3 s\u1EBD kh\xF4ng cho b\u1EA1n bi\u1EBFt m\xF4 h\xECnh c\u1EE7a b\u1EA1n \u0111ang ho\u1EA1t \u0111\u1ED9ng t\u1ED1t (ho\u1EB7c t\u1ED3i t\u1EC7 nh\u01B0 th\u1EBF n\xE0o). \u0110i\u1EC1u n\xE0y l\xE0 do:"),da.forEach(e),ke=p(t),st=a(t,"OL",{});var We=o(st);x=a(We,"LI",{});var H=o(x);Xh=c(H,"Ch\xFAng ta \u0111\xE3 kh\xF4ng y\xEAu c\u1EA7u "),_n=a(H,"CODE",{});var ga=o(_n);Qh=c(ga,"Trainer"),ga.forEach(e),Zh=c(H," \u0111\xE1nh gi\xE1 trong qu\xE1 tr\xECnh hu\u1EA5n luy\u1EC7n b\u1EB1ng c\xE1ch c\xE0i \u0111\u1EB7t "),yn=a(H,"CODE",{});var fa=o(yn);tc=c(fa,"eval_strategy"),fa.forEach(e),nc=c(H," th\xE0nh "),bn=a(H,"CODE",{});var va=o(bn);ec=c(va,'"steps"'),va.forEach(e),hc=c(H," (\u0111\xE1nh gi\xE1 m\u1ECDi "),$n=a(H,"CODE",{});var _a=o($n);cc=c(_a,"eval_steps"),_a.forEach(e),rc=c(H,") ho\u1EB7c "),kn=a(H,"CODE",{});var ya=o(kn);ac=c(ya,'"epoch"'),ya.forEach(e),oc=c(H," (\u0111\xE1nh gi\xE1 v\xE0o cu\u1ED1i m\u1ED7i epoch)."),H.forEach(e),ic=p(We),ht=a(We,"LI",{});var Wt=o(ht);sc=c(Wt,"Ch\xFAng ta \u0111\xE3 kh\xF4ng cung c\u1EA5p cho "),En=a(Wt,"CODE",{});var ba=o(En);lc=c(ba,"Trainer"),ba.forEach(e),pc=c(Wt," m\u1ED9t h\xE0m "),Cn=a(Wt,"CODE",{});var $a=o(Cn);mc=c($a,"compute_metrics()"),$a.forEach(e),uc=c(Wt," \u0111\u1EC3 t\xEDnh to\xE1n ch\u1EC9 s\u1ED1 trong qu\xE1 tr\xECnh \u0111\xE1nh gi\xE1 n\xF3i tr\xEAn (n\u1EBFu kh\xF4ng, \u0111\xE1nh gi\xE1 s\u1EBD ch\u1EC9 in ra l\u1ED7, \u0111\xE2y kh\xF4ng ph\u1EA3i l\xE0 m\u1ED9t ch\u1EC9 s\u1ED1 tr\u1EF1c quan cho l\u1EAFm)."),Wt.forEach(e),We.forEach(e),Ee=p(t),ct=a(t,"H3",{class:!0});var Ve=o(ct);lt=a(Ve,"A",{id:!0,class:!0,href:!0});var ka=o(lt);Tn=a(ka,"SPAN",{});var Ea=o(Tn);v(wt.$$.fragment,Ea),Ea.forEach(e),ka.forEach(e),dc=p(Ve),wn=a(Ve,"SPAN",{});var Ca=o(wn);gc=c(Ca,"\u0110\xE1nh gi\xE1"),Ca.forEach(e),Ve.forEach(e),Ce=p(t),P=a(t,"P",{});var I=o(P);fc=c(I,"H\xE3y xem c\xE1ch ch\xFAng ta c\xF3 th\u1EC3 x\xE2y d\u1EF1ng m\u1ED9t h\xE0m "),qn=a(I,"CODE",{});var Ta=o(qn);vc=c(Ta,"compute_metrics()"),Ta.forEach(e),_c=c(I," h\u1EEFu \xEDch v\xE0 s\u1EED d\u1EE5ng n\xF3 trong l\u1EA7n hu\u1EA5n luy\u1EC7n ti\u1EBFp theo. H\xE0m ph\u1EA3i nh\u1EADn m\u1ED9t \u0111\u1ED1i t\u01B0\u1EE3ng "),Pn=a(I,"CODE",{});var wa=o(Pn);yc=c(wa,"EvalPrediction"),wa.forEach(e),bc=c(I," (l\xE0 m\u1ED9t tuple \u0111\u01B0\u1EE3c \u0111\u1EB7t t\xEAn v\u1EDBi tr\u01B0\u1EDDng "),Dn=a(I,"CODE",{});var qa=o(Dn);$c=c(qa,"predictions"),qa.forEach(e),kc=c(I," v\xE0 tr\u01B0\u1EDDng "),xn=a(I,"CODE",{});var Pa=o(xn);Ec=c(Pa,"label_ids"),Pa.forEach(e),Cc=c(I,") v\xE0 s\u1EBD tr\u1EA3 v\u1EC1 m\u1ED9t chu\u1ED7i \xE1nh x\u1EA1 t\u1EEB th\xE0nh s\u1ED1 th\u1EF1c (c\xE1c chu\u1ED7i l\xE0 t\xEAn c\u1EE7a c\xE1c ch\u1EC9 s\u1ED1 \u0111\u01B0\u1EE3c tr\u1EA3 v\u1EC1 v\xE0 c\xE1c gi\xE1 tr\u1ECB c\u1EE7a ch\xFAng \xE9p v\u1EC1 ki\u1EC3u s\u1ED1 th\u1EF1c). \u0110\u1EC3 nh\u1EADn \u0111\u01B0\u1EE3c d\u1EF1 \u0111o\xE1n t\u1EEB m\xF4 h\xECnh, ch\xFAng ta c\xF3 th\u1EC3 s\u1EED d\u1EE5ng l\u1EC7nh "),On=a(I,"CODE",{});var Da=o(On);Tc=c(Da,"Trainer.predict()"),Da.forEach(e),wc=c(I,":"),I.forEach(e),Te=p(t),v(qt.$$.fragment,t),we=p(t),v(Pt.$$.fragment,t),qe=p(t),g=a(t,"P",{});var E=o(g);qc=c(E,"\u0110\u1EA7u ra c\u1EE7a ph\u01B0\u01A1ng th\u1EE9c "),jn=a(E,"CODE",{});var xa=o(jn);Pc=c(xa,"predict()"),xa.forEach(e),Dc=c(E," l\xE0 m\u1ED9t tuple c\xF3 t\xEAn kh\xE1c v\u1EDBi ba tr\u01B0\u1EDDng: "),An=a(E,"CODE",{});var Oa=o(An);xc=c(Oa,"predictions"),Oa.forEach(e),Oc=c(E,", "),zn=a(E,"CODE",{});var ja=o(zn);jc=c(ja,"label_ids"),ja.forEach(e),Ac=c(E,", v\xE0 "),Sn=a(E,"CODE",{});var Aa=o(Sn);zc=c(Aa,"metrics"),Aa.forEach(e),Sc=c(E,". Tr\u01B0\u1EDDng "),Nn=a(E,"CODE",{});var za=o(Nn);Nc=c(za,"metrics"),za.forEach(e),Gc=c(E," s\u1EBD ch\u1EC9 ch\u1EE9a s\u1EF1 m\u1EA5t m\xE1t tr\xEAn t\u1EADp d\u1EEF li\u1EC7u \u0111\xE3 truy\u1EC1n v\xE0o, c\u0169ng nh\u01B0 m\u1ED9t s\u1ED1 ch\u1EC9 s\u1ED1 th\u1EDDi gian (t\u1ED5ng c\u1ED9ng v\xE0 trung b\xECnh m\u1EA5t bao l\xE2u \u0111\u1EC3 d\u1EF1 \u0111o\xE1n). Sau khi ch\xFAng ta ho\xE0n th\xE0nh h\xE0m "),Gn=a(E,"CODE",{});var Sa=o(Gn);Mc=c(Sa,"compute_metrics()"),Sa.forEach(e),Uc=c(E," v\xE0 truy\u1EC1n n\xF3 v\xE0o "),Mn=a(E,"CODE",{});var Na=o(Mn);Fc=c(Na,"Trainer"),Na.forEach(e),Lc=c(E,", tr\u01B0\u1EDDng \u0111\xF3 c\u0169ng s\u1EBD ch\u1EE9a c\xE1c ch\u1EC9 s\u1ED1 \u0111\u01B0\u1EE3c tr\u1EA3 v\u1EC1 b\u1EDFi"),Un=a(E,"CODE",{});var Ga=o(Un);Bc=c(Ga,"compute_metrics()"),Ga.forEach(e),Hc=c(E,"."),E.forEach(e),Pe=p(t),M=a(t,"P",{});var dt=o(M);Ic=c(dt,"Nh\u01B0 b\u1EA1n c\xF3 th\u1EC3 th\u1EA5y, "),Fn=a(dt,"CODE",{});var Ma=o(Fn);Rc=c(Ma,"predictions"),Ma.forEach(e),Kc=c(dt," l\xE0 m\u1ED9t m\u1EA3ng hai chi\u1EC1u c\xF3 h\xECnh d\u1EA1ng 408 x 2 (408 l\xE0 s\u1ED1 ph\u1EA7n t\u1EED trong t\u1EADp d\u1EEF li\u1EC7u ta \u0111\xE3 s\u1EED d\u1EE5ng). \u0110\xF3 l\xE0 c\xE1c logit cho t\u1EEBng ph\u1EA7n t\u1EED c\u1EE7a t\u1EADp d\u1EEF li\u1EC7u m\xE0 ch\xFAng ta \u0111\xE3 truy\u1EC1n v\xE0o cho"),Ln=a(dt,"CODE",{});var Ua=o(Ln);Wc=c(Ua,"predict()"),Ua.forEach(e),Vc=c(dt," ( nh\u01B0 b\u1EA1n \u0111\xE3 th\u1EA5y trong "),Bt=a(dt,"A",{href:!0});var Fa=o(Bt);Yc=c(Fa,"ch\u01B0\u01A1ng tr\u01B0\u1EDBc"),Fa.forEach(e),Jc=c(dt,", t\u1EA5t c\u1EA3 c\xE1c m\xF4 h\xECnh Transformer \u0111\u1EC1u tr\u1EA3 v\u1EC1 logit). \u0110\u1EC3 chuy\u1EC3n \u0111\u1ED5i ch\xFAng th\xE0nh c\xE1c d\u1EF1 \u0111o\xE1n m\xE0 ch\xFAng ta c\xF3 th\u1EC3 so s\xE1nh v\u1EDBi c\xE1c nh\xE3n c\u1EE7a m\xECnh, ch\xFAng ta c\u1EA7n l\u1EA5y ch\u1EC9 s\u1ED1 c\xF3 gi\xE1 tr\u1ECB l\u1EDBn nh\u1EA5t tr\xEAn tr\u1EE5c th\u1EE9 hai:"),dt.forEach(e),De=p(t),v(Dt.$$.fragment,t),xe=p(t),D=a(t,"P",{});var R=o(D);Xc=c(R,"Gi\u1EDD ch\xFAng ta c\xF3 th\u1EC3 so s\xE1nh c\xE1c "),Bn=a(R,"CODE",{});var La=o(Bn);Qc=c(La,"preds"),La.forEach(e),Zc=c(R," \u0111\xF3 v\u1EDBi c\xE1c nh\xE3n. \u0110\u1EC3 x\xE2y d\u1EF1ng h\xE0m "),Hn=a(R,"CODE",{});var Ba=o(Hn);tr=c(Ba,"compute_metric()"),Ba.forEach(e),nr=c(R,", ch\xFAng ta s\u1EBD d\u1EF1a v\xE0o c\xE1c ch\u1EC9 s\u1ED1 t\u1EEB th\u01B0 vi\u1EC7n \u{1F917} "),xt=a(R,"A",{href:!0,rel:!0});var Ha=o(xt);er=c(Ha,"\u0110\xE1nh gi\xE1"),Ha.forEach(e),hr=c(R,". Ch\xFAng ta c\xF3 th\u1EC3 t\u1EA3i c\xE1c ch\u1EC9 s\u1ED1 \u0111\u01B0\u1EE3c li\xEAn k\u1EBFt v\u1EDBi t\u1EADp d\u1EEF li\u1EC7u MRPC d\u1EC5 d\xE0ng nh\u01B0 khi ch\xFAng ta t\u1EA3i t\u1EADp d\u1EEF li\u1EC7u, l\u1EA7n n\xE0y l\xE0 v\u1EDBi h\xE0m "),In=a(R,"CODE",{});var Ia=o(In);cr=c(Ia,"evaluate.load()"),Ia.forEach(e),rr=c(R,". \u0110\u1ED1i t\u01B0\u1EE3ng \u0111\u01B0\u1EE3c tr\u1EA3 v\u1EC1 c\xF3 ph\u01B0\u01A1ng th\u1EE9c "),Rn=a(R,"CODE",{});var Ra=o(Rn);ar=c(Ra,"compute()"),Ra.forEach(e),or=c(R," m\xE0 ch\xFAng ta c\xF3 th\u1EC3 s\u1EED d\u1EE5ng \u0111\u1EC3 th\u1EF1c hi\u1EC7n t\xEDnh to\xE1n s\u1ED1 li\u1EC7u:"),R.forEach(e),Oe=p(t),v(Ot.$$.fragment,t),je=p(t),v(jt.$$.fragment,t),Ae=p(t),U=a(t,"P",{});var gt=o(U);ir=c(gt,"K\u1EBFt qu\u1EA3 ch\xEDnh x\xE1c b\u1EA1n nh\u1EADn \u0111\u01B0\u1EE3c c\xF3 th\u1EC3 kh\xE1c nhau, v\xEC vi\u1EC7c kh\u1EDFi t\u1EA1o ng\u1EABu nhi\xEAn ph\u1EA7n \u0111\u1EA7u m\xF4 h\xECnh c\xF3 th\u1EC3 thay \u0111\u1ED5i c\xE1c ch\u1EC9 s\u1ED1 m\xE0 n\xF3 \u0111\u1EA1t \u0111\u01B0\u1EE3c. \u1EDE \u0111\xE2y, ch\xFAng ta c\xF3 th\u1EC3 th\u1EA5y m\xF4 h\xECnh c\xF3 \u0111\u1ED9 ch\xEDnh x\xE1c 85.78% tr\xEAn t\u1EADp ki\u1EC3m \u0111\u1ECBnh v\xE0 \u0111i\u1EC3m F1 l\xE0 89.97. \u0110\xF3 l\xE0 hai ch\u1EC9 s\u1ED1 \u0111\u01B0\u1EE3c s\u1EED d\u1EE5ng \u0111\u1EC3 \u0111\xE1nh gi\xE1 k\u1EBFt qu\u1EA3 tr\xEAn t\u1EADp d\u1EEF li\u1EC7u MRPC theo \u0111i\u1EC3m chu\u1EA9n GLUE. B\u1EA3ng trong "),At=a(gt,"A",{href:!0,rel:!0});var Ka=o(At);sr=c(Ka,"b\xE0i b\xE1o BERT"),Ka.forEach(e),lr=c(gt," b\xE1o c\xE1o \u0111i\u1EC3m F1 l\xE0 88.9 cho m\xF4 h\xECnh c\u01A1 s\u1EDF. \u0110\xF3 l\xE0 m\xF4 h\xECnh "),Kn=a(gt,"CODE",{});var Wa=o(Kn);pr=c(Wa,"kh\xF4ng ph\xE2n bi\u1EC7t"),Wa.forEach(e),mr=c(gt," vi\u1EBFt hoa vi\u1EBFt th\u01B0\u1EDDng trong khi ch\xFAng ta hi\u1EC7n \u0111ang s\u1EED d\u1EE5ng m\xF4 h\xECnh "),Wn=a(gt,"CODE",{});var Va=o(Wn);ur=c(Va,"c\xF3 ph\xE2n bi\u1EC7t"),Va.forEach(e),dr=c(gt,", \u0111i\u1EC1u n\xE0y gi\u1EA3i th\xEDch k\u1EBFt qu\u1EA3 t\u1ED1t h\u01A1n."),gt.forEach(e),ze=p(t),pt=a(t,"P",{});var Ye=o(pt);gr=c(Ye,"K\u1EBFt h\u1EE3p m\u1ECDi th\u1EE9 l\u1EA1i v\u1EDBi nhau, ch\xFAng ta nh\u1EADn \u0111\u01B0\u1EE3c h\xE0m "),Vn=a(Ye,"CODE",{});var Ya=o(Vn);fr=c(Ya,"compute_metrics()"),Ya.forEach(e),vr=c(Ye,":"),Ye.forEach(e),Se=p(t),v(zt.$$.fragment,t),Ne=p(t),X=a(t,"P",{});var Vt=o(X);_r=c(Vt,"V\xE0 \u0111\u1EC3 xem n\xF3 \u0111\u01B0\u1EE3c s\u1EED d\u1EE5ng trong th\u1EF1c ti\u1EC5n \u0111\u1EC3 b\xE1o c\xE1o c\xE1c ch\u1EC9 s\u1ED1 \u1EDF cu\u1ED1i m\u1ED7i epoch nh\u01B0 th\u1EBF n\xE0o, \u0111\xE2y l\xE0 c\xE1ch ch\xFAng t\xF4i \u0111\u1ECBnh ngh\u0129a m\u1ED9t "),Yn=a(Vt,"CODE",{});var Ja=o(Yn);yr=c(Ja,"Trainer"),Ja.forEach(e),br=c(Vt," m\u1EDBi v\u1EDBi h\xE0m "),Jn=a(Vt,"CODE",{});var Xa=o(Jn);$r=c(Xa,"compute_metrics()"),Xa.forEach(e),kr=c(Vt," n\xE0y:"),Vt.forEach(e),Ge=p(t),v(St.$$.fragment,t),Me=p(t),F=a(t,"P",{});var ft=o(F);Er=c(ft,"L\u01B0u \xFD r\u1EB1ng ch\xFAng ta t\u1EA1o m\u1ED9t "),Xn=a(ft,"CODE",{});var Qa=o(Xn);Cr=c(Qa,"TrainingArguments"),Qa.forEach(e),Tr=c(ft," m\u1EDBi v\u1EDBi "),Qn=a(ft,"CODE",{});var Za=o(Qn);wr=c(Za,"eval_strategy"),Za.forEach(e),qr=c(ft," c\u1EE7a n\xF3 \u0111\u01B0\u1EE3c \u0111\u1EB7t th\xE0nh "),Zn=a(ft,"CODE",{});var to=o(Zn);Pr=c(to,'"epoch"'),to.forEach(e),Dr=c(ft," v\xE0 m\u1ED9t m\xF4 h\xECnh m\u1EDBi - n\u1EBFu kh\xF4ng, ch\xFAng ta s\u1EBD ti\u1EBFp t\u1EE5c hu\u1EA5n luy\u1EC7n m\xF4 h\xECnh ta \u0111\xE3 hu\u1EA5n luy\u1EC7n. \u0110\u1EC3 kh\u1EDFi ch\u1EA1y m\u1ED9t \u0111\u1EE3t hu\u1EA5n luy\u1EC7n m\u1EDBi, ch\xFAng ta th\u1EF1c hi\u1EC7n:"),ft.forEach(e),Ue=p(t),v(Nt.$$.fragment,t),Fe=p(t),Ht=a(t,"P",{});var no=o(Ht);xr=c(no,"L\u1EA7n n\xE0y, n\xF3 s\u1EBD b\xE1o c\xE1o th\xF4ng s\u1ED1 m\u1EA5t m\xE1t ki\u1EC3m \u0111\u1ECBnh v\xE0 ch\u1EC9 s\u1ED1 \u1EDF cu\u1ED1i m\u1ED7i epoch \xEAn c\u1EA1nh th\xF4ng s\u1ED1 m\u1EA5t m\xE1t tr\xEAn t\u1EADp hu\u1EA5n luy\u1EC7n. M\u1ED9t l\u1EA7n n\u1EEFa, \u0111\u1ED9 ch\xEDnh x\xE1c tuy\u1EC7t \u0111\u1ED1i/\u0111i\u1EC3m F1 m\xE0 b\u1EA1n \u0111\u1EA1t \u0111\u01B0\u1EE3c c\xF3 th\u1EC3 h\u01A1i kh\xE1c so v\u1EDBi nh\u1EEFng g\xEC ch\xFAng t\xF4i t\xECm th\u1EA5y, do vi\u1EC7c kh\u1EDFi t\u1EA1o \u0111\u1EA7u ng\u1EABu nhi\xEAn c\u1EE7a m\xF4 h\xECnh, nh\u01B0ng n\xF3 ph\u1EA3i \u1EDF trong c\xF9ng m\u1ED9t kho\u1EA3ng."),no.forEach(e),Le=p(t),rt=a(t,"P",{});var re=o(rt);te=a(re,"CODE",{});var eo=o(te);Or=c(eo,"Trainer"),eo.forEach(e),jr=c(re," s\u1EBD ho\u1EA1t \u0111\u1ED9ng hi\u1EC7u qu\u1EA3 tr\xEAn nhi\u1EC1u GPU ho\u1EB7c TPU v\xE0 cung c\u1EA5p nhi\u1EC1u t\xF9y ch\u1ECDn, ch\u1EB3ng h\u1EA1n nh\u01B0 hu\u1EA5n luy\u1EC7n v\u1EC1 \u0111\u1ED9 ch\xEDnh x\xE1c h\u1ED7n h\u1EE3p (s\u1EED d\u1EE5ng "),ne=a(re,"CODE",{});var ho=o(ne);Ar=c(ho,"fp16=True"),ho.forEach(e),zr=c(re," trong tham s\u1ED1 hu\u1EA5n luy\u1EC7n c\u1EE7a b\u1EA1n). Ch\xFAng ta s\u1EBD xem x\xE9t m\u1ECDi th\u1EE9 m\xE0 n\xF3 h\u1ED7 tr\u1EE3 trong Ch\u01B0\u01A1ng 10."),re.forEach(e),Be=p(t),Q=a(t,"P",{});var Yt=o(Q);Sr=c(Yt,"Ph\u1EA7n n\xE0y k\u1EBFt th\xFAc ph\u1EA7n gi\u1EDBi thi\u1EC7u v\u1EC1 c\xE1ch tinh ch\u1EC9nh b\u1EB1ng API "),ee=a(Yt,"CODE",{});var co=o(ee);Nr=c(co,"Trainer"),co.forEach(e),Gr=c(Yt,". M\u1ED9t v\xED d\u1EE5 v\u1EC1 vi\u1EC7c th\u1EF1c hi\u1EC7n \u0111i\u1EC1u n\xE0y \u0111\u1ED1i v\u1EDBi h\u1EA7u h\u1EBFt c\xE1c t\xE1c v\u1EE5 NLP ph\u1ED5 bi\u1EBFn s\u1EBD \u0111\u01B0\u1EE3c \u0111\u01B0a ra trong "),It=a(Yt,"A",{href:!0});var ro=o(It);Mr=c(ro,"Ch\u01B0\u01A1ng 7"),ro.forEach(e),Ur=c(Yt,", nh\u01B0ng \u1EDF th\u1EDDi \u0111i\u1EC3m n\xE0y ch\xFAng ta h\xE3y xem c\xE1ch th\u1EF1c hi\u1EC7n \u0111i\u1EC1u t\u01B0\u01A1ng t\u1EF1 trong PyTorch thu\u1EA7n t\xFAy."),Yt.forEach(e),He=p(t),v(mt.$$.fragment,t),this.h()},h(){u(m,"name","hf:doc:metadata"),u(m,"content",JSON.stringify(yo)),u(k,"id","tinh-chnh-mt-m-hnh-vi-trainer-api"),u(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"),u(k,"href","#tinh-chnh-mt-m-hnh-vi-trainer-api"),u(C,"class","relative group"),u(yt,"href","https://colab.research.google.com/"),u(yt,"rel","nofollow"),u(at,"id","hun-luyn"),u(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"),u(at,"href","#hun-luyn"),u(et,"class","relative group"),u(Ut,"href","/course/chapter2"),u(Ft,"href","/course/chapter2"),u(lt,"id","nh-gi"),u(lt,"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"),u(lt,"href","#nh-gi"),u(ct,"class","relative group"),u(Bt,"href","/course/chapter2"),u(xt,"href","https://github.com/huggingface/evaluate/"),u(xt,"rel","nofollow"),u(At,"href","https://arxiv.org/pdf/1810.04805.pdf"),u(At,"rel","nofollow"),u(It,"href","/course/chapter7")},m(t,i){n(document.head,m),s(t,O,i),_(d,t,i),s(t,j,i),s(t,C,i),n(C,k),n(k,T),_(A,T,null),n(C,K),n(C,tt),n(tt,nt),s(t,z,i),_(W,t,i),s(t,_t,i),_(V,t,i),s(t,ae,i),s(t,S,i),n(S,Je),n(S,Jt),n(Jt,Xe),n(S,Qe),n(S,Xt),n(Xt,Ze),n(S,th),n(S,Qt),n(Qt,nh),n(S,eh),n(S,yt),n(yt,hh),n(S,ch),s(t,oe,i),s(t,Mt,i),n(Mt,rh),s(t,ie,i),_(bt,t,i),s(t,se,i),s(t,et,i),n(et,at),n(at,Zt),_($t,Zt,null),n(et,ah),n(et,tn),n(tn,oh),s(t,le,i),s(t,G,i),n(G,ih),n(G,nn),n(nn,sh),n(G,lh),n(G,en),n(en,ph),n(G,mh),n(G,hn),n(hn,uh),n(G,dh),s(t,pe,i),_(kt,t,i),s(t,me,i),_(ot,t,i),s(t,ue,i),s(t,Y,i),n(Y,gh),n(Y,Ut),n(Ut,fh),n(Y,vh),n(Y,cn),n(cn,_h),n(Y,yh),s(t,de,i),_(Et,t,i),s(t,ge,i),s(t,it,i),n(it,bh),n(it,Ft),n(Ft,$h),n(it,kh),s(t,fe,i),s(t,w,i),n(w,Eh),n(w,rn),n(rn,Ch),n(w,Th),n(w,an),n(an,wh),n(w,qh),n(w,on),n(on,Ph),n(w,Dh),n(w,sn),n(sn,xh),n(w,Oh),n(w,ln),n(ln,jh),n(w,Ah),s(t,ve,i),_(Ct,t,i),s(t,_e,i),s(t,q,i),n(q,zh),n(q,pn),n(pn,Sh),n(q,Nh),n(q,mn),n(mn,Gh),n(q,Mh),n(q,un),n(un,Uh),n(q,Fh),n(q,dn),n(dn,Lh),n(q,Bh),n(q,gn),n(gn,Hh),n(q,Ih),s(t,ye,i),s(t,J,i),n(J,Rh),n(J,fn),n(fn,Kh),n(J,Wh),n(J,vn),n(vn,Vh),n(J,Yh),s(t,be,i),_(Tt,t,i),s(t,$e,i),s(t,Lt,i),n(Lt,Jh),s(t,ke,i),s(t,st,i),n(st,x),n(x,Xh),n(x,_n),n(_n,Qh),n(x,Zh),n(x,yn),n(yn,tc),n(x,nc),n(x,bn),n(bn,ec),n(x,hc),n(x,$n),n($n,cc),n(x,rc),n(x,kn),n(kn,ac),n(x,oc),n(st,ic),n(st,ht),n(ht,sc),n(ht,En),n(En,lc),n(ht,pc),n(ht,Cn),n(Cn,mc),n(ht,uc),s(t,Ee,i),s(t,ct,i),n(ct,lt),n(lt,Tn),_(wt,Tn,null),n(ct,dc),n(ct,wn),n(wn,gc),s(t,Ce,i),s(t,P,i),n(P,fc),n(P,qn),n(qn,vc),n(P,_c),n(P,Pn),n(Pn,yc),n(P,bc),n(P,Dn),n(Dn,$c),n(P,kc),n(P,xn),n(xn,Ec),n(P,Cc),n(P,On),n(On,Tc),n(P,wc),s(t,Te,i),_(qt,t,i),s(t,we,i),_(Pt,t,i),s(t,qe,i),s(t,g,i),n(g,qc),n(g,jn),n(jn,Pc),n(g,Dc),n(g,An),n(An,xc),n(g,Oc),n(g,zn),n(zn,jc),n(g,Ac),n(g,Sn),n(Sn,zc),n(g,Sc),n(g,Nn),n(Nn,Nc),n(g,Gc),n(g,Gn),n(Gn,Mc),n(g,Uc),n(g,Mn),n(Mn,Fc),n(g,Lc),n(g,Un),n(Un,Bc),n(g,Hc),s(t,Pe,i),s(t,M,i),n(M,Ic),n(M,Fn),n(Fn,Rc),n(M,Kc),n(M,Ln),n(Ln,Wc),n(M,Vc),n(M,Bt),n(Bt,Yc),n(M,Jc),s(t,De,i),_(Dt,t,i),s(t,xe,i),s(t,D,i),n(D,Xc),n(D,Bn),n(Bn,Qc),n(D,Zc),n(D,Hn),n(Hn,tr),n(D,nr),n(D,xt),n(xt,er),n(D,hr),n(D,In),n(In,cr),n(D,rr),n(D,Rn),n(Rn,ar),n(D,or),s(t,Oe,i),_(Ot,t,i),s(t,je,i),_(jt,t,i),s(t,Ae,i),s(t,U,i),n(U,ir),n(U,At),n(At,sr),n(U,lr),n(U,Kn),n(Kn,pr),n(U,mr),n(U,Wn),n(Wn,ur),n(U,dr),s(t,ze,i),s(t,pt,i),n(pt,gr),n(pt,Vn),n(Vn,fr),n(pt,vr),s(t,Se,i),_(zt,t,i),s(t,Ne,i),s(t,X,i),n(X,_r),n(X,Yn),n(Yn,yr),n(X,br),n(X,Jn),n(Jn,$r),n(X,kr),s(t,Ge,i),_(St,t,i),s(t,Me,i),s(t,F,i),n(F,Er),n(F,Xn),n(Xn,Cr),n(F,Tr),n(F,Qn),n(Qn,wr),n(F,qr),n(F,Zn),n(Zn,Pr),n(F,Dr),s(t,Ue,i),_(Nt,t,i),s(t,Fe,i),s(t,Ht,i),n(Ht,xr),s(t,Le,i),s(t,rt,i),n(rt,te),n(te,Or),n(rt,jr),n(rt,ne),n(ne,Ar),n(rt,zr),s(t,Be,i),s(t,Q,i),n(Q,Sr),n(Q,ee),n(ee,Nr),n(Q,Gr),n(Q,It),n(It,Mr),n(Q,Ur),s(t,He,i),_(mt,t,i),Ie=!0},p(t,[i]){const Gt={};i&1&&(Gt.fw=t[0]),d.$set(Gt);const he={};i&2&&(he.$$scope={dirty:i,ctx:t}),ot.$set(he);const ce={};i&2&&(ce.$$scope={dirty:i,ctx:t}),mt.$set(ce)},i(t){Ie||(y(d.$$.fragment,t),y(A.$$.fragment,t),y(W.$$.fragment,t),y(V.$$.fragment,t),y(bt.$$.fragment,t),y($t.$$.fragment,t),y(kt.$$.fragment,t),y(ot.$$.fragment,t),y(Et.$$.fragment,t),y(Ct.$$.fragment,t),y(Tt.$$.fragment,t),y(wt.$$.fragment,t),y(qt.$$.fragment,t),y(Pt.$$.fragment,t),y(Dt.$$.fragment,t),y(Ot.$$.fragment,t),y(jt.$$.fragment,t),y(zt.$$.fragment,t),y(St.$$.fragment,t),y(Nt.$$.fragment,t),y(mt.$$.fragment,t),Ie=!0)},o(t){b(d.$$.fragment,t),b(A.$$.fragment,t),b(W.$$.fragment,t),b(V.$$.fragment,t),b(bt.$$.fragment,t),b($t.$$.fragment,t),b(kt.$$.fragment,t),b(ot.$$.fragment,t),b(Et.$$.fragment,t),b(Ct.$$.fragment,t),b(Tt.$$.fragment,t),b(wt.$$.fragment,t),b(qt.$$.fragment,t),b(Pt.$$.fragment,t),b(Dt.$$.fragment,t),b(Ot.$$.fragment,t),b(jt.$$.fragment,t),b(zt.$$.fragment,t),b(St.$$.fragment,t),b(Nt.$$.fragment,t),b(mt.$$.fragment,t),Ie=!1},d(t){e(m),t&&e(O),$(d,t),t&&e(j),t&&e(C),$(A),t&&e(z),$(W,t),t&&e(_t),$(V,t),t&&e(ae),t&&e(S),t&&e(oe),t&&e(Mt),t&&e(ie),$(bt,t),t&&e(se),t&&e(et),$($t),t&&e(le),t&&e(G),t&&e(pe),$(kt,t),t&&e(me),$(ot,t),t&&e(ue),t&&e(Y),t&&e(de),$(Et,t),t&&e(ge),t&&e(it),t&&e(fe),t&&e(w),t&&e(ve),$(Ct,t),t&&e(_e),t&&e(q),t&&e(ye),t&&e(J),t&&e(be),$(Tt,t),t&&e($e),t&&e(Lt),t&&e(ke),t&&e(st),t&&e(Ee),t&&e(ct),$(wt),t&&e(Ce),t&&e(P),t&&e(Te),$(qt,t),t&&e(we),$(Pt,t),t&&e(qe),t&&e(g),t&&e(Pe),t&&e(M),t&&e(De),$(Dt,t),t&&e(xe),t&&e(D),t&&e(Oe),$(Ot,t),t&&e(je),$(jt,t),t&&e(Ae),t&&e(U),t&&e(ze),t&&e(pt),t&&e(Se),$(zt,t),t&&e(Ne),t&&e(X),t&&e(Ge),$(St,t),t&&e(Me),t&&e(F),t&&e(Ue),$(Nt,t),t&&e(Fe),t&&e(Ht),t&&e(Le),t&&e(rt),t&&e(Be),t&&e(Q),t&&e(He),$(mt,t)}}}const yo={local:"tinh-chnh-mt-m-hnh-vi-trainer-api",sections:[{local:"hun-luyn",title:"Hu\u1EA5n luy\u1EC7n"},{local:"nh-gi",title:"\u0110\xE1nh gi\xE1"}],title:"Tinh ch\u1EC9nh m\u1ED9t m\xF4 h\xECnh v\u1EDBi Trainer API"};function bo(vt,m,O){let d="pt";return po(()=>{const j=new URLSearchParams(window.location.search);O(0,d=j.get("fw")||"pt")}),[d]}class Do extends oo{constructor(m){super();io(this,m,bo,_o,so,{})}}export{Do as default,yo as metadata};
