import{s as Ye,o as Ae,n as Ue}from"../chunks/scheduler.889ebb13.js";import{S as Fe,i as Ne,g as r,s as o,u as w,A as Se,h as p,f as t,c as i,j as $,v,y as g,k as u,o as c,a as s,w as b,d as j,t as T,x as J}from"../chunks/index.8980e686.js";import{T as xe}from"../chunks/Tip.7191df11.js";import{Y as Ze}from"../chunks/Youtube.532e53e0.js";import{I as te}from"../chunks/IconCopyLink.357761cd.js";import{C as V}from"../chunks/CodeBlock.25fc3430.js";import{D as Le}from"../chunks/DocNotebookDropdown.f8a50280.js";import{F as He,M as Ge}from"../chunks/Markdown.31057263.js";function Qe(Wt){let m,k=`사전 훈련된 가중치 중 일부가 사용되지 않고 일부 가중치가 무작위로 표시된다는 경고가 표시됩니다.
걱정마세요. 이것은 올바른 동작입니다! 사전 학습된 BERT 모델의 헤드는 폐기되고 무작위로 초기화된 분류 헤드로 대체됩니다. 이제 사전 학습된 모델의 지식으로 시퀀스 분류 작업을 위한 새로운 모델 헤드를 미세 튜닝 합니다.`;return{c(){m=r("p"),m.textContent=k},l(h){m=p(h,"P",{"data-svelte-h":!0}),g(m)!=="svelte-133r2kc"&&(m.textContent=k)},m(h,_){s(h,m,_)},p:Ue,d(h){h&&t(m)}}}function Pe(Wt){let m,k,h,_,C,Z,Ht,z,Yt="파이토치 Trainer로 훈련하기",it,Jt,ee="🤗 Transformers는 🤗 Transformers 모델 훈련에 최적화된 <code>Trainer</code> 클래스를 제공하여 훈련 루프를 직접 작성하지 않고도 쉽게 훈련을 시작할 수 있습니다. <code>Trainer</code> API는 로깅(logging), 경사 누적(gradient accumulation), 혼합 정밀도(mixed precision) 등 다양한 훈련 옵션과 기능을 지원합니다.",K,F,ht='먼저 모델을 가져오고 예상되는 레이블 수를 지정합니다. Yelp 리뷰 <a href="https://huggingface.co/datasets/yelp_review_full#data-fields" rel="nofollow">데이터셋 카드</a>에서 5개의 레이블이 있음을 알 수 있습니다:',lt,at,wt,H,Qt,x,mt,ct,W,xt,dt,vt="하이퍼파라미터 훈련",kt,At,Rt="다음으로 정할 수 있는 모든 하이퍼파라미터와 다양한 훈련 옵션을 활성화하기 위한 플래그를 포함하는 <code>TrainingArguments</code> 클래스를 생성합니다.",D,O,_t='이 튜토리얼에서는 기본 훈련 <a href="https://huggingface.co/docs/transformers/main_classes/trainer#transformers.TrainingArguments" rel="nofollow">하이퍼파라미터</a>로 시작하지만, 자유롭게 실험하여 여러분들에게 맞는 최적의 설정을 찾을 수 있습니다.',se,tt,ft="훈련에서 체크포인트(checkpoints)를 저장할 위치를 지정합니다:",Gt,et,N,R,I,Ct,nt,bt,Xt,ut="평가 하기",It,S,rt=`<code>Trainer</code>는 훈련 중에 모델 성능을 자동으로 평가하지 않습니다. 평가 지표를 계산하고 보고할 함수를 <code>Trainer</code>에 전달해야 합니다.
<a href="https://huggingface.co/docs/evaluate/index" rel="nofollow">🤗 Evaluate</a> 라이브러리는 <a href="https://huggingface.co/spaces/evaluate-metric/accuracy" rel="nofollow"><code>evaluate.load</code></a> 함수로 로드할 수 있는 간단한 <code>accuracy</code>함수를 제공합니다 (자세한 내용은 <a href="https://huggingface.co/docs/evaluate/a_quick_tour" rel="nofollow">둘러보기</a>를 참조하세요):`,jt,L,Et,st,pt="<code>metric</code>에서 <code>compute</code>를 호출하여 예측의 정확도를 계산합니다. 예측을 <code>compute</code>에 전달하기 전에 예측을 로짓으로 변환해야 합니다(모든 🤗 Transformers 모델은 로짓으로 반환한다는 점을 기억하세요):",Mt,X,Tt,E,Kt="미세 튜닝 중에 평가 지표를 모니터링하려면 훈련 인수에 <code>evaluation_strategy</code> 파라미터를 지정하여 각 에폭이 끝날 때 평가 지표를 확인할 수 있습니다:",Ft,G,ae,ot,U,Nt,Y,Bt,Q,A="훈련 하기",St,B,Pt="모델, 훈련 인수, 훈련 및 테스트 데이터셋, 평가 함수가 포함된 <code>Trainer</code> 객체를 만듭니다:",Zt,P,le,q,yt="그리고 <code>train()</code>을 호출하여 모델을 미세 튜닝합니다:",Ut,a,d;return m=new Ze({props:{id:"nvBXf7s7vTI"}}),Z=new te({}),at=new V({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMEF1dG9Nb2RlbEZvclNlcXVlbmNlQ2xhc3NpZmljYXRpb24lMEElMEFtb2RlbCUyMCUzRCUyMEF1dG9Nb2RlbEZvclNlcXVlbmNlQ2xhc3NpZmljYXRpb24uZnJvbV9wcmV0cmFpbmVkKCUyMmJlcnQtYmFzZS1jYXNlZCUyMiUyQyUyMG51bV9sYWJlbHMlM0Q1KQ==",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoModelForSequenceClassification

<span class="hljs-meta">&gt;&gt;&gt; </span>model = AutoModelForSequenceClassification.from_pretrained(<span class="hljs-string">&quot;bert-base-cased&quot;</span>, num_labels=<span class="hljs-number">5</span>)`}}),H=new xe({props:{$$slots:{default:[Qe]},$$scope:{ctx:Wt}}}),W=new te({}),et=new V({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMFRyYWluaW5nQXJndW1lbnRzJTBBJTBBdHJhaW5pbmdfYXJncyUyMCUzRCUyMFRyYWluaW5nQXJndW1lbnRzKG91dHB1dF9kaXIlM0QlMjJ0ZXN0X3RyYWluZXIlMjIp",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> TrainingArguments

<span class="hljs-meta">&gt;&gt;&gt; </span>training_args = TrainingArguments(output_dir=<span class="hljs-string">&quot;test_trainer&quot;</span>)`}}),nt=new te({}),L=new V({props:{code:"aW1wb3J0JTIwbnVtcHklMjBhcyUyMG5wJTBBaW1wb3J0JTIwZXZhbHVhdGUlMEElMEFtZXRyaWMlMjAlM0QlMjBldmFsdWF0ZS5sb2FkKCUyMmFjY3VyYWN5JTIyKQ==",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">import</span> numpy <span class="hljs-keyword">as</span> np
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">import</span> evaluate

<span class="hljs-meta">&gt;&gt;&gt; </span>metric = evaluate.load(<span class="hljs-string">&quot;accuracy&quot;</span>)`}}),X=new V({props:{code:"ZGVmJTIwY29tcHV0ZV9tZXRyaWNzKGV2YWxfcHJlZCklM0ElMEElMjAlMjAlMjAlMjBsb2dpdHMlMkMlMjBsYWJlbHMlMjAlM0QlMjBldmFsX3ByZWQlMEElMjAlMjAlMjAlMjBwcmVkaWN0aW9ucyUyMCUzRCUyMG5wLmFyZ21heChsb2dpdHMlMkMlMjBheGlzJTNELTEpJTBBJTIwJTIwJTIwJTIwcmV0dXJuJTIwbWV0cmljLmNvbXB1dGUocHJlZGljdGlvbnMlM0RwcmVkaWN0aW9ucyUyQyUyMHJlZmVyZW5jZXMlM0RsYWJlbHMp",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">def</span> <span class="hljs-title function_">compute_metrics</span>(<span class="hljs-params">eval_pred</span>):
<span class="hljs-meta">... </span>    logits, labels = eval_pred
<span class="hljs-meta">... </span>    predictions = np.argmax(logits, axis=-<span class="hljs-number">1</span>)
<span class="hljs-meta">... </span>    <span class="hljs-keyword">return</span> metric.compute(predictions=predictions, references=labels)`}}),G=new V({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMFRyYWluaW5nQXJndW1lbnRzJTJDJTIwVHJhaW5lciUwQSUwQXRyYWluaW5nX2FyZ3MlMjAlM0QlMjBUcmFpbmluZ0FyZ3VtZW50cyhvdXRwdXRfZGlyJTNEJTIydGVzdF90cmFpbmVyJTIyJTJDJTIwZXZhbHVhdGlvbl9zdHJhdGVneSUzRCUyMmVwb2NoJTIyKQ==",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> TrainingArguments, Trainer

<span class="hljs-meta">&gt;&gt;&gt; </span>training_args = TrainingArguments(output_dir=<span class="hljs-string">&quot;test_trainer&quot;</span>, evaluation_strategy=<span class="hljs-string">&quot;epoch&quot;</span>)`}}),Y=new te({}),P=new V({props:{code:"dHJhaW5lciUyMCUzRCUyMFRyYWluZXIoJTBBJTIwJTIwJTIwJTIwbW9kZWwlM0Rtb2RlbCUyQyUwQSUyMCUyMCUyMCUyMGFyZ3MlM0R0cmFpbmluZ19hcmdzJTJDJTBBJTIwJTIwJTIwJTIwdHJhaW5fZGF0YXNldCUzRHNtYWxsX3RyYWluX2RhdGFzZXQlMkMlMEElMjAlMjAlMjAlMjBldmFsX2RhdGFzZXQlM0RzbWFsbF9ldmFsX2RhdGFzZXQlMkMlMEElMjAlMjAlMjAlMjBjb21wdXRlX21ldHJpY3MlM0Rjb21wdXRlX21ldHJpY3MlMkMlMEEp",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span>trainer = Trainer(
<span class="hljs-meta">... </span>    model=model,
<span class="hljs-meta">... </span>    args=training_args,
<span class="hljs-meta">... </span>    train_dataset=small_train_dataset,
<span class="hljs-meta">... </span>    eval_dataset=small_eval_dataset,
<span class="hljs-meta">... </span>    compute_metrics=compute_metrics,
<span class="hljs-meta">... </span>)`}}),a=new V({props:{code:"dHJhaW5lci50cmFpbigp",highlighted:'<span class="hljs-meta">&gt;&gt;&gt; </span>trainer.train()'}}),{c(){w(m.$$.fragment),k=o(),h=r("h2"),_=r("a"),C=r("span"),w(Z.$$.fragment),Ht=o(),z=r("span"),z.textContent=Yt,it=o(),Jt=r("p"),Jt.innerHTML=ee,K=o(),F=r("p"),F.innerHTML=ht,lt=o(),w(at.$$.fragment),wt=o(),w(H.$$.fragment),Qt=o(),x=r("h3"),mt=r("a"),ct=r("span"),w(W.$$.fragment),xt=o(),dt=r("span"),dt.textContent=vt,kt=o(),At=r("p"),At.innerHTML=Rt,D=o(),O=r("p"),O.innerHTML=_t,se=o(),tt=r("p"),tt.textContent=ft,Gt=o(),w(et.$$.fragment),N=o(),R=r("h3"),I=r("a"),Ct=r("span"),w(nt.$$.fragment),bt=o(),Xt=r("span"),Xt.textContent=ut,It=o(),S=r("p"),S.innerHTML=rt,jt=o(),w(L.$$.fragment),Et=o(),st=r("p"),st.innerHTML=pt,Mt=o(),w(X.$$.fragment),Tt=o(),E=r("p"),E.innerHTML=Kt,Ft=o(),w(G.$$.fragment),ae=o(),ot=r("h3"),U=r("a"),Nt=r("span"),w(Y.$$.fragment),Bt=o(),Q=r("span"),Q.textContent=A,St=o(),B=r("p"),B.innerHTML=Pt,Zt=o(),w(P.$$.fragment),le=o(),q=r("p"),q.innerHTML=yt,Ut=o(),w(a.$$.fragment),this.h()},l(l){v(m.$$.fragment,l),k=i(l),h=p(l,"H2",{class:!0});var y=$(h);_=p(y,"A",{id:!0,class:!0,href:!0});var gt=$(_);C=p(gt,"SPAN",{});var Vt=$(C);v(Z.$$.fragment,Vt),Vt.forEach(t),gt.forEach(t),Ht=i(y),z=p(y,"SPAN",{"data-svelte-h":!0}),g(z)!=="svelte-xux3je"&&(z.textContent=Yt),y.forEach(t),it=i(l),Jt=p(l,"P",{"data-svelte-h":!0}),g(Jt)!=="svelte-1a30hsl"&&(Jt.innerHTML=ee),K=i(l),F=p(l,"P",{"data-svelte-h":!0}),g(F)!=="svelte-vv5j33"&&(F.innerHTML=ht),lt=i(l),v(at.$$.fragment,l),wt=i(l),v(H.$$.fragment,l),Qt=i(l),x=p(l,"H3",{class:!0});var $t=$(x);mt=p($t,"A",{id:!0,class:!0,href:!0});var Dt=$(mt);ct=p(Dt,"SPAN",{});var Lt=$(ct);v(W.$$.fragment,Lt),Lt.forEach(t),Dt.forEach(t),xt=i($t),dt=p($t,"SPAN",{"data-svelte-h":!0}),g(dt)!=="svelte-1pmq875"&&(dt.textContent=vt),$t.forEach(t),kt=i(l),At=p(l,"P",{"data-svelte-h":!0}),g(At)!=="svelte-1sl91ao"&&(At.innerHTML=Rt),D=i(l),O=p(l,"P",{"data-svelte-h":!0}),g(O)!=="svelte-17gf6c"&&(O.innerHTML=_t),se=i(l),tt=p(l,"P",{"data-svelte-h":!0}),g(tt)!=="svelte-3gh4w5"&&(tt.textContent=ft),Gt=i(l),v(et.$$.fragment,l),N=i(l),R=p(l,"H3",{class:!0});var zt=$(R);I=p(zt,"A",{id:!0,class:!0,href:!0});var re=$(I);Ct=p(re,"SPAN",{});var ie=$(Ct);v(nt.$$.fragment,ie),ie.forEach(t),re.forEach(t),bt=i(zt),Xt=p(zt,"SPAN",{"data-svelte-h":!0}),g(Xt)!=="svelte-1nunm40"&&(Xt.textContent=ut),zt.forEach(t),It=i(l),S=p(l,"P",{"data-svelte-h":!0}),g(S)!=="svelte-1ofd291"&&(S.innerHTML=rt),jt=i(l),v(L.$$.fragment,l),Et=i(l),st=p(l,"P",{"data-svelte-h":!0}),g(st)!=="svelte-fpot8d"&&(st.innerHTML=pt),Mt=i(l),v(X.$$.fragment,l),Tt=i(l),E=p(l,"P",{"data-svelte-h":!0}),g(E)!=="svelte-b8mk68"&&(E.innerHTML=Kt),Ft=i(l),v(G.$$.fragment,l),ae=i(l),ot=p(l,"H3",{class:!0});var qt=$(ot);U=p(qt,"A",{id:!0,class:!0,href:!0});var ne=$(U);Nt=p(ne,"SPAN",{});var he=$(Nt);v(Y.$$.fragment,he),he.forEach(t),ne.forEach(t),Bt=i(qt),Q=p(qt,"SPAN",{"data-svelte-h":!0}),g(Q)!=="svelte-4fwkgz"&&(Q.textContent=A),qt.forEach(t),St=i(l),B=p(l,"P",{"data-svelte-h":!0}),g(B)!=="svelte-w01mtl"&&(B.innerHTML=Pt),Zt=i(l),v(P.$$.fragment,l),le=i(l),q=p(l,"P",{"data-svelte-h":!0}),g(q)!=="svelte-xfml58"&&(q.innerHTML=yt),Ut=i(l),v(a.$$.fragment,l),this.h()},h(){u(_,"id","train-with-pytorch-trainer"),u(_,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),u(_,"href","#train-with-pytorch-trainer"),u(h,"class","relative group"),u(mt,"id","training-hyperparameters"),u(mt,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),u(mt,"href","#training-hyperparameters"),u(x,"class","relative group"),u(I,"id","evaluate"),u(I,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),u(I,"href","#evaluate"),u(R,"class","relative group"),u(U,"id","trainer"),u(U,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),u(U,"href","#trainer"),u(ot,"class","relative group")},m(l,y){b(m,l,y),s(l,k,y),s(l,h,y),c(h,_),c(_,C),b(Z,C,null),c(h,Ht),c(h,z),s(l,it,y),s(l,Jt,y),s(l,K,y),s(l,F,y),s(l,lt,y),b(at,l,y),s(l,wt,y),b(H,l,y),s(l,Qt,y),s(l,x,y),c(x,mt),c(mt,ct),b(W,ct,null),c(x,xt),c(x,dt),s(l,kt,y),s(l,At,y),s(l,D,y),s(l,O,y),s(l,se,y),s(l,tt,y),s(l,Gt,y),b(et,l,y),s(l,N,y),s(l,R,y),c(R,I),c(I,Ct),b(nt,Ct,null),c(R,bt),c(R,Xt),s(l,It,y),s(l,S,y),s(l,jt,y),b(L,l,y),s(l,Et,y),s(l,st,y),s(l,Mt,y),b(X,l,y),s(l,Tt,y),s(l,E,y),s(l,Ft,y),b(G,l,y),s(l,ae,y),s(l,ot,y),c(ot,U),c(U,Nt),b(Y,Nt,null),c(ot,Bt),c(ot,Q),s(l,St,y),s(l,B,y),s(l,Zt,y),b(P,l,y),s(l,le,y),s(l,q,y),s(l,Ut,y),b(a,l,y),d=!0},p(l,y){const gt={};y&2&&(gt.$$scope={dirty:y,ctx:l}),H.$set(gt)},i(l){d||(j(m.$$.fragment,l),j(Z.$$.fragment,l),j(at.$$.fragment,l),j(H.$$.fragment,l),j(W.$$.fragment,l),j(et.$$.fragment,l),j(nt.$$.fragment,l),j(L.$$.fragment,l),j(X.$$.fragment,l),j(G.$$.fragment,l),j(Y.$$.fragment,l),j(P.$$.fragment,l),j(a.$$.fragment,l),d=!0)},o(l){T(m.$$.fragment,l),T(Z.$$.fragment,l),T(at.$$.fragment,l),T(H.$$.fragment,l),T(W.$$.fragment,l),T(et.$$.fragment,l),T(nt.$$.fragment,l),T(L.$$.fragment,l),T(X.$$.fragment,l),T(G.$$.fragment,l),T(Y.$$.fragment,l),T(P.$$.fragment,l),T(a.$$.fragment,l),d=!1},d(l){l&&(t(k),t(h),t(it),t(Jt),t(K),t(F),t(lt),t(wt),t(Qt),t(x),t(kt),t(At),t(D),t(O),t(se),t(tt),t(Gt),t(N),t(R),t(It),t(S),t(jt),t(Et),t(st),t(Mt),t(Tt),t(E),t(Ft),t(ae),t(ot),t(St),t(B),t(Zt),t(le),t(q),t(Ut)),J(m,l),J(Z),J(at,l),J(H,l),J(W),J(et,l),J(nt),J(L,l),J(X,l),J(G,l),J(Y),J(P,l),J(a,l)}}}function qe(Wt){let m,k;return m=new Ge({props:{$$slots:{default:[Pe]},$$scope:{ctx:Wt}}}),{c(){w(m.$$.fragment)},l(h){v(m.$$.fragment,h)},m(h,_){b(m,h,_),k=!0},p(h,_){const C={};_&2&&(C.$$scope={dirty:_,ctx:h}),m.$set(C)},i(h){k||(j(m.$$.fragment,h),k=!0)},o(h){T(m.$$.fragment,h),k=!1},d(h){J(m,h)}}}function Ke(Wt){let m,k=`모델을 <code>compile()</code>할 때 손실 인수를 모델에 전달할 필요가 없습니다!
이 인수를 비워두면 허깅 페이스 모델은 작업과 모델 아키텍처에 적합한 손실을 자동으로 선택합니다.
원한다면 언제든지 직접 손실을 지정하여 이를 재정의할 수 있습니다!`;return{c(){m=r("p"),m.innerHTML=k},l(h){m=p(h,"P",{"data-svelte-h":!0}),g(m)!=="svelte-z0fgk0"&&(m.innerHTML=k)},m(h,_){s(h,m,_)},p:Ue,d(h){h&&t(m)}}}function De(Wt){let m,k,h,_,C,Z,Ht,z,Yt,it,Jt="Keras로 텐서플로우 모델 훈련하기",ee,K,F="Keras API를 사용하여 텐서플로우에서 🤗 Transformers 모델을 훈련할 수도 있습니다!",ht,lt,at,wt,H,Qt,x,mt="Keras용 데이터 로드",ct,W,xt=`Keras API로 🤗 Transformers 모델을 학습시키려면 데이터셋을 Keras가 이해할 수 있는 형식으로 변환해야 합니다.
데이터 세트가 작은 경우, 전체를 NumPy 배열로 변환하여 Keras로 전달하면 됩니다.
더 복잡한 작업을 수행하기 전에 먼저 이 작업을 시도해 보겠습니다.`,dt,vt,kt=`먼저 데이터 세트를 로드합니다. <a href="https://huggingface.co/datasets/glue" rel="nofollow">GLUE 벤치마크</a>의 CoLA 데이터 세트를 사용하겠습니다.
간단한 바이너리 텍스트 분류 작업이므로 지금은 훈련 데이터 분할만 사용합니다.`,At,Rt,D,O,_t="다음으로 토크나이저를 로드하고 데이터를 NumPy 배열로 토큰화합니다. 레이블은 이미 0과 1로 된 리스트이기 때문에 토큰화하지 않고 바로 NumPy 배열로 변환할 수 있습니다!",se,tt,ft,Gt,et='마지막으로 모델을 로드, <a href="https://keras.io/api/models/model_training_apis/#compile-method" rel="nofollow"><code>compile</code></a>, <a href="https://keras.io/api/models/model_training_apis/#fit-method" rel="nofollow"><code>fit</code></a>합니다:',N,R,I,Ct,nt,bt,Xt=`이 접근 방식은 소규모 데이터 집합에서는 잘 작동하지만, 대규모 데이터 집합에서는 문제가 될 수 있습니다. 왜 그럴까요?
토큰화된 배열과 레이블을 메모리에 완전히 로드하고 NumPy는 “들쭉날쭉한” 배열을 처리하지 않기 때문에,
모든 토큰화된 샘플을 전체 데이터셋에서 가장 긴 샘플의 길이만큼 패딩해야 합니다. 이렇게 하면 배열이 훨씬 더 커지고 이 패딩 토큰으로 인해 학습 속도도 느려집니다!`,ut,It,S,rt,jt,L,Et,st="데이터를 tf.data.Dataset으로 로드하기",pt,Mt,X=`학습 속도가 느려지는 것을 피하려면 데이터를 <code>tf.data.Dataset</code>으로 로드할 수 있습니다. 원한다면 직접
<code>tf.data</code> 파이프라인을 직접 작성할 수도 있지만, 이 작업을 간편하게 수행하는 수 있는 두 가지 방법이 있습니다:`,Tt,E,Kt=`<li><code>prepare_tf_dataset()</code>: 대부분의 경우 이 방법을 권장합니다. 모델의 메서드이기 때문에 모델을 검사하여 모델 입력으로 사용할 수 있는 열을 자동으로 파악하고
나머지는 버려서 더 단순하고 성능이 좋은 데이터 집합을 만들 수 있습니다.</li> <li><code>to_tf_dataset</code>: 이 방법은 좀 더 낮은 수준이며, 포함할 ‘열’과 ‘레이블’을 정확히 지정하여
데이터셋을 생성하는 방법을 정확히 제어하고 싶을 때 유용하며, 포함할 ‘columns’과 ‘label_cols’을 정확히 지정할 수 있습니다.</li>`,Ft,G,ae="<code>prepare_tf_dataset()</code>을 사용하려면 먼저 다음 코드 샘플과 같이 토크나이저 출력을 데이터 세트에 열로 추가해야 합니다:",ot,U,Nt,Y,Bt=`허깅 페이스 데이터셋은 기본적으로 디스크에 저장되므로 메모리 사용량을 늘리지 않는다는 점을 기억하세요!
열이 추가되면 데이터셋에서 배치를 스트리밍하고 각 배치에 패딩을 추가할 수 있으므로 전체 데이터셋에 패딩을 추가하는 것보다 패딩 토큰의 수를 크게 줄일 수 있습니다.`,Q,A,St,B,Pt=`위의 코드 샘플에서는 배치가 로드될 때 올바르게 패딩할 수 있도록 <code>prepare_tf_dataset</code>에 토크나이저를 전달해야 합니다.
데이터셋의 모든 샘플 길이가 같고 패딩이 필요하지 않은 경우 이 인수를 건너뛸 수 있습니다.
샘플을 채우는 것보다 더 복잡한 작업(예: 마스킹된 언어의 토큰 손상 모델링)을 수행하기 위해 토큰을 손상시켜야 하는 경우,
<code>collate_fn</code> 인수를 사용하여 샘플 목록을 배치로 변환하고 원하는 전처리를 적용할 함수를 전달할 수 있습니다.
<a href="https://github.com/huggingface/transformers/tree/main/examples" rel="nofollow">예시</a> 또는
<a href="https://huggingface.co/docs/transformers/notebooks" rel="nofollow">노트북</a>을 참조하여 이 접근 방식이 실제로 작동하는 모습을 확인하세요.`,Zt,P,le="<code>tf.data.Dataset</code>을 생성한 후에는 이전과 마찬가지로 모델을 컴파일하고 훈련(fit)할 수 있습니다:",q,yt,Ut;return h=new Ze({props:{id:"rnTGBy2ax1c"}}),z=new te({}),H=new te({}),Rt=new V({props:{code:"ZnJvbSUyMGRhdGFzZXRzJTIwaW1wb3J0JTIwbG9hZF9kYXRhc2V0JTBBJTBBZGF0YXNldCUyMCUzRCUyMGxvYWRfZGF0YXNldCglMjJnbHVlJTIyJTJDJTIwJTIyY29sYSUyMiklMEFkYXRhc2V0JTIwJTNEJTIwZGF0YXNldCU1QiUyMnRyYWluJTIyJTVEJTIwJTIwJTIzJTIwSnVzdCUyMHRha2UlMjB0aGUlMjB0cmFpbmluZyUyMHNwbGl0JTIwZm9yJTIwbm93",highlighted:`<span class="hljs-keyword">from</span> datasets <span class="hljs-keyword">import</span> load_dataset

dataset = load_dataset(<span class="hljs-string">&quot;glue&quot;</span>, <span class="hljs-string">&quot;cola&quot;</span>)
dataset = dataset[<span class="hljs-string">&quot;train&quot;</span>]  <span class="hljs-comment"># Just take the training split for now</span>`}}),tt=new V({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMEF1dG9Ub2tlbml6ZXIlMEElMEF0b2tlbml6ZXIlMjAlM0QlMjBBdXRvVG9rZW5pemVyLmZyb21fcHJldHJhaW5lZCglMjJiZXJ0LWJhc2UtY2FzZWQlMjIpJTBBdG9rZW5pemVkX2RhdGElMjAlM0QlMjB0b2tlbml6ZXIoZGF0YXNldCU1QiUyMnNlbnRlbmNlJTIyJTVEJTJDJTIwcmV0dXJuX3RlbnNvcnMlM0QlMjJucCUyMiUyQyUyMHBhZGRpbmclM0RUcnVlKSUwQSUyMyUyMFRva2VuaXplciUyMHJldHVybnMlMjBhJTIwQmF0Y2hFbmNvZGluZyUyQyUyMGJ1dCUyMHdlJTIwY29udmVydCUyMHRoYXQlMjB0byUyMGElMjBkaWN0JTIwZm9yJTIwS2VyYXMlMEF0b2tlbml6ZWRfZGF0YSUyMCUzRCUyMGRpY3QodG9rZW5pemVkX2RhdGEpJTBBJTBBbGFiZWxzJTIwJTNEJTIwbnAuYXJyYXkoZGF0YXNldCU1QiUyMmxhYmVsJTIyJTVEKSUyMCUyMCUyMyUyMExhYmVsJTIwaXMlMjBhbHJlYWR5JTIwYW4lMjBhcnJheSUyMG9mJTIwMCUyMGFuZCUyMDE=",highlighted:`<span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoTokenizer

tokenizer = AutoTokenizer.from_pretrained(<span class="hljs-string">&quot;bert-base-cased&quot;</span>)
tokenized_data = tokenizer(dataset[<span class="hljs-string">&quot;sentence&quot;</span>], return_tensors=<span class="hljs-string">&quot;np&quot;</span>, padding=<span class="hljs-literal">True</span>)
<span class="hljs-comment"># Tokenizer returns a BatchEncoding, but we convert that to a dict for Keras</span>
tokenized_data = <span class="hljs-built_in">dict</span>(tokenized_data)

labels = np.array(dataset[<span class="hljs-string">&quot;label&quot;</span>])  <span class="hljs-comment"># Label is already an array of 0 and 1</span>`}}),R=new V({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMFRGQXV0b01vZGVsRm9yU2VxdWVuY2VDbGFzc2lmaWNhdGlvbiUwQWZyb20lMjB0ZW5zb3JmbG93LmtlcmFzLm9wdGltaXplcnMlMjBpbXBvcnQlMjBBZGFtJTBBJTBBJTIzJTIwTG9hZCUyMGFuZCUyMGNvbXBpbGUlMjBvdXIlMjBtb2RlbCUwQW1vZGVsJTIwJTNEJTIwVEZBdXRvTW9kZWxGb3JTZXF1ZW5jZUNsYXNzaWZpY2F0aW9uLmZyb21fcHJldHJhaW5lZCglMjJiZXJ0LWJhc2UtY2FzZWQlMjIpJTBBJTIzJTIwTG93ZXIlMjBsZWFybmluZyUyMHJhdGVzJTIwYXJlJTIwb2Z0ZW4lMjBiZXR0ZXIlMjBmb3IlMjBmaW5lLXR1bmluZyUyMHRyYW5zZm9ybWVycyUwQW1vZGVsLmNvbXBpbGUob3B0aW1pemVyJTNEQWRhbSgzZS01KSklMEElMEFtb2RlbC5maXQodG9rZW5pemVkX2RhdGElMkMlMjBsYWJlbHMp",highlighted:`<span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> TFAutoModelForSequenceClassification
<span class="hljs-keyword">from</span> tensorflow.keras.optimizers <span class="hljs-keyword">import</span> Adam

<span class="hljs-comment"># Load and compile our model</span>
model = TFAutoModelForSequenceClassification.from_pretrained(<span class="hljs-string">&quot;bert-base-cased&quot;</span>)
<span class="hljs-comment"># Lower learning rates are often better for fine-tuning transformers</span>
model.<span class="hljs-built_in">compile</span>(optimizer=Adam(<span class="hljs-number">3e-5</span>))

model.fit(tokenized_data, labels)`}}),Ct=new xe({props:{$$slots:{default:[Ke]},$$scope:{ctx:Wt}}}),jt=new te({}),U=new V({props:{code:"ZGVmJTIwdG9rZW5pemVfZGF0YXNldChkYXRhKSUzQSUwQSUyMCUyMCUyMCUyMCUyMyUyMEtleXMlMjBvZiUyMHRoZSUyMHJldHVybmVkJTIwZGljdGlvbmFyeSUyMHdpbGwlMjBiZSUyMGFkZGVkJTIwdG8lMjB0aGUlMjBkYXRhc2V0JTIwYXMlMjBjb2x1bW5zJTBBJTIwJTIwJTIwJTIwcmV0dXJuJTIwdG9rZW5pemVyKGRhdGElNUIlMjJ0ZXh0JTIyJTVEKSUwQSUwQSUwQWRhdGFzZXQlMjAlM0QlMjBkYXRhc2V0Lm1hcCh0b2tlbml6ZV9kYXRhc2V0KQ==",highlighted:`<span class="hljs-keyword">def</span> <span class="hljs-title function_">tokenize_dataset</span>(<span class="hljs-params">data</span>):
    <span class="hljs-comment"># Keys of the returned dictionary will be added to the dataset as columns</span>
    <span class="hljs-keyword">return</span> tokenizer(data[<span class="hljs-string">&quot;text&quot;</span>])


dataset = dataset.<span class="hljs-built_in">map</span>(tokenize_dataset)`}}),A=new V({props:{code:"dGZfZGF0YXNldCUyMCUzRCUyMG1vZGVsLnByZXBhcmVfdGZfZGF0YXNldChkYXRhc2V0JTJDJTIwYmF0Y2hfc2l6ZSUzRDE2JTJDJTIwc2h1ZmZsZSUzRFRydWUlMkMlMjB0b2tlbml6ZXIlM0R0b2tlbml6ZXIp",highlighted:'<span class="hljs-meta">&gt;&gt;&gt; </span>tf_dataset = model.prepare_tf_dataset(dataset, batch_size=<span class="hljs-number">16</span>, shuffle=<span class="hljs-literal">True</span>, tokenizer=tokenizer)'}}),yt=new V({props:{code:"bW9kZWwuY29tcGlsZShvcHRpbWl6ZXIlM0RBZGFtKDNlLTUpKSUwQSUwQW1vZGVsLmZpdCh0Zl9kYXRhc2V0KQ==",highlighted:`model.<span class="hljs-built_in">compile</span>(optimizer=Adam(<span class="hljs-number">3e-5</span>))

model.fit(tf_dataset)`}}),{c(){m=r("a"),k=o(),w(h.$$.fragment),_=o(),C=r("h2"),Z=r("a"),Ht=r("span"),w(z.$$.fragment),Yt=o(),it=r("span"),it.textContent=Jt,ee=o(),K=r("p"),K.textContent=F,ht=o(),lt=r("h3"),at=r("a"),wt=r("span"),w(H.$$.fragment),Qt=o(),x=r("span"),x.textContent=mt,ct=o(),W=r("p"),W.textContent=xt,dt=o(),vt=r("p"),vt.innerHTML=kt,At=o(),w(Rt.$$.fragment),D=o(),O=r("p"),O.textContent=_t,se=o(),w(tt.$$.fragment),ft=o(),Gt=r("p"),Gt.innerHTML=et,N=o(),w(R.$$.fragment),I=o(),w(Ct.$$.fragment),nt=o(),bt=r("p"),bt.textContent=Xt,ut=o(),It=r("h3"),S=r("a"),rt=r("span"),w(jt.$$.fragment),L=o(),Et=r("span"),Et.textContent=st,pt=o(),Mt=r("p"),Mt.innerHTML=X,Tt=o(),E=r("ul"),E.innerHTML=Kt,Ft=o(),G=r("p"),G.innerHTML=ae,ot=o(),w(U.$$.fragment),Nt=o(),Y=r("p"),Y.textContent=Bt,Q=o(),w(A.$$.fragment),St=o(),B=r("p"),B.innerHTML=Pt,Zt=o(),P=r("p"),P.innerHTML=le,q=o(),w(yt.$$.fragment),this.h()},l(a){m=p(a,"A",{id:!0}),$(m).forEach(t),k=i(a),v(h.$$.fragment,a),_=i(a),C=p(a,"H2",{class:!0});var d=$(C);Z=p(d,"A",{id:!0,class:!0,href:!0});var l=$(Z);Ht=p(l,"SPAN",{});var y=$(Ht);v(z.$$.fragment,y),y.forEach(t),l.forEach(t),Yt=i(d),it=p(d,"SPAN",{"data-svelte-h":!0}),g(it)!=="svelte-uqfh4n"&&(it.textContent=Jt),d.forEach(t),ee=i(a),K=p(a,"P",{"data-svelte-h":!0}),g(K)!=="svelte-ze9716"&&(K.textContent=F),ht=i(a),lt=p(a,"H3",{class:!0});var gt=$(lt);at=p(gt,"A",{id:!0,class:!0,href:!0});var Vt=$(at);wt=p(Vt,"SPAN",{});var $t=$(wt);v(H.$$.fragment,$t),$t.forEach(t),Vt.forEach(t),Qt=i(gt),x=p(gt,"SPAN",{"data-svelte-h":!0}),g(x)!=="svelte-1c89e88"&&(x.textContent=mt),gt.forEach(t),ct=i(a),W=p(a,"P",{"data-svelte-h":!0}),g(W)!=="svelte-15pnkld"&&(W.textContent=xt),dt=i(a),vt=p(a,"P",{"data-svelte-h":!0}),g(vt)!=="svelte-1u2iume"&&(vt.innerHTML=kt),At=i(a),v(Rt.$$.fragment,a),D=i(a),O=p(a,"P",{"data-svelte-h":!0}),g(O)!=="svelte-kduu5a"&&(O.textContent=_t),se=i(a),v(tt.$$.fragment,a),ft=i(a),Gt=p(a,"P",{"data-svelte-h":!0}),g(Gt)!=="svelte-1mtm6sq"&&(Gt.innerHTML=et),N=i(a),v(R.$$.fragment,a),I=i(a),v(Ct.$$.fragment,a),nt=i(a),bt=p(a,"P",{"data-svelte-h":!0}),g(bt)!=="svelte-1ggdj2"&&(bt.textContent=Xt),ut=i(a),It=p(a,"H3",{class:!0});var Dt=$(It);S=p(Dt,"A",{id:!0,class:!0,href:!0});var Lt=$(S);rt=p(Lt,"SPAN",{});var zt=$(rt);v(jt.$$.fragment,zt),zt.forEach(t),Lt.forEach(t),L=i(Dt),Et=p(Dt,"SPAN",{"data-svelte-h":!0}),g(Et)!=="svelte-p9esx1"&&(Et.textContent=st),Dt.forEach(t),pt=i(a),Mt=p(a,"P",{"data-svelte-h":!0}),g(Mt)!=="svelte-5ru8h1"&&(Mt.innerHTML=X),Tt=i(a),E=p(a,"UL",{"data-svelte-h":!0}),g(E)!=="svelte-10w0g1z"&&(E.innerHTML=Kt),Ft=i(a),G=p(a,"P",{"data-svelte-h":!0}),g(G)!=="svelte-10gw6tz"&&(G.innerHTML=ae),ot=i(a),v(U.$$.fragment,a),Nt=i(a),Y=p(a,"P",{"data-svelte-h":!0}),g(Y)!=="svelte-10zjmdj"&&(Y.textContent=Bt),Q=i(a),v(A.$$.fragment,a),St=i(a),B=p(a,"P",{"data-svelte-h":!0}),g(B)!=="svelte-1k6j3lz"&&(B.innerHTML=Pt),Zt=i(a),P=p(a,"P",{"data-svelte-h":!0}),g(P)!=="svelte-zwzwju"&&(P.innerHTML=le),q=i(a),v(yt.$$.fragment,a),this.h()},h(){u(m,"id","keras"),u(Z,"id","train-a-tensorflow-model-with-keras"),u(Z,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),u(Z,"href","#train-a-tensorflow-model-with-keras"),u(C,"class","relative group"),u(at,"id","loading-data-for-keras"),u(at,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),u(at,"href","#loading-data-for-keras"),u(lt,"class","relative group"),u(S,"id","loading-data-as-a-tfdatadataset"),u(S,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),u(S,"href","#loading-data-as-a-tfdatadataset"),u(It,"class","relative group")},m(a,d){s(a,m,d),s(a,k,d),b(h,a,d),s(a,_,d),s(a,C,d),c(C,Z),c(Z,Ht),b(z,Ht,null),c(C,Yt),c(C,it),s(a,ee,d),s(a,K,d),s(a,ht,d),s(a,lt,d),c(lt,at),c(at,wt),b(H,wt,null),c(lt,Qt),c(lt,x),s(a,ct,d),s(a,W,d),s(a,dt,d),s(a,vt,d),s(a,At,d),b(Rt,a,d),s(a,D,d),s(a,O,d),s(a,se,d),b(tt,a,d),s(a,ft,d),s(a,Gt,d),s(a,N,d),b(R,a,d),s(a,I,d),b(Ct,a,d),s(a,nt,d),s(a,bt,d),s(a,ut,d),s(a,It,d),c(It,S),c(S,rt),b(jt,rt,null),c(It,L),c(It,Et),s(a,pt,d),s(a,Mt,d),s(a,Tt,d),s(a,E,d),s(a,Ft,d),s(a,G,d),s(a,ot,d),b(U,a,d),s(a,Nt,d),s(a,Y,d),s(a,Q,d),b(A,a,d),s(a,St,d),s(a,B,d),s(a,Zt,d),s(a,P,d),s(a,q,d),b(yt,a,d),Ut=!0},p(a,d){const l={};d&2&&(l.$$scope={dirty:d,ctx:a}),Ct.$set(l)},i(a){Ut||(j(h.$$.fragment,a),j(z.$$.fragment,a),j(H.$$.fragment,a),j(Rt.$$.fragment,a),j(tt.$$.fragment,a),j(R.$$.fragment,a),j(Ct.$$.fragment,a),j(jt.$$.fragment,a),j(U.$$.fragment,a),j(A.$$.fragment,a),j(yt.$$.fragment,a),Ut=!0)},o(a){T(h.$$.fragment,a),T(z.$$.fragment,a),T(H.$$.fragment,a),T(Rt.$$.fragment,a),T(tt.$$.fragment,a),T(R.$$.fragment,a),T(Ct.$$.fragment,a),T(jt.$$.fragment,a),T(U.$$.fragment,a),T(A.$$.fragment,a),T(yt.$$.fragment,a),Ut=!1},d(a){a&&(t(m),t(k),t(_),t(C),t(ee),t(K),t(ht),t(lt),t(ct),t(W),t(dt),t(vt),t(At),t(D),t(O),t(se),t(ft),t(Gt),t(N),t(I),t(nt),t(bt),t(ut),t(It),t(pt),t(Mt),t(Tt),t(E),t(Ft),t(G),t(ot),t(Nt),t(Y),t(Q),t(St),t(B),t(Zt),t(P),t(q)),J(h,a),J(z),J(H),J(Rt,a),J(tt,a),J(R,a),J(Ct,a),J(jt),J(U,a),J(A,a),J(yt,a)}}}function Oe(Wt){let m,k;return m=new Ge({props:{$$slots:{default:[De]},$$scope:{ctx:Wt}}}),{c(){w(m.$$.fragment)},l(h){v(m.$$.fragment,h)},m(h,_){b(m,h,_),k=!0},p(h,_){const C={};_&2&&(C.$$scope={dirty:_,ctx:h}),m.$set(C)},i(h){k||(j(m.$$.fragment,h),k=!0)},o(h){T(m.$$.fragment,h),k=!1},d(h){J(m,h)}}}function ts(Wt){let m,k='<a href="https://colab.research.google.com/" rel="nofollow">Colaboratory</a> 또는 <a href="https://studiolab.sagemaker.aws/" rel="nofollow">SageMaker StudioLab</a>과 같은 호스팅 노트북이 없는 경우 클라우드 GPU에 무료로 액세스할 수 있습니다.';return{c(){m=r("p"),m.innerHTML=k},l(h){m=p(h,"P",{"data-svelte-h":!0}),g(m)!=="svelte-1ctkiwu"&&(m.innerHTML=k)},m(h,_){s(h,m,_)},p:Ue,d(h){h&&t(m)}}}function es(Wt){let m,k,h,_="<code>Trainer</code>는 훈련 루프를 처리하며 한 줄의 코드로 모델을 미세 조정할 수 있습니다. 직접 훈련 루프를 작성하는 것을 선호하는 사용자의 경우, 기본 PyTorch에서 🤗 Transformers 모델을 미세 조정할 수도 있습니다.",C,Z,Ht="이 시점에서 노트북을 다시 시작하거나 다음 코드를 실행해 메모리를 확보해야 할 수 있습니다:",z,Yt,it,Jt,ee="다음으로, ‘토큰화된 데이터셋’을 수동으로 후처리하여 훈련련에 사용할 수 있도록 준비합니다.",K,F,ht,lt,at="모델이 원시 텍스트를 입력으로 허용하지 않으므로 <code>text</code> 열을 제거합니다:",wt,H,Qt,x,mt,ct="모델에서 인수의 이름이 <code>labels</code>로 지정될 것으로 예상하므로 <code>label</code> 열의 이름을 <code>labels</code>로 변경합니다:",W,xt,dt,vt,kt,At="데이터셋의 형식을 List 대신 PyTorch 텐서를 반환하도록 설정합니다:",Rt,D,O,_t,se="그리고 앞서 표시된 대로 데이터셋의 더 작은 하위 집합을 생성하여 미세 조정 속도를 높입니다:",tt,ft,Gt,et,N,R,I,Ct,nt,bt="DataLoader",Xt,ut,It="훈련 및 테스트 데이터셋에 대한 ‘DataLoader’를 생성하여 데이터 배치를 반복할 수 있습니다:",S,rt,jt,L,Et="예측을 위한 레이블 개수를 사용하여 모델을 로드합니다:",st,pt,Mt,X,Tt,E,Kt,Ft,G,ae="옵티마이저 및 학습 속도 스케줄러",ot,U,Nt='옵티마이저와 학습 속도 스케줄러를 생성하여 모델을 미세 조정합니다. 파이토치에서 제공하는 <a href="https://pytorch.org/docs/stable/generated/torch.optim.AdamW.html" rel="nofollow"><code>AdamW</code></a> 옵티마이저를 사용해 보겠습니다:',Y,Bt,Q,A,St="<code>Trainer</code>에서 기본 학습 속도 스케줄러를 생성합니다:",B,Pt,Zt,P,le="마지막으로, GPU에 액세스할 수 있는 경우 ‘device’를 지정하여 GPU를 사용하도록 합니다. 그렇지 않으면 CPU에서 훈련하며 몇 분이 아닌 몇 시간이 걸릴 수 있습니다.",q,yt,Ut,a,d,l,y="이제 훈련할 준비가 되었습니다! 🥳",gt,Vt,$t,Dt,Lt,zt,re,ie="훈련 루프",qt,ne,he='훈련 진행 상황을 추적하려면 <a href="https://tqdm.github.io/" rel="nofollow">tqdm</a> 라이브러리를 사용하여 트레이닝 단계 수에 진행률 표시줄을 추가하세요:',me,pe,n,f,Ot,oe,ce,$e,Me,ve="평가 하기",ye,de,be="<code>Trainer</code>에 평가 함수를 추가한 방법과 마찬가지로, 훈련 루프를 직접 작성할 때도 동일한 작업을 수행해야 합니다. 하지만 이번에는 각 에포크가 끝날 때마다 평가지표를 계산하여 보고하는 대신, <code>add_batch</code>를 사용하여 모든 배치를 누적하고 맨 마지막에 평가지표를 계산합니다.",ge,fe,we;return m=new Ze({props:{id:"Dh9CL8fyG80"}}),Yt=new V({props:{code:"ZGVsJTIwbW9kZWwlMEFkZWwlMjB0cmFpbmVyJTBBdG9yY2guY3VkYS5lbXB0eV9jYWNoZSgp",highlighted:`<span class="hljs-keyword">del</span> model
<span class="hljs-keyword">del</span> trainer
torch.cuda.empty_cache()`}}),H=new V({props:{code:"dG9rZW5pemVkX2RhdGFzZXRzJTIwJTNEJTIwdG9rZW5pemVkX2RhdGFzZXRzLnJlbW92ZV9jb2x1bW5zKCU1QiUyMnRleHQlMjIlNUQp",highlighted:'<span class="hljs-meta">&gt;&gt;&gt; </span>tokenized_datasets = tokenized_datasets.remove_columns([<span class="hljs-string">&quot;text&quot;</span>])'}}),xt=new V({props:{code:"dG9rZW5pemVkX2RhdGFzZXRzJTIwJTNEJTIwdG9rZW5pemVkX2RhdGFzZXRzLnJlbmFtZV9jb2x1bW4oJTIybGFiZWwlMjIlMkMlMjAlMjJsYWJlbHMlMjIp",highlighted:'<span class="hljs-meta">&gt;&gt;&gt; </span>tokenized_datasets = tokenized_datasets.rename_column(<span class="hljs-string">&quot;label&quot;</span>, <span class="hljs-string">&quot;labels&quot;</span>)'}}),D=new V({props:{code:"dG9rZW5pemVkX2RhdGFzZXRzLnNldF9mb3JtYXQoJTIydG9yY2glMjIp",highlighted:'<span class="hljs-meta">&gt;&gt;&gt; </span>tokenized_datasets.set_format(<span class="hljs-string">&quot;torch&quot;</span>)'}}),ft=new V({props:{code:"c21hbGxfdHJhaW5fZGF0YXNldCUyMCUzRCUyMHRva2VuaXplZF9kYXRhc2V0cyU1QiUyMnRyYWluJTIyJTVELnNodWZmbGUoc2VlZCUzRDQyKS5zZWxlY3QocmFuZ2UoMTAwMCkpJTBBc21hbGxfZXZhbF9kYXRhc2V0JTIwJTNEJTIwdG9rZW5pemVkX2RhdGFzZXRzJTVCJTIydGVzdCUyMiU1RC5zaHVmZmxlKHNlZWQlM0Q0Mikuc2VsZWN0KHJhbmdlKDEwMDApKQ==",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span>small_train_dataset = tokenized_datasets[<span class="hljs-string">&quot;train&quot;</span>].shuffle(seed=<span class="hljs-number">42</span>).select(<span class="hljs-built_in">range</span>(<span class="hljs-number">1000</span>))
<span class="hljs-meta">&gt;&gt;&gt; </span>small_eval_dataset = tokenized_datasets[<span class="hljs-string">&quot;test&quot;</span>].shuffle(seed=<span class="hljs-number">42</span>).select(<span class="hljs-built_in">range</span>(<span class="hljs-number">1000</span>))`}}),I=new te({}),rt=new V({props:{code:"ZnJvbSUyMHRvcmNoLnV0aWxzLmRhdGElMjBpbXBvcnQlMjBEYXRhTG9hZGVyJTBBJTBBdHJhaW5fZGF0YWxvYWRlciUyMCUzRCUyMERhdGFMb2FkZXIoc21hbGxfdHJhaW5fZGF0YXNldCUyQyUyMHNodWZmbGUlM0RUcnVlJTJDJTIwYmF0Y2hfc2l6ZSUzRDgpJTBBZXZhbF9kYXRhbG9hZGVyJTIwJTNEJTIwRGF0YUxvYWRlcihzbWFsbF9ldmFsX2RhdGFzZXQlMkMlMjBiYXRjaF9zaXplJTNEOCk=",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> torch.utils.data <span class="hljs-keyword">import</span> DataLoader

<span class="hljs-meta">&gt;&gt;&gt; </span>train_dataloader = DataLoader(small_train_dataset, shuffle=<span class="hljs-literal">True</span>, batch_size=<span class="hljs-number">8</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>eval_dataloader = DataLoader(small_eval_dataset, batch_size=<span class="hljs-number">8</span>)`}}),pt=new V({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMEF1dG9Nb2RlbEZvclNlcXVlbmNlQ2xhc3NpZmljYXRpb24lMEElMEFtb2RlbCUyMCUzRCUyMEF1dG9Nb2RlbEZvclNlcXVlbmNlQ2xhc3NpZmljYXRpb24uZnJvbV9wcmV0cmFpbmVkKCUyMmJlcnQtYmFzZS1jYXNlZCUyMiUyQyUyMG51bV9sYWJlbHMlM0Q1KQ==",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoModelForSequenceClassification

<span class="hljs-meta">&gt;&gt;&gt; </span>model = AutoModelForSequenceClassification.from_pretrained(<span class="hljs-string">&quot;bert-base-cased&quot;</span>, num_labels=<span class="hljs-number">5</span>)`}}),Kt=new te({}),Bt=new V({props:{code:"ZnJvbSUyMHRvcmNoLm9wdGltJTIwaW1wb3J0JTIwQWRhbVclMEElMEFvcHRpbWl6ZXIlMjAlM0QlMjBBZGFtVyhtb2RlbC5wYXJhbWV0ZXJzKCklMkMlMjBsciUzRDVlLTUp",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> torch.optim <span class="hljs-keyword">import</span> AdamW

<span class="hljs-meta">&gt;&gt;&gt; </span>optimizer = AdamW(model.parameters(), lr=<span class="hljs-number">5e-5</span>)`}}),Pt=new V({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMGdldF9zY2hlZHVsZXIlMEElMEFudW1fZXBvY2hzJTIwJTNEJTIwMyUwQW51bV90cmFpbmluZ19zdGVwcyUyMCUzRCUyMG51bV9lcG9jaHMlMjAqJTIwbGVuKHRyYWluX2RhdGFsb2FkZXIpJTBBbHJfc2NoZWR1bGVyJTIwJTNEJTIwZ2V0X3NjaGVkdWxlciglMEElMjAlMjAlMjAlMjBuYW1lJTNEJTIybGluZWFyJTIyJTJDJTIwb3B0aW1pemVyJTNEb3B0aW1pemVyJTJDJTIwbnVtX3dhcm11cF9zdGVwcyUzRDAlMkMlMjBudW1fdHJhaW5pbmdfc3RlcHMlM0RudW1fdHJhaW5pbmdfc3RlcHMlMEEp",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> get_scheduler

<span class="hljs-meta">&gt;&gt;&gt; </span>num_epochs = <span class="hljs-number">3</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>num_training_steps = num_epochs * <span class="hljs-built_in">len</span>(train_dataloader)
<span class="hljs-meta">&gt;&gt;&gt; </span>lr_scheduler = get_scheduler(
<span class="hljs-meta">... </span>    name=<span class="hljs-string">&quot;linear&quot;</span>, optimizer=optimizer, num_warmup_steps=<span class="hljs-number">0</span>, num_training_steps=num_training_steps
<span class="hljs-meta">... </span>)`}}),yt=new V({props:{code:"aW1wb3J0JTIwdG9yY2glMEElMEFkZXZpY2UlMjAlM0QlMjB0b3JjaC5kZXZpY2UoJTIyY3VkYSUyMiklMjBpZiUyMHRvcmNoLmN1ZGEuaXNfYXZhaWxhYmxlKCklMjBlbHNlJTIwdG9yY2guZGV2aWNlKCUyMmNwdSUyMiklMEFtb2RlbC50byhkZXZpY2Up",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">import</span> torch

<span class="hljs-meta">&gt;&gt;&gt; </span>device = torch.device(<span class="hljs-string">&quot;cuda&quot;</span>) <span class="hljs-keyword">if</span> torch.cuda.is_available() <span class="hljs-keyword">else</span> torch.device(<span class="hljs-string">&quot;cpu&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>model.to(device)`}}),a=new xe({props:{$$slots:{default:[ts]},$$scope:{ctx:Wt}}}),Lt=new te({}),pe=new V({props:{code:"ZnJvbSUyMHRxZG0uYXV0byUyMGltcG9ydCUyMHRxZG0lMEElMEFwcm9ncmVzc19iYXIlMjAlM0QlMjB0cWRtKHJhbmdlKG51bV90cmFpbmluZ19zdGVwcykpJTBBJTBBbW9kZWwudHJhaW4oKSUwQWZvciUyMGVwb2NoJTIwaW4lMjByYW5nZShudW1fZXBvY2hzKSUzQSUwQSUyMCUyMCUyMCUyMGZvciUyMGJhdGNoJTIwaW4lMjB0cmFpbl9kYXRhbG9hZGVyJTNBJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwYmF0Y2glMjAlM0QlMjAlN0JrJTNBJTIwdi50byhkZXZpY2UpJTIwZm9yJTIwayUyQyUyMHYlMjBpbiUyMGJhdGNoLml0ZW1zKCklN0QlMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjBvdXRwdXRzJTIwJTNEJTIwbW9kZWwoKipiYXRjaCklMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjBsb3NzJTIwJTNEJTIwb3V0cHV0cy5sb3NzJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwbG9zcy5iYWNrd2FyZCgpJTBBJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwb3B0aW1pemVyLnN0ZXAoKSUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMGxyX3NjaGVkdWxlci5zdGVwKCklMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjBvcHRpbWl6ZXIuemVyb19ncmFkKCklMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjBwcm9ncmVzc19iYXIudXBkYXRlKDEp",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> tqdm.auto <span class="hljs-keyword">import</span> tqdm

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

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

<span class="hljs-meta">... </span>        optimizer.step()
<span class="hljs-meta">... </span>        lr_scheduler.step()
<span class="hljs-meta">... </span>        optimizer.zero_grad()
<span class="hljs-meta">... </span>        progress_bar.update(<span class="hljs-number">1</span>)`}}),ce=new te({}),fe=new V({props:{code:"aW1wb3J0JTIwZXZhbHVhdGUlMEElMEFtZXRyaWMlMjAlM0QlMjBldmFsdWF0ZS5sb2FkKCUyMmFjY3VyYWN5JTIyKSUwQW1vZGVsLmV2YWwoKSUwQWZvciUyMGJhdGNoJTIwaW4lMjBldmFsX2RhdGFsb2FkZXIlM0ElMEElMjAlMjAlMjAlMjBiYXRjaCUyMCUzRCUyMCU3QmslM0ElMjB2LnRvKGRldmljZSklMjBmb3IlMjBrJTJDJTIwdiUyMGluJTIwYmF0Y2guaXRlbXMoKSU3RCUwQSUyMCUyMCUyMCUyMHdpdGglMjB0b3JjaC5ub19ncmFkKCklM0ElMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjBvdXRwdXRzJTIwJTNEJTIwbW9kZWwoKipiYXRjaCklMEElMEElMjAlMjAlMjAlMjBsb2dpdHMlMjAlM0QlMjBvdXRwdXRzLmxvZ2l0cyUwQSUyMCUyMCUyMCUyMHByZWRpY3Rpb25zJTIwJTNEJTIwdG9yY2guYXJnbWF4KGxvZ2l0cyUyQyUyMGRpbSUzRC0xKSUwQSUyMCUyMCUyMCUyMG1ldHJpYy5hZGRfYmF0Y2gocHJlZGljdGlvbnMlM0RwcmVkaWN0aW9ucyUyQyUyMHJlZmVyZW5jZXMlM0RiYXRjaCU1QiUyMmxhYmVscyUyMiU1RCklMEElMEFtZXRyaWMuY29tcHV0ZSgp",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">import</span> evaluate

<span class="hljs-meta">&gt;&gt;&gt; </span>metric = evaluate.load(<span class="hljs-string">&quot;accuracy&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>model.<span class="hljs-built_in">eval</span>()
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">for</span> batch <span class="hljs-keyword">in</span> eval_dataloader:
<span class="hljs-meta">... </span>    batch = {k: v.to(device) <span class="hljs-keyword">for</span> k, v <span class="hljs-keyword">in</span> batch.items()}
<span class="hljs-meta">... </span>    <span class="hljs-keyword">with</span> torch.no_grad():
<span class="hljs-meta">... </span>        outputs = model(**batch)

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

<span class="hljs-meta">&gt;&gt;&gt; </span>metric.compute()`}}),{c(){w(m.$$.fragment),k=o(),h=r("p"),h.innerHTML=_,C=o(),Z=r("p"),Z.textContent=Ht,z=o(),w(Yt.$$.fragment),it=o(),Jt=r("p"),Jt.textContent=ee,K=o(),F=r("ol"),ht=r("li"),lt=r("p"),lt.innerHTML=at,wt=o(),w(H.$$.fragment),Qt=o(),x=r("li"),mt=r("p"),mt.innerHTML=ct,W=o(),w(xt.$$.fragment),dt=o(),vt=r("li"),kt=r("p"),kt.textContent=At,Rt=o(),w(D.$$.fragment),O=o(),_t=r("p"),_t.textContent=se,tt=o(),w(ft.$$.fragment),Gt=o(),et=r("h3"),N=r("a"),R=r("span"),w(I.$$.fragment),Ct=o(),nt=r("span"),nt.textContent=bt,Xt=o(),ut=r("p"),ut.textContent=It,S=o(),w(rt.$$.fragment),jt=o(),L=r("p"),L.textContent=Et,st=o(),w(pt.$$.fragment),Mt=o(),X=r("h3"),Tt=r("a"),E=r("span"),w(Kt.$$.fragment),Ft=o(),G=r("span"),G.textContent=ae,ot=o(),U=r("p"),U.innerHTML=Nt,Y=o(),w(Bt.$$.fragment),Q=o(),A=r("p"),A.innerHTML=St,B=o(),w(Pt.$$.fragment),Zt=o(),P=r("p"),P.textContent=le,q=o(),w(yt.$$.fragment),Ut=o(),w(a.$$.fragment),d=o(),l=r("p"),l.textContent=y,gt=o(),Vt=r("h3"),$t=r("a"),Dt=r("span"),w(Lt.$$.fragment),zt=o(),re=r("span"),re.textContent=ie,qt=o(),ne=r("p"),ne.innerHTML=he,me=o(),w(pe.$$.fragment),n=o(),f=r("h3"),Ot=r("a"),oe=r("span"),w(ce.$$.fragment),$e=o(),Me=r("span"),Me.textContent=ve,ye=o(),de=r("p"),de.innerHTML=be,ge=o(),w(fe.$$.fragment),this.h()},l(e){v(m.$$.fragment,e),k=i(e),h=p(e,"P",{"data-svelte-h":!0}),g(h)!=="svelte-26l7tj"&&(h.innerHTML=_),C=i(e),Z=p(e,"P",{"data-svelte-h":!0}),g(Z)!=="svelte-192c5yp"&&(Z.textContent=Ht),z=i(e),v(Yt.$$.fragment,e),it=i(e),Jt=p(e,"P",{"data-svelte-h":!0}),g(Jt)!=="svelte-108uveq"&&(Jt.textContent=ee),K=i(e),F=p(e,"OL",{});var M=$(F);ht=p(M,"LI",{});var ue=$(ht);lt=p(ue,"P",{"data-svelte-h":!0}),g(lt)!=="svelte-1y5q08j"&&(lt.innerHTML=at),wt=i(ue),v(H.$$.fragment,ue),ue.forEach(t),Qt=i(M),x=p(M,"LI",{});var je=$(x);mt=p(je,"P",{"data-svelte-h":!0}),g(mt)!=="svelte-1j9nsiy"&&(mt.innerHTML=ct),W=i(je),v(xt.$$.fragment,je),je.forEach(t),dt=i(M),vt=p(M,"LI",{});var Te=$(vt);kt=p(Te,"P",{"data-svelte-h":!0}),g(kt)!=="svelte-1h9qay5"&&(kt.textContent=At),Rt=i(Te),v(D.$$.fragment,Te),Te.forEach(t),M.forEach(t),O=i(e),_t=p(e,"P",{"data-svelte-h":!0}),g(_t)!=="svelte-hdideh"&&(_t.textContent=se),tt=i(e),v(ft.$$.fragment,e),Gt=i(e),et=p(e,"H3",{class:!0});var Je=$(et);N=p(Je,"A",{id:!0,class:!0,href:!0});var Ie=$(N);R=p(Ie,"SPAN",{});var We=$(R);v(I.$$.fragment,We),We.forEach(t),Ie.forEach(t),Ct=i(Je),nt=p(Je,"SPAN",{"data-svelte-h":!0}),g(nt)!=="svelte-19b0x1w"&&(nt.textContent=bt),Je.forEach(t),Xt=i(e),ut=p(e,"P",{"data-svelte-h":!0}),g(ut)!=="svelte-1ektf94"&&(ut.textContent=It),S=i(e),v(rt.$$.fragment,e),jt=i(e),L=p(e,"P",{"data-svelte-h":!0}),g(L)!=="svelte-sqozl7"&&(L.textContent=Et),st=i(e),v(pt.$$.fragment,e),Mt=i(e),X=p(e,"H3",{class:!0});var ke=$(X);Tt=p(ke,"A",{id:!0,class:!0,href:!0});var Re=$(Tt);E=p(Re,"SPAN",{});var Xe=$(E);v(Kt.$$.fragment,Xe),Xe.forEach(t),Re.forEach(t),Ft=i(ke),G=p(ke,"SPAN",{"data-svelte-h":!0}),g(G)!=="svelte-1hvdjsg"&&(G.textContent=ae),ke.forEach(t),ot=i(e),U=p(e,"P",{"data-svelte-h":!0}),g(U)!=="svelte-15zsq6h"&&(U.innerHTML=Nt),Y=i(e),v(Bt.$$.fragment,e),Q=i(e),A=p(e,"P",{"data-svelte-h":!0}),g(A)!=="svelte-15mbbl4"&&(A.innerHTML=St),B=i(e),v(Pt.$$.fragment,e),Zt=i(e),P=p(e,"P",{"data-svelte-h":!0}),g(P)!=="svelte-e6t5r4"&&(P.textContent=le),q=i(e),v(yt.$$.fragment,e),Ut=i(e),v(a.$$.fragment,e),d=i(e),l=p(e,"P",{"data-svelte-h":!0}),g(l)!=="svelte-1yeeebv"&&(l.textContent=y),gt=i(e),Vt=p(e,"H3",{class:!0});var _e=$(Vt);$t=p(_e,"A",{id:!0,class:!0,href:!0});var Ee=$($t);Dt=p(Ee,"SPAN",{});var Be=$(Dt);v(Lt.$$.fragment,Be),Be.forEach(t),Ee.forEach(t),zt=i(_e),re=p(_e,"SPAN",{"data-svelte-h":!0}),g(re)!=="svelte-hqwlfj"&&(re.textContent=ie),_e.forEach(t),qt=i(e),ne=p(e,"P",{"data-svelte-h":!0}),g(ne)!=="svelte-1atq943"&&(ne.innerHTML=he),me=i(e),v(pe.$$.fragment,e),n=i(e),f=p(e,"H3",{class:!0});var Ce=$(f);Ot=p(Ce,"A",{id:!0,class:!0,href:!0});var Ve=$(Ot);oe=p(Ve,"SPAN",{});var ze=$(oe);v(ce.$$.fragment,ze),ze.forEach(t),Ve.forEach(t),$e=i(Ce),Me=p(Ce,"SPAN",{"data-svelte-h":!0}),g(Me)!=="svelte-1nunm40"&&(Me.textContent=ve),Ce.forEach(t),ye=i(e),de=p(e,"P",{"data-svelte-h":!0}),g(de)!=="svelte-18p9q2b"&&(de.innerHTML=be),ge=i(e),v(fe.$$.fragment,e),this.h()},h(){u(N,"id","dataloader"),u(N,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),u(N,"href","#dataloader"),u(et,"class","relative group"),u(Tt,"id","optimizer-and-learning-rate-scheduler"),u(Tt,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),u(Tt,"href","#optimizer-and-learning-rate-scheduler"),u(X,"class","relative group"),u($t,"id","training-loop"),u($t,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),u($t,"href","#training-loop"),u(Vt,"class","relative group"),u(Ot,"id","evaluate"),u(Ot,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),u(Ot,"href","#evaluate"),u(f,"class","relative group")},m(e,M){b(m,e,M),s(e,k,M),s(e,h,M),s(e,C,M),s(e,Z,M),s(e,z,M),b(Yt,e,M),s(e,it,M),s(e,Jt,M),s(e,K,M),s(e,F,M),c(F,ht),c(ht,lt),c(ht,wt),b(H,ht,null),c(F,Qt),c(F,x),c(x,mt),c(x,W),b(xt,x,null),c(F,dt),c(F,vt),c(vt,kt),c(vt,Rt),b(D,vt,null),s(e,O,M),s(e,_t,M),s(e,tt,M),b(ft,e,M),s(e,Gt,M),s(e,et,M),c(et,N),c(N,R),b(I,R,null),c(et,Ct),c(et,nt),s(e,Xt,M),s(e,ut,M),s(e,S,M),b(rt,e,M),s(e,jt,M),s(e,L,M),s(e,st,M),b(pt,e,M),s(e,Mt,M),s(e,X,M),c(X,Tt),c(Tt,E),b(Kt,E,null),c(X,Ft),c(X,G),s(e,ot,M),s(e,U,M),s(e,Y,M),b(Bt,e,M),s(e,Q,M),s(e,A,M),s(e,B,M),b(Pt,e,M),s(e,Zt,M),s(e,P,M),s(e,q,M),b(yt,e,M),s(e,Ut,M),b(a,e,M),s(e,d,M),s(e,l,M),s(e,gt,M),s(e,Vt,M),c(Vt,$t),c($t,Dt),b(Lt,Dt,null),c(Vt,zt),c(Vt,re),s(e,qt,M),s(e,ne,M),s(e,me,M),b(pe,e,M),s(e,n,M),s(e,f,M),c(f,Ot),c(Ot,oe),b(ce,oe,null),c(f,$e),c(f,Me),s(e,ye,M),s(e,de,M),s(e,ge,M),b(fe,e,M),we=!0},p(e,M){const ue={};M&2&&(ue.$$scope={dirty:M,ctx:e}),a.$set(ue)},i(e){we||(j(m.$$.fragment,e),j(Yt.$$.fragment,e),j(H.$$.fragment,e),j(xt.$$.fragment,e),j(D.$$.fragment,e),j(ft.$$.fragment,e),j(I.$$.fragment,e),j(rt.$$.fragment,e),j(pt.$$.fragment,e),j(Kt.$$.fragment,e),j(Bt.$$.fragment,e),j(Pt.$$.fragment,e),j(yt.$$.fragment,e),j(a.$$.fragment,e),j(Lt.$$.fragment,e),j(pe.$$.fragment,e),j(ce.$$.fragment,e),j(fe.$$.fragment,e),we=!0)},o(e){T(m.$$.fragment,e),T(Yt.$$.fragment,e),T(H.$$.fragment,e),T(xt.$$.fragment,e),T(D.$$.fragment,e),T(ft.$$.fragment,e),T(I.$$.fragment,e),T(rt.$$.fragment,e),T(pt.$$.fragment,e),T(Kt.$$.fragment,e),T(Bt.$$.fragment,e),T(Pt.$$.fragment,e),T(yt.$$.fragment,e),T(a.$$.fragment,e),T(Lt.$$.fragment,e),T(pe.$$.fragment,e),T(ce.$$.fragment,e),T(fe.$$.fragment,e),we=!1},d(e){e&&(t(k),t(h),t(C),t(Z),t(z),t(it),t(Jt),t(K),t(F),t(O),t(_t),t(tt),t(Gt),t(et),t(Xt),t(ut),t(S),t(jt),t(L),t(st),t(Mt),t(X),t(ot),t(U),t(Y),t(Q),t(A),t(B),t(Zt),t(P),t(q),t(Ut),t(d),t(l),t(gt),t(Vt),t(qt),t(ne),t(me),t(n),t(f),t(ye),t(de),t(ge)),J(m,e),J(Yt,e),J(H),J(xt),J(D),J(ft,e),J(I),J(rt,e),J(pt,e),J(Kt),J(Bt,e),J(Pt,e),J(yt,e),J(a,e),J(Lt),J(pe,e),J(ce),J(fe,e)}}}function ss(Wt){let m,k;return m=new Ge({props:{$$slots:{default:[es]},$$scope:{ctx:Wt}}}),{c(){w(m.$$.fragment)},l(h){v(m.$$.fragment,h)},m(h,_){b(m,h,_),k=!0},p(h,_){const C={};_&2&&(C.$$scope={dirty:_,ctx:h}),m.$set(C)},i(h){k||(j(m.$$.fragment,h),k=!0)},o(h){T(m.$$.fragment,h),k=!1},d(h){J(m,h)}}}function ls(Wt){let m,k,h,_,C,Z,Ht,z,Yt,it,Jt="사전 학습된 모델 미세 튜닝하기",ee,K,F,ht,lt="사전 학습된 모델을 사용하면 상당한 이점이 있습니다. 계산 비용과 탄소발자국을 줄이고, 처음부터 모델을 학습시킬 필요 없이 최신 모델을 사용할 수 있습니다. 🤗 Transformers는 다양한 작업을 위해 사전 학습된 수천 개의 모델에 액세스할 수 있습니다. 사전 학습된 모델을 사용하는 경우, 자신의 작업과 관련된 데이터셋을 사용해 학습합니다. 이것은 미세 튜닝이라고 하는 매우 강력한 훈련 기법입니다. 이 튜토리얼에서는 당신이 선택한 딥러닝 프레임워크로 사전 학습된 모델을 미세 튜닝합니다:",at,wt,H="<li>🤗 Transformers로 사전 학습된 모델 미세 튜닝하기 <code>Trainer</code>.</li> <li>Keras를 사용하여 TensorFlow에서 사전 학습된 모델을 미세 튜닝하기.</li> <li>기본 PyTorch에서 사전 학습된 모델을 미세 튜닝하기.</li>",Qt,x,mt,ct,W,xt,dt,vt,kt,At="데이터셋 준비",Rt,D,O,_t,se="사전 학습된 모델을 미세 튜닝하기 위해서 데이터셋을 다운로드하고 훈련할 수 있도록 준비하세요. 이전 튜토리얼에서 훈련을 위해 데이터를 처리하는 방법을 보여드렸는데, 지금이 배울 걸 되짚을 기회입니다!",tt,ft,Gt='먼저 <a href="https://huggingface.co/datasets/yelp_review_full" rel="nofollow">Yelp 리뷰</a> 데이터 세트를 로드합니다:',et,N,R,I,Ct='텍스트를 처리하고 서로 다른 길이의 시퀀스 패딩 및 잘라내기 전략을 포함하려면 토크나이저가 필요합니다. 데이터셋을 한 번에 처리하려면 🤗 Dataset <a href="https://huggingface.co/docs/datasets/process.html#map" rel="nofollow"><code>map</code></a> 메서드를 사용하여 전체 데이터셋에 전처리 함수를 적용하세요:',nt,bt,Xt,ut,It="필요한 경우 미세 튜닝을 위해 데이터셋의 작은 부분 집합을 만들어 미세 튜닝 작업 시간을 줄일 수 있습니다:",S,rt,jt,L,Et,st,pt,Mt,X,Tt,E,Kt="Train",Ft,G,ae="여기서부터는 사용하려는 프레임워크에 해당하는 섹션을 따라야 합니다. 오른쪽 사이드바의 링크를 사용하여 원하는 프레임워크로 이동할 수 있으며, 특정 프레임워크의 모든 콘텐츠를 숨기려면 해당 프레임워크 블록의 오른쪽 상단에 있는 버튼을 사용하면 됩니다!",ot,U,Nt,Y,Bt,Q,A,St,B,Pt,Zt,P="기본 파이토치로 훈련하기",le,q,yt,Ut,a,d,l,y,gt,Vt,$t,Dt="추가 자료",Lt,zt,re="더 많은 미세 튜닝 예제는 다음을 참조하세요:",ie,qt,ne='<li><p><a href="https://github.com/huggingface/transformers/tree/main/examples" rel="nofollow">🤗 Trnasformers 예제</a>에는 PyTorch 및 텐서플로우에서 일반적인 NLP 작업을 훈련할 수 있는 스크립트가 포함되어 있습니다.</p></li> <li><p><a href="notebooks">🤗 Transformers 노트북</a>에는 PyTorch 및 텐서플로우에서 특정 작업을 위해 모델을 미세 튜닝하는 방법에 대한 다양한 노트북이 포함되어 있습니다.</p></li>',he,me,pe;return z=new te({}),K=new Le({props:{classNames:"absolute z-10 right-0 top-0",options:[{label:"Mixed",value:"https://colab.research.google.com/github/huggingface/notebooks/blob/main/transformers_doc/ko/training.ipynb"},{label:"PyTorch",value:"https://colab.research.google.com/github/huggingface/notebooks/blob/main/transformers_doc/ko/pytorch/training.ipynb"},{label:"TensorFlow",value:"https://colab.research.google.com/github/huggingface/notebooks/blob/main/transformers_doc/ko/tensorflow/training.ipynb"},{label:"Mixed",value:"https://studiolab.sagemaker.aws/import/github/huggingface/notebooks/blob/main/transformers_doc/ko/training.ipynb"},{label:"PyTorch",value:"https://studiolab.sagemaker.aws/import/github/huggingface/notebooks/blob/main/transformers_doc/ko/pytorch/training.ipynb"},{label:"TensorFlow",value:"https://studiolab.sagemaker.aws/import/github/huggingface/notebooks/blob/main/transformers_doc/ko/tensorflow/training.ipynb"}]}}),dt=new te({}),D=new Ze({props:{id:"_BZearw7f0w"}}),N=new V({props:{code:"ZnJvbSUyMGRhdGFzZXRzJTIwaW1wb3J0JTIwbG9hZF9kYXRhc2V0JTBBJTBBZGF0YXNldCUyMCUzRCUyMGxvYWRfZGF0YXNldCglMjJ5ZWxwX3Jldmlld19mdWxsJTIyKSUwQWRhdGFzZXQlNUIlMjJ0cmFpbiUyMiU1RCU1QjEwMCU1RA==",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> datasets <span class="hljs-keyword">import</span> load_dataset

<span class="hljs-meta">&gt;&gt;&gt; </span>dataset = load_dataset(<span class="hljs-string">&quot;yelp_review_full&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>dataset[<span class="hljs-string">&quot;train&quot;</span>][<span class="hljs-number">100</span>]
{<span class="hljs-string">&#x27;label&#x27;</span>: <span class="hljs-number">0</span>,
 <span class="hljs-string">&#x27;text&#x27;</span>: <span class="hljs-string">&#x27;My expectations for McDonalds are t rarely high. But for one to still fail so spectacularly...that takes something special!\\\\nThe cashier took my friends\\&#x27;s order, then promptly ignored me. I had to force myself in front of a cashier who opened his register to wait on the person BEHIND me. I waited over five minutes for a gigantic order that included precisely one kid\\&#x27;s meal. After watching two people who ordered after me be handed their food, I asked where mine was. The manager started yelling at the cashiers for \\\\&quot;serving off their orders\\\\&quot; when they didn\\&#x27;t have their food. But neither cashier was anywhere near those controls, and the manager was the one serving food to customers and clearing the boards.\\\\nThe manager was rude when giving me my order. She didn\\&#x27;t make sure that I had everything ON MY RECEIPT, and never even had the decency to apologize that I felt I was getting poor service.\\\\nI\\&#x27;ve eaten at various McDonalds restaurants for over 30 years. I\\&#x27;ve worked at more than one location. I expect bad days, bad moods, and the occasional mistake. But I have yet to have a decent experience at this store. It will remain a place I avoid unless someone in my party needs to avoid illness from low blood sugar. Perhaps I should go back to the racially biased service of Steak n Shake instead!&#x27;</span>}`}}),bt=new V({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMEF1dG9Ub2tlbml6ZXIlMEElMEF0b2tlbml6ZXIlMjAlM0QlMjBBdXRvVG9rZW5pemVyLmZyb21fcHJldHJhaW5lZCglMjJiZXJ0LWJhc2UtY2FzZWQlMjIpJTBBJTBBJTBBZGVmJTIwdG9rZW5pemVfZnVuY3Rpb24oZXhhbXBsZXMpJTNBJTBBJTIwJTIwJTIwJTIwcmV0dXJuJTIwdG9rZW5pemVyKGV4YW1wbGVzJTVCJTIydGV4dCUyMiU1RCUyQyUyMHBhZGRpbmclM0QlMjJtYXhfbGVuZ3RoJTIyJTJDJTIwdHJ1bmNhdGlvbiUzRFRydWUpJTBBJTBBJTBBdG9rZW5pemVkX2RhdGFzZXRzJTIwJTNEJTIwZGF0YXNldC5tYXAodG9rZW5pemVfZnVuY3Rpb24lMkMlMjBiYXRjaGVkJTNEVHJ1ZSk=",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoTokenizer

<span class="hljs-meta">&gt;&gt;&gt; </span>tokenizer = AutoTokenizer.from_pretrained(<span class="hljs-string">&quot;bert-base-cased&quot;</span>)


<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">def</span> <span class="hljs-title function_">tokenize_function</span>(<span class="hljs-params">examples</span>):
<span class="hljs-meta">... </span>    <span class="hljs-keyword">return</span> tokenizer(examples[<span class="hljs-string">&quot;text&quot;</span>], padding=<span class="hljs-string">&quot;max_length&quot;</span>, truncation=<span class="hljs-literal">True</span>)


<span class="hljs-meta">&gt;&gt;&gt; </span>tokenized_datasets = dataset.<span class="hljs-built_in">map</span>(tokenize_function, batched=<span class="hljs-literal">True</span>)`}}),rt=new V({props:{code:"c21hbGxfdHJhaW5fZGF0YXNldCUyMCUzRCUyMHRva2VuaXplZF9kYXRhc2V0cyU1QiUyMnRyYWluJTIyJTVELnNodWZmbGUoc2VlZCUzRDQyKS5zZWxlY3QocmFuZ2UoMTAwMCkpJTBBc21hbGxfZXZhbF9kYXRhc2V0JTIwJTNEJTIwdG9rZW5pemVkX2RhdGFzZXRzJTVCJTIydGVzdCUyMiU1RC5zaHVmZmxlKHNlZWQlM0Q0Mikuc2VsZWN0KHJhbmdlKDEwMDApKQ==",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span>small_train_dataset = tokenized_datasets[<span class="hljs-string">&quot;train&quot;</span>].shuffle(seed=<span class="hljs-number">42</span>).select(<span class="hljs-built_in">range</span>(<span class="hljs-number">1000</span>))
<span class="hljs-meta">&gt;&gt;&gt; </span>small_eval_dataset = tokenized_datasets[<span class="hljs-string">&quot;test&quot;</span>].shuffle(seed=<span class="hljs-number">42</span>).select(<span class="hljs-built_in">range</span>(<span class="hljs-number">1000</span>))`}}),X=new te({}),U=new He({props:{pytorch:!0,tensorflow:!0,jax:!1,$$slots:{tensorflow:[Oe],pytorch:[qe]},$$scope:{ctx:Wt}}}),B=new te({}),q=new He({props:{pytorch:!0,tensorflow:!1,jax:!1,$$slots:{pytorch:[ss]},$$scope:{ctx:Wt}}}),gt=new te({}),{c(){m=r("meta"),k=o(),h=r("p"),_=o(),C=r("h1"),Z=r("a"),Ht=r("span"),w(z.$$.fragment),Yt=o(),it=r("span"),it.textContent=Jt,ee=o(),w(K.$$.fragment),F=o(),ht=r("p"),ht.textContent=lt,at=o(),wt=r("ul"),wt.innerHTML=H,Qt=o(),x=r("a"),mt=o(),ct=r("h2"),W=r("a"),xt=r("span"),w(dt.$$.fragment),vt=o(),kt=r("span"),kt.textContent=At,Rt=o(),w(D.$$.fragment),O=o(),_t=r("p"),_t.textContent=se,tt=o(),ft=r("p"),ft.innerHTML=Gt,et=o(),w(N.$$.fragment),R=o(),I=r("p"),I.innerHTML=Ct,nt=o(),w(bt.$$.fragment),Xt=o(),ut=r("p"),ut.textContent=It,S=o(),w(rt.$$.fragment),jt=o(),L=r("a"),Et=o(),st=r("h2"),pt=r("a"),Mt=r("span"),w(X.$$.fragment),Tt=o(),E=r("span"),E.textContent=Kt,Ft=o(),G=r("p"),G.textContent=ae,ot=o(),w(U.$$.fragment),Nt=o(),Y=r("a"),Bt=o(),Q=r("h2"),A=r("a"),St=r("span"),w(B.$$.fragment),Pt=o(),Zt=r("span"),Zt.textContent=P,le=o(),w(q.$$.fragment),yt=o(),Ut=r("a"),a=o(),d=r("h2"),l=r("a"),y=r("span"),w(gt.$$.fragment),Vt=o(),$t=r("span"),$t.textContent=Dt,Lt=o(),zt=r("p"),zt.textContent=re,ie=o(),qt=r("ul"),qt.innerHTML=ne,he=o(),me=r("p"),this.h()},l(n){const f=Se("svelte-1phssyn",document.head);m=p(f,"META",{name:!0,content:!0}),f.forEach(t),k=i(n),h=p(n,"P",{}),$(h).forEach(t),_=i(n),C=p(n,"H1",{class:!0});var Ot=$(C);Z=p(Ot,"A",{id:!0,class:!0,href:!0});var oe=$(Z);Ht=p(oe,"SPAN",{});var ce=$(Ht);v(z.$$.fragment,ce),ce.forEach(t),oe.forEach(t),Yt=i(Ot),it=p(Ot,"SPAN",{"data-svelte-h":!0}),g(it)!=="svelte-17fdw86"&&(it.textContent=Jt),Ot.forEach(t),ee=i(n),v(K.$$.fragment,n),F=i(n),ht=p(n,"P",{"data-svelte-h":!0}),g(ht)!=="svelte-lewprv"&&(ht.textContent=lt),at=i(n),wt=p(n,"UL",{"data-svelte-h":!0}),g(wt)!=="svelte-6blpq0"&&(wt.innerHTML=H),Qt=i(n),x=p(n,"A",{id:!0}),$(x).forEach(t),mt=i(n),ct=p(n,"H2",{class:!0});var $e=$(ct);W=p($e,"A",{id:!0,class:!0,href:!0});var Me=$(W);xt=p(Me,"SPAN",{});var ve=$(xt);v(dt.$$.fragment,ve),ve.forEach(t),Me.forEach(t),vt=i($e),kt=p($e,"SPAN",{"data-svelte-h":!0}),g(kt)!=="svelte-1ixk6yw"&&(kt.textContent=At),$e.forEach(t),Rt=i(n),v(D.$$.fragment,n),O=i(n),_t=p(n,"P",{"data-svelte-h":!0}),g(_t)!=="svelte-agqeit"&&(_t.textContent=se),tt=i(n),ft=p(n,"P",{"data-svelte-h":!0}),g(ft)!=="svelte-1w9wcpp"&&(ft.innerHTML=Gt),et=i(n),v(N.$$.fragment,n),R=i(n),I=p(n,"P",{"data-svelte-h":!0}),g(I)!=="svelte-kuz32y"&&(I.innerHTML=Ct),nt=i(n),v(bt.$$.fragment,n),Xt=i(n),ut=p(n,"P",{"data-svelte-h":!0}),g(ut)!=="svelte-jaac36"&&(ut.textContent=It),S=i(n),v(rt.$$.fragment,n),jt=i(n),L=p(n,"A",{id:!0}),$(L).forEach(t),Et=i(n),st=p(n,"H2",{class:!0});var ye=$(st);pt=p(ye,"A",{id:!0,class:!0,href:!0});var de=$(pt);Mt=p(de,"SPAN",{});var be=$(Mt);v(X.$$.fragment,be),be.forEach(t),de.forEach(t),Tt=i(ye),E=p(ye,"SPAN",{"data-svelte-h":!0}),g(E)!=="svelte-5arm0l"&&(E.textContent=Kt),ye.forEach(t),Ft=i(n),G=p(n,"P",{"data-svelte-h":!0}),g(G)!=="svelte-12mtsa7"&&(G.textContent=ae),ot=i(n),v(U.$$.fragment,n),Nt=i(n),Y=p(n,"A",{id:!0}),$(Y).forEach(t),Bt=i(n),Q=p(n,"H2",{class:!0});var ge=$(Q);A=p(ge,"A",{id:!0,class:!0,href:!0});var fe=$(A);St=p(fe,"SPAN",{});var we=$(St);v(B.$$.fragment,we),we.forEach(t),fe.forEach(t),Pt=i(ge),Zt=p(ge,"SPAN",{"data-svelte-h":!0}),g(Zt)!=="svelte-1555oen"&&(Zt.textContent=P),ge.forEach(t),le=i(n),v(q.$$.fragment,n),yt=i(n),Ut=p(n,"A",{id:!0}),$(Ut).forEach(t),a=i(n),d=p(n,"H2",{class:!0});var e=$(d);l=p(e,"A",{id:!0,class:!0,href:!0});var M=$(l);y=p(M,"SPAN",{});var ue=$(y);v(gt.$$.fragment,ue),ue.forEach(t),M.forEach(t),Vt=i(e),$t=p(e,"SPAN",{"data-svelte-h":!0}),g($t)!=="svelte-1x7i9sz"&&($t.textContent=Dt),e.forEach(t),Lt=i(n),zt=p(n,"P",{"data-svelte-h":!0}),g(zt)!=="svelte-1nv5qh9"&&(zt.textContent=re),ie=i(n),qt=p(n,"UL",{"data-svelte-h":!0}),g(qt)!=="svelte-7q2z1g"&&(qt.innerHTML=ne),he=i(n),me=p(n,"P",{}),$(me).forEach(t),this.h()},h(){u(m,"name","hf:doc:metadata"),u(m,"content",JSON.stringify(as)),u(Z,"id","finetune-a-pretrained-model"),u(Z,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),u(Z,"href","#finetune-a-pretrained-model"),u(C,"class","relative group"),u(x,"id","data-processing"),u(W,"id","prepare-a-dataset"),u(W,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),u(W,"href","#prepare-a-dataset"),u(ct,"class","relative group"),u(L,"id","trainer"),u(pt,"id","train"),u(pt,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),u(pt,"href","#train"),u(st,"class","relative group"),u(Y,"id","pytorch_native"),u(A,"id","train-in-native-pytorch"),u(A,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),u(A,"href","#train-in-native-pytorch"),u(Q,"class","relative group"),u(Ut,"id","additional-resources"),u(l,"id","additional-resources"),u(l,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),u(l,"href","#additional-resources"),u(d,"class","relative group")},m(n,f){c(document.head,m),s(n,k,f),s(n,h,f),s(n,_,f),s(n,C,f),c(C,Z),c(Z,Ht),b(z,Ht,null),c(C,Yt),c(C,it),s(n,ee,f),b(K,n,f),s(n,F,f),s(n,ht,f),s(n,at,f),s(n,wt,f),s(n,Qt,f),s(n,x,f),s(n,mt,f),s(n,ct,f),c(ct,W),c(W,xt),b(dt,xt,null),c(ct,vt),c(ct,kt),s(n,Rt,f),b(D,n,f),s(n,O,f),s(n,_t,f),s(n,tt,f),s(n,ft,f),s(n,et,f),b(N,n,f),s(n,R,f),s(n,I,f),s(n,nt,f),b(bt,n,f),s(n,Xt,f),s(n,ut,f),s(n,S,f),b(rt,n,f),s(n,jt,f),s(n,L,f),s(n,Et,f),s(n,st,f),c(st,pt),c(pt,Mt),b(X,Mt,null),c(st,Tt),c(st,E),s(n,Ft,f),s(n,G,f),s(n,ot,f),b(U,n,f),s(n,Nt,f),s(n,Y,f),s(n,Bt,f),s(n,Q,f),c(Q,A),c(A,St),b(B,St,null),c(Q,Pt),c(Q,Zt),s(n,le,f),b(q,n,f),s(n,yt,f),s(n,Ut,f),s(n,a,f),s(n,d,f),c(d,l),c(l,y),b(gt,y,null),c(d,Vt),c(d,$t),s(n,Lt,f),s(n,zt,f),s(n,ie,f),s(n,qt,f),s(n,he,f),s(n,me,f),pe=!0},p(n,[f]){const Ot={};f&2&&(Ot.$$scope={dirty:f,ctx:n}),U.$set(Ot);const oe={};f&2&&(oe.$$scope={dirty:f,ctx:n}),q.$set(oe)},i(n){pe||(j(z.$$.fragment,n),j(K.$$.fragment,n),j(dt.$$.fragment,n),j(D.$$.fragment,n),j(N.$$.fragment,n),j(bt.$$.fragment,n),j(rt.$$.fragment,n),j(X.$$.fragment,n),j(U.$$.fragment,n),j(B.$$.fragment,n),j(q.$$.fragment,n),j(gt.$$.fragment,n),pe=!0)},o(n){T(z.$$.fragment,n),T(K.$$.fragment,n),T(dt.$$.fragment,n),T(D.$$.fragment,n),T(N.$$.fragment,n),T(bt.$$.fragment,n),T(rt.$$.fragment,n),T(X.$$.fragment,n),T(U.$$.fragment,n),T(B.$$.fragment,n),T(q.$$.fragment,n),T(gt.$$.fragment,n),pe=!1},d(n){n&&(t(k),t(h),t(_),t(C),t(ee),t(F),t(ht),t(at),t(wt),t(Qt),t(x),t(mt),t(ct),t(Rt),t(O),t(_t),t(tt),t(ft),t(et),t(R),t(I),t(nt),t(Xt),t(ut),t(S),t(jt),t(L),t(Et),t(st),t(Ft),t(G),t(ot),t(Nt),t(Y),t(Bt),t(Q),t(le),t(yt),t(Ut),t(a),t(d),t(Lt),t(zt),t(ie),t(qt),t(he),t(me)),t(m),J(z),J(K,n),J(dt),J(D,n),J(N,n),J(bt,n),J(rt,n),J(X),J(U,n),J(B),J(q,n),J(gt)}}}const as={local:"finetune-a-pretrained-model",sections:[{local:"prepare-a-dataset",title:"데이터셋 준비"},{local:"train",title:"Train"},{local:"train-with-pytorch-trainer",sections:[{local:"training-hyperparameters",title:"하이퍼파라미터 훈련"},{local:"evaluate",title:"평가 하기"},{local:"trainer",title:"훈련 하기"}],title:"파이토치 Trainer로 훈련하기"},{local:"train-a-tensorflow-model-with-keras",sections:[{local:"loading-data-for-keras",title:"Keras용 데이터 로드"},{local:"loading-data-as-a-tfdatadataset",title:"데이터를 tf.data.Dataset으로 로드하기"}],title:"Keras로 텐서플로우 모델 훈련하기"},{local:"train-in-native-pytorch",sections:[{local:"dataloader",title:"DataLoader"},{local:"optimizer-and-learning-rate-scheduler",title:"옵티마이저 및 학습 속도 스케줄러"},{local:"training-loop",title:"훈련 루프"},{local:"evaluate",title:"평가 하기"}],title:"기본 파이토치로 훈련하기"},{local:"additional-resources",title:"추가 자료"}],title:"사전 학습된 모델 미세 튜닝하기"};function ns(Wt){return Ae(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class fs extends Fe{constructor(m){super(),Ne(this,m,ns,ls,Ye,{})}}export{fs as component};
