import{s as Ws,o as Bs,n as he}from"../chunks/scheduler.9bc65507.js";import{S as Xs,i as Vs,g as d,s as p,u as M,A as zs,h as f,f as t,c as i,j as Y,v as y,y as k,k as X,o as V,a,w as b,d as j,t as w,x as $,m as Rs,n as Is}from"../chunks/index.78c82d43.js";import{T as Kt}from"../chunks/Tip.87d55b76.js";import{Y as Gs}from"../chunks/Youtube.b19762b6.js";import{I as it}from"../chunks/IconCopyLink.bedaa44d.js";import{C as Z}from"../chunks/CodeBlock.73e038be.js";import{D as Es}from"../chunks/DocNotebookDropdown.31840a23.js";import{F as as,M as et}from"../chunks/Markdown.1b9b4e1c.js";function Fs(v){let s,h,l='<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/mra">MRA</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(){s=Rs(`You can finetune other architectures for masked language modeling following the same steps in this guide.
Choose one of the following architectures:

`),h=d("p"),h.innerHTML=l},l(r){s=Is(r,`You can finetune other architectures for masked language modeling following the same steps in this guide.
Choose one of the following architectures:

`),h=f(r,"P",{"data-svelte-h":!0}),k(h)!=="svelte-e35b6o"&&(h.innerHTML=l)},m(r,g){a(r,s,g),a(r,h,g)},p:he,d(r){r&&(t(s),t(h))}}}function Hs(v){let s,h="Use the end-of-sequence token as the padding token and specify <code>mlm_probability</code> to randomly mask tokens each time you iterate over the data:",l,r,g;return r=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>)`,wrap:!1}}),{c(){s=d("p"),s.innerHTML=h,l=p(),M(r.$$.fragment)},l(u){s=f(u,"P",{"data-svelte-h":!0}),k(s)!=="svelte-z8dnpj"&&(s.innerHTML=h),l=i(u),y(r.$$.fragment,u)},m(u,R){a(u,s,R),a(u,l,R),b(r,u,R),g=!0},p:he,i(u){g||(j(r.$$.fragment,u),g=!0)},o(u){w(r.$$.fragment,u),g=!1},d(u){u&&(t(s),t(l)),$(r,u)}}}function As(v){let s,h;return s=new et({props:{$$slots:{default:[Hs]},$$scope:{ctx:v}}}),{c(){M(s.$$.fragment)},l(l){y(s.$$.fragment,l)},m(l,r){b(s,l,r),h=!0},p(l,r){const g={};r&2&&(g.$$scope={dirty:r,ctx:l}),s.$set(g)},i(l){h||(j(s.$$.fragment,l),h=!0)},o(l){w(s.$$.fragment,l),h=!1},d(l){$(s,l)}}}function Ns(v){let s,h="Use the end-of-sequence token as the padding token and specify <code>mlm_probability</code> to randomly mask tokens each time you iterate over the data:",l,r,g;return r=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>)`,wrap:!1}}),{c(){s=d("p"),s.innerHTML=h,l=p(),M(r.$$.fragment)},l(u){s=f(u,"P",{"data-svelte-h":!0}),k(s)!=="svelte-z8dnpj"&&(s.innerHTML=h),l=i(u),y(r.$$.fragment,u)},m(u,R){a(u,s,R),a(u,l,R),b(r,u,R),g=!0},p:he,i(u){g||(j(r.$$.fragment,u),g=!0)},o(u){w(r.$$.fragment,u),g=!1},d(u){u&&(t(s),t(l)),$(r,u)}}}function Ys(v){let s,h;return s=new et({props:{$$slots:{default:[Ns]},$$scope:{ctx:v}}}),{c(){M(s.$$.fragment)},l(l){y(s.$$.fragment,l)},m(l,r){b(s,l,r),h=!0},p(l,r){const g={};r&2&&(g.$$scope={dirty:r,ctx:l}),s.$set(g)},i(l){h||(j(s.$$.fragment,l),h=!0)},o(l){w(s.$$.fragment,l),h=!1},d(l){$(s,l)}}}function Qs(v){let s,h='If you aren’t familiar with finetuning a model with the <a href="/docs/transformers/v4.34.0/en/main_classes/trainer#transformers.Trainer">Trainer</a>, take a look at the basic tutorial <a href="../training#train-with-pytorch-trainer">here</a>!';return{c(){s=d("p"),s.innerHTML=h},l(l){s=f(l,"P",{"data-svelte-h":!0}),k(s)!=="svelte-1ufp0ay"&&(s.innerHTML=h)},m(l,r){a(l,s,r)},p:he,d(l){l&&t(s)}}}function Ls(v){let s,h,l,r='You’re ready to start training your model now! Load DistilRoBERTa with <a href="/docs/transformers/v4.34.0/en/model_doc/auto#transformers.AutoModelForMaskedLM">AutoModelForMaskedLM</a>:',g,u,R,_,B="At this point, only three steps remain:",I,W,F='<li>Define your training hyperparameters in <a href="/docs/transformers/v4.34.0/en/main_classes/trainer#transformers.TrainingArguments">TrainingArguments</a>. The only required parameter is <code>output_dir</code> which specifies where to save your model. You’ll push this model to the Hub by setting <code>push_to_hub=True</code> (you need to be signed in to Hugging Face to upload your model).</li> <li>Pass the training arguments to <a href="/docs/transformers/v4.34.0/en/main_classes/trainer#transformers.Trainer">Trainer</a> along with the model, datasets, and data collator.</li> <li>Call <a href="/docs/transformers/v4.34.0/en/main_classes/trainer#transformers.Trainer.train">train()</a> to finetune your model.</li>',C,x,G,o,T='Once training is completed, use the <a href="/docs/transformers/v4.34.0/en/main_classes/trainer#transformers.Trainer.evaluate">evaluate()</a> method to evaluate your model and get its perplexity:',Q,A,z,q,S='Then share your model to the Hub with the <a href="/docs/transformers/v4.34.0/en/main_classes/trainer#transformers.Trainer.push_to_hub">push_to_hub()</a> method so everyone can use your model:',E,L,N;return s=new Kt({props:{$$slots:{default:[Qs]},$$scope:{ctx:v}}}),u=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>)`,wrap:!1}}),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()`,wrap:!1}}),A=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>`,wrap:!1}}),L=new Z({props:{code:"dHJhaW5lci5wdXNoX3RvX2h1Yigp",highlighted:'<span class="hljs-meta">&gt;&gt;&gt; </span>trainer.push_to_hub()',wrap:!1}}),{c(){M(s.$$.fragment),h=p(),l=d("p"),l.innerHTML=r,g=p(),M(u.$$.fragment),R=p(),_=d("p"),_.textContent=B,I=p(),W=d("ol"),W.innerHTML=F,C=p(),M(x.$$.fragment),G=p(),o=d("p"),o.innerHTML=T,Q=p(),M(A.$$.fragment),z=p(),q=d("p"),q.innerHTML=S,E=p(),M(L.$$.fragment)},l(c){y(s.$$.fragment,c),h=i(c),l=f(c,"P",{"data-svelte-h":!0}),k(l)!=="svelte-1vthcgg"&&(l.innerHTML=r),g=i(c),y(u.$$.fragment,c),R=i(c),_=f(c,"P",{"data-svelte-h":!0}),k(_)!=="svelte-l42k0i"&&(_.textContent=B),I=i(c),W=f(c,"OL",{"data-svelte-h":!0}),k(W)!=="svelte-6uyzj4"&&(W.innerHTML=F),C=i(c),y(x.$$.fragment,c),G=i(c),o=f(c,"P",{"data-svelte-h":!0}),k(o)!=="svelte-1h6sduc"&&(o.innerHTML=T),Q=i(c),y(A.$$.fragment,c),z=i(c),q=f(c,"P",{"data-svelte-h":!0}),k(q)!=="svelte-xx2cfv"&&(q.innerHTML=S),E=i(c),y(L.$$.fragment,c)},m(c,J){b(s,c,J),a(c,h,J),a(c,l,J),a(c,g,J),b(u,c,J),a(c,R,J),a(c,_,J),a(c,I,J),a(c,W,J),a(c,C,J),b(x,c,J),a(c,G,J),a(c,o,J),a(c,Q,J),b(A,c,J),a(c,z,J),a(c,q,J),a(c,E,J),b(L,c,J),N=!0},p(c,J){const H={};J&2&&(H.$$scope={dirty:J,ctx:c}),s.$set(H)},i(c){N||(j(s.$$.fragment,c),j(u.$$.fragment,c),j(x.$$.fragment,c),j(A.$$.fragment,c),j(L.$$.fragment,c),N=!0)},o(c){w(s.$$.fragment,c),w(u.$$.fragment,c),w(x.$$.fragment,c),w(A.$$.fragment,c),w(L.$$.fragment,c),N=!1},d(c){c&&(t(h),t(l),t(g),t(R),t(_),t(I),t(W),t(C),t(G),t(o),t(Q),t(z),t(q),t(E)),$(s,c),$(u,c),$(x,c),$(A,c),$(L,c)}}}function qs(v){let s,h;return s=new et({props:{$$slots:{default:[Ls]},$$scope:{ctx:v}}}),{c(){M(s.$$.fragment)},l(l){y(s.$$.fragment,l)},m(l,r){b(s,l,r),h=!0},p(l,r){const g={};r&2&&(g.$$scope={dirty:r,ctx:l}),s.$set(g)},i(l){h||(j(s.$$.fragment,l),h=!0)},o(l){w(s.$$.fragment,l),h=!1},d(l){$(s,l)}}}function Ss(v){let s,h='If you aren’t familiar with finetuning a model with Keras, take a look at the basic tutorial <a href="../training#train-a-tensorflow-model-with-keras">here</a>!';return{c(){s=d("p"),s.innerHTML=h},l(l){s=f(l,"P",{"data-svelte-h":!0}),k(s)!=="svelte-1rd4nl8"&&(s.innerHTML=h)},m(l,r){a(l,s,r)},p:he,d(l){l&&t(s)}}}function Ps(v){let s,h,l,r,g,u='Then you can load DistilRoBERTa with <a href="/docs/transformers/v4.34.0/en/model_doc/auto#transformers.TFAutoModelForMaskedLM">TFAutoModelForMaskedLM</a>:',R,_,B,I,W='Convert your datasets to the <code>tf.data.Dataset</code> format with <a href="/docs/transformers/v4.34.0/en/main_classes/model#transformers.TFPreTrainedModel.prepare_tf_dataset">prepare_tf_dataset()</a>:',F,C,x,G,o='Configure the model for training with <a href="https://keras.io/api/models/model_training_apis/#compile-method" rel="nofollow"><code>compile</code></a>. Note that Transformers models all have a default task-relevant loss function, so you don’t need to specify one unless you want to:',T,Q,A,z,q='This can be done by specifying where to push your model and tokenizer in the <a href="/docs/transformers/v4.34.0/en/main_classes/keras_callbacks#transformers.PushToHubCallback">PushToHubCallback</a>:',S,E,L,N,c='Finally, you’re ready to start training your model! Call <a href="https://keras.io/api/models/model_training_apis/#fit-method" rel="nofollow"><code>fit</code></a> with your training and validation datasets, the number of epochs, and your callback to finetune the model:',J,H,ce,P,D="Once training is completed, your model is automatically uploaded to the Hub so everyone can use it!",K;return s=new Kt({props:{$$slots:{default:[Ss]},$$scope:{ctx:v}}}),l=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>)`,wrap:!1}}),_=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>)`,wrap:!1}}),C=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>)`,wrap:!1}}),Q=new Z({props:{code:"aW1wb3J0JTIwdGVuc29yZmxvdyUyMGFzJTIwdGYlMEElMEFtb2RlbC5jb21waWxlKG9wdGltaXplciUzRG9wdGltaXplciklMjAlMjAlMjMlMjBObyUyMGxvc3MlMjBhcmd1bWVudCE=",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)  <span class="hljs-comment"># No loss argument!</span>`,wrap:!1}}),E=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>)`,wrap:!1}}),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])',wrap:!1}}),{c(){M(s.$$.fragment),h=Rs(`
To finetune a model in TensorFlow, start by setting up an optimizer function, learning rate schedule, and some training hyperparameters:

	`),M(l.$$.fragment),r=p(),g=d("p"),g.innerHTML=u,R=p(),M(_.$$.fragment),B=p(),I=d("p"),I.innerHTML=W,F=p(),M(C.$$.fragment),x=p(),G=d("p"),G.innerHTML=o,T=p(),M(Q.$$.fragment),A=p(),z=d("p"),z.innerHTML=q,S=p(),M(E.$$.fragment),L=p(),N=d("p"),N.innerHTML=c,J=p(),M(H.$$.fragment),ce=p(),P=d("p"),P.textContent=D},l(m){y(s.$$.fragment,m),h=Is(m,`
