import{s as qe,o as Se,n as ss}from"../chunks/scheduler.25b97de1.js";import{S as Pe,i as De,g as w,s as o,r as f,A as Ke,h as $,f as a,c as i,j as Ne,u as g,x as k,k as Ae,y as Oe,a as l,v as M,d as y,t as j,w as b,m as st,n as et}from"../chunks/index.d9030fc9.js";import{T as $e}from"../chunks/Tip.baa67368.js";import{Y as Le}from"../chunks/Youtube.eaf1a617.js";import{C as W}from"../chunks/CodeBlock.e6cd0d95.js";import{D as tt}from"../chunks/DocNotebookDropdown.5ea6cb78.js";import{F as ke,M as Is}from"../chunks/Markdown.7217f838.js";import{H as Vs,E as at}from"../chunks/EditOnGithub.91d95064.js";function lt(Z){let e,c='To see all architectures and checkpoints compatible with this task, we recommend checking the <a href="https://huggingface.co/tasks/fill-mask" rel="nofollow">task-page</a>';return{c(){e=w("p"),e.innerHTML=c},l(t){e=$(t,"P",{"data-svelte-h":!0}),k(e)!=="svelte-jsmslo"&&(e.innerHTML=c)},m(t,m){l(t,e,m)},p:ss,d(t){t&&a(e)}}}function nt(Z){let e,c="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:",t,m,u;return m=new W({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=w("p"),e.innerHTML=c,t=o(),f(m.$$.fragment)},l(d){e=$(d,"P",{"data-svelte-h":!0}),k(e)!=="svelte-z8dnpj"&&(e.innerHTML=c),t=i(d),g(m.$$.fragment,d)},m(d,G){l(d,e,G),l(d,t,G),M(m,d,G),u=!0},p:ss,i(d){u||(y(m.$$.fragment,d),u=!0)},o(d){j(m.$$.fragment,d),u=!1},d(d){d&&(a(e),a(t)),b(m,d)}}}function pt(Z){let e,c;return e=new Is({props:{$$slots:{default:[nt]},$$scope:{ctx:Z}}}),{c(){f(e.$$.fragment)},l(t){g(e.$$.fragment,t)},m(t,m){M(e,t,m),c=!0},p(t,m){const u={};m&2&&(u.$$scope={dirty:m,ctx:t}),e.$set(u)},i(t){c||(y(e.$$.fragment,t),c=!0)},o(t){j(e.$$.fragment,t),c=!1},d(t){b(e,t)}}}function rt(Z){let e,c="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:",t,m,u;return m=new W({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=w("p"),e.innerHTML=c,t=o(),f(m.$$.fragment)},l(d){e=$(d,"P",{"data-svelte-h":!0}),k(e)!=="svelte-z8dnpj"&&(e.innerHTML=c),t=i(d),g(m.$$.fragment,d)},m(d,G){l(d,e,G),l(d,t,G),M(m,d,G),u=!0},p:ss,i(d){u||(y(m.$$.fragment,d),u=!0)},o(d){j(m.$$.fragment,d),u=!1},d(d){d&&(a(e),a(t)),b(m,d)}}}function ot(Z){let e,c;return e=new Is({props:{$$slots:{default:[rt]},$$scope:{ctx:Z}}}),{c(){f(e.$$.fragment)},l(t){g(e.$$.fragment,t)},m(t,m){M(e,t,m),c=!0},p(t,m){const u={};m&2&&(u.$$scope={dirty:m,ctx:t}),e.$set(u)},i(t){c||(y(e.$$.fragment,t),c=!0)},o(t){j(e.$$.fragment,t),c=!1},d(t){b(e,t)}}}function it(Z){let e,c='If you aren’t familiar with finetuning a model with the <a href="/docs/transformers/pr_30530/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(){e=w("p"),e.innerHTML=c},l(t){e=$(t,"P",{"data-svelte-h":!0}),k(e)!=="svelte-4zq9b7"&&(e.innerHTML=c)},m(t,m){l(t,e,m)},p:ss,d(t){t&&a(e)}}}function mt(Z){let e,c,t,m='You’re ready to start training your model now! Load DistilRoBERTa with <a href="/docs/transformers/pr_30530/en/model_doc/auto#transformers.AutoModelForMaskedLM">AutoModelForMaskedLM</a>:',u,d,G,C,v="At this point, only three steps remain:",I,U,H='<li>Define your training hyperparameters in <a href="/docs/transformers/pr_30530/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/pr_30530/en/main_classes/trainer#transformers.Trainer">Trainer</a> along with the model, datasets, and data collator.</li> <li>Call <a href="/docs/transformers/pr_30530/en/main_classes/trainer#transformers.Trainer.train">train()</a> to finetune your model.</li>',R,x,X,p,T='Once training is completed, use the <a href="/docs/transformers/pr_30530/en/main_classes/trainer#transformers.Trainer.evaluate">evaluate()</a> method to evaluate your model and get its perplexity:',E,z,V,Y,Q='Then share your model to the Hub with the <a href="/docs/transformers/pr_30530/en/main_classes/trainer#transformers.Trainer.push_to_hub">push_to_hub()</a> method so everyone can use your model:',N,F,B;return e=new $e({props:{$$slots:{default:[it]},$$scope:{ctx:Z}}}),d=new W({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMEF1dG9Nb2RlbEZvck1hc2tlZExNJTBBJTBBbW9kZWwlMjAlM0QlMjBBdXRvTW9kZWxGb3JNYXNrZWRMTS5mcm9tX3ByZXRyYWluZWQoJTIyZGlzdGlsYmVydCUyRmRpc3RpbHJvYmVydGEtYmFzZSUyMik=",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;distilbert/distilroberta-base&quot;</span>)`,wrap:!1}}),x=new W({props:{code:"dHJhaW5pbmdfYXJncyUyMCUzRCUyMFRyYWluaW5nQXJndW1lbnRzKCUwQSUyMCUyMCUyMCUyMG91dHB1dF9kaXIlM0QlMjJteV9hd2Vzb21lX2VsaTVfbWxtX21vZGVsJTIyJTJDJTBBJTIwJTIwJTIwJTIwZXZhbF9zdHJhdGVneSUzRCUyMmVwb2NoJTIyJTJDJTBBJTIwJTIwJTIwJTIwbGVhcm5pbmdfcmF0ZSUzRDJlLTUlMkMlMEElMjAlMjAlMjAlMjBudW1fdHJhaW5fZXBvY2hzJTNEMyUyQyUwQSUyMCUyMCUyMCUyMHdlaWdodF9kZWNheSUzRDAuMDElMkMlMEElMjAlMjAlMjAlMjBwdXNoX3RvX2h1YiUzRFRydWUlMkMlMEEpJTBBJTBBdHJhaW5lciUyMCUzRCUyMFRyYWluZXIoJTBBJTIwJTIwJTIwJTIwbW9kZWwlM0Rtb2RlbCUyQyUwQSUyMCUyMCUyMCUyMGFyZ3MlM0R0cmFpbmluZ19hcmdzJTJDJTBBJTIwJTIwJTIwJTIwdHJhaW5fZGF0YXNldCUzRGxtX2RhdGFzZXQlNUIlMjJ0cmFpbiUyMiU1RCUyQyUwQSUyMCUyMCUyMCUyMGV2YWxfZGF0YXNldCUzRGxtX2RhdGFzZXQlNUIlMjJ0ZXN0JTIyJTVEJTJDJTBBJTIwJTIwJTIwJTIwZGF0YV9jb2xsYXRvciUzRGRhdGFfY29sbGF0b3IlMkMlMEEpJTBBJTBBdHJhaW5lci50cmFpbigp",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>    eval_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 W({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}}),F=new W({props:{code:"dHJhaW5lci5wdXNoX3RvX2h1Yigp",highlighted:'<span class="hljs-meta">&gt;&gt;&gt; </span>trainer.push_to_hub()',wrap:!1}}),{c(){f(e.$$.fragment),c=o(),t=w("p"),t.innerHTML=m,u=o(),f(d.$$.fragment),G=o(),C=w("p"),C.textContent=v,I=o(),U=w("ol"),U.innerHTML=H,R=o(),f(x.$$.fragment),X=o(),p=w("p"),p.innerHTML=T,E=o(),f(z.$$.fragment),V=o(),Y=w("p"),Y.innerHTML=Q,N=o(),f(F.$$.fragment)},l(h){g(e.$$.fragment,h),c=i(h),t=$(h,"P",{"data-svelte-h":!0}),k(t)!=="svelte-h3kj93"&&(t.innerHTML=m),u=i(h),g(d.$$.fragment,h),G=i(h),C=$(h,"P",{"data-svelte-h":!0}),k(C)!=="svelte-l42k0i"&&(C.textContent=v),I=i(h),U=$(h,"OL",{"data-svelte-h":!0}),k(U)!=="svelte-u93gxh"&&(U.innerHTML=H),R=i(h),g(x.$$.fragment,h),X=i(h),p=$(h,"P",{"data-svelte-h":!0}),k(p)!=="svelte-my9y0l"&&(p.innerHTML=T),E=i(h),g(z.$$.fragment,h),V=i(h),Y=$(h,"P",{"data-svelte-h":!0}),k(Y)!=="svelte-16kjplo"&&(Y.innerHTML=Q),N=i(h),g(F.$$.fragment,h)},m(h,J){M(e,h,J),l(h,c,J),l(h,t,J),l(h,u,J),M(d,h,J),l(h,G,J),l(h,C,J),l(h,I,J),l(h,U,J),l(h,R,J),M(x,h,J),l(h,X,J),l(h,p,J),l(h,E,J),M(z,h,J),l(h,V,J),l(h,Y,J),l(h,N,J),M(F,h,J),B=!0},p(h,J){const L={};J&2&&(L.$$scope={dirty:J,ctx:h}),e.$set(L)},i(h){B||(y(e.$$.fragment,h),y(d.$$.fragment,h),y(x.$$.fragment,h),y(z.$$.fragment,h),y(F.$$.fragment,h),B=!0)},o(h){j(e.$$.fragment,h),j(d.$$.fragment,h),j(x.$$.fragment,h),j(z.$$.fragment,h),j(F.$$.fragment,h),B=!1},d(h){h&&(a(c),a(t),a(u),a(G),a(C),a(I),a(U),a(R),a(X),a(p),a(E),a(V),a(Y),a(N)),b(e,h),b(d,h),b(x,h),b(z,h),b(F,h)}}}function ct(Z){let e,c;return e=new Is({props:{$$slots:{default:[mt]},$$scope:{ctx:Z}}}),{c(){f(e.$$.fragment)},l(t){g(e.$$.fragment,t)},m(t,m){M(e,t,m),c=!0},p(t,m){const u={};m&2&&(u.$$scope={dirty:m,ctx:t}),e.$set(u)},i(t){c||(y(e.$$.fragment,t),c=!0)},o(t){j(e.$$.fragment,t),c=!1},d(t){b(e,t)}}}function ht(Z){let e,c='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(){e=w("p"),e.innerHTML=c},l(t){e=$(t,"P",{"data-svelte-h":!0}),k(e)!=="svelte-1rd4nl8"&&(e.innerHTML=c)},m(t,m){l(t,e,m)},p:ss,d(t){t&&a(e)}}}function dt(Z){let e,c,t,m,u,d='Then you can load DistilRoBERTa with <a href="/docs/transformers/pr_30530/en/model_doc/auto#transformers.TFAutoModelForMaskedLM">TFAutoModelForMaskedLM</a>:',G,C,v,I,U='Convert your datasets to the <code>tf.data.Dataset</code> format with <a href="/docs/transformers/pr_30530/en/main_classes/model#transformers.TFPreTrainedModel.prepare_tf_dataset">prepare_tf_dataset()</a>:',H,R,x,X,p='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,E,z,V,Y='This can be done by specifying where to push your model and tokenizer in the <a href="/docs/transformers/pr_30530/en/main_classes/keras_callbacks#transformers.PushToHubCallback">PushToHubCallback</a>:',Q,N,F,B,h='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,L,S,A,es="Once training is completed, your model is automatically uploaded to the Hub so everyone can use it!",q;return e=new $e({props:{$$slots:{default:[ht]},$$scope:{ctx:Z}}}),t=new W({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}}),C=new W({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMFRGQXV0b01vZGVsRm9yTWFza2VkTE0lMEElMEFtb2RlbCUyMCUzRCUyMFRGQXV0b01vZGVsRm9yTWFza2VkTE0uZnJvbV9wcmV0cmFpbmVkKCUyMmRpc3RpbGJlcnQlMkZkaXN0aWxyb2JlcnRhLWJhc2UlMjIp",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;distilbert/distilroberta-base&quot;</span>)`,wrap:!1}}),R=new W({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}}),E=new W({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}}),N=new W({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 W({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(){f(e.$$.fragment),c=st(`
To finetune a model in TensorFlow, start by setting up an optimizer function, learning rate schedule, and some training hyperparameters:

	`),f(t.$$.fragment),m=o(),u=w("p"),u.innerHTML=d,G=o(),f(C.$$.fragment),v=o(),I=w("p"),I.innerHTML=U,H=o(),f(R.$$.fragment),x=o(),X=w("p"),X.innerHTML=p,T=o(),f(E.$$.fragment),z=o(),V=w("p"),V.innerHTML=Y,Q=o(),f(N.$$.fragment),F=o(),B=w("p"),B.innerHTML=h,J=o(),f(L.$$.fragment),S=o(),A=w("p"),A.textContent=es},l(r){g(e.$$.fragment,r),c=et(r,`
To finetune a model in TensorFlow, start by setting up an optimizer function, learning rate schedule, and some training hyperparameters:

	`),g(t.$$.fragment,r),m=i(r),u=$(r,"P",{"data-svelte-h":!0}),k(u)!=="svelte-13fsjb1"&&(u.innerHTML=d),G=i(r),g(C.$$.fragment,r),v=i(r),I=$(r,"P",{"data-svelte-h":!0}),k(I)!=="svelte-1dqdado"&&(I.innerHTML=U),H=i(r),g(R.$$.fragment,r),x=i(r),X=$(r,"P",{"data-svelte-h":!0}),k(X)!=="svelte-17cxx5e"&&(X.innerHTML=p),T=i(r),g(E.$$.fragment,r),z=i(r),V=$(r,"P",{"data-svelte-h":!0}),k(V)!=="svelte-vn17vg"&&(V.innerHTML=Y),Q=i(r),g(N.$$.fragment,r),F=i(r),B=$(r,"P",{"data-svelte-h":!0}),k(B)!=="svelte-1pfsro2"&&(B.innerHTML=h),J=i(r),g(L.$$.fragment,r),S=i(r),A=$(r,"P",{"data-svelte-h":!0}),k(A)!=="svelte-2s71om"&&(A.textContent=es)},m(r,_){M(e,r,_),l(r,c,_),M(t,r,_),l(r,m,_),l(r,u,_),l(r,G,_),M(C,r,_),l(r,v,_),l(r,I,_),l(r,H,_),M(R,r,_),l(r,x,_),l(r,X,_),l(r,T,_),M(E,r,_),l(r,z,_),l(r,V,_),l(r,Q,_),M(N,r,_),l(r,F,_),l(r,B,_),l(r,J,_),M(L,r,_),l(r,S,_),l(r,A,_),q=!0},p(r,_){const Rs={};_&2&&(Rs.$$scope={dirty:_,ctx:r}),e.$set(Rs)},i(r){q||(y(e.$$.fragment,r),y(t.$$.fragment,r),y(C.$$.fragment,r),y(R.$$.fragment,r),y(E.$$.fragment,r),y(N.$$.fragment,r),y(L.$$.fragment,r),q=!0)},o(r){j(e.$$.fragment,r),j(t.$$.fragment,r),j(C.$$.fragment,r),j(R.$$.fragment,r),j(E.$$.fragment,r),j(N.$$.fragment,r),j(L.$$.fragment,r),q=!1},d(r){r&&(a(c),a(m),a(u),a(G),a(v),a(I),a(H),a(x),a(X),a(T),a(z),a(V),a(Q),a(F),a(B),a(J),a(S),a(A)),b(e,r),b(t,r),b(C,r),b(R,r),b(E,r),b(N,r),b(L,r)}}}function ut(Z){let e,c;return e=new Is({props:{$$slots:{default:[dt]},$$scope:{ctx:Z}}}),{c(){f(e.$$.fragment)},l(t){g(e.$$.fragment,t)},m(t,m){M(e,t,m),c=!0},p(t,m){const u={};m&2&&(u.$$scope={dirty:m,ctx:t}),e.$set(u)},i(t){c||(y(e.$$.fragment,t),c=!0)},o(t){j(e.$$.fragment,t),c=!1},d(t){b(e,t)}}}function ft(Z){let e,c=`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(){e=w("p"),e.innerHTML=c},l(t){e=$(t,"P",{"data-svelte-h":!0}),k(e)!=="svelte-1c4g6cv"&&(e.innerHTML=c)},m(t,m){l(t,e,m)},p:ss,d(t){t&&a(e)}}}function gt(Z){let e,c="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:",t,m,u,d,G="Pass your inputs to the model and return the <code>logits</code> of the masked token:",C,v,I,U,H="Then return the three masked tokens with the highest probability and print them out:",R,x,X;return m=new W({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMEF1dG9Ub2tlbml6ZXIlMEElMEF0b2tlbml6ZXIlMjAlM0QlMjBBdXRvVG9rZW5pemVyLmZyb21fcHJldHJhaW5lZCglMjJ1c2VybmFtZSUyRm15X2F3ZXNvbWVfZWxpNV9tbG1fbW9kZWwlMjIpJTBBaW5wdXRzJTIwJTNEJTIwdG9rZW5pemVyKHRleHQlMkMlMjByZXR1cm5fdGVuc29ycyUzRCUyMnB0JTIyKSUwQW1hc2tfdG9rZW5faW5kZXglMjAlM0QlMjB0b3JjaC53aGVyZShpbnB1dHMlNUIlMjJpbnB1dF9pZHMlMjIlNUQlMjAlM0QlM0QlMjB0b2tlbml6ZXIubWFza190b2tlbl9pZCklNUIxJTVE",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;username/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}}),v=new W({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMEF1dG9Nb2RlbEZvck1hc2tlZExNJTBBJTBBbW9kZWwlMjAlM0QlMjBBdXRvTW9kZWxGb3JNYXNrZWRMTS5mcm9tX3ByZXRyYWluZWQoJTIydXNlcm5hbWUlMkZteV9hd2Vzb21lX2VsaTVfbWxtX21vZGVsJTIyKSUwQWxvZ2l0cyUyMCUzRCUyMG1vZGVsKCoqaW5wdXRzKS5sb2dpdHMlMEFtYXNrX3Rva2VuX2xvZ2l0cyUyMCUzRCUyMGxvZ2l0cyU1QjAlMkMlMjBtYXNrX3Rva2VuX2luZGV4JTJDJTIwJTNBJTVE",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;username/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 W({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=w("p"),e.innerHTML=c,t=o(),f(m.$$.fragment),u=o(),d=w("p"),d.innerHTML=G,C=o(),f(v.$$.fragment),I=o(),U=w("p"),U.textContent=H,R=o(),f(x.$$.fragment)},l(p){e=$(p,"P",{"data-svelte-h":!0}),k(e)!=="svelte-1rt88cg"&&(e.innerHTML=c),t=i(p),g(m.$$.fragment,p),u=i(p),d=$(p,"P",{"data-svelte-h":!0}),k(d)!=="svelte-1abk23t"&&(d.innerHTML=G),C=i(p),g(v.$$.fragment,p),I=i(p),U=$(p,"P",{"data-svelte-h":!0}),k(U)!=="svelte-jux2mn"&&(U.textContent=H),R=i(p),g(x.$$.fragment,p)},m(p,T){l(p,e,T),l(p,t,T),M(m,p,T),l(p,u,T),l(p,d,T),l(p,C,T),M(v,p,T),l(p,I,T),l(p,U,T),l(p,R,T),M(x,p,T),X=!0},p:ss,i(p){X||(y(m.$$.fragment,p),y(v.$$.fragment,p),y(x.$$.fragment,p),X=!0)},o(p){j(m.$$.fragment,p),j(v.$$.fragment,p),j(x.$$.fragment,p),X=!1},d(p){p&&(a(e),a(t),a(u),a(d),a(C),a(I),a(U),a(R)),b(m,p),b(v,p),b(x,p)}}}function Mt(Z){let e,c;return e=new Is({props:{$$slots:{default:[gt]},$$scope:{ctx:Z}}}),{c(){f(e.$$.fragment)},l(t){g(e.$$.fragment,t)},m(t,m){M(e,t,m),c=!0},p(t,m){const u={};m&2&&(u.$$scope={dirty:m,ctx:t}),e.$set(u)},i(t){c||(y(e.$$.fragment,t),c=!0)},o(t){j(e.$$.fragment,t),c=!1},d(t){b(e,t)}}}function yt(Z){let e,c="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:",t,m,u,d,G="Pass your inputs to the model and return the <code>logits</code> of the masked token:",C,v,I,U,H="Then return the three masked tokens with the highest probability and print them out:",R,x,X;return m=new W({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMEF1dG9Ub2tlbml6ZXIlMEElMEF0b2tlbml6ZXIlMjAlM0QlMjBBdXRvVG9rZW5pemVyLmZyb21fcHJldHJhaW5lZCglMjJ1c2VybmFtZSUyRm15X2F3ZXNvbWVfZWxpNV9tbG1fbW9kZWwlMjIpJTBBaW5wdXRzJTIwJTNEJTIwdG9rZW5pemVyKHRleHQlMkMlMjByZXR1cm5fdGVuc29ycyUzRCUyMnRmJTIyKSUwQW1hc2tfdG9rZW5faW5kZXglMjAlM0QlMjB0Zi53aGVyZShpbnB1dHMlNUIlMjJpbnB1dF9pZHMlMjIlNUQlMjAlM0QlM0QlMjB0b2tlbml6ZXIubWFza190b2tlbl9pZCklNUIwJTJDJTIwMSU1RA==",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;username/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}}),v=new W({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMFRGQXV0b01vZGVsRm9yTWFza2VkTE0lMEElMEFtb2RlbCUyMCUzRCUyMFRGQXV0b01vZGVsRm9yTWFza2VkTE0uZnJvbV9wcmV0cmFpbmVkKCUyMnVzZXJuYW1lJTJGbXlfYXdlc29tZV9lbGk1X21sbV9tb2RlbCUyMiklMEFsb2dpdHMlMjAlM0QlMjBtb2RlbCgqKmlucHV0cykubG9naXRzJTBBbWFza190b2tlbl9sb2dpdHMlMjAlM0QlMjBsb2dpdHMlNUIwJTJDJTIwbWFza190b2tlbl9pbmRleCUyQyUyMCUzQSU1RA==",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;username/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 W({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=w("p"),e.innerHTML=c,t=o(),f(m.$$.fragment),u=o(),d=w("p"),d.innerHTML=G,C=o(),f(v.$$.fragment),I=o(),U=w("p"),U.textContent=H,R=o(),f(x.$$.fragment)},l(p){e=$(p,"P",{"data-svelte-h":!0}),k(e)!=="svelte-h6kxlc"&&(e.innerHTML=c),t=i(p),g(m.$$.fragment,p),u=i(p),d=$(p,"P",{"data-svelte-h":!0}),k(d)!=="svelte-1abk23t"&&(d.innerHTML=G),C=i(p),g(v.$$.fragment,p),I=i(p),U=$(p,"P",{"data-svelte-h":!0}),k(U)!=="svelte-jux2mn"&&(U.textContent=H),R=i(p),g(x.$$.fragment,p)},m(p,T){l(p,e,T),l(p,t,T),M(m,p,T),l(p,u,T),l(p,d,T),l(p,C,T),M(v,p,T),l(p,I,T),l(p,U,T),l(p,R,T),M(x,p,T),X=!0},p:ss,i(p){X||(y(m.$$.fragment,p),y(v.$$.fragment,p),y(x.$$.fragment,p),X=!0)},o(p){j(m.$$.fragment,p),j(v.$$.fragment,p),j(x.$$.fragment,p),X=!1},d(p){p&&(a(e),a(t),a(u),a(d),a(C),a(I),a(U),a(R)),b(m,p),b(v,p),b(x,p)}}}function jt(Z){let e,c;return e=new Is({props:{$$slots:{default:[yt]},$$scope:{ctx:Z}}}),{c(){f(e.$$.fragment)},l(t){g(e.$$.fragment,t)},m(t,m){M(e,t,m),c=!0},p(t,m){const u={};m&2&&(u.$$scope={dirty:m,ctx:t}),e.$set(u)},i(t){c||(y(e.$$.fragment,t),c=!0)},o(t){j(e.$$.fragment,t),c=!1},d(t){b(e,t)}}}function bt(Z){let e,c,t,m,u,d,G,C,v,I,U,H=`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.`,R,x,X="This guide will show you how to:",p,T,E='<li>Finetune <a href="https://huggingface.co/distilbert/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>',z,V,Y,Q,N="Before you begin, make sure you have all the necessary libraries installed:",F,B,h,J,L="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:",S,A,es,q,r,_,Rs='Start by loading the first 5000 examples from the <a href="https://huggingface.co/datasets/eli5_category" rel="nofollow">ELI5-Category</a> dataset with 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.',Bs,ts,zs,as,Te='Split the dataset’s <code>train</code> split into a train and test set with the <a href="https://huggingface.co/docs/datasets/main/en/package_reference/main_classes#datasets.Dataset.train_test_split" rel="nofollow">train_test_split</a> method:',Fs,ls,Hs,ns,xe="Then take a look at an example:",Es,ps,Ys,rs,_e="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.",Qs,os,Ns,is,As,ms,Je="For masked language modeling, the next step is to load a DistilRoBERTa tokenizer to process the <code>text</code> subfield:",Ls,cs,qs,hs,Ue='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 extract the <code>text</code> subfield from its nested structure with the <a href="https://huggingface.co/docs/datasets/process#flatten" rel="nofollow"><code>flatten</code></a> method:',Ss,ds,Ps,us,Ze=`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.`,Ds,fs,Ge="Here is a first preprocessing function to join the list of strings for each example and tokenize the result:",Ks,gs,Os,Ms,ve='To apply this preprocessing function over the entire dataset, use the 🤗 Datasets <a href="https://huggingface.co/docs/datasets/main/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:',se,ys,ee,js,We="This dataset contains the token sequences, but some of these are longer than the maximum input length for the model.",te,bs,Ce="You can now use a second preprocessing function to",ae,ws,Ie="<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>",le,$s,ne,ks,Re="Apply the <code>group_texts</code> function over the entire dataset:",pe,Ts,re,xs,Xe='Now create a batch of examples using <a href="/docs/transformers/pr_30530/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.',oe,P,ie,_s,me,D,ce,K,he,Js,de,Us,Ve="Great, now that you’ve finetuned a model, you can use it for inference!",ue,Zs,Be="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:",fe,Gs,ge,vs,ze='The simplest way to try out your finetuned model for inference is to use it in a <a href="/docs/transformers/pr_30530/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:',Me,Ws,ye,O,je,Cs,be,Xs,we;return u=new Vs({props:{title:"Masked language modeling",local:"masked-language-modeling",headingTag:"h1"}}),G=new tt({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"}]}}),v=new Le({props:{id:"mqElG5QJWUg"}}),V=new $e({props:{$$slots:{default:[lt]},$$scope:{ctx:Z}}}),B=new W({props:{code:"cGlwJTIwaW5zdGFsbCUyMHRyYW5zZm9ybWVycyUyMGRhdGFzZXRzJTIwZXZhbHVhdGU=",highlighted:"pip install transformers datasets evaluate",wrap:!1}}),A=new W({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:"Load ELI5 dataset",local:"load-eli5-dataset",headingTag:"h2"}}),ts=new W({props:{code:"ZnJvbSUyMGRhdGFzZXRzJTIwaW1wb3J0JTIwbG9hZF9kYXRhc2V0JTBBJTBBZWxpNSUyMCUzRCUyMGxvYWRfZGF0YXNldCglMjJlbGk1X2NhdGVnb3J5JTIyJTJDJTIwc3BsaXQlM0QlMjJ0cmFpbiU1QiUzQTUwMDAlNUQlMjIp",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_category&quot;</span>, split=<span class="hljs-string">&quot;train[:5000]&quot;</span>)`,wrap:!1}}),ls=new W({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 W({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;q_id&#x27;</span>: <span class="hljs-string">&#x27;7h191n&#x27;</span>,
 <span class="hljs-string">&#x27;title&#x27;</span>: <span class="hljs-string">&#x27;What does the tax bill that was passed today mean? How will it affect Americans in each tax bracket?&#x27;</span>,
 <span class="hljs-string">&#x27;selftext&#x27;</span>: <span class="hljs-string">&#x27;&#x27;</span>,
 <span class="hljs-string">&#x27;category&#x27;</span>: <span class="hljs-string">&#x27;Economics&#x27;</span>,
 <span class="hljs-string">&#x27;subreddit&#x27;</span>: <span class="hljs-string">&#x27;explainlikeimfive&#x27;</span>,
 <span class="hljs-string">&#x27;answers&#x27;</span>: {<span class="hljs-string">&#x27;a_id&#x27;</span>: [<span class="hljs-string">&#x27;dqnds8l&#x27;</span>, <span class="hljs-string">&#x27;dqnd1jl&#x27;</span>, <span class="hljs-string">&#x27;dqng3i1&#x27;</span>, <span class="hljs-string">&#x27;dqnku5x&#x27;</span>],
  <span class="hljs-string">&#x27;text&#x27;</span>: [<span class="hljs-string">&quot;The tax bill is 500 pages long and there were a lot of changes still going on right to the end. It&#x27;s not just an adjustment to the income tax brackets, it&#x27;s a whole bunch of changes. As such there is no good answer to your question. The big take aways are: - Big reduction in corporate income tax rate will make large companies very happy. - Pass through rate change will make certain styles of business (law firms, hedge funds) extremely happy - Income tax changes are moderate, and are set to expire (though it&#x27;s the kind of thing that might just always get re-applied without being made permanent) - People in high tax states (California, New York) lose out, and many of them will end up with their taxes raised.&quot;</span>,
   <span class="hljs-string">&#x27;None yet. It has to be reconciled with a vastly different house bill and then passed again.&#x27;</span>,
   <span class="hljs-string">&#x27;Also: does this apply to 2017 taxes? Or does it start with 2018 taxes?&#x27;</span>,
   <span class="hljs-string">&#x27;This article explains both the House and senate bills, including the proposed changes to your income taxes based on your income level. URL_0&#x27;</span>],
  <span class="hljs-string">&#x27;score&#x27;</span>: [<span class="hljs-number">21</span>, <span class="hljs-number">19</span>, <span class="hljs-number">5</span>, <span class="hljs-number">3</span>],
  <span class="hljs-string">&#x27;text_urls&#x27;</span>: [[],
   [],
   [],
   [<span class="hljs-string">&#x27;https://www.investopedia.com/news/trumps-tax-reform-what-can-be-done/&#x27;</span>]]},
 <span class="hljs-string">&#x27;title_urls&#x27;</span>: [<span class="hljs-string">&#x27;url&#x27;</span>],
 <span class="hljs-string">&#x27;selftext_urls&#x27;</span>: [<span class="hljs-string">&#x27;url&#x27;</span>]}`,wrap:!1}}),os=new Vs({props:{title:"Preprocess",local:"preprocess",headingTag:"h2"}}),is=new Le({props:{id:"8PmhEIXhBvI"}}),cs=new W({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMEF1dG9Ub2tlbml6ZXIlMEElMEF0b2tlbml6ZXIlMjAlM0QlMjBBdXRvVG9rZW5pemVyLmZyb21fcHJldHJhaW5lZCglMjJkaXN0aWxiZXJ0JTJGZGlzdGlscm9iZXJ0YS1iYXNlJTIyKQ==",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;distilbert/distilroberta-base&quot;</span>)`,wrap:!1}}),ds=new W({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;q_id&#x27;</span>: <span class="hljs-string">&#x27;7h191n&#x27;</span>,
 <span class="hljs-string">&#x27;title&#x27;</span>: <span class="hljs-string">&#x27;What does the tax bill that was passed today mean? How will it affect Americans in each tax bracket?&#x27;</span>,
 <span class="hljs-string">&#x27;selftext&#x27;</span>: <span class="hljs-string">&#x27;&#x27;</span>,
 <span class="hljs-string">&#x27;category&#x27;</span>: <span class="hljs-string">&#x27;Economics&#x27;</span>,
 <span class="hljs-string">&#x27;subreddit&#x27;</span>: <span class="hljs-string">&#x27;explainlikeimfive&#x27;</span>,
 <span class="hljs-string">&#x27;answers.a_id&#x27;</span>: [<span class="hljs-string">&#x27;dqnds8l&#x27;</span>, <span class="hljs-string">&#x27;dqnd1jl&#x27;</span>, <span class="hljs-string">&#x27;dqng3i1&#x27;</span>, <span class="hljs-string">&#x27;dqnku5x&#x27;</span>],
 <span class="hljs-string">&#x27;answers.text&#x27;</span>: [<span class="hljs-string">&quot;The tax bill is 500 pages long and there were a lot of changes still going on right to the end. It&#x27;s not just an adjustment to the income tax brackets, it&#x27;s a whole bunch of changes. As such there is no good answer to your question. The big take aways are: - Big reduction in corporate income tax rate will make large companies very happy. - Pass through rate change will make certain styles of business (law firms, hedge funds) extremely happy - Income tax changes are moderate, and are set to expire (though it&#x27;s the kind of thing that might just always get re-applied without being made permanent) - People in high tax states (California, New York) lose out, and many of them will end up with their taxes raised.&quot;</span>,
  <span class="hljs-string">&#x27;None yet. It has to be reconciled with a vastly different house bill and then passed again.&#x27;</span>,
  <span class="hljs-string">&#x27;Also: does this apply to 2017 taxes? Or does it start with 2018 taxes?&#x27;</span>,
  <span class="hljs-string">&#x27;This article explains both the House and senate bills, including the proposed changes to your income taxes based on your income level. URL_0&#x27;</span>],
 <span class="hljs-string">&#x27;answers.score&#x27;</span>: [<span class="hljs-number">21</span>, <span class="hljs-number">19</span>, <span class="hljs-number">5</span>, <span class="hljs-number">3</span>],
 <span class="hljs-string">&#x27;answers.text_urls&#x27;</span>: [[],
  [],
  [],
  [<span class="hljs-string">&#x27;https://www.investopedia.com/news/trumps-tax-reform-what-can-be-done/&#x27;</span>]],
 <span class="hljs-string">&#x27;title_urls&#x27;</span>: [<span class="hljs-string">&#x27;url&#x27;</span>],
 <span class="hljs-string">&#x27;selftext_urls&#x27;</span>: [<span class="hljs-string">&#x27;url&#x27;</span>]}`,wrap:!1}}),gs=new W({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 W({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}}),$s=new W({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}}),Ts=new W({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 ke({props:{pytorch:!0,tensorflow:!0,jax:!1,$$slots:{tensorflow:[ot],pytorch:[pt]},$$scope:{ctx:Z}}}),_s=new Vs({props:{title:"Train",local:"train",headingTag:"h2"}}),D=new ke({props:{pytorch:!0,tensorflow:!0,jax:!1,$$slots:{tensorflow:[ut],pytorch:[ct]},$$scope:{ctx:Z}}}),K=new $e({props:{$$slots:{default:[ft]},$$scope:{ctx:Z}}}),Js=new Vs({props:{title:"Inference",local:"inference",headingTag:"h2"}}),Gs=new W({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}}),Ws=new W({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMHBpcGVsaW5lJTBBJTBBbWFza19maWxsZXIlMjAlM0QlMjBwaXBlbGluZSglMjJmaWxsLW1hc2slMjIlMkMlMjAlMjJ1c2VybmFtZSUyRm15X2F3ZXNvbWVfZWxpNV9tbG1fbW9kZWwlMjIpJTBBbWFza19maWxsZXIodGV4dCUyQyUyMHRvcF9rJTNEMyk=",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;username/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 ke({props:{pytorch:!0,tensorflow:!0,jax:!1,$$slots:{tensorflow:[jt],pytorch:[Mt]},$$scope:{ctx:Z}}}),Cs=new at({props:{source:"https://github.com/huggingface/transformers/blob/main/docs/source/en/tasks/masked_language_modeling.md"}}),{c(){e=w("meta"),c=o(),t=w("p"),m=o(),f(u.$$.fragment),d=o(),f(G.$$.fragment),C=o(),f(v.$$.fragment),I=o(),U=w("p"),U.textContent=H,R=o(),x=w("p"),x.textContent=X,p=o(),T=w("ol"),T.innerHTML=E,z=o(),f(V.$$.fragment),Y=o(),Q=w("p"),Q.textContent=N,F=o(),f(B.$$.fragment),h=o(),J=w("p"),J.textContent=L,S=o(),f(A.$$.fragment),es=o(),f(q.$$.fragment),r=o(),_=w("p"),_.innerHTML=Rs,Bs=o(),f(ts.$$.fragment),zs=o(),as=w("p"),as.innerHTML=Te,Fs=o(),f(ls.$$.fragment),Hs=o(),ns=w("p"),ns.textContent=xe,Es=o(),f(ps.$$.fragment),Ys=o(),rs=w("p"),rs.innerHTML=_e,Qs=o(),f(os.$$.fragment),Ns=o(),f(is.$$.fragment),As=o(),ms=w("p"),ms.innerHTML=Je,Ls=o(),f(cs.$$.fragment),qs=o(),hs=w("p"),hs.innerHTML=Ue,Ss=o(),f(ds.$$.fragment),Ps=o(),us=w("p"),us.innerHTML=Ze,Ds=o(),fs=w("p"),fs.textContent=Ge,Ks=o(),f(gs.$$.fragment),Os=o(),Ms=w("p"),Ms.innerHTML=ve,se=o(),f(ys.$$.fragment),ee=o(),js=w("p"),js.textContent=We,te=o(),bs=w("p"),bs.textContent=Ce,ae=o(),ws=w("ul"),ws.innerHTML=Ie,le=o(),f($s.$$.fragment),ne=o(),ks=w("p"),ks.innerHTML=Re,pe=o(),f(Ts.$$.fragment),re=o(),xs=w("p"),xs.innerHTML=Xe,oe=o(),f(P.$$.fragment),ie=o(),f(_s.$$.fragment),me=o(),f(D.$$.fragment),ce=o(),f(K.$$.fragment),he=o(),f(Js.$$.fragment),de=o(),Us=w("p"),Us.textContent=Ve,ue=o(),Zs=w("p"),Zs.innerHTML=Be,fe=o(),f(Gs.$$.fragment),ge=o(),vs=w("p"),vs.innerHTML=ze,Me=o(),f(Ws.$$.fragment),ye=o(),f(O.$$.fragment),je=o(),f(Cs.$$.fragment),be=o(),Xs=w("p"),this.h()},l(s){const n=Ke("svelte-u9bgzb",document.head);e=$(n,"META",{name:!0,content:!0}),n.forEach(a),c=i(s),t=$(s,"P",{}),Ne(t).forEach(a),m=i(s),g(u.$$.fragment,s),d=i(s),g(G.$$.fragment,s),C=i(s),g(v.$$.fragment,s),I=i(s),U=$(s,"P",{"data-svelte-h":!0}),k(U)!=="svelte-ed5ap0"&&(U.textContent=H),R=i(s),x=$(s,"P",{"data-svelte-h":!0}),k(x)!=="svelte-1aff4p7"&&(x.textContent=X),p=i(s),T=$(s,"OL",{"data-svelte-h":!0}),k(T)!=="svelte-k2329c"&&(T.innerHTML=E),z=i(s),g(V.$$.fragment,s),Y=i(s),Q=$(s,"P",{"data-svelte-h":!0}),k(Q)!=="svelte-1c9nexd"&&(Q.textContent=N),F=i(s),g(B.$$.fragment,s),h=i(s),J=$(s,"P",{"data-svelte-h":!0}),k(J)!=="svelte-27hn0u"&&(J.textContent=L),S=i(s),g(A.$$.fragment,s),es=i(s),g(q.$$.fragment,s),r=i(s),_=$(s,"P",{"data-svelte-h":!0}),k(_)!=="svelte-1172m8d"&&(_.innerHTML=Rs),Bs=i(s),g(ts.$$.fragment,s),zs=i(s),as=$(s,"P",{"data-svelte-h":!0}),k(as)!=="svelte-rugbz4"&&(as.innerHTML=Te),Fs=i(s),g(ls.$$.fragment,s),Hs=i(s),ns=$(s,"P",{"data-svelte-h":!0}),k(ns)!=="svelte-1m91ua0"&&(ns.textContent=xe),Es=i(s),g(ps.$$.fragment,s),Ys=i(s),rs=$(s,"P",{"data-svelte-h":!0}),k(rs)!=="svelte-dtsbii"&&(rs.innerHTML=_e),Qs=i(s),g(os.$$.fragment,s),Ns=i(s),g(is.$$.fragment,s),As=i(s),ms=$(s,"P",{"data-svelte-h":!0}),k(ms)!=="svelte-i99oeh"&&(ms.innerHTML=Je),Ls=i(s),g(cs.$$.fragment,s),qs=i(s),hs=$(s,"P",{"data-svelte-h":!0}),k(hs)!=="svelte-1275j7o"&&(hs.innerHTML=Ue),Ss=i(s),g(ds.$$.fragment,s),Ps=i(s),us=$(s,"P",{"data-svelte-h":!0}),k(us)!=="svelte-1mdv3gu"&&(us.innerHTML=Ze),Ds=i(s),fs=$(s,"P",{"data-svelte-h":!0}),k(fs)!=="svelte-njkc6i"&&(fs.textContent=Ge),Ks=i(s),g(gs.$$.fragment,s),Os=i(s),Ms=$(s,"P",{"data-svelte-h":!0}),k(Ms)!=="svelte-1xbgtq4"&&(Ms.innerHTML=ve),se=i(s),g(ys.$$.fragment,s),ee=i(s),js=$(s,"P",{"data-svelte-h":!0}),k(js)!=="svelte-pz0l04"&&(js.textContent=We),te=i(s),bs=$(s,"P",{"data-svelte-h":!0}),k(bs)!=="svelte-5guq64"&&(bs.textContent=Ce),ae=i(s),ws=$(s,"UL",{"data-svelte-h":!0}),k(ws)!=="svelte-vz17je"&&(ws.innerHTML=Ie),le=i(s),g($s.$$.fragment,s),ne=i(s),ks=$(s,"P",{"data-svelte-h":!0}),k(ks)!=="svelte-1o69amy"&&(ks.innerHTML=Re),pe=i(s),g(Ts.$$.fragment,s),re=i(s),xs=$(s,"P",{"data-svelte-h":!0}),k(xs)!=="svelte-1ds6m60"&&(xs.innerHTML=Xe),oe=i(s),g(P.$$.fragment,s),ie=i(s),g(_s.$$.fragment,s),me=i(s),g(D.$$.fragment,s),ce=i(s),g(K.$$.fragment,s),he=i(s),g(Js.$$.fragment,s),de=i(s),Us=$(s,"P",{"data-svelte-h":!0}),k(Us)!=="svelte-633ppb"&&(Us.textContent=Ve),ue=i(s),Zs=$(s,"P",{"data-svelte-h":!0}),k(Zs)!=="svelte-9jago5"&&(Zs.innerHTML=Be),fe=i(s),g(Gs.$$.fragment,s),ge=i(s),vs=$(s,"P",{"data-svelte-h":!0}),k(vs)!=="svelte-1jb8gw"&&(vs.innerHTML=ze),Me=i(s),g(Ws.$$.fragment,s),ye=i(s),g(O.$$.fragment,s),je=i(s),g(Cs.$$.fragment,s),be=i(s),Xs=$(s,"P",{}),Ne(Xs).forEach(a),this.h()},h(){Ae(e,"name","hf:doc:metadata"),Ae(e,"content",wt)},m(s,n){Oe(document.head,e),l(s,c,n),l(s,t,n),l(s,m,n),M(u,s,n),l(s,d,n),M(G,s,n),l(s,C,n),M(v,s,n),l(s,I,n),l(s,U,n),l(s,R,n),l(s,x,n),l(s,p,n),l(s,T,n),l(s,z,n),M(V,s,n),l(s,Y,n),l(s,Q,n),l(s,F,n),M(B,s,n),l(s,h,n),l(s,J,n),l(s,S,n),M(A,s,n),l(s,es,n),M(q,s,n),l(s,r,n),l(s,_,n),l(s,Bs,n),M(ts,s,n),l(s,zs,n),l(s,as,n),l(s,Fs,n),M(ls,s,n),l(s,Hs,n),l(s,ns,n),l(s,Es,n),M(ps,s,n),l(s,Ys,n),l(s,rs,n),l(s,Qs,n),M(os,s,n),l(s,Ns,n),M(is,s,n),l(s,As,n),l(s,ms,n),l(s,Ls,n),M(cs,s,n),l(s,qs,n),l(s,hs,n),l(s,Ss,n),M(ds,s,n),l(s,Ps,n),l(s,us,n),l(s,Ds,n),l(s,fs,n),l(s,Ks,n),M(gs,s,n),l(s,Os,n),l(s,Ms,n),l(s,se,n),M(ys,s,n),l(s,ee,n),l(s,js,n),l(s,te,n),l(s,bs,n),l(s,ae,n),l(s,ws,n),l(s,le,n),M($s,s,n),l(s,ne,n),l(s,ks,n),l(s,pe,n),M(Ts,s,n),l(s,re,n),l(s,xs,n),l(s,oe,n),M(P,s,n),l(s,ie,n),M(_s,s,n),l(s,me,n),M(D,s,n),l(s,ce,n),M(K,s,n),l(s,he,n),M(Js,s,n),l(s,de,n),l(s,Us,n),l(s,ue,n),l(s,Zs,n),l(s,fe,n),M(Gs,s,n),l(s,ge,n),l(s,vs,n),l(s,Me,n),M(Ws,s,n),l(s,ye,n),M(O,s,n),l(s,je,n),M(Cs,s,n),l(s,be,n),l(s,Xs,n),we=!0},p(s,[n]){const Fe={};n&2&&(Fe.$$scope={dirty:n,ctx:s}),V.$set(Fe);const He={};n&2&&(He.$$scope={dirty:n,ctx:s}),P.$set(He);const Ee={};n&2&&(Ee.$$scope={dirty:n,ctx:s}),D.$set(Ee);const Ye={};n&2&&(Ye.$$scope={dirty:n,ctx:s}),K.$set(Ye);const Qe={};n&2&&(Qe.$$scope={dirty:n,ctx:s}),O.$set(Qe)},i(s){we||(y(u.$$.fragment,s),y(G.$$.fragment,s),y(v.$$.fragment,s),y(V.$$.fragment,s),y(B.$$.fragment,s),y(A.$$.fragment,s),y(q.$$.fragment,s),y(ts.$$.fragment,s),y(ls.$$.fragment,s),y(ps.$$.fragment,s),y(os.$$.fragment,s),y(is.$$.fragment,s),y(cs.$$.fragment,s),y(ds.$$.fragment,s),y(gs.$$.fragment,s),y(ys.$$.fragment,s),y($s.$$.fragment,s),y(Ts.$$.fragment,s),y(P.$$.fragment,s),y(_s.$$.fragment,s),y(D.$$.fragment,s),y(K.$$.fragment,s),y(Js.$$.fragment,s),y(Gs.$$.fragment,s),y(Ws.$$.fragment,s),y(O.$$.fragment,s),y(Cs.$$.fragment,s),we=!0)},o(s){j(u.$$.fragment,s),j(G.$$.fragment,s),j(v.$$.fragment,s),j(V.$$.fragment,s),j(B.$$.fragment,s),j(A.$$.fragment,s),j(q.$$.fragment,s),j(ts.$$.fragment,s),j(ls.$$.fragment,s),j(ps.$$.fragment,s),j(os.$$.fragment,s),j(is.$$.fragment,s),j(cs.$$.fragment,s),j(ds.$$.fragment,s),j(gs.$$.fragment,s),j(ys.$$.fragment,s),j($s.$$.fragment,s),j(Ts.$$.fragment,s),j(P.$$.fragment,s),j(_s.$$.fragment,s),j(D.$$.fragment,s),j(K.$$.fragment,s),j(Js.$$.fragment,s),j(Gs.$$.fragment,s),j(Ws.$$.fragment,s),j(O.$$.fragment,s),j(Cs.$$.fragment,s),we=!1},d(s){s&&(a(c),a(t),a(m),a(d),a(C),a(I),a(U),a(R),a(x),a(p),a(T),a(z),a(Y),a(Q),a(F),a(h),a(J),a(S),a(es),a(r),a(_),a(Bs),a(zs),a(as),a(Fs),a(Hs),a(ns),a(Es),a(Ys),a(rs),a(Qs),a(Ns),a(As),a(ms),a(Ls),a(qs),a(hs),a(Ss),a(Ps),a(us),a(Ds),a(fs),a(Ks),a(Os),a(Ms),a(se),a(ee),a(js),a(te),a(bs),a(ae),a(ws),a(le),a(ne),a(ks),a(pe),a(re),a(xs),a(oe),a(ie),a(me),a(ce),a(he),a(de),a(Us),a(ue),a(Zs),a(fe),a(ge),a(vs),a(Me),a(ye),a(je),a(be),a(Xs)),a(e),b(u,s),b(G,s),b(v,s),b(V,s),b(B,s),b(A,s),b(q,s),b(ts,s),b(ls,s),b(ps,s),b(os,s),b(is,s),b(cs,s),b(ds,s),b(gs,s),b(ys,s),b($s,s),b(Ts,s),b(P,s),b(_s,s),b(D,s),b(K,s),b(Js,s),b(Gs,s),b(Ws,s),b(O,s),b(Cs,s)}}}const wt='{"title":"Masked language modeling","local":"masked-language-modeling","sections":[{"title":"Load ELI5 dataset","local":"load-eli5-dataset","sections":[],"depth":2},{"title":"Preprocess","local":"preprocess","sections":[],"depth":2},{"title":"Train","local":"train","sections":[],"depth":2},{"title":"Inference","local":"inference","sections":[],"depth":2}],"depth":1}';function $t(Z){return Se(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class vt extends Pe{constructor(e){super(),De(this,e,$t,bt,qe,{})}}export{vt as component};
