import{S as vr,i as br,s as kr,e as c,k as h,w as u,t as a,M as $r,c as o,d as n,m as p,a as i,x as m,h as l,b as v,G as e,g as r,y as d,q as g,o as f,B as _,v as yr}from"../../chunks/vendor-hf-doc-builder.js";import{T as fr}from"../../chunks/Tip-hf-doc-builder.js";import{Y as _r}from"../../chunks/Youtube-hf-doc-builder.js";import{I as Vn}from"../../chunks/IconCopyLink-hf-doc-builder.js";import{C as k}from"../../chunks/CodeBlock-hf-doc-builder.js";import{C as wr}from"../../chunks/CourseFloatingBanner-hf-doc-builder.js";import"../../chunks/DocNotebookDropdown-hf-doc-builder.js";function jr(Bt){let b,w,$,q,O;return{c(){b=c("p"),w=a("\u270F\uFE0F "),$=c("strong"),q=a("Th\u1EED nghi\u1EC7m th\xF4i!"),O=a(" S\u1EEDa \u0111\u1ED5i v\xF2ng l\u1EB7p hu\u1EA5n luy\u1EC7n tr\u01B0\u1EDBc \u0111\xF3 \u0111\u1EC3 tinh ch\u1EC9nh m\xF4 h\xECnh c\u1EE7a b\u1EA1n tr\xEAn t\u1EADp d\u1EEF li\u1EC7u SST-2.")},l(E){b=o(E,"P",{});var P=i(b);w=l(P,"\u270F\uFE0F "),$=o(P,"STRONG",{});var F=i($);q=l(F,"Th\u1EED nghi\u1EC7m th\xF4i!"),F.forEach(n),O=l(P," S\u1EEDa \u0111\u1ED5i v\xF2ng l\u1EB7p hu\u1EA5n luy\u1EC7n tr\u01B0\u1EDBc \u0111\xF3 \u0111\u1EC3 tinh ch\u1EC9nh m\xF4 h\xECnh c\u1EE7a b\u1EA1n tr\xEAn t\u1EADp d\u1EEF li\u1EC7u SST-2."),P.forEach(n)},m(E,P){r(E,b,P),e(b,w),e(b,$),e($,q),e(b,O)},d(E){E&&n(b)}}}function Er(Bt){let b;return{c(){b=a('\u26A0\uFE0F \u0110\u1EC3 h\u01B0\u1EDFng l\u1EE3i t\u1EEB vi\u1EC7c t\u0103ng t\u1ED1c \u0111\u1ED9 do Cloud TPUs cung c\u1EA5p, ch\xFAng t\xF4i khuy\xEAn b\u1EA1n n\xEAn \u0111\u1EC7m c\xE1c m\u1EABu c\u1EE7a m\xECnh theo \u0111\u1ED9 d\xE0i c\u1ED1 \u0111\u1ECBnh b\u1EB1ng c\xE1c tham s\u1ED1 `padding="max_length"` v\xE0 `max_length` c\u1EE7a tokenizer.')},l(w){b=l(w,'\u26A0\uFE0F \u0110\u1EC3 h\u01B0\u1EDFng l\u1EE3i t\u1EEB vi\u1EC7c t\u0103ng t\u1ED1c \u0111\u1ED9 do Cloud TPUs cung c\u1EA5p, ch\xFAng t\xF4i khuy\xEAn b\u1EA1n n\xEAn \u0111\u1EC7m c\xE1c m\u1EABu c\u1EE7a m\xECnh theo \u0111\u1ED9 d\xE0i c\u1ED1 \u0111\u1ECBnh b\u1EB1ng c\xE1c tham s\u1ED1 `padding="max_length"` v\xE0 `max_length` c\u1EE7a tokenizer.')},m(w,$){r(w,b,$)},d(w){w&&n(b)}}}function qr(Bt){let b,w,$,q,O,E,P,F,us,Hn,ct,In,ot,Rn,B,ms,sn,ds,gs,Jn,it,Kn,M,G,an,ht,fs,ln,_s,Xn,T,vs,rn,bs,ks,cn,$s,ys,Yn,D,N,ws,on,js,Es,hn,qs,zs,Cs,A,xs,pn,As,Ps,un,Ts,Ds,mn,Ss,Os,Ms,dn,Ns,Qn,pt,gn,Ws,Ls,Zn,ut,te,Gt,Us,ne,mt,ee,Vt,Fs,se,dt,ae,Ht,Bs,le,gt,re,ft,ce,V,Gs,fn,Vs,Hs,oe,It,Is,ie,_t,he,Rt,Rs,pe,vt,ue,bt,me,H,Js,_n,Ks,Xs,de,j,Ys,vn,Qs,Zs,bn,ta,na,kn,ea,sa,kt,aa,la,ge,$t,fe,I,ra,$n,ca,oa,_e,yt,ve,wt,be,W,R,yn,jt,ia,wn,ha,ke,J,pa,jn,ua,ma,$e,Et,ye,qt,we,K,da,En,ga,fa,je,zt,Ee,Jt,_a,qe,L,X,qn,Ct,va,zn,ba,ze,z,ka,Cn,$a,ya,xn,wa,ja,An,Ea,qa,Ce,xt,xe,At,Ae,Kt,za,Pe,Y,Te,U,Q,Pn,Pt,Ca,Tn,xa,De,Tt,Se,Z,Aa,Dt,Pa,Ta,Oe,St,Me,Xt,Da,Ne,Ot,We,C,Sa,Dn,Oa,Ma,Sn,Na,Wa,On,La,Ua,Le,y,Fa,Mn,Ba,Ga,Nn,Va,Ha,Wn,Ia,Ra,Ln,Ja,Ka,Un,Xa,Ya,Ue,tt,Fe,Yt,Qa,Be,Mt,Ge,nt,Za,Fn,tl,nl,Ve,Nt,He,Qt,el,Ie,Wt,Re,Zt,sl,Je,et,al,Bn,ll,rl,Ke,Lt,Xe,st,cl,Ut,ol,il,Ye;return E=new Vn({}),ct=new wr({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/section4.ipynb"},{label:"Aws Studio",value:"https://studiolab.sagemaker.aws/import/github/huggingface/notebooks/blob/master/course/vi/chapter3/section4.ipynb"}]}}),ot=new _r({props:{id:"Dh9CL8fyG80"}}),it=new k({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)`}}),ht=new Vn({}),ut=new k({props:{code:`tokenized_datasets = tokenized_datasets.remove_columns(["sentence1", "sentence2", "idx"])
tokenized_datasets = tokenized_datasets.rename_column("label", "labels")
tokenized_datasets.set_format("torch")
tokenized_datasets["train"].column_names`,highlighted:`tokenized_datasets = tokenized_datasets.remove_columns([<span class="hljs-string">&quot;sentence1&quot;</span>, <span class="hljs-string">&quot;sentence2&quot;</span>, <span class="hljs-string">&quot;idx&quot;</span>])
tokenized_datasets = tokenized_datasets.rename_column(<span class="hljs-string">&quot;label&quot;</span>, <span class="hljs-string">&quot;labels&quot;</span>)
tokenized_datasets.set_format(<span class="hljs-string">&quot;torch&quot;</span>)
tokenized_datasets[<span class="hljs-string">&quot;train&quot;</span>].column_names`}}),mt=new k({props:{code:'["attention_mask", "input_ids", "labels", "token_type_ids"]',highlighted:'[<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>]'}}),dt=new k({props:{code:`from torch.utils.data import DataLoader

train_dataloader = DataLoader(
    tokenized_datasets["train"], shuffle=True, batch_size=8, collate_fn=data_collator
)
eval_dataloader = DataLoader(
    tokenized_datasets["validation"], batch_size=8, collate_fn=data_collator
)`,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>, batch_size=<span class="hljs-number">8</span>, collate_fn=data_collator
)
eval_dataloader = DataLoader(
    tokenized_datasets[<span class="hljs-string">&quot;validation&quot;</span>], batch_size=<span class="hljs-number">8</span>, collate_fn=data_collator
)`}}),gt=new k({props:{code:`for batch in train_dataloader:
    break
{k: v.shape for k, v in batch.items()}`,highlighted:`<span class="hljs-keyword">for</span> batch <span class="hljs-keyword">in</span> train_dataloader:
    <span class="hljs-keyword">break</span>
{k: v.shape <span class="hljs-keyword">for</span> k, v <span class="hljs-keyword">in</span> batch.items()}`}}),ft=new k({props:{code:`{'attention_mask': torch.Size([8, 65]),
 'input_ids': torch.Size([8, 65]),
 'labels': torch.Size([8]),
 'token_type_ids': torch.Size([8, 65])}`,highlighted:`{<span class="hljs-string">&#x27;attention_mask&#x27;</span>: torch.Size([<span class="hljs-number">8</span>, <span class="hljs-number">65</span>]),
 <span class="hljs-string">&#x27;input_ids&#x27;</span>: torch.Size([<span class="hljs-number">8</span>, <span class="hljs-number">65</span>]),
 <span class="hljs-string">&#x27;labels&#x27;</span>: torch.Size([<span class="hljs-number">8</span>]),
 <span class="hljs-string">&#x27;token_type_ids&#x27;</span>: torch.Size([<span class="hljs-number">8</span>, <span class="hljs-number">65</span>])}`}}),_t=new k({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>)`}}),vt=new k({props:{code:`outputs = model(**batch)
print(outputs.loss, outputs.logits.shape)`,highlighted:`outputs = model(**batch)
<span class="hljs-built_in">print</span>(outputs.loss, outputs.logits.shape)`}}),bt=new k({props:{code:"tensor(0.5441, grad_fn=<NllLossBackward>) torch.Size([8, 2])",highlighted:'tensor(<span class="hljs-number">0.5441</span>, grad_fn=&lt;NllLossBackward&gt;) torch.Size([<span class="hljs-number">8</span>, <span class="hljs-number">2</span>])'}}),$t=new k({props:{code:`from transformers import AdamW

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

optimizer = AdamW(model.parameters(), lr=<span class="hljs-number">5e-5</span>)`}}),yt=new k({props:{code:`from transformers import get_scheduler

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

num_epochs = <span class="hljs-number">3</span>
num_training_steps = num_epochs * <span class="hljs-built_in">len</span>(train_dataloader)
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,
)
<span class="hljs-built_in">print</span>(num_training_steps)`}}),wt=new k({props:{code:"1377",highlighted:'<span class="hljs-number">1377</span>'}}),jt=new Vn({}),Et=new k({props:{code:`import torch

device = torch.device("cuda") if torch.cuda.is_available() else torch.device("cpu")
model.to(device)
device`,highlighted:`<span class="hljs-keyword">import</span> torch

device = torch.device(<span class="hljs-string">&quot;cuda&quot;</span>) <span class="hljs-keyword">if</span> torch.cuda.is_available() <span class="hljs-keyword">else</span> torch.device(<span class="hljs-string">&quot;cpu&quot;</span>)
model.to(device)
device`}}),qt=new k({props:{code:"device(type='cuda')",highlighted:'device(<span class="hljs-built_in">type</span>=<span class="hljs-string">&#x27;cuda&#x27;</span>)'}}),zt=new k({props:{code:`from tqdm.auto import tqdm

progress_bar = tqdm(range(num_training_steps))

model.train()
for epoch in range(num_epochs):
    for batch in train_dataloader:
        batch = {k: v.to(device) for k, v in batch.items()}
        outputs = model(**batch)
        loss = outputs.loss
        loss.backward()

        optimizer.step()
        lr_scheduler.step()
        optimizer.zero_grad()
        progress_bar.update(1)`,highlighted:`<span class="hljs-keyword">from</span> tqdm.auto <span class="hljs-keyword">import</span> tqdm

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

model.train()
<span class="hljs-keyword">for</span> epoch <span class="hljs-keyword">in</span> <span class="hljs-built_in">range</span>(num_epochs):
    <span class="hljs-keyword">for</span> batch <span class="hljs-keyword">in</span> train_dataloader:
        batch = {k: v.to(device) <span class="hljs-keyword">for</span> k, v <span class="hljs-keyword">in</span> batch.items()}
        outputs = model(**batch)
        loss = outputs.loss
        loss.backward()

        optimizer.step()
        lr_scheduler.step()
        optimizer.zero_grad()
        progress_bar.update(<span class="hljs-number">1</span>)`}}),Ct=new Vn({}),xt=new k({props:{code:`import evaluate