To finetune a model in TensorFlow, start by setting up an optimizer function, learning rate schedule, and some training hyperparameters:

	`),y(l.$$.fragment,m),r=i(m),g=f(m,"P",{"data-svelte-h":!0}),k(g)!=="svelte-17rpkxm"&&(g.innerHTML=u),R=i(m),y(_.$$.fragment,m),B=i(m),I=f(m,"P",{"data-svelte-h":!0}),k(I)!=="svelte-qmwuyd"&&(I.innerHTML=W),F=i(m),y(C.$$.fragment,m),x=i(m),G=f(m,"P",{"data-svelte-h":!0}),k(G)!=="svelte-17cxx5e"&&(G.innerHTML=o),T=i(m),y(Q.$$.fragment,m),A=i(m),z=f(m,"P",{"data-svelte-h":!0}),k(z)!=="svelte-ufj5fr"&&(z.innerHTML=q),S=i(m),y(E.$$.fragment,m),L=i(m),N=f(m,"P",{"data-svelte-h":!0}),k(N)!=="svelte-1pfsro2"&&(N.innerHTML=c),J=i(m),y(H.$$.fragment,m),ce=i(m),P=f(m,"P",{"data-svelte-h":!0}),k(P)!=="svelte-2s71om"&&(P.textContent=D)},m(m,U){b(s,m,U),a(m,h,U),b(l,m,U),a(m,r,U),a(m,g,U),a(m,R,U),b(_,m,U),a(m,B,U),a(m,I,U),a(m,F,U),b(C,m,U),a(m,x,U),a(m,G,U),a(m,T,U),b(Q,m,U),a(m,A,U),a(m,z,U),a(m,S,U),b(E,m,U),a(m,L,U),a(m,N,U),a(m,J,U),b(H,m,U),a(m,ce,U),a(m,P,U),K=!0},p(m,U){const de={};U&2&&(de.$$scope={dirty:U,ctx:m}),s.$set(de)},i(m){K||(j(s.$$.fragment,m),j(l.$$.fragment,m),j(_.$$.fragment,m),j(C.$$.fragment,m),j(Q.$$.fragment,m),j(E.$$.fragment,m),j(H.$$.fragment,m),K=!0)},o(m){w(s.$$.fragment,m),w(l.$$.fragment,m),w(_.$$.fragment,m),w(C.$$.fragment,m),w(Q.$$.fragment,m),w(E.$$.fragment,m),w(H.$$.fragment,m),K=!1},d(m){m&&(t(h),t(r),t(g),t(R),t(B),t(I),t(F),t(x),t(G),t(T),t(A),t(z),t(S),t(L),t(N),t(J),t(ce),t(P)),$(s,m),$(l,m),$(_,m),$(C,m),$(Q,m),$(E,m),$(H,m)}}}function Ds(v){let s,h;return s=new et({props:{$$slots:{default:[Ps]},$$scope:{ctx:v}}}),{c(){M(s.$$.fragment)},l(l){y(s.$$.fragment,l)},m(l,r){b(s,l,r),h=!0},p(l,r){const g={};r&2&&(g.$$scope={dirty:r,ctx:l}),s.$set(g)},i(l){h||(j(s.$$.fragment,l),h=!0)},o(l){w(s.$$.fragment,l),h=!1},d(l){$(s,l)}}}function Ks(v){let s,h=`For a more in-depth example of how to finetune a model for masked language modeling, take a look at the corresponding
