import{s as qe,o as Se,n as ss}from"../chunks/scheduler.56730f09.js";import{S as Pe,i as De,g as $,s as m,r as u,A as Ke,h as w,f as t,c as i,j as Ye,u as M,x as T,k as Ne,y as Oe,a,v as g,d as y,t as j,w as b,m as Ae,n as Le}from"../chunks/index.1f144517.js";import{T as be}from"../chunks/Tip.41e845e5.js";import{Y as Qe}from"../chunks/Youtube.62e0f062.js";import{C}from"../chunks/CodeBlock.738eeccb.js";import{D as st}from"../chunks/DocNotebookDropdown.b2e82107.js";import{F as $e,M as Cs}from"../chunks/Markdown.c541024b.js";import{H as Vs}from"../chunks/Heading.57d46534.js";function et(G){let e,c,l="다음 아키텍쳐 중 하나를 선택하세요:",r,f,d='<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(){e=Ae(`이번 가이드에서처럼 다른 아키텍처를 미세 조정해 마스킹된 언어 모델링을 할 수 있습니다.
`),c=$("p"),c.textContent=l,r=m(),f=$("p"),f.innerHTML=d},l(_){e=Le(_,`이번 가이드에서처럼 다른 아키텍처를 미세 조정해 마스킹된 언어 모델링을 할 수 있습니다.
`),c=w(_,"P",{"data-svelte-h":!0}),T(c)!=="svelte-1envvxx"&&(c.textContent=l),r=i(_),f=w(_,"P",{"data-svelte-h":!0}),T(f)!=="svelte-cb0kyv"&&(f.innerHTML=d)},m(_,U){a(_,e,U),a(_,c,U),a(_,r,U),a(_,f,U)},p:ss,d(_){_&&(t(e),t(c),t(r),t(f))}}}function tt(G){let e,c="시퀀스 끝 토큰을 패딩 토큰으로 사용하고 데이터를 반복할 때마다 토큰을 무작위로 마스킹하도록 <code>mlm_-probability</code>를 지정합니다:",l,r,f;return r=new C({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>)`,wrap:!1}}),{c(){e=$("p"),e.innerHTML=c,l=m(),u(r.$$.fragment)},l(d){e=w(d,"P",{"data-svelte-h":!0}),T(e)!=="svelte-5j66ud"&&(e.innerHTML=c),l=i(d),M(r.$$.fragment,d)},m(d,_){a(d,e,_),a(d,l,_),g(r,d,_),f=!0},p:ss,i(d){f||(y(r.$$.fragment,d),f=!0)},o(d){j(r.$$.fragment,d),f=!1},d(d){d&&(t(e),t(l)),b(r,d)}}}function lt(G){let e,c;return e=new Cs({props:{$$slots:{default:[tt]},$$scope:{ctx:G}}}),{c(){u(e.$$.fragment)},l(l){M(e.$$.fragment,l)},m(l,r){g(e,l,r),c=!0},p(l,r){const f={};r&2&&(f.$$scope={dirty:r,ctx:l}),e.$set(f)},i(l){c||(y(e.$$.fragment,l),c=!0)},o(l){j(e.$$.fragment,l),c=!1},d(l){b(e,l)}}}function at(G){let e,c="시퀀스 끝 토큰을 패딩 토큰으로 사용하고 데이터를 반복할 때마다 토큰을 무작위로 마스킹하도록 <code>mlm_-probability</code>를 지정합니다:",l,r,f;return r=new C({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>)`,wrap:!1}}),{c(){e=$("p"),e.innerHTML=c,l=m(),u(r.$$.fragment)},l(d){e=w(d,"P",{"data-svelte-h":!0}),T(e)!=="svelte-5j66ud"&&(e.innerHTML=c),l=i(d),M(r.$$.fragment,d)},m(d,_){a(d,e,_),a(d,l,_),g(r,d,_),f=!0},p:ss,i(d){f||(y(r.$$.fragment,d),f=!0)},o(d){j(r.$$.fragment,d),f=!1},d(d){d&&(t(e),t(l)),b(r,d)}}}function nt(G){let e,c;return e=new Cs({props:{$$slots:{default:[at]},$$scope:{ctx:G}}}),{c(){u(e.$$.fragment)},l(l){M(e.$$.fragment,l)},m(l,r){g(e,l,r),c=!0},p(l,r){const f={};r&2&&(f.$$scope={dirty:r,ctx:l}),e.$set(f)},i(l){c||(y(e.$$.fragment,l),c=!0)},o(l){j(e.$$.fragment,l),c=!1},d(l){b(e,l)}}}function pt(G){let e,c='<code>Trainer</code>로 모델을 미세 조정하는 데 익숙하지 않다면 기본 튜토리얼 <a href="../training#train-with-pytorch-trainer">여기</a>를 살펴보세요!';return{c(){e=$("p"),e.innerHTML=c},l(l){e=w(l,"P",{"data-svelte-h":!0}),T(e)!=="svelte-mnr18a"&&(e.innerHTML=c)},m(l,r){a(l,e,r)},p:ss,d(l){l&&t(e)}}}function rt(G){let e,c,l,r="이제 모델 훈련을 시작할 준비가 되었습니다! <code>AutoModelForMaskedLM</code>를 사용해 DistilRoBERTa 모델을 가져옵니다:",f,d,_,U,R="이제 세 단계가 남았습니다:",I,Z,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>",W,k,V,p,J="훈련이 완료되면 <code>evaluate()</code> 메소드를 사용하여 펄플렉서티(perplexity)를 계산하고 모델을 평가합니다:",H,z,X,Y,N="그리고 <code>push_to_hub()</code> 메소드를 사용해 다른 사람들이 사용할 수 있도록, Hub로 모델을 업로드합니다.",Q,E,B;return e=new be({props:{$$slots:{default:[pt]},$$scope:{ctx:G}}}),d=new C({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>)`,wrap:!1}}),k=new C({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()`,wrap:!1}}),z=new C({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>`,wrap:!1}}),E=new C({props:{code:"dHJhaW5lci5wdXNoX3RvX2h1Yigp",highlighted:'<span class="hljs-meta">&gt;&gt;&gt; </span>trainer.push_to_hub()',wrap:!1}}),{c(){u(e.$$.fragment),c=m(),l=$("p"),l.innerHTML=r,f=m(),u(d.$$.fragment),_=m(),U=$("p"),U.textContent=R,I=m(),Z=$("ol"),Z.innerHTML=F,W=m(),u(k.$$.fragment),V=m(),p=$("p"),p.innerHTML=J,H=m(),u(z.$$.fragment),X=m(),Y=$("p"),Y.innerHTML=N,Q=m(),u(E.$$.fragment)},l(h){M(e.$$.fragment,h),c=i(h),l=w(h,"P",{"data-svelte-h":!0}),T(l)!=="svelte-j58c41"&&(l.innerHTML=r),f=i(h),M(d.$$.fragment,h),_=i(h),U=w(h,"P",{"data-svelte-h":!0}),T(U)!=="svelte-adwu43"&&(U.textContent=R),I=i(h),Z=w(h,"OL",{"data-svelte-h":!0}),T(Z)!=="svelte-1qz54pn"&&(Z.innerHTML=F),W=i(h),M(k.$$.fragment,h),V=i(h),p=w(h,"P",{"data-svelte-h":!0}),T(p)!=="svelte-d2qmt2"&&(p.innerHTML=J),H=i(h),M(z.$$.fragment,h),X=i(h),Y=w(h,"P",{"data-svelte-h":!0}),T(Y)!=="svelte-1sgaay4"&&(Y.innerHTML=N),Q=i(h),M(E.$$.fragment,h)},m(h,v){g(e,h,v),a(h,c,v),a(h,l,v),a(h,f,v),g(d,h,v),a(h,_,v),a(h,U,v),a(h,I,v),a(h,Z,v),a(h,W,v),g(k,h,v),a(h,V,v),a(h,p,v),a(h,H,v),g(z,h,v),a(h,X,v),a(h,Y,v),a(h,Q,v),g(E,h,v),B=!0},p(h,v){const L={};v&2&&(L.$$scope={dirty:v,ctx:h}),e.$set(L)},i(h){B||(y(e.$$.fragment,h),y(d.$$.fragment,h),y(k.$$.fragment,h),y(z.$$.fragment,h),y(E.$$.fragment,h),B=!0)},o(h){j(e.$$.fragment,h),j(d.$$.fragment,h),j(k.$$.fragment,h),j(z.$$.fragment,h),j(E.$$.fragment,h),B=!1},d(h){h&&(t(c),t(l),t(f),t(_),t(U),t(I),t(Z),t(W),t(V),t(p),t(H),t(X),t(Y),t(Q)),b(e,h),b(d,h),b(k,h),b(z,h),b(E,h)}}}function ot(G){let e,c;return e=new Cs({props:{$$slots:{default:[rt]},$$scope:{ctx:G}}}),{c(){u(e.$$.fragment)},l(l){M(e.$$.fragment,l)},m(l,r){g(e,l,r),c=!0},p(l,r){const f={};r&2&&(f.$$scope={dirty:r,ctx:l}),e.$set(f)},i(l){c||(y(e.$$.fragment,l),c=!0)},o(l){j(e.$$.fragment,l),c=!1},d(l){b(e,l)}}}function mt(G){let e,c='Keras로 모델을 미세 조정하는 데 익숙하지 않다면 기본 튜토리얼 <a href="../training#train-a-tensorflow-model-with-keras">여기</a>를 살펴보세요!';return{c(){e=$("p"),e.innerHTML=c},l(l){e=w(l,"P",{"data-svelte-h":!0}),T(e)!=="svelte-2dbfdz"&&(e.innerHTML=c)},m(l,r){a(l,e,r)},p:ss,d(l){l&&t(e)}}}function it(G){let e,c,l,r,f,d="다음으로 <code>TFAutoModelForMaskedLM</code>를 사용해 DistilRoBERTa 모델을 가져옵니다:",_,U,R,I,Z="<code>prepare_tf_dataset()</code> 메소드를 사용해 데이터 세트를 <code>tf.data.Dataset</code> 형식으로 변환하세요:",F,W,k,V,p='<a href="https://keras.io/api/models/model_training_apis/#compile-method" rel="nofollow"><code>compile</code></a> 메소드를 통해 모델 훈련을 구성합니다:',J,H,z,X,Y="이는 업로드할 모델과 토크나이저의 위치를 <code>PushToHubCallback</code>에 지정하여 수행할 수 있습니다:",N,Q,E,B,h=`드디어 모델을 훈련할 준비가 되었습니다!
모델을 미세 조정할 때 훈련 및 검증 데이터 세트, 에포크 수, 콜백이 포함된 <a href="https://keras.io/api/models/model_training_apis/#fit-method" rel="nofollow"><code>fit</code></a>을 호출합니다:`,v,L,S,A,es="훈련이 완료되면, 자동으로 Hub로 업로드되어 누구나 사용할 수 있습니다!",q;return e=new be({props:{$$slots:{default:[mt]},$$scope:{ctx:G}}}),l=new C({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>)`,wrap:!1}}),U=new C({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>)`,wrap:!1}}),W=new C({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>)`,wrap:!1}}),H=new C({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)`,wrap:!1}}),Q=new C({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>)`,wrap:!1}}),L=new C({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])',wrap:!1}}),{c(){u(e.$$.fragment),c=Ae(`
TensorFlow로 모델을 미세 조정하기 위해서는 옵티마이저(optimizer) 함수 설정, 학습률(learning rate) 스케쥴링, 훈련 하이퍼파라미터 설정부터 시작하세요:

	`),u(l.$$.fragment),r=m(),f=$("p"),f.innerHTML=d,_=m(),u(U.$$.fragment),R=m(),I=$("p"),I.innerHTML=Z,F=m(),u(W.$$.fragment),k=m(),V=$("p"),V.innerHTML=p,J=m(),u(H.$$.fragment),z=m(),X=$("p"),X.innerHTML=Y,N=m(),u(Q.$$.fragment),E=m(),B=$("p"),B.innerHTML=h,v=m(),u(L.$$.fragment),S=m(),A=$("p"),A.textContent=es},l(o){M(e.$$.fragment,o),c=Le(o,`
TensorFlow로 모델을 미세 조정하기 위해서는 옵티마이저(optimizer) 함수 설정, 학습률(learning rate) 스케쥴링, 훈련 하이퍼파라미터 설정부터 시작하세요:

	`),M(l.$$.fragment,o),r=i(o),f=w(o,"P",{"data-svelte-h":!0}),T(f)!=="svelte-gg210g"&&(f.innerHTML=d),_=i(o),M(U.$$.fragment,o),R=i(o),I=w(o,"P",{"data-svelte-h":!0}),T(I)!=="svelte-s4fgj9"&&(I.innerHTML=Z),F=i(o),M(W.$$.fragment,o),k=i(o),V=w(o,"P",{"data-svelte-h":!0}),T(V)!=="svelte-1nhrjql"&&(V.innerHTML=p),J=i(o),M(H.$$.fragment,o),z=i(o),X=w(o,"P",{"data-svelte-h":!0}),T(X)!=="svelte-5310au"&&(X.innerHTML=Y),N=i(o),M(Q.$$.fragment,o),E=i(o),B=w(o,"P",{"data-svelte-h":!0}),T(B)!=="svelte-3mv0xn"&&(B.innerHTML=h),v=i(o),M(L.$$.fragment,o),S=i(o),A=w(o,"P",{"data-svelte-h":!0}),T(A)!=="svelte-1v3ov90"&&(A.textContent=es)},m(o,x){g(e,o,x),a(o,c,x),g(l,o,x),a(o,r,x),a(o,f,x),a(o,_,x),g(U,o,x),a(o,R,x),a(o,I,x),a(o,F,x),g(W,o,x),a(o,k,x),a(o,V,x),a(o,J,x),g(H,o,x),a(o,z,x),a(o,X,x),a(o,N,x),g(Q,o,x),a(o,E,x),a(o,B,x),a(o,v,x),g(L,o,x),a(o,S,x),a(o,A,x),q=!0},p(o,x){const Is={};x&2&&(Is.$$scope={dirty:x,ctx:o}),e.$set(Is)},i(o){q||(y(e.$$.fragment,o),y(l.$$.fragment,o),y(U.$$.fragment,o),y(W.$$.fragment,o),y(H.$$.fragment,o),y(Q.$$.fragment,o),y(L.$$.fragment,o),q=!0)},o(o){j(e.$$.fragment,o),j(l.$$.fragment,o),j(U.$$.fragment,o),j(W.$$.fragment,o),j(H.$$.fragment,o),j(Q.$$.fragment,o),j(L.$$.fragment,o),q=!1},d(o){o&&(t(c),t(r),t(f),t(_),t(R),t(I),t(F),t(k),t(V),t(J),t(z),t(X),t(N),t(E),t(B),t(v),t(S),t(A)),b(e,o),b(l,o),b(U,o),b(W,o),b(H,o),b(Q,o),b(L,o)}}}function ct(G){let e,c;return e=new Cs({props:{$$slots:{default:[it]},$$scope:{ctx:G}}}),{c(){u(e.$$.fragment)},l(l){M(e.$$.fragment,l)},m(l,r){g(e,l,r),c=!0},p(l,r){const f={};r&2&&(f.$$scope={dirty:r,ctx:l}),e.$set(f)},i(l){c||(y(e.$$.fragment,l),c=!0)},o(l){j(e.$$.fragment,l),c=!1},d(l){b(e,l)}}}function ht(G){let e,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(){e=$("p"),e.innerHTML=c},l(l){e=w(l,"P",{"data-svelte-h":!0}),T(e)!=="svelte-rnza4"&&(e.innerHTML=c)},m(l,r){a(l,e,r)},p:ss,d(l){l&&t(e)}}}function ft(G){let e,c=`텍스트를 토큰화하고 <code>input_ids</code>를 PyTorch 텐서 형태로 반환합니다.
또한, <code>&lt;mask&gt;</code> 토큰의 위치를 지정해야 합니다:`,l,r,f,d,_="모델에 <code>inputs</code>를 입력하고, 마스킹된 토큰의 <code>logits</code>를 반환합니다:",U,R,I,Z,F="그런 다음 가장 높은 확률은 가진 마스크 토큰 3개를 반환하고, 출력합니다:",W,k,V;return r=new C({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>]`,wrap:!1}}),R=new C({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, :]`,wrap:!1}}),k=new C({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.`,wrap:!1}}),{c(){e=$("p"),e.innerHTML=c,l=m(),u(r.$$.fragment),f=m(),d=$("p"),d.innerHTML=_,U=m(),u(R.$$.fragment),I=m(),Z=$("p"),Z.textContent=F,W=m(),u(k.$$.fragment)},l(p){e=w(p,"P",{"data-svelte-h":!0}),T(e)!=="svelte-1iuu1u"&&(e.innerHTML=c),l=i(p),M(r.$$.fragment,p),f=i(p),d=w(p,"P",{"data-svelte-h":!0}),T(d)!=="svelte-zykhjj"&&(d.innerHTML=_),U=i(p),M(R.$$.fragment,p),I=i(p),Z=w(p,"P",{"data-svelte-h":!0}),T(Z)!=="svelte-pa5g1"&&(Z.textContent=F),W=i(p),M(k.$$.fragment,p)},m(p,J){a(p,e,J),a(p,l,J),g(r,p,J),a(p,f,J),a(p,d,J),a(p,U,J),g(R,p,J),a(p,I,J),a(p,Z,J),a(p,W,J),g(k,p,J),V=!0},p:ss,i(p){V||(y(r.$$.fragment,p),y(R.$$.fragment,p),y(k.$$.fragment,p),V=!0)},o(p){j(r.$$.fragment,p),j(R.$$.fragment,p),j(k.$$.fragment,p),V=!1},d(p){p&&(t(e),t(l),t(f),t(d),t(U),t(I),t(Z),t(W)),b(r,p),b(R,p),b(k,p)}}}function dt(G){let e,c;return e=new Cs({props:{$$slots:{default:[ft]},$$scope:{ctx:G}}}),{c(){u(e.$$.fragment)},l(l){M(e.$$.fragment,l)},m(l,r){g(e,l,r),c=!0},p(l,r){const f={};r&2&&(f.$$scope={dirty:r,ctx:l}),e.$set(f)},i(l){c||(y(e.$$.fragment,l),c=!0)},o(l){j(e.$$.fragment,l),c=!1},d(l){b(e,l)}}}function ut(G){let e,c=`텍스트를 토큰화하고 <code>input_ids</code>를 TensorFlow 텐서 형태로 반환합니다.
또한, <code>&lt;mask&gt;</code> 토큰의 위치를 지정해야 합니다:`,l,r,f,d,_="모델에 <code>inputs</code>를 입력하고, 마스킹된 토큰의 <code>logits</code>를 반환합니다:",U,R,I,Z,F="그런 다음 가장 높은 확률은 가진 마스크 토큰 3개를 반환하고, 출력합니다:",W,k,V;return r=new C({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>]`,wrap:!1}}),R=new C({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, :]`,wrap:!1}}),k=new C({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.`,wrap:!1}}),{c(){e=$("p"),e.innerHTML=c,l=m(),u(r.$$.fragment),f=m(),d=$("p"),d.innerHTML=_,U=m(),u(R.$$.fragment),I=m(),Z=$("p"),Z.textContent=F,W=m(),u(k.$$.fragment)},l(p){e=w(p,"P",{"data-svelte-h":!0}),T(e)!=="svelte-67cw7a"&&(e.innerHTML=c),l=i(p),M(r.$$.fragment,p),f=i(p),d=w(p,"P",{"data-svelte-h":!0}),T(d)!=="svelte-zykhjj"&&(d.innerHTML=_),U=i(p),M(R.$$.fragment,p),I=i(p),Z=w(p,"P",{"data-svelte-h":!0}),T(Z)!=="svelte-pa5g1"&&(Z.textContent=F),W=i(p),M(k.$$.fragment,p)},m(p,J){a(p,e,J),a(p,l,J),g(r,p,J),a(p,f,J),a(p,d,J),a(p,U,J),g(R,p,J),a(p,I,J),a(p,Z,J),a(p,W,J),g(k,p,J),V=!0},p:ss,i(p){V||(y(r.$$.fragment,p),y(R.$$.fragment,p),y(k.$$.fragment,p),V=!0)},o(p){j(r.$$.fragment,p),j(R.$$.fragment,p),j(k.$$.fragment,p),V=!1},d(p){p&&(t(e),t(l),t(f),t(d),t(U),t(I),t(Z),t(W)),b(r,p),b(R,p),b(k,p)}}}function Mt(G){let e,c;return e=new Cs({props:{$$slots:{default:[ut]},$$scope:{ctx:G}}}),{c(){u(e.$$.fragment)},l(l){M(e.$$.fragment,l)},m(l,r){g(e,l,r),c=!0},p(l,r){const f={};r&2&&(f.$$scope={dirty:r,ctx:l}),e.$set(f)},i(l){c||(y(e.$$.fragment,l),c=!0)},o(l){j(e.$$.fragment,l),c=!1},d(l){b(e,l)}}}function gt(G){let e,c,l,r,f,d,_,U,R,I,Z,F=`마스킹된 언어 모델링은 시퀀스에서 마스킹된 토큰을 예측하며, 모델은 양방향으로 토큰에 액세스할 수 있습니다.
즉, 모델은 토큰의 왼쪽과 오른쪽 양쪽에서 접근할 수 있습니다.
마스킹된 언어 모델링은 전체 시퀀스에 대한 문맥적 이해가 필요한 작업에 적합하며, BERT가 그 예에 해당합니다.`,W,k,V="이번 가이드에서 다룰 내용은 다음과 같습니다:",p,J,H='<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>',z,X,Y,N,Q="시작하기 전에 필요한 라이브러리가 모두 설치되어 있는지 확인하세요:",E,B,h,v,L="Hugging Face 계정에 로그인하여 모델을 업로드하고 커뮤니티와의 공유를 권장합니다. 메시지가 표시되면(When prompted) 토큰을 입력하여 로그인합니다:",S,A,es,q,o,x,Is=`먼저 🤗 Datasets 라이브러리에서 ELI5 데이터 세트의 r/askscience 중 일부만 가져옵니다.
이렇게 하면 전체 데이터 세트 학습에 더 많은 시간을 할애하기 전에 모든 것이 작동하는지 실험하고 확인할 수 있습니다.`,Xs,ts,Bs,ls,we="데이터 세트의 <code>train_asks</code>를 <code>train_test_split</code> 메소드를 사용해 훈련 데이터와 테스트 데이터로 분할합니다:",zs,as,Es,ns,Te="그리고 아래 예시를 살펴보세요:",Fs,ps,Hs,rs,_e=`많아 보일 수 있지만 실제로는 <code>text</code> 필드에만 집중하면 됩나다.
언어 모델링 작업의 멋진 점은 (비지도 학습으로) <em>다음 단어가 레이블</em>이기 때문에 레이블이 따로 필요하지 않습니다.`,Ys,os,Ns,ms,Qs,is,Je="마스킹된 언어 모델링을 위해, 다음 단계로 DistilRoBERTa 토크나이저를 가져와서 <code>text</code> 하위 필드를 처리합니다:",As,cs,Ls,hs,ke=`위의 예제에서와 마찬가지로, <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> 하위 필드를 추출합니다:`,qs,fs,Ss,ds,xe=`이제 각 하위 필드는 <code>answers</code> 접두사(prefix)로 표시된 대로 별도의 열이 되고, <code>text</code> 필드는 이제 리스트가 되었습니다.
각 문장을 개별적으로 토큰화하는 대신 리스트를 문자열로 변환하여 한번에 토큰화할 수 있습니다.`,Ps,us,Ue="다음은 각 예제에 대해 문자열로 이루어진 리스트를 <code>join</code>하고 결과를 토큰화하는 첫 번째 전처리 함수입니다:",Ds,Ms,Ks,gs,ve=`이 전처리 함수를 전체 데이터 세트에 적용하기 위해 🤗 Datasets <code>map</code> 메소드를 사용합니다.
데이터 세트의 여러 요소를 한 번에 처리하도록 <code>batched=True</code>를 설정하고 <code>num_proc</code>로 처리 횟수를 늘리면 <code>map</code> 함수의 속도를 높일 수 있습니다.
필요하지 않은 열은 제거합니다:`,Os,ys,se,js,Ze="이 데이터 세트에는 토큰 시퀀스가 포함되어 있지만 이 중 일부는 모델의 최대 입력 길이보다 깁니다.",ee,bs,Ge="이제 두 번째 전처리 함수를 사용해",te,$s,Re="<li>모든 시퀀스를 연결하고</li> <li>연결된 시퀀스를 정의한 <code>block_size</code> 보다 더 짧은 덩어리로 분할하는데, 이 덩어리는 모델의 최대 입력 길이보다 짧고 GPU RAM이 수용할 수 있는 길이여야 합니다.</li>",le,ws,ae,Ts,Ce="전체 데이터 세트에 <code>group_texts</code> 함수를 적용합니다:",ne,_s,pe,Js,Ie=`이제 <code>DataCollatorForLanguageModeling</code>을 사용하여 데이터 예제의 배치를 생성합니다.
데이터 세트 전체를 최대 길이로 패딩하는 것보다 collation 단계에서 매 배치안에서의 최대 길이로 문장을 <em>동적으로 패딩</em>하는 것이 더 효율적입니다.`,re,P,oe,ks,me,D,ie,K,ce,xs,he,Us,We="지금까지 모델 미세 조정을 잘 했으니, 추론에 사용할 수 있습니다!",fe,vs,Ve="모델이 빈칸을 채울 텍스트를 스페셜 토큰(special token)인 <code>&lt;mask&gt;</code> 토큰으로 표시합니다:",de,Zs,ue,Gs,Xe=`추론을 위해 미세 조정한 모델을 테스트하는 가장 간단한 방법은 <code>pipeline()</code>에서 사용하는 것입니다.
<code>fill-mask</code>태스크로 <code>pipeline</code>을 인스턴스화하고 텍스트를 전달합니다.
<code>top_k</code> 매개변수를 사용하여 반환하는 예측의 수를 지정할 수 있습니다:`,Me,Rs,ge,O,ye,Ws,je;return f=new Vs({props:{title:"마스킹된 언어 모델링(Masked language modeling)",local:"masked-language-modeling",headingTag:"h1"}}),_=new st({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 Qe({props:{id:"mqElG5QJWUg"}}),X=new be({props:{$$slots:{default:[et]},$$scope:{ctx:G}}}),B=new C({props:{code:"cGlwJTIwaW5zdGFsbCUyMHRyYW5zZm9ybWVycyUyMGRhdGFzZXRzJTIwZXZhbHVhdGU=",highlighted:"pip install transformers datasets evaluate",wrap:!1}}),A=new C({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()`,wrap:!1}}),q=new Vs({props:{title:"ELI5 데이터 세트 가져오기",local:"load-eli5-dataset",headingTag:"h2"}}),ts=new C({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>)`,wrap:!1}}),as=new C({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>)',wrap:!1}}),ps=new C({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>: []}}`,wrap:!1}}),os=new Vs({props:{title:"전처리",local:"preprocess",headingTag:"h2"}}),ms=new Qe({props:{id:"8PmhEIXhBvI"}}),cs=new C({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>)`,wrap:!1}}),fs=new C({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>: []}`,wrap:!1}}),Ms=new C({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>]])`,wrap:!1}}),ys=new C({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>)`,wrap:!1}}),ws=new C({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`,wrap:!1}}),_s=new C({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>)',wrap:!1}}),P=new $e({props:{pytorch:!0,tensorflow:!0,jax:!1,$$slots:{tensorflow:[nt],pytorch:[lt]},$$scope:{ctx:G}}}),ks=new Vs({props:{title:"훈련",local:"train",headingTag:"h2"}}),D=new $e({props:{pytorch:!0,tensorflow:!0,jax:!1,$$slots:{tensorflow:[ct],pytorch:[ot]},$$scope:{ctx:G}}}),K=new be({props:{$$slots:{default:[ht]},$$scope:{ctx:G}}}),xs=new Vs({props:{title:"추론",local:"inference",headingTag:"h2"}}),Zs=new C({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>',wrap:!1}}),Rs=new C({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>}]`,wrap:!1}}),O=new $e({props:{pytorch:!0,tensorflow:!0,jax:!1,$$slots:{tensorflow:[Mt],pytorch:[dt]},$$scope:{ctx:G}}}),{c(){e=$("meta"),c=m(),l=$("p"),r=m(),u(f.$$.fragment),d=m(),u(_.$$.fragment),U=m(),u(R.$$.fragment),I=m(),Z=$("p"),Z.textContent=F,W=m(),k=$("p"),k.textContent=V,p=m(),J=$("ol"),J.innerHTML=H,z=m(),u(X.$$.fragment),Y=m(),N=$("p"),N.textContent=Q,E=m(),u(B.$$.fragment),h=m(),v=$("p"),v.textContent=L,S=m(),u(A.$$.fragment),es=m(),u(q.$$.fragment),o=m(),x=$("p"),x.textContent=Is,Xs=m(),u(ts.$$.fragment),Bs=m(),ls=$("p"),ls.innerHTML=we,zs=m(),u(as.$$.fragment),Es=m(),ns=$("p"),ns.textContent=Te,Fs=m(),u(ps.$$.fragment),Hs=m(),rs=$("p"),rs.innerHTML=_e,Ys=m(),u(os.$$.fragment),Ns=m(),u(ms.$$.fragment),Qs=m(),is=$("p"),is.innerHTML=Je,As=m(),u(cs.$$.fragment),Ls=m(),hs=$("p"),hs.innerHTML=ke,qs=m(),u(fs.$$.fragment),Ss=m(),ds=$("p"),ds.innerHTML=xe,Ps=m(),us=$("p"),us.innerHTML=Ue,Ds=m(),u(Ms.$$.fragment),Ks=m(),gs=$("p"),gs.innerHTML=ve,Os=m(),u(ys.$$.fragment),se=m(),js=$("p"),js.textContent=Ze,ee=m(),bs=$("p"),bs.textContent=Ge,te=m(),$s=$("ul"),$s.innerHTML=Re,le=m(),u(ws.$$.fragment),ae=m(),Ts=$("p"),Ts.innerHTML=Ce,ne=m(),u(_s.$$.fragment),pe=m(),Js=$("p"),Js.innerHTML=Ie,re=m(),u(P.$$.fragment),oe=m(),u(ks.$$.fragment),me=m(),u(D.$$.fragment),ie=m(),u(K.$$.fragment),ce=m(),u(xs.$$.fragment),he=m(),Us=$("p"),Us.textContent=We,fe=m(),vs=$("p"),vs.innerHTML=Ve,de=m(),u(Zs.$$.fragment),ue=m(),Gs=$("p"),Gs.innerHTML=Xe,Me=m(),u(Rs.$$.fragment),ge=m(),u(O.$$.fragment),ye=m(),Ws=$("p"),this.h()},l(s){const n=Ke("svelte-u9bgzb",document.head);e=w(n,"META",{name:!0,content:!0}),n.forEach(t),c=i(s),l=w(s,"P",{}),Ye(l).forEach(t),r=i(s),M(f.$$.fragment,s),d=i(s),M(_.$$.fragment,s),U=i(s),M(R.$$.fragment,s),I=i(s),Z=w(s,"P",{"data-svelte-h":!0}),T(Z)!=="svelte-1n9q4rf"&&(Z.textContent=F),W=i(s),k=w(s,"P",{"data-svelte-h":!0}),T(k)!=="svelte-ccgtvl"&&(k.textContent=V),p=i(s),J=w(s,"OL",{"data-svelte-h":!0}),T(J)!=="svelte-1vo3ofa"&&(J.innerHTML=H),z=i(s),M(X.$$.fragment,s),Y=i(s),N=w(s,"P",{"data-svelte-h":!0}),T(N)!=="svelte-1k0z9pm"&&(N.textContent=Q),E=i(s),M(B.$$.fragment,s),h=i(s),v=w(s,"P",{"data-svelte-h":!0}),T(v)!=="svelte-m2mub0"&&(v.textContent=L),S=i(s),M(A.$$.fragment,s),es=i(s),M(q.$$.fragment,s),o=i(s),x=w(s,"P",{"data-svelte-h":!0}),T(x)!=="svelte-vr9p67"&&(x.textContent=Is),Xs=i(s),M(ts.$$.fragment,s),Bs=i(s),ls=w(s,"P",{"data-svelte-h":!0}),T(ls)!=="svelte-297gyr"&&(ls.innerHTML=we),zs=i(s),M(as.$$.fragment,s),Es=i(s),ns=w(s,"P",{"data-svelte-h":!0}),T(ns)!=="svelte-1aqlhyu"&&(ns.textContent=Te),Fs=i(s),M(ps.$$.fragment,s),Hs=i(s),rs=w(s,"P",{"data-svelte-h":!0}),T(rs)!=="svelte-1cy2b9o"&&(rs.innerHTML=_e),Ys=i(s),M(os.$$.fragment,s),Ns=i(s),M(ms.$$.fragment,s),Qs=i(s),is=w(s,"P",{"data-svelte-h":!0}),T(is)!=="svelte-1a969tz"&&(is.innerHTML=Je),As=i(s),M(cs.$$.fragment,s),Ls=i(s),hs=w(s,"P",{"data-svelte-h":!0}),T(hs)!=="svelte-1p65oj6"&&(hs.innerHTML=ke),qs=i(s),M(fs.$$.fragment,s),Ss=i(s),ds=w(s,"P",{"data-svelte-h":!0}),T(ds)!=="svelte-1tsflso"&&(ds.innerHTML=xe),Ps=i(s),us=w(s,"P",{"data-svelte-h":!0}),T(us)!=="svelte-1ry86e0"&&(us.innerHTML=Ue),Ds=i(s),M(Ms.$$.fragment,s),Ks=i(s),gs=w(s,"P",{"data-svelte-h":!0}),T(gs)!=="svelte-hhkhvj"&&(gs.innerHTML=ve),Os=i(s),M(ys.$$.fragment,s),se=i(s),js=w(s,"P",{"data-svelte-h":!0}),T(js)!=="svelte-2gfwha"&&(js.textContent=Ze),ee=i(s),bs=w(s,"P",{"data-svelte-h":!0}),T(bs)!=="svelte-dy2yct"&&(bs.textContent=Ge),te=i(s),$s=w(s,"UL",{"data-svelte-h":!0}),T($s)!=="svelte-1t9aqgv"&&($s.innerHTML=Re),le=i(s),M(ws.$$.fragment,s),ae=i(s),Ts=w(s,"P",{"data-svelte-h":!0}),T(Ts)!=="svelte-by0nu8"&&(Ts.innerHTML=Ce),ne=i(s),M(_s.$$.fragment,s),pe=i(s),Js=w(s,"P",{"data-svelte-h":!0}),T(Js)!=="svelte-izyzcu"&&(Js.innerHTML=Ie),re=i(s),M(P.$$.fragment,s),oe=i(s),M(ks.$$.fragment,s),me=i(s),M(D.$$.fragment,s),ie=i(s),M(K.$$.fragment,s),ce=i(s),M(xs.$$.fragment,s),he=i(s),Us=w(s,"P",{"data-svelte-h":!0}),T(Us)!=="svelte-8jfat8"&&(Us.textContent=We),fe=i(s),vs=w(s,"P",{"data-svelte-h":!0}),T(vs)!=="svelte-9tmh7v"&&(vs.innerHTML=Ve),de=i(s),M(Zs.$$.fragment,s),ue=i(s),Gs=w(s,"P",{"data-svelte-h":!0}),T(Gs)!=="svelte-1pw875r"&&(Gs.innerHTML=Xe),Me=i(s),M(Rs.$$.fragment,s),ge=i(s),M(O.$$.fragment,s),ye=i(s),Ws=w(s,"P",{}),Ye(Ws).forEach(t),this.h()},h(){Ne(e,"name","hf:doc:metadata"),Ne(e,"content",yt)},m(s,n){Oe(document.head,e),a(s,c,n),a(s,l,n),a(s,r,n),g(f,s,n),a(s,d,n),g(_,s,n),a(s,U,n),g(R,s,n),a(s,I,n),a(s,Z,n),a(s,W,n),a(s,k,n),a(s,p,n),a(s,J,n),a(s,z,n),g(X,s,n),a(s,Y,n),a(s,N,n),a(s,E,n),g(B,s,n),a(s,h,n),a(s,v,n),a(s,S,n),g(A,s,n),a(s,es,n),g(q,s,n),a(s,o,n),a(s,x,n),a(s,Xs,n),g(ts,s,n),a(s,Bs,n),a(s,ls,n),a(s,zs,n),g(as,s,n),a(s,Es,n),a(s,ns,n),a(s,Fs,n),g(ps,s,n),a(s,Hs,n),a(s,rs,n),a(s,Ys,n),g(os,s,n),a(s,Ns,n),g(ms,s,n),a(s,Qs,n),a(s,is,n),a(s,As,n),g(cs,s,n),a(s,Ls,n),a(s,hs,n),a(s,qs,n),g(fs,s,n),a(s,Ss,n),a(s,ds,n),a(s,Ps,n),a(s,us,n),a(s,Ds,n),g(Ms,s,n),a(s,Ks,n),a(s,gs,n),a(s,Os,n),g(ys,s,n),a(s,se,n),a(s,js,n),a(s,ee,n),a(s,bs,n),a(s,te,n),a(s,$s,n),a(s,le,n),g(ws,s,n),a(s,ae,n),a(s,Ts,n),a(s,ne,n),g(_s,s,n),a(s,pe,n),a(s,Js,n),a(s,re,n),g(P,s,n),a(s,oe,n),g(ks,s,n),a(s,me,n),g(D,s,n),a(s,ie,n),g(K,s,n),a(s,ce,n),g(xs,s,n),a(s,he,n),a(s,Us,n),a(s,fe,n),a(s,vs,n),a(s,de,n),g(Zs,s,n),a(s,ue,n),a(s,Gs,n),a(s,Me,n),g(Rs,s,n),a(s,ge,n),g(O,s,n),a(s,ye,n),a(s,Ws,n),je=!0},p(s,[n]){const Be={};n&2&&(Be.$$scope={dirty:n,ctx:s}),X.$set(Be);const ze={};n&2&&(ze.$$scope={dirty:n,ctx:s}),P.$set(ze);const Ee={};n&2&&(Ee.$$scope={dirty:n,ctx:s}),D.$set(Ee);const Fe={};n&2&&(Fe.$$scope={dirty:n,ctx:s}),K.$set(Fe);const He={};n&2&&(He.$$scope={dirty:n,ctx:s}),O.$set(He)},i(s){je||(y(f.$$.fragment,s),y(_.$$.fragment,s),y(R.$$.fragment,s),y(X.$$.fragment,s),y(B.$$.fragment,s),y(A.$$.fragment,s),y(q.$$.fragment,s),y(ts.$$.fragment,s),y(as.$$.fragment,s),y(ps.$$.fragment,s),y(os.$$.fragment,s),y(ms.$$.fragment,s),y(cs.$$.fragment,s),y(fs.$$.fragment,s),y(Ms.$$.fragment,s),y(ys.$$.fragment,s),y(ws.$$.fragment,s),y(_s.$$.fragment,s),y(P.$$.fragment,s),y(ks.$$.fragment,s),y(D.$$.fragment,s),y(K.$$.fragment,s),y(xs.$$.fragment,s),y(Zs.$$.fragment,s),y(Rs.$$.fragment,s),y(O.$$.fragment,s),je=!0)},o(s){j(f.$$.fragment,s),j(_.$$.fragment,s),j(R.$$.fragment,s),j(X.$$.fragment,s),j(B.$$.fragment,s),j(A.$$.fragment,s),j(q.$$.fragment,s),j(ts.$$.fragment,s),j(as.$$.fragment,s),j(ps.$$.fragment,s),j(os.$$.fragment,s),j(ms.$$.fragment,s),j(cs.$$.fragment,s),j(fs.$$.fragment,s),j(Ms.$$.fragment,s),j(ys.$$.fragment,s),j(ws.$$.fragment,s),j(_s.$$.fragment,s),j(P.$$.fragment,s),j(ks.$$.fragment,s),j(D.$$.fragment,s),j(K.$$.fragment,s),j(xs.$$.fragment,s),j(Zs.$$.fragment,s),j(Rs.$$.fragment,s),j(O.$$.fragment,s),je=!1},d(s){s&&(t(c),t(l),t(r),t(d),t(U),t(I),t(Z),t(W),t(k),t(p),t(J),t(z),t(Y),t(N),t(E),t(h),t(v),t(S),t(es),t(o),t(x),t(Xs),t(Bs),t(ls),t(zs),t(Es),t(ns),t(Fs),t(Hs),t(rs),t(Ys),t(Ns),t(Qs),t(is),t(As),t(Ls),t(hs),t(qs),t(Ss),t(ds),t(Ps),t(us),t(Ds),t(Ks),t(gs),t(Os),t(se),t(js),t(ee),t(bs),t(te),t($s),t(le),t(ae),t(Ts),t(ne),t(pe),t(Js),t(re),t(oe),t(me),t(ie),t(ce),t(he),t(Us),t(fe),t(vs),t(de),t(ue),t(Gs),t(Me),t(ge),t(ye),t(Ws)),t(e),b(f,s),b(_,s),b(R,s),b(X,s),b(B,s),b(A,s),b(q,s),b(ts,s),b(as,s),b(ps,s),b(os,s),b(ms,s),b(cs,s),b(fs,s),b(Ms,s),b(ys,s),b(ws,s),b(_s,s),b(P,s),b(ks,s),b(D,s),b(K,s),b(xs,s),b(Zs,s),b(Rs,s),b(O,s)}}}const yt='{"title":"마스킹된 언어 모델링(Masked language modeling)","local":"masked-language-modeling","sections":[{"title":"ELI5 데이터 세트 가져오기","local":"load-eli5-dataset","sections":[],"depth":2},{"title":"전처리","local":"preprocess","sections":[],"depth":2},{"title":"훈련","local":"train","sections":[],"depth":2},{"title":"추론","local":"inference","sections":[],"depth":2}],"depth":1}';function jt(G){return Se(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class Ut extends Pe{constructor(e){super(),De(this,e,jt,gt,qe,{})}}export{Ut as component};
