import{S as cl,i as ml,s as gl,e as a,k as f,w as h,t as s,M as _l,c as n,d as r,m as c,x as T,a as l,h as o,b as G,G as e,g as p,y as v,q as E,o as k,B as S,v as ul}from"../../chunks/vendor-hf-doc-builder.js";import{T as pl}from"../../chunks/Tip-hf-doc-builder.js";import{Y as dl}from"../../chunks/Youtube-hf-doc-builder.js";import{I as fl}from"../../chunks/IconCopyLink-hf-doc-builder.js";import{C}from"../../chunks/CodeBlock-hf-doc-builder.js";import{D as $l}from"../../chunks/DocNotebookDropdown-hf-doc-builder.js";import{F as hl}from"../../chunks/FrameworkSwitchCourse-hf-doc-builder.js";function Tl(pt){let m,j,_,q,w;return{c(){m=a("p"),j=s("\u{1F4A1} \u5982\u679C\u60A8\u60F3\u5728\u8BAD\u7EC3\u671F\u95F4\u81EA\u52A8\u5C06\u6A21\u578B\u4E0A\u4F20\u5230 Hub\uFF0C\u8BF7\u5C06push_to_hub=True\u6DFB\u52A0\u5230TrainingArguments\u4E4B\u4E2D. \u6211\u4EEC\u5C06\u5728"),_=a("a"),q=s("\u7B2C\u56DB\u7AE0"),w=s("\u4E2D\u8BE6\u7EC6\u4ECB\u7ECD\u8FD9\u90E8\u5206\u3002"),this.h()},l($){m=n($,"P",{});var b=l(m);j=o(b,"\u{1F4A1} \u5982\u679C\u60A8\u60F3\u5728\u8BAD\u7EC3\u671F\u95F4\u81EA\u52A8\u5C06\u6A21\u578B\u4E0A\u4F20\u5230 Hub\uFF0C\u8BF7\u5C06push_to_hub=True\u6DFB\u52A0\u5230TrainingArguments\u4E4B\u4E2D. \u6211\u4EEC\u5C06\u5728"),_=n(b,"A",{href:!0});var A=l(_);q=o(A,"\u7B2C\u56DB\u7AE0"),A.forEach(r),w=o(b,"\u4E2D\u8BE6\u7EC6\u4ECB\u7ECD\u8FD9\u90E8\u5206\u3002"),b.forEach(r),this.h()},h(){G(_,"href","/course/chapter4/3")},m($,b){p($,m,b),e(m,j),e(m,_),e(_,q),e(m,w)},d($){$&&r(m)}}}function vl(pt){let m,j,_,q,w;return{c(){m=a("p"),j=s("\u270F\uFE0F "),_=a("strong"),q=s("\u8BD5\u8BD5\u770B!"),w=s(" \u4F7F\u7528\u60A8\u5728\u7B2C 2 \u8282\u4E2D\u8FDB\u884C\u7684\u6570\u636E\u5904\u7406\uFF0C\u5728 GLUE SST-2 \u6570\u636E\u96C6\u4E0A\u5FAE\u8C03\u6A21\u578B\u3002")},l($){m=n($,"P",{});var b=l(m);j=o(b,"\u270F\uFE0F "),_=n(b,"STRONG",{});var A=l(_);q=o(A,"\u8BD5\u8BD5\u770B!"),A.forEach(r),w=o(b," \u4F7F\u7528\u60A8\u5728\u7B2C 2 \u8282\u4E2D\u8FDB\u884C\u7684\u6570\u636E\u5904\u7406\uFF0C\u5728 GLUE SST-2 \u6570\u636E\u96C6\u4E0A\u5FAE\u8C03\u6A21\u578B\u3002"),b.forEach(r)},m($,b){p($,m,b),e(m,j),e(m,_),e(_,q),e(m,w)},d($){$&&r(m)}}}function El(pt){let m,j,_,q,w,$,b,A,Wr,Ft,Hr,Ve,ft,Ze,ct,tr,y,Yr,Mt,Jr,Xr,It,Kr,Qr,Dt,Vr,Zr,mt,ts,es,er,Pt,rs,rr,gt,sr,X,Q,Lt,_t,ss,Bt,os,or,x,as,Wt,ns,ls,Ht,is,ps,Yt,fs,cs,ar,ut,nr,V,lr,Z,ms,Jt,gs,_s,ir,dt,pr,tt,us,jt,ds,$s,fr,R,hs,Xt,Ts,vs,Kt,Es,ks,Qt,Ss,bs,Vt,Gs,ws,Zt,Ns,Rs,cr,$t,mr,O,Os,te,Ps,js,ee,qs,ys,re,As,zs,se,Cs,xs,oe,Us,Fs,gr,B,Ms,ae,Is,Ds,ne,Ls,Bs,_r,ht,ur,qt,Ws,dr,et,z,Hs,le,Ys,Js,ie,Xs,Ks,pe,Qs,Vs,fe,Zs,to,eo,K,ro,ce,so,oo,me,ao,no,$r,Tt,lo,hr,P,io,ge,po,fo,_e,co,mo,ue,go,_o,de,uo,$o,$e,ho,To,Tr,vt,vr,Et,Er,d,he,vo,Eo,Te,ko,So,ve,bo,Go,Ee,wo,No,ke,Ro,Oo,Se,Po,jo,be,qo,yo,Ge,Ao,zo,kr,g,we,Co,xo,Ne,Uo,Fo,Re,Mo,Io,Oe,Do,Lo,Pe,Bo,Wo,je,Ho,Yo,qe,Jo,Xo,ye,Ko,Qo,Ae,Vo,Zo,ze,ta,ea,yt,ra,sa,Sr,kt,br,U,oa,Ce,aa,na,xe,la,ia,Ue,pa,fa,Gr,St,wr,bt,Nr,F,ca,Gt,ma,ga,Fe,_a,ua,Me,da,$a,Rr,rt,ha,Ie,Ta,va,Or,wt,Pr,W,Ea,De,ka,Sa,Le,ba,Ga,jr,Nt,qr,M,wa,Be,Na,Ra,We,Oa,Pa,He,ja,qa,yr,Rt,Ar,At,ya,zr,H,Aa,Ye,za,Ca,Je,xa,Ua,Cr,st,Fa,Xe,Ma,Ia,xr,ot,Ur;return _=new hl({props:{fw:pt[0]}}),A=new fl({}),ft=new $l({props:{classNames:"absolute z-10 right-0 top-0",options:[{label:"Google Colab",value:"https://colab.research.google.com/github/huggingface/notebooks/blob/master/course/chapter3/section3.ipynb"},{label:"Aws Studio",value:"https://studiolab.sagemaker.aws/import/github/huggingface/notebooks/blob/master/course/chapter3/section3.ipynb"}]}}),ct=new dl({props:{id:"nvBXf7s7vTI"}}),gt=new C({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 fl({}),ut=new C({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>)`}}),V=new pl({props:{$$slots:{default:[Tl]},$$scope:{ctx:pt}}}),dt=new C({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>)`}}),$t=new C({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,
)`}}),ht=new C({props:{code:"trainer.train()",highlighted:"trainer.train()"}}),vt=new C({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)`}}),Et=new C({props:{code:"(408, 2) (408,)",highlighted:'(<span class="hljs-number">408</span>, <span class="hljs-number">2</span>) (<span class="hljs-number">408</span>,)'}}),kt=new C({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>)`}}),St=new C({props:{code:`from datasets import load_metric

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

metric = load_metric(<span class="hljs-string">&quot;glue&quot;</span>, <span class="hljs-string">&quot;mrpc&quot;</span>)
metric.compute(predictions=preds, references=predictions.label_ids)`}}),bt=new C({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>}'}}),wt=new C({props:{code:`def compute_metrics(eval_preds):
    metric = load_metric("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 = load_metric(<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)`}}),Nt=new C({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,
)`}}),Rt=new C({props:{code:"trainer.train()",highlighted:'trainer.trai<span class="hljs-meta">n</span>()'}}),ot=new pl({props:{$$slots:{default:[vl]},$$scope:{ctx:pt}}}),{c(){m=a("meta"),j=f(),h(_.$$.fragment),q=f(),w=a("h1"),$=a("a"),b=a("span"),h(A.$$.fragment),Wr=f(),Ft=a("span"),Hr=s("\u4F7F\u7528 Trainer API \u5FAE\u8C03\u6A21\u578B"),Ve=f(),h(ft.$$.fragment),Ze=f(),h(ct.$$.fragment),tr=f(),y=a("p"),Yr=s("\u{1F917} Transformers\u63D0\u4F9B\u4E86\u4E00\u4E2A "),Mt=a("strong"),Jr=s("Trainer"),Xr=s(" \u7C7B\u6765\u5E2E\u52A9\u60A8\u5728\u81EA\u5DF1\u7684\u6570\u636E\u96C6\u4E0A\u5FAE\u8C03\u4EFB\u4F55\u9884\u8BAD\u7EC3\u6A21\u578B\u3002\u5B8C\u6210\u4E0A\u4E00\u8282\u4E2D\u7684\u6240\u6709\u6570\u636E\u9884\u5904\u7406\u5DE5\u4F5C\u540E\uFF0C\u60A8\u53EA\u9700\u8981\u6267\u884C\u51E0\u4E2A\u6B65\u9AA4\u6765\u521B\u5EFA "),It=a("strong"),Kr=s("Trainer"),Qr=s(" .\u6700\u96BE\u7684\u90E8\u5206\u53EF\u80FD\u662F\u4E3A "),Dt=a("strong"),Vr=s("Trainer.train()"),Zr=s("\u914D\u7F6E\u8FD0\u884C\u73AF\u5883\uFF0C\u56E0\u4E3A\u5B83\u5728 CPU \u4E0A\u8FD0\u884C\u901F\u5EA6\u4F1A\u975E\u5E38\u6162\u3002\u5982\u679C\u60A8\u6CA1\u6709\u8BBE\u7F6E GPU\uFF0C\u60A8\u53EF\u4EE5\u8BBF\u95EE\u514D\u8D39\u7684 GPU \u6216 TPU"),mt=a("a"),ts=s("Google Colab"),es=s("."),er=f(),Pt=a("p"),rs=s("\u4E0B\u9762\u7684\u793A\u4F8B\u5047\u8BBE\u60A8\u5DF2\u7ECF\u6267\u884C\u4E86\u4E0A\u4E00\u8282\u4E2D\u7684\u793A\u4F8B\u3002\u4E0B\u9762\u8FD9\u6BB5\u4EE3\u7801\uFF0C\u6982\u62EC\u4E86\u60A8\u9700\u8981\u63D0\u524D\u8FD0\u884C\u7684\u4EE3\u7801\uFF1A"),rr=f(),h(gt.$$.fragment),sr=f(),X=a("h3"),Q=a("a"),Lt=a("span"),h(_t.$$.fragment),ss=f(),Bt=a("span"),os=s("Training"),or=f(),x=a("p"),as=s("\u5728\u6211\u4EEC\u5B9A\u4E49\u6211\u4EEC\u7684 "),Wt=a("strong"),ns=s("Trainer"),ls=s(" \u4E4B\u524D\u9996\u5148\u8981\u5B9A\u4E49\u4E00\u4E2A "),Ht=a("strong"),is=s("TrainingArguments"),ps=s(" \u7C7B\uFF0C\u5B83\u5C06\u5305\u542B "),Yt=a("strong"),fs=s("Trainer"),cs=s("\u7528\u4E8E\u8BAD\u7EC3\u548C\u8BC4\u4F30\u7684\u6240\u6709\u8D85\u53C2\u6570\u3002\u60A8\u552F\u4E00\u5FC5\u987B\u63D0\u4F9B\u7684\u53C2\u6570\u662F\u4FDD\u5B58\u8BAD\u7EC3\u6A21\u578B\u7684\u76EE\u5F55\uFF0C\u4EE5\u53CA\u8BAD\u7EC3\u8FC7\u7A0B\u4E2D\u7684\u68C0\u67E5\u70B9\u3002\u5BF9\u4E8E\u5176\u4F59\u7684\u53C2\u6570\uFF0C\u60A8\u53EF\u4EE5\u4FDD\u7559\u9ED8\u8BA4\u503C\uFF0C\u8FD9\u5BF9\u4E8E\u57FA\u672C\u5FAE\u8C03\u5E94\u8BE5\u975E\u5E38\u6709\u6548\u3002"),ar=f(),h(ut.$$.fragment),nr=f(),h(V.$$.fragment),lr=f(),Z=a("p"),ms=s("\u7B2C\u4E8C\u6B65\u662F\u5B9A\u4E49\u6211\u4EEC\u7684\u6A21\u578B\u3002\u6B63\u5982\u5728[\u4E4B\u524D\u7684\u7AE0\u8282](/2_Using Transformers/Introduction)\u4E00\u6837\uFF0C\u6211\u4EEC\u5C06\u4F7F\u7528 "),Jt=a("strong"),gs=s("AutoModelForSequenceClassification"),_s=s(" \u7C7B\uFF0C\u5B83\u6709\u4E24\u4E2A\u53C2\u6570\uFF1A"),ir=f(),h(dt.$$.fragment),pr=f(),tt=a("p"),us=s("\u4F60\u4F1A\u6CE8\u610F\u5230\uFF0C\u548C"),jt=a("a"),ds=s("\u7B2C\u4E8C\u7AE0"),$s=s("\u4E0D\u4E00\u6837\u7684\u662F\uFF0C\u5728\u5B9E\u4F8B\u5316\u6B64\u9884\u8BAD\u7EC3\u6A21\u578B\u540E\u4F1A\u6536\u5230\u8B66\u544A\u3002\u8FD9\u662F\u56E0\u4E3A BERT \u6CA1\u6709\u5728\u53E5\u5B50\u5BF9\u5206\u7C7B\u65B9\u9762\u8FDB\u884C\u8FC7\u9884\u8BAD\u7EC3\uFF0C\u6240\u4EE5\u9884\u8BAD\u7EC3\u6A21\u578B\u7684\u5934\u90E8\u5DF2\u7ECF\u88AB\u4E22\u5F03\uFF0C\u800C\u662F\u6DFB\u52A0\u4E86\u4E00\u4E2A\u9002\u5408\u53E5\u5B50\u5E8F\u5217\u5206\u7C7B\u7684\u65B0\u5934\u90E8\u3002\u8B66\u544A\u8868\u660E\u4E00\u4E9B\u6743\u91CD\u6CA1\u6709\u4F7F\u7528\uFF08\u5BF9\u5E94\u4E8E\u4E22\u5F03\u7684\u9884\u8BAD\u7EC3\u5934\u7684\u90A3\u4E9B\uFF09\uFF0C\u800C\u5176\u4ED6\u4E00\u4E9B\u6743\u91CD\u88AB\u968F\u673A\u521D\u59CB\u5316\uFF08\u65B0\u5934\u7684\u90A3\u4E9B\uFF09\u3002\u6700\u540E\u9F13\u52B1\u60A8\u8BAD\u7EC3\u6A21\u578B\uFF0C\u8FD9\u6B63\u662F\u6211\u4EEC\u73B0\u5728\u8981\u505A\u7684\u3002"),fr=f(),R=a("p"),hs=s("\u4E00\u65E6\u6211\u4EEC\u6709\u4E86\u6211\u4EEC\u7684\u6A21\u578B\uFF0C\u6211\u4EEC\u5C31\u53EF\u4EE5\u5B9A\u4E49\u4E00\u4E2A "),Xt=a("strong"),Ts=s("Trainer"),vs=s(" \u901A\u8FC7\u5C06\u4E4B\u524D\u6784\u9020\u7684\u6240\u6709\u5BF9\u8C61\u4F20\u9012\u7ED9\u5B83\u2014\u2014\u6211\u4EEC\u7684"),Kt=a("strong"),Es=s("model"),ks=s(" \u3001"),Qt=a("strong"),Ss=s("training_args"),bs=s(" \uFF0C\u8BAD\u7EC3\u548C\u9A8C\u8BC1\u6570\u636E\u96C6\uFF0C"),Vt=a("strong"),Gs=s("data_collator"),ws=s(" \uFF0C\u548C "),Zt=a("strong"),Ns=s("tokenizer"),Rs=s(" \uFF1A"),cr=f(),h($t.$$.fragment),mr=f(),O=a("p"),Os=s("\u8BF7\u6CE8\u610F\uFF0C\u5F53\u60A8\u5728\u8FD9\u91CC\u5B8C\u6210"),te=a("strong"),Ps=s("tokenizer"),js=s("\u540E\uFF0C\u9ED8\u8BA4 "),ee=a("strong"),qs=s("Trainer"),ys=s("\u4F7F\u7528 \u7684"),re=a("strong"),As=s("data_collator"),zs=s("\u4F1A\u4F7F\u7528\u4E4B\u524D\u9884\u5B9A\u4E49\u7684 "),se=a("strong"),Cs=s("DataCollatorWithPadding"),xs=s(" \uFF0C\u56E0\u6B64\u60A8\u53EF\u4EE5\u5728\u8FD9\u4E2A\u4F8B\u5B50\u4E2D\u8DF3\u8FC7 "),oe=a("strong"),Us=s("data_collator=data_collator"),Fs=s("\u3002\u5728\u7B2C 2 \u8282\u4E2D\u5411\u60A8\u5C55\u793A\u8FD9\u90E8\u5206\u5904\u7406\u4ECD\u7136\u5F88\u91CD\u8981\uFF01"),gr=f(),B=a("p"),Ms=s("\u4E3A\u4E86\u8BA9\u9884\u8BAD\u7EC3\u6A21\u578B\u5728\u5728\u6211\u4EEC\u7684\u6570\u636E\u96C6\u4E0A\u5FAE\u8C03\uFF0C\u6211\u4EEC\u53EA\u9700\u8981\u8C03\u7528"),ae=a("strong"),Is=s("Trainer"),Ds=s("\u7684"),ne=a("strong"),Ls=s("train()"),Bs=s(" \u65B9\u6CD5 \uFF1A"),_r=f(),h(ht.$$.fragment),ur=f(),qt=a("p"),Ws=s("\u8FD9\u5C06\u5F00\u59CB\u5FAE\u8C03\uFF08\u5728GPU\u4E0A\u5E94\u8BE5\u9700\u8981\u51E0\u5206\u949F\uFF09\uFF0C\u5E76\u6BCF500\u6B65\u62A5\u544A\u4E00\u6B21\u8BAD\u7EC3\u635F\u5931\u3002\u4F46\u662F\uFF0C\u5B83\u4E0D\u4F1A\u544A\u8BC9\u60A8\u6A21\u578B\u7684\u6027\u80FD\u5982\u4F55\uFF08\u6216\u8D28\u91CF\u5982\u4F55\uFF09\u3002\u8FD9\u662F\u56E0\u4E3A:"),dr=f(),et=a("ol"),z=a("li"),Hs=s("\u6211\u4EEC\u6CA1\u6709\u901A\u8FC7\u5C06"),le=a("strong"),Ys=s("evaluation_strategy"),Js=s("\u8BBE\u7F6E\u4E3A\u201C"),ie=a("strong"),Xs=s("steps"),Ks=s("\u201D(\u5728\u6BCF\u6B21\u66F4\u65B0\u53C2\u6570\u7684\u65F6\u5019\u8BC4\u4F30)\u6216\u201C"),pe=a("strong"),Qs=s("epoch"),Vs=s("\u201D(\u5728\u6BCF\u4E2Aepoch\u7ED3\u675F\u65F6\u8BC4\u4F30)\u6765\u544A\u8BC9"),fe=a("strong"),Zs=s("Trainer"),to=s("\u5728\u8BAD\u7EC3\u671F\u95F4\u8FDB\u884C\u8BC4\u4F30\u3002"),eo=f(),K=a("li"),ro=s("\u6211\u4EEC\u6CA1\u6709\u4E3A"),ce=a("strong"),so=s("Trainer"),oo=s("\u63D0\u4F9B\u4E00\u4E2A"),me=a("strong"),ao=s("compute_metrics()"),no=s("\u51FD\u6570\u6765\u76F4\u63A5\u8BA1\u7B97\u6A21\u578B\u7684\u597D\u574F(\u5426\u5219\u8BC4\u4F30\u5C06\u53EA\u8F93\u51FAloss\uFF0C\u8FD9\u4E0D\u662F\u4E00\u4E2A\u975E\u5E38\u76F4\u89C2\u7684\u6570\u5B57)\u3002"),$r=f(),Tt=a("h3"),lo=s("\u8BC4\u4F30"),hr=f(),P=a("p"),io=s("\u8BA9\u6211\u4EEC\u770B\u770B\u5982\u4F55\u6784\u5EFA\u4E00\u4E2A\u6709\u7528\u7684 "),ge=a("strong"),po=s("compute_metrics()"),fo=s(" \u51FD\u6570\u5E76\u5728\u6211\u4EEC\u4E0B\u6B21\u8BAD\u7EC3\u65F6\u4F7F\u7528\u5B83\u3002\u8BE5\u51FD\u6570\u5FC5\u987B\u91C7\u7528 "),_e=a("strong"),co=s("EvalPrediction"),mo=s(" \u5BF9\u8C61\uFF08\u5E26\u6709 "),ue=a("strong"),go=s("predictions"),_o=s(" \u548C "),de=a("strong"),uo=s("label_ids"),$o=s(" \u5B57\u6BB5\u7684\u53C2\u6570\u5143\u7EC4\uFF09\u5E76\u5C06\u8FD4\u56DE\u4E00\u4E2A\u5B57\u7B26\u4E32\u5230\u6D6E\u70B9\u6570\u7684\u5B57\u5178\uFF08\u5B57\u7B26\u4E32\u662F\u8FD4\u56DE\u7684\u6307\u6807\u7684\u540D\u79F0\uFF0C\u800C\u6D6E\u70B9\u6570\u662F\u5B83\u4EEC\u7684\u503C\uFF09\u3002\u6211\u4EEC\u53EF\u4EE5\u4F7F\u7528 "),$e=a("strong"),ho=s("Trainer.predict()"),To=s(" \u547D\u4EE4\u6765\u4F7F\u7528\u6211\u4EEC\u7684\u6A21\u578B\u8FDB\u884C\u9884\u6D4B\uFF1A"),Tr=f(),h(vt.$$.fragment),vr=f(),h(Et.$$.fragment),Er=f(),d=a("p"),he=a("strong"),vo=s("predict()"),Eo=s(" \u7684\u8F93\u51FA\u7ED3\u679C\u662F\u5177\u6709\u4E09\u4E2A\u5B57\u6BB5\u7684\u547D\u540D\u5143\u7EC4\uFF1A "),Te=a("strong"),ko=s("predictions"),So=s(" , "),ve=a("strong"),bo=s("label_ids"),Go=s(" \uFF0C \u548C "),Ee=a("strong"),wo=s("metrics"),No=s(" .\u8FD9 "),ke=a("strong"),Ro=s("metrics"),Oo=s(" \u5B57\u6BB5\u5C06\u53EA\u5305\u542B\u4F20\u9012\u7684\u6570\u636E\u96C6\u7684loss\uFF0C\u4EE5\u53CA\u4E00\u4E9B\u8FD0\u884C\u65F6\u95F4\uFF08\u9884\u6D4B\u6240\u9700\u7684\u603B\u65F6\u95F4\u548C\u5E73\u5747\u65F6\u95F4\uFF09\u3002\u5982\u679C\u6211\u4EEC\u5B9A\u4E49\u4E86\u81EA\u5DF1\u7684 "),Se=a("strong"),Po=s("compute_metrics()"),jo=s(" \u51FD\u6570\u5E76\u5C06\u5176\u4F20\u9012\u7ED9 "),be=a("strong"),qo=s("Trainer"),yo=s(" \uFF0C\u8BE5\u5B57\u6BB5\u8FD8\u5C06\u5305\u542B"),Ge=a("strong"),Ao=s("compute_metrics()"),zo=s("\u7684\u7ED3\u679C\u3002"),kr=f(),g=a("p"),we=a("strong"),Co=s("predict()"),xo=s(" \u65B9\u6CD5\u662F\u5177\u6709\u4E09\u4E2A\u5B57\u6BB5\u7684\u547D\u540D\u5143\u7EC4\uFF1A "),Ne=a("strong"),Uo=s("predictions"),Fo=s(" , "),Re=a("strong"),Mo=s("label_ids"),Io=s(" \uFF0C \u548C "),Oe=a("strong"),Do=s("metrics"),Lo=s(" .\u8FD9 "),Pe=a("strong"),Bo=s("metrics"),Wo=s(" \u5B57\u6BB5\u5C06\u53EA\u5305\u542B\u4F20\u9012\u7684\u6570\u636E\u96C6\u7684loss\uFF0C\u4EE5\u53CA\u4E00\u4E9B\u8FD0\u884C\u65F6\u95F4\uFF08\u9884\u6D4B\u6240\u9700\u7684\u603B\u65F6\u95F4\u548C\u5E73\u5747\u65F6\u95F4\uFF09\u3002\u5982\u679C\u6211\u4EEC\u5B9A\u4E49\u4E86\u81EA\u5DF1\u7684 "),je=a("strong"),Ho=s("compute_metrics()"),Yo=s(" \u51FD\u6570\u5E76\u5C06\u5176\u4F20\u9012\u7ED9 "),qe=a("strong"),Jo=s("Trainer"),Xo=s(" \uFF0C\u8BE5\u5B57\u6BB5\u8FD8\u5C06\u5305\u542B"),ye=a("strong"),Ko=s("compute_metrics()"),Qo=s(" \u7684\u7ED3\u679C\u3002\u5982\u4F60\u770B\u5230\u7684\uFF0C "),Ae=a("strong"),Vo=s("predictions"),Zo=s(" \u662F\u4E00\u4E2A\u5F62\u72B6\u4E3A 408 x 2 \u7684\u4E8C\u7EF4\u6570\u7EC4\uFF08408 \u662F\u6211\u4EEC\u4F7F\u7528\u7684\u6570\u636E\u96C6\u4E2D\u5143\u7D20\u7684\u6570\u91CF\uFF09\u3002\u8FD9\u4E9B\u662F\u6211\u4EEC\u4F20\u9012\u7ED9"),ze=a("strong"),ta=s("predict()"),ea=s("\u7684\u6570\u636E\u96C6\u7684\u6BCF\u4E2A\u5143\u7D20\u7684\u7ED3\u679C(logits)\uFF08\u6B63\u5982\u4F60\u5728"),yt=a("a"),ra=s("\u4E4B\u524D\u7684\u7AE0\u8282"),sa=s("\u770B\u5230\u7684\u60C5\u51B5\uFF09\u3002\u8981\u5C06\u6211\u4EEC\u7684\u9884\u6D4B\u7684\u53EF\u4EE5\u4E0E\u771F\u6B63\u7684\u6807\u7B7E\u8FDB\u884C\u6BD4\u8F83\uFF0C\u6211\u4EEC\u9700\u8981\u5728\u7B2C\u4E8C\u4E2A\u8F74\u4E0A\u53D6\u6700\u5927\u503C\u7684\u7D22\u5F15\uFF1A"),Sr=f(),h(kt.$$.fragment),br=f(),U=a("p"),oa=s("\u73B0\u5728\u5EFA\u7ACB\u6211\u4EEC\u7684 "),Ce=a("strong"),aa=s("compute_metric()"),na=s(" \u51FD\u6570\u6765\u8F83\u4E3A\u76F4\u89C2\u5730\u8BC4\u4F30\u6A21\u578B\u7684\u597D\u574F\uFF0C\u6211\u4EEC\u5C06\u4F7F\u7528 \u{1F917} Datasets \u5E93\u4E2D\u7684\u6307\u6807\u3002\u6211\u4EEC\u53EF\u4EE5\u50CF\u52A0\u8F7D\u6570\u636E\u96C6\u4E00\u6837\u8F7B\u677E\u52A0\u8F7D\u4E0E MRPC \u6570\u636E\u96C6\u5173\u8054\u7684\u6307\u6807\uFF0C\u8FD9\u6B21\u4F7F\u7528 "),xe=a("strong"),la=s("load_metric()"),ia=s(" \u51FD\u6570\u3002\u8FD4\u56DE\u7684\u5BF9\u8C61\u6709\u4E00\u4E2A "),Ue=a("strong"),pa=s("compute()"),fa=s("\u65B9\u6CD5\u6211\u4EEC\u53EF\u4EE5\u7528\u6765\u8FDB\u884C\u5EA6\u91CF\u8BA1\u7B97\u7684\u65B9\u6CD5\uFF1A"),Gr=f(),h(St.$$.fragment),wr=f(),h(bt.$$.fragment),Nr=f(),F=a("p"),ca=s("\u60A8\u83B7\u5F97\u7684\u786E\u5207\u7ED3\u679C\u53EF\u80FD\u4F1A\u6709\u6240\u4E0D\u540C\uFF0C\u56E0\u4E3A\u6A21\u578B\u5934\u7684\u968F\u673A\u521D\u59CB\u5316\u53EF\u80FD\u4F1A\u5F71\u54CD\u6700\u7EC8\u5EFA\u7ACB\u7684\u6A21\u578B\u3002\u5728\u8FD9\u91CC\uFF0C\u6211\u4EEC\u53EF\u4EE5\u770B\u5230\u6211\u4EEC\u7684\u6A21\u578B\u5728\u9A8C\u8BC1\u96C6\u4E0A\u7684\u51C6\u786E\u7387\u4E3A 85.78%\uFF0CF1 \u5206\u6570\u4E3A 89.97\u3002\u8FD9\u662F\u7528\u4E8E\u8BC4\u4F30 GLUE \u57FA\u51C6\u7684 MRPC \u6570\u636E\u96C6\u7ED3\u679C\u7684\u4E24\u4E2A\u6307\u6807\u3002\u800C\u5728"),Gt=a("a"),ma=s("BERT \u8BBA\u6587"),ga=s("\u4E2D\u5C55\u793A\u7684\u57FA\u7840\u6A21\u578B\u7684 F1 \u5206\u6570\u4E3A 88.9\u3002\u90A3\u662F "),Fe=a("strong"),_a=s("uncased"),ua=s(" \u6A21\u578B\uFF0C\u800C\u6211\u4EEC\u76EE\u524D\u6B63\u5728\u4F7F\u7528 "),Me=a("strong"),da=s("cased"),$a=s(" \u6A21\u578B\uFF0C\u901A\u8FC7\u6539\u8FDB\u5F97\u5230\u4E86\u66F4\u597D\u7684\u7ED3\u679C\u3002"),Rr=f(),rt=a("p"),ha=s("\u6700\u540E\u5C06\u6240\u6709\u4E1C\u897F\u6253\u5305\u5728\u4E00\u8D77\uFF0C\u6211\u4EEC\u5F97\u5230\u4E86\u6211\u4EEC\u7684 "),Ie=a("strong"),Ta=s("compute_metrics()"),va=s(" \u51FD\u6570\uFF1A"),Or=f(),h(wt.$$.fragment),Pr=f(),W=a("p"),Ea=s("\u4E3A\u4E86\u67E5\u770B\u6A21\u578B\u5728\u6BCF\u4E2A\u8BAD\u7EC3\u5468\u671F\u7ED3\u675F\u7684\u597D\u574F\uFF0C\u4E0B\u9762\u662F\u6211\u4EEC\u5982\u4F55\u4F7F\u7528"),De=a("strong"),ka=s("compute_metrics()"),Sa=s("\u51FD\u6570\u5B9A\u4E49\u4E00\u4E2A\u65B0\u7684 "),Le=a("strong"),ba=s("Trainer"),Ga=s(" \uFF1A"),jr=f(),h(Nt.$$.fragment),qr=f(),M=a("p"),wa=s("\u8BF7\u6CE8\u610F\uFF0C\u6211\u4EEC\u8BBE\u7F6E\u4E86\u4E86\u4E00\u4E2A\u65B0\u7684 "),Be=a("strong"),Na=s("TrainingArguments"),Ra=s(" \u5B83\u7684"),We=a("strong"),Oa=s("evaluation_strategy"),Pa=s(" \u8BBE\u7F6E\u4E3A "),He=a("strong"),ja=s("epoch"),qa=s(" \u5E76\u521B\u5EFA\u4E86\u4E00\u4E2A\u65B0\u6A21\u578B\u3002\u5982\u679C\u4E0D\u521B\u5EFA\u65B0\u7684\u6A21\u578B\u5C31\u76F4\u63A5\u8BAD\u7EC3\uFF0C\u5C31\u53EA\u4F1A\u7EE7\u7EED\u8BAD\u7EC3\u4E4B\u524D\u6211\u4EEC\u5DF2\u7ECF\u8BAD\u7EC3\u8FC7\u7684\u6A21\u578B\u3002\u8981\u542F\u52A8\u65B0\u7684\u8BAD\u7EC3\u8FD0\u884C\uFF0C\u6211\u4EEC\u6267\u884C\uFF1A"),yr=f(),h(Rt.$$.fragment),Ar=f(),At=a("p"),ya=s("\u8FD9\u4E00\u6B21\uFF0C\u5B83\u5C06\u5728\u8BAD\u7EC3loss\u4E4B\u5916\uFF0C\u8FD8\u4F1A\u8F93\u51FA\u6BCF\u4E2A epoch \u7ED3\u675F\u65F6\u7684\u9A8C\u8BC1loss\u548C\u6307\u6807\u3002\u540C\u6837\uFF0C\u7531\u4E8E\u6A21\u578B\u7684\u968F\u673A\u5934\u90E8\u521D\u59CB\u5316\uFF0C\u60A8\u8FBE\u5230\u7684\u51C6\u786E\u7387/F1 \u5206\u6570\u53EF\u80FD\u4E0E\u6211\u4EEC\u53D1\u73B0\u7684\u7565\u6709\u4E0D\u540C\uFF0C\u4F46\u5B83\u5E94\u8BE5\u5728\u540C\u4E00\u8303\u56F4\u5185\u3002"),zr=f(),H=a("p"),Aa=s("\u8FD9 "),Ye=a("strong"),za=s("Trainer"),Ca=s(" \u5C06\u5728\u591A\u4E2A GPU \u6216 TPU \u4E0A\u5F00\u7BB1\u5373\u7528\uFF0C\u5E76\u63D0\u4F9B\u8BB8\u591A\u9009\u9879\uFF0C\u4F8B\u5982\u6DF7\u5408\u7CBE\u5EA6\u8BAD\u7EC3\uFF08\u5728\u8BAD\u7EC3\u7684\u53C2\u6570\u4E2D\u4F7F\u7528 "),Je=a("strong"),xa=s("fp16 = True"),Ua=s(" \uFF09\u3002\u6211\u4EEC\u5C06\u5728\u7B2C 10 \u7AE0\u8BA8\u8BBA\u5B83\u652F\u6301\u7684\u6240\u6709\u5185\u5BB9\u3002"),Cr=f(),st=a("p"),Fa=s("\u4F7F\u7528"),Xe=a("strong"),Ma=s("Trainer"),Ia=s(" API\u5FAE\u8C03\u7684\u4ECB\u7ECD\u5230\u6B64\u7ED3\u675F\u3002\u5BF9\u6700\u5E38\u89C1\u7684 NLP \u4EFB\u52A1\u6267\u884C\u6B64\u64CD\u4F5C\u7684\u793A\u4F8B\u5C06\u5728\u7B2C 7 \u7AE0\u4E2D\u7ED9\u51FA\uFF0C\u4F46\u73B0\u5728\u8BA9\u6211\u4EEC\u770B\u770B\u5982\u4F55\u5728\u7EAF PyTorch \u4E2D\u6267\u884C\u76F8\u540C\u7684\u64CD\u4F5C\u3002"),xr=f(),h(ot.$$.fragment),this.h()},l(t){const i=_l('[data-svelte="svelte-1phssyn"]',document.head);m=n(i,"META",{name:!0,content:!0}),i.forEach(r),j=c(t),T(_.$$.fragment,t),q=c(t),w=n(t,"H1",{class:!0});var Ot=l(w);$=n(Ot,"A",{id:!0,class:!0,href:!0});var Ke=l($);b=n(Ke,"SPAN",{});var Qe=l(b);T(A.$$.fragment,Qe),Qe.forEach(r),Ke.forEach(r),Wr=c(Ot),Ft=n(Ot,"SPAN",{});var Da=l(Ft);Hr=o(Da,"\u4F7F\u7528 Trainer API \u5FAE\u8C03\u6A21\u578B"),Da.forEach(r),Ot.forEach(r),Ve=c(t),T(ft.$$.fragment,t),Ze=c(t),T(ct.$$.fragment,t),tr=c(t),y=n(t,"P",{});var Y=l(y);Yr=o(Y,"\u{1F917} Transformers\u63D0\u4F9B\u4E86\u4E00\u4E2A "),Mt=n(Y,"STRONG",{});var La=l(Mt);Jr=o(La,"Trainer"),La.forEach(r),Xr=o(Y," \u7C7B\u6765\u5E2E\u52A9\u60A8\u5728\u81EA\u5DF1\u7684\u6570\u636E\u96C6\u4E0A\u5FAE\u8C03\u4EFB\u4F55\u9884\u8BAD\u7EC3\u6A21\u578B\u3002\u5B8C\u6210\u4E0A\u4E00\u8282\u4E2D\u7684\u6240\u6709\u6570\u636E\u9884\u5904\u7406\u5DE5\u4F5C\u540E\uFF0C\u60A8\u53EA\u9700\u8981\u6267\u884C\u51E0\u4E2A\u6B65\u9AA4\u6765\u521B\u5EFA "),It=n(Y,"STRONG",{});var Ba=l(It);Kr=o(Ba,"Trainer"),Ba.forEach(r),Qr=o(Y," .\u6700\u96BE\u7684\u90E8\u5206\u53EF\u80FD\u662F\u4E3A "),Dt=n(Y,"STRONG",{});var Wa=l(Dt);Vr=o(Wa,"Trainer.train()"),Wa.forEach(r),Zr=o(Y,"\u914D\u7F6E\u8FD0\u884C\u73AF\u5883\uFF0C\u56E0\u4E3A\u5B83\u5728 CPU \u4E0A\u8FD0\u884C\u901F\u5EA6\u4F1A\u975E\u5E38\u6162\u3002\u5982\u679C\u60A8\u6CA1\u6709\u8BBE\u7F6E GPU\uFF0C\u60A8\u53EF\u4EE5\u8BBF\u95EE\u514D\u8D39\u7684 GPU \u6216 TPU"),mt=n(Y,"A",{href:!0,rel:!0});var Ha=l(mt);ts=o(Ha,"Google Colab"),Ha.forEach(r),es=o(Y,"."),Y.forEach(r),er=c(t),Pt=n(t,"P",{});var Ya=l(Pt);rs=o(Ya,"\u4E0B\u9762\u7684\u793A\u4F8B\u5047\u8BBE\u60A8\u5DF2\u7ECF\u6267\u884C\u4E86\u4E0A\u4E00\u8282\u4E2D\u7684\u793A\u4F8B\u3002\u4E0B\u9762\u8FD9\u6BB5\u4EE3\u7801\uFF0C\u6982\u62EC\u4E86\u60A8\u9700\u8981\u63D0\u524D\u8FD0\u884C\u7684\u4EE3\u7801\uFF1A"),Ya.forEach(r),rr=c(t),T(gt.$$.fragment,t),sr=c(t),X=n(t,"H3",{class:!0});var Fr=l(X);Q=n(Fr,"A",{id:!0,class:!0,href:!0});var Ja=l(Q);Lt=n(Ja,"SPAN",{});var Xa=l(Lt);T(_t.$$.fragment,Xa),Xa.forEach(r),Ja.forEach(r),ss=c(Fr),Bt=n(Fr,"SPAN",{});var Ka=l(Bt);os=o(Ka,"Training"),Ka.forEach(r),Fr.forEach(r),or=c(t),x=n(t,"P",{});var at=l(x);as=o(at,"\u5728\u6211\u4EEC\u5B9A\u4E49\u6211\u4EEC\u7684 "),Wt=n(at,"STRONG",{});var Qa=l(Wt);ns=o(Qa,"Trainer"),Qa.forEach(r),ls=o(at," \u4E4B\u524D\u9996\u5148\u8981\u5B9A\u4E49\u4E00\u4E2A "),Ht=n(at,"STRONG",{});var Va=l(Ht);is=o(Va,"TrainingArguments"),Va.forEach(r),ps=o(at," \u7C7B\uFF0C\u5B83\u5C06\u5305\u542B "),Yt=n(at,"STRONG",{});var Za=l(Yt);fs=o(Za,"Trainer"),Za.forEach(r),cs=o(at,"\u7528\u4E8E\u8BAD\u7EC3\u548C\u8BC4\u4F30\u7684\u6240\u6709\u8D85\u53C2\u6570\u3002\u60A8\u552F\u4E00\u5FC5\u987B\u63D0\u4F9B\u7684\u53C2\u6570\u662F\u4FDD\u5B58\u8BAD\u7EC3\u6A21\u578B\u7684\u76EE\u5F55\uFF0C\u4EE5\u53CA\u8BAD\u7EC3\u8FC7\u7A0B\u4E2D\u7684\u68C0\u67E5\u70B9\u3002\u5BF9\u4E8E\u5176\u4F59\u7684\u53C2\u6570\uFF0C\u60A8\u53EF\u4EE5\u4FDD\u7559\u9ED8\u8BA4\u503C\uFF0C\u8FD9\u5BF9\u4E8E\u57FA\u672C\u5FAE\u8C03\u5E94\u8BE5\u975E\u5E38\u6709\u6548\u3002"),at.forEach(r),ar=c(t),T(ut.$$.fragment,t),nr=c(t),T(V.$$.fragment,t),lr=c(t),Z=n(t,"P",{});var Mr=l(Z);ms=o(Mr,"\u7B2C\u4E8C\u6B65\u662F\u5B9A\u4E49\u6211\u4EEC\u7684\u6A21\u578B\u3002\u6B63\u5982\u5728[\u4E4B\u524D\u7684\u7AE0\u8282](/2_Using Transformers/Introduction)\u4E00\u6837\uFF0C\u6211\u4EEC\u5C06\u4F7F\u7528 "),Jt=n(Mr,"STRONG",{});var tn=l(Jt);gs=o(tn,"AutoModelForSequenceClassification"),tn.forEach(r),_s=o(Mr," \u7C7B\uFF0C\u5B83\u6709\u4E24\u4E2A\u53C2\u6570\uFF1A"),Mr.forEach(r),ir=c(t),T(dt.$$.fragment,t),pr=c(t),tt=n(t,"P",{});var Ir=l(tt);us=o(Ir,"\u4F60\u4F1A\u6CE8\u610F\u5230\uFF0C\u548C"),jt=n(Ir,"A",{href:!0});var en=l(jt);ds=o(en,"\u7B2C\u4E8C\u7AE0"),en.forEach(r),$s=o(Ir,"\u4E0D\u4E00\u6837\u7684\u662F\uFF0C\u5728\u5B9E\u4F8B\u5316\u6B64\u9884\u8BAD\u7EC3\u6A21\u578B\u540E\u4F1A\u6536\u5230\u8B66\u544A\u3002\u8FD9\u662F\u56E0\u4E3A BERT \u6CA1\u6709\u5728\u53E5\u5B50\u5BF9\u5206\u7C7B\u65B9\u9762\u8FDB\u884C\u8FC7\u9884\u8BAD\u7EC3\uFF0C\u6240\u4EE5\u9884\u8BAD\u7EC3\u6A21\u578B\u7684\u5934\u90E8\u5DF2\u7ECF\u88AB\u4E22\u5F03\uFF0C\u800C\u662F\u6DFB\u52A0\u4E86\u4E00\u4E2A\u9002\u5408\u53E5\u5B50\u5E8F\u5217\u5206\u7C7B\u7684\u65B0\u5934\u90E8\u3002\u8B66\u544A\u8868\u660E\u4E00\u4E9B\u6743\u91CD\u6CA1\u6709\u4F7F\u7528\uFF08\u5BF9\u5E94\u4E8E\u4E22\u5F03\u7684\u9884\u8BAD\u7EC3\u5934\u7684\u90A3\u4E9B\uFF09\uFF0C\u800C\u5176\u4ED6\u4E00\u4E9B\u6743\u91CD\u88AB\u968F\u673A\u521D\u59CB\u5316\uFF08\u65B0\u5934\u7684\u90A3\u4E9B\uFF09\u3002\u6700\u540E\u9F13\u52B1\u60A8\u8BAD\u7EC3\u6A21\u578B\uFF0C\u8FD9\u6B63\u662F\u6211\u4EEC\u73B0\u5728\u8981\u505A\u7684\u3002"),Ir.forEach(r),fr=c(t),R=n(t,"P",{});var I=l(R);hs=o(I,"\u4E00\u65E6\u6211\u4EEC\u6709\u4E86\u6211\u4EEC\u7684\u6A21\u578B\uFF0C\u6211\u4EEC\u5C31\u53EF\u4EE5\u5B9A\u4E49\u4E00\u4E2A "),Xt=n(I,"STRONG",{});var rn=l(Xt);Ts=o(rn,"Trainer"),rn.forEach(r),vs=o(I," \u901A\u8FC7\u5C06\u4E4B\u524D\u6784\u9020\u7684\u6240\u6709\u5BF9\u8C61\u4F20\u9012\u7ED9\u5B83\u2014\u2014\u6211\u4EEC\u7684"),Kt=n(I,"STRONG",{});var sn=l(Kt);Es=o(sn,"model"),sn.forEach(r),ks=o(I," \u3001"),Qt=n(I,"STRONG",{});var on=l(Qt);Ss=o(on,"training_args"),on.forEach(r),bs=o(I," \uFF0C\u8BAD\u7EC3\u548C\u9A8C\u8BC1\u6570\u636E\u96C6\uFF0C"),Vt=n(I,"STRONG",{});var an=l(Vt);Gs=o(an,"data_collator"),an.forEach(r),ws=o(I," \uFF0C\u548C "),Zt=n(I,"STRONG",{});var nn=l(Zt);Ns=o(nn,"tokenizer"),nn.forEach(r),Rs=o(I," \uFF1A"),I.forEach(r),cr=c(t),T($t.$$.fragment,t),mr=c(t),O=n(t,"P",{});var D=l(O);Os=o(D,"\u8BF7\u6CE8\u610F\uFF0C\u5F53\u60A8\u5728\u8FD9\u91CC\u5B8C\u6210"),te=n(D,"STRONG",{});var ln=l(te);Ps=o(ln,"tokenizer"),ln.forEach(r),js=o(D,"\u540E\uFF0C\u9ED8\u8BA4 "),ee=n(D,"STRONG",{});var pn=l(ee);qs=o(pn,"Trainer"),pn.forEach(r),ys=o(D,"\u4F7F\u7528 \u7684"),re=n(D,"STRONG",{});var fn=l(re);As=o(fn,"data_collator"),fn.forEach(r),zs=o(D,"\u4F1A\u4F7F\u7528\u4E4B\u524D\u9884\u5B9A\u4E49\u7684 "),se=n(D,"STRONG",{});var cn=l(se);Cs=o(cn,"DataCollatorWithPadding"),cn.forEach(r),xs=o(D," \uFF0C\u56E0\u6B64\u60A8\u53EF\u4EE5\u5728\u8FD9\u4E2A\u4F8B\u5B50\u4E2D\u8DF3\u8FC7 "),oe=n(D,"STRONG",{});var mn=l(oe);Us=o(mn,"data_collator=data_collator"),mn.forEach(r),Fs=o(D,"\u3002\u5728\u7B2C 2 \u8282\u4E2D\u5411\u60A8\u5C55\u793A\u8FD9\u90E8\u5206\u5904\u7406\u4ECD\u7136\u5F88\u91CD\u8981\uFF01"),D.forEach(r),gr=c(t),B=n(t,"P",{});var zt=l(B);Ms=o(zt,"\u4E3A\u4E86\u8BA9\u9884\u8BAD\u7EC3\u6A21\u578B\u5728\u5728\u6211\u4EEC\u7684\u6570\u636E\u96C6\u4E0A\u5FAE\u8C03\uFF0C\u6211\u4EEC\u53EA\u9700\u8981\u8C03\u7528"),ae=n(zt,"STRONG",{});var gn=l(ae);Is=o(gn,"Trainer"),gn.forEach(r),Ds=o(zt,"\u7684"),ne=n(zt,"STRONG",{});var _n=l(ne);Ls=o(_n,"train()"),_n.forEach(r),Bs=o(zt," \u65B9\u6CD5 \uFF1A"),zt.forEach(r),_r=c(t),T(ht.$$.fragment,t),ur=c(t),qt=n(t,"P",{});var un=l(qt);Ws=o(un,"\u8FD9\u5C06\u5F00\u59CB\u5FAE\u8C03\uFF08\u5728GPU\u4E0A\u5E94\u8BE5\u9700\u8981\u51E0\u5206\u949F\uFF09\uFF0C\u5E76\u6BCF500\u6B65\u62A5\u544A\u4E00\u6B21\u8BAD\u7EC3\u635F\u5931\u3002\u4F46\u662F\uFF0C\u5B83\u4E0D\u4F1A\u544A\u8BC9\u60A8\u6A21\u578B\u7684\u6027\u80FD\u5982\u4F55\uFF08\u6216\u8D28\u91CF\u5982\u4F55\uFF09\u3002\u8FD9\u662F\u56E0\u4E3A:"),un.forEach(r),dr=c(t),et=n(t,"OL",{});var Dr=l(et);z=n(Dr,"LI",{});var J=l(z);Hs=o(J,"\u6211\u4EEC\u6CA1\u6709\u901A\u8FC7\u5C06"),le=n(J,"STRONG",{});var dn=l(le);Ys=o(dn,"evaluation_strategy"),dn.forEach(r),Js=o(J,"\u8BBE\u7F6E\u4E3A\u201C"),ie=n(J,"STRONG",{});var $n=l(ie);Xs=o($n,"steps"),$n.forEach(r),Ks=o(J,"\u201D(\u5728\u6BCF\u6B21\u66F4\u65B0\u53C2\u6570\u7684\u65F6\u5019\u8BC4\u4F30)\u6216\u201C"),pe=n(J,"STRONG",{});var hn=l(pe);Qs=o(hn,"epoch"),hn.forEach(r),Vs=o(J,"\u201D(\u5728\u6BCF\u4E2Aepoch\u7ED3\u675F\u65F6\u8BC4\u4F30)\u6765\u544A\u8BC9"),fe=n(J,"STRONG",{});var Tn=l(fe);Zs=o(Tn,"Trainer"),Tn.forEach(r),to=o(J,"\u5728\u8BAD\u7EC3\u671F\u95F4\u8FDB\u884C\u8BC4\u4F30\u3002"),J.forEach(r),eo=c(Dr),K=n(Dr,"LI",{});var Ct=l(K);ro=o(Ct,"\u6211\u4EEC\u6CA1\u6709\u4E3A"),ce=n(Ct,"STRONG",{});var vn=l(ce);so=o(vn,"Trainer"),vn.forEach(r),oo=o(Ct,"\u63D0\u4F9B\u4E00\u4E2A"),me=n(Ct,"STRONG",{});var En=l(me);ao=o(En,"compute_metrics()"),En.forEach(r),no=o(Ct,"\u51FD\u6570\u6765\u76F4\u63A5\u8BA1\u7B97\u6A21\u578B\u7684\u597D\u574F(\u5426\u5219\u8BC4\u4F30\u5C06\u53EA\u8F93\u51FAloss\uFF0C\u8FD9\u4E0D\u662F\u4E00\u4E2A\u975E\u5E38\u76F4\u89C2\u7684\u6570\u5B57)\u3002"),Ct.forEach(r),Dr.forEach(r),$r=c(t),Tt=n(t,"H3",{id:!0});var kn=l(Tt);lo=o(kn,"\u8BC4\u4F30"),kn.forEach(r),hr=c(t),P=n(t,"P",{});var L=l(P);io=o(L,"\u8BA9\u6211\u4EEC\u770B\u770B\u5982\u4F55\u6784\u5EFA\u4E00\u4E2A\u6709\u7528\u7684 "),ge=n(L,"STRONG",{});var Sn=l(ge);po=o(Sn,"compute_metrics()"),Sn.forEach(r),fo=o(L," \u51FD\u6570\u5E76\u5728\u6211\u4EEC\u4E0B\u6B21\u8BAD\u7EC3\u65F6\u4F7F\u7528\u5B83\u3002\u8BE5\u51FD\u6570\u5FC5\u987B\u91C7\u7528 "),_e=n(L,"STRONG",{});var bn=l(_e);co=o(bn,"EvalPrediction"),bn.forEach(r),mo=o(L," \u5BF9\u8C61\uFF08\u5E26\u6709 "),ue=n(L,"STRONG",{});var Gn=l(ue);go=o(Gn,"predictions"),Gn.forEach(r),_o=o(L," \u548C "),de=n(L,"STRONG",{});var wn=l(de);uo=o(wn,"label_ids"),wn.forEach(r),$o=o(L," \u5B57\u6BB5\u7684\u53C2\u6570\u5143\u7EC4\uFF09\u5E76\u5C06\u8FD4\u56DE\u4E00\u4E2A\u5B57\u7B26\u4E32\u5230\u6D6E\u70B9\u6570\u7684\u5B57\u5178\uFF08\u5B57\u7B26\u4E32\u662F\u8FD4\u56DE\u7684\u6307\u6807\u7684\u540D\u79F0\uFF0C\u800C\u6D6E\u70B9\u6570\u662F\u5B83\u4EEC\u7684\u503C\uFF09\u3002\u6211\u4EEC\u53EF\u4EE5\u4F7F\u7528 "),$e=n(L,"STRONG",{});var Nn=l($e);ho=o(Nn,"Trainer.predict()"),Nn.forEach(r),To=o(L," \u547D\u4EE4\u6765\u4F7F\u7528\u6211\u4EEC\u7684\u6A21\u578B\u8FDB\u884C\u9884\u6D4B\uFF1A"),L.forEach(r),Tr=c(t),T(vt.$$.fragment,t),vr=c(t),T(Et.$$.fragment,t),Er=c(t),d=n(t,"P",{});var N=l(d);he=n(N,"STRONG",{});var Rn=l(he);vo=o(Rn,"predict()"),Rn.forEach(r),Eo=o(N," \u7684\u8F93\u51FA\u7ED3\u679C\u662F\u5177\u6709\u4E09\u4E2A\u5B57\u6BB5\u7684\u547D\u540D\u5143\u7EC4\uFF1A "),Te=n(N,"STRONG",{});var On=l(Te);ko=o(On,"predictions"),On.forEach(r),So=o(N," , "),ve=n(N,"STRONG",{});var Pn=l(ve);bo=o(Pn,"label_ids"),Pn.forEach(r),Go=o(N," \uFF0C \u548C "),Ee=n(N,"STRONG",{});var jn=l(Ee);wo=o(jn,"metrics"),jn.forEach(r),No=o(N," .\u8FD9 "),ke=n(N,"STRONG",{});var qn=l(ke);Ro=o(qn,"metrics"),qn.forEach(r),Oo=o(N," \u5B57\u6BB5\u5C06\u53EA\u5305\u542B\u4F20\u9012\u7684\u6570\u636E\u96C6\u7684loss\uFF0C\u4EE5\u53CA\u4E00\u4E9B\u8FD0\u884C\u65F6\u95F4\uFF08\u9884\u6D4B\u6240\u9700\u7684\u603B\u65F6\u95F4\u548C\u5E73\u5747\u65F6\u95F4\uFF09\u3002\u5982\u679C\u6211\u4EEC\u5B9A\u4E49\u4E86\u81EA\u5DF1\u7684 "),Se=n(N,"STRONG",{});var yn=l(Se);Po=o(yn,"compute_metrics()"),yn.forEach(r),jo=o(N," \u51FD\u6570\u5E76\u5C06\u5176\u4F20\u9012\u7ED9 "),be=n(N,"STRONG",{});var An=l(be);qo=o(An,"Trainer"),An.forEach(r),yo=o(N," \uFF0C\u8BE5\u5B57\u6BB5\u8FD8\u5C06\u5305\u542B"),Ge=n(N,"STRONG",{});var zn=l(Ge);Ao=o(zn,"compute_metrics()"),zn.forEach(r),zo=o(N,"\u7684\u7ED3\u679C\u3002"),N.forEach(r),kr=c(t),g=n(t,"P",{});var u=l(g);we=n(u,"STRONG",{});var Cn=l(we);Co=o(Cn,"predict()"),Cn.forEach(r),xo=o(u," \u65B9\u6CD5\u662F\u5177\u6709\u4E09\u4E2A\u5B57\u6BB5\u7684\u547D\u540D\u5143\u7EC4\uFF1A "),Ne=n(u,"STRONG",{});var xn=l(Ne);Uo=o(xn,"predictions"),xn.forEach(r),Fo=o(u," , "),Re=n(u,"STRONG",{});var Un=l(Re);Mo=o(Un,"label_ids"),Un.forEach(r),Io=o(u," \uFF0C \u548C "),Oe=n(u,"STRONG",{});var Fn=l(Oe);Do=o(Fn,"metrics"),Fn.forEach(r),Lo=o(u," .\u8FD9 "),Pe=n(u,"STRONG",{});var Mn=l(Pe);Bo=o(Mn,"metrics"),Mn.forEach(r),Wo=o(u," \u5B57\u6BB5\u5C06\u53EA\u5305\u542B\u4F20\u9012\u7684\u6570\u636E\u96C6\u7684loss\uFF0C\u4EE5\u53CA\u4E00\u4E9B\u8FD0\u884C\u65F6\u95F4\uFF08\u9884\u6D4B\u6240\u9700\u7684\u603B\u65F6\u95F4\u548C\u5E73\u5747\u65F6\u95F4\uFF09\u3002\u5982\u679C\u6211\u4EEC\u5B9A\u4E49\u4E86\u81EA\u5DF1\u7684 "),je=n(u,"STRONG",{});var In=l(je);Ho=o(In,"compute_metrics()"),In.forEach(r),Yo=o(u," \u51FD\u6570\u5E76\u5C06\u5176\u4F20\u9012\u7ED9 "),qe=n(u,"STRONG",{});var Dn=l(qe);Jo=o(Dn,"Trainer"),Dn.forEach(r),Xo=o(u," \uFF0C\u8BE5\u5B57\u6BB5\u8FD8\u5C06\u5305\u542B"),ye=n(u,"STRONG",{});var Ln=l(ye);Ko=o(Ln,"compute_metrics()"),Ln.forEach(r),Qo=o(u," \u7684\u7ED3\u679C\u3002\u5982\u4F60\u770B\u5230\u7684\uFF0C "),Ae=n(u,"STRONG",{});var Bn=l(Ae);Vo=o(Bn,"predictions"),Bn.forEach(r),Zo=o(u," \u662F\u4E00\u4E2A\u5F62\u72B6\u4E3A 408 x 2 \u7684\u4E8C\u7EF4\u6570\u7EC4\uFF08408 \u662F\u6211\u4EEC\u4F7F\u7528\u7684\u6570\u636E\u96C6\u4E2D\u5143\u7D20\u7684\u6570\u91CF\uFF09\u3002\u8FD9\u4E9B\u662F\u6211\u4EEC\u4F20\u9012\u7ED9"),ze=n(u,"STRONG",{});var Wn=l(ze);ta=o(Wn,"predict()"),Wn.forEach(r),ea=o(u,"\u7684\u6570\u636E\u96C6\u7684\u6BCF\u4E2A\u5143\u7D20\u7684\u7ED3\u679C(logits)\uFF08\u6B63\u5982\u4F60\u5728"),yt=n(u,"A",{href:!0});var Hn=l(yt);ra=o(Hn,"\u4E4B\u524D\u7684\u7AE0\u8282"),Hn.forEach(r),sa=o(u,"\u770B\u5230\u7684\u60C5\u51B5\uFF09\u3002\u8981\u5C06\u6211\u4EEC\u7684\u9884\u6D4B\u7684\u53EF\u4EE5\u4E0E\u771F\u6B63\u7684\u6807\u7B7E\u8FDB\u884C\u6BD4\u8F83\uFF0C\u6211\u4EEC\u9700\u8981\u5728\u7B2C\u4E8C\u4E2A\u8F74\u4E0A\u53D6\u6700\u5927\u503C\u7684\u7D22\u5F15\uFF1A"),u.forEach(r),Sr=c(t),T(kt.$$.fragment,t),br=c(t),U=n(t,"P",{});var nt=l(U);oa=o(nt,"\u73B0\u5728\u5EFA\u7ACB\u6211\u4EEC\u7684 "),Ce=n(nt,"STRONG",{});var Yn=l(Ce);aa=o(Yn,"compute_metric()"),Yn.forEach(r),na=o(nt," \u51FD\u6570\u6765\u8F83\u4E3A\u76F4\u89C2\u5730\u8BC4\u4F30\u6A21\u578B\u7684\u597D\u574F\uFF0C\u6211\u4EEC\u5C06\u4F7F\u7528 \u{1F917} Datasets \u5E93\u4E2D\u7684\u6307\u6807\u3002\u6211\u4EEC\u53EF\u4EE5\u50CF\u52A0\u8F7D\u6570\u636E\u96C6\u4E00\u6837\u8F7B\u677E\u52A0\u8F7D\u4E0E MRPC \u6570\u636E\u96C6\u5173\u8054\u7684\u6307\u6807\uFF0C\u8FD9\u6B21\u4F7F\u7528 "),xe=n(nt,"STRONG",{});var Jn=l(xe);la=o(Jn,"load_metric()"),Jn.forEach(r),ia=o(nt," \u51FD\u6570\u3002\u8FD4\u56DE\u7684\u5BF9\u8C61\u6709\u4E00\u4E2A "),Ue=n(nt,"STRONG",{});var Xn=l(Ue);pa=o(Xn,"compute()"),Xn.forEach(r),fa=o(nt,"\u65B9\u6CD5\u6211\u4EEC\u53EF\u4EE5\u7528\u6765\u8FDB\u884C\u5EA6\u91CF\u8BA1\u7B97\u7684\u65B9\u6CD5\uFF1A"),nt.forEach(r),Gr=c(t),T(St.$$.fragment,t),wr=c(t),T(bt.$$.fragment,t),Nr=c(t),F=n(t,"P",{});var lt=l(F);ca=o(lt,"\u60A8\u83B7\u5F97\u7684\u786E\u5207\u7ED3\u679C\u53EF\u80FD\u4F1A\u6709\u6240\u4E0D\u540C\uFF0C\u56E0\u4E3A\u6A21\u578B\u5934\u7684\u968F\u673A\u521D\u59CB\u5316\u53EF\u80FD\u4F1A\u5F71\u54CD\u6700\u7EC8\u5EFA\u7ACB\u7684\u6A21\u578B\u3002\u5728\u8FD9\u91CC\uFF0C\u6211\u4EEC\u53EF\u4EE5\u770B\u5230\u6211\u4EEC\u7684\u6A21\u578B\u5728\u9A8C\u8BC1\u96C6\u4E0A\u7684\u51C6\u786E\u7387\u4E3A 85.78%\uFF0CF1 \u5206\u6570\u4E3A 89.97\u3002\u8FD9\u662F\u7528\u4E8E\u8BC4\u4F30 GLUE \u57FA\u51C6\u7684 MRPC \u6570\u636E\u96C6\u7ED3\u679C\u7684\u4E24\u4E2A\u6307\u6807\u3002\u800C\u5728"),Gt=n(lt,"A",{href:!0,rel:!0});var Kn=l(Gt);ma=o(Kn,"BERT \u8BBA\u6587"),Kn.forEach(r),ga=o(lt,"\u4E2D\u5C55\u793A\u7684\u57FA\u7840\u6A21\u578B\u7684 F1 \u5206\u6570\u4E3A 88.9\u3002\u90A3\u662F "),Fe=n(lt,"STRONG",{});var Qn=l(Fe);_a=o(Qn,"uncased"),Qn.forEach(r),ua=o(lt," \u6A21\u578B\uFF0C\u800C\u6211\u4EEC\u76EE\u524D\u6B63\u5728\u4F7F\u7528 "),Me=n(lt,"STRONG",{});var Vn=l(Me);da=o(Vn,"cased"),Vn.forEach(r),$a=o(lt," \u6A21\u578B\uFF0C\u901A\u8FC7\u6539\u8FDB\u5F97\u5230\u4E86\u66F4\u597D\u7684\u7ED3\u679C\u3002"),lt.forEach(r),Rr=c(t),rt=n(t,"P",{});var Lr=l(rt);ha=o(Lr,"\u6700\u540E\u5C06\u6240\u6709\u4E1C\u897F\u6253\u5305\u5728\u4E00\u8D77\uFF0C\u6211\u4EEC\u5F97\u5230\u4E86\u6211\u4EEC\u7684 "),Ie=n(Lr,"STRONG",{});var Zn=l(Ie);Ta=o(Zn,"compute_metrics()"),Zn.forEach(r),va=o(Lr," \u51FD\u6570\uFF1A"),Lr.forEach(r),Or=c(t),T(wt.$$.fragment,t),Pr=c(t),W=n(t,"P",{});var xt=l(W);Ea=o(xt,"\u4E3A\u4E86\u67E5\u770B\u6A21\u578B\u5728\u6BCF\u4E2A\u8BAD\u7EC3\u5468\u671F\u7ED3\u675F\u7684\u597D\u574F\uFF0C\u4E0B\u9762\u662F\u6211\u4EEC\u5982\u4F55\u4F7F\u7528"),De=n(xt,"STRONG",{});var tl=l(De);ka=o(tl,"compute_metrics()"),tl.forEach(r),Sa=o(xt,"\u51FD\u6570\u5B9A\u4E49\u4E00\u4E2A\u65B0\u7684 "),Le=n(xt,"STRONG",{});var el=l(Le);ba=o(el,"Trainer"),el.forEach(r),Ga=o(xt," \uFF1A"),xt.forEach(r),jr=c(t),T(Nt.$$.fragment,t),qr=c(t),M=n(t,"P",{});var it=l(M);wa=o(it,"\u8BF7\u6CE8\u610F\uFF0C\u6211\u4EEC\u8BBE\u7F6E\u4E86\u4E86\u4E00\u4E2A\u65B0\u7684 "),Be=n(it,"STRONG",{});var rl=l(Be);Na=o(rl,"TrainingArguments"),rl.forEach(r),Ra=o(it," \u5B83\u7684"),We=n(it,"STRONG",{});var sl=l(We);Oa=o(sl,"evaluation_strategy"),sl.forEach(r),Pa=o(it," \u8BBE\u7F6E\u4E3A "),He=n(it,"STRONG",{});var ol=l(He);ja=o(ol,"epoch"),ol.forEach(r),qa=o(it," \u5E76\u521B\u5EFA\u4E86\u4E00\u4E2A\u65B0\u6A21\u578B\u3002\u5982\u679C\u4E0D\u521B\u5EFA\u65B0\u7684\u6A21\u578B\u5C31\u76F4\u63A5\u8BAD\u7EC3\uFF0C\u5C31\u53EA\u4F1A\u7EE7\u7EED\u8BAD\u7EC3\u4E4B\u524D\u6211\u4EEC\u5DF2\u7ECF\u8BAD\u7EC3\u8FC7\u7684\u6A21\u578B\u3002\u8981\u542F\u52A8\u65B0\u7684\u8BAD\u7EC3\u8FD0\u884C\uFF0C\u6211\u4EEC\u6267\u884C\uFF1A"),it.forEach(r),yr=c(t),T(Rt.$$.fragment,t),Ar=c(t),At=n(t,"P",{});var al=l(At);ya=o(al,"\u8FD9\u4E00\u6B21\uFF0C\u5B83\u5C06\u5728\u8BAD\u7EC3loss\u4E4B\u5916\uFF0C\u8FD8\u4F1A\u8F93\u51FA\u6BCF\u4E2A epoch \u7ED3\u675F\u65F6\u7684\u9A8C\u8BC1loss\u548C\u6307\u6807\u3002\u540C\u6837\uFF0C\u7531\u4E8E\u6A21\u578B\u7684\u968F\u673A\u5934\u90E8\u521D\u59CB\u5316\uFF0C\u60A8\u8FBE\u5230\u7684\u51C6\u786E\u7387/F1 \u5206\u6570\u53EF\u80FD\u4E0E\u6211\u4EEC\u53D1\u73B0\u7684\u7565\u6709\u4E0D\u540C\uFF0C\u4F46\u5B83\u5E94\u8BE5\u5728\u540C\u4E00\u8303\u56F4\u5185\u3002"),al.forEach(r),zr=c(t),H=n(t,"P",{});var Ut=l(H);Aa=o(Ut,"\u8FD9 "),Ye=n(Ut,"STRONG",{});var nl=l(Ye);za=o(nl,"Trainer"),nl.forEach(r),Ca=o(Ut," \u5C06\u5728\u591A\u4E2A GPU \u6216 TPU \u4E0A\u5F00\u7BB1\u5373\u7528\uFF0C\u5E76\u63D0\u4F9B\u8BB8\u591A\u9009\u9879\uFF0C\u4F8B\u5982\u6DF7\u5408\u7CBE\u5EA6\u8BAD\u7EC3\uFF08\u5728\u8BAD\u7EC3\u7684\u53C2\u6570\u4E2D\u4F7F\u7528 "),Je=n(Ut,"STRONG",{});var ll=l(Je);xa=o(ll,"fp16 = True"),ll.forEach(r),Ua=o(Ut," \uFF09\u3002\u6211\u4EEC\u5C06\u5728\u7B2C 10 \u7AE0\u8BA8\u8BBA\u5B83\u652F\u6301\u7684\u6240\u6709\u5185\u5BB9\u3002"),Ut.forEach(r),Cr=c(t),st=n(t,"P",{});var Br=l(st);Fa=o(Br,"\u4F7F\u7528"),Xe=n(Br,"STRONG",{});var il=l(Xe);Ma=o(il,"Trainer"),il.forEach(r),Ia=o(Br," API\u5FAE\u8C03\u7684\u4ECB\u7ECD\u5230\u6B64\u7ED3\u675F\u3002\u5BF9\u6700\u5E38\u89C1\u7684 NLP \u4EFB\u52A1\u6267\u884C\u6B64\u64CD\u4F5C\u7684\u793A\u4F8B\u5C06\u5728\u7B2C 7 \u7AE0\u4E2D\u7ED9\u51FA\uFF0C\u4F46\u73B0\u5728\u8BA9\u6211\u4EEC\u770B\u770B\u5982\u4F55\u5728\u7EAF PyTorch \u4E2D\u6267\u884C\u76F8\u540C\u7684\u64CD\u4F5C\u3002"),Br.forEach(r),xr=c(t),T(ot.$$.fragment,t),this.h()},h(){G(m,"name","hf:doc:metadata"),G(m,"content",JSON.stringify(kl)),G($,"id","trainer-api"),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"),G($,"href","#trainer-api"),G(w,"class","relative group"),G(mt,"href","https://colab.research.google.com/"),G(mt,"rel","nofollow"),G(Q,"id","training"),G(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"),G(Q,"href","#training"),G(X,"class","relative group"),G(jt,"href","/course/chapter2"),G(Tt,"id",""),G(yt,"href","/course/chapter2"),G(Gt,"href","https://arxiv.org/pdf/1810.04805.pdf"),G(Gt,"rel","nofollow")},m(t,i){e(document.head,m),p(t,j,i),v(_,t,i),p(t,q,i),p(t,w,i),e(w,$),e($,b),v(A,b,null),e(w,Wr),e(w,Ft),e(Ft,Hr),p(t,Ve,i),v(ft,t,i),p(t,Ze,i),v(ct,t,i),p(t,tr,i),p(t,y,i),e(y,Yr),e(y,Mt),e(Mt,Jr),e(y,Xr),e(y,It),e(It,Kr),e(y,Qr),e(y,Dt),e(Dt,Vr),e(y,Zr),e(y,mt),e(mt,ts),e(y,es),p(t,er,i),p(t,Pt,i),e(Pt,rs),p(t,rr,i),v(gt,t,i),p(t,sr,i),p(t,X,i),e(X,Q),e(Q,Lt),v(_t,Lt,null),e(X,ss),e(X,Bt),e(Bt,os),p(t,or,i),p(t,x,i),e(x,as),e(x,Wt),e(Wt,ns),e(x,ls),e(x,Ht),e(Ht,is),e(x,ps),e(x,Yt),e(Yt,fs),e(x,cs),p(t,ar,i),v(ut,t,i),p(t,nr,i),v(V,t,i),p(t,lr,i),p(t,Z,i),e(Z,ms),e(Z,Jt),e(Jt,gs),e(Z,_s),p(t,ir,i),v(dt,t,i),p(t,pr,i),p(t,tt,i),e(tt,us),e(tt,jt),e(jt,ds),e(tt,$s),p(t,fr,i),p(t,R,i),e(R,hs),e(R,Xt),e(Xt,Ts),e(R,vs),e(R,Kt),e(Kt,Es),e(R,ks),e(R,Qt),e(Qt,Ss),e(R,bs),e(R,Vt),e(Vt,Gs),e(R,ws),e(R,Zt),e(Zt,Ns),e(R,Rs),p(t,cr,i),v($t,t,i),p(t,mr,i),p(t,O,i),e(O,Os),e(O,te),e(te,Ps),e(O,js),e(O,ee),e(ee,qs),e(O,ys),e(O,re),e(re,As),e(O,zs),e(O,se),e(se,Cs),e(O,xs),e(O,oe),e(oe,Us),e(O,Fs),p(t,gr,i),p(t,B,i),e(B,Ms),e(B,ae),e(ae,Is),e(B,Ds),e(B,ne),e(ne,Ls),e(B,Bs),p(t,_r,i),v(ht,t,i),p(t,ur,i),p(t,qt,i),e(qt,Ws),p(t,dr,i),p(t,et,i),e(et,z),e(z,Hs),e(z,le),e(le,Ys),e(z,Js),e(z,ie),e(ie,Xs),e(z,Ks),e(z,pe),e(pe,Qs),e(z,Vs),e(z,fe),e(fe,Zs),e(z,to),e(et,eo),e(et,K),e(K,ro),e(K,ce),e(ce,so),e(K,oo),e(K,me),e(me,ao),e(K,no),p(t,$r,i),p(t,Tt,i),e(Tt,lo),p(t,hr,i),p(t,P,i),e(P,io),e(P,ge),e(ge,po),e(P,fo),e(P,_e),e(_e,co),e(P,mo),e(P,ue),e(ue,go),e(P,_o),e(P,de),e(de,uo),e(P,$o),e(P,$e),e($e,ho),e(P,To),p(t,Tr,i),v(vt,t,i),p(t,vr,i),v(Et,t,i),p(t,Er,i),p(t,d,i),e(d,he),e(he,vo),e(d,Eo),e(d,Te),e(Te,ko),e(d,So),e(d,ve),e(ve,bo),e(d,Go),e(d,Ee),e(Ee,wo),e(d,No),e(d,ke),e(ke,Ro),e(d,Oo),e(d,Se),e(Se,Po),e(d,jo),e(d,be),e(be,qo),e(d,yo),e(d,Ge),e(Ge,Ao),e(d,zo),p(t,kr,i),p(t,g,i),e(g,we),e(we,Co),e(g,xo),e(g,Ne),e(Ne,Uo),e(g,Fo),e(g,Re),e(Re,Mo),e(g,Io),e(g,Oe),e(Oe,Do),e(g,Lo),e(g,Pe),e(Pe,Bo),e(g,Wo),e(g,je),e(je,Ho),e(g,Yo),e(g,qe),e(qe,Jo),e(g,Xo),e(g,ye),e(ye,Ko),e(g,Qo),e(g,Ae),e(Ae,Vo),e(g,Zo),e(g,ze),e(ze,ta),e(g,ea),e(g,yt),e(yt,ra),e(g,sa),p(t,Sr,i),v(kt,t,i),p(t,br,i),p(t,U,i),e(U,oa),e(U,Ce),e(Ce,aa),e(U,na),e(U,xe),e(xe,la),e(U,ia),e(U,Ue),e(Ue,pa),e(U,fa),p(t,Gr,i),v(St,t,i),p(t,wr,i),v(bt,t,i),p(t,Nr,i),p(t,F,i),e(F,ca),e(F,Gt),e(Gt,ma),e(F,ga),e(F,Fe),e(Fe,_a),e(F,ua),e(F,Me),e(Me,da),e(F,$a),p(t,Rr,i),p(t,rt,i),e(rt,ha),e(rt,Ie),e(Ie,Ta),e(rt,va),p(t,Or,i),v(wt,t,i),p(t,Pr,i),p(t,W,i),e(W,Ea),e(W,De),e(De,ka),e(W,Sa),e(W,Le),e(Le,ba),e(W,Ga),p(t,jr,i),v(Nt,t,i),p(t,qr,i),p(t,M,i),e(M,wa),e(M,Be),e(Be,Na),e(M,Ra),e(M,We),e(We,Oa),e(M,Pa),e(M,He),e(He,ja),e(M,qa),p(t,yr,i),v(Rt,t,i),p(t,Ar,i),p(t,At,i),e(At,ya),p(t,zr,i),p(t,H,i),e(H,Aa),e(H,Ye),e(Ye,za),e(H,Ca),e(H,Je),e(Je,xa),e(H,Ua),p(t,Cr,i),p(t,st,i),e(st,Fa),e(st,Xe),e(Xe,Ma),e(st,Ia),p(t,xr,i),v(ot,t,i),Ur=!0},p(t,[i]){const Ot={};i&1&&(Ot.fw=t[0]),_.$set(Ot);const Ke={};i&2&&(Ke.$$scope={dirty:i,ctx:t}),V.$set(Ke);const Qe={};i&2&&(Qe.$$scope={dirty:i,ctx:t}),ot.$set(Qe)},i(t){Ur||(E(_.$$.fragment,t),E(A.$$.fragment,t),E(ft.$$.fragment,t),E(ct.$$.fragment,t),E(gt.$$.fragment,t),E(_t.$$.fragment,t),E(ut.$$.fragment,t),E(V.$$.fragment,t),E(dt.$$.fragment,t),E($t.$$.fragment,t),E(ht.$$.fragment,t),E(vt.$$.fragment,t),E(Et.$$.fragment,t),E(kt.$$.fragment,t),E(St.$$.fragment,t),E(bt.$$.fragment,t),E(wt.$$.fragment,t),E(Nt.$$.fragment,t),E(Rt.$$.fragment,t),E(ot.$$.fragment,t),Ur=!0)},o(t){k(_.$$.fragment,t),k(A.$$.fragment,t),k(ft.$$.fragment,t),k(ct.$$.fragment,t),k(gt.$$.fragment,t),k(_t.$$.fragment,t),k(ut.$$.fragment,t),k(V.$$.fragment,t),k(dt.$$.fragment,t),k($t.$$.fragment,t),k(ht.$$.fragment,t),k(vt.$$.fragment,t),k(Et.$$.fragment,t),k(kt.$$.fragment,t),k(St.$$.fragment,t),k(bt.$$.fragment,t),k(wt.$$.fragment,t),k(Nt.$$.fragment,t),k(Rt.$$.fragment,t),k(ot.$$.fragment,t),Ur=!1},d(t){r(m),t&&r(j),S(_,t),t&&r(q),t&&r(w),S(A),t&&r(Ve),S(ft,t),t&&r(Ze),S(ct,t),t&&r(tr),t&&r(y),t&&r(er),t&&r(Pt),t&&r(rr),S(gt,t),t&&r(sr),t&&r(X),S(_t),t&&r(or),t&&r(x),t&&r(ar),S(ut,t),t&&r(nr),S(V,t),t&&r(lr),t&&r(Z),t&&r(ir),S(dt,t),t&&r(pr),t&&r(tt),t&&r(fr),t&&r(R),t&&r(cr),S($t,t),t&&r(mr),t&&r(O),t&&r(gr),t&&r(B),t&&r(_r),S(ht,t),t&&r(ur),t&&r(qt),t&&r(dr),t&&r(et),t&&r($r),t&&r(Tt),t&&r(hr),t&&r(P),t&&r(Tr),S(vt,t),t&&r(vr),S(Et,t),t&&r(Er),t&&r(d),t&&r(kr),t&&r(g),t&&r(Sr),S(kt,t),t&&r(br),t&&r(U),t&&r(Gr),S(St,t),t&&r(wr),S(bt,t),t&&r(Nr),t&&r(F),t&&r(Rr),t&&r(rt),t&&r(Or),S(wt,t),t&&r(Pr),t&&r(W),t&&r(jr),S(Nt,t),t&&r(qr),t&&r(M),t&&r(yr),S(Rt,t),t&&r(Ar),t&&r(At),t&&r(zr),t&&r(H),t&&r(Cr),t&&r(st),t&&r(xr),S(ot,t)}}}const kl={local:"trainer-api",sections:[{local:"training",title:"Training"},{local:"",title:"\u8BC4\u4F30"}],title:"\u4F7F\u7528 Trainer API \u5FAE\u8C03\u6A21\u578B"};function Sl(pt,m,j){let _="pt";return ul(()=>{const q=new URLSearchParams(window.location.search);j(0,_=q.get("fw")||"pt")}),[_]}class jl extends cl{constructor(m){super();ml(this,m,Sl,El,gl,{})}}export{jl as default,kl as metadata};