<a href="https://colab.research.google.com/github/huggingface/notebooks/blob/main/examples/language_modeling.ipynb" rel="nofollow">PyTorch notebook</a>
or <a href="https://colab.research.google.com/github/huggingface/notebooks/blob/main/examples/language_modeling-tf.ipynb" rel="nofollow">TensorFlow notebook</a>.`;return{c(){s=d("p"),s.innerHTML=h},l(l){s=f(l,"P",{"data-svelte-h":!0}),k(s)!=="svelte-1c4g6cv"&&(s.innerHTML=h)},m(l,r){a(l,s,r)},p:he,d(l){l&&t(s)}}}function Os(v){let s,h="Tokenize the text and return the <code>input_ids</code> as PyTorch tensors. You’ll also need to specify the position of the <code>&lt;mask&gt;</code> token:",l,r,g,u,R="Pass your inputs to the model and return the <code>logits</code> of the masked token:",_,B,I,W,F="Then return the three masked tokens with the highest probability and print them out:",C,x,G;return r=new Z({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMEF1dG9Ub2tlbml6ZXIlMEElMEF0b2tlbml6ZXIlMjAlM0QlMjBBdXRvVG9rZW5pemVyLmZyb21fcHJldHJhaW5lZCglMjJzdGV2aGxpdSUyRm15X2F3ZXNvbWVfZWxpNV9tbG1fbW9kZWwlMjIpJTBBaW5wdXRzJTIwJTNEJTIwdG9rZW5pemVyKHRleHQlMkMlMjByZXR1cm5fdGVuc29ycyUzRCUyMnB0JTIyKSUwQW1hc2tfdG9rZW5faW5kZXglMjAlM0QlMjB0b3JjaC53aGVyZShpbnB1dHMlNUIlMjJpbnB1dF9pZHMlMjIlNUQlMjAlM0QlM0QlMjB0b2tlbml6ZXIubWFza190b2tlbl9pZCklNUIxJTVE",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;stevhliu/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}}),B=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, :]`,wrap:!1}}),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.`,wrap:!1}}),{c(){s=d("p"),s.innerHTML=h,l=p(),M(r.$$.fragment),g=p(),u=d("p"),u.innerHTML=R,_=p(),M(B.$$.fragment),I=p(),W=d("p"),W.textContent=F,C=p(),M(x.$$.fragment)},l(o){s=f(o,"P",{"data-svelte-h":!0}),k(s)!=="svelte-1rt88cg"&&(s.innerHTML=h),l=i(o),y(r.$$.fragment,o),g=i(o),u=f(o,"P",{"data-svelte-h":!0}),k(u)!=="svelte-1abk23t"&&(u.innerHTML=R),_=i(o),y(B.$$.fragment,o),I=i(o),W=f(o,"P",{"data-svelte-h":!0}),k(W)!=="svelte-jux2mn"&&(W.textContent=F),C=i(o),y(x.$$.fragment,o)},m(o,T){a(o,s,T),a(o,l,T),b(r,o,T),a(o,g,T),a(o,u,T),a(o,_,T),b(B,o,T),a(o,I,T),a(o,W,T),a(o,C,T),b(x,o,T),G=!0},p:he,i(o){G||(j(r.$$.fragment,o),j(B.$$.fragment,o),j(x.$$.fragment,o),G=!0)},o(o){w(r.$$.fragment,o),w(B.$$.fragment,o),w(x.$$.fragment,o),G=!1},d(o){o&&(t(s),t(l),t(g),t(u),t(_),t(I),t(W),t(C)),$(r,o),$(B,o),$(x,o)}}}function ea(v){let s,h;return s=new et({props:{$$slots:{default:[Os]},$$scope:{ctx:v}}}),{c(){M(s.$$.fragment)},l(l){y(s.$$.fragment,l)},m(l,r){b(s,l,r),h=!0},p(l,r){const g={};r&2&&(g.$$scope={dirty:r,ctx:l}),s.$set(g)},i(l){h||(j(s.$$.fragment,l),h=!0)},o(l){w(s.$$.fragment,l),h=!1},d(l){$(s,l)}}}function ta(v){let s,h="Tokenize the text and return the <code>input_ids</code> as TensorFlow tensors. You’ll also need to specify the position of the <code>&lt;mask&gt;</code> token:",l,r,g,u,R="Pass your inputs to the model and return the <code>logits</code> of the masked token:",_,B,I,W,F="Then return the three masked tokens with the highest probability and print them out:",C,x,G;return r=new Z({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMEF1dG9Ub2tlbml6ZXIlMEElMEF0b2tlbml6ZXIlMjAlM0QlMjBBdXRvVG9rZW5pemVyLmZyb21fcHJldHJhaW5lZCglMjJzdGV2aGxpdSUyRm15X2F3ZXNvbWVfZWxpNV9tbG1fbW9kZWwlMjIpJTBBaW5wdXRzJTIwJTNEJTIwdG9rZW5pemVyKHRleHQlMkMlMjByZXR1cm5fdGVuc29ycyUzRCUyMnRmJTIyKSUwQW1hc2tfdG9rZW5faW5kZXglMjAlM0QlMjB0Zi53aGVyZShpbnB1dHMlNUIlMjJpbnB1dF9pZHMlMjIlNUQlMjAlM0QlM0QlMjB0b2tlbml6ZXIubWFza190b2tlbl9pZCklNUIwJTJDJTIwMSU1RA==",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;stevhliu/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}}),B=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, :]`,wrap:!1}}),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.`,wrap:!1}}),{c(){s=d("p"),s.innerHTML=h,l=p(),M(r.$$.fragment),g=p(),u=d("p"),u.innerHTML=R,_=p(),M(B.$$.fragment),I=p(),W=d("p"),W.textContent=F,C=p(),M(x.$$.fragment)},l(o){s=f(o,"P",{"data-svelte-h":!0}),k(s)!=="svelte-h6kxlc"&&(s.innerHTML=h),l=i(o),y(r.$$.fragment,o),g=i(o),u=f(o,"P",{"data-svelte-h":!0}),k(u)!=="svelte-1abk23t"&&(u.innerHTML=R),_=i(o),y(B.$$.fragment,o),I=i(o),W=f(o,"P",{"data-svelte-h":!0}),k(W)!=="svelte-jux2mn"&&(W.textContent=F),C=i(o),y(x.$$.fragment,o)},m(o,T){a(o,s,T),a(o,l,T),b(r,o,T),a(o,g,T),a(o,u,T),a(o,_,T),b(B,o,T),a(o,I,T),a(o,W,T),a(o,C,T),b(x,o,T),G=!0},p:he,i(o){G||(j(r.$$.fragment,o),j(B.$$.fragment,o),j(x.$$.fragment,o),G=!0)},o(o){w(r.$$.fragment,o),w(B.$$.fragment,o),w(x.$$.fragment,o),G=!1},d(o){o&&(t(s),t(l),t(g),t(u),t(_),t(I),t(W),t(C)),$(r,o),$(B,o),$(x,o)}}}function sa(v){let s,h;return s=new et({props:{$$slots:{default:[ta]},$$scope:{ctx:v}}}),{c(){M(s.$$.fragment)},l(l){y(s.$$.fragment,l)},m(l,r){b(s,l,r),h=!0},p(l,r){const g={};r&2&&(g.$$scope={dirty:r,ctx:l}),s.$set(g)},i(l){h||(j(s.$$.fragment,l),h=!0)},o(l){w(s.$$.fragment,l),h=!1},d(l){$(s,l)}}}function aa(v){let s,h,l,r,g,u,R,_,B,I,W="Masked language modeling",F,C,x,G,o,T,Q=`Masked language modeling predicts a masked token in a sequence, and the model can attend to tokens bidirectionally. This
means the model has full access to the tokens on the left and right. Masked language modeling is great for tasks that
require a good contextual understanding of an entire sequence. BERT is an example of a masked language model.`,A,z,q="This guide will show you how to:",S,E,L='<li>Finetune <a href="https://huggingface.co/distilroberta-base" rel="nofollow">DistilRoBERTa</a> on the <a href="https://www.reddit.com/r/askscience/" rel="nofollow">r/askscience</a> subset of the <a href="https://huggingface.co/datasets/eli5" rel="nofollow">ELI5</a> dataset.</li> <li>Use your finetuned model for inference.</li>',N,c,J,H,ce="Before you begin, make sure you have all the necessary libraries installed:",P,D,K,m,U="We encourage you to log in to your Hugging Face account so you can upload and share your model with the community. When prompted, enter your token to log in:",de,fe,mt,O,ae,tt,ue,Ot,Pe,ls="Load ELI5 dataset",ht,ge,ns=`Start by loading a smaller subset of the r/askscience subset of the ELI5 dataset from the 🤗 Datasets library. This’ll
give you a chance to experiment and make sure everything works before spending more time training on the full dataset.`,ct,Me,dt,ye,os='Split the dataset’s <code>train_asks</code> split into a train and test set with the <a href="https://huggingface.co/docs/datasets/v2.14.5/en/package_reference/main_classes#datasets.Dataset.train_test_split" rel="nofollow">train_test_split</a> method:',ft,be,ut,je,rs="Then take a look at an example:",gt,we,Mt,$e,ps="While this may look like a lot, you’re only really interested in the <code>text</code> field. What’s cool about language modeling tasks is you don’t need labels (also known as an unsupervised task) because the next word <em>is</em> the label.",yt,ee,le,st,ke,es,De,is="Preprocess",bt,Te,jt,_e,ms="For masked language modeling, the next step is to load a DistilRoBERTa tokenizer to process the <code>text</code> subfield:",wt,xe,$t,Je,hs=`You’ll notice from the example above, the <code>text</code> field is actually nested inside <code>answers</code>. This means you’ll need to e
xtract the <code>text</code> subfield from its nested structure with the <a href="https://huggingface.co/docs/datasets/process.html#flatten" rel="nofollow"><code>flatten</code></a> method:`,kt,ve,Tt,Ue,cs=`Each subfield is now a separate column as indicated by the <code>answers</code> prefix, and the <code>text</code> field is a list now. Instead
of tokenizing each sentence separately, convert the list to a string so you can jointly tokenize them.`,_t,Ze,ds="Here is a first preprocessing function to join the list of strings for each example and tokenize the result:",xt,Ce,Jt,Ge,fs='To apply this preprocessing function over the entire dataset, use the 🤗 Datasets <a href="https://huggingface.co/docs/datasets/v2.14.5/en/package_reference/main_classes#datasets.Dataset.map" rel="nofollow">map</a> method. You can speed up the <code>map</code> function by setting <code>batched=True</code> to process multiple elements of the dataset at once, and increasing the number of processes with <code>num_proc</code>. Remove any columns you don’t need:',vt,Re,Ut,Ie,us="This dataset contains the token sequences, but some of these are longer than the maximum input length for the model.",Zt,We,gs="You can now use a second preprocessing function to",Ct,Be,Ms="<li>concatenate all the sequences</li> <li>split the concatenated sequences into shorter chunks defined by <code>block_size</code>, which should be both shorter than the maximum input length and short enough for your GPU RAM.</li>",Gt,Xe,Rt,Ve,ys="Apply the <code>group_texts</code> function over the entire dataset:",It,ze,Wt,Ee,bs='Now create a batch of examples using <a href="/docs/transformers/v4.34.0/en/main_classes/data_collator#transformers.DataCollatorForLanguageModeling">DataCollatorForLanguageModeling</a>. It’s more efficient to <em>dynamically pad</em> the sentences to the longest length in a batch during collation, instead of padding the whole dataset to the maximum length.',Bt,ne,Xt,te,oe,at,Fe,ts,Ke,js="Train",Vt,re,zt,pe,Et,se,ie,lt,He,ss,Oe,ws="Inference",Ft,Ae,$s="Great, now that you’ve finetuned a model, you can use it for inference!",Ht,Ne,ks="Come up with some text you’d like the model to fill in the blank with, and use the special <code>&lt;mask&gt;</code> token to indicate the blank:",At,Ye,Nt,Qe,Ts='The simplest way to try out your finetuned model for inference is to use it in a <a href="/docs/transformers/v4.34.0/en/main_classes/pipelines#transformers.pipeline">pipeline()</a>. Instantiate a <code>pipeline</code> for fill-mask with your model, and pass your text to it. If you like, you can use the <code>top_k</code> parameter to specify how many predictions to return:',Yt,Le,Qt,me,Lt,nt,qt;return _=new it({}),C=new Es({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/en/masked_language_modeling.ipynb"},{label:"PyTorch",value:"https://colab.research.google.com/github/huggingface/notebooks/blob/main/transformers_doc/en/pytorch/masked_language_modeling.ipynb"},{label:"TensorFlow",value:"https://colab.research.google.com/github/huggingface/notebooks/blob/main/transformers_doc/en/tensorflow/masked_language_modeling.ipynb"},{label:"Mixed",value:"https://studiolab.sagemaker.aws/import/github/huggingface/notebooks/blob/main/transformers_doc/en/masked_language_modeling.ipynb"},{label:"PyTorch",value:"https://studiolab.sagemaker.aws/import/github/huggingface/notebooks/blob/main/transformers_doc/en/pytorch/masked_language_modeling.ipynb"},{label:"TensorFlow",value:"https://studiolab.sagemaker.aws/import/github/huggingface/notebooks/blob/main/transformers_doc/en/tensorflow/masked_language_modeling.ipynb"}]}}),G=new Gs({props:{id:"mqElG5QJWUg"}}),c=new Kt({props:{$$slots:{default:[Fs]},$$scope:{ctx:v}}}),D=new Z({props:{code:"cGlwJTIwaW5zdGFsbCUyMHRyYW5zZm9ybWVycyUyMGRhdGFzZXRzJTIwZXZhbHVhdGU=",highlighted:"pip install transformers datasets evaluate",wrap:!1}}),fe=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()`,wrap:!1}}),ue=new it({}),Me=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>)`,wrap:!1}}),be=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>)',wrap:!1}}),we=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>: []}}`,wrap:!1}}),ke=new it({}),Te=new Gs({props:{id:"8PmhEIXhBvI"}}),xe=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>)`,wrap:!1}}),ve=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>: []}`,wrap:!1}}),Ce=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>]])`,wrap:!1}}),Re=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>)`,wrap:!1}}),Xe=new Z({props:{code:"YmxvY2tfc2l6ZSUyMCUzRCUyMDEyOCUwQSUwQSUwQWRlZiUyMGdyb3VwX3RleHRzKGV4YW1wbGVzKSUzQSUwQSUyMCUyMCUyMCUyMCUyMyUyMENvbmNhdGVuYXRlJTIwYWxsJTIwdGV4dHMuJTBBJTIwJTIwJTIwJTIwY29uY2F0ZW5hdGVkX2V4YW1wbGVzJTIwJTNEJTIwJTdCayUzQSUyMHN1bShleGFtcGxlcyU1QmslNUQlMkMlMjAlNUIlNUQpJTIwZm9yJTIwayUyMGluJTIwZXhhbXBsZXMua2V5cygpJTdEJTBBJTIwJTIwJTIwJTIwdG90YWxfbGVuZ3RoJTIwJTNEJTIwbGVuKGNvbmNhdGVuYXRlZF9leGFtcGxlcyU1Qmxpc3QoZXhhbXBsZXMua2V5cygpKSU1QjAlNUQlNUQpJTBBJTIwJTIwJTIwJTIwJTIzJTIwV2UlMjBkcm9wJTIwdGhlJTIwc21hbGwlMjByZW1haW5kZXIlMkMlMjB3ZSUyMGNvdWxkJTIwYWRkJTIwcGFkZGluZyUyMGlmJTIwdGhlJTIwbW9kZWwlMjBzdXBwb3J0ZWQlMjBpdCUyMGluc3RlYWQlMjBvZiUyMHRoaXMlMjBkcm9wJTJDJTIweW91JTIwY2FuJTBBJTIwJTIwJTIwJTIwJTIzJTIwY3VzdG9taXplJTIwdGhpcyUyMHBhcnQlMjB0byUyMHlvdXIlMjBuZWVkcy4lMEElMjAlMjAlMjAlMjBpZiUyMHRvdGFsX2xlbmd0aCUyMCUzRSUzRCUyMGJsb2NrX3NpemUlM0ElMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjB0b3RhbF9sZW5ndGglMjAlM0QlMjAodG90YWxfbGVuZ3RoJTIwJTJGJTJGJTIwYmxvY2tfc2l6ZSklMjAqJTIwYmxvY2tfc2l6ZSUwQSUyMCUyMCUyMCUyMCUyMyUyMFNwbGl0JTIwYnklMjBjaHVua3MlMjBvZiUyMGJsb2NrX3NpemUuJTBBJTIwJTIwJTIwJTIwcmVzdWx0JTIwJTNEJTIwJTdCJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwayUzQSUyMCU1QnQlNUJpJTIwJTNBJTIwaSUyMCUyQiUyMGJsb2NrX3NpemUlNUQlMjBmb3IlMjBpJTIwaW4lMjByYW5nZSgwJTJDJTIwdG90YWxfbGVuZ3RoJTJDJTIwYmxvY2tfc2l6ZSklNUQlMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjBmb3IlMjBrJTJDJTIwdCUyMGluJTIwY29uY2F0ZW5hdGVkX2V4YW1wbGVzLml0ZW1zKCklMEElMjAlMjAlMjAlMjAlN0QlMEElMjAlMjAlMjAlMjByZXR1cm4lMjByZXN1bHQ=",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>    <span class="hljs-keyword">return</span> result`,wrap:!1}}),ze=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>)',wrap:!1}}),ne=new as({props:{pytorch:!0,tensorflow:!0,jax:!1,$$slots:{tensorflow:[Ys],pytorch:[As]},$$scope:{ctx:v}}}),Fe=new it({}),re=new as({props:{pytorch:!0,tensorflow:!0,jax:!1,$$slots:{tensorflow:[Ds],pytorch:[qs]},$$scope:{ctx:v}}}),pe=new Kt({props:{$$slots:{default:[Ks]},$$scope:{ctx:v}}}),He=new it({}),Ye=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>',wrap:!1}}),Le=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>}]`,wrap:!1}}),me=new as({props:{pytorch:!0,tensorflow:!0,jax:!1,$$slots:{tensorflow:[sa],pytorch:[ea]},$$scope:{ctx:v}}}),{c(){s=d("meta"),h=p(),l=d("p"),r=p(),g=d("h1"),u=d("a"),R=d("span"),M(_.$$.fragment),B=p(),I=d("span"),I.textContent=W,F=p(),M(C.$$.fragment),x=p(),M(G.$$.fragment),o=p(),T=d("p"),T.textContent=Q,A=p(),z=d("p"),z.textContent=q,S=p(),E=d("ol"),E.innerHTML=L,N=p(),M(c.$$.fragment),J=p(),H=d("p"),H.textContent=ce,P=p(),M(D.$$.fragment),K=p(),m=d("p"),m.textContent=U,de=p(),M(fe.$$.fragment),mt=p(),O=d("h2"),ae=d("a"),tt=d("span"),M(ue.$$.fragment),Ot=p(),Pe=d("span"),Pe.textContent=ls,ht=p(),ge=d("p"),ge.textContent=ns,ct=p(),M(Me.$$.fragment),dt=p(),ye=d("p"),ye.innerHTML=os,ft=p(),M(be.$$.fragment),ut=p(),je=d("p"),je.textContent=rs,gt=p(),M(we.$$.fragment),Mt=p(),$e=d("p"),$e.innerHTML=ps,yt=p(),ee=d("h2"),le=d("a"),st=d("span"),M(ke.$$.fragment),es=p(),De=d("span"),De.textContent=is,bt=p(),M(Te.$$.fragment),jt=p(),_e=d("p"),_e.innerHTML=ms,wt=p(),M(xe.$$.fragment),$t=p(),Je=d("p"),Je.innerHTML=hs,kt=p(),M(ve.$$.fragment),Tt=p(),Ue=d("p"),Ue.innerHTML=cs,_t=p(),Ze=d("p"),Ze.textContent=ds,xt=p(),M(Ce.$$.fragment),Jt=p(),Ge=d("p"),Ge.innerHTML=fs,vt=p(),M(Re.$$.fragment),Ut=p(),Ie=d("p"),Ie.textContent=us,Zt=p(),We=d("p"),We.textContent=gs,Ct=p(),Be=d("ul"),Be.innerHTML=Ms,Gt=p(),M(Xe.$$.fragment),Rt=p(),Ve=d("p"),Ve.innerHTML=ys,It=p(),M(ze.$$.fragment),Wt=p(),Ee=d("p"),Ee.innerHTML=bs,Bt=p(),M(ne.$$.fragment),Xt=p(),te=d("h2"),oe=d("a"),at=d("span"),M(Fe.$$.fragment),ts=p(),Ke=d("span"),Ke.textContent=js,Vt=p(),M(re.$$.fragment),zt=p(),M(pe.$$.fragment),Et=p(),se=d("h2"),ie=d("a"),lt=d("span"),M(He.$$.fragment),ss=p(),Oe=d("span"),Oe.textContent=ws,Ft=p(),Ae=d("p"),Ae.textContent=$s,Ht=p(),Ne=d("p"),Ne.innerHTML=ks,At=p(),M(Ye.$$.fragment),Nt=p(),Qe=d("p"),Qe.innerHTML=Ts,Yt=p(),M(Le.$$.fragment),Qt=p(),M(me.$$.fragment),Lt=p(),nt=d("p"),this.h()},l(e){const n=zs("svelte-1phssyn",document.head);s=f(n,"META",{name:!0,content:!0}),n.forEach(t),h=i(e),l=f(e,"P",{}),Y(l).forEach(t),r=i(e),g=f(e,"H1",{class:!0});var qe=Y(g);u=f(qe,"A",{id:!0,class:!0,href:!0});var ot=Y(u);R=f(ot,"SPAN",{});var rt=Y(R);y(_.$$.fragment,rt),rt.forEach(t),ot.forEach(t),B=i(qe),I=f(qe,"SPAN",{"data-svelte-h":!0}),k(I)!=="svelte-1vb8xp5"&&(I.textContent=W),qe.forEach(t),F=i(e),y(C.$$.fragment,e),x=i(e),y(G.$$.fragment,e),o=i(e),T=f(e,"P",{"data-svelte-h":!0}),k(T)!=="svelte-ed5ap0"&&(T.textContent=Q),A=i(e),z=f(e,"P",{"data-svelte-h":!0}),k(z)!=="svelte-1aff4p7"&&(z.textContent=q),S=i(e),E=f(e,"OL",{"data-svelte-h":!0}),k(E)!=="svelte-1iq9zup"&&(E.innerHTML=L),N=i(e),y(c.$$.fragment,e),J=i(e),H=f(e,"P",{"data-svelte-h":!0}),k(H)!=="svelte-1c9nexd"&&(H.textContent=ce),P=i(e),y(D.$$.fragment,e),K=i(e),m=f(e,"P",{"data-svelte-h":!0}),k(m)!=="svelte-27hn0u"&&(m.textContent=U),de=i(e),y(fe.$$.fragment,e),mt=i(e),O=f(e,"H2",{class:!0});var Se=Y(O);ae=f(Se,"A",{id:!0,class:!0,href:!0});var pt=Y(ae);tt=f(pt,"SPAN",{});var _s=Y(tt);y(ue.$$.fragment,_s),_s.forEach(t),pt.forEach(t),Ot=i(Se),Pe=f(Se,"SPAN",{"data-svelte-h":!0}),k(Pe)!=="svelte-vt5erg"&&(Pe.textContent=ls),Se.forEach(t),ht=i(e),ge=f(e,"P",{"data-svelte-h":!0}),k(ge)!=="svelte-1elcj66"&&(ge.textContent=ns),ct=i(e),y(Me.$$.fragment,e),dt=i(e),ye=f(e,"P",{"data-svelte-h":!0}),k(ye)!=="svelte-4cgbu8"&&(ye.innerHTML=os),ft=i(e),y(be.$$.fragment,e),ut=i(e),je=f(e,"P",{"data-svelte-h":!0}),k(je)!=="svelte-1m91ua0"&&(je.textContent=rs),gt=i(e),y(we.$$.fragment,e),Mt=i(e),$e=f(e,"P",{"data-svelte-h":!0}),k($e)!=="svelte-dtsbii"&&($e.innerHTML=ps),yt=i(e),ee=f(e,"H2",{class:!0});var St=Y(ee);le=f(St,"A",{id:!0,class:!0,href:!0});var xs=Y(le);st=f(xs,"SPAN",{});var Js=Y(st);y(ke.$$.fragment,Js),Js.forEach(t),xs.forEach(t),es=i(St),De=f(St,"SPAN",{"data-svelte-h":!0}),k(De)!=="svelte-1cg9qj"&&(De.textContent=is),St.forEach(t),bt=i(e),y(Te.$$.fragment,e),jt=i(e),_e=f(e,"P",{"data-svelte-h":!0}),k(_e)!=="svelte-i99oeh"&&(_e.innerHTML=ms),wt=i(e),y(xe.$$.fragment,e),$t=i(e),Je=f(e,"P",{"data-svelte-h":!0}),k(Je)!=="svelte-1oxkzu9"&&(Je.innerHTML=hs),kt=i(e),y(ve.$$.fragment,e),Tt=i(e),Ue=f(e,"P",{"data-svelte-h":!0}),k(Ue)!=="svelte-1mdv3gu"&&(Ue.innerHTML=cs),_t=i(e),Ze=f(e,"P",{"data-svelte-h":!0}),k(Ze)!=="svelte-njkc6i"&&(Ze.textContent=ds),xt=i(e),y(Ce.$$.fragment,e),Jt=i(e),Ge=f(e,"P",{"data-svelte-h":!0}),k(Ge)!=="svelte-1iccbqj"&&(Ge.innerHTML=fs),vt=i(e),y(Re.$$.fragment,e),Ut=i(e),Ie=f(e,"P",{"data-svelte-h":!0}),k(Ie)!=="svelte-pz0l04"&&(Ie.textContent=us),Zt=i(e),We=f(e,"P",{"data-svelte-h":!0}),k(We)!=="svelte-5guq64"&&(We.textContent=gs),Ct=i(e),Be=f(e,"UL",{"data-svelte-h":!0}),k(Be)!=="svelte-vz17je"&&(Be.innerHTML=Ms),Gt=i(e),y(Xe.$$.fragment,e),Rt=i(e),Ve=f(e,"P",{"data-svelte-h":!0}),k(Ve)!=="svelte-1o69amy"&&(Ve.innerHTML=ys),It=i(e),y(ze.$$.fragment,e),Wt=i(e),Ee=f(e,"P",{"data-svelte-h":!0}),k(Ee)!=="svelte-1fu1iu7"&&(Ee.innerHTML=bs),Bt=i(e),y(ne.$$.fragment,e),Xt=i(e),te=f(e,"H2",{class:!0});var Pt=Y(te);oe=f(Pt,"A",{id:!0,class:!0,href:!0});var vs=Y(oe);at=f(vs,"SPAN",{});var Us=Y(at);y(Fe.$$.fragment,Us),Us.forEach(t),vs.forEach(t),ts=i(Pt),Ke=f(Pt,"SPAN",{"data-svelte-h":!0}),k(Ke)!=="svelte-5arm0l"&&(Ke.textContent=js),Pt.forEach(t),Vt=i(e),y(re.$$.fragment,e),zt=i(e),y(pe.$$.fragment,e),Et=i(e),se=f(e,"H2",{class:!0});var Dt=Y(se);ie=f(Dt,"A",{id:!0,class:!0,href:!0});var Zs=Y(ie);lt=f(Zs,"SPAN",{});var Cs=Y(lt);y(He.$$.fragment,Cs),Cs.forEach(t),Zs.forEach(t),ss=i(Dt),Oe=f(Dt,"SPAN",{"data-svelte-h":!0}),k(Oe)!=="svelte-199uz7g"&&(Oe.textContent=ws),Dt.forEach(t),Ft=i(e),Ae=f(e,"P",{"data-svelte-h":!0}),k(Ae)!=="svelte-633ppb"&&(Ae.textContent=$s),Ht=i(e),Ne=f(e,"P",{"data-svelte-h":!0}),k(Ne)!=="svelte-9jago5"&&(Ne.innerHTML=ks),At=i(e),y(Ye.$$.fragment,e),Nt=i(e),Qe=f(e,"P",{"data-svelte-h":!0}),k(Qe)!=="svelte-5vt6cp"&&(Qe.innerHTML=Ts),Yt=i(e),y(Le.$$.fragment,e),Qt=i(e),y(me.$$.fragment,e),Lt=i(e),nt=f(e,"P",{}),Y(nt).forEach(t),this.h()},h(){X(s,"name","hf:doc:metadata"),X(s,"content",JSON.stringify(la)),X(u,"id","masked-language-modeling"),X(u,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),X(u,"href","#masked-language-modeling"),X(g,"class","relative group"),X(ae,"id","load-eli5-dataset"),X(ae,"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(ae,"href","#load-eli5-dataset"),X(O,"class","relative group"),X(le,"id","preprocess"),X(le,"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(le,"href","#preprocess"),X(ee,"class","relative group"),X(oe,"id","train"),X(oe,"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(oe,"href","#train"),X(te,"class","relative group"),X(ie,"id","inference"),X(ie,"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(ie,"href","#inference"),X(se,"class","relative group")},m(e,n){V(document.head,s),a(e,h,n),a(e,l,n),a(e,r,n),a(e,g,n),V(g,u),V(u,R),b(_,R,null),V(g,B),V(g,I),a(e,F,n),b(C,e,n),a(e,x,n),b(G,e,n),a(e,o,n),a(e,T,n),a(e,A,n),a(e,z,n),a(e,S,n),a(e,E,n),a(e,N,n),b(c,e,n),a(e,J,n),a(e,H,n),a(e,P,n),b(D,e,n),a(e,K,n),a(e,m,n),a(e,de,n),b(fe,e,n),a(e,mt,n),a(e,O,n),V(O,ae),V(ae,tt),b(ue,tt,null),V(O,Ot),V(O,Pe),a(e,ht,n),a(e,ge,n),a(e,ct,n),b(Me,e,n),a(e,dt,n),a(e,ye,n),a(e,ft,n),b(be,e,n),a(e,ut,n),a(e,je,n),a(e,gt,n),b(we,e,n),a(e,Mt,n),a(e,$e,n),a(e,yt,n),a(e,ee,n),V(ee,le),V(le,st),b(ke,st,null),V(ee,es),V(ee,De),a(e,bt,n),b(Te,e,n),a(e,jt,n),a(e,_e,n),a(e,wt,n),b(xe,e,n),a(e,$t,n),a(e,Je,n),a(e,kt,n),b(ve,e,n),a(e,Tt,n),a(e,Ue,n),a(e,_t,n),a(e,Ze,n),a(e,xt,n),b(Ce,e,n),a(e,Jt,n),a(e,Ge,n),a(e,vt,n),b(Re,e,n),a(e,Ut,n),a(e,Ie,n),a(e,Zt,n),a(e,We,n),a(e,Ct,n),a(e,Be,n),a(e,Gt,n),b(Xe,e,n),a(e,Rt,n),a(e,Ve,n),a(e,It,n),b(ze,e,n),a(e,Wt,n),a(e,Ee,n),a(e,Bt,n),b(ne,e,n),a(e,Xt,n),a(e,te,n),V(te,oe),V(oe,at),b(Fe,at,null),V(te,ts),V(te,Ke),a(e,Vt,n),b(re,e,n),a(e,zt,n),b(pe,e,n),a(e,Et,n),a(e,se,n),V(se,ie),V(ie,lt),b(He,lt,null),V(se,ss),V(se,Oe),a(e,Ft,n),a(e,Ae,n),a(e,Ht,n),a(e,Ne,n),a(e,At,n),b(Ye,e,n),a(e,Nt,n),a(e,Qe,n),a(e,Yt,n),b(Le,e,n),a(e,Qt,n),b(me,e,n),a(e,Lt,n),a(e,nt,n),qt=!0},p(e,[n]){const qe={};n&2&&(qe.$$scope={dirty:n,ctx:e}),c.$set(qe);const ot={};n&2&&(ot.$$scope={dirty:n,ctx:e}),ne.$set(ot);const rt={};n&2&&(rt.$$scope={dirty:n,ctx:e}),re.$set(rt);const Se={};n&2&&(Se.$$scope={dirty:n,ctx:e}),pe.$set(Se);const pt={};n&2&&(pt.$$scope={dirty:n,ctx:e}),me.$set(pt)},i(e){qt||(j(_.$$.fragment,e),j(C.$$.fragment,e),j(G.$$.fragment,e),j(c.$$.fragment,e),j(D.$$.fragment,e),j(fe.$$.fragment,e),j(ue.$$.fragment,e),j(Me.$$.fragment,e),j(be.$$.fragment,e),j(we.$$.fragment,e),j(ke.$$.fragment,e),j(Te.$$.fragment,e),j(xe.$$.fragment,e),j(ve.$$.fragment,e),j(Ce.$$.fragment,e),j(Re.$$.fragment,e),j(Xe.$$.fragment,e),j(ze.$$.fragment,e),j(ne.$$.fragment,e),j(Fe.$$.fragment,e),j(re.$$.fragment,e),j(pe.$$.fragment,e),j(He.$$.fragment,e),j(Ye.$$.fragment,e),j(Le.$$.fragment,e),j(me.$$.fragment,e),qt=!0)},o(e){w(_.$$.fragment,e),w(C.$$.fragment,e),w(G.$$.fragment,e),w(c.$$.fragment,e),w(D.$$.fragment,e),w(fe.$$.fragment,e),w(ue.$$.fragment,e),w(Me.$$.fragment,e),w(be.$$.fragment,e),w(we.$$.fragment,e),w(ke.$$.fragment,e),w(Te.$$.fragment,e),w(xe.$$.fragment,e),w(ve.$$.fragment,e),w(Ce.$$.fragment,e),w(Re.$$.fragment,e),w(Xe.$$.fragment,e),w(ze.$$.fragment,e),w(ne.$$.fragment,e),w(Fe.$$.fragment,e),w(re.$$.fragment,e),w(pe.$$.fragment,e),w(He.$$.fragment,e),w(Ye.$$.fragment,e),w(Le.$$.fragment,e),w(me.$$.fragment,e),qt=!1},d(e){e&&(t(h),t(l),t(r),t(g),t(F),t(x),t(o),t(T),t(A),t(z),t(S),t(E),t(N),t(J),t(H),t(P),t(K),t(m),t(de),t(mt),t(O),t(ht),t(ge),t(ct),t(dt),t(ye),t(ft),t(ut),t(je),t(gt),t(Mt),t($e),t(yt),t(ee),t(bt),t(jt),t(_e),t(wt),t($t),t(Je),t(kt),t(Tt),t(Ue),t(_t),t(Ze),t(xt),t(Jt),t(Ge),t(vt),t(Ut),t(Ie),t(Zt),t(We),t(Ct),t(Be),t(Gt),t(Rt),t(Ve),t(It),t(Wt),t(Ee),t(Bt),t(Xt),t(te),t(Vt),t(zt),t(Et),t(se),t(Ft),t(Ae),t(Ht),t(Ne),t(At),t(Nt),t(Qe),t(Yt),t(Qt),t(Lt),t(nt)),t(s),$(_),$(C,e),$(G,e),$(c,e),$(D,e),$(fe,e),$(ue),$(Me,e),$(be,e),$(we,e),$(ke),$(Te,e),$(xe,e),$(ve,e),$(Ce,e),$(Re,e),$(Xe,e),$(ze,e),$(ne,e),$(Fe),$(re,e),$(pe,e),$(He),$(Ye,e),$(Le,e),$(me,e)}}}const la={local:"masked-language-modeling",sections:[{local:"load-eli5-dataset",title:"Load ELI5 dataset"},{local:"preprocess",title:"Preprocess"},{local:"train",title:"Train"},{local:"inference",title:"Inference"}],title:"Masked language modeling"};function na(v){return Bs(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class fa extends Xs{constructor(s){super(),Vs(this,s,na,aa,Ws,{})}}export{fa as component};
