import{s as Wt,o as Vt,n as cs}from"../chunks/scheduler.889ebb13.js";import{S as Xt,i as Bt,g as d,s as r,u as M,A as Et,h as f,f as e,c as o,j as Y,v as y,y as T,k as X,o as B,a as l,w as j,d as b,t as $,x as w,m as Rt,n as It}from"../chunks/index.8980e686.js";import{T as Ke}from"../chunks/Tip.7191df11.js";import{Y as Gt}from"../chunks/Youtube.532e53e0.js";import{I as ie}from"../chunks/IconCopyLink.357761cd.js";import{C as Z}from"../chunks/CodeBlock.25fc3430.js";import{D as zt}from"../chunks/DocNotebookDropdown.f8a50280.js";import{F as lt,M as se}from"../chunks/Markdown.31057263.js";function Ft(U){let t,c,a="다음 아키텍쳐 중 하나를 선택하세요:",m,u,g='<a href="../model_doc/albert">ALBERT</a>, <a href="../model_doc/bart">BART</a>, <a href="../model_doc/bert">BERT</a>, <a href="../model_doc/big_bird">BigBird</a>, <a href="../model_doc/camembert">CamemBERT</a>, <a href="../model_doc/convbert">ConvBERT</a>, <a href="../model_doc/data2vec-text">Data2VecText</a>, <a href="../model_doc/deberta">DeBERTa</a>, <a href="../model_doc/deberta-v2">DeBERTa-v2</a>, <a href="../model_doc/distilbert">DistilBERT</a>, <a href="../model_doc/electra">ELECTRA</a>, <a href="../model_doc/ernie">ERNIE</a>, <a href="../model_doc/esm">ESM</a>, <a href="../model_doc/flaubert">FlauBERT</a>, <a href="../model_doc/fnet">FNet</a>, <a href="../model_doc/funnel">Funnel Transformer</a>, <a href="../model_doc/ibert">I-BERT</a>, <a href="../model_doc/layoutlm">LayoutLM</a>, <a href="../model_doc/longformer">Longformer</a>, <a href="../model_doc/luke">LUKE</a>, <a href="../model_doc/mbart">mBART</a>, <a href="../model_doc/mega">MEGA</a>, <a href="../model_doc/megatron-bert">Megatron-BERT</a>, <a href="../model_doc/mobilebert">MobileBERT</a>, <a href="../model_doc/mpnet">MPNet</a>, <a href="../model_doc/mvp">MVP</a>, <a href="../model_doc/nezha">Nezha</a>, <a href="../model_doc/nystromformer">Nyströmformer</a>, <a href="../model_doc/perceiver">Perceiver</a>, <a href="../model_doc/qdqbert">QDQBert</a>, <a href="../model_doc/reformer">Reformer</a>, <a href="../model_doc/rembert">RemBERT</a>, <a href="../model_doc/roberta">RoBERTa</a>, <a href="../model_doc/roberta-prelayernorm">RoBERTa-PreLayerNorm</a>, <a href="../model_doc/roc_bert">RoCBert</a>, <a href="../model_doc/roformer">RoFormer</a>, <a href="../model_doc/squeezebert">SqueezeBERT</a>, <a href="../model_doc/tapas">TAPAS</a>, <a href="../model_doc/wav2vec2">Wav2Vec2</a>, <a href="../model_doc/xlm">XLM</a>, <a href="../model_doc/xlm-roberta">XLM-RoBERTa</a>, <a href="../model_doc/xlm-roberta-xl">XLM-RoBERTa-XL</a>, <a href="../model_doc/xmod">X-MOD</a>, <a href="../model_doc/yoso">YOSO</a>';return{c(){t=Rt(`이번 가이드에서처럼 다른 아키텍처를 미세 조정해 마스킹된 언어 모델링을 할 수 있습니다.
`),c=d("p"),c.textContent=a,m=r(),u=d("p"),u.innerHTML=g},l(_){t=It(_,`이번 가이드에서처럼 다른 아키텍처를 미세 조정해 마스킹된 언어 모델링을 할 수 있습니다.
`),c=f(_,"P",{"data-svelte-h":!0}),T(c)!=="svelte-1envvxx"&&(c.textContent=a),m=o(_),u=f(_,"P",{"data-svelte-h":!0}),T(u)!=="svelte-cb0kyv"&&(u.innerHTML=g)},m(_,J){l(_,t,J),l(_,c,J),l(_,m,J),l(_,u,J)},p:cs,d(_){_&&(e(t),e(c),e(m),e(u))}}}function Ht(U){let t,c="시퀀스 끝 토큰을 패딩 토큰으로 사용하고 데이터를 반복할 때마다 토큰을 무작위로 마스킹하도록 <code>mlm_-probability</code>를 지정합니다:",a,m,u;return m=new Z({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMERhdGFDb2xsYXRvckZvckxhbmd1YWdlTW9kZWxpbmclMEElMEF0b2tlbml6ZXIucGFkX3Rva2VuJTIwJTNEJTIwdG9rZW5pemVyLmVvc190b2tlbiUwQWRhdGFfY29sbGF0b3IlMjAlM0QlMjBEYXRhQ29sbGF0b3JGb3JMYW5ndWFnZU1vZGVsaW5nKHRva2VuaXplciUzRHRva2VuaXplciUyQyUyMG1sbV9wcm9iYWJpbGl0eSUzRDAuMTUp",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> DataCollatorForLanguageModeling

<span class="hljs-meta">&gt;&gt;&gt; </span>tokenizer.pad_token = tokenizer.eos_token
<span class="hljs-meta">&gt;&gt;&gt; </span>data_collator = DataCollatorForLanguageModeling(tokenizer=tokenizer, mlm_probability=<span class="hljs-number">0.15</span>)`}}),{c(){t=d("p"),t.innerHTML=c,a=r(),M(m.$$.fragment)},l(g){t=f(g,"P",{"data-svelte-h":!0}),T(t)!=="svelte-5j66ud"&&(t.innerHTML=c),a=o(g),y(m.$$.fragment,g)},m(g,_){l(g,t,_),l(g,a,_),j(m,g,_),u=!0},p:cs,i(g){u||(b(m.$$.fragment,g),u=!0)},o(g){$(m.$$.fragment,g),u=!1},d(g){g&&(e(t),e(a)),w(m,g)}}}function Nt(U){let t,c;return t=new se({props:{$$slots:{default:[Ht]},$$scope:{ctx:U}}}),{c(){M(t.$$.fragment)},l(a){y(t.$$.fragment,a)},m(a,m){j(t,a,m),c=!0},p(a,m){const u={};m&2&&(u.$$scope={dirty:m,ctx:a}),t.$set(u)},i(a){c||(b(t.$$.fragment,a),c=!0)},o(a){$(t.$$.fragment,a),c=!1},d(a){w(t,a)}}}function At(U){let t,c="시퀀스 끝 토큰을 패딩 토큰으로 사용하고 데이터를 반복할 때마다 토큰을 무작위로 마스킹하도록 <code>mlm_-probability</code>를 지정합니다:",a,m,u;return m=new Z({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMERhdGFDb2xsYXRvckZvckxhbmd1YWdlTW9kZWxpbmclMEElMEFkYXRhX2NvbGxhdG9yJTIwJTNEJTIwRGF0YUNvbGxhdG9yRm9yTGFuZ3VhZ2VNb2RlbGluZyh0b2tlbml6ZXIlM0R0b2tlbml6ZXIlMkMlMjBtbG1fcHJvYmFiaWxpdHklM0QwLjE1JTJDJTIwcmV0dXJuX3RlbnNvcnMlM0QlMjJ0ZiUyMik=",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> DataCollatorForLanguageModeling

<span class="hljs-meta">&gt;&gt;&gt; </span>data_collator = DataCollatorForLanguageModeling(tokenizer=tokenizer, mlm_probability=<span class="hljs-number">0.15</span>, return_tensors=<span class="hljs-string">&quot;tf&quot;</span>)`}}),{c(){t=d("p"),t.innerHTML=c,a=r(),M(m.$$.fragment)},l(g){t=f(g,"P",{"data-svelte-h":!0}),T(t)!=="svelte-5j66ud"&&(t.innerHTML=c),a=o(g),y(m.$$.fragment,g)},m(g,_){l(g,t,_),l(g,a,_),j(m,g,_),u=!0},p:cs,i(g){u||(b(m.$$.fragment,g),u=!0)},o(g){$(m.$$.fragment,g),u=!1},d(g){g&&(e(t),e(a)),w(m,g)}}}function Yt(U){let t,c;return t=new se({props:{$$slots:{default:[At]},$$scope:{ctx:U}}}),{c(){M(t.$$.fragment)},l(a){y(t.$$.fragment,a)},m(a,m){j(t,a,m),c=!0},p(a,m){const u={};m&2&&(u.$$scope={dirty:m,ctx:a}),t.$set(u)},i(a){c||(b(t.$$.fragment,a),c=!0)},o(a){$(t.$$.fragment,a),c=!1},d(a){w(t,a)}}}function Qt(U){let t,c='<code>Trainer</code>로 모델을 미세 조정하는 데 익숙하지 않다면 기본 튜토리얼 <a href="../training#train-with-pytorch-trainer">여기</a>를 살펴보세요!';return{c(){t=d("p"),t.innerHTML=c},l(a){t=f(a,"P",{"data-svelte-h":!0}),T(t)!=="svelte-mnr18a"&&(t.innerHTML=c)},m(a,m){l(a,t,m)},p:cs,d(a){a&&e(t)}}}function Lt(U){let t,c,a,m="이제 모델 훈련을 시작할 준비가 되었습니다! <code>AutoModelForMaskedLM</code>를 사용해 DistilRoBERTa 모델을 가져옵니다:",u,g,_,J,V="이제 세 단계가 남았습니다:",I,W,F="<li><code>TrainingArguments</code>의 훈련 하이퍼파라미터를 정의합니다. 모델 저장 위치를 지정하는 <code>output_dir</code>은 유일한 필수 파라미터입니다. <code>push_to_hub=True</code>를 설정하여 이 모델을 Hub에 업로드합니다 (모델을 업로드하려면 Hugging Face에 로그인해야 합니다).</li> <li>모델, 데이터 세트 및 데이터 콜레이터(collator)와 함께 훈련 인수를 <code>Trainer</code>에 전달합니다.</li> <li><code>train()</code>을 호출하여 모델을 미세 조정합니다.</li>",G,x,R,p,k="훈련이 완료되면 <code>evaluate()</code> 메소드를 사용하여 펄플렉서티(perplexity)를 계산하고 모델을 평가합니다:",Q,N,E,q,S="그리고 <code>push_to_hub()</code> 메소드를 사용해 다른 사람들이 사용할 수 있도록, Hub로 모델을 업로드합니다.",z,L,A;return t=new Ke({props:{$$slots:{default:[Qt]},$$scope:{ctx:U}}}),g=new Z({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMEF1dG9Nb2RlbEZvck1hc2tlZExNJTBBJTBBbW9kZWwlMjAlM0QlMjBBdXRvTW9kZWxGb3JNYXNrZWRMTS5mcm9tX3ByZXRyYWluZWQoJTIyZGlzdGlscm9iZXJ0YS1iYXNlJTIyKQ==",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoModelForMaskedLM

<span class="hljs-meta">&gt;&gt;&gt; </span>model = AutoModelForMaskedLM.from_pretrained(<span class="hljs-string">&quot;distilroberta-base&quot;</span>)`}}),x=new Z({props:{code:"dHJhaW5pbmdfYXJncyUyMCUzRCUyMFRyYWluaW5nQXJndW1lbnRzKCUwQSUyMCUyMCUyMCUyMG91dHB1dF9kaXIlM0QlMjJteV9hd2Vzb21lX2VsaTVfbWxtX21vZGVsJTIyJTJDJTBBJTIwJTIwJTIwJTIwZXZhbHVhdGlvbl9zdHJhdGVneSUzRCUyMmVwb2NoJTIyJTJDJTBBJTIwJTIwJTIwJTIwbGVhcm5pbmdfcmF0ZSUzRDJlLTUlMkMlMEElMjAlMjAlMjAlMjBudW1fdHJhaW5fZXBvY2hzJTNEMyUyQyUwQSUyMCUyMCUyMCUyMHdlaWdodF9kZWNheSUzRDAuMDElMkMlMEElMjAlMjAlMjAlMjBwdXNoX3RvX2h1YiUzRFRydWUlMkMlMEEpJTBBJTBBdHJhaW5lciUyMCUzRCUyMFRyYWluZXIoJTBBJTIwJTIwJTIwJTIwbW9kZWwlM0Rtb2RlbCUyQyUwQSUyMCUyMCUyMCUyMGFyZ3MlM0R0cmFpbmluZ19hcmdzJTJDJTBBJTIwJTIwJTIwJTIwdHJhaW5fZGF0YXNldCUzRGxtX2RhdGFzZXQlNUIlMjJ0cmFpbiUyMiU1RCUyQyUwQSUyMCUyMCUyMCUyMGV2YWxfZGF0YXNldCUzRGxtX2RhdGFzZXQlNUIlMjJ0ZXN0JTIyJTVEJTJDJTBBJTIwJTIwJTIwJTIwZGF0YV9jb2xsYXRvciUzRGRhdGFfY29sbGF0b3IlMkMlMEEpJTBBJTBBdHJhaW5lci50cmFpbigp",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span>training_args = TrainingArguments(
<span class="hljs-meta">... </span>    output_dir=<span class="hljs-string">&quot;my_awesome_eli5_mlm_model&quot;</span>,
<span class="hljs-meta">... </span>    evaluation_strategy=<span class="hljs-string">&quot;epoch&quot;</span>,
<span class="hljs-meta">... </span>    learning_rate=<span class="hljs-number">2e-5</span>,
<span class="hljs-meta">... </span>    num_train_epochs=<span class="hljs-number">3</span>,
<span class="hljs-meta">... </span>    weight_decay=<span class="hljs-number">0.01</span>,
<span class="hljs-meta">... </span>    push_to_hub=<span class="hljs-literal">True</span>,
<span class="hljs-meta">... </span>)

<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=lm_dataset[<span class="hljs-string">&quot;train&quot;</span>],
<span class="hljs-meta">... </span>    eval_dataset=lm_dataset[<span class="hljs-string">&quot;test&quot;</span>],
<span class="hljs-meta">... </span>    data_collator=data_collator,
<span class="hljs-meta">... </span>)

<span class="hljs-meta">&gt;&gt;&gt; </span>trainer.train()`}}),N=new Z({props:{code:"aW1wb3J0JTIwbWF0aCUwQSUwQWV2YWxfcmVzdWx0cyUyMCUzRCUyMHRyYWluZXIuZXZhbHVhdGUoKSUwQXByaW50KGYlMjJQZXJwbGV4aXR5JTNBJTIwJTdCbWF0aC5leHAoZXZhbF9yZXN1bHRzJTVCJ2V2YWxfbG9zcyclNUQpJTNBLjJmJTdEJTIyKQ==",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">import</span> math

<span class="hljs-meta">&gt;&gt;&gt; </span>eval_results = trainer.evaluate()
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-built_in">print</span>(<span class="hljs-string">f&quot;Perplexity: <span class="hljs-subst">{math.exp(eval_results[<span class="hljs-string">&#x27;eval_loss&#x27;</span>]):<span class="hljs-number">.2</span>f}</span>&quot;</span>)
Perplexity: <span class="hljs-number">8.76</span>`}}),L=new Z({props:{code:"dHJhaW5lci5wdXNoX3RvX2h1Yigp",highlighted:'<span class="hljs-meta">&gt;&gt;&gt; </span>trainer.push_to_hub()'}}),{c(){M(t.$$.fragment),c=r(),a=d("p"),a.innerHTML=m,u=r(),M(g.$$.fragment),_=r(),J=d("p"),J.textContent=V,I=r(),W=d("ol"),W.innerHTML=F,G=r(),M(x.$$.fragment),R=r(),p=d("p"),p.innerHTML=k,Q=r(),M(N.$$.fragment),E=r(),q=d("p"),q.innerHTML=S,z=r(),M(L.$$.fragment)},l(h){y(t.$$.fragment,h),c=o(h),a=f(h,"P",{"data-svelte-h":!0}),T(a)!=="svelte-j58c41"&&(a.innerHTML=m),u=o(h),y(g.$$.fragment,h),_=o(h),J=f(h,"P",{"data-svelte-h":!0}),T(J)!=="svelte-adwu43"&&(J.textContent=V),I=o(h),W=f(h,"OL",{"data-svelte-h":!0}),T(W)!=="svelte-1qz54pn"&&(W.innerHTML=F),G=o(h),y(x.$$.fragment,h),R=o(h),p=f(h,"P",{"data-svelte-h":!0}),T(p)!=="svelte-d2qmt2"&&(p.innerHTML=k),Q=o(h),y(N.$$.fragment,h),E=o(h),q=f(h,"P",{"data-svelte-h":!0}),T(q)!=="svelte-1sgaay4"&&(q.innerHTML=S),z=o(h),y(L.$$.fragment,h)},m(h,v){j(t,h,v),l(h,c,v),l(h,a,v),l(h,u,v),j(g,h,v),l(h,_,v),l(h,J,v),l(h,I,v),l(h,W,v),l(h,G,v),j(x,h,v),l(h,R,v),l(h,p,v),l(h,Q,v),j(N,h,v),l(h,E,v),l(h,q,v),l(h,z,v),j(L,h,v),A=!0},p(h,v){const H={};v&2&&(H.$$scope={dirty:v,ctx:h}),t.$set(H)},i(h){A||(b(t.$$.fragment,h),b(g.$$.fragment,h),b(x.$$.fragment,h),b(N.$$.fragment,h),b(L.$$.fragment,h),A=!0)},o(h){$(t.$$.fragment,h),$(g.$$.fragment,h),$(x.$$.fragment,h),$(N.$$.fragment,h),$(L.$$.fragment,h),A=!1},d(h){h&&(e(c),e(a),e(u),e(_),e(J),e(I),e(W),e(G),e(R),e(p),e(Q),e(E),e(q),e(z)),w(t,h),w(g,h),w(x,h),w(N,h),w(L,h)}}}function qt(U){let t,c;return t=new se({props:{$$slots:{default:[Lt]},$$scope:{ctx:U}}}),{c(){M(t.$$.fragment)},l(a){y(t.$$.fragment,a)},m(a,m){j(t,a,m),c=!0},p(a,m){const u={};m&2&&(u.$$scope={dirty:m,ctx:a}),t.$set(u)},i(a){c||(b(t.$$.fragment,a),c=!0)},o(a){$(t.$$.fragment,a),c=!1},d(a){w(t,a)}}}function St(U){let t,c='Keras로 모델을 미세 조정하는 데 익숙하지 않다면 기본 튜토리얼 <a href="../training#train-a-tensorflow-model-with-keras">여기</a>를 살펴보세요!';return{c(){t=d("p"),t.innerHTML=c},l(a){t=f(a,"P",{"data-svelte-h":!0}),T(t)!=="svelte-2dbfdz"&&(t.innerHTML=c)},m(a,m){l(a,t,m)},p:cs,d(a){a&&e(t)}}}function Pt(U){let t,c,a,m,u,g="다음으로 <code>TFAutoModelForMaskedLM</code>를 사용해 DistilRoBERTa 모델을 가져옵니다:",_,J,V,I,W="<code>prepare_tf_dataset()</code> 메소드를 사용해 데이터 세트를 <code>tf.data.Dataset</code> 형식으로 변환하세요:",F,G,x,R,p='<a href="https://keras.io/api/models/model_training_apis/#compile-method" rel="nofollow"><code>compile</code></a> 메소드를 통해 모델 훈련을 구성합니다:',k,Q,N,E,q="이는 업로드할 모델과 토크나이저의 위치를 <code>PushToHubCallback</code>에 지정하여 수행할 수 있습니다:",S,z,L,A,h=`드디어 모델을 훈련할 준비가 되었습니다!
모델을 미세 조정할 때 훈련 및 검증 데이터 세트, 에포크 수, 콜백이 포함된 <a href="https://keras.io/api/models/model_training_apis/#fit-method" rel="nofollow"><code>fit</code></a>을 호출합니다:`,v,H,hs,P,D="훈련이 완료되면, 자동으로 Hub로 업로드되어 누구나 사용할 수 있습니다!",K;return t=new Ke({props:{$$slots:{default:[St]},$$scope:{ctx:U}}}),a=new Z({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMGNyZWF0ZV9vcHRpbWl6ZXIlMkMlMjBBZGFtV2VpZ2h0RGVjYXklMEElMEFvcHRpbWl6ZXIlMjAlM0QlMjBBZGFtV2VpZ2h0RGVjYXkobGVhcm5pbmdfcmF0ZSUzRDJlLTUlMkMlMjB3ZWlnaHRfZGVjYXlfcmF0ZSUzRDAuMDEp",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> create_optimizer, AdamWeightDecay

<span class="hljs-meta">&gt;&gt;&gt; </span>optimizer = AdamWeightDecay(learning_rate=<span class="hljs-number">2e-5</span>, weight_decay_rate=<span class="hljs-number">0.01</span>)`}}),J=new Z({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMFRGQXV0b01vZGVsRm9yTWFza2VkTE0lMEElMEFtb2RlbCUyMCUzRCUyMFRGQXV0b01vZGVsRm9yTWFza2VkTE0uZnJvbV9wcmV0cmFpbmVkKCUyMmRpc3RpbHJvYmVydGEtYmFzZSUyMik=",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> TFAutoModelForMaskedLM

<span class="hljs-meta">&gt;&gt;&gt; </span>model = TFAutoModelForMaskedLM.from_pretrained(<span class="hljs-string">&quot;distilroberta-base&quot;</span>)`}}),G=new Z({props:{code:"dGZfdHJhaW5fc2V0JTIwJTNEJTIwbW9kZWwucHJlcGFyZV90Zl9kYXRhc2V0KCUwQSUyMCUyMCUyMCUyMGxtX2RhdGFzZXQlNUIlMjJ0cmFpbiUyMiU1RCUyQyUwQSUyMCUyMCUyMCUyMHNodWZmbGUlM0RUcnVlJTJDJTBBJTIwJTIwJTIwJTIwYmF0Y2hfc2l6ZSUzRDE2JTJDJTBBJTIwJTIwJTIwJTIwY29sbGF0ZV9mbiUzRGRhdGFfY29sbGF0b3IlMkMlMEEpJTBBJTBBdGZfdGVzdF9zZXQlMjAlM0QlMjBtb2RlbC5wcmVwYXJlX3RmX2RhdGFzZXQoJTBBJTIwJTIwJTIwJTIwbG1fZGF0YXNldCU1QiUyMnRlc3QlMjIlNUQlMkMlMEElMjAlMjAlMjAlMjBzaHVmZmxlJTNERmFsc2UlMkMlMEElMjAlMjAlMjAlMjBiYXRjaF9zaXplJTNEMTYlMkMlMEElMjAlMjAlMjAlMjBjb2xsYXRlX2ZuJTNEZGF0YV9jb2xsYXRvciUyQyUwQSk=",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span>tf_train_set = model.prepare_tf_dataset(
<span class="hljs-meta">... </span>    lm_dataset[<span class="hljs-string">&quot;train&quot;</span>],
<span class="hljs-meta">... </span>    shuffle=<span class="hljs-literal">True</span>,
<span class="hljs-meta">... </span>    batch_size=<span class="hljs-number">16</span>,
<span class="hljs-meta">... </span>    collate_fn=data_collator,
<span class="hljs-meta">... </span>)

<span class="hljs-meta">&gt;&gt;&gt; </span>tf_test_set = model.prepare_tf_dataset(
<span class="hljs-meta">... </span>    lm_dataset[<span class="hljs-string">&quot;test&quot;</span>],
<span class="hljs-meta">... </span>    shuffle=<span class="hljs-literal">False</span>,
<span class="hljs-meta">... </span>    batch_size=<span class="hljs-number">16</span>,
<span class="hljs-meta">... </span>    collate_fn=data_collator,
<span class="hljs-meta">... </span>)`}}),Q=new Z({props:{code:"aW1wb3J0JTIwdGVuc29yZmxvdyUyMGFzJTIwdGYlMEElMEFtb2RlbC5jb21waWxlKG9wdGltaXplciUzRG9wdGltaXplcik=",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">import</span> tensorflow <span class="hljs-keyword">as</span> tf

<span class="hljs-meta">&gt;&gt;&gt; </span>model.<span class="hljs-built_in">compile</span>(optimizer=optimizer)`}}),z=new Z({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycy5rZXJhc19jYWxsYmFja3MlMjBpbXBvcnQlMjBQdXNoVG9IdWJDYWxsYmFjayUwQSUwQWNhbGxiYWNrJTIwJTNEJTIwUHVzaFRvSHViQ2FsbGJhY2soJTBBJTIwJTIwJTIwJTIwb3V0cHV0X2RpciUzRCUyMm15X2F3ZXNvbWVfZWxpNV9tbG1fbW9kZWwlMjIlMkMlMEElMjAlMjAlMjAlMjB0b2tlbml6ZXIlM0R0b2tlbml6ZXIlMkMlMEEp",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers.keras_callbacks <span class="hljs-keyword">import</span> PushToHubCallback

<span class="hljs-meta">&gt;&gt;&gt; </span>callback = PushToHubCallback(
<span class="hljs-meta">... </span>    output_dir=<span class="hljs-string">&quot;my_awesome_eli5_mlm_model&quot;</span>,
<span class="hljs-meta">... </span>    tokenizer=tokenizer,
<span class="hljs-meta">... </span>)`}}),H=new Z({props:{code:"bW9kZWwuZml0KHglM0R0Zl90cmFpbl9zZXQlMkMlMjB2YWxpZGF0aW9uX2RhdGElM0R0Zl90ZXN0X3NldCUyQyUyMGVwb2NocyUzRDMlMkMlMjBjYWxsYmFja3MlM0QlNUJjYWxsYmFjayU1RCk=",highlighted:'<span class="hljs-meta">&gt;&gt;&gt; </span>model.fit(x=tf_train_set, validation_data=tf_test_set, epochs=<span class="hljs-number">3</span>, callbacks=[callback])'}}),{c(){M(t.$$.fragment),c=Rt(`
TensorFlow로 모델을 미세 조정하기 위해서는 옵티마이저(optimizer) 함수 설정, 학습률(learning rate) 스케쥴링, 훈련 하이퍼파라미터 설정부터 시작하세요:

	`),M(a.$$.fragment),m=r(),u=d("p"),u.innerHTML=g,_=r(),M(J.$$.fragment),V=r(),I=d("p"),I.innerHTML=W,F=r(),M(G.$$.fragment),x=r(),R=d("p"),R.innerHTML=p,k=r(),M(Q.$$.fragment),N=r(),E=d("p"),E.innerHTML=q,S=r(),M(z.$$.fragment),L=r(),A=d("p"),A.innerHTML=h,v=r(),M(H.$$.fragment),hs=r(),P=d("p"),P.textContent=D},l(i){y(t.$$.fragment,i),c=It(i,`
TensorFlow로 모델을 미세 조정하기 위해서는 옵티마이저(optimizer) 함수 설정, 학습률(learning rate) 스케쥴링, 훈련 하이퍼파라미터 설정부터 시작하세요:

	`),y(a.$$.fragment,i),m=o(i),u=f(i,"P",{"data-svelte-h":!0}),T(u)!=="svelte-gg210g"&&(u.innerHTML=g),_=o(i),y(J.$$.fragment,i),V=o(i),I=f(i,"P",{"data-svelte-h":!0}),T(I)!=="svelte-s4fgj9"&&(I.innerHTML=W),F=o(i),y(G.$$.fragment,i),x=o(i),R=f(i,"P",{"data-svelte-h":!0}),T(R)!=="svelte-1nhrjql"&&(R.innerHTML=p),k=o(i),y(Q.$$.fragment,i),N=o(i),E=f(i,"P",{"data-svelte-h":!0}),T(E)!=="svelte-5310au"&&(E.innerHTML=q),S=o(i),y(z.$$.fragment,i),L=o(i),A=f(i,"P",{"data-svelte-h":!0}),T(A)!=="svelte-3mv0xn"&&(A.innerHTML=h),v=o(i),y(H.$$.fragment,i),hs=o(i),P=f(i,"P",{"data-svelte-h":!0}),T(P)!=="svelte-1v3ov90"&&(P.textContent=D)},m(i,C){j(t,i,C),l(i,c,C),j(a,i,C),l(i,m,C),l(i,u,C),l(i,_,C),j(J,i,C),l(i,V,C),l(i,I,C),l(i,F,C),j(G,i,C),l(i,x,C),l(i,R,C),l(i,k,C),j(Q,i,C),l(i,N,C),l(i,E,C),l(i,S,C),j(z,i,C),l(i,L,C),l(i,A,C),l(i,v,C),j(H,i,C),l(i,hs,C),l(i,P,C),K=!0},p(i,C){const ds={};C&2&&(ds.$$scope={dirty:C,ctx:i}),t.$set(ds)},i(i){K||(b(t.$$.fragment,i),b(a.$$.fragment,i),b(J.$$.fragment,i),b(G.$$.fragment,i),b(Q.$$.fragment,i),b(z.$$.fragment,i),b(H.$$.fragment,i),K=!0)},o(i){$(t.$$.fragment,i),$(a.$$.fragment,i),$(J.$$.fragment,i),$(G.$$.fragment,i),$(Q.$$.fragment,i),$(z.$$.fragment,i),$(H.$$.fragment,i),K=!1},d(i){i&&(e(c),e(m),e(u),e(_),e(V),e(I),e(F),e(x),e(R),e(k),e(N),e(E),e(S),e(L),e(A),e(v),e(hs),e(P)),w(t,i),w(a,i),w(J,i),w(G,i),w(Q,i),w(z,i),w(H,i)}}}function Dt(U){let t,c;return t=new se({props:{$$slots:{default:[Pt]},$$scope:{ctx:U}}}),{c(){M(t.$$.fragment)},l(a){y(t.$$.fragment,a)},m(a,m){j(t,a,m),c=!0},p(a,m){const u={};m&2&&(u.$$scope={dirty:m,ctx:a}),t.$set(u)},i(a){c||(b(t.$$.fragment,a),c=!0)},o(a){$(t.$$.fragment,a),c=!1},d(a){w(t,a)}}}function Kt(U){let t,c=`마스킹된 언어 모델링을 위해 모델을 미세 조정하는 방법에 대한 보다 심층적인 예제는
<a href="https://colab.research.google.com/github/huggingface/notebooks/blob/main/examples/language_modeling.ipynb" rel="nofollow">PyTorch notebook</a>
또는 <a href="https://colab.research.google.com/github/huggingface/notebooks/blob/main/examples/language_modeling-tf.ipynb" rel="nofollow">TensorFlow notebook</a>을 참조하세요.`;return{c(){t=d("p"),t.innerHTML=c},l(a){t=f(a,"P",{"data-svelte-h":!0}),T(t)!=="svelte-rnza4"&&(t.innerHTML=c)},m(a,m){l(a,t,m)},p:cs,d(a){a&&e(t)}}}function Ot(U){let t,c=`텍스트를 토큰화하고 <code>input_ids</code>를 PyTorch 텐서 형태로 반환합니다.
또한, <code>&lt;mask&gt;</code> 토큰의 위치를 지정해야 합니다:`,a,m,u,g,_="모델에 <code>inputs</code>를 입력하고, 마스킹된 토큰의 <code>logits</code>를 반환합니다:",J,V,I,W,F="그런 다음 가장 높은 확률은 가진 마스크 토큰 3개를 반환하고, 출력합니다:",G,x,R;return m=new Z({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMEF1dG9Ub2tlbml6ZXIlMEElMEF0b2tlbml6ZXIlMjAlM0QlMjBBdXRvVG9rZW5pemVyLmZyb21fcHJldHJhaW5lZCglMjJteV9hd2Vzb21lX2VsaTVfbWxtX21vZGVsJTIyKSUwQWlucHV0cyUyMCUzRCUyMHRva2VuaXplcih0ZXh0JTJDJTIwcmV0dXJuX3RlbnNvcnMlM0QlMjJwdCUyMiklMEFtYXNrX3Rva2VuX2luZGV4JTIwJTNEJTIwdG9yY2gud2hlcmUoaW5wdXRzJTVCJTIyaW5wdXRfaWRzJTIyJTVEJTIwJTNEJTNEJTIwdG9rZW5pemVyLm1hc2tfdG9rZW5faWQpJTVCMSU1RA==",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;my_awesome_eli5_mlm_model&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>inputs = tokenizer(text, return_tensors=<span class="hljs-string">&quot;pt&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>mask_token_index = torch.where(inputs[<span class="hljs-string">&quot;input_ids&quot;</span>] == tokenizer.mask_token_id)[<span class="hljs-number">1</span>]`}}),V=new Z({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMEF1dG9Nb2RlbEZvck1hc2tlZExNJTBBJTBBbW9kZWwlMjAlM0QlMjBBdXRvTW9kZWxGb3JNYXNrZWRMTS5mcm9tX3ByZXRyYWluZWQoJTIyc3RldmhsaXUlMkZteV9hd2Vzb21lX2VsaTVfbWxtX21vZGVsJTIyKSUwQWxvZ2l0cyUyMCUzRCUyMG1vZGVsKCoqaW5wdXRzKS5sb2dpdHMlMEFtYXNrX3Rva2VuX2xvZ2l0cyUyMCUzRCUyMGxvZ2l0cyU1QjAlMkMlMjBtYXNrX3Rva2VuX2luZGV4JTJDJTIwJTNBJTVE",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoModelForMaskedLM

<span class="hljs-meta">&gt;&gt;&gt; </span>model = AutoModelForMaskedLM.from_pretrained(<span class="hljs-string">&quot;stevhliu/my_awesome_eli5_mlm_model&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>logits = model(**inputs).logits
<span class="hljs-meta">&gt;&gt;&gt; </span>mask_token_logits = logits[<span class="hljs-number">0</span>, mask_token_index, :]`}}),x=new Z({props:{code:"dG9wXzNfdG9rZW5zJTIwJTNEJTIwdG9yY2gudG9wayhtYXNrX3Rva2VuX2xvZ2l0cyUyQyUyMDMlMkMlMjBkaW0lM0QxKS5pbmRpY2VzJTVCMCU1RC50b2xpc3QoKSUwQSUwQWZvciUyMHRva2VuJTIwaW4lMjB0b3BfM190b2tlbnMlM0ElMEElMjAlMjAlMjAlMjBwcmludCh0ZXh0LnJlcGxhY2UodG9rZW5pemVyLm1hc2tfdG9rZW4lMkMlMjB0b2tlbml6ZXIuZGVjb2RlKCU1QnRva2VuJTVEKSkp",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span>top_3_tokens = torch.topk(mask_token_logits, <span class="hljs-number">3</span>, dim=<span class="hljs-number">1</span>).indices[<span class="hljs-number">0</span>].tolist()

<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">for</span> token <span class="hljs-keyword">in</span> top_3_tokens:
<span class="hljs-meta">... </span>    <span class="hljs-built_in">print</span>(text.replace(tokenizer.mask_token, tokenizer.decode([token])))
The Milky Way <span class="hljs-keyword">is</span> a spiral galaxy.
The Milky Way <span class="hljs-keyword">is</span> a massive galaxy.
The Milky Way <span class="hljs-keyword">is</span> a small galaxy.`}}),{c(){t=d("p"),t.innerHTML=c,a=r(),M(m.$$.fragment),u=r(),g=d("p"),g.innerHTML=_,J=r(),M(V.$$.fragment),I=r(),W=d("p"),W.textContent=F,G=r(),M(x.$$.fragment)},l(p){t=f(p,"P",{"data-svelte-h":!0}),T(t)!=="svelte-1iuu1u"&&(t.innerHTML=c),a=o(p),y(m.$$.fragment,p),u=o(p),g=f(p,"P",{"data-svelte-h":!0}),T(g)!=="svelte-zykhjj"&&(g.innerHTML=_),J=o(p),y(V.$$.fragment,p),I=o(p),W=f(p,"P",{"data-svelte-h":!0}),T(W)!=="svelte-pa5g1"&&(W.textContent=F),G=o(p),y(x.$$.fragment,p)},m(p,k){l(p,t,k),l(p,a,k),j(m,p,k),l(p,u,k),l(p,g,k),l(p,J,k),j(V,p,k),l(p,I,k),l(p,W,k),l(p,G,k),j(x,p,k),R=!0},p:cs,i(p){R||(b(m.$$.fragment,p),b(V.$$.fragment,p),b(x.$$.fragment,p),R=!0)},o(p){$(m.$$.fragment,p),$(V.$$.fragment,p),$(x.$$.fragment,p),R=!1},d(p){p&&(e(t),e(a),e(u),e(g),e(J),e(I),e(W),e(G)),w(m,p),w(V,p),w(x,p)}}}function sl(U){let t,c;return t=new se({props:{$$slots:{default:[Ot]},$$scope:{ctx:U}}}),{c(){M(t.$$.fragment)},l(a){y(t.$$.fragment,a)},m(a,m){j(t,a,m),c=!0},p(a,m){const u={};m&2&&(u.$$scope={dirty:m,ctx:a}),t.$set(u)},i(a){c||(b(t.$$.fragment,a),c=!0)},o(a){$(t.$$.fragment,a),c=!1},d(a){w(t,a)}}}function el(U){let t,c=`텍스트를 토큰화하고 <code>input_ids</code>를 TensorFlow 텐서 형태로 반환합니다.
또한, <code>&lt;mask&gt;</code> 토큰의 위치를 지정해야 합니다:`,a,m,u,g,_="모델에 <code>inputs</code>를 입력하고, 마스킹된 토큰의 <code>logits</code>를 반환합니다:",J,V,I,W,F="그런 다음 가장 높은 확률은 가진 마스크 토큰 3개를 반환하고, 출력합니다:",G,x,R;return m=new Z({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMEF1dG9Ub2tlbml6ZXIlMEElMEF0b2tlbml6ZXIlMjAlM0QlMjBBdXRvVG9rZW5pemVyLmZyb21fcHJldHJhaW5lZCglMjJteV9hd2Vzb21lX2VsaTVfbWxtX21vZGVsJTIyKSUwQWlucHV0cyUyMCUzRCUyMHRva2VuaXplcih0ZXh0JTJDJTIwcmV0dXJuX3RlbnNvcnMlM0QlMjJ0ZiUyMiklMEFtYXNrX3Rva2VuX2luZGV4JTIwJTNEJTIwdGYud2hlcmUoaW5wdXRzJTVCJTIyaW5wdXRfaWRzJTIyJTVEJTIwJTNEJTNEJTIwdG9rZW5pemVyLm1hc2tfdG9rZW5faWQpJTVCMCUyQyUyMDElNUQ=",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;my_awesome_eli5_mlm_model&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>inputs = tokenizer(text, return_tensors=<span class="hljs-string">&quot;tf&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>mask_token_index = tf.where(inputs[<span class="hljs-string">&quot;input_ids&quot;</span>] == tokenizer.mask_token_id)[<span class="hljs-number">0</span>, <span class="hljs-number">1</span>]`}}),V=new Z({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMFRGQXV0b01vZGVsRm9yTWFza2VkTE0lMEElMEFtb2RlbCUyMCUzRCUyMFRGQXV0b01vZGVsRm9yTWFza2VkTE0uZnJvbV9wcmV0cmFpbmVkKCUyMnN0ZXZobGl1JTJGbXlfYXdlc29tZV9lbGk1X21sbV9tb2RlbCUyMiklMEFsb2dpdHMlMjAlM0QlMjBtb2RlbCgqKmlucHV0cykubG9naXRzJTBBbWFza190b2tlbl9sb2dpdHMlMjAlM0QlMjBsb2dpdHMlNUIwJTJDJTIwbWFza190b2tlbl9pbmRleCUyQyUyMCUzQSU1RA==",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> TFAutoModelForMaskedLM

<span class="hljs-meta">&gt;&gt;&gt; </span>model = TFAutoModelForMaskedLM.from_pretrained(<span class="hljs-string">&quot;stevhliu/my_awesome_eli5_mlm_model&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>logits = model(**inputs).logits
<span class="hljs-meta">&gt;&gt;&gt; </span>mask_token_logits = logits[<span class="hljs-number">0</span>, mask_token_index, :]`}}),x=new Z({props:{code:"dG9wXzNfdG9rZW5zJTIwJTNEJTIwdGYubWF0aC50b3BfayhtYXNrX3Rva2VuX2xvZ2l0cyUyQyUyMDMpLmluZGljZXMubnVtcHkoKSUwQSUwQWZvciUyMHRva2VuJTIwaW4lMjB0b3BfM190b2tlbnMlM0ElMEElMjAlMjAlMjAlMjBwcmludCh0ZXh0LnJlcGxhY2UodG9rZW5pemVyLm1hc2tfdG9rZW4lMkMlMjB0b2tlbml6ZXIuZGVjb2RlKCU1QnRva2VuJTVEKSkp",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span>top_3_tokens = tf.math.top_k(mask_token_logits, <span class="hljs-number">3</span>).indices.numpy()

<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">for</span> token <span class="hljs-keyword">in</span> top_3_tokens:
<span class="hljs-meta">... </span>    <span class="hljs-built_in">print</span>(text.replace(tokenizer.mask_token, tokenizer.decode([token])))
The Milky Way <span class="hljs-keyword">is</span> a spiral galaxy.
The Milky Way <span class="hljs-keyword">is</span> a massive galaxy.
The Milky Way <span class="hljs-keyword">is</span> a small galaxy.`}}),{c(){t=d("p"),t.innerHTML=c,a=r(),M(m.$$.fragment),u=r(),g=d("p"),g.innerHTML=_,J=r(),M(V.$$.fragment),I=r(),W=d("p"),W.textContent=F,G=r(),M(x.$$.fragment)},l(p){t=f(p,"P",{"data-svelte-h":!0}),T(t)!=="svelte-67cw7a"&&(t.innerHTML=c),a=o(p),y(m.$$.fragment,p),u=o(p),g=f(p,"P",{"data-svelte-h":!0}),T(g)!=="svelte-zykhjj"&&(g.innerHTML=_),J=o(p),y(V.$$.fragment,p),I=o(p),W=f(p,"P",{"data-svelte-h":!0}),T(W)!=="svelte-pa5g1"&&(W.textContent=F),G=o(p),y(x.$$.fragment,p)},m(p,k){l(p,t,k),l(p,a,k),j(m,p,k),l(p,u,k),l(p,g,k),l(p,J,k),j(V,p,k),l(p,I,k),l(p,W,k),l(p,G,k),j(x,p,k),R=!0},p:cs,i(p){R||(b(m.$$.fragment,p),b(V.$$.fragment,p),b(x.$$.fragment,p),R=!0)},o(p){$(m.$$.fragment,p),$(V.$$.fragment,p),$(x.$$.fragment,p),R=!1},d(p){p&&(e(t),e(a),e(u),e(g),e(J),e(I),e(W),e(G)),w(m,p),w(V,p),w(x,p)}}}function tl(U){let t,c;return t=new se({props:{$$slots:{default:[el]},$$scope:{ctx:U}}}),{c(){M(t.$$.fragment)},l(a){y(t.$$.fragment,a)},m(a,m){j(t,a,m),c=!0},p(a,m){const u={};m&2&&(u.$$scope={dirty:m,ctx:a}),t.$set(u)},i(a){c||(b(t.$$.fragment,a),c=!0)},o(a){$(t.$$.fragment,a),c=!1},d(a){w(t,a)}}}function ll(U){let t,c,a,m,u,g,_,J,V,I,W="마스킹된 언어 모델링(Masked language modeling)",F,G,x,R,p,k,Q=`마스킹된 언어 모델링은 시퀀스에서 마스킹된 토큰을 예측하며, 모델은 양방향으로 토큰에 액세스할 수 있습니다.
즉, 모델은 토큰의 왼쪽과 오른쪽 양쪽에서 접근할 수 있습니다.
마스킹된 언어 모델링은 전체 시퀀스에 대한 문맥적 이해가 필요한 작업에 적합하며, BERT가 그 예에 해당합니다.`,N,E,q="이번 가이드에서 다룰 내용은 다음과 같습니다:",S,z,L='<li><a href="https://huggingface.co/datasets/eli5" rel="nofollow">ELI5</a> 데이터 세트에서 <a href="https://www.reddit.com/r/askscience/" rel="nofollow">r/askscience</a> 부분을 사용해 <a href="https://huggingface.co/distilroberta-base" rel="nofollow">DistilRoBERTa</a> 모델을 미세 조정합니다.</li> <li>추론 시에 직접 미세 조정한 모델을 사용합니다.</li>',A,h,v,H,hs="시작하기 전에 필요한 라이브러리가 모두 설치되어 있는지 확인하세요:",P,D,K,i,C="Hugging Face 계정에 로그인하여 모델을 업로드하고 커뮤니티와의 공유를 권장합니다. 메시지가 표시되면(When prompted) 토큰을 입력하여 로그인합니다:",ds,fs,me,O,ls,ee,us,Oe,Ps,at="ELI5 데이터 세트 가져오기",ce,gs,nt=`먼저 🤗 Datasets 라이브러리에서 ELI5 데이터 세트의 r/askscience 중 일부만 가져옵니다.
이렇게 하면 전체 데이터 세트 학습에 더 많은 시간을 할애하기 전에 모든 것이 작동하는지 실험하고 확인할 수 있습니다.`,he,Ms,de,ys,pt="데이터 세트의 <code>train_asks</code>를 <code>train_test_split</code> 메소드를 사용해 훈련 데이터와 테스트 데이터로 분할합니다:",fe,js,ue,bs,rt="그리고 아래 예시를 살펴보세요:",ge,$s,Me,ws,ot=`많아 보일 수 있지만 실제로는 <code>text</code> 필드에만 집중하면 됩나다.
언어 모델링 작업의 멋진 점은 (비지도 학습으로) <em>다음 단어가 레이블</em>이기 때문에 레이블이 따로 필요하지 않습니다.`,ye,ss,as,te,Ts,st,Ds,it="전처리",je,_s,be,ks,mt="마스킹된 언어 모델링을 위해, 다음 단계로 DistilRoBERTa 토크나이저를 가져와서 <code>text</code> 하위 필드를 처리합니다:",$e,Js,we,xs,ct=`위의 예제에서와 마찬가지로, <code>text</code> 필드는 <code>answers</code> 안에 중첩되어 있습니다.
따라서 중첩된 구조에서 <a href="https://huggingface.co/docs/datasets/process.html#flatten" rel="nofollow"><code>flatten</code></a> 메소드를 사용하여 <code>text</code> 하위 필드를 추출합니다:`,Te,vs,_e,Us,ht=`이제 각 하위 필드는 <code>answers</code> 접두사(prefix)로 표시된 대로 별도의 열이 되고, <code>text</code> 필드는 이제 리스트가 되었습니다.
각 문장을 개별적으로 토큰화하는 대신 리스트를 문자열로 변환하여 한번에 토큰화할 수 있습니다.`,ke,Cs,dt="다음은 각 예제에 대해 문자열로 이루어진 리스트를 <code>join</code>하고 결과를 토큰화하는 첫 번째 전처리 함수입니다:",Je,Zs,xe,Gs,ft=`이 전처리 함수를 전체 데이터 세트에 적용하기 위해 🤗 Datasets <code>map</code> 메소드를 사용합니다.
데이터 세트의 여러 요소를 한 번에 처리하도록 <code>batched=True</code>를 설정하고 <code>num_proc</code>로 처리 횟수를 늘리면 <code>map</code> 함수의 속도를 높일 수 있습니다.
필요하지 않은 열은 제거합니다:`,ve,Rs,Ue,Is,ut="이 데이터 세트에는 토큰 시퀀스가 포함되어 있지만 이 중 일부는 모델의 최대 입력 길이보다 깁니다.",Ce,Ws,gt="이제 두 번째 전처리 함수를 사용해",Ze,Vs,Mt="<li>모든 시퀀스를 연결하고</li> <li>연결된 시퀀스를 정의한 <code>block_size</code> 보다 더 짧은 덩어리로 분할하는데, 이 덩어리는 모델의 최대 입력 길이보다 짧고 GPU RAM이 수용할 수 있는 길이여야 합니다.</li>",Ge,Xs,Re,Bs,yt="전체 데이터 세트에 <code>group_texts</code> 함수를 적용합니다:",Ie,Es,We,zs,jt=`이제 <code>DataCollatorForLanguageModeling</code>을 사용하여 데이터 예제의 배치를 생성합니다.
데이터 세트 전체를 최대 길이로 패딩하는 것보다 collation 단계에서 매 배치안에서의 최대 길이로 문장을 <em>동적으로 패딩</em>하는 것이 더 효율적입니다.`,Ve,ns,Xe,es,ps,le,Fs,et,Ks,bt="훈련",Be,rs,Ee,os,ze,ts,is,ae,Hs,tt,Os,$t="추론",Fe,Ns,wt="지금까지 모델 미세 조정을 잘 했으니, 추론에 사용할 수 있습니다!",He,As,Tt="모델이 빈칸을 채울 텍스트를 스페셜 토큰(special token)인 <code>&lt;mask&gt;</code> 토큰으로 표시합니다:",Ne,Ys,Ae,Qs,_t=`추론을 위해 미세 조정한 모델을 테스트하는 가장 간단한 방법은 <code>pipeline()</code>에서 사용하는 것입니다.
<code>fill-mask</code>태스크로 <code>pipeline</code>을 인스턴스화하고 텍스트를 전달합니다.
<code>top_k</code> 매개변수를 사용하여 반환하는 예측의 수를 지정할 수 있습니다:`,Ye,Ls,Qe,ms,Le,ne,qe;return J=new ie({}),G=new zt({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/masked_language_modeling.ipynb"},{label:"PyTorch",value:"https://colab.research.google.com/github/huggingface/notebooks/blob/main/transformers_doc/ko/pytorch/masked_language_modeling.ipynb"},{label:"TensorFlow",value:"https://colab.research.google.com/github/huggingface/notebooks/blob/main/transformers_doc/ko/tensorflow/masked_language_modeling.ipynb"},{label:"Mixed",value:"https://studiolab.sagemaker.aws/import/github/huggingface/notebooks/blob/main/transformers_doc/ko/masked_language_modeling.ipynb"},{label:"PyTorch",value:"https://studiolab.sagemaker.aws/import/github/huggingface/notebooks/blob/main/transformers_doc/ko/pytorch/masked_language_modeling.ipynb"},{label:"TensorFlow",value:"https://studiolab.sagemaker.aws/import/github/huggingface/notebooks/blob/main/transformers_doc/ko/tensorflow/masked_language_modeling.ipynb"}]}}),R=new Gt({props:{id:"mqElG5QJWUg"}}),h=new Ke({props:{$$slots:{default:[Ft]},$$scope:{ctx:U}}}),D=new Z({props:{code:"cGlwJTIwaW5zdGFsbCUyMHRyYW5zZm9ybWVycyUyMGRhdGFzZXRzJTIwZXZhbHVhdGU=",highlighted:"pip install transformers datasets evaluate"}}),fs=new Z({props:{code:"ZnJvbSUyMGh1Z2dpbmdmYWNlX2h1YiUyMGltcG9ydCUyMG5vdGVib29rX2xvZ2luJTBBJTBBbm90ZWJvb2tfbG9naW4oKQ==",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> huggingface_hub <span class="hljs-keyword">import</span> notebook_login

<span class="hljs-meta">&gt;&gt;&gt; </span>notebook_login()`}}),us=new ie({}),Ms=new Z({props:{code:"ZnJvbSUyMGRhdGFzZXRzJTIwaW1wb3J0JTIwbG9hZF9kYXRhc2V0JTBBJTBBZWxpNSUyMCUzRCUyMGxvYWRfZGF0YXNldCglMjJlbGk1JTIyJTJDJTIwc3BsaXQlM0QlMjJ0cmFpbl9hc2tzJTVCJTNBNTAwMCU1RCUyMik=",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>eli5 = load_dataset(<span class="hljs-string">&quot;eli5&quot;</span>, split=<span class="hljs-string">&quot;train_asks[:5000]&quot;</span>)`}}),js=new Z({props:{code:"ZWxpNSUyMCUzRCUyMGVsaTUudHJhaW5fdGVzdF9zcGxpdCh0ZXN0X3NpemUlM0QwLjIp",highlighted:'<span class="hljs-meta">&gt;&gt;&gt; </span>eli5 = eli5.train_test_split(test_size=<span class="hljs-number">0.2</span>)'}}),$s=new Z({props:{code:"ZWxpNSU1QiUyMnRyYWluJTIyJTVEJTVCMCU1RA==",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span>eli5[<span class="hljs-string">&quot;train&quot;</span>][<span class="hljs-number">0</span>]
{<span class="hljs-string">&#x27;answers&#x27;</span>: {<span class="hljs-string">&#x27;a_id&#x27;</span>: [<span class="hljs-string">&#x27;c3d1aib&#x27;</span>, <span class="hljs-string">&#x27;c3d4lya&#x27;</span>],
  <span class="hljs-string">&#x27;score&#x27;</span>: [<span class="hljs-number">6</span>, <span class="hljs-number">3</span>],
  <span class="hljs-string">&#x27;text&#x27;</span>: [<span class="hljs-string">&quot;The velocity needed to remain in orbit is equal to the square root of Newton&#x27;s constant times the mass of earth divided by the distance from the center of the earth. I don&#x27;t know the altitude of that specific mission, but they&#x27;re usually around 300 km. That means he&#x27;s going 7-8 km/s.\\n\\nIn space there are no other forces acting on either the shuttle or the guy, so they stay in the same position relative to each other. If he were to become unable to return to the ship, he would presumably run out of oxygen, or slowly fall into the atmosphere and burn up.&quot;</span>,
   <span class="hljs-string">&quot;Hope you don&#x27;t mind me asking another question, but why aren&#x27;t there any stars visible in this photo?&quot;</span>]},
 <span class="hljs-string">&#x27;answers_urls&#x27;</span>: {<span class="hljs-string">&#x27;url&#x27;</span>: []},
 <span class="hljs-string">&#x27;document&#x27;</span>: <span class="hljs-string">&#x27;&#x27;</span>,
 <span class="hljs-string">&#x27;q_id&#x27;</span>: <span class="hljs-string">&#x27;nyxfp&#x27;</span>,
 <span class="hljs-string">&#x27;selftext&#x27;</span>: <span class="hljs-string">&#x27;_URL_0_\\n\\nThis was on the front page earlier and I have a few questions about it. Is it possible to calculate how fast the astronaut would be orbiting the earth? Also how does he stay close to the shuttle so that he can return safely, i.e is he orbiting at the same speed and can therefore stay next to it? And finally if his propulsion system failed, would he eventually re-enter the atmosphere and presumably die?&#x27;</span>,
 <span class="hljs-string">&#x27;selftext_urls&#x27;</span>: {<span class="hljs-string">&#x27;url&#x27;</span>: [<span class="hljs-string">&#x27;http://apod.nasa.gov/apod/image/1201/freeflyer_nasa_3000.jpg&#x27;</span>]},
 <span class="hljs-string">&#x27;subreddit&#x27;</span>: <span class="hljs-string">&#x27;askscience&#x27;</span>,
 <span class="hljs-string">&#x27;title&#x27;</span>: <span class="hljs-string">&#x27;Few questions about this space walk photograph.&#x27;</span>,
 <span class="hljs-string">&#x27;title_urls&#x27;</span>: {<span class="hljs-string">&#x27;url&#x27;</span>: []}}`}}),Ts=new ie({}),_s=new Gt({props:{id:"8PmhEIXhBvI"}}),Js=new Z({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMEF1dG9Ub2tlbml6ZXIlMEElMEF0b2tlbml6ZXIlMjAlM0QlMjBBdXRvVG9rZW5pemVyLmZyb21fcHJldHJhaW5lZCglMjJkaXN0aWxyb2JlcnRhLWJhc2UlMjIp",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;distilroberta-base&quot;</span>)`}}),vs=new Z({props:{code:"ZWxpNSUyMCUzRCUyMGVsaTUuZmxhdHRlbigpJTBBZWxpNSU1QiUyMnRyYWluJTIyJTVEJTVCMCU1RA==",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span>eli5 = eli5.flatten()
<span class="hljs-meta">&gt;&gt;&gt; </span>eli5[<span class="hljs-string">&quot;train&quot;</span>][<span class="hljs-number">0</span>]
{<span class="hljs-string">&#x27;answers.a_id&#x27;</span>: [<span class="hljs-string">&#x27;c3d1aib&#x27;</span>, <span class="hljs-string">&#x27;c3d4lya&#x27;</span>],
 <span class="hljs-string">&#x27;answers.score&#x27;</span>: [<span class="hljs-number">6</span>, <span class="hljs-number">3</span>],
 <span class="hljs-string">&#x27;answers.text&#x27;</span>: [<span class="hljs-string">&quot;The velocity needed to remain in orbit is equal to the square root of Newton&#x27;s constant times the mass of earth divided by the distance from the center of the earth. I don&#x27;t know the altitude of that specific mission, but they&#x27;re usually around 300 km. That means he&#x27;s going 7-8 km/s.\\n\\nIn space there are no other forces acting on either the shuttle or the guy, so they stay in the same position relative to each other. If he were to become unable to return to the ship, he would presumably run out of oxygen, or slowly fall into the atmosphere and burn up.&quot;</span>,
  <span class="hljs-string">&quot;Hope you don&#x27;t mind me asking another question, but why aren&#x27;t there any stars visible in this photo?&quot;</span>],
 <span class="hljs-string">&#x27;answers_urls.url&#x27;</span>: [],
 <span class="hljs-string">&#x27;document&#x27;</span>: <span class="hljs-string">&#x27;&#x27;</span>,
 <span class="hljs-string">&#x27;q_id&#x27;</span>: <span class="hljs-string">&#x27;nyxfp&#x27;</span>,
 <span class="hljs-string">&#x27;selftext&#x27;</span>: <span class="hljs-string">&#x27;_URL_0_\\n\\nThis was on the front page earlier and I have a few questions about it. Is it possible to calculate how fast the astronaut would be orbiting the earth? Also how does he stay close to the shuttle so that he can return safely, i.e is he orbiting at the same speed and can therefore stay next to it? And finally if his propulsion system failed, would he eventually re-enter the atmosphere and presumably die?&#x27;</span>,
 <span class="hljs-string">&#x27;selftext_urls.url&#x27;</span>: [<span class="hljs-string">&#x27;http://apod.nasa.gov/apod/image/1201/freeflyer_nasa_3000.jpg&#x27;</span>],
 <span class="hljs-string">&#x27;subreddit&#x27;</span>: <span class="hljs-string">&#x27;askscience&#x27;</span>,
 <span class="hljs-string">&#x27;title&#x27;</span>: <span class="hljs-string">&#x27;Few questions about this space walk photograph.&#x27;</span>,
 <span class="hljs-string">&#x27;title_urls.url&#x27;</span>: []}`}}),Zs=new Z({props:{code:"ZGVmJTIwcHJlcHJvY2Vzc19mdW5jdGlvbihleGFtcGxlcyklM0ElMEElMjAlMjAlMjAlMjByZXR1cm4lMjB0b2tlbml6ZXIoJTVCJTIyJTIwJTIyLmpvaW4oeCklMjBmb3IlMjB4JTIwaW4lMjBleGFtcGxlcyU1QiUyMmFuc3dlcnMudGV4dCUyMiU1RCU1RCk=",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">def</span> <span class="hljs-title function_">preprocess_function</span>(<span class="hljs-params">examples</span>):
<span class="hljs-meta">... </span>    <span class="hljs-keyword">return</span> tokenizer([<span class="hljs-string">&quot; &quot;</span>.join(x) <span class="hljs-keyword">for</span> x <span class="hljs-keyword">in</span> examples[<span class="hljs-string">&quot;answers.text&quot;</span>]])`}}),Rs=new Z({props:{code:"dG9rZW5pemVkX2VsaTUlMjAlM0QlMjBlbGk1Lm1hcCglMEElMjAlMjAlMjAlMjBwcmVwcm9jZXNzX2Z1bmN0aW9uJTJDJTBBJTIwJTIwJTIwJTIwYmF0Y2hlZCUzRFRydWUlMkMlMEElMjAlMjAlMjAlMjBudW1fcHJvYyUzRDQlMkMlMEElMjAlMjAlMjAlMjByZW1vdmVfY29sdW1ucyUzRGVsaTUlNUIlMjJ0cmFpbiUyMiU1RC5jb2x1bW5fbmFtZXMlMkMlMEEp",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span>tokenized_eli5 = eli5.<span class="hljs-built_in">map</span>(
<span class="hljs-meta">... </span>    preprocess_function,
<span class="hljs-meta">... </span>    batched=<span class="hljs-literal">True</span>,
<span class="hljs-meta">... </span>    num_proc=<span class="hljs-number">4</span>,
<span class="hljs-meta">... </span>    remove_columns=eli5[<span class="hljs-string">&quot;train&quot;</span>].column_names,
<span class="hljs-meta">... </span>)`}}),Xs=new Z({props:{code:"YmxvY2tfc2l6ZSUyMCUzRCUyMDEyOCUwQSUwQSUwQWRlZiUyMGdyb3VwX3RleHRzKGV4YW1wbGVzKSUzQSUwQSUyMCUyMCUyMCUyMCUyMyUyMENvbmNhdGVuYXRlJTIwYWxsJTIwdGV4dHMuJTBBJTIwJTIwJTIwJTIwY29uY2F0ZW5hdGVkX2V4YW1wbGVzJTIwJTNEJTIwJTdCayUzQSUyMHN1bShleGFtcGxlcyU1QmslNUQlMkMlMjAlNUIlNUQpJTIwZm9yJTIwayUyMGluJTIwZXhhbXBsZXMua2V5cygpJTdEJTBBJTIwJTIwJTIwJTIwdG90YWxfbGVuZ3RoJTIwJTNEJTIwbGVuKGNvbmNhdGVuYXRlZF9leGFtcGxlcyU1Qmxpc3QoZXhhbXBsZXMua2V5cygpKSU1QjAlNUQlNUQpJTBBJTIwJTIwJTIwJTIwJTIzJTIwV2UlMjBkcm9wJTIwdGhlJTIwc21hbGwlMjByZW1haW5kZXIlMkMlMjB3ZSUyMGNvdWxkJTIwYWRkJTIwcGFkZGluZyUyMGlmJTIwdGhlJTIwbW9kZWwlMjBzdXBwb3J0ZWQlMjBpdCUyMGluc3RlYWQlMjBvZiUyMHRoaXMlMjBkcm9wJTJDJTIweW91JTIwY2FuJTBBJTIwJTIwJTIwJTIwJTIzJTIwY3VzdG9taXplJTIwdGhpcyUyMHBhcnQlMjB0byUyMHlvdXIlMjBuZWVkcy4lMEElMjAlMjAlMjAlMjBpZiUyMHRvdGFsX2xlbmd0aCUyMCUzRSUzRCUyMGJsb2NrX3NpemUlM0ElMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjB0b3RhbF9sZW5ndGglMjAlM0QlMjAodG90YWxfbGVuZ3RoJTIwJTJGJTJGJTIwYmxvY2tfc2l6ZSklMjAqJTIwYmxvY2tfc2l6ZSUwQSUyMCUyMCUyMCUyMCUyMyUyMFNwbGl0JTIwYnklMjBjaHVua3MlMjBvZiUyMGJsb2NrX3NpemUuJTBBJTIwJTIwJTIwJTIwcmVzdWx0JTIwJTNEJTIwJTdCJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwayUzQSUyMCU1QnQlNUJpJTIwJTNBJTIwaSUyMCUyQiUyMGJsb2NrX3NpemUlNUQlMjBmb3IlMjBpJTIwaW4lMjByYW5nZSgwJTJDJTIwdG90YWxfbGVuZ3RoJTJDJTIwYmxvY2tfc2l6ZSklNUQlMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjBmb3IlMjBrJTJDJTIwdCUyMGluJTIwY29uY2F0ZW5hdGVkX2V4YW1wbGVzLml0ZW1zKCklMEElMjAlMjAlMjAlMjAlN0QlMEElMjAlMjAlMjAlMjByZXN1bHQlNUIlMjJsYWJlbHMlMjIlNUQlMjAlM0QlMjByZXN1bHQlNUIlMjJpbnB1dF9pZHMlMjIlNUQuY29weSgpJTBBJTIwJTIwJTIwJTIwcmV0dXJuJTIwcmVzdWx0",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span>block_size = <span class="hljs-number">128</span>


<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">def</span> <span class="hljs-title function_">group_texts</span>(<span class="hljs-params">examples</span>):
<span class="hljs-meta">... </span>    <span class="hljs-comment"># Concatenate all texts.</span>
<span class="hljs-meta">... </span>    concatenated_examples = {k: <span class="hljs-built_in">sum</span>(examples[k], []) <span class="hljs-keyword">for</span> k <span class="hljs-keyword">in</span> examples.keys()}
<span class="hljs-meta">... </span>    total_length = <span class="hljs-built_in">len</span>(concatenated_examples[<span class="hljs-built_in">list</span>(examples.keys())[<span class="hljs-number">0</span>]])
<span class="hljs-meta">... </span>    <span class="hljs-comment"># We drop the small remainder, we could add padding if the model supported it instead of this drop, you can</span>
<span class="hljs-meta">... </span>    <span class="hljs-comment"># customize this part to your needs.</span>
<span class="hljs-meta">... </span>    <span class="hljs-keyword">if</span> total_length &gt;= block_size:
<span class="hljs-meta">... </span>        total_length = (total_length // block_size) * block_size
<span class="hljs-meta">... </span>    <span class="hljs-comment"># Split by chunks of block_size.</span>
<span class="hljs-meta">... </span>    result = {
<span class="hljs-meta">... </span>        k: [t[i : i + block_size] <span class="hljs-keyword">for</span> i <span class="hljs-keyword">in</span> <span class="hljs-built_in">range</span>(<span class="hljs-number">0</span>, total_length, block_size)]
<span class="hljs-meta">... </span>        <span class="hljs-keyword">for</span> k, t <span class="hljs-keyword">in</span> concatenated_examples.items()
<span class="hljs-meta">... </span>    }
<span class="hljs-meta">... </span>    result[<span class="hljs-string">&quot;labels&quot;</span>] = result[<span class="hljs-string">&quot;input_ids&quot;</span>].copy()
<span class="hljs-meta">... </span>    <span class="hljs-keyword">return</span> result`}}),Es=new Z({props:{code:"bG1fZGF0YXNldCUyMCUzRCUyMHRva2VuaXplZF9lbGk1Lm1hcChncm91cF90ZXh0cyUyQyUyMGJhdGNoZWQlM0RUcnVlJTJDJTIwbnVtX3Byb2MlM0Q0KQ==",highlighted:'<span class="hljs-meta">&gt;&gt;&gt; </span>lm_dataset = tokenized_eli5.<span class="hljs-built_in">map</span>(group_texts, batched=<span class="hljs-literal">True</span>, num_proc=<span class="hljs-number">4</span>)'}}),ns=new lt({props:{pytorch:!0,tensorflow:!0,jax:!1,$$slots:{tensorflow:[Yt],pytorch:[Nt]},$$scope:{ctx:U}}}),Fs=new ie({}),rs=new lt({props:{pytorch:!0,tensorflow:!0,jax:!1,$$slots:{tensorflow:[Dt],pytorch:[qt]},$$scope:{ctx:U}}}),os=new Ke({props:{$$slots:{default:[Kt]},$$scope:{ctx:U}}}),Hs=new ie({}),Ys=new Z({props:{code:"dGV4dCUyMCUzRCUyMCUyMlRoZSUyME1pbGt5JTIwV2F5JTIwaXMlMjBhJTIwJTNDbWFzayUzRSUyMGdhbGF4eS4lMjI=",highlighted:'<span class="hljs-meta">&gt;&gt;&gt; </span>text = <span class="hljs-string">&quot;The Milky Way is a &lt;mask&gt; galaxy.&quot;</span>'}}),Ls=new Z({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMHBpcGVsaW5lJTBBJTBBbWFza19maWxsZXIlMjAlM0QlMjBwaXBlbGluZSglMjJmaWxsLW1hc2slMjIlMkMlMjAlMjJzdGV2aGxpdSUyRm15X2F3ZXNvbWVfZWxpNV9tbG1fbW9kZWwlMjIpJTBBbWFza19maWxsZXIodGV4dCUyQyUyMHRvcF9rJTNEMyk=",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> pipeline

<span class="hljs-meta">&gt;&gt;&gt; </span>mask_filler = pipeline(<span class="hljs-string">&quot;fill-mask&quot;</span>, <span class="hljs-string">&quot;stevhliu/my_awesome_eli5_mlm_model&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>mask_filler(text, top_k=<span class="hljs-number">3</span>)
[{<span class="hljs-string">&#x27;score&#x27;</span>: <span class="hljs-number">0.5150994658470154</span>,
  <span class="hljs-string">&#x27;token&#x27;</span>: <span class="hljs-number">21300</span>,
  <span class="hljs-string">&#x27;token_str&#x27;</span>: <span class="hljs-string">&#x27; spiral&#x27;</span>,
  <span class="hljs-string">&#x27;sequence&#x27;</span>: <span class="hljs-string">&#x27;The Milky Way is a spiral galaxy.&#x27;</span>},
 {<span class="hljs-string">&#x27;score&#x27;</span>: <span class="hljs-number">0.07087188959121704</span>,
  <span class="hljs-string">&#x27;token&#x27;</span>: <span class="hljs-number">2232</span>,
  <span class="hljs-string">&#x27;token_str&#x27;</span>: <span class="hljs-string">&#x27; massive&#x27;</span>,
  <span class="hljs-string">&#x27;sequence&#x27;</span>: <span class="hljs-string">&#x27;The Milky Way is a massive galaxy.&#x27;</span>},
 {<span class="hljs-string">&#x27;score&#x27;</span>: <span class="hljs-number">0.06434620916843414</span>,
  <span class="hljs-string">&#x27;token&#x27;</span>: <span class="hljs-number">650</span>,
  <span class="hljs-string">&#x27;token_str&#x27;</span>: <span class="hljs-string">&#x27; small&#x27;</span>,
  <span class="hljs-string">&#x27;sequence&#x27;</span>: <span class="hljs-string">&#x27;The Milky Way is a small galaxy.&#x27;</span>}]`}}),ms=new lt({props:{pytorch:!0,tensorflow:!0,jax:!1,$$slots:{tensorflow:[tl],pytorch:[sl]},$$scope:{ctx:U}}}),{c(){t=d("meta"),c=r(),a=d("p"),m=r(),u=d("h1"),g=d("a"),_=d("span"),M(J.$$.fragment),V=r(),I=d("span"),I.textContent=W,F=r(),M(G.$$.fragment),x=r(),M(R.$$.fragment),p=r(),k=d("p"),k.textContent=Q,N=r(),E=d("p"),E.textContent=q,S=r(),z=d("ol"),z.innerHTML=L,A=r(),M(h.$$.fragment),v=r(),H=d("p"),H.textContent=hs,P=r(),M(D.$$.fragment),K=r(),i=d("p"),i.textContent=C,ds=r(),M(fs.$$.fragment),me=r(),O=d("h2"),ls=d("a"),ee=d("span"),M(us.$$.fragment),Oe=r(),Ps=d("span"),Ps.textContent=at,ce=r(),gs=d("p"),gs.textContent=nt,he=r(),M(Ms.$$.fragment),de=r(),ys=d("p"),ys.innerHTML=pt,fe=r(),M(js.$$.fragment),ue=r(),bs=d("p"),bs.textContent=rt,ge=r(),M($s.$$.fragment),Me=r(),ws=d("p"),ws.innerHTML=ot,ye=r(),ss=d("h2"),as=d("a"),te=d("span"),M(Ts.$$.fragment),st=r(),Ds=d("span"),Ds.textContent=it,je=r(),M(_s.$$.fragment),be=r(),ks=d("p"),ks.innerHTML=mt,$e=r(),M(Js.$$.fragment),we=r(),xs=d("p"),xs.innerHTML=ct,Te=r(),M(vs.$$.fragment),_e=r(),Us=d("p"),Us.innerHTML=ht,ke=r(),Cs=d("p"),Cs.innerHTML=dt,Je=r(),M(Zs.$$.fragment),xe=r(),Gs=d("p"),Gs.innerHTML=ft,ve=r(),M(Rs.$$.fragment),Ue=r(),Is=d("p"),Is.textContent=ut,Ce=r(),Ws=d("p"),Ws.textContent=gt,Ze=r(),Vs=d("ul"),Vs.innerHTML=Mt,Ge=r(),M(Xs.$$.fragment),Re=r(),Bs=d("p"),Bs.innerHTML=yt,Ie=r(),M(Es.$$.fragment),We=r(),zs=d("p"),zs.innerHTML=jt,Ve=r(),M(ns.$$.fragment),Xe=r(),es=d("h2"),ps=d("a"),le=d("span"),M(Fs.$$.fragment),et=r(),Ks=d("span"),Ks.textContent=bt,Be=r(),M(rs.$$.fragment),Ee=r(),M(os.$$.fragment),ze=r(),ts=d("h2"),is=d("a"),ae=d("span"),M(Hs.$$.fragment),tt=r(),Os=d("span"),Os.textContent=$t,Fe=r(),Ns=d("p"),Ns.textContent=wt,He=r(),As=d("p"),As.innerHTML=Tt,Ne=r(),M(Ys.$$.fragment),Ae=r(),Qs=d("p"),Qs.innerHTML=_t,Ye=r(),M(Ls.$$.fragment),Qe=r(),M(ms.$$.fragment),Le=r(),ne=d("p"),this.h()},l(s){const n=Et("svelte-1phssyn",document.head);t=f(n,"META",{name:!0,content:!0}),n.forEach(e),c=o(s),a=f(s,"P",{}),Y(a).forEach(e),m=o(s),u=f(s,"H1",{class:!0});var qs=Y(u);g=f(qs,"A",{id:!0,class:!0,href:!0});var pe=Y(g);_=f(pe,"SPAN",{});var re=Y(_);y(J.$$.fragment,re),re.forEach(e),pe.forEach(e),V=o(qs),I=f(qs,"SPAN",{"data-svelte-h":!0}),T(I)!=="svelte-j55hrs"&&(I.textContent=W),qs.forEach(e),F=o(s),y(G.$$.fragment,s),x=o(s),y(R.$$.fragment,s),p=o(s),k=f(s,"P",{"data-svelte-h":!0}),T(k)!=="svelte-1n9q4rf"&&(k.textContent=Q),N=o(s),E=f(s,"P",{"data-svelte-h":!0}),T(E)!=="svelte-ccgtvl"&&(E.textContent=q),S=o(s),z=f(s,"OL",{"data-svelte-h":!0}),T(z)!=="svelte-1vo3ofa"&&(z.innerHTML=L),A=o(s),y(h.$$.fragment,s),v=o(s),H=f(s,"P",{"data-svelte-h":!0}),T(H)!=="svelte-1k0z9pm"&&(H.textContent=hs),P=o(s),y(D.$$.fragment,s),K=o(s),i=f(s,"P",{"data-svelte-h":!0}),T(i)!=="svelte-m2mub0"&&(i.textContent=C),ds=o(s),y(fs.$$.fragment,s),me=o(s),O=f(s,"H2",{class:!0});var Ss=Y(O);ls=f(Ss,"A",{id:!0,class:!0,href:!0});var oe=Y(ls);ee=f(oe,"SPAN",{});var kt=Y(ee);y(us.$$.fragment,kt),kt.forEach(e),oe.forEach(e),Oe=o(Ss),Ps=f(Ss,"SPAN",{"data-svelte-h":!0}),T(Ps)!=="svelte-1o8bri8"&&(Ps.textContent=at),Ss.forEach(e),ce=o(s),gs=f(s,"P",{"data-svelte-h":!0}),T(gs)!=="svelte-vr9p67"&&(gs.textContent=nt),he=o(s),y(Ms.$$.fragment,s),de=o(s),ys=f(s,"P",{"data-svelte-h":!0}),T(ys)!=="svelte-297gyr"&&(ys.innerHTML=pt),fe=o(s),y(js.$$.fragment,s),ue=o(s),bs=f(s,"P",{"data-svelte-h":!0}),T(bs)!=="svelte-1aqlhyu"&&(bs.textContent=rt),ge=o(s),y($s.$$.fragment,s),Me=o(s),ws=f(s,"P",{"data-svelte-h":!0}),T(ws)!=="svelte-1cy2b9o"&&(ws.innerHTML=ot),ye=o(s),ss=f(s,"H2",{class:!0});var Se=Y(ss);as=f(Se,"A",{id:!0,class:!0,href:!0});var Jt=Y(as);te=f(Jt,"SPAN",{});var xt=Y(te);y(Ts.$$.fragment,xt),xt.forEach(e),Jt.forEach(e),st=o(Se),Ds=f(Se,"SPAN",{"data-svelte-h":!0}),T(Ds)!=="svelte-1cte2wb"&&(Ds.textContent=it),Se.forEach(e),je=o(s),y(_s.$$.fragment,s),be=o(s),ks=f(s,"P",{"data-svelte-h":!0}),T(ks)!=="svelte-1a969tz"&&(ks.innerHTML=mt),$e=o(s),y(Js.$$.fragment,s),we=o(s),xs=f(s,"P",{"data-svelte-h":!0}),T(xs)!=="svelte-1p65oj6"&&(xs.innerHTML=ct),Te=o(s),y(vs.$$.fragment,s),_e=o(s),Us=f(s,"P",{"data-svelte-h":!0}),T(Us)!=="svelte-1tsflso"&&(Us.innerHTML=ht),ke=o(s),Cs=f(s,"P",{"data-svelte-h":!0}),T(Cs)!=="svelte-1ry86e0"&&(Cs.innerHTML=dt),Je=o(s),y(Zs.$$.fragment,s),xe=o(s),Gs=f(s,"P",{"data-svelte-h":!0}),T(Gs)!=="svelte-hhkhvj"&&(Gs.innerHTML=ft),ve=o(s),y(Rs.$$.fragment,s),Ue=o(s),Is=f(s,"P",{"data-svelte-h":!0}),T(Is)!=="svelte-2gfwha"&&(Is.textContent=ut),Ce=o(s),Ws=f(s,"P",{"data-svelte-h":!0}),T(Ws)!=="svelte-dy2yct"&&(Ws.textContent=gt),Ze=o(s),Vs=f(s,"UL",{"data-svelte-h":!0}),T(Vs)!=="svelte-1t9aqgv"&&(Vs.innerHTML=Mt),Ge=o(s),y(Xs.$$.fragment,s),Re=o(s),Bs=f(s,"P",{"data-svelte-h":!0}),T(Bs)!=="svelte-by0nu8"&&(Bs.innerHTML=yt),Ie=o(s),y(Es.$$.fragment,s),We=o(s),zs=f(s,"P",{"data-svelte-h":!0}),T(zs)!=="svelte-izyzcu"&&(zs.innerHTML=jt),Ve=o(s),y(ns.$$.fragment,s),Xe=o(s),es=f(s,"H2",{class:!0});var Pe=Y(es);ps=f(Pe,"A",{id:!0,class:!0,href:!0});var vt=Y(ps);le=f(vt,"SPAN",{});var Ut=Y(le);y(Fs.$$.fragment,Ut),Ut.forEach(e),vt.forEach(e),et=o(Pe),Ks=f(Pe,"SPAN",{"data-svelte-h":!0}),T(Ks)!=="svelte-tdy10p"&&(Ks.textContent=bt),Pe.forEach(e),Be=o(s),y(rs.$$.fragment,s),Ee=o(s),y(os.$$.fragment,s),ze=o(s),ts=f(s,"H2",{class:!0});var De=Y(ts);is=f(De,"A",{id:!0,class:!0,href:!0});var Ct=Y(is);ae=f(Ct,"SPAN",{});var Zt=Y(ae);y(Hs.$$.fragment,Zt),Zt.forEach(e),Ct.forEach(e),tt=o(De),Os=f(De,"SPAN",{"data-svelte-h":!0}),T(Os)!=="svelte-8litrx"&&(Os.textContent=$t),De.forEach(e),Fe=o(s),Ns=f(s,"P",{"data-svelte-h":!0}),T(Ns)!=="svelte-8jfat8"&&(Ns.textContent=wt),He=o(s),As=f(s,"P",{"data-svelte-h":!0}),T(As)!=="svelte-9tmh7v"&&(As.innerHTML=Tt),Ne=o(s),y(Ys.$$.fragment,s),Ae=o(s),Qs=f(s,"P",{"data-svelte-h":!0}),T(Qs)!=="svelte-1pw875r"&&(Qs.innerHTML=_t),Ye=o(s),y(Ls.$$.fragment,s),Qe=o(s),y(ms.$$.fragment,s),Le=o(s),ne=f(s,"P",{}),Y(ne).forEach(e),this.h()},h(){X(t,"name","hf:doc:metadata"),X(t,"content",JSON.stringify(al)),X(g,"id","masked-language-modeling"),X(g,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),X(g,"href","#masked-language-modeling"),X(u,"class","relative group"),X(ls,"id","load-eli5-dataset"),X(ls,"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"),X(ls,"href","#load-eli5-dataset"),X(O,"class","relative group"),X(as,"id","preprocess"),X(as,"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"),X(as,"href","#preprocess"),X(ss,"class","relative group"),X(ps,"id","train"),X(ps,"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"),X(ps,"href","#train"),X(es,"class","relative group"),X(is,"id","inference"),X(is,"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"),X(is,"href","#inference"),X(ts,"class","relative group")},m(s,n){B(document.head,t),l(s,c,n),l(s,a,n),l(s,m,n),l(s,u,n),B(u,g),B(g,_),j(J,_,null),B(u,V),B(u,I),l(s,F,n),j(G,s,n),l(s,x,n),j(R,s,n),l(s,p,n),l(s,k,n),l(s,N,n),l(s,E,n),l(s,S,n),l(s,z,n),l(s,A,n),j(h,s,n),l(s,v,n),l(s,H,n),l(s,P,n),j(D,s,n),l(s,K,n),l(s,i,n),l(s,ds,n),j(fs,s,n),l(s,me,n),l(s,O,n),B(O,ls),B(ls,ee),j(us,ee,null),B(O,Oe),B(O,Ps),l(s,ce,n),l(s,gs,n),l(s,he,n),j(Ms,s,n),l(s,de,n),l(s,ys,n),l(s,fe,n),j(js,s,n),l(s,ue,n),l(s,bs,n),l(s,ge,n),j($s,s,n),l(s,Me,n),l(s,ws,n),l(s,ye,n),l(s,ss,n),B(ss,as),B(as,te),j(Ts,te,null),B(ss,st),B(ss,Ds),l(s,je,n),j(_s,s,n),l(s,be,n),l(s,ks,n),l(s,$e,n),j(Js,s,n),l(s,we,n),l(s,xs,n),l(s,Te,n),j(vs,s,n),l(s,_e,n),l(s,Us,n),l(s,ke,n),l(s,Cs,n),l(s,Je,n),j(Zs,s,n),l(s,xe,n),l(s,Gs,n),l(s,ve,n),j(Rs,s,n),l(s,Ue,n),l(s,Is,n),l(s,Ce,n),l(s,Ws,n),l(s,Ze,n),l(s,Vs,n),l(s,Ge,n),j(Xs,s,n),l(s,Re,n),l(s,Bs,n),l(s,Ie,n),j(Es,s,n),l(s,We,n),l(s,zs,n),l(s,Ve,n),j(ns,s,n),l(s,Xe,n),l(s,es,n),B(es,ps),B(ps,le),j(Fs,le,null),B(es,et),B(es,Ks),l(s,Be,n),j(rs,s,n),l(s,Ee,n),j(os,s,n),l(s,ze,n),l(s,ts,n),B(ts,is),B(is,ae),j(Hs,ae,null),B(ts,tt),B(ts,Os),l(s,Fe,n),l(s,Ns,n),l(s,He,n),l(s,As,n),l(s,Ne,n),j(Ys,s,n),l(s,Ae,n),l(s,Qs,n),l(s,Ye,n),j(Ls,s,n),l(s,Qe,n),j(ms,s,n),l(s,Le,n),l(s,ne,n),qe=!0},p(s,[n]){const qs={};n&2&&(qs.$$scope={dirty:n,ctx:s}),h.$set(qs);const pe={};n&2&&(pe.$$scope={dirty:n,ctx:s}),ns.$set(pe);const re={};n&2&&(re.$$scope={dirty:n,ctx:s}),rs.$set(re);const Ss={};n&2&&(Ss.$$scope={dirty:n,ctx:s}),os.$set(Ss);const oe={};n&2&&(oe.$$scope={dirty:n,ctx:s}),ms.$set(oe)},i(s){qe||(b(J.$$.fragment,s),b(G.$$.fragment,s),b(R.$$.fragment,s),b(h.$$.fragment,s),b(D.$$.fragment,s),b(fs.$$.fragment,s),b(us.$$.fragment,s),b(Ms.$$.fragment,s),b(js.$$.fragment,s),b($s.$$.fragment,s),b(Ts.$$.fragment,s),b(_s.$$.fragment,s),b(Js.$$.fragment,s),b(vs.$$.fragment,s),b(Zs.$$.fragment,s),b(Rs.$$.fragment,s),b(Xs.$$.fragment,s),b(Es.$$.fragment,s),b(ns.$$.fragment,s),b(Fs.$$.fragment,s),b(rs.$$.fragment,s),b(os.$$.fragment,s),b(Hs.$$.fragment,s),b(Ys.$$.fragment,s),b(Ls.$$.fragment,s),b(ms.$$.fragment,s),qe=!0)},o(s){$(J.$$.fragment,s),$(G.$$.fragment,s),$(R.$$.fragment,s),$(h.$$.fragment,s),$(D.$$.fragment,s),$(fs.$$.fragment,s),$(us.$$.fragment,s),$(Ms.$$.fragment,s),$(js.$$.fragment,s),$($s.$$.fragment,s),$(Ts.$$.fragment,s),$(_s.$$.fragment,s),$(Js.$$.fragment,s),$(vs.$$.fragment,s),$(Zs.$$.fragment,s),$(Rs.$$.fragment,s),$(Xs.$$.fragment,s),$(Es.$$.fragment,s),$(ns.$$.fragment,s),$(Fs.$$.fragment,s),$(rs.$$.fragment,s),$(os.$$.fragment,s),$(Hs.$$.fragment,s),$(Ys.$$.fragment,s),$(Ls.$$.fragment,s),$(ms.$$.fragment,s),qe=!1},d(s){s&&(e(c),e(a),e(m),e(u),e(F),e(x),e(p),e(k),e(N),e(E),e(S),e(z),e(A),e(v),e(H),e(P),e(K),e(i),e(ds),e(me),e(O),e(ce),e(gs),e(he),e(de),e(ys),e(fe),e(ue),e(bs),e(ge),e(Me),e(ws),e(ye),e(ss),e(je),e(be),e(ks),e($e),e(we),e(xs),e(Te),e(_e),e(Us),e(ke),e(Cs),e(Je),e(xe),e(Gs),e(ve),e(Ue),e(Is),e(Ce),e(Ws),e(Ze),e(Vs),e(Ge),e(Re),e(Bs),e(Ie),e(We),e(zs),e(Ve),e(Xe),e(es),e(Be),e(Ee),e(ze),e(ts),e(Fe),e(Ns),e(He),e(As),e(Ne),e(Ae),e(Qs),e(Ye),e(Qe),e(Le),e(ne)),e(t),w(J),w(G,s),w(R,s),w(h,s),w(D,s),w(fs,s),w(us),w(Ms,s),w(js,s),w($s,s),w(Ts),w(_s,s),w(Js,s),w(vs,s),w(Zs,s),w(Rs,s),w(Xs,s),w(Es,s),w(ns,s),w(Fs),w(rs,s),w(os,s),w(Hs),w(Ys,s),w(Ls,s),w(ms,s)}}}const al={local:"masked-language-modeling",sections:[{local:"load-eli5-dataset",title:"ELI5 데이터 세트 가져오기"},{local:"preprocess",title:"전처리"},{local:"train",title:"훈련"},{local:"inference",title:"추론"}],title:"마스킹된 언어 모델링(Masked language modeling)"};function nl(U){return Vt(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class fl extends Xt{constructor(t){super(),Bt(this,t,nl,ll,Wt,{})}}export{fl as component};
