import{S as ca,i as ma,s as ga,e as l,k as f,w as h,t as s,M as _a,c as n,d as r,m as c,x as v,a,h as o,b,G as e,g as p,y as T,q as E,o as S,B as G,v as ua}from"../../chunks/vendor-hf-doc-builder.js";import{T as pa}from"../../chunks/Tip-hf-doc-builder.js";import{Y as $a}from"../../chunks/Youtube-hf-doc-builder.js";import{I as fa}from"../../chunks/IconCopyLink-hf-doc-builder.js";import{C}from"../../chunks/CodeBlock-hf-doc-builder.js";import{D as da}from"../../chunks/DocNotebookDropdown-hf-doc-builder.js";import{F as ha}from"../../chunks/FrameworkSwitchCourse-hf-doc-builder.js";function va(pt){let m,j,_,q,N;return{c(){m=l("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"),_=l("a"),q=s("\u7B2C\u56DB\u7AE0"),N=s("\u4E2D\u8BE6\u7EC6\u4ECB\u7ECD\u8FD9\u90E8\u5206\u3002"),this.h()},l(d){m=n(d,"P",{});var k=a(m);j=o(k,"\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(k,"A",{href:!0});var A=a(_);q=o(A,"\u7B2C\u56DB\u7AE0"),A.forEach(r),N=o(k,"\u4E2D\u8BE6\u7EC6\u4ECB\u7ECD\u8FD9\u90E8\u5206\u3002"),k.forEach(r),this.h()},h(){b(_,"href","/course/chapter4/3")},m(d,k){p(d,m,k),e(m,j),e(m,_),e(_,q),e(m,N)},d(d){d&&r(m)}}}function Ta(pt){let m,j,_,q,N;return{c(){m=l("p"),j=s("\u270F\uFE0F "),_=l("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(d){m=n(d,"P",{});var k=a(m);j=o(k,"\u270F\uFE0F "),_=n(k,"STRONG",{});var A=a(_);q=o(A,"\u8BD5\u8BD5\u770B!"),A.forEach(r),N=o(k," \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"),k.forEach(r)},m(d,k){p(d,m,k),e(m,j),e(m,_),e(_,q),e(m,N)},d(d){d&&r(m)}}}function Ea(pt){let m,j,_,q,N,d,k,A,Hr,Ft,Wr,Ve,ft,Ze,ct,tr,y,Yr,It,Jr,Xr,Mt,Kr,Qr,Lt,Vr,Zr,mt,ts,es,er,Pt,rs,rr,gt,sr,X,Q,Dt,_t,ss,Bt,os,or,x,ls,Ht,ns,as,Wt,is,ps,Yt,fs,cs,lr,ut,nr,V,ar,Z,ms,Jt,gs,_s,ir,$t,pr,tt,us,jt,$s,ds,fr,w,hs,Xt,vs,Ts,Kt,Es,Ss,Qt,Gs,ks,Vt,bs,Ns,Zt,Rs,ws,cr,dt,mr,O,Os,te,Ps,js,ee,qs,ys,re,As,zs,se,Cs,xs,oe,Us,Fs,gr,B,Is,le,Ms,Ls,ne,Ds,Bs,_r,ht,ur,qt,Hs,$r,et,z,Ws,ae,Ys,Js,ie,Xs,Ks,pe,Qs,Vs,fe,Zs,to,eo,K,ro,ce,so,oo,me,lo,no,dr,vt,ao,hr,P,io,ge,po,fo,_e,co,mo,ue,go,_o,$e,uo,$o,de,ho,vo,vr,Tt,Tr,Et,Er,$,he,To,Eo,ve,So,Go,Te,ko,bo,Ee,No,Ro,Se,wo,Oo,Ge,Po,jo,ke,qo,yo,be,Ao,zo,Sr,g,Ne,Co,xo,Re,Uo,Fo,we,Io,Mo,Oe,Lo,Do,Pe,Bo,Ho,je,Wo,Yo,qe,Jo,Xo,ye,Ko,Qo,Ae,Vo,Zo,ze,tl,el,yt,rl,sl,Gr,St,kr,U,ol,Ce,ll,nl,xe,al,il,Ue,pl,fl,br,Gt,Nr,kt,Rr,F,cl,bt,ml,gl,Fe,_l,ul,Ie,$l,dl,wr,rt,hl,Me,vl,Tl,Or,Nt,Pr,H,El,Le,Sl,Gl,De,kl,bl,jr,Rt,qr,I,Nl,Be,Rl,wl,He,Ol,Pl,We,jl,ql,yr,wt,Ar,At,yl,zr,W,Al,Ye,zl,Cl,Je,xl,Ul,Cr,st,Fl,Xe,Il,Ml,xr,ot,Ur;return _=new ha({props:{fw:pt[0]}}),A=new fa({}),ft=new da({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 $a({props:{id:"nvBXf7s7vTI"}}),gt=new C({props:{code:`



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