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

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

metric = evaluate.load(<span class="hljs-string">&quot;glue&quot;</span>, <span class="hljs-string">&quot;mrpc&quot;</span>)
metric.compute(predictions=preds, references=predictions.label_ids)`}}),Gt=new x({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>}'}}),Rt=new x({props:{code:`def compute_metrics(eval_preds):
    metric = evaluate.load("glue", "mrpc")
    logits, labels = eval_preds
    predictions = np.argmax(logits, axis=-1)
    return metric.compute(predictions=predictions, references=labels)`,highlighted:`<span class="hljs-keyword">def</span> <span class="hljs-title function_">compute_metrics</span>(<span class="hljs-params">eval_preds</span>):
    metric = evaluate.load(<span class="hljs-string">&quot;glue&quot;</span>, <span class="hljs-string">&quot;mrpc&quot;</span>)
    logits, labels = eval_preds
    predictions = np.argmax(logits, axis=-<span class="hljs-number">1</span>)
    <span class="hljs-keyword">return</span> metric.compute(predictions=predictions, references=labels)`}}),wt=new x({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,
)`}}),Ot=new x({props:{code:"trainer.train()",highlighted:'trainer.trai<span class="hljs-meta">n</span>()'}}),at=new gl({props:{$$slots:{default:[bl]},$$scope:{ctx:pt}}}),{c(){m=a("meta"),j=f(),h(_.$$.fragment),q=f(),N=a("h1"),$=a("a"),G=a("span"),h(y.$$.fragment),Hr=f(),Mt=a("span"),Yr=s("\u4F7F\u7528 Trainer API \u5FAE\u8C03\u6A21\u578B"),Ze=f(),h(ft.$$.fragment),tr=f(),h(ct.$$.fragment),er=f(),z=a("p"),Jr=s("\u{1F917} Transformers\u63D0\u4F9B\u4E86\u4E00\u4E2A "),It=a("strong"),Xr=s("Trainer"),Kr=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 "),Lt=a("strong"),Qr=s("Trainer"),Vr=s(" .\u6700\u96BE\u7684\u90E8\u5206\u53EF\u80FD\u662F\u4E3A "),Bt=a("strong"),Zr=s("Trainer.train()"),ts=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"),es=s("Google Colab"),rs=s("."),rr=f(),jt=a("p"),ss=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"),sr=f(),h(gt.$$.fragment),or=f(),K=a("h3"),V=a("a"),Dt=a("span"),h(_t.$$.fragment),os=f(),Wt=a("span"),as=s("Training"),ar=f(),U=a("p"),ns=s("\u5728\u6211\u4EEC\u5B9A\u4E49\u6211\u4EEC\u7684 "),Ht=a("strong"),ls=s("Trainer"),is=s(" \u4E4B\u524D\u9996\u5148\u8981\u5B9A\u4E49\u4E00\u4E2A "),Yt=a("strong"),ps=s("TrainingArguments"),fs=s(" \u7C7B\uFF0C\u5B83\u5C06\u5305\u542B "),Jt=a("strong"),cs=s("Trainer"),ms=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"),nr=f(),h(ut.$$.fragment),lr=f(),h(Z.$$.fragment),ir=f(),tt=a("p"),gs=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 "),Xt=a("strong"),_s=s("AutoModelForSequenceClassification"),us=s(" \u7C7B\uFF0C\u5B83\u6709\u4E24\u4E2A\u53C2\u6570\uFF1A"),pr=f(),h(dt.$$.fragment),fr=f(),et=a("p"),ds=s("\u4F60\u4F1A\u6CE8\u610F\u5230\uFF0C\u548C"),qt=a("a"),$s=s("\u7B2C\u4E8C\u7AE0"),hs=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"),cr=f(),w=a("p"),vs=s("\u4E00\u65E6\u6211\u4EEC\u6709\u4E86\u6211\u4EEC\u7684\u6A21\u578B\uFF0C\u6211\u4EEC\u5C31\u53EF\u4EE5\u5B9A\u4E49\u4E00\u4E2A "),Kt=a("strong"),Ts=s("Trainer"),Es=s(" \u901A\u8FC7\u5C06\u4E4B\u524D\u6784\u9020\u7684\u6240\u6709\u5BF9\u8C61\u4F20\u9012\u7ED9\u5B83\u2014\u2014\u6211\u4EEC\u7684"),Qt=a("strong"),ks=s("model"),Ss=s(" \u3001"),Vt=a("strong"),bs=s("training_args"),Gs=s(" \uFF0C\u8BAD\u7EC3\u548C\u9A8C\u8BC1\u6570\u636E\u96C6\uFF0C"),Zt=a("strong"),Ns=s("data_collator"),Rs=s(" \uFF0C\u548C "),te=a("strong"),ws=s("tokenizer"),Os=s(" \uFF1A"),mr=f(),h($t.$$.fragment),gr=f(),O=a("p"),Ps=s("\u8BF7\u6CE8\u610F\uFF0C\u5F53\u60A8\u5728\u8FD9\u91CC\u5B8C\u6210"),ee=a("strong"),js=s("tokenizer"),qs=s("\u540E\uFF0C\u9ED8\u8BA4 "),re=a("strong"),zs=s("Trainer"),As=s("\u4F7F\u7528 \u7684"),se=a("strong"),ys=s("data_collator"),Cs=s("\u4F1A\u4F7F\u7528\u4E4B\u524D\u9884\u5B9A\u4E49\u7684 "),oe=a("strong"),xs=s("DataCollatorWithPadding"),Us=s(" \uFF0C\u56E0\u6B64\u60A8\u53EF\u4EE5\u5728\u8FD9\u4E2A\u4F8B\u5B50\u4E2D\u8DF3\u8FC7 "),ae=a("strong"),Fs=s("data_collator=data_collator"),Ms=s("\u3002\u5728\u7B2C 2 \u8282\u4E2D\u5411\u60A8\u5C55\u793A\u8FD9\u90E8\u5206\u5904\u7406\u4ECD\u7136\u5F88\u91CD\u8981\uFF01"),_r=f(),D=a("p"),Is=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"),ne=a("strong"),Ls=s("Trainer"),Bs=s("\u7684"),le=a("strong"),Ds=s("train()"),Ws=s(" \u65B9\u6CD5 \uFF1A"),ur=f(),h(ht.$$.fragment),dr=f(),zt=a("p"),Hs=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:"),$r=f(),rt=a("ol"),C=a("li"),Ys=s("\u6211\u4EEC\u6CA1\u6709\u901A\u8FC7\u5C06"),ie=a("strong"),Js=s("evaluation_strategy"),Xs=s("\u8BBE\u7F6E\u4E3A\u201C"),pe=a("strong"),Ks=s("steps"),Qs=s("\u201D(\u5728\u6BCF\u6B21\u66F4\u65B0\u53C2\u6570\u7684\u65F6\u5019\u8BC4\u4F30)\u6216\u201C"),fe=a("strong"),Vs=s("epoch"),Zs=s("\u201D(\u5728\u6BCF\u4E2Aepoch\u7ED3\u675F\u65F6\u8BC4\u4F30)\u6765\u544A\u8BC9"),ce=a("strong"),to=s("Trainer"),eo=s("\u5728\u8BAD\u7EC3\u671F\u95F4\u8FDB\u884C\u8BC4\u4F30\u3002"),ro=f(),Q=a("li"),so=s("\u6211\u4EEC\u6CA1\u6709\u4E3A"),me=a("strong"),oo=s("Trainer"),ao=s("\u63D0\u4F9B\u4E00\u4E2A"),ge=a("strong"),no=s("compute_metrics()"),lo=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"),hr=f(),vt=a("h3"),io=s("\u8BC4\u4F30"),vr=f(),P=a("p"),po=s("\u8BA9\u6211\u4EEC\u770B\u770B\u5982\u4F55\u6784\u5EFA\u4E00\u4E2A\u6709\u7528\u7684 "),_e=a("strong"),fo=s("compute_metrics()"),co=s(" \u51FD\u6570\u5E76\u5728\u6211\u4EEC\u4E0B\u6B21\u8BAD\u7EC3\u65F6\u4F7F\u7528\u5B83\u3002\u8BE5\u51FD\u6570\u5FC5\u987B\u91C7\u7528 "),ue=a("strong"),mo=s("EvalPrediction"),go=s(" \u5BF9\u8C61\uFF08\u5E26\u6709 "),de=a("strong"),_o=s("predictions"),uo=s(" \u548C "),$e=a("strong"),$o=s("label_ids"),ho=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 "),he=a("strong"),vo=s("Trainer.predict()"),To=s(" \u547D\u4EE4\u6765\u4F7F\u7528\u6211\u4EEC\u7684\u6A21\u578B\u8FDB\u884C\u9884\u6D4B\uFF1A"),Tr=f(),h(Tt.$$.fragment),Er=f(),h(Et.$$.fragment),kr=f(),d=a("p"),ve=a("strong"),Eo=s("predict()"),ko=s(" \u7684\u8F93\u51FA\u7ED3\u679C\u662F\u5177\u6709\u4E09\u4E2A\u5B57\u6BB5\u7684\u547D\u540D\u5143\u7EC4\uFF1A "),Te=a("strong"),So=s("predictions"),bo=s(" , "),Ee=a("strong"),Go=s("label_ids"),No=s(" \uFF0C \u548C "),ke=a("strong"),Ro=s("metrics"),wo=s(" .\u8FD9 "),Se=a("strong"),Oo=s("metrics"),Po=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 "),be=a("strong"),jo=s("compute_metrics()"),qo=s(" \u51FD\u6570\u5E76\u5C06\u5176\u4F20\u9012\u7ED9 "),Ge=a("strong"),zo=s("Trainer"),Ao=s(" \uFF0C\u8BE5\u5B57\u6BB5\u8FD8\u5C06\u5305\u542B"),Ne=a("strong"),yo=s("compute_metrics()"),Co=s("\u7684\u7ED3\u679C\u3002"),Sr=f(),g=a("p"),Re=a("strong"),xo=s("predict()"),Uo=s(" \u65B9\u6CD5\u662F\u5177\u6709\u4E09\u4E2A\u5B57\u6BB5\u7684\u547D\u540D\u5143\u7EC4\uFF1A "),we=a("strong"),Fo=s("predictions"),Mo=s(" , "),Oe=a("strong"),Io=s("label_ids"),Lo=s(" \uFF0C \u548C "),Pe=a("strong"),Bo=s("metrics"),Do=s(" .\u8FD9 "),je=a("strong"),Wo=s("metrics"),Ho=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 "),qe=a("strong"),Yo=s("compute_metrics()"),Jo=s(" \u51FD\u6570\u5E76\u5C06\u5176\u4F20\u9012\u7ED9 "),ze=a("strong"),Xo=s("Trainer"),Ko=s(" \uFF0C\u8BE5\u5B57\u6BB5\u8FD8\u5C06\u5305\u542B"),Ae=a("strong"),Qo=s("compute_metrics()"),Vo=s(" \u7684\u7ED3\u679C\u3002\u5982\u4F60\u770B\u5230\u7684\uFF0C "),ye=a("strong"),Zo=s("predictions"),ta=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"),Ce=a("strong"),ea=s("predict()"),ra=s("\u7684\u6570\u636E\u96C6\u7684\u6BCF\u4E2A\u5143\u7D20\u7684\u7ED3\u679C(logits)\uFF08\u6B63\u5982\u4F60\u5728"),At=a("a"),sa=s("\u4E4B\u524D\u7684\u7AE0\u8282"),oa=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"),br=f(),h(kt.$$.fragment),Gr=f(),A=a("p"),aa=s("\u73B0\u5728\u5EFA\u7ACB\u6211\u4EEC\u7684 "),xe=a("strong"),na=s("compute_metric()"),la=s(" \u51FD\u6570\u6765\u8F83\u4E3A\u76F4\u89C2\u5730\u8BC4\u4F30\u6A21\u578B\u7684\u597D\u574F\uFF0C\u6211\u4EEC\u5C06\u4F7F\u7528 \u{1F917} "),St=a("a"),ia=s("Evaluate"),pa=s(" \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 "),Ue=a("strong"),fa=s("evaluate.load()"),ca=s(" \u51FD\u6570\u3002\u8FD4\u56DE\u7684\u5BF9\u8C61\u6709\u4E00\u4E2A "),Fe=a("strong"),ma=s("compute()"),ga=s("\u65B9\u6CD5\u6211\u4EEC\u53EF\u4EE5\u7528\u6765\u8FDB\u884C\u5EA6\u91CF\u8BA1\u7B97\u7684\u65B9\u6CD5\uFF1A"),Nr=f(),h(bt.$$.fragment),Rr=f(),h(Gt.$$.fragment),wr=f(),F=a("p"),_a=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"),Nt=a("a"),ua=s("BERT \u8BBA\u6587"),da=s("\u4E2D\u5C55\u793A\u7684\u57FA\u7840\u6A21\u578B\u7684 F1 \u5206\u6570\u4E3A 88.9\u3002\u90A3\u662F "),Me=a("strong"),$a=s("uncased"),ha=s(" \u6A21\u578B\uFF0C\u800C\u6211\u4EEC\u76EE\u524D\u6B63\u5728\u4F7F\u7528 "),Ie=a("strong"),va=s("cased"),Ta=s(" \u6A21\u578B\uFF0C\u901A\u8FC7\u6539\u8FDB\u5F97\u5230\u4E86\u66F4\u597D\u7684\u7ED3\u679C\u3002"),Or=f(),st=a("p"),Ea=s("\u6700\u540E\u5C06\u6240\u6709\u4E1C\u897F\u6253\u5305\u5728\u4E00\u8D77\uFF0C\u6211\u4EEC\u5F97\u5230\u4E86\u6211\u4EEC\u7684 "),Le=a("strong"),ka=s("compute_metrics()"),Sa=s(" \u51FD\u6570\uFF1A"),Pr=f(),h(Rt.$$.fragment),jr=f(),W=a("p"),ba=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"),Be=a("strong"),Ga=s("compute_metrics()"),Na=s("\u51FD\u6570\u5B9A\u4E49\u4E00\u4E2A\u65B0\u7684 "),De=a("strong"),Ra=s("Trainer"),wa=s(" \uFF1A"),qr=f(),h(wt.$$.fragment),zr=f(),M=a("p"),Oa=s("\u8BF7\u6CE8\u610F\uFF0C\u6211\u4EEC\u8BBE\u7F6E\u4E86\u4E86\u4E00\u4E2A\u65B0\u7684 "),We=a("strong"),Pa=s("TrainingArguments"),ja=s(" \u5B83\u7684"),He=a("strong"),qa=s("evaluation_strategy"),za=s(" \u8BBE\u7F6E\u4E3A "),Ye=a("strong"),Aa=s("epoch"),ya=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"),Ar=f(),h(Ot.$$.fragment),yr=f(),yt=a("p"),Ca=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"),Cr=f(),H=a("p"),xa=s("\u8FD9 "),Je=a("strong"),Ua=s("Trainer"),Fa=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 "),Xe=a("strong"),Ma=s("fp16 = True"),Ia=s(" \uFF09\u3002\u6211\u4EEC\u5C06\u5728\u7B2C 10 \u7AE0\u8BA8\u8BBA\u5B83\u652F\u6301\u7684\u6240\u6709\u5185\u5BB9\u3002"),xr=f(),ot=a("p"),La=s("\u4F7F\u7528"),Ke=a("strong"),Ba=s("Trainer"),Da=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"),Ur=f(),h(at.$$.fragment),this.h()},l(t){const i=hl('[data-svelte="svelte-1phssyn"]',document.head);m=n(i,"META",{name:!0,content:!0}),i.forEach(r),j=c(t),v(_.$$.fragment,t),q=c(t),N=n(t,"H1",{class:!0});var Pt=l(N);$=n(Pt,"A",{id:!0,class:!0,href:!0});var Qe=l($);G=n(Qe,"SPAN",{});var Ve=l(G);v(y.$$.fragment,Ve),Ve.forEach(r),Qe.forEach(r),Hr=c(Pt),Mt=n(Pt,"SPAN",{});var Wa=l(Mt);Yr=o(Wa,"\u4F7F\u7528 Trainer API \u5FAE\u8C03\u6A21\u578B"),Wa.forEach(r),Pt.forEach(r),Ze=c(t),v(ft.$$.fragment,t),tr=c(t),v(ct.$$.fragment,t),er=c(t),z=n(t,"P",{});var Y=l(z);Jr=o(Y,"\u{1F917} Transformers\u63D0\u4F9B\u4E86\u4E00\u4E2A "),It=n(Y,"STRONG",{});var Ha=l(It);Xr=o(Ha,"Trainer"),Ha.forEach(r),Kr=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 "),Lt=n(Y,"STRONG",{});var Ya=l(Lt);Qr=o(Ya,"Trainer"),Ya.forEach(r),Vr=o(Y," .\u6700\u96BE\u7684\u90E8\u5206\u53EF\u80FD\u662F\u4E3A "),Bt=n(Y,"STRONG",{});var Ja=l(Bt);Zr=o(Ja,"Trainer.train()"),Ja.forEach(r),ts=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 Xa=l(mt);es=o(Xa,"Google Colab"),Xa.forEach(r),rs=o(Y,"."),Y.forEach(r),rr=c(t),jt=n(t,"P",{});var Ka=l(jt);ss=o(Ka,"\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"),Ka.forEach(r),sr=c(t),v(gt.$$.fragment,t),or=c(t),K=n(t,"H3",{class:!0});var Mr=l(K);V=n(Mr,"A",{id:!0,class:!0,href:!0});var Qa=l(V);Dt=n(Qa,"SPAN",{});var Va=l(Dt);v(_t.$$.fragment,Va),Va.forEach(r),Qa.forEach(r),os=c(Mr),Wt=n(Mr,"SPAN",{});var Za=l(Wt);as=o(Za,"Training"),Za.forEach(r),Mr.forEach(r),ar=c(t),U=n(t,"P",{});var nt=l(U);ns=o(nt,"\u5728\u6211\u4EEC\u5B9A\u4E49\u6211\u4EEC\u7684 "),Ht=n(nt,"STRONG",{});var tn=l(Ht);ls=o(tn,"Trainer"),tn.forEach(r),is=o(nt," \u4E4B\u524D\u9996\u5148\u8981\u5B9A\u4E49\u4E00\u4E2A "),Yt=n(nt,"STRONG",{});var en=l(Yt);ps=o(en,"TrainingArguments"),en.forEach(r),fs=o(nt," \u7C7B\uFF0C\u5B83\u5C06\u5305\u542B "),Jt=n(nt,"STRONG",{});var rn=l(Jt);cs=o(rn,"Trainer"),rn.forEach(r),ms=o(nt,"\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"),nt.forEach(r),nr=c(t),v(ut.$$.fragment,t),lr=c(t),v(Z.$$.fragment,t),ir=c(t),tt=n(t,"P",{});var Ir=l(tt);gs=o(Ir,"\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 "),Xt=n(Ir,"STRONG",{});var sn=l(Xt);_s=o(sn,"AutoModelForSequenceClassification"),sn.forEach(r),us=o(Ir," \u7C7B\uFF0C\u5B83\u6709\u4E24\u4E2A\u53C2\u6570\uFF1A"),Ir.forEach(r),pr=c(t),v(dt.$$.fragment,t),fr=c(t),et=n(t,"P",{});var Lr=l(et);ds=o(Lr,"\u4F60\u4F1A\u6CE8\u610F\u5230\uFF0C\u548C"),qt=n(Lr,"A",{href:!0});var on=l(qt);$s=o(on,"\u7B2C\u4E8C\u7AE0"),on.forEach(r),hs=o(Lr,"\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"),Lr.forEach(r),cr=c(t),w=n(t,"P",{});var I=l(w);vs=o(I,"\u4E00\u65E6\u6211\u4EEC\u6709\u4E86\u6211\u4EEC\u7684\u6A21\u578B\uFF0C\u6211\u4EEC\u5C31\u53EF\u4EE5\u5B9A\u4E49\u4E00\u4E2A "),Kt=n(I,"STRONG",{});var an=l(Kt);Ts=o(an,"Trainer"),an.forEach(r),Es=o(I," \u901A\u8FC7\u5C06\u4E4B\u524D\u6784\u9020\u7684\u6240\u6709\u5BF9\u8C61\u4F20\u9012\u7ED9\u5B83\u2014\u2014\u6211\u4EEC\u7684"),Qt=n(I,"STRONG",{});var nn=l(Qt);ks=o(nn,"model"),nn.forEach(r),Ss=o(I," \u3001"),Vt=n(I,"STRONG",{});var ln=l(Vt);bs=o(ln,"training_args"),ln.forEach(r),Gs=o(I," \uFF0C\u8BAD\u7EC3\u548C\u9A8C\u8BC1\u6570\u636E\u96C6\uFF0C"),Zt=n(I,"STRONG",{});var pn=l(Zt);Ns=o(pn,"data_collator"),pn.forEach(r),Rs=o(I," \uFF0C\u548C "),te=n(I,"STRONG",{});var fn=l(te);ws=o(fn,"tokenizer"),fn.forEach(r),Os=o(I," \uFF1A"),I.forEach(r),mr=c(t),v($t.$$.fragment,t),gr=c(t),O=n(t,"P",{});var L=l(O);Ps=o(L,"\u8BF7\u6CE8\u610F\uFF0C\u5F53\u60A8\u5728\u8FD9\u91CC\u5B8C\u6210"),ee=n(L,"STRONG",{});var cn=l(ee);js=o(cn,"tokenizer"),cn.forEach(r),qs=o(L,"\u540E\uFF0C\u9ED8\u8BA4 "),re=n(L,"STRONG",{});var mn=l(re);zs=o(mn,"Trainer"),mn.forEach(r),As=o(L,"\u4F7F\u7528 \u7684"),se=n(L,"STRONG",{});var gn=l(se);ys=o(gn,"data_collator"),gn.forEach(r),Cs=o(L,"\u4F1A\u4F7F\u7528\u4E4B\u524D\u9884\u5B9A\u4E49\u7684 "),oe=n(L,"STRONG",{});var _n=l(oe);xs=o(_n,"DataCollatorWithPadding"),_n.forEach(r),Us=o(L," \uFF0C\u56E0\u6B64\u60A8\u53EF\u4EE5\u5728\u8FD9\u4E2A\u4F8B\u5B50\u4E2D\u8DF3\u8FC7 "),ae=n(L,"STRONG",{});var un=l(ae);Fs=o(un,"data_collator=data_collator"),un.forEach(r),Ms=o(L,"\u3002\u5728\u7B2C 2 \u8282\u4E2D\u5411\u60A8\u5C55\u793A\u8FD9\u90E8\u5206\u5904\u7406\u4ECD\u7136\u5F88\u91CD\u8981\uFF01"),L.forEach(r),_r=c(t),D=n(t,"P",{});var Ct=l(D);Is=o(Ct,"\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"),ne=n(Ct,"STRONG",{});var dn=l(ne);Ls=o(dn,"Trainer"),dn.forEach(r),Bs=o(Ct,"\u7684"),le=n(Ct,"STRONG",{});var $n=l(le);Ds=o($n,"train()"),$n.forEach(r),Ws=o(Ct," \u65B9\u6CD5 \uFF1A"),Ct.forEach(r),ur=c(t),v(ht.$$.fragment,t),dr=c(t),zt=n(t,"P",{});var hn=l(zt);Hs=o(hn,"\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:"),hn.forEach(r),$r=c(t),rt=n(t,"OL",{});var Br=l(rt);C=n(Br,"LI",{});var J=l(C);Ys=o(J,"\u6211\u4EEC\u6CA1\u6709\u901A\u8FC7\u5C06"),ie=n(J,"STRONG",{});var vn=l(ie);Js=o(vn,"evaluation_strategy"),vn.forEach(r),Xs=o(J,"\u8BBE\u7F6E\u4E3A\u201C"),pe=n(J,"STRONG",{});var Tn=l(pe);Ks=o(Tn,"steps"),Tn.forEach(r),Qs=o(J,"\u201D(\u5728\u6BCF\u6B21\u66F4\u65B0\u53C2\u6570\u7684\u65F6\u5019\u8BC4\u4F30)\u6216\u201C"),fe=n(J,"STRONG",{});var En=l(fe);Vs=o(En,"epoch"),En.forEach(r),Zs=o(J,"\u201D(\u5728\u6BCF\u4E2Aepoch\u7ED3\u675F\u65F6\u8BC4\u4F30)\u6765\u544A\u8BC9"),ce=n(J,"STRONG",{});var kn=l(ce);to=o(kn,"Trainer"),kn.forEach(r),eo=o(J,"\u5728\u8BAD\u7EC3\u671F\u95F4\u8FDB\u884C\u8BC4\u4F30\u3002"),J.forEach(r),ro=c(Br),Q=n(Br,"LI",{});var xt=l(Q);so=o(xt,"\u6211\u4EEC\u6CA1\u6709\u4E3A"),me=n(xt,"STRONG",{});var Sn=l(me);oo=o(Sn,"Trainer"),Sn.forEach(r),ao=o(xt,"\u63D0\u4F9B\u4E00\u4E2A"),ge=n(xt,"STRONG",{});var bn=l(ge);no=o(bn,"compute_metrics()"),bn.forEach(r),lo=o(xt,"\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"),xt.forEach(r),Br.forEach(r),hr=c(t),vt=n(t,"H3",{id:!0});var Gn=l(vt);io=o(Gn,"\u8BC4\u4F30"),Gn.forEach(r),vr=c(t),P=n(t,"P",{});var B=l(P);po=o(B,"\u8BA9\u6211\u4EEC\u770B\u770B\u5982\u4F55\u6784\u5EFA\u4E00\u4E2A\u6709\u7528\u7684 "),_e=n(B,"STRONG",{});var Nn=l(_e);fo=o(Nn,"compute_metrics()"),Nn.forEach(r),co=o(B," \u51FD\u6570\u5E76\u5728\u6211\u4EEC\u4E0B\u6B21\u8BAD\u7EC3\u65F6\u4F7F\u7528\u5B83\u3002\u8BE5\u51FD\u6570\u5FC5\u987B\u91C7\u7528 "),ue=n(B,"STRONG",{});var Rn=l(ue);mo=o(Rn,"EvalPrediction"),Rn.forEach(r),go=o(B," \u5BF9\u8C61\uFF08\u5E26\u6709 "),de=n(B,"STRONG",{});var wn=l(de);_o=o(wn,"predictions"),wn.forEach(r),uo=o(B," \u548C "),$e=n(B,"STRONG",{});var On=l($e);$o=o(On,"label_ids"),On.forEach(r),ho=o(B," \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 "),he=n(B,"STRONG",{});var Pn=l(he);vo=o(Pn,"Trainer.predict()"),Pn.forEach(r),To=o(B," \u547D\u4EE4\u6765\u4F7F\u7528\u6211\u4EEC\u7684\u6A21\u578B\u8FDB\u884C\u9884\u6D4B\uFF1A"),B.forEach(r),Tr=c(t),v(Tt.$$.fragment,t),Er=c(t),v(Et.$$.fragment,t),kr=c(t),d=n(t,"P",{});var R=l(d);ve=n(R,"STRONG",{});var jn=l(ve);Eo=o(jn,"predict()"),jn.forEach(r),ko=o(R," \u7684\u8F93\u51FA\u7ED3\u679C\u662F\u5177\u6709\u4E09\u4E2A\u5B57\u6BB5\u7684\u547D\u540D\u5143\u7EC4\uFF1A "),Te=n(R,"STRONG",{});var qn=l(Te);So=o(qn,"predictions"),qn.forEach(r),bo=o(R," , "),Ee=n(R,"STRONG",{});var zn=l(Ee);Go=o(zn,"label_ids"),zn.forEach(r),No=o(R," \uFF0C \u548C "),ke=n(R,"STRONG",{});var An=l(ke);Ro=o(An,"metrics"),An.forEach(r),wo=o(R," .\u8FD9 "),Se=n(R,"STRONG",{});var yn=l(Se);Oo=o(yn,"metrics"),yn.forEach(r),Po=o(R," \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 "),be=n(R,"STRONG",{});var Cn=l(be);jo=o(Cn,"compute_metrics()"),Cn.forEach(r),qo=o(R," \u51FD\u6570\u5E76\u5C06\u5176\u4F20\u9012\u7ED9 "),Ge=n(R,"STRONG",{});var xn=l(Ge);zo=o(xn,"Trainer"),xn.forEach(r),Ao=o(R," \uFF0C\u8BE5\u5B57\u6BB5\u8FD8\u5C06\u5305\u542B"),Ne=n(R,"STRONG",{});var Un=l(Ne);yo=o(Un,"compute_metrics()"),Un.forEach(r),Co=o(R,"\u7684\u7ED3\u679C\u3002"),R.forEach(r),Sr=c(t),g=n(t,"P",{});var u=l(g);Re=n(u,"STRONG",{});var Fn=l(Re);xo=o(Fn,"predict()"),Fn.forEach(r),Uo=o(u," \u65B9\u6CD5\u662F\u5177\u6709\u4E09\u4E2A\u5B57\u6BB5\u7684\u547D\u540D\u5143\u7EC4\uFF1A "),we=n(u,"STRONG",{});var Mn=l(we);Fo=o(Mn,"predictions"),Mn.forEach(r),Mo=o(u," , "),Oe=n(u,"STRONG",{});var In=l(Oe);Io=o(In,"label_ids"),In.forEach(r),Lo=o(u," \uFF0C \u548C "),Pe=n(u,"STRONG",{});var Ln=l(Pe);Bo=o(Ln,"metrics"),Ln.forEach(r),Do=o(u," .\u8FD9 "),je=n(u,"STRONG",{});var Bn=l(je);Wo=o(Bn,"metrics"),Bn.forEach(r),Ho=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 "),qe=n(u,"STRONG",{});var Dn=l(qe);Yo=o(Dn,"compute_metrics()"),Dn.forEach(r),Jo=o(u," \u51FD\u6570\u5E76\u5C06\u5176\u4F20\u9012\u7ED9 "),ze=n(u,"STRONG",{});var Wn=l(ze);Xo=o(Wn,"Trainer"),Wn.forEach(r),Ko=o(u," \uFF0C\u8BE5\u5B57\u6BB5\u8FD8\u5C06\u5305\u542B"),Ae=n(u,"STRONG",{});var Hn=l(Ae);Qo=o(Hn,"compute_metrics()"),Hn.forEach(r),Vo=o(u," \u7684\u7ED3\u679C\u3002\u5982\u4F60\u770B\u5230\u7684\uFF0C "),ye=n(u,"STRONG",{});var Yn=l(ye);Zo=o(Yn,"predictions"),Yn.forEach(r),ta=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"),Ce=n(u,"STRONG",{});var Jn=l(Ce);ea=o(Jn,"predict()"),Jn.forEach(r),ra=o(u,"\u7684\u6570\u636E\u96C6\u7684\u6BCF\u4E2A\u5143\u7D20\u7684\u7ED3\u679C(logits)\uFF08\u6B63\u5982\u4F60\u5728"),At=n(u,"A",{href:!0});var Xn=l(At);sa=o(Xn,"\u4E4B\u524D\u7684\u7AE0\u8282"),Xn.forEach(r),oa=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),br=c(t),v(kt.$$.fragment,t),Gr=c(t),A=n(t,"P",{});var X=l(A);aa=o(X,"\u73B0\u5728\u5EFA\u7ACB\u6211\u4EEC\u7684 "),xe=n(X,"STRONG",{});var Kn=l(xe);na=o(Kn,"compute_metric()"),Kn.forEach(r),la=o(X," \u51FD\u6570\u6765\u8F83\u4E3A\u76F4\u89C2\u5730\u8BC4\u4F30\u6A21\u578B\u7684\u597D\u574F\uFF0C\u6211\u4EEC\u5C06\u4F7F\u7528 \u{1F917} "),St=n(X,"A",{href:!0,rel:!0});var Qn=l(St);ia=o(Qn,"Evaluate"),Qn.forEach(r),pa=o(X," \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 "),Ue=n(X,"STRONG",{});var Vn=l(Ue);fa=o(Vn,"evaluate.load()"),Vn.forEach(r),ca=o(X," \u51FD\u6570\u3002\u8FD4\u56DE\u7684\u5BF9\u8C61\u6709\u4E00\u4E2A "),Fe=n(X,"STRONG",{});var Zn=l(Fe);ma=o(Zn,"compute()"),Zn.forEach(r),ga=o(X,"\u65B9\u6CD5\u6211\u4EEC\u53EF\u4EE5\u7528\u6765\u8FDB\u884C\u5EA6\u91CF\u8BA1\u7B97\u7684\u65B9\u6CD5\uFF1A"),X.forEach(r),Nr=c(t),v(bt.$$.fragment,t),Rr=c(t),v(Gt.$$.fragment,t),wr=c(t),F=n(t,"P",{});var lt=l(F);_a=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"),Nt=n(lt,"A",{href:!0,rel:!0});var tl=l(Nt);ua=o(tl,"BERT \u8BBA\u6587"),tl.forEach(r),da=o(lt,"\u4E2D\u5C55\u793A\u7684\u57FA\u7840\u6A21\u578B\u7684 F1 \u5206\u6570\u4E3A 88.9\u3002\u90A3\u662F "),Me=n(lt,"STRONG",{});var el=l(Me);$a=o(el,"uncased"),el.forEach(r),ha=o(lt," \u6A21\u578B\uFF0C\u800C\u6211\u4EEC\u76EE\u524D\u6B63\u5728\u4F7F\u7528 "),Ie=n(lt,"STRONG",{});var rl=l(Ie);va=o(rl,"cased"),rl.forEach(r),Ta=o(lt," \u6A21\u578B\uFF0C\u901A\u8FC7\u6539\u8FDB\u5F97\u5230\u4E86\u66F4\u597D\u7684\u7ED3\u679C\u3002"),lt.forEach(r),Or=c(t),st=n(t,"P",{});var Dr=l(st);Ea=o(Dr,"\u6700\u540E\u5C06\u6240\u6709\u4E1C\u897F\u6253\u5305\u5728\u4E00\u8D77\uFF0C\u6211\u4EEC\u5F97\u5230\u4E86\u6211\u4EEC\u7684 "),Le=n(Dr,"STRONG",{});var sl=l(Le);ka=o(sl,"compute_metrics()"),sl.forEach(r),Sa=o(Dr," \u51FD\u6570\uFF1A"),Dr.forEach(r),Pr=c(t),v(Rt.$$.fragment,t),jr=c(t),W=n(t,"P",{});var Ut=l(W);ba=o(Ut,"\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"),Be=n(Ut,"STRONG",{});var ol=l(Be);Ga=o(ol,"compute_metrics()"),ol.forEach(r),Na=o(Ut,"\u51FD\u6570\u5B9A\u4E49\u4E00\u4E2A\u65B0\u7684 "),De=n(Ut,"STRONG",{});var al=l(De);Ra=o(al,"Trainer"),al.forEach(r),wa=o(Ut," \uFF1A"),Ut.forEach(r),qr=c(t),v(wt.$$.fragment,t),zr=c(t),M=n(t,"P",{});var it=l(M);Oa=o(it,"\u8BF7\u6CE8\u610F\uFF0C\u6211\u4EEC\u8BBE\u7F6E\u4E86\u4E86\u4E00\u4E2A\u65B0\u7684 "),We=n(it,"STRONG",{});var nl=l(We);Pa=o(nl,"TrainingArguments"),nl.forEach(r),ja=o(it," \u5B83\u7684"),He=n(it,"STRONG",{});var ll=l(He);qa=o(ll,"evaluation_strategy"),ll.forEach(r),za=o(it," \u8BBE\u7F6E\u4E3A "),Ye=n(it,"STRONG",{});var il=l(Ye);Aa=o(il,"epoch"),il.forEach(r),ya=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),Ar=c(t),v(Ot.$$.fragment,t),yr=c(t),yt=n(t,"P",{});var pl=l(yt);Ca=o(pl,"\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"),pl.forEach(r),Cr=c(t),H=n(t,"P",{});var Ft=l(H);xa=o(Ft,"\u8FD9 "),Je=n(Ft,"STRONG",{});var fl=l(Je);Ua=o(fl,"Trainer"),fl.forEach(r),Fa=o(Ft," \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 "),Xe=n(Ft,"STRONG",{});var cl=l(Xe);Ma=o(cl,"fp16 = True"),cl.forEach(r),Ia=o(Ft," \uFF09\u3002\u6211\u4EEC\u5C06\u5728\u7B2C 10 \u7AE0\u8BA8\u8BBA\u5B83\u652F\u6301\u7684\u6240\u6709\u5185\u5BB9\u3002"),Ft.forEach(r),xr=c(t),ot=n(t,"P",{});var Wr=l(ot);La=o(Wr,"\u4F7F\u7528"),Ke=n(Wr,"STRONG",{});var ml=l(Ke);Ba=o(ml,"Trainer"),ml.forEach(r),Da=o(Wr," 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"),Wr.forEach(r),Ur=c(t),v(at.$$.fragment,t),this.h()},h(){b(m,"name","hf:doc:metadata"),b(m,"content",JSON.stringify(Nl)),b($,"id","trainer-api"),b($,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),b($,"href","#trainer-api"),b(N,"class","relative group"),b(mt,"href","https://colab.research.google.com/"),b(mt,"rel","nofollow"),b(V,"id","training"),b(V,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),b(V,"href","#training"),b(K,"class","relative group"),b(qt,"href","/course/chapter2"),b(vt,"id",""),b(At,"href","/course/chapter2"),b(St,"href","https://github.com/huggingface/evaluate/"),b(St,"rel","nofollow"),b(Nt,"href","https://arxiv.org/pdf/1810.04805.pdf"),b(Nt,"rel","nofollow")},m(t,i){e(document.head,m),p(t,j,i),T(_,t,i),p(t,q,i),p(t,N,i),e(N,$),e($,G),T(y,G,null),e(N,Hr),e(N,Mt),e(Mt,Yr),p(t,Ze,i),T(ft,t,i),p(t,tr,i),T(ct,t,i),p(t,er,i),p(t,z,i),e(z,Jr),e(z,It),e(It,Xr),e(z,Kr),e(z,Lt),e(Lt,Qr),e(z,Vr),e(z,Bt),e(Bt,Zr),e(z,ts),e(z,mt),e(mt,es),e(z,rs),p(t,rr,i),p(t,jt,i),e(jt,ss),p(t,sr,i),T(gt,t,i),p(t,or,i),p(t,K,i),e(K,V),e(V,Dt),T(_t,Dt,null),e(K,os),e(K,Wt),e(Wt,as),p(t,ar,i),p(t,U,i),e(U,ns),e(U,Ht),e(Ht,ls),e(U,is),e(U,Yt),e(Yt,ps),e(U,fs),e(U,Jt),e(Jt,cs),e(U,ms),p(t,nr,i),T(ut,t,i),p(t,lr,i),T(Z,t,i),p(t,ir,i),p(t,tt,i),e(tt,gs),e(tt,Xt),e(Xt,_s),e(tt,us),p(t,pr,i),T(dt,t,i),p(t,fr,i),p(t,et,i),e(et,ds),e(et,qt),e(qt,$s),e(et,hs),p(t,cr,i),p(t,w,i),e(w,vs),e(w,Kt),e(Kt,Ts),e(w,Es),e(w,Qt),e(Qt,ks),e(w,Ss),e(w,Vt),e(Vt,bs),e(w,Gs),e(w,Zt),e(Zt,Ns),e(w,Rs),e(w,te),e(te,ws),e(w,Os),p(t,mr,i),T($t,t,i),p(t,gr,i),p(t,O,i),e(O,Ps),e(O,ee),e(ee,js),e(O,qs),e(O,re),e(re,zs),e(O,As),e(O,se),e(se,ys),e(O,Cs),e(O,oe),e(oe,xs),e(O,Us),e(O,ae),e(ae,Fs),e(O,Ms),p(t,_r,i),p(t,D,i),e(D,Is),e(D,ne),e(ne,Ls),e(D,Bs),e(D,le),e(le,Ds),e(D,Ws),p(t,ur,i),T(ht,t,i),p(t,dr,i),p(t,zt,i),e(zt,Hs),p(t,$r,i),p(t,rt,i),e(rt,C),e(C,Ys),e(C,ie),e(ie,Js),e(C,Xs),e(C,pe),e(pe,Ks),e(C,Qs),e(C,fe),e(fe,Vs),e(C,Zs),e(C,ce),e(ce,to),e(C,eo),e(rt,ro),e(rt,Q),e(Q,so),e(Q,me),e(me,oo),e(Q,ao),e(Q,ge),e(ge,no),e(Q,lo),p(t,hr,i),p(t,vt,i),e(vt,io),p(t,vr,i),p(t,P,i),e(P,po),e(P,_e),e(_e,fo),e(P,co),e(P,ue),e(ue,mo),e(P,go),e(P,de),e(de,_o),e(P,uo),e(P,$e),e($e,$o),e(P,ho),e(P,he),e(he,vo),e(P,To),p(t,Tr,i),T(Tt,t,i),p(t,Er,i),T(Et,t,i),p(t,kr,i),p(t,d,i),e(d,ve),e(ve,Eo),e(d,ko),e(d,Te),e(Te,So),e(d,bo),e(d,Ee),e(Ee,Go),e(d,No),e(d,ke),e(ke,Ro),e(d,wo),e(d,Se),e(Se,Oo),e(d,Po),e(d,be),e(be,jo),e(d,qo),e(d,Ge),e(Ge,zo),e(d,Ao),e(d,Ne),e(Ne,yo),e(d,Co),p(t,Sr,i),p(t,g,i),e(g,Re),e(Re,xo),e(g,Uo),e(g,we),e(we,Fo),e(g,Mo),e(g,Oe),e(Oe,Io),e(g,Lo),e(g,Pe),e(Pe,Bo),e(g,Do),e(g,je),e(je,Wo),e(g,Ho),e(g,qe),e(qe,Yo),e(g,Jo),e(g,ze),e(ze,Xo),e(g,Ko),e(g,Ae),e(Ae,Qo),e(g,Vo),e(g,ye),e(ye,Zo),e(g,ta),e(g,Ce),e(Ce,ea),e(g,ra),e(g,At),e(At,sa),e(g,oa),p(t,br,i),T(kt,t,i),p(t,Gr,i),p(t,A,i),e(A,aa),e(A,xe),e(xe,na),e(A,la),e(A,St),e(St,ia),e(A,pa),e(A,Ue),e(Ue,fa),e(A,ca),e(A,Fe),e(Fe,ma),e(A,ga),p(t,Nr,i),T(bt,t,i),p(t,Rr,i),T(Gt,t,i),p(t,wr,i),p(t,F,i),e(F,_a),e(F,Nt),e(Nt,ua),e(F,da),e(F,Me),e(Me,$a),e(F,ha),e(F,Ie),e(Ie,va),e(F,Ta),p(t,Or,i),p(t,st,i),e(st,Ea),e(st,Le),e(Le,ka),e(st,Sa),p(t,Pr,i),T(Rt,t,i),p(t,jr,i),p(t,W,i),e(W,ba),e(W,Be),e(Be,Ga),e(W,Na),e(W,De),e(De,Ra),e(W,wa),p(t,qr,i),T(wt,t,i),p(t,zr,i),p(t,M,i),e(M,Oa),e(M,We),e(We,Pa),e(M,ja),e(M,He),e(He,qa),e(M,za),e(M,Ye),e(Ye,Aa),e(M,ya),p(t,Ar,i),T(Ot,t,i),p(t,yr,i),p(t,yt,i),e(yt,Ca),p(t,Cr,i),p(t,H,i),e(H,xa),e(H,Je),e(Je,Ua),e(H,Fa),e(H,Xe),e(Xe,Ma),e(H,Ia),p(t,xr,i),p(t,ot,i),e(ot,La),e(ot,Ke),e(Ke,Ba),e(ot,Da),p(t,Ur,i),T(at,t,i),Fr=!0},p(t,[i]){const Pt={};i&1&&(Pt.fw=t[0]),_.$set(Pt);const Qe={};i&2&&(Qe.$$scope={dirty:i,ctx:t}),Z.$set(Qe);const Ve={};i&2&&(Ve.$$scope={dirty:i,ctx:t}),at.$set(Ve)},i(t){Fr||(E(_.$$.fragment,t),E(y.$$.fragment,t),E(ft.$$.fragment,t),E(ct.$$.fragment,t),E(gt.$$.fragment,t),E(_t.$$.fragment,t),E(ut.$$.fragment,t),E(Z.$$.fragment,t),E(dt.$$.fragment,t),E($t.$$.fragment,t),E(ht.$$.fragment,t),E(Tt.$$.fragment,t),E(Et.$$.fragment,t),E(kt.$$.fragment,t),E(bt.$$.fragment,t),E(Gt.$$.fragment,t),E(Rt.$$.fragment,t),E(wt.$$.fragment,t),E(Ot.$$.fragment,t),E(at.$$.fragment,t),Fr=!0)},o(t){k(_.$$.fragment,t),k(y.$$.fragment,t),k(ft.$$.fragment,t),k(ct.$$.fragment,t),k(gt.$$.fragment,t),k(_t.$$.fragment,t),k(ut.$$.fragment,t),k(Z.$$.fragment,t),k(dt.$$.fragment,t),k($t.$$.fragment,t),k(ht.$$.fragment,t),k(Tt.$$.fragment,t),k(Et.$$.fragment,t),k(kt.$$.fragment,t),k(bt.$$.fragment,t),k(Gt.$$.fragment,t),k(Rt.$$.fragment,t),k(wt.$$.fragment,t),k(Ot.$$.fragment,t),k(at.$$.fragment,t),Fr=!1},d(t){r(m),t&&r(j),S(_,t),t&&r(q),t&&r(N),S(y),t&&r(Ze),S(ft,t),t&&r(tr),S(ct,t),t&&r(er),t&&r(z),t&&r(rr),t&&r(jt),t&&r(sr),S(gt,t),t&&r(or),t&&r(K),S(_t),t&&r(ar),t&&r(U),t&&r(nr),S(ut,t),t&&r(lr),S(Z,t),t&&r(ir),t&&r(tt),t&&r(pr),S(dt,t),t&&r(fr),t&&r(et),t&&r(cr),t&&r(w),t&&r(mr),S($t,t),t&&r(gr),t&&r(O),t&&r(_r),t&&r(D),t&&r(ur),S(ht,t),t&&r(dr),t&&r(zt),t&&r($r),t&&r(rt),t&&r(hr),t&&r(vt),t&&r(vr),t&&r(P),t&&r(Tr),S(Tt,t),t&&r(Er),S(Et,t),t&&r(kr),t&&r(d),t&&r(Sr),t&&r(g),t&&r(br),S(kt,t),t&&r(Gr),t&&r(A),t&&r(Nr),S(bt,t),t&&r(Rr),S(Gt,t),t&&r(wr),t&&r(F),t&&r(Or),t&&r(st),t&&r(Pr),S(Rt,t),t&&r(jr),t&&r(W),t&&r(qr),S(wt,t),t&&r(zr),t&&r(M),t&&r(Ar),S(Ot,t),t&&r(yr),t&&r(yt),t&&r(Cr),t&&r(H),t&&r(xr),t&&r(ot),t&&r(Ur),S(at,t)}}}const Nl={local:"trainer-api",sections:[{local:"training",title:"Training"},{local:"",title:"\u8BC4\u4F30"}],title:"\u4F7F\u7528 Trainer API \u5FAE\u8C03\u6A21\u578B"};function Rl(pt,m,j){let _="pt";return vl(()=>{const q=new URLSearchParams(window.location.search);j(0,_=q.get("fw")||"pt")}),[_]}class Cl extends ul{constructor(m){super();dl(this,m,Rl,Gl,$l,{})}}export{Cl as default,Nl as metadata};