metric = evaluate.load("glue", "mrpc")
model.eval()
for batch in eval_dataloader:
    batch = {k: v.to(device) for k, v in batch.items()}
    with torch.no_grad():
        outputs = model(**batch)

    logits = outputs.logits
    predictions = torch.argmax(logits, dim=-1)
    metric.add_batch(predictions=predictions, references=batch["labels"])

metric.compute()`,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>)
model.<span class="hljs-built_in">eval</span>()
<span class="hljs-keyword">for</span> batch <span class="hljs-keyword">in</span> eval_dataloader:
    batch = {k: v.to(device) <span class="hljs-keyword">for</span> k, v <span class="hljs-keyword">in</span> batch.items()}
    <span class="hljs-keyword">with</span> torch.no_grad():
        outputs = model(**batch)

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

metric.compute()`}}),At=new k({props:{code:"{'accuracy': 0.8431372549019608, 'f1': 0.8907849829351535}",highlighted:'{<span class="hljs-string">&#x27;accuracy&#x27;</span>: <span class="hljs-number">0.8431372549019608</span>, <span class="hljs-string">&#x27;f1&#x27;</span>: <span class="hljs-number">0.8907849829351535</span>}'}}),Y=new fr({props:{$$slots:{default:[jr]},$$scope:{ctx:Bt}}}),Pt=new Vn({}),Tt=new _r({props:{id:"s7dy8QRgjJ0"}}),St=new k({props:{code:`from transformers import AdamW, AutoModelForSequenceClassification, get_scheduler

model = AutoModelForSequenceClassification.from_pretrained(checkpoint, num_labels=2)
optimizer = AdamW(model.parameters(), lr=3e-5)

device = torch.device("cuda") if torch.cuda.is_available() else torch.device("cpu")
model.to(device)

num_epochs = 3
num_training_steps = num_epochs * len(train_dataloader)
lr_scheduler = get_scheduler(
    "linear",
    optimizer=optimizer,
    num_warmup_steps=0,
    num_training_steps=num_training_steps,
)

progress_bar = tqdm(range(num_training_steps))

model.train()
for epoch in range(num_epochs):
    for batch in train_dataloader:
        batch = {k: v.to(device) for k, v in batch.items()}
        outputs = model(**batch)
        loss = outputs.loss
        loss.backward()

        optimizer.step()
        lr_scheduler.step()
        optimizer.zero_grad()
        progress_bar.update(1)`,highlighted:`<span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AdamW, AutoModelForSequenceClassification, get_scheduler

model = AutoModelForSequenceClassification.from_pretrained(checkpoint, num_labels=<span class="hljs-number">2</span>)
optimizer = AdamW(model.parameters(), lr=<span class="hljs-number">3e-5</span>)

device = torch.device(<span class="hljs-string">&quot;cuda&quot;</span>) <span class="hljs-keyword">if</span> torch.cuda.is_available() <span class="hljs-keyword">else</span> torch.device(<span class="hljs-string">&quot;cpu&quot;</span>)
model.to(device)

num_epochs = <span class="hljs-number">3</span>
num_training_steps = num_epochs * <span class="hljs-built_in">len</span>(train_dataloader)
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,
)

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

model.train()
<span class="hljs-keyword">for</span> epoch <span class="hljs-keyword">in</span> <span class="hljs-built_in">range</span>(num_epochs):
    <span class="hljs-keyword">for</span> batch <span class="hljs-keyword">in</span> train_dataloader:
        batch = {k: v.to(device) <span class="hljs-keyword">for</span> k, v <span class="hljs-keyword">in</span> batch.items()}
        outputs = model(**batch)
        loss = outputs.loss
        loss.backward()

        optimizer.step()
        lr_scheduler.step()
        optimizer.zero_grad()
        progress_bar.update(<span class="hljs-number">1</span>)`}}),Ot=new k({props:{code:`+ from accelerate import Accelerator
  from transformers import AdamW, AutoModelForSequenceClassification, get_scheduler

+ accelerator = Accelerator()

  model = AutoModelForSequenceClassification.from_pretrained(checkpoint, num_labels=2)
  optimizer = AdamW(model.parameters(), lr=3e-5)

- device = torch.device("cuda") if torch.cuda.is_available() else torch.device("cpu")
- model.to(device)

+ train_dataloader, eval_dataloader, model, optimizer = accelerator.prepare(
+     train_dataloader, eval_dataloader, model, optimizer
+ )

  num_epochs = 3
  num_training_steps = num_epochs * len(train_dataloader)
  lr_scheduler = get_scheduler(
      "linear",
      optimizer=optimizer,
      num_warmup_steps=0,
      num_training_steps=num_training_steps
  )

  progress_bar = tqdm(range(num_training_steps))

  model.train()
  for epoch in range(num_epochs):
      for batch in train_dataloader:
-         batch = {k: v.to(device) for k, v in batch.items()}
          outputs = model(**batch)
          loss = outputs.loss
-         loss.backward()
+         accelerator.backward(loss)

          optimizer.step()
          lr_scheduler.step()
          optimizer.zero_grad()
          progress_bar.update(1)`,highlighted:`<span class="hljs-addition">+ from accelerate import Accelerator</span>
  from transformers import AdamW, AutoModelForSequenceClassification, get_scheduler

<span class="hljs-addition">+ accelerator = Accelerator()</span>

  model = AutoModelForSequenceClassification.from_pretrained(checkpoint, num_labels=2)
  optimizer = AdamW(model.parameters(), lr=3e-5)

<span class="hljs-deletion">- device = torch.device(&quot;cuda&quot;) if torch.cuda.is_available() else torch.device(&quot;cpu&quot;)</span>
<span class="hljs-deletion">- model.to(device)</span>

<span class="hljs-addition">+ train_dataloader, eval_dataloader, model, optimizer = accelerator.prepare(</span>
<span class="hljs-addition">+     train_dataloader, eval_dataloader, model, optimizer</span>
<span class="hljs-addition">+ )</span>

  num_epochs = 3
  num_training_steps = num_epochs * len(train_dataloader)
  lr_scheduler = get_scheduler(
      &quot;linear&quot;,
      optimizer=optimizer,
      num_warmup_steps=0,
      num_training_steps=num_training_steps
  )

  progress_bar = tqdm(range(num_training_steps))

  model.train()
  for epoch in range(num_epochs):
      for batch in train_dataloader:
<span class="hljs-deletion">-         batch = {k: v.to(device) for k, v in batch.items()}</span>
          outputs = model(**batch)
          loss = outputs.loss
<span class="hljs-deletion">-         loss.backward()</span>
<span class="hljs-addition">+         accelerator.backward(loss)</span>

          optimizer.step()
          lr_scheduler.step()
          optimizer.zero_grad()
          progress_bar.update(1)`}}),tt=new fr({props:{$$slots:{default:[Er]},$$scope:{ctx:Bt}}}),Mt=new k({props:{code:`from accelerate import Accelerator
from transformers import AdamW, AutoModelForSequenceClassification, get_scheduler

accelerator = Accelerator()

model = AutoModelForSequenceClassification.from_pretrained(checkpoint, num_labels=2)
optimizer = AdamW(model.parameters(), lr=3e-5)

train_dl, eval_dl, model, optimizer = accelerator.prepare(
    train_dataloader, eval_dataloader, model, optimizer
)

num_epochs = 3
num_training_steps = num_epochs * len(train_dl)
lr_scheduler = get_scheduler(
    "linear",
    optimizer=optimizer,
    num_warmup_steps=0,
    num_training_steps=num_training_steps,
)

progress_bar = tqdm(range(num_training_steps))

model.train()
for epoch in range(num_epochs):
    for batch in train_dl:
        outputs = model(**batch)
        loss = outputs.loss
        accelerator.backward(loss)

        optimizer.step()
        lr_scheduler.step()
        optimizer.zero_grad()
        progress_bar.update(1)`,highlighted:`<span class="hljs-keyword">from</span> accelerate <span class="hljs-keyword">import</span> Accelerator
<span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AdamW, AutoModelForSequenceClassification, get_scheduler

accelerator = Accelerator()

model = AutoModelForSequenceClassification.from_pretrained(checkpoint, num_labels=<span class="hljs-number">2</span>)
optimizer = AdamW(model.parameters(), lr=<span class="hljs-number">3e-5</span>)

train_dl, eval_dl, model, optimizer = accelerator.prepare(
    train_dataloader, eval_dataloader, model, optimizer
)

num_epochs = <span class="hljs-number">3</span>
num_training_steps = num_epochs * <span class="hljs-built_in">len</span>(train_dl)
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,
)

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

model.train()
<span class="hljs-keyword">for</span> epoch <span class="hljs-keyword">in</span> <span class="hljs-built_in">range</span>(num_epochs):
    <span class="hljs-keyword">for</span> batch <span class="hljs-keyword">in</span> train_dl:
        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>)`}}),Nt=new k({props:{code:"accelerate config",highlighted:"accelerate config"}}),Wt=new k({props:{code:"accelerate launch train.py",highlighted:'accelerate <span class="hljs-built_in">launch</span> train.py'}}),Lt=new k({props:{code:`from accelerate import notebook_launcher

notebook_launcher(training_function)`,highlighted:`<span class="hljs-keyword">from</span> accelerate <span class="hljs-keyword">import</span> notebook_launcher

notebook_launcher(training_function)`}}),{c(){b=c("meta"),w=h(),$=c("h1"),q=c("a"),O=c("span"),u(E.$$.fragment),P=h(),F=c("span"),us=a("B\u1EA3n hu\u1EA5n luy\u1EC7n ho\xE0n ch\u1EC9nh"),Hn=h(),u(ct.$$.fragment),In=h(),u(ot.$$.fragment),Rn=h(),B=c("p"),ms=a("B\xE2y gi\u1EDD ch\xFAng ta s\u1EBD xem c\xE1ch \u0111\u1EA1t \u0111\u01B0\u1EE3c k\u1EBFt qu\u1EA3 t\u01B0\u01A1ng t\u1EF1 nh\u01B0 ch\xFAng ta \u0111\xE3 l\xE0m trong ph\u1EA7n tr\u01B0\u1EDBc m\xE0 kh\xF4ng c\u1EA7n s\u1EED d\u1EE5ng l\u1EDBp "),sn=c("code"),ds=a("Trainer"),gs=a(". M\u1ED9t l\u1EA7n n\u1EEFa, ch\xFAng t\xF4i gi\u1EA3 s\u1EED b\u1EA1n \u0111\xE3 th\u1EF1c hi\u1EC7n b\u01B0\u1EDBc x\u1EED l\xFD d\u1EEF li\u1EC7u trong ph\u1EA7n 2. D\u01B0\u1EDBi \u0111\xE2y l\xE0 m\u1ED9t b\u1EA3n t\xF3m t\u1EAFt ng\u1EAFn bao g\u1ED3m m\u1ECDi th\u1EE9 b\u1EA1n c\u1EA7n:"),Jn=h(),u(it.$$.fragment),Kn=h(),M=c("h3"),G=c("a"),an=c("span"),u(ht.$$.fragment),fs=h(),ln=c("span"),_s=a("Chu\u1EA9n b\u1ECB cho hu\u1EA5n luy\u1EC7n"),Xn=h(),T=c("p"),vs=a("Tr\u01B0\u1EDBc khi th\u1EF1c s\u1EF1 vi\u1EBFt v\xF2ng l\u1EB7p hu\u1EA5n luy\u1EC7n c\u1EE7a m\xECnh, ch\xFAng ta s\u1EBD c\u1EA7n x\xE1c \u0111\u1ECBnh m\u1ED9t v\xE0i \u0111\u1ED1i t\u01B0\u1EE3ng. \u0110\u1EA7u ti\xEAn l\xE0 b\u1ED9 d\u1EEF li\u1EC7u dataloader m\xE0 ch\xFAng t\xF4i s\u1EBD s\u1EED d\u1EE5ng \u0111\u1EC3 l\u1EB7p qua c\xE1c l\xF4. Nh\u01B0ng tr\u01B0\u1EDBc khi ch\xFAng ta c\xF3 th\u1EC3 x\xE1c \u0111\u1ECBnh c\xE1c b\u1ED9 d\u1EEF li\u1EC7u \u0111\xF3, ch\xFAng ta c\u1EA7n \xE1p d\u1EE5ng m\u1ED9t ch\xFAt h\u1EADu x\u1EED l\xFD cho "),rn=c("code"),bs=a("tokenized_datasets"),ks=a(" c\u1EE7a m\xECnh, \u0111\u1EC3 x\u1EED l\xFD m\u1ED9t s\u1ED1 th\u1EE9 m\xE0 "),cn=c("code"),$s=a("Trainer"),ys=a(" \u0111\xE3 l\xE0m cho ch\xFAng ta m\u1ED9t c\xE1ch t\u1EF1 \u0111\u1ED9ng. C\u1EE5 th\u1EC3, ch\xFAng ta c\u1EA7n:"),Yn=h(),D=c("ul"),N=c("li"),ws=a("Lo\u1EA1i b\u1ECF c\xE1c c\u1ED9t t\u01B0\u01A1ng \u1EE9ng v\u1EDBi c\xE1c gi\xE1 tr\u1ECB m\xE0 m\xF4 h\xECnh kh\xF4ng mong \u0111\u1EE3i (nh\u01B0 c\u1ED9t "),on=c("code"),js=a("sentence1"),Es=a(" v\xE0 "),hn=c("code"),qs=a("sentence2"),zs=a(")."),Cs=h(),A=c("li"),xs=a("\u0110\u1ED5i t\xEAn c\u1ED9t "),pn=c("code"),As=a("label"),Ps=a(" th\xE0nh "),un=c("code"),Ts=a("labels"),Ds=a(" (v\xEC m\xF4 h\xECnh mong \u0111\u1EE3i \u0111\u1ED1i s\u1ED1 \u0111\u01B0\u1EE3c \u0111\u1EB7t t\xEAn l\xE0 "),mn=c("code"),Ss=a("labels"),Os=a(")."),Ms=h(),dn=c("li"),Ns=a("\u0110\u1EB7t \u0111\u1ECBnh d\u1EA1ng c\u1EE7a b\u1ED9 d\u1EEF li\u1EC7u \u0111\u1EC3 ch\xFAng tr\u1EA3 v\u1EC1 c\xE1c tensor PyTorch thay v\xEC danh s\xE1ch."),Qn=h(),pt=c("p"),gn=c("code"),Ws=a("Tokenized_datasets"),Ls=a(" c\u1EE7a ch\xFAng ta c\xF3 ph\u01B0\u01A1ng th\u1EE9c cho m\u1ED7i b\u01B0\u1EDBc \u0111\xF3:"),Zn=h(),u(ut.$$.fragment),te=h(),Gt=c("p"),Us=a("Sau \u0111\xF3, ch\xFAng ta c\xF3 th\u1EC3 ki\u1EC3m tra xem k\u1EBFt qu\u1EA3 c\xF3 ch\u1EC9 c\xF3 c\xE1c c\u1ED9t m\xE0 m\xF4 h\xECnh c\u1EE7a ch\xFAng ta s\u1EBD ch\u1EA5p nh\u1EADn kh\xF4ng:"),ne=h(),u(mt.$$.fragment),ee=h(),Vt=c("p"),Fs=a("Xong r\u1ED3i, ch\xFAng ta c\xF3 th\u1EC3 d\u1EC5 d\xE0ng \u0111\u1ECBnh ngh\u0129a c\xE1c b\u1ED9 d\u1EEF li\u1EC7u c\u1EE7a m\xECnh:"),se=h(),u(dt.$$.fragment),ae=h(),Ht=c("p"),Bs=a("\u0110\u1EC3 nhanh ch\xF3ng ki\u1EC3m tra kh\xF4ng c\xF3 sai s\xF3t trong qu\xE1 tr\xECnh x\u1EED l\xFD d\u1EEF li\u1EC7u, ch\xFAng ta c\xF3 th\u1EC3 ki\u1EC3m tra m\u1ED9t l\xF4 nh\u01B0 sau:"),le=h(),u(gt.$$.fragment),re=h(),u(ft.$$.fragment),ce=h(),V=c("p"),Gs=a("L\u01B0u \xFD r\u1EB1ng c\xE1c h\xECnh d\u1EA1ng th\u1EF1c t\u1EBF c\xF3 th\u1EC3 s\u1EBD h\u01A1i kh\xE1c \u0111\u1ED1i v\u1EDBi b\u1EA1n v\xEC ch\xFAng t\xF4i \u0111\u1EB7t "),fn=c("code"),Vs=a("shuffle = True"),Hs=a(" cho dataloader hu\u1EA5n luy\u1EC7n v\xE0 ch\xFAng t\xF4i \u0111ang \u0111\u1EC7m \u0111\u1EBFn \u0111\u1ED9 d\xE0i t\u1ED1i \u0111a b\xEAn trong l\xF4."),oe=h(),It=c("p"),Is=a("B\xE2y gi\u1EDD ch\xFAng ta \u0111\xE3 ho\xE0n th\xE0nh vi\u1EC7c x\u1EED l\xFD tr\u01B0\u1EDBc d\u1EEF li\u1EC7u (m\u1ED9t m\u1EE5c ti\xEAu th\u1ECFa m\xE3n nh\u01B0ng kh\xF3 n\u1EAFm b\u1EAFt \u0111\u1ED1i v\u1EDBi b\u1EA5t k\u1EF3 ng\u01B0\u1EDDi th\u1EF1c h\xE0nh ML n\xE0o), h\xE3y chuy\u1EC3n sang m\xF4 h\xECnh th\xF4i. Ch\xFAng ta kh\u1EDFi t\u1EA1o n\xF3 ch\xEDnh x\xE1c nh\u01B0 \u0111\xE3 l\xE0m trong ph\u1EA7n tr\u01B0\u1EDBc:"),ie=h(),u(_t.$$.fragment),he=h(),Rt=c("p"),Rs=a("To make sure that everything will go smoothly during training, we pass our batch to this model:"),pe=h(),u(vt.$$.fragment),ue=h(),u(bt.$$.fragment),me=h(),H=c("p"),Js=a("T\u1EA5t c\u1EA3 c\xE1c m\xF4 h\xECnh \u{1F917} Transformers s\u1EBD tr\u1EA3 v\u1EC1 l\u01B0\u1EE3ng m\u1EA5t m\xE1t khi "),_n=c("code"),Ks=a("labels"),Xs=a(" \u0111\u01B0\u1EE3c cung c\u1EA5p v\xE0 ch\xFAng ta c\u0169ng nh\u1EADn \u0111\u01B0\u1EE3c logit (hai cho m\u1ED7i \u0111\u1EA7u v\xE0o trong l\xF4, do \u0111\xF3, m\u1ED9t tensor c\xF3 k\xEDch th\u01B0\u1EDBc 8 x 2)."),de=h(),j=c("p"),Ys=a("Ch\xFAng ta g\u1EA7n nh\u01B0 \u0111\xE3 s\u1EB5n s\xE0ng \u0111\u1EC3 vi\u1EBFt v\xF2ng l\u1EB7p hu\u1EA5n luy\u1EC7n c\u1EE7a m\xECnh! Ch\xFAng ta ch\u1EC9 thi\u1EBFu hai th\u1EE9: m\u1ED9t tr\xECnh t\u1ED1i \u01B0u h\xF3a v\xE0 m\u1ED9t c\xF4ng c\u1EE5 l\u1EADp l\u1ECBch t\u1ED1c \u0111\u1ED9 h\u1ECDc t\u1EADp. V\xEC ch\xFAng ta \u0111ang c\u1ED1 g\u1EAFng t\xE1i t\u1EA1o nh\u1EEFng g\xEC m\xE0 "),vn=c("code"),Qs=a("Trainer"),Zs=a(" \u0111\xE3 l\xE0m b\u1EB1ng tay, n\xEAn ta s\u1EBD s\u1EED d\u1EE5ng c\xE1c gi\xE1 tr\u1ECB m\u1EB7c \u0111\u1ECBnh t\u01B0\u01A1ng t\u1EF1. Tr\xECnh t\u1ED1i \u01B0u h\xF3a \u0111\u01B0\u1EE3c s\u1EED d\u1EE5ng b\u1EDFi "),bn=c("code"),ta=a("Trainer"),na=a(" l\xE0 "),kn=c("code"),ea=a("AdamW"),sa=a(", t\u01B0\u01A1ng t\u1EF1 nh\u01B0 Adam, nh\u01B0ng c\xF3 m\u1ED9t b\u01B0\u1EDBc ngo\u1EB7t \u0111\u1EC3 \u0111i\u1EC1u ch\u1EC9nh ph\xE2n r\xE3 tr\u1ECDng s\u1ED1 (xem "),kt=c("a"),aa=a("\u201CDecoupled Weight Decay Regularization\u201D"),la=a(" c\u1EE7a Ilya Loshchilov v\xE0 Frank Hutter):"),ge=h(),u($t.$$.fragment),fe=h(),I=c("p"),ra=a("Cu\u1ED1i c\xF9ng, b\u1ED9 l\u1EADp l\u1ECBch t\u1ED1c \u0111\u1ED9 h\u1ECDc \u0111\u01B0\u1EE3c s\u1EED d\u1EE5ng theo m\u1EB7c \u0111\u1ECBnh ch\u1EC9 l\xE0 m\u1ED9t ph\xE2n r\xE3 tuy\u1EBFn t\xEDnh t\u1EEB gi\xE1 tr\u1ECB l\u1EDBn nh\u1EA5t (5e-5) xu\u1ED1ng 0. \u0110\u1EC3 x\xE1c \u0111\u1ECBnh \u0111\xFAng, ch\xFAng ta c\u1EA7n bi\u1EBFt s\u1ED1 b\u01B0\u1EDBc hu\u1EA5n luy\u1EC7n s\u1EBD th\u1EF1c hi\u1EC7n, \u0111\xF3 l\xE0 s\u1ED1 epoch mu\u1ED1n ch\u1EA1y nh\xE2n v\u1EDBi s\u1ED1 l\xF4 hu\u1EA5n luy\u1EC7n (l\xE0 \u0111\u1ED9 d\xE0i c\u1EE7a b\u1ED9 d\u1EEF li\u1EC7u hu\u1EA5n luy\u1EC7n). "),$n=c("code"),ca=a("Trainer"),oa=a(" s\u1EED d\u1EE5ng ba epoch theo m\u1EB7c \u0111\u1ECBnh, v\xEC v\u1EADy ch\xFAng t\xF4i s\u1EBD tu\xE2n theo \u0111i\u1EC1u \u0111\xF3:"),_e=h(),u(yt.$$.fragment),ve=h(),u(wt.$$.fragment),be=h(),W=c("h3"),R=c("a"),yn=c("span"),u(jt.$$.fragment),ia=h(),wn=c("span"),ha=a("V\xF2ng l\u1EB7p hu\u1EA5n luy\u1EC7n"),ke=h(),J=c("p"),pa=a("M\u1ED9t \u0111i\u1EC1u cu\u1ED1i c\xF9ng: ch\xFAng ta s\u1EBD mu\u1ED1n s\u1EED d\u1EE5ng GPU n\u1EBFu c\xF3 quy\u1EC1n truy c\u1EADp v\xE0o m\u1ED9t GPU (tr\xEAn CPU, qu\xE1 tr\xECnh hu\u1EA5n luy\u1EC7n c\xF3 th\u1EC3 m\u1EA5t v\xE0i gi\u1EDD thay v\xEC v\xE0i ph\xFAt). \u0110\u1EC3 l\xE0m \u0111i\u1EC1u n\xE0y, ch\xFAng ta x\xE1c \u0111\u1ECBnh m\u1ED9t "),jn=c("code"),ua=a("device"),ma=a(", ta s\u1EBD \u0111\u1EB7t m\xF4 h\xECnh v\xE0 c\xE1c l\xF4 c\u1EE7a ta tr\xEAn \u0111\xF3:"),$e=h(),u(Et.$$.fragment),ye=h(),u(qt.$$.fragment),we=h(),K=c("p"),da=a("Gi\u1EDD th\xEC ta \u0111\xE3 s\u1EB5n s\xE0ng \u0111\u1EC3 hu\u1EA5n luy\u1EC7n r\u1ED3i! \u0110\u1EC3 bi\u1EBFt khi n\xE0o qu\xE1 tr\xECnh hu\u1EA5n luy\u1EC7n s\u1EBD k\u1EBFt th\xFAc, ta th\xEAm thanh ti\u1EBFn tr\xECnh qua s\u1ED1 b\u01B0\u1EDBc hu\u1EA5n luy\u1EC7n, s\u1EED d\u1EE5ng th\u01B0 vi\u1EC7n "),En=c("code"),ga=a("tqdm"),fa=a(":"),je=h(),u(zt.$$.fragment),Ee=h(),Jt=c("p"),_a=a("B\u1EA1n c\xF3 th\u1EC3 th\u1EA5y r\u1EB1ng c\u1ED1t l\xF5i c\u1EE7a v\xF2ng l\u1EB7p hu\u1EA5n luy\u1EC7n tr\xF4ng r\u1EA5t gi\u1ED1ng nh\u01B0 trong ph\u1EA7n gi\u1EDBi thi\u1EC7u. Ch\xFAng ta \u0111\xE3 kh\xF4ng y\xEAu c\u1EA7u b\u1EA5t k\u1EF3 b\xE1o c\xE1o n\xE0o, v\xEC v\u1EADy v\xF2ng hu\u1EA5n luy\u1EC7n n\xE0y s\u1EBD kh\xF4ng cho ta bi\u1EBFt b\u1EA5t k\u1EF3 \u0111i\u1EC1u g\xEC v\u1EC1 c\xE1i gi\xE1 c\u1EE7a m\xF4 h\xECnh. Ch\xFAng ta c\u1EA7n th\xEAm m\u1ED9t v\xF2ng l\u1EB7p \u0111\xE1nh gi\xE1 cho \u0111i\u1EC1u \u0111\xF3."),qe=h(),L=c("h3"),X=c("a"),qn=c("span"),u(Ct.$$.fragment),va=h(),zn=c("span"),ba=a("V\xF2ng l\u1EB7p \u0111\xE1nh gi\xE1"),ze=h(),z=c("p"),ka=a("Nh\u01B0 \u0111\xE3 l\xE0m tr\u01B0\u1EDBc \u0111\xF3, ch\xFAng ta s\u1EBD s\u1EED d\u1EE5ng m\u1ED9t ch\u1EC9 s\u1ED1 \u0111\u01B0\u1EE3c cung c\u1EA5p b\u1EDFi th\u01B0 vi\u1EC7n \u{1F917} Evaluate. Ch\xFAng ta \u0111\xE3 th\u1EA5y ph\u01B0\u01A1ng th\u1EE9c "),Cn=c("code"),$a=a("metric.compute()"),ya=a(", c\xE1c ch\u1EC9 s\u1ED1 th\u1EF1c s\u1EF1 c\xF3 th\u1EC3 t\xEDch l\u0169y c\xE1c l\xF4 cho ta khi xem qua v\xF2ng d\u1EF1 \u0111o\xE1n v\u1EDBi ph\u01B0\u01A1ng th\u1EE9c "),xn=c("code"),wa=a("add_batch()"),ja=a(". Khi ta \u0111\xE3 t\xEDch l\u0169y t\u1EA5t c\u1EA3 c\xE1c l\xF4, ch\xFAng ta c\xF3 th\u1EC3 nh\u1EADn \u0111\u01B0\u1EE3c k\u1EBFt qu\u1EA3 cu\u1ED1i c\xF9ng v\u1EDBi "),An=c("code"),Ea=a("metric.compute()"),qa=a(". D\u01B0\u1EDBi \u0111\xE2y l\xE0 c\xE1ch th\u1EF1c hi\u1EC7n t\u1EA5t c\u1EA3 nh\u1EEFng \u0111i\u1EC1u n\xE0y trong m\u1ED9t v\xF2ng l\u1EB7p \u0111\xE1nh gi\xE1:"),Ce=h(),u(xt.$$.fragment),xe=h(),u(At.$$.fragment),Ae=h(),Kt=c("p"),za=a("M\u1ED9t l\u1EA7n n\u1EEFa, k\u1EBFt qu\u1EA3 c\u1EE7a b\u1EA1n s\u1EBD h\u01A1i kh\xE1c m\u1ED9t ch\xFAt v\xEC s\u1EF1 ng\u1EABu nhi\xEAn trong qu\xE1 tr\xECnh kh\u1EDFi t\u1EA1o \u0111\u1EA7u m\xF4 h\xECnh v\xE0 x\xE1o tr\u1ED9n d\u1EEF li\u1EC7u, nh\u01B0ng ch\xFAng ph\u1EA3i \u1EDF trong c\xF9ng m\u1ED9t kho\u1EA3ng."),Pe=h(),u(Y.$$.fragment),Te=h(),U=c("h3"),Q=c("a"),Pn=c("span"),u(Pt.$$.fragment),Ca=h(),Tn=c("span"),xa=a("T\u0103ng c\u01B0\u1EDDng tr\xED th\xF4ng minh c\u1EE7a v\xF2ng hu\u1EA5n luy\u1EC7n v\u1EDBi \u{1F917} Accelerate"),De=h(),u(Tt.$$.fragment),Se=h(),Z=c("p"),Aa=a("V\xF2ng l\u1EB7p hu\u1EA5n luy\u1EC7n m\xE0 ta \u0111\xE3 \u0111\u1ECBnh ngh\u0129a tr\u01B0\u1EDBc \u0111\xF3 ho\u1EA1t \u0111\u1ED9ng t\u1ED1t tr\xEAn m\u1ED9t CPU ho\u1EB7c GPU. Nh\u01B0ng b\u1EB1ng c\xE1ch s\u1EED d\u1EE5ng th\u01B0 vi\u1EC7n "),Dt=c("a"),Pa=a("\u{1F917} Accelerate"),Ta=a(", ch\u1EC9 v\u1EDBi m\u1ED9t v\xE0i \u0111i\u1EC1u ch\u1EC9nh, ch\xFAng ta c\xF3 th\u1EC3 hu\u1EA5n luy\u1EC7n ph\xE2n t\xE1n tr\xEAn nhi\u1EC1u GPU ho\u1EB7c TPU. B\u1EAFt \u0111\u1EA7u t\u1EEB vi\u1EC7c t\u1EA1o b\u1ED9 d\u1EEF li\u1EC7u hu\u1EA5n luy\u1EC7n v\xE0 ki\u1EC3m \u0111\u1ECBnh, \u0111\xE2y l\xE0 v\xF2ng l\u1EB7p hu\u1EA5n luy\u1EC7n th\u1EE7 c\xF4ng th\u1EF1c thi:"),Oe=h(),u(St.$$.fragment),Me=h(),Xt=c("p"),Da=a("V\xE0 \u0111\xE2y l\xE0 m\u1ED9t s\u1ED1 thay \u0111\u1ED5i:"),Ne=h(),u(Ot.$$.fragment),We=h(),C=c("p"),Sa=a("D\xF2ng \u0111\u1EA7u ti\xEAn c\u1EA7n th\xEAm l\xE0 d\xF2ng nh\u1EADp. D\xF2ng th\u1EE9 hai kh\u1EDFi t\u1EA1o m\u1ED9t \u0111\u1ED1i t\u01B0\u1EE3ng "),Dn=c("code"),Oa=a("Accelerator"),Ma=a(" s\u1EBD xem x\xE9t m\xF4i tr\u01B0\u1EDDng v\xE0 kh\u1EDFi t\u1EA1o thi\u1EBFt l\u1EADp ph\xE2n t\xE1n th\xEDch h\u1EE3p. \u{1F917} Accelerate x\u1EED l\xFD v\u1ECB tr\xED \u0111\u1EB7t thi\u1EBFt b\u1ECB cho b\u1EA1n, v\xEC v\u1EADy b\u1EA1n c\xF3 th\u1EC3 x\xF3a c\xE1c d\xF2ng \u0111\u1EB7t m\xF4 h\xECnh tr\xEAn thi\u1EBFt b\u1ECB (ho\u1EB7c, n\u1EBFu b\u1EA1n th\xEDch, h\xE3y thay \u0111\u1ED5i ch\xFAng \u0111\u1EC3 s\u1EED d\u1EE5ng "),Sn=c("code"),Na=a("accelerator.device"),Wa=a(" thay v\xEC "),On=c("code"),La=a("device"),Ua=a(")."),Le=h(),y=c("p"),Fa=a("Sau \u0111\xF3, ph\u1EA7n l\u1EDBn c\xF4ng vi\u1EC7c ch\xEDnh \u0111\u01B0\u1EE3c th\u1EF1c hi\u1EC7n trong d\xF2ng g\u1EEDi b\u1ED9 l\u01B0u d\u1EEF li\u1EC7u, m\xF4 h\xECnh v\xE0 tr\xECnh t\u1ED1i \u01B0u h\xF3a \u0111\u1EBFn "),Mn=c("code"),Ba=a("accelerator.prepare()"),Ga=a(". Thao t\xE1c n\xE0y s\u1EBD b\u1ECDc c\xE1c \u0111\u1ED1i t\u01B0\u1EE3ng \u0111\xF3 trong h\u1ED9p ch\u1EE9a th\xEDch h\u1EE3p \u0111\u1EC3 \u0111\u1EA3m b\u1EA3o vi\u1EC7c hu\u1EA5n luy\u1EC7n \u0111\u01B0\u1EE3c ph\xE2n ph\u1ED1i ho\u1EA1t \u0111\u1ED9ng nh\u01B0 d\u1EF1 \u0111\u1ECBnh. C\xE1c thay \u0111\u1ED5i c\xF2n l\u1EA1i c\u1EA7n th\u1EF1c hi\u1EC7n l\xE0 lo\u1EA1i b\u1ECF d\xF2ng \u0111\u1EB7t l\xF4 tr\xEAn "),Nn=c("code"),Va=a("device"),Ha=a(" (m\u1ED9t l\u1EA7n n\u1EEFa, n\u1EBFu b\u1EA1n mu\u1ED1n gi\u1EEF l\u1EA1i \u0111i\u1EC1u n\xE0y, b\u1EA1n ch\u1EC9 c\u1EA7n thay \u0111\u1ED5i n\xF3 th\xE0nh s\u1EED d\u1EE5ng "),Wn=c("code"),Ia=a("accelerator.device"),Ra=a(") v\xE0 thay th\u1EBF "),Ln=c("code"),Ja=a("loss.backward()"),Ka=a(" b\u1EB1ng  "),Un=c("code"),Xa=a("accelerator.backward(loss)"),Ya=a("."),Ue=h(),u(tt.$$.fragment),Fe=h(),Yt=c("p"),Qa=a("N\u1EBFu b\u1EA1n mu\u1ED1n sao ch\xE9p v\xE0 d\xE1n n\xF3 \u0111\u1EC3 m\xE0y m\xF2, \u0111\xE2y l\xE0 giao di\u1EC7n c\u1EE7a v\xF2ng hu\u1EA5n luy\u1EC7n ho\xE0n ch\u1EC9nh v\u1EDBi \u{1F917} Accelerate:"),Be=h(),u(Mt.$$.fragment),Ge=h(),nt=c("p"),Za=a("\u0110\u1EB7t \u0111i\u1EC1u n\xE0y trong "),Fn=c("code"),tl=a("train.py"),nl=a(" s\u1EBD l\xE0m cho t\u1EADp l\u1EC7nh \u0111\xF3 c\xF3 th\u1EC3 ch\u1EA1y \u0111\u01B0\u1EE3c tr\xEAn b\u1EA5t k\u1EF3 lo\u1EA1i thi\u1EBFt l\u1EADp ph\xE2n t\xE1n n\xE0o. \u0110\u1EC3 d\xF9ng th\u1EED trong thi\u1EBFt l\u1EADp ph\xE2n t\xE1n c\u1EE7a b\u1EA1n, h\xE3y ch\u1EA1y l\u1EC7nh:"),Ve=h(),u(Nt.$$.fragment),He=h(),Qt=c("p"),el=a("\u0111i\u1EC1u n\xE0y s\u1EBD nh\u1EAFc b\u1EA1n tr\u1EA3 l\u1EDDi m\u1ED9t s\u1ED1 c\xE2u h\u1ECFi v\xE0 tr\xEDch xu\u1EA5t c\xE2u tr\u1EA3 l\u1EDDi c\u1EE7a b\u1EA1n v\xE0o t\u1EC7p c\u1EA5u h\xECnh b\u1EDFi l\u1EC7nh sau:"),Ie=h(),u(Wt.$$.fragment),Re=h(),Zt=c("p"),sl=a("v\xE0 n\xF3 s\u1EBD kh\u1EDFi ch\u1EA1y ch\u01B0\u01A1ng tr\xECnh hu\u1EA5n luy\u1EC7n ph\xE2n t\xE1n."),Je=h(),et=c("p"),al=a("N\u1EBFu b\u1EA1n mu\u1ED1n th\u1EED \u0111i\u1EC1u n\xE0y trong Notebook (v\xED d\u1EE5: \u0111\u1EC3 ki\u1EC3m tra n\xF3 v\u1EDBi TPU tr\xEAn Colab), ch\u1EC9 c\u1EA7n d\xE1n \u0111o\u1EA1n m\xE3 v\xE0o "),Bn=c("code"),ll=a("training_function()"),rl=a(" v\xE0 ch\u1EA1y \xF4 cu\u1ED1i c\xF9ng v\u1EDBi:"),Ke=h(),u(Lt.$$.fragment),Xe=h(),st=c("p"),cl=a("B\u1EA1n c\xF3 th\u1EC3 t\xECm th\xEAm c\xE1c v\xED d\u1EE5 t\u1EA1i "),Ut=c("a"),ol=a("\u{1F917} Accelerate repo"),il=a("."),this.h()},l(t){const s=$r('[data-svelte="svelte-1phssyn"]',document.head);b=o(s,"META",{name:!0,content:!0}),s.forEach(n),w=p(t),$=o(t,"H1",{class:!0});var Ft=i($);q=o(Ft,"A",{id:!0,class:!0,href:!0});var Gn=i(q);O=o(Gn,"SPAN",{});var pl=i(O);m(E.$$.fragment,pl),pl.forEach(n),Gn.forEach(n),P=p(Ft),F=o(Ft,"SPAN",{});var ul=i(F);us=l(ul,"B\u1EA3n hu\u1EA5n luy\u1EC7n ho\xE0n ch\u1EC9nh"),ul.forEach(n),Ft.forEach(n),Hn=p(t),m(ct.$$.fragment,t),In=p(t),m(ot.$$.fragment,t),Rn=p(t),B=o(t,"P",{});var Qe=i(B);ms=l(Qe,"B\xE2y gi\u1EDD ch\xFAng ta s\u1EBD xem c\xE1ch \u0111\u1EA1t \u0111\u01B0\u1EE3c k\u1EBFt qu\u1EA3 t\u01B0\u01A1ng t\u1EF1 nh\u01B0 ch\xFAng ta \u0111\xE3 l\xE0m trong ph\u1EA7n tr\u01B0\u1EDBc m\xE0 kh\xF4ng c\u1EA7n s\u1EED d\u1EE5ng l\u1EDBp "),sn=o(Qe,"CODE",{});var ml=i(sn);ds=l(ml,"Trainer"),ml.forEach(n),gs=l(Qe,". M\u1ED9t l\u1EA7n n\u1EEFa, ch\xFAng t\xF4i gi\u1EA3 s\u1EED b\u1EA1n \u0111\xE3 th\u1EF1c hi\u1EC7n b\u01B0\u1EDBc x\u1EED l\xFD d\u1EEF li\u1EC7u trong ph\u1EA7n 2. D\u01B0\u1EDBi \u0111\xE2y l\xE0 m\u1ED9t b\u1EA3n t\xF3m t\u1EAFt ng\u1EAFn bao g\u1ED3m m\u1ECDi th\u1EE9 b\u1EA1n c\u1EA7n:"),Qe.forEach(n),Jn=p(t),m(it.$$.fragment,t),Kn=p(t),M=o(t,"H3",{class:!0});var Ze=i(M);G=o(Ze,"A",{id:!0,class:!0,href:!0});var dl=i(G);an=o(dl,"SPAN",{});var gl=i(an);m(ht.$$.fragment,gl),gl.forEach(n),dl.forEach(n),fs=p(Ze),ln=o(Ze,"SPAN",{});var fl=i(ln);_s=l(fl,"Chu\u1EA9n b\u1ECB cho hu\u1EA5n luy\u1EC7n"),fl.forEach(n),Ze.forEach(n),Xn=p(t),T=o(t,"P",{});var tn=i(T);vs=l(tn,"Tr\u01B0\u1EDBc khi th\u1EF1c s\u1EF1 vi\u1EBFt v\xF2ng l\u1EB7p hu\u1EA5n luy\u1EC7n c\u1EE7a m\xECnh, ch\xFAng ta s\u1EBD c\u1EA7n x\xE1c \u0111\u1ECBnh m\u1ED9t v\xE0i \u0111\u1ED1i t\u01B0\u1EE3ng. \u0110\u1EA7u ti\xEAn l\xE0 b\u1ED9 d\u1EEF li\u1EC7u dataloader m\xE0 ch\xFAng t\xF4i s\u1EBD s\u1EED d\u1EE5ng \u0111\u1EC3 l\u1EB7p qua c\xE1c l\xF4. Nh\u01B0ng tr\u01B0\u1EDBc khi ch\xFAng ta c\xF3 th\u1EC3 x\xE1c \u0111\u1ECBnh c\xE1c b\u1ED9 d\u1EEF li\u1EC7u \u0111\xF3, ch\xFAng ta c\u1EA7n \xE1p d\u1EE5ng m\u1ED9t ch\xFAt h\u1EADu x\u1EED l\xFD cho "),rn=o(tn,"CODE",{});var _l=i(rn);bs=l(_l,"tokenized_datasets"),_l.forEach(n),ks=l(tn," c\u1EE7a m\xECnh, \u0111\u1EC3 x\u1EED l\xFD m\u1ED9t s\u1ED1 th\u1EE9 m\xE0 "),cn=o(tn,"CODE",{});var vl=i(cn);$s=l(vl,"Trainer"),vl.forEach(n),ys=l(tn," \u0111\xE3 l\xE0m cho ch\xFAng ta m\u1ED9t c\xE1ch t\u1EF1 \u0111\u1ED9ng. C\u1EE5 th\u1EC3, ch\xFAng ta c\u1EA7n:"),tn.forEach(n),Yn=p(t),D=o(t,"UL",{});var nn=i(D);N=o(nn,"LI",{});var en=i(N);ws=l(en,"Lo\u1EA1i b\u1ECF c\xE1c c\u1ED9t t\u01B0\u01A1ng \u1EE9ng v\u1EDBi c\xE1c gi\xE1 tr\u1ECB m\xE0 m\xF4 h\xECnh kh\xF4ng mong \u0111\u1EE3i (nh\u01B0 c\u1ED9t "),on=o(en,"CODE",{});var bl=i(on);js=l(bl,"sentence1"),bl.forEach(n),Es=l(en," v\xE0 "),hn=o(en,"CODE",{});var kl=i(hn);qs=l(kl,"sentence2"),kl.forEach(n),zs=l(en,")."),en.forEach(n),Cs=p(nn),A=o(nn,"LI",{});var at=i(A);xs=l(at,"\u0110\u1ED5i t\xEAn c\u1ED9t "),pn=o(at,"CODE",{});var $l=i(pn);As=l($l,"label"),$l.forEach(n),Ps=l(at," th\xE0nh "),un=o(at,"CODE",{});var yl=i(un);Ts=l(yl,"labels"),yl.forEach(n),Ds=l(at," (v\xEC m\xF4 h\xECnh mong \u0111\u1EE3i \u0111\u1ED1i s\u1ED1 \u0111\u01B0\u1EE3c \u0111\u1EB7t t\xEAn l\xE0 "),mn=o(at,"CODE",{});var wl=i(mn);Ss=l(wl,"labels"),wl.forEach(n),Os=l(at,")."),at.forEach(n),Ms=p(nn),dn=o(nn,"LI",{});var jl=i(dn);Ns=l(jl,"\u0110\u1EB7t \u0111\u1ECBnh d\u1EA1ng c\u1EE7a b\u1ED9 d\u1EEF li\u1EC7u \u0111\u1EC3 ch\xFAng tr\u1EA3 v\u1EC1 c\xE1c tensor PyTorch thay v\xEC danh s\xE1ch."),jl.forEach(n),nn.forEach(n),Qn=p(t),pt=o(t,"P",{});var hl=i(pt);gn=o(hl,"CODE",{});var El=i(gn);Ws=l(El,"Tokenized_datasets"),El.forEach(n),Ls=l(hl," c\u1EE7a ch\xFAng ta c\xF3 ph\u01B0\u01A1ng th\u1EE9c cho m\u1ED7i b\u01B0\u1EDBc \u0111\xF3:"),hl.forEach(n),Zn=p(t),m(ut.$$.fragment,t),te=p(t),Gt=o(t,"P",{});var ql=i(Gt);Us=l(ql,"Sau \u0111\xF3, ch\xFAng ta c\xF3 th\u1EC3 ki\u1EC3m tra xem k\u1EBFt qu\u1EA3 c\xF3 ch\u1EC9 c\xF3 c\xE1c c\u1ED9t m\xE0 m\xF4 h\xECnh c\u1EE7a ch\xFAng ta s\u1EBD ch\u1EA5p nh\u1EADn kh\xF4ng:"),ql.forEach(n),ne=p(t),m(mt.$$.fragment,t),ee=p(t),Vt=o(t,"P",{});var zl=i(Vt);Fs=l(zl,"Xong r\u1ED3i, ch\xFAng ta c\xF3 th\u1EC3 d\u1EC5 d\xE0ng \u0111\u1ECBnh ngh\u0129a c\xE1c b\u1ED9 d\u1EEF li\u1EC7u c\u1EE7a m\xECnh:"),zl.forEach(n),se=p(t),m(dt.$$.fragment,t),ae=p(t),Ht=o(t,"P",{});var Cl=i(Ht);Bs=l(Cl,"\u0110\u1EC3 nhanh ch\xF3ng ki\u1EC3m tra kh\xF4ng c\xF3 sai s\xF3t trong qu\xE1 tr\xECnh x\u1EED l\xFD d\u1EEF li\u1EC7u, ch\xFAng ta c\xF3 th\u1EC3 ki\u1EC3m tra m\u1ED9t l\xF4 nh\u01B0 sau:"),Cl.forEach(n),le=p(t),m(gt.$$.fragment,t),re=p(t),m(ft.$$.fragment,t),ce=p(t),V=o(t,"P",{});var ts=i(V);Gs=l(ts,"L\u01B0u \xFD r\u1EB1ng c\xE1c h\xECnh d\u1EA1ng th\u1EF1c t\u1EBF c\xF3 th\u1EC3 s\u1EBD h\u01A1i kh\xE1c \u0111\u1ED1i v\u1EDBi b\u1EA1n v\xEC ch\xFAng t\xF4i \u0111\u1EB7t "),fn=o(ts,"CODE",{});var xl=i(fn);Vs=l(xl,"shuffle = True"),xl.forEach(n),Hs=l(ts," cho dataloader hu\u1EA5n luy\u1EC7n v\xE0 ch\xFAng t\xF4i \u0111ang \u0111\u1EC7m \u0111\u1EBFn \u0111\u1ED9 d\xE0i t\u1ED1i \u0111a b\xEAn trong l\xF4."),ts.forEach(n),oe=p(t),It=o(t,"P",{});var Al=i(It);Is=l(Al,"B\xE2y gi\u1EDD ch\xFAng ta \u0111\xE3 ho\xE0n th\xE0nh vi\u1EC7c x\u1EED l\xFD tr\u01B0\u1EDBc d\u1EEF li\u1EC7u (m\u1ED9t m\u1EE5c ti\xEAu th\u1ECFa m\xE3n nh\u01B0ng kh\xF3 n\u1EAFm b\u1EAFt \u0111\u1ED1i v\u1EDBi b\u1EA5t k\u1EF3 ng\u01B0\u1EDDi th\u1EF1c h\xE0nh ML n\xE0o), h\xE3y chuy\u1EC3n sang m\xF4 h\xECnh th\xF4i. Ch\xFAng ta kh\u1EDFi t\u1EA1o n\xF3 ch\xEDnh x\xE1c nh\u01B0 \u0111\xE3 l\xE0m trong ph\u1EA7n tr\u01B0\u1EDBc:"),Al.forEach(n),ie=p(t),m(_t.$$.fragment,t),he=p(t),Rt=o(t,"P",{});var Pl=i(Rt);Rs=l(Pl,"To make sure that everything will go smoothly during training, we pass our batch to this model:"),Pl.forEach(n),pe=p(t),m(vt.$$.fragment,t),ue=p(t),m(bt.$$.fragment,t),me=p(t),H=o(t,"P",{});var ns=i(H);Js=l(ns,"T\u1EA5t c\u1EA3 c\xE1c m\xF4 h\xECnh \u{1F917} Transformers s\u1EBD tr\u1EA3 v\u1EC1 l\u01B0\u1EE3ng m\u1EA5t m\xE1t khi "),_n=o(ns,"CODE",{});var Tl=i(_n);Ks=l(Tl,"labels"),Tl.forEach(n),Xs=l(ns," \u0111\u01B0\u1EE3c cung c\u1EA5p v\xE0 ch\xFAng ta c\u0169ng nh\u1EADn \u0111\u01B0\u1EE3c logit (hai cho m\u1ED7i \u0111\u1EA7u v\xE0o trong l\xF4, do \u0111\xF3, m\u1ED9t tensor c\xF3 k\xEDch th\u01B0\u1EDBc 8 x 2)."),ns.forEach(n),de=p(t),j=o(t,"P",{});var S=i(j);Ys=l(S,"Ch\xFAng ta g\u1EA7n nh\u01B0 \u0111\xE3 s\u1EB5n s\xE0ng \u0111\u1EC3 vi\u1EBFt v\xF2ng l\u1EB7p hu\u1EA5n luy\u1EC7n c\u1EE7a m\xECnh! Ch\xFAng ta ch\u1EC9 thi\u1EBFu hai th\u1EE9: m\u1ED9t tr\xECnh t\u1ED1i \u01B0u h\xF3a v\xE0 m\u1ED9t c\xF4ng c\u1EE5 l\u1EADp l\u1ECBch t\u1ED1c \u0111\u1ED9 h\u1ECDc t\u1EADp. V\xEC ch\xFAng ta \u0111ang c\u1ED1 g\u1EAFng t\xE1i t\u1EA1o nh\u1EEFng g\xEC m\xE0 "),vn=o(S,"CODE",{});var Dl=i(vn);Qs=l(Dl,"Trainer"),Dl.forEach(n),Zs=l(S," \u0111\xE3 l\xE0m b\u1EB1ng tay, n\xEAn ta s\u1EBD s\u1EED d\u1EE5ng c\xE1c gi\xE1 tr\u1ECB m\u1EB7c \u0111\u1ECBnh t\u01B0\u01A1ng t\u1EF1. Tr\xECnh t\u1ED1i \u01B0u h\xF3a \u0111\u01B0\u1EE3c s\u1EED d\u1EE5ng b\u1EDFi "),bn=o(S,"CODE",{});var Sl=i(bn);ta=l(Sl,"Trainer"),Sl.forEach(n),na=l(S," l\xE0 "),kn=o(S,"CODE",{});var Ol=i(kn);ea=l(Ol,"AdamW"),Ol.forEach(n),sa=l(S,", t\u01B0\u01A1ng t\u1EF1 nh\u01B0 Adam, nh\u01B0ng c\xF3 m\u1ED9t b\u01B0\u1EDBc ngo\u1EB7t \u0111\u1EC3 \u0111i\u1EC1u ch\u1EC9nh ph\xE2n r\xE3 tr\u1ECDng s\u1ED1 (xem "),kt=o(S,"A",{href:!0,rel:!0});var Ml=i(kt);aa=l(Ml,"\u201CDecoupled Weight Decay Regularization\u201D"),Ml.forEach(n),la=l(S," c\u1EE7a Ilya Loshchilov v\xE0 Frank Hutter):"),S.forEach(n),ge=p(t),m($t.$$.fragment,t),fe=p(t),I=o(t,"P",{});var es=i(I);ra=l(es,"Cu\u1ED1i c\xF9ng, b\u1ED9 l\u1EADp l\u1ECBch t\u1ED1c \u0111\u1ED9 h\u1ECDc \u0111\u01B0\u1EE3c s\u1EED d\u1EE5ng theo m\u1EB7c \u0111\u1ECBnh ch\u1EC9 l\xE0 m\u1ED9t ph\xE2n r\xE3 tuy\u1EBFn t\xEDnh t\u1EEB gi\xE1 tr\u1ECB l\u1EDBn nh\u1EA5t (5e-5) xu\u1ED1ng 0. \u0110\u1EC3 x\xE1c \u0111\u1ECBnh \u0111\xFAng, ch\xFAng ta c\u1EA7n bi\u1EBFt s\u1ED1 b\u01B0\u1EDBc hu\u1EA5n luy\u1EC7n s\u1EBD th\u1EF1c hi\u1EC7n, \u0111\xF3 l\xE0 s\u1ED1 epoch mu\u1ED1n ch\u1EA1y nh\xE2n v\u1EDBi s\u1ED1 l\xF4 hu\u1EA5n luy\u1EC7n (l\xE0 \u0111\u1ED9 d\xE0i c\u1EE7a b\u1ED9 d\u1EEF li\u1EC7u hu\u1EA5n luy\u1EC7n). "),$n=o(es,"CODE",{});var Nl=i($n);ca=l(Nl,"Trainer"),Nl.forEach(n),oa=l(es," s\u1EED d\u1EE5ng ba epoch theo m\u1EB7c \u0111\u1ECBnh, v\xEC v\u1EADy ch\xFAng t\xF4i s\u1EBD tu\xE2n theo \u0111i\u1EC1u \u0111\xF3:"),es.forEach(n),_e=p(t),m(yt.$$.fragment,t),ve=p(t),m(wt.$$.fragment,t),be=p(t),W=o(t,"H3",{class:!0});var ss=i(W);R=o(ss,"A",{id:!0,class:!0,href:!0});var Wl=i(R);yn=o(Wl,"SPAN",{});var Ll=i(yn);m(jt.$$.fragment,Ll),Ll.forEach(n),Wl.forEach(n),ia=p(ss),wn=o(ss,"SPAN",{});var Ul=i(wn);ha=l(Ul,"V\xF2ng l\u1EB7p hu\u1EA5n luy\u1EC7n"),Ul.forEach(n),ss.forEach(n),ke=p(t),J=o(t,"P",{});var as=i(J);pa=l(as,"M\u1ED9t \u0111i\u1EC1u cu\u1ED1i c\xF9ng: ch\xFAng ta s\u1EBD mu\u1ED1n s\u1EED d\u1EE5ng GPU n\u1EBFu c\xF3 quy\u1EC1n truy c\u1EADp v\xE0o m\u1ED9t GPU (tr\xEAn CPU, qu\xE1 tr\xECnh hu\u1EA5n luy\u1EC7n c\xF3 th\u1EC3 m\u1EA5t v\xE0i gi\u1EDD thay v\xEC v\xE0i ph\xFAt). \u0110\u1EC3 l\xE0m \u0111i\u1EC1u n\xE0y, ch\xFAng ta x\xE1c \u0111\u1ECBnh m\u1ED9t "),jn=o(as,"CODE",{});var Fl=i(jn);ua=l(Fl,"device"),Fl.forEach(n),ma=l(as,", ta s\u1EBD \u0111\u1EB7t m\xF4 h\xECnh v\xE0 c\xE1c l\xF4 c\u1EE7a ta tr\xEAn \u0111\xF3:"),as.forEach(n),$e=p(t),m(Et.$$.fragment,t),ye=p(t),m(qt.$$.fragment,t),we=p(t),K=o(t,"P",{});var ls=i(K);da=l(ls,"Gi\u1EDD th\xEC ta \u0111\xE3 s\u1EB5n s\xE0ng \u0111\u1EC3 hu\u1EA5n luy\u1EC7n r\u1ED3i! \u0110\u1EC3 bi\u1EBFt khi n\xE0o qu\xE1 tr\xECnh hu\u1EA5n luy\u1EC7n s\u1EBD k\u1EBFt th\xFAc, ta th\xEAm thanh ti\u1EBFn tr\xECnh qua s\u1ED1 b\u01B0\u1EDBc hu\u1EA5n luy\u1EC7n, s\u1EED d\u1EE5ng th\u01B0 vi\u1EC7n "),En=o(ls,"CODE",{});var Bl=i(En);ga=l(Bl,"tqdm"),Bl.forEach(n),fa=l(ls,":"),ls.forEach(n),je=p(t),m(zt.$$.fragment,t),Ee=p(t),Jt=o(t,"P",{});var Gl=i(Jt);_a=l(Gl,"B\u1EA1n c\xF3 th\u1EC3 th\u1EA5y r\u1EB1ng c\u1ED1t l\xF5i c\u1EE7a v\xF2ng l\u1EB7p hu\u1EA5n luy\u1EC7n tr\xF4ng r\u1EA5t gi\u1ED1ng nh\u01B0 trong ph\u1EA7n gi\u1EDBi thi\u1EC7u. Ch\xFAng ta \u0111\xE3 kh\xF4ng y\xEAu c\u1EA7u b\u1EA5t k\u1EF3 b\xE1o c\xE1o n\xE0o, v\xEC v\u1EADy v\xF2ng hu\u1EA5n luy\u1EC7n n\xE0y s\u1EBD kh\xF4ng cho ta bi\u1EBFt b\u1EA5t k\u1EF3 \u0111i\u1EC1u g\xEC v\u1EC1 c\xE1i gi\xE1 c\u1EE7a m\xF4 h\xECnh. Ch\xFAng ta c\u1EA7n th\xEAm m\u1ED9t v\xF2ng l\u1EB7p \u0111\xE1nh gi\xE1 cho \u0111i\u1EC1u \u0111\xF3."),Gl.forEach(n),qe=p(t),L=o(t,"H3",{class:!0});var rs=i(L);X=o(rs,"A",{id:!0,class:!0,href:!0});var Vl=i(X);qn=o(Vl,"SPAN",{});var Hl=i(qn);m(Ct.$$.fragment,Hl),Hl.forEach(n),Vl.forEach(n),va=p(rs),zn=o(rs,"SPAN",{});var Il=i(zn);ba=l(Il,"V\xF2ng l\u1EB7p \u0111\xE1nh gi\xE1"),Il.forEach(n),rs.forEach(n),ze=p(t),z=o(t,"P",{});var lt=i(z);ka=l(lt,"Nh\u01B0 \u0111\xE3 l\xE0m tr\u01B0\u1EDBc \u0111\xF3, ch\xFAng ta s\u1EBD s\u1EED d\u1EE5ng m\u1ED9t ch\u1EC9 s\u1ED1 \u0111\u01B0\u1EE3c cung c\u1EA5p b\u1EDFi th\u01B0 vi\u1EC7n \u{1F917} Evaluate. Ch\xFAng ta \u0111\xE3 th\u1EA5y ph\u01B0\u01A1ng th\u1EE9c "),Cn=o(lt,"CODE",{});var Rl=i(Cn);$a=l(Rl,"metric.compute()"),Rl.forEach(n),ya=l(lt,", c\xE1c ch\u1EC9 s\u1ED1 th\u1EF1c s\u1EF1 c\xF3 th\u1EC3 t\xEDch l\u0169y c\xE1c l\xF4 cho ta khi xem qua v\xF2ng d\u1EF1 \u0111o\xE1n v\u1EDBi ph\u01B0\u01A1ng th\u1EE9c "),xn=o(lt,"CODE",{});var Jl=i(xn);wa=l(Jl,"add_batch()"),Jl.forEach(n),ja=l(lt,". Khi ta \u0111\xE3 t\xEDch l\u0169y t\u1EA5t c\u1EA3 c\xE1c l\xF4, ch\xFAng ta c\xF3 th\u1EC3 nh\u1EADn \u0111\u01B0\u1EE3c k\u1EBFt qu\u1EA3 cu\u1ED1i c\xF9ng v\u1EDBi "),An=o(lt,"CODE",{});var Kl=i(An);Ea=l(Kl,"metric.compute()"),Kl.forEach(n),qa=l(lt,". D\u01B0\u1EDBi \u0111\xE2y l\xE0 c\xE1ch th\u1EF1c hi\u1EC7n t\u1EA5t c\u1EA3 nh\u1EEFng \u0111i\u1EC1u n\xE0y trong m\u1ED9t v\xF2ng l\u1EB7p \u0111\xE1nh gi\xE1:"),lt.forEach(n),Ce=p(t),m(xt.$$.fragment,t),xe=p(t),m(At.$$.fragment,t),Ae=p(t),Kt=o(t,"P",{});var Xl=i(Kt);za=l(Xl,"M\u1ED9t l\u1EA7n n\u1EEFa, k\u1EBFt qu\u1EA3 c\u1EE7a b\u1EA1n s\u1EBD h\u01A1i kh\xE1c m\u1ED9t ch\xFAt v\xEC s\u1EF1 ng\u1EABu nhi\xEAn trong qu\xE1 tr\xECnh kh\u1EDFi t\u1EA1o \u0111\u1EA7u m\xF4 h\xECnh v\xE0 x\xE1o tr\u1ED9n d\u1EEF li\u1EC7u, nh\u01B0ng ch\xFAng ph\u1EA3i \u1EDF trong c\xF9ng m\u1ED9t kho\u1EA3ng."),Xl.forEach(n),Pe=p(t),m(Y.$$.fragment,t),Te=p(t),U=o(t,"H3",{class:!0});var cs=i(U);Q=o(cs,"A",{id:!0,class:!0,href:!0});var Yl=i(Q);Pn=o(Yl,"SPAN",{});var Ql=i(Pn);m(Pt.$$.fragment,Ql),Ql.forEach(n),Yl.forEach(n),Ca=p(cs),Tn=o(cs,"SPAN",{});var Zl=i(Tn);xa=l(Zl,"T\u0103ng c\u01B0\u1EDDng tr\xED th\xF4ng minh c\u1EE7a v\xF2ng hu\u1EA5n luy\u1EC7n v\u1EDBi \u{1F917} Accelerate"),Zl.forEach(n),cs.forEach(n),De=p(t),m(Tt.$$.fragment,t),Se=p(t),Z=o(t,"P",{});var os=i(Z);Aa=l(os,"V\xF2ng l\u1EB7p hu\u1EA5n luy\u1EC7n m\xE0 ta \u0111\xE3 \u0111\u1ECBnh ngh\u0129a tr\u01B0\u1EDBc \u0111\xF3 ho\u1EA1t \u0111\u1ED9ng t\u1ED1t tr\xEAn m\u1ED9t CPU ho\u1EB7c GPU. Nh\u01B0ng b\u1EB1ng c\xE1ch s\u1EED d\u1EE5ng th\u01B0 vi\u1EC7n "),Dt=o(os,"A",{href:!0,rel:!0});var tr=i(Dt);Pa=l(tr,"\u{1F917} Accelerate"),tr.forEach(n),Ta=l(os,", ch\u1EC9 v\u1EDBi m\u1ED9t v\xE0i \u0111i\u1EC1u ch\u1EC9nh, ch\xFAng ta c\xF3 th\u1EC3 hu\u1EA5n luy\u1EC7n ph\xE2n t\xE1n tr\xEAn nhi\u1EC1u GPU ho\u1EB7c TPU. B\u1EAFt \u0111\u1EA7u t\u1EEB vi\u1EC7c t\u1EA1o b\u1ED9 d\u1EEF li\u1EC7u hu\u1EA5n luy\u1EC7n v\xE0 ki\u1EC3m \u0111\u1ECBnh, \u0111\xE2y l\xE0 v\xF2ng l\u1EB7p hu\u1EA5n luy\u1EC7n th\u1EE7 c\xF4ng th\u1EF1c thi:"),os.forEach(n),Oe=p(t),m(St.$$.fragment,t),Me=p(t),Xt=o(t,"P",{});var nr=i(Xt);Da=l(nr,"V\xE0 \u0111\xE2y l\xE0 m\u1ED9t s\u1ED1 thay \u0111\u1ED5i:"),nr.forEach(n),Ne=p(t),m(Ot.$$.fragment,t),We=p(t),C=o(t,"P",{});var rt=i(C);Sa=l(rt,"D\xF2ng \u0111\u1EA7u ti\xEAn c\u1EA7n th\xEAm l\xE0 d\xF2ng nh\u1EADp. D\xF2ng th\u1EE9 hai kh\u1EDFi t\u1EA1o m\u1ED9t \u0111\u1ED1i t\u01B0\u1EE3ng "),Dn=o(rt,"CODE",{});var er=i(Dn);Oa=l(er,"Accelerator"),er.forEach(n),Ma=l(rt," s\u1EBD xem x\xE9t m\xF4i tr\u01B0\u1EDDng v\xE0 kh\u1EDFi t\u1EA1o thi\u1EBFt l\u1EADp ph\xE2n t\xE1n th\xEDch h\u1EE3p. \u{1F917} Accelerate x\u1EED l\xFD v\u1ECB tr\xED \u0111\u1EB7t thi\u1EBFt b\u1ECB cho b\u1EA1n, v\xEC v\u1EADy b\u1EA1n c\xF3 th\u1EC3 x\xF3a c\xE1c d\xF2ng \u0111\u1EB7t m\xF4 h\xECnh tr\xEAn thi\u1EBFt b\u1ECB (ho\u1EB7c, n\u1EBFu b\u1EA1n th\xEDch, h\xE3y thay \u0111\u1ED5i ch\xFAng \u0111\u1EC3 s\u1EED d\u1EE5ng "),Sn=o(rt,"CODE",{});var sr=i(Sn);Na=l(sr,"accelerator.device"),sr.forEach(n),Wa=l(rt," thay v\xEC "),On=o(rt,"CODE",{});var ar=i(On);La=l(ar,"device"),ar.forEach(n),Ua=l(rt,")."),rt.forEach(n),Le=p(t),y=o(t,"P",{});var x=i(y);Fa=l(x,"Sau \u0111\xF3, ph\u1EA7n l\u1EDBn c\xF4ng vi\u1EC7c ch\xEDnh \u0111\u01B0\u1EE3c th\u1EF1c hi\u1EC7n trong d\xF2ng g\u1EEDi b\u1ED9 l\u01B0u d\u1EEF li\u1EC7u, m\xF4 h\xECnh v\xE0 tr\xECnh t\u1ED1i \u01B0u h\xF3a \u0111\u1EBFn "),Mn=o(x,"CODE",{});var lr=i(Mn);Ba=l(lr,"accelerator.prepare()"),lr.forEach(n),Ga=l(x,". Thao t\xE1c n\xE0y s\u1EBD b\u1ECDc c\xE1c \u0111\u1ED1i t\u01B0\u1EE3ng \u0111\xF3 trong h\u1ED9p ch\u1EE9a th\xEDch h\u1EE3p \u0111\u1EC3 \u0111\u1EA3m b\u1EA3o vi\u1EC7c hu\u1EA5n luy\u1EC7n \u0111\u01B0\u1EE3c ph\xE2n ph\u1ED1i ho\u1EA1t \u0111\u1ED9ng nh\u01B0 d\u1EF1 \u0111\u1ECBnh. C\xE1c thay \u0111\u1ED5i c\xF2n l\u1EA1i c\u1EA7n th\u1EF1c hi\u1EC7n l\xE0 lo\u1EA1i b\u1ECF d\xF2ng \u0111\u1EB7t l\xF4 tr\xEAn "),Nn=o(x,"CODE",{});var rr=i(Nn);Va=l(rr,"device"),rr.forEach(n),Ha=l(x," (m\u1ED9t l\u1EA7n n\u1EEFa, n\u1EBFu b\u1EA1n mu\u1ED1n gi\u1EEF l\u1EA1i \u0111i\u1EC1u n\xE0y, b\u1EA1n ch\u1EC9 c\u1EA7n thay \u0111\u1ED5i n\xF3 th\xE0nh s\u1EED d\u1EE5ng "),Wn=o(x,"CODE",{});var cr=i(Wn);Ia=l(cr,"accelerator.device"),cr.forEach(n),Ra=l(x,") v\xE0 thay th\u1EBF "),Ln=o(x,"CODE",{});var or=i(Ln);Ja=l(or,"loss.backward()"),or.forEach(n),Ka=l(x," b\u1EB1ng  "),Un=o(x,"CODE",{});var ir=i(Un);Xa=l(ir,"accelerator.backward(loss)"),ir.forEach(n),Ya=l(x,"."),x.forEach(n),Ue=p(t),m(tt.$$.fragment,t),Fe=p(t),Yt=o(t,"P",{});var hr=i(Yt);Qa=l(hr,"N\u1EBFu b\u1EA1n mu\u1ED1n sao ch\xE9p v\xE0 d\xE1n n\xF3 \u0111\u1EC3 m\xE0y m\xF2, \u0111\xE2y l\xE0 giao di\u1EC7n c\u1EE7a v\xF2ng hu\u1EA5n luy\u1EC7n ho\xE0n ch\u1EC9nh v\u1EDBi \u{1F917} Accelerate:"),hr.forEach(n),Be=p(t),m(Mt.$$.fragment,t),Ge=p(t),nt=o(t,"P",{});var is=i(nt);Za=l(is,"\u0110\u1EB7t \u0111i\u1EC1u n\xE0y trong "),Fn=o(is,"CODE",{});var pr=i(Fn);tl=l(pr,"train.py"),pr.forEach(n),nl=l(is," s\u1EBD l\xE0m cho t\u1EADp l\u1EC7nh \u0111\xF3 c\xF3 th\u1EC3 ch\u1EA1y \u0111\u01B0\u1EE3c tr\xEAn b\u1EA5t k\u1EF3 lo\u1EA1i thi\u1EBFt l\u1EADp ph\xE2n t\xE1n n\xE0o. \u0110\u1EC3 d\xF9ng th\u1EED trong thi\u1EBFt l\u1EADp ph\xE2n t\xE1n c\u1EE7a b\u1EA1n, h\xE3y ch\u1EA1y l\u1EC7nh:"),is.forEach(n),Ve=p(t),m(Nt.$$.fragment,t),He=p(t),Qt=o(t,"P",{});var ur=i(Qt);el=l(ur,"\u0111i\u1EC1u n\xE0y s\u1EBD nh\u1EAFc b\u1EA1n tr\u1EA3 l\u1EDDi m\u1ED9t s\u1ED1 c\xE2u h\u1ECFi v\xE0 tr\xEDch xu\u1EA5t c\xE2u tr\u1EA3 l\u1EDDi c\u1EE7a b\u1EA1n v\xE0o t\u1EC7p c\u1EA5u h\xECnh b\u1EDFi l\u1EC7nh sau:"),ur.forEach(n),Ie=p(t),m(Wt.$$.fragment,t),Re=p(t),Zt=o(t,"P",{});var mr=i(Zt);sl=l(mr,"v\xE0 n\xF3 s\u1EBD kh\u1EDFi ch\u1EA1y ch\u01B0\u01A1ng tr\xECnh hu\u1EA5n luy\u1EC7n ph\xE2n t\xE1n."),mr.forEach(n),Je=p(t),et=o(t,"P",{});var hs=i(et);al=l(hs,"N\u1EBFu b\u1EA1n mu\u1ED1n th\u1EED \u0111i\u1EC1u n\xE0y trong Notebook (v\xED d\u1EE5: \u0111\u1EC3 ki\u1EC3m tra n\xF3 v\u1EDBi TPU tr\xEAn Colab), ch\u1EC9 c\u1EA7n d\xE1n \u0111o\u1EA1n m\xE3 v\xE0o "),Bn=o(hs,"CODE",{});var dr=i(Bn);ll=l(dr,"training_function()"),dr.forEach(n),rl=l(hs," v\xE0 ch\u1EA1y \xF4 cu\u1ED1i c\xF9ng v\u1EDBi:"),hs.forEach(n),Ke=p(t),m(Lt.$$.fragment,t),Xe=p(t),st=o(t,"P",{});var ps=i(st);cl=l(ps,"B\u1EA1n c\xF3 th\u1EC3 t\xECm th\xEAm c\xE1c v\xED d\u1EE5 t\u1EA1i "),Ut=o(ps,"A",{href:!0,rel:!0});var gr=i(Ut);ol=l(gr,"\u{1F917} Accelerate repo"),gr.forEach(n),il=l(ps,"."),ps.forEach(n),this.h()},h(){v(b,"name","hf:doc:metadata"),v(b,"content",JSON.stringify(zr)),v(q,"id","bn-hun-luyn-hon-chnh"),v(q,"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"),v(q,"href","#bn-hun-luyn-hon-chnh"),v($,"class","relative group"),v(G,"id","chun-b-cho-hun-luyn"),v(G,"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"),v(G,"href","#chun-b-cho-hun-luyn"),v(M,"class","relative group"),v(kt,"href","https://arxiv.org/abs/1711.05101"),v(kt,"rel","nofollow"),v(R,"id","vng-lp-hun-luyn"),v(R,"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"),v(R,"href","#vng-lp-hun-luyn"),v(W,"class","relative group"),v(X,"id","vng-lp-nh-gi"),v(X,"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"),v(X,"href","#vng-lp-nh-gi"),v(L,"class","relative group"),v(Q,"id","tng-cng-tr-thng-minh-ca-vng-hun-luyn-vi-accelerate"),v(Q,"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"),v(Q,"href","#tng-cng-tr-thng-minh-ca-vng-hun-luyn-vi-accelerate"),v(U,"class","relative group"),v(Dt,"href","https://github.com/huggingface/accelerate"),v(Dt,"rel","nofollow"),v(Ut,"href","https://github.com/huggingface/accelerate/tree/main/examples"),v(Ut,"rel","nofollow")},m(t,s){e(document.head,b),r(t,w,s),r(t,$,s),e($,q),e(q,O),d(E,O,null),e($,P),e($,F),e(F,us),r(t,Hn,s),d(ct,t,s),r(t,In,s),d(ot,t,s),r(t,Rn,s),r(t,B,s),e(B,ms),e(B,sn),e(sn,ds),e(B,gs),r(t,Jn,s),d(it,t,s),r(t,Kn,s),r(t,M,s),e(M,G),e(G,an),d(ht,an,null),e(M,fs),e(M,ln),e(ln,_s),r(t,Xn,s),r(t,T,s),e(T,vs),e(T,rn),e(rn,bs),e(T,ks),e(T,cn),e(cn,$s),e(T,ys),r(t,Yn,s),r(t,D,s),e(D,N),e(N,ws),e(N,on),e(on,js),e(N,Es),e(N,hn),e(hn,qs),e(N,zs),e(D,Cs),e(D,A),e(A,xs),e(A,pn),e(pn,As),e(A,Ps),e(A,un),e(un,Ts),e(A,Ds),e(A,mn),e(mn,Ss),e(A,Os),e(D,Ms),e(D,dn),e(dn,Ns),r(t,Qn,s),r(t,pt,s),e(pt,gn),e(gn,Ws),e(pt,Ls),r(t,Zn,s),d(ut,t,s),r(t,te,s),r(t,Gt,s),e(Gt,Us),r(t,ne,s),d(mt,t,s),r(t,ee,s),r(t,Vt,s),e(Vt,Fs),r(t,se,s),d(dt,t,s),r(t,ae,s),r(t,Ht,s),e(Ht,Bs),r(t,le,s),d(gt,t,s),r(t,re,s),d(ft,t,s),r(t,ce,s),r(t,V,s),e(V,Gs),e(V,fn),e(fn,Vs),e(V,Hs),r(t,oe,s),r(t,It,s),e(It,Is),r(t,ie,s),d(_t,t,s),r(t,he,s),r(t,Rt,s),e(Rt,Rs),r(t,pe,s),d(vt,t,s),r(t,ue,s),d(bt,t,s),r(t,me,s),r(t,H,s),e(H,Js),e(H,_n),e(_n,Ks),e(H,Xs),r(t,de,s),r(t,j,s),e(j,Ys),e(j,vn),e(vn,Qs),e(j,Zs),e(j,bn),e(bn,ta),e(j,na),e(j,kn),e(kn,ea),e(j,sa),e(j,kt),e(kt,aa),e(j,la),r(t,ge,s),d($t,t,s),r(t,fe,s),r(t,I,s),e(I,ra),e(I,$n),e($n,ca),e(I,oa),r(t,_e,s),d(yt,t,s),r(t,ve,s),d(wt,t,s),r(t,be,s),r(t,W,s),e(W,R),e(R,yn),d(jt,yn,null),e(W,ia),e(W,wn),e(wn,ha),r(t,ke,s),r(t,J,s),e(J,pa),e(J,jn),e(jn,ua),e(J,ma),r(t,$e,s),d(Et,t,s),r(t,ye,s),d(qt,t,s),r(t,we,s),r(t,K,s),e(K,da),e(K,En),e(En,ga),e(K,fa),r(t,je,s),d(zt,t,s),r(t,Ee,s),r(t,Jt,s),e(Jt,_a),r(t,qe,s),r(t,L,s),e(L,X),e(X,qn),d(Ct,qn,null),e(L,va),e(L,zn),e(zn,ba),r(t,ze,s),r(t,z,s),e(z,ka),e(z,Cn),e(Cn,$a),e(z,ya),e(z,xn),e(xn,wa),e(z,ja),e(z,An),e(An,Ea),e(z,qa),r(t,Ce,s),d(xt,t,s),r(t,xe,s),d(At,t,s),r(t,Ae,s),r(t,Kt,s),e(Kt,za),r(t,Pe,s),d(Y,t,s),r(t,Te,s),r(t,U,s),e(U,Q),e(Q,Pn),d(Pt,Pn,null),e(U,Ca),e(U,Tn),e(Tn,xa),r(t,De,s),d(Tt,t,s),r(t,Se,s),r(t,Z,s),e(Z,Aa),e(Z,Dt),e(Dt,Pa),e(Z,Ta),r(t,Oe,s),d(St,t,s),r(t,Me,s),r(t,Xt,s),e(Xt,Da),r(t,Ne,s),d(Ot,t,s),r(t,We,s),r(t,C,s),e(C,Sa),e(C,Dn),e(Dn,Oa),e(C,Ma),e(C,Sn),e(Sn,Na),e(C,Wa),e(C,On),e(On,La),e(C,Ua),r(t,Le,s),r(t,y,s),e(y,Fa),e(y,Mn),e(Mn,Ba),e(y,Ga),e(y,Nn),e(Nn,Va),e(y,Ha),e(y,Wn),e(Wn,Ia),e(y,Ra),e(y,Ln),e(Ln,Ja),e(y,Ka),e(y,Un),e(Un,Xa),e(y,Ya),r(t,Ue,s),d(tt,t,s),r(t,Fe,s),r(t,Yt,s),e(Yt,Qa),r(t,Be,s),d(Mt,t,s),r(t,Ge,s),r(t,nt,s),e(nt,Za),e(nt,Fn),e(Fn,tl),e(nt,nl),r(t,Ve,s),d(Nt,t,s),r(t,He,s),r(t,Qt,s),e(Qt,el),r(t,Ie,s),d(Wt,t,s),r(t,Re,s),r(t,Zt,s),e(Zt,sl),r(t,Je,s),r(t,et,s),e(et,al),e(et,Bn),e(Bn,ll),e(et,rl),r(t,Ke,s),d(Lt,t,s),r(t,Xe,s),r(t,st,s),e(st,cl),e(st,Ut),e(Ut,ol),e(st,il),Ye=!0},p(t,[s]){const Ft={};s&2&&(Ft.$$scope={dirty:s,ctx:t}),Y.$set(Ft);const Gn={};s&2&&(Gn.$$scope={dirty:s,ctx:t}),tt.$set(Gn)},i(t){Ye||(g(E.$$.fragment,t),g(ct.$$.fragment,t),g(ot.$$.fragment,t),g(it.$$.fragment,t),g(ht.$$.fragment,t),g(ut.$$.fragment,t),g(mt.$$.fragment,t),g(dt.$$.fragment,t),g(gt.$$.fragment,t),g(ft.$$.fragment,t),g(_t.$$.fragment,t),g(vt.$$.fragment,t),g(bt.$$.fragment,t),g($t.$$.fragment,t),g(yt.$$.fragment,t),g(wt.$$.fragment,t),g(jt.$$.fragment,t),g(Et.$$.fragment,t),g(qt.$$.fragment,t),g(zt.$$.fragment,t),g(Ct.$$.fragment,t),g(xt.$$.fragment,t),g(At.$$.fragment,t),g(Y.$$.fragment,t),g(Pt.$$.fragment,t),g(Tt.$$.fragment,t),g(St.$$.fragment,t),g(Ot.$$.fragment,t),g(tt.$$.fragment,t),g(Mt.$$.fragment,t),g(Nt.$$.fragment,t),g(Wt.$$.fragment,t),g(Lt.$$.fragment,t),Ye=!0)},o(t){f(E.$$.fragment,t),f(ct.$$.fragment,t),f(ot.$$.fragment,t),f(it.$$.fragment,t),f(ht.$$.fragment,t),f(ut.$$.fragment,t),f(mt.$$.fragment,t),f(dt.$$.fragment,t),f(gt.$$.fragment,t),f(ft.$$.fragment,t),f(_t.$$.fragment,t),f(vt.$$.fragment,t),f(bt.$$.fragment,t),f($t.$$.fragment,t),f(yt.$$.fragment,t),f(wt.$$.fragment,t),f(jt.$$.fragment,t),f(Et.$$.fragment,t),f(qt.$$.fragment,t),f(zt.$$.fragment,t),f(Ct.$$.fragment,t),f(xt.$$.fragment,t),f(At.$$.fragment,t),f(Y.$$.fragment,t),f(Pt.$$.fragment,t),f(Tt.$$.fragment,t),f(St.$$.fragment,t),f(Ot.$$.fragment,t),f(tt.$$.fragment,t),f(Mt.$$.fragment,t),f(Nt.$$.fragment,t),f(Wt.$$.fragment,t),f(Lt.$$.fragment,t),Ye=!1},d(t){n(b),t&&n(w),t&&n($),_(E),t&&n(Hn),_(ct,t),t&&n(In),_(ot,t),t&&n(Rn),t&&n(B),t&&n(Jn),_(it,t),t&&n(Kn),t&&n(M),_(ht),t&&n(Xn),t&&n(T),t&&n(Yn),t&&n(D),t&&n(Qn),t&&n(pt),t&&n(Zn),_(ut,t),t&&n(te),t&&n(Gt),t&&n(ne),_(mt,t),t&&n(ee),t&&n(Vt),t&&n(se),_(dt,t),t&&n(ae),t&&n(Ht),t&&n(le),_(gt,t),t&&n(re),_(ft,t),t&&n(ce),t&&n(V),t&&n(oe),t&&n(It),t&&n(ie),_(_t,t),t&&n(he),t&&n(Rt),t&&n(pe),_(vt,t),t&&n(ue),_(bt,t),t&&n(me),t&&n(H),t&&n(de),t&&n(j),t&&n(ge),_($t,t),t&&n(fe),t&&n(I),t&&n(_e),_(yt,t),t&&n(ve),_(wt,t),t&&n(be),t&&n(W),_(jt),t&&n(ke),t&&n(J),t&&n($e),_(Et,t),t&&n(ye),_(qt,t),t&&n(we),t&&n(K),t&&n(je),_(zt,t),t&&n(Ee),t&&n(Jt),t&&n(qe),t&&n(L),_(Ct),t&&n(ze),t&&n(z),t&&n(Ce),_(xt,t),t&&n(xe),_(At,t),t&&n(Ae),t&&n(Kt),t&&n(Pe),_(Y,t),t&&n(Te),t&&n(U),_(Pt),t&&n(De),_(Tt,t),t&&n(Se),t&&n(Z),t&&n(Oe),_(St,t),t&&n(Me),t&&n(Xt),t&&n(Ne),_(Ot,t),t&&n(We),t&&n(C),t&&n(Le),t&&n(y),t&&n(Ue),_(tt,t),t&&n(Fe),t&&n(Yt),t&&n(Be),_(Mt,t),t&&n(Ge),t&&n(nt),t&&n(Ve),_(Nt,t),t&&n(He),t&&n(Qt),t&&n(Ie),_(Wt,t),t&&n(Re),t&&n(Zt),t&&n(Je),t&&n(et),t&&n(Ke),_(Lt,t),t&&n(Xe),t&&n(st)}}}const zr={local:"bn-hun-luyn-hon-chnh",sections:[{local:"chun-b-cho-hun-luyn",title:"Chu\u1EA9n b\u1ECB cho hu\u1EA5n luy\u1EC7n"},{local:"vng-lp-hun-luyn",title:"V\xF2ng l\u1EB7p hu\u1EA5n luy\u1EC7n"},{local:"vng-lp-nh-gi",title:"V\xF2ng l\u1EB7p \u0111\xE1nh gi\xE1"},{local:"tng-cng-tr-thng-minh-ca-vng-hun-luyn-vi-accelerate",title:"T\u0103ng c\u01B0\u1EDDng tr\xED th\xF4ng minh c\u1EE7a v\xF2ng hu\u1EA5n luy\u1EC7n v\u1EDBi \u{1F917} Accelerate"}],title:"B\u1EA3n hu\u1EA5n luy\u1EC7n ho\xE0n ch\u1EC9nh"};function Cr(Bt){return yr(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class Mr extends vr{constructor(b){super();br(this,b,Cr,qr,kr,{})}}export{Mr as default,zr as metadata};
