import{s as Dt,o as Kt,n as te}from"../chunks/scheduler.9bc65507.js";import{S as Ot,i as es,g as $,s as i,r as d,A as ts,h as j,f as s,c as m,j as Qt,u as g,x as T,k as Nt,y as ss,a as l,v as y,d as M,t as b,w,m as Pt,n as St}from"../chunks/index.707bf1b6.js";import{T as jt}from"../chunks/Tip.c2ecdbf4.js";import{Y as qt}from"../chunks/Youtube.e1129c6f.js";import{C as I}from"../chunks/CodeBlock.54a9f38d.js";import{D as as}from"../chunks/DocNotebookDropdown.3e6b3817.js";import{F as Tt,M as Re}from"../chunks/Markdown.8ab98a13.js";import{H as Xe}from"../chunks/Heading.342b1fa6.js";function ls(U){let t,c,a='<a href="../model_doc/bart">BART</a>, <a href="../model_doc/bert">BERT</a>, <a href="../model_doc/bert-generation">Bert Generation</a>, <a href="../model_doc/big_bird">BigBird</a>, <a href="../model_doc/bigbird_pegasus">BigBird-Pegasus</a>, <a href="../model_doc/biogpt">BioGpt</a>, <a href="../model_doc/blenderbot">Blenderbot</a>, <a href="../model_doc/blenderbot-small">BlenderbotSmall</a>, <a href="../model_doc/bloom">BLOOM</a>, <a href="../model_doc/camembert">CamemBERT</a>, <a href="../model_doc/code_llama">CodeLlama</a>, <a href="../model_doc/codegen">CodeGen</a>, <a href="../model_doc/cpmant">CPM-Ant</a>, <a href="../model_doc/ctrl">CTRL</a>, <a href="../model_doc/data2vec-text">Data2VecText</a>, <a href="../model_doc/electra">ELECTRA</a>, <a href="../model_doc/ernie">ERNIE</a>, <a href="../model_doc/falcon">Falcon</a>, <a href="../model_doc/fuyu">Fuyu</a>, <a href="../model_doc/git">GIT</a>, <a href="../model_doc/gpt-sw3">GPT-Sw3</a>, <a href="../model_doc/gpt2">OpenAI GPT-2</a>, <a href="../model_doc/gpt_bigcode">GPTBigCode</a>, <a href="../model_doc/gpt_neo">GPT Neo</a>, <a href="../model_doc/gpt_neox">GPT NeoX</a>, <a href="../model_doc/gpt_neox_japanese">GPT NeoX Japanese</a>, <a href="../model_doc/gptj">GPT-J</a>, <a href="../model_doc/llama">LLaMA</a>, <a href="../model_doc/marian">Marian</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/mistral">Mistral</a>, <a href="../model_doc/mpt">MPT</a>, <a href="../model_doc/musicgen">MusicGen</a>, <a href="../model_doc/mvp">MVP</a>, <a href="../model_doc/open-llama">OpenLlama</a>, <a href="../model_doc/openai-gpt">OpenAI GPT</a>, <a href="../model_doc/opt">OPT</a>, <a href="../model_doc/pegasus">Pegasus</a>, <a href="../model_doc/persimmon">Persimmon</a>, <a href="../model_doc/plbart">PLBart</a>, <a href="../model_doc/prophetnet">ProphetNet</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/rwkv">RWKV</a>, <a href="../model_doc/speech_to_text_2">Speech2Text2</a>, <a href="../model_doc/transfo-xl">Transformer-XL</a>, <a href="../model_doc/trocr">TrOCR</a>, <a href="../model_doc/whisper">Whisper</a>, <a href="../model_doc/xglm">XGLM</a>, <a href="../model_doc/xlm">XLM</a>, <a href="../model_doc/xlm-prophetnet">XLM-ProphetNet</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/xlnet">XLNet</a>, <a href="../model_doc/xmod">X-MOD</a>';return{c(){t=Pt(`You can finetune other architectures for causal language modeling following the same steps in this guide.
Choose one of the following architectures:

`),c=$("p"),c.innerHTML=a},l(r){t=St(r,`You can finetune other architectures for causal language modeling following the same steps in this guide.
Choose one of the following architectures:

`),c=j(r,"P",{"data-svelte-h":!0}),T(c)!=="svelte-14jv5mt"&&(c.innerHTML=a)},m(r,u){l(r,t,u),l(r,c,u)},p:te,d(r){r&&(s(t),s(c))}}}function ns(U){let t,c="Use the end-of-sequence token as the padding token and set <code>mlm=False</code>. This will use the inputs as labels shifted to the right by one element:",a,r,u;return r=new I({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMERhdGFDb2xsYXRvckZvckxhbmd1YWdlTW9kZWxpbmclMEElMEF0b2tlbml6ZXIucGFkX3Rva2VuJTIwJTNEJTIwdG9rZW5pemVyLmVvc190b2tlbiUwQWRhdGFfY29sbGF0b3IlMjAlM0QlMjBEYXRhQ29sbGF0b3JGb3JMYW5ndWFnZU1vZGVsaW5nKHRva2VuaXplciUzRHRva2VuaXplciUyQyUyMG1sbSUzREZhbHNlKQ==",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=<span class="hljs-literal">False</span>)`,wrap:!1}}),{c(){t=$("p"),t.innerHTML=c,a=i(),d(r.$$.fragment)},l(f){t=j(f,"P",{"data-svelte-h":!0}),T(t)!=="svelte-su9ugx"&&(t.innerHTML=c),a=m(f),g(r.$$.fragment,f)},m(f,v){l(f,t,v),l(f,a,v),y(r,f,v),u=!0},p:te,i(f){u||(M(r.$$.fragment,f),u=!0)},o(f){b(r.$$.fragment,f),u=!1},d(f){f&&(s(t),s(a)),w(r,f)}}}function os(U){let t,c;return t=new Re({props:{$$slots:{default:[ns]},$$scope:{ctx:U}}}),{c(){d(t.$$.fragment)},l(a){g(t.$$.fragment,a)},m(a,r){y(t,a,r),c=!0},p(a,r){const u={};r&2&&(u.$$scope={dirty:r,ctx:a}),t.$set(u)},i(a){c||(M(t.$$.fragment,a),c=!0)},o(a){b(t.$$.fragment,a),c=!1},d(a){w(t,a)}}}function rs(U){let t,c="Use the end-of-sequence token as the padding token and set <code>mlm=False</code>. This will use the inputs as labels shifted to the right by one element:",a,r,u;return r=new I({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMERhdGFDb2xsYXRvckZvckxhbmd1YWdlTW9kZWxpbmclMEElMEFkYXRhX2NvbGxhdG9yJTIwJTNEJTIwRGF0YUNvbGxhdG9yRm9yTGFuZ3VhZ2VNb2RlbGluZyh0b2tlbml6ZXIlM0R0b2tlbml6ZXIlMkMlMjBtbG0lM0RGYWxzZSUyQyUyMHJldHVybl90ZW5zb3JzJTNEJTIydGYlMjIp",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=<span class="hljs-literal">False</span>, return_tensors=<span class="hljs-string">&quot;tf&quot;</span>)`,wrap:!1}}),{c(){t=$("p"),t.innerHTML=c,a=i(),d(r.$$.fragment)},l(f){t=j(f,"P",{"data-svelte-h":!0}),T(t)!=="svelte-su9ugx"&&(t.innerHTML=c),a=m(f),g(r.$$.fragment,f)},m(f,v){l(f,t,v),l(f,a,v),y(r,f,v),u=!0},p:te,i(f){u||(M(r.$$.fragment,f),u=!0)},o(f){b(r.$$.fragment,f),u=!1},d(f){f&&(s(t),s(a)),w(r,f)}}}function ps(U){let t,c;return t=new Re({props:{$$slots:{default:[rs]},$$scope:{ctx:U}}}),{c(){d(t.$$.fragment)},l(a){g(t.$$.fragment,a)},m(a,r){y(t,a,r),c=!0},p(a,r){const u={};r&2&&(u.$$scope={dirty:r,ctx:a}),t.$set(u)},i(a){c||(M(t.$$.fragment,a),c=!0)},o(a){b(t.$$.fragment,a),c=!1},d(a){w(t,a)}}}function is(U){let t,c='If you aren’t familiar with finetuning a model with the <a href="/docs/transformers/main/en/main_classes/trainer#transformers.Trainer">Trainer</a>, take a look at the <a href="../training#train-with-pytorch-trainer">basic tutorial</a>!';return{c(){t=$("p"),t.innerHTML=c},l(a){t=j(a,"P",{"data-svelte-h":!0}),T(t)!=="svelte-me8q54"&&(t.innerHTML=c)},m(a,r){l(a,t,r)},p:te,d(a){a&&s(t)}}}function ms(U){let t,c,a,r='You’re ready to start training your model now! Load DistilGPT2 with <a href="/docs/transformers/main/en/model_doc/auto#transformers.AutoModelForCausalLM">AutoModelForCausalLM</a>:',u,f,v,Z,C="At this point, only three steps remain:",W,G,X='<li>Define your training hyperparameters in <a href="/docs/transformers/main/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/main/en/main_classes/trainer#transformers.Trainer">Trainer</a> along with the model, datasets, and data collator.</li> <li>Call <a href="/docs/transformers/main/en/main_classes/trainer#transformers.Trainer.train">train()</a> to finetune your model.</li>',R,x,V,o,_='Once training is completed, use the <a href="/docs/transformers/main/en/main_classes/trainer#transformers.Trainer.evaluate">evaluate()</a> method to evaluate your model and get its perplexity:',A,E,F,Q,N='Then share your model to the Hub with the <a href="/docs/transformers/main/en/main_classes/trainer#transformers.Trainer.push_to_hub">push_to_hub()</a> method so everyone can use your model:',B,Y,z;return t=new jt({props:{$$slots:{default:[is]},$$scope:{ctx:U}}}),f=new I({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMEF1dG9Nb2RlbEZvckNhdXNhbExNJTJDJTIwVHJhaW5pbmdBcmd1bWVudHMlMkMlMjBUcmFpbmVyJTBBJTBBbW9kZWwlMjAlM0QlMjBBdXRvTW9kZWxGb3JDYXVzYWxMTS5mcm9tX3ByZXRyYWluZWQoJTIyZGlzdGlsZ3B0MiUyMik=",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoModelForCausalLM, TrainingArguments, Trainer

<span class="hljs-meta">&gt;&gt;&gt; </span>model = AutoModelForCausalLM.from_pretrained(<span class="hljs-string">&quot;distilgpt2&quot;</span>)`,wrap:!1}}),x=new I({props:{code:"dHJhaW5pbmdfYXJncyUyMCUzRCUyMFRyYWluaW5nQXJndW1lbnRzKCUwQSUyMCUyMCUyMCUyMG91dHB1dF9kaXIlM0QlMjJteV9hd2Vzb21lX2VsaTVfY2xtLW1vZGVsJTIyJTJDJTBBJTIwJTIwJTIwJTIwZXZhbHVhdGlvbl9zdHJhdGVneSUzRCUyMmVwb2NoJTIyJTJDJTBBJTIwJTIwJTIwJTIwbGVhcm5pbmdfcmF0ZSUzRDJlLTUlMkMlMEElMjAlMjAlMjAlMjB3ZWlnaHRfZGVjYXklM0QwLjAxJTJDJTBBJTIwJTIwJTIwJTIwcHVzaF90b19odWIlM0RUcnVlJTJDJTBBKSUwQSUwQXRyYWluZXIlMjAlM0QlMjBUcmFpbmVyKCUwQSUyMCUyMCUyMCUyMG1vZGVsJTNEbW9kZWwlMkMlMEElMjAlMjAlMjAlMjBhcmdzJTNEdHJhaW5pbmdfYXJncyUyQyUwQSUyMCUyMCUyMCUyMHRyYWluX2RhdGFzZXQlM0RsbV9kYXRhc2V0JTVCJTIydHJhaW4lMjIlNUQlMkMlMEElMjAlMjAlMjAlMjBldmFsX2RhdGFzZXQlM0RsbV9kYXRhc2V0JTVCJTIydGVzdCUyMiU1RCUyQyUwQSUyMCUyMCUyMCUyMGRhdGFfY29sbGF0b3IlM0RkYXRhX2NvbGxhdG9yJTJDJTBBKSUwQSUwQXRyYWluZXIudHJhaW4oKQ==",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_clm-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>    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}}),E=new I({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">49.61</span>`,wrap:!1}}),Y=new I({props:{code:"dHJhaW5lci5wdXNoX3RvX2h1Yigp",highlighted:'<span class="hljs-meta">&gt;&gt;&gt; </span>trainer.push_to_hub()',wrap:!1}}),{c(){d(t.$$.fragment),c=i(),a=$("p"),a.innerHTML=r,u=i(),d(f.$$.fragment),v=i(),Z=$("p"),Z.textContent=C,W=i(),G=$("ol"),G.innerHTML=X,R=i(),d(x.$$.fragment),V=i(),o=$("p"),o.innerHTML=_,A=i(),d(E.$$.fragment),F=i(),Q=$("p"),Q.innerHTML=N,B=i(),d(Y.$$.fragment)},l(h){g(t.$$.fragment,h),c=m(h),a=j(h,"P",{"data-svelte-h":!0}),T(a)!=="svelte-1q2so56"&&(a.innerHTML=r),u=m(h),g(f.$$.fragment,h),v=m(h),Z=j(h,"P",{"data-svelte-h":!0}),T(Z)!=="svelte-l42k0i"&&(Z.textContent=C),W=m(h),G=j(h,"OL",{"data-svelte-h":!0}),T(G)!=="svelte-9nzdq0"&&(G.innerHTML=X),R=m(h),g(x.$$.fragment,h),V=m(h),o=j(h,"P",{"data-svelte-h":!0}),T(o)!=="svelte-18h3zoe"&&(o.innerHTML=_),A=m(h),g(E.$$.fragment,h),F=m(h),Q=j(h,"P",{"data-svelte-h":!0}),T(Q)!=="svelte-1ofhil3"&&(Q.innerHTML=N),B=m(h),g(Y.$$.fragment,h)},m(h,k){y(t,h,k),l(h,c,k),l(h,a,k),l(h,u,k),y(f,h,k),l(h,v,k),l(h,Z,k),l(h,W,k),l(h,G,k),l(h,R,k),y(x,h,k),l(h,V,k),l(h,o,k),l(h,A,k),y(E,h,k),l(h,F,k),l(h,Q,k),l(h,B,k),y(Y,h,k),z=!0},p(h,k){const H={};k&2&&(H.$$scope={dirty:k,ctx:h}),t.$set(H)},i(h){z||(M(t.$$.fragment,h),M(f.$$.fragment,h),M(x.$$.fragment,h),M(E.$$.fragment,h),M(Y.$$.fragment,h),z=!0)},o(h){b(t.$$.fragment,h),b(f.$$.fragment,h),b(x.$$.fragment,h),b(E.$$.fragment,h),b(Y.$$.fragment,h),z=!1},d(h){h&&(s(c),s(a),s(u),s(v),s(Z),s(W),s(G),s(R),s(V),s(o),s(A),s(F),s(Q),s(B)),w(t,h),w(f,h),w(x,h),w(E,h),w(Y,h)}}}function cs(U){let t,c;return t=new Re({props:{$$slots:{default:[ms]},$$scope:{ctx:U}}}),{c(){d(t.$$.fragment)},l(a){g(t.$$.fragment,a)},m(a,r){y(t,a,r),c=!0},p(a,r){const u={};r&2&&(u.$$scope={dirty:r,ctx:a}),t.$set(u)},i(a){c||(M(t.$$.fragment,a),c=!0)},o(a){b(t.$$.fragment,a),c=!1},d(a){w(t,a)}}}function hs(U){let t,c='If you aren’t familiar with finetuning a model with Keras, take a look at the <a href="../training#train-a-tensorflow-model-with-keras">basic tutorial</a>!';return{c(){t=$("p"),t.innerHTML=c},l(a){t=j(a,"P",{"data-svelte-h":!0}),T(t)!=="svelte-1mqyx4y"&&(t.innerHTML=c)},m(a,r){l(a,t,r)},p:te,d(a){a&&s(t)}}}function us(U){let t,c,a,r,u,f='Then you can load DistilGPT2 with <a href="/docs/transformers/main/en/model_doc/auto#transformers.TFAutoModelForCausalLM">TFAutoModelForCausalLM</a>:',v,Z,C,W,G='Convert your datasets to the <code>tf.data.Dataset</code> format with <a href="/docs/transformers/main/en/main_classes/model#transformers.TFPreTrainedModel.prepare_tf_dataset">prepare_tf_dataset()</a>:',X,R,x,V,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:',_,A,E,F,Q='This can be done by specifying where to push your model and tokenizer in the <a href="/docs/transformers/main/en/main_classes/keras_callbacks#transformers.PushToHubCallback">PushToHubCallback</a>:',N,B,Y,z,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:',k,H,P,L,We="Once training is completed, your model is automatically uploaded to the Hub so everyone can use it!",S;return t=new jt({props:{$$slots:{default:[hs]},$$scope:{ctx:U}}}),a=new I({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}}),Z=new I({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMFRGQXV0b01vZGVsRm9yQ2F1c2FsTE0lMEElMEFtb2RlbCUyMCUzRCUyMFRGQXV0b01vZGVsRm9yQ2F1c2FsTE0uZnJvbV9wcmV0cmFpbmVkKCUyMmRpc3RpbGdwdDIlMjIp",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> TFAutoModelForCausalLM

<span class="hljs-meta">&gt;&gt;&gt; </span>model = TFAutoModelForCausalLM.from_pretrained(<span class="hljs-string">&quot;distilgpt2&quot;</span>)`,wrap:!1}}),R=new I({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}}),A=new I({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}}),B=new I({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycy5rZXJhc19jYWxsYmFja3MlMjBpbXBvcnQlMjBQdXNoVG9IdWJDYWxsYmFjayUwQSUwQWNhbGxiYWNrJTIwJTNEJTIwUHVzaFRvSHViQ2FsbGJhY2soJTBBJTIwJTIwJTIwJTIwb3V0cHV0X2RpciUzRCUyMm15X2F3ZXNvbWVfZWxpNV9jbG0tbW9kZWwlMjIlMkMlMEElMjAlMjAlMjAlMjB0b2tlbml6ZXIlM0R0b2tlbml6ZXIlMkMlMEEp",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_clm-model&quot;</span>,
<span class="hljs-meta">... </span>    tokenizer=tokenizer,
<span class="hljs-meta">... </span>)`,wrap:!1}}),H=new I({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(){d(t.$$.fragment),c=Pt(`
To finetune a model in TensorFlow, start by setting up an optimizer function, learning rate schedule, and some training hyperparameters:

	`),d(a.$$.fragment),r=i(),u=$("p"),u.innerHTML=f,v=i(),d(Z.$$.fragment),C=i(),W=$("p"),W.innerHTML=G,X=i(),d(R.$$.fragment),x=i(),V=$("p"),V.innerHTML=o,_=i(),d(A.$$.fragment),E=i(),F=$("p"),F.innerHTML=Q,N=i(),d(B.$$.fragment),Y=i(),z=$("p"),z.innerHTML=h,k=i(),d(H.$$.fragment),P=i(),L=$("p"),L.textContent=We},l(p){g(t.$$.fragment,p),c=St(p,`
To finetune a model in TensorFlow, start by setting up an optimizer function, learning rate schedule, and some training hyperparameters:

	`),g(a.$$.fragment,p),r=m(p),u=j(p,"P",{"data-svelte-h":!0}),T(u)!=="svelte-dt80o4"&&(u.innerHTML=f),v=m(p),g(Z.$$.fragment,p),C=m(p),W=j(p,"P",{"data-svelte-h":!0}),T(W)!=="svelte-9ymftz"&&(W.innerHTML=G),X=m(p),g(R.$$.fragment,p),x=m(p),V=j(p,"P",{"data-svelte-h":!0}),T(V)!=="svelte-17cxx5e"&&(V.innerHTML=o),_=m(p),g(A.$$.fragment,p),E=m(p),F=j(p,"P",{"data-svelte-h":!0}),T(F)!=="svelte-1aajtcp"&&(F.innerHTML=Q),N=m(p),g(B.$$.fragment,p),Y=m(p),z=j(p,"P",{"data-svelte-h":!0}),T(z)!=="svelte-1pfsro2"&&(z.innerHTML=h),k=m(p),g(H.$$.fragment,p),P=m(p),L=j(p,"P",{"data-svelte-h":!0}),T(L)!=="svelte-2s71om"&&(L.textContent=We)},m(p,J){y(t,p,J),l(p,c,J),y(a,p,J),l(p,r,J),l(p,u,J),l(p,v,J),y(Z,p,J),l(p,C,J),l(p,W,J),l(p,X,J),y(R,p,J),l(p,x,J),l(p,V,J),l(p,_,J),y(A,p,J),l(p,E,J),l(p,F,J),l(p,N,J),y(B,p,J),l(p,Y,J),l(p,z,J),l(p,k,J),y(H,p,J),l(p,P,J),l(p,L,J),S=!0},p(p,J){const q={};J&2&&(q.$$scope={dirty:J,ctx:p}),t.$set(q)},i(p){S||(M(t.$$.fragment,p),M(a.$$.fragment,p),M(Z.$$.fragment,p),M(R.$$.fragment,p),M(A.$$.fragment,p),M(B.$$.fragment,p),M(H.$$.fragment,p),S=!0)},o(p){b(t.$$.fragment,p),b(a.$$.fragment,p),b(Z.$$.fragment,p),b(R.$$.fragment,p),b(A.$$.fragment,p),b(B.$$.fragment,p),b(H.$$.fragment,p),S=!1},d(p){p&&(s(c),s(r),s(u),s(v),s(C),s(W),s(X),s(x),s(V),s(_),s(E),s(F),s(N),s(Y),s(z),s(k),s(P),s(L)),w(t,p),w(a,p),w(Z,p),w(R,p),w(A,p),w(B,p),w(H,p)}}}function fs(U){let t,c;return t=new Re({props:{$$slots:{default:[us]},$$scope:{ctx:U}}}),{c(){d(t.$$.fragment)},l(a){g(t.$$.fragment,a)},m(a,r){y(t,a,r),c=!0},p(a,r){const u={};r&2&&(u.$$scope={dirty:r,ctx:a}),t.$set(u)},i(a){c||(M(t.$$.fragment,a),c=!0)},o(a){b(t.$$.fragment,a),c=!1},d(a){w(t,a)}}}function ds(U){let t,c=`For a more in-depth example of how to finetune a model for causal 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(){t=$("p"),t.innerHTML=c},l(a){t=j(a,"P",{"data-svelte-h":!0}),T(t)!=="svelte-bbjpvr"&&(t.innerHTML=c)},m(a,r){l(a,t,r)},p:te,d(a){a&&s(t)}}}function gs(U){let t,c="Tokenize the text and return the <code>input_ids</code> as PyTorch tensors:",a,r,u,f,v=`Use the <a href="/docs/transformers/main/en/main_classes/text_generation#transformers.GenerationMixin.generate">generate()</a> method to generate text.
For more details about the different text generation strategies and parameters for controlling generation, check out the <a href="../generation_strategies">Text generation strategies</a> page.`,Z,C,W,G,X="Decode the generated token ids back into text:",R,x,V;return r=new I({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMEF1dG9Ub2tlbml6ZXIlMEElMEF0b2tlbml6ZXIlMjAlM0QlMjBBdXRvVG9rZW5pemVyLmZyb21fcHJldHJhaW5lZCglMjJteV9hd2Vzb21lX2VsaTVfY2xtLW1vZGVsJTIyKSUwQWlucHV0cyUyMCUzRCUyMHRva2VuaXplcihwcm9tcHQlMkMlMjByZXR1cm5fdGVuc29ycyUzRCUyMnB0JTIyKS5pbnB1dF9pZHM=",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoTokenizer

<span class="hljs-meta">&gt;&gt;&gt; </span>tokenizer = AutoTokenizer.from_pretrained(<span class="hljs-string">&quot;my_awesome_eli5_clm-model&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>inputs = tokenizer(prompt, return_tensors=<span class="hljs-string">&quot;pt&quot;</span>).input_ids`,wrap:!1}}),C=new I({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMEF1dG9Nb2RlbEZvckNhdXNhbExNJTBBJTBBbW9kZWwlMjAlM0QlMjBBdXRvTW9kZWxGb3JDYXVzYWxMTS5mcm9tX3ByZXRyYWluZWQoJTIybXlfYXdlc29tZV9lbGk1X2NsbS1tb2RlbCUyMiklMEFvdXRwdXRzJTIwJTNEJTIwbW9kZWwuZ2VuZXJhdGUoaW5wdXRzJTJDJTIwbWF4X25ld190b2tlbnMlM0QxMDAlMkMlMjBkb19zYW1wbGUlM0RUcnVlJTJDJTIwdG9wX2slM0Q1MCUyQyUyMHRvcF9wJTNEMC45NSk=",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoModelForCausalLM

<span class="hljs-meta">&gt;&gt;&gt; </span>model = AutoModelForCausalLM.from_pretrained(<span class="hljs-string">&quot;my_awesome_eli5_clm-model&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>outputs = model.generate(inputs, max_new_tokens=<span class="hljs-number">100</span>, do_sample=<span class="hljs-literal">True</span>, top_k=<span class="hljs-number">50</span>, top_p=<span class="hljs-number">0.95</span>)`,wrap:!1}}),x=new I({props:{code:"dG9rZW5pemVyLmJhdGNoX2RlY29kZShvdXRwdXRzJTJDJTIwc2tpcF9zcGVjaWFsX3Rva2VucyUzRFRydWUp",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span>tokenizer.batch_decode(outputs, skip_special_tokens=<span class="hljs-literal">True</span>)
[<span class="hljs-string">&quot;Somatic hypermutation allows the immune system to react to drugs with the ability to adapt to a different environmental situation. In other words, a system of &#x27;hypermutation&#x27; can help the immune system to adapt to a different environmental situation or in some cases even a single life. In contrast, researchers at the University of Massachusetts-Boston have found that &#x27;hypermutation&#x27; is much stronger in mice than in humans but can be found in humans, and that it&#x27;s not completely unknown to the immune system. A study on how the immune system&quot;</span>]`,wrap:!1}}),{c(){t=$("p"),t.innerHTML=c,a=i(),d(r.$$.fragment),u=i(),f=$("p"),f.innerHTML=v,Z=i(),d(C.$$.fragment),W=i(),G=$("p"),G.textContent=X,R=i(),d(x.$$.fragment)},l(o){t=j(o,"P",{"data-svelte-h":!0}),T(t)!=="svelte-1c2y1ia"&&(t.innerHTML=c),a=m(o),g(r.$$.fragment,o),u=m(o),f=j(o,"P",{"data-svelte-h":!0}),T(f)!=="svelte-1qra5al"&&(f.innerHTML=v),Z=m(o),g(C.$$.fragment,o),W=m(o),G=j(o,"P",{"data-svelte-h":!0}),T(G)!=="svelte-1918fu9"&&(G.textContent=X),R=m(o),g(x.$$.fragment,o)},m(o,_){l(o,t,_),l(o,a,_),y(r,o,_),l(o,u,_),l(o,f,_),l(o,Z,_),y(C,o,_),l(o,W,_),l(o,G,_),l(o,R,_),y(x,o,_),V=!0},p:te,i(o){V||(M(r.$$.fragment,o),M(C.$$.fragment,o),M(x.$$.fragment,o),V=!0)},o(o){b(r.$$.fragment,o),b(C.$$.fragment,o),b(x.$$.fragment,o),V=!1},d(o){o&&(s(t),s(a),s(u),s(f),s(Z),s(W),s(G),s(R)),w(r,o),w(C,o),w(x,o)}}}function ys(U){let t,c;return t=new Re({props:{$$slots:{default:[gs]},$$scope:{ctx:U}}}),{c(){d(t.$$.fragment)},l(a){g(t.$$.fragment,a)},m(a,r){y(t,a,r),c=!0},p(a,r){const u={};r&2&&(u.$$scope={dirty:r,ctx:a}),t.$set(u)},i(a){c||(M(t.$$.fragment,a),c=!0)},o(a){b(t.$$.fragment,a),c=!1},d(a){w(t,a)}}}function Ms(U){let t,c="Tokenize the text and return the <code>input_ids</code> as TensorFlow tensors:",a,r,u,f,v='Use the <a href="/docs/transformers/main/en/main_classes/text_generation#transformers.TFGenerationMixin.generate">generate()</a> method to create the summarization. For more details about the different text generation strategies and parameters for controlling generation, check out the <a href="../generation_strategies">Text generation strategies</a> page.',Z,C,W,G,X="Decode the generated token ids back into text:",R,x,V;return r=new I({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMEF1dG9Ub2tlbml6ZXIlMEElMEF0b2tlbml6ZXIlMjAlM0QlMjBBdXRvVG9rZW5pemVyLmZyb21fcHJldHJhaW5lZCglMjJteV9hd2Vzb21lX2VsaTVfY2xtLW1vZGVsJTIyKSUwQWlucHV0cyUyMCUzRCUyMHRva2VuaXplcihwcm9tcHQlMkMlMjByZXR1cm5fdGVuc29ycyUzRCUyMnRmJTIyKS5pbnB1dF9pZHM=",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoTokenizer

<span class="hljs-meta">&gt;&gt;&gt; </span>tokenizer = AutoTokenizer.from_pretrained(<span class="hljs-string">&quot;my_awesome_eli5_clm-model&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>inputs = tokenizer(prompt, return_tensors=<span class="hljs-string">&quot;tf&quot;</span>).input_ids`,wrap:!1}}),C=new I({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMFRGQXV0b01vZGVsRm9yQ2F1c2FsTE0lMEElMEFtb2RlbCUyMCUzRCUyMFRGQXV0b01vZGVsRm9yQ2F1c2FsTE0uZnJvbV9wcmV0cmFpbmVkKCUyMm15X2F3ZXNvbWVfZWxpNV9jbG0tbW9kZWwlMjIpJTBBb3V0cHV0cyUyMCUzRCUyMG1vZGVsLmdlbmVyYXRlKGlucHV0X2lkcyUzRGlucHV0cyUyQyUyMG1heF9uZXdfdG9rZW5zJTNEMTAwJTJDJTIwZG9fc2FtcGxlJTNEVHJ1ZSUyQyUyMHRvcF9rJTNENTAlMkMlMjB0b3BfcCUzRDAuOTUp",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> TFAutoModelForCausalLM

<span class="hljs-meta">&gt;&gt;&gt; </span>model = TFAutoModelForCausalLM.from_pretrained(<span class="hljs-string">&quot;my_awesome_eli5_clm-model&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>outputs = model.generate(input_ids=inputs, max_new_tokens=<span class="hljs-number">100</span>, do_sample=<span class="hljs-literal">True</span>, top_k=<span class="hljs-number">50</span>, top_p=<span class="hljs-number">0.95</span>)`,wrap:!1}}),x=new I({props:{code:"dG9rZW5pemVyLmJhdGNoX2RlY29kZShvdXRwdXRzJTJDJTIwc2tpcF9zcGVjaWFsX3Rva2VucyUzRFRydWUp",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span>tokenizer.batch_decode(outputs, skip_special_tokens=<span class="hljs-literal">True</span>)
[<span class="hljs-string">&#x27;Somatic hypermutation allows the immune system to detect the presence of other viruses as they become more prevalent. Therefore, researchers have identified a high proportion of human viruses. The proportion of virus-associated viruses in our study increases with age. Therefore, we propose a simple algorithm to detect the presence of these new viruses in our samples as a sign of improved immunity. A first study based on this algorithm, which will be published in Science on Friday, aims to show that this finding could translate into the development of a better vaccine that is more effective for&#x27;</span>]`,wrap:!1}}),{c(){t=$("p"),t.innerHTML=c,a=i(),d(r.$$.fragment),u=i(),f=$("p"),f.innerHTML=v,Z=i(),d(C.$$.fragment),W=i(),G=$("p"),G.textContent=X,R=i(),d(x.$$.fragment)},l(o){t=j(o,"P",{"data-svelte-h":!0}),T(t)!=="svelte-hw2mu6"&&(t.innerHTML=c),a=m(o),g(r.$$.fragment,o),u=m(o),f=j(o,"P",{"data-svelte-h":!0}),T(f)!=="svelte-sk8f6j"&&(f.innerHTML=v),Z=m(o),g(C.$$.fragment,o),W=m(o),G=j(o,"P",{"data-svelte-h":!0}),T(G)!=="svelte-1918fu9"&&(G.textContent=X),R=m(o),g(x.$$.fragment,o)},m(o,_){l(o,t,_),l(o,a,_),y(r,o,_),l(o,u,_),l(o,f,_),l(o,Z,_),y(C,o,_),l(o,W,_),l(o,G,_),l(o,R,_),y(x,o,_),V=!0},p:te,i(o){V||(M(r.$$.fragment,o),M(C.$$.fragment,o),M(x.$$.fragment,o),V=!0)},o(o){b(r.$$.fragment,o),b(C.$$.fragment,o),b(x.$$.fragment,o),V=!1},d(o){o&&(s(t),s(a),s(u),s(f),s(Z),s(W),s(G),s(R)),w(r,o),w(C,o),w(x,o)}}}function bs(U){let t,c;return t=new Re({props:{$$slots:{default:[Ms]},$$scope:{ctx:U}}}),{c(){d(t.$$.fragment)},l(a){g(t.$$.fragment,a)},m(a,r){y(t,a,r),c=!0},p(a,r){const u={};r&2&&(u.$$scope={dirty:r,ctx:a}),t.$set(u)},i(a){c||(M(t.$$.fragment,a),c=!0)},o(a){b(t.$$.fragment,a),c=!1},d(a){w(t,a)}}}function ws(U){let t,c,a,r,u,f,v,Z,C,W=`There are two types of language modeling, causal and masked. This guide illustrates causal language modeling.
Causal language models are frequently used for text generation. You can use these models for creative applications like
choosing your own text adventure or an intelligent coding assistant like Copilot or CodeParrot.`,G,X,R,x,V=`Causal language modeling predicts the next token in a sequence of tokens, and the model can only attend to tokens on
the left. This means the model cannot see future tokens. GPT-2 is an example of a causal language model.`,o,_,A="This guide will show you how to:",E,F,Q='<li>Finetune <a href="https://huggingface.co/distilgpt2" rel="nofollow">DistilGPT2</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,B,Y,z,h="Before you begin, make sure you have all the necessary libraries installed:",k,H,P,L,We="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,p,J,q,Be,se,_t=`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.`,Fe,ae,ze,le,xt='Split the dataset’s <code>train_asks</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:',He,ne,Ee,oe,Jt="Then take a look at an example:",Ye,re,Ae,pe,kt=`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.`,Le,ie,Qe,me,Ne,ce,Ut="The next step is to load a DistilGPT2 tokenizer to process the <code>text</code> subfield:",qe,he,Pe,ue,vt=`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.html#flatten" rel="nofollow"><code>flatten</code></a> method:`,Se,fe,De,de,Ct=`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.`,Ke,ge,Gt="Here is a first preprocessing function to join the list of strings for each example and tokenize the result:",Oe,ye,et,Me,It='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:',tt,be,st,we,Zt="This dataset contains the token sequences, but some of these are longer than the maximum input length for the model.",at,$e,Rt="You can now use a second preprocessing function to",lt,je,Wt="<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>",nt,Te,ot,_e,Vt="Apply the <code>group_texts</code> function over the entire dataset:",rt,xe,pt,Je,Xt=`Now create a batch of examples using <a href="/docs/transformers/main/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.`,it,D,mt,ke,ct,K,ht,O,ut,Ue,ft,ve,Bt="Great, now that you’ve finetuned a model, you can use it for inference!",dt,Ce,Ft="Come up with a prompt you’d like to generate text from:",gt,Ge,yt,Ie,zt='The simplest way to try out your finetuned model for inference is to use it in a <a href="/docs/transformers/main/en/main_classes/pipelines#transformers.pipeline">pipeline()</a>. Instantiate a <code>pipeline</code> for text generation with your model, and pass your text to it:',Mt,Ze,bt,ee,wt,Ve,$t;return u=new Xe({props:{title:"Causal language modeling",local:"causal-language-modeling",headingTag:"h1"}}),v=new as({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/language_modeling.ipynb"},{label:"PyTorch",value:"https://colab.research.google.com/github/huggingface/notebooks/blob/main/transformers_doc/en/pytorch/language_modeling.ipynb"},{label:"TensorFlow",value:"https://colab.research.google.com/github/huggingface/notebooks/blob/main/transformers_doc/en/tensorflow/language_modeling.ipynb"},{label:"Mixed",value:"https://studiolab.sagemaker.aws/import/github/huggingface/notebooks/blob/main/transformers_doc/en/language_modeling.ipynb"},{label:"PyTorch",value:"https://studiolab.sagemaker.aws/import/github/huggingface/notebooks/blob/main/transformers_doc/en/pytorch/language_modeling.ipynb"},{label:"TensorFlow",value:"https://studiolab.sagemaker.aws/import/github/huggingface/notebooks/blob/main/transformers_doc/en/tensorflow/language_modeling.ipynb"}]}}),X=new qt({props:{id:"Vpjb1lu0MDk"}}),B=new jt({props:{$$slots:{default:[ls]},$$scope:{ctx:U}}}),H=new I({props:{code:"cGlwJTIwaW5zdGFsbCUyMHRyYW5zZm9ybWVycyUyMGRhdGFzZXRzJTIwZXZhbHVhdGU=",highlighted:"pip install transformers datasets evaluate",wrap:!1}}),p=new I({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 Xe({props:{title:"Load ELI5 dataset",local:"load-eli5-dataset",headingTag:"h2"}}),ae=new I({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}}),ne=new I({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}}),re=new I({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}}),ie=new Xe({props:{title:"Preprocess",local:"preprocess",headingTag:"h2"}}),me=new qt({props:{id:"ma1TrR7gE7I"}}),he=new I({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMEF1dG9Ub2tlbml6ZXIlMEElMEF0b2tlbml6ZXIlMjAlM0QlMjBBdXRvVG9rZW5pemVyLmZyb21fcHJldHJhaW5lZCglMjJkaXN0aWxncHQyJTIyKQ==",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;distilgpt2&quot;</span>)`,wrap:!1}}),fe=new I({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}}),ye=new I({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}}),be=new I({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}}),Te=new I({props:{code:"YmxvY2tfc2l6ZSUyMCUzRCUyMDEyOCUwQSUwQSUwQWRlZiUyMGdyb3VwX3RleHRzKGV4YW1wbGVzKSUzQSUwQSUyMCUyMCUyMCUyMCUyMyUyMENvbmNhdGVuYXRlJTIwYWxsJTIwdGV4dHMuJTBBJTIwJTIwJTIwJTIwY29uY2F0ZW5hdGVkX2V4YW1wbGVzJTIwJTNEJTIwJTdCayUzQSUyMHN1bShleGFtcGxlcyU1QmslNUQlMkMlMjAlNUIlNUQpJTIwZm9yJTIwayUyMGluJTIwZXhhbXBsZXMua2V5cygpJTdEJTBBJTIwJTIwJTIwJTIwdG90YWxfbGVuZ3RoJTIwJTNEJTIwbGVuKGNvbmNhdGVuYXRlZF9leGFtcGxlcyU1Qmxpc3QoZXhhbXBsZXMua2V5cygpKSU1QjAlNUQlNUQpJTBBJTIwJTIwJTIwJTIwJTIzJTIwV2UlMjBkcm9wJTIwdGhlJTIwc21hbGwlMjByZW1haW5kZXIlMkMlMjB3ZSUyMGNvdWxkJTIwYWRkJTIwcGFkZGluZyUyMGlmJTIwdGhlJTIwbW9kZWwlMjBzdXBwb3J0ZWQlMjBpdCUyMGluc3RlYWQlMjBvZiUyMHRoaXMlMjBkcm9wJTJDJTIweW91JTIwY2FuJTBBJTIwJTIwJTIwJTIwJTIzJTIwY3VzdG9taXplJTIwdGhpcyUyMHBhcnQlMjB0byUyMHlvdXIlMjBuZWVkcy4lMEElMjAlMjAlMjAlMjBpZiUyMHRvdGFsX2xlbmd0aCUyMCUzRSUzRCUyMGJsb2NrX3NpemUlM0ElMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjB0b3RhbF9sZW5ndGglMjAlM0QlMjAodG90YWxfbGVuZ3RoJTIwJTJGJTJGJTIwYmxvY2tfc2l6ZSklMjAqJTIwYmxvY2tfc2l6ZSUwQSUyMCUyMCUyMCUyMCUyMyUyMFNwbGl0JTIwYnklMjBjaHVua3MlMjBvZiUyMGJsb2NrX3NpemUuJTBBJTIwJTIwJTIwJTIwcmVzdWx0JTIwJTNEJTIwJTdCJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwayUzQSUyMCU1QnQlNUJpJTIwJTNBJTIwaSUyMCUyQiUyMGJsb2NrX3NpemUlNUQlMjBmb3IlMjBpJTIwaW4lMjByYW5nZSgwJTJDJTIwdG90YWxfbGVuZ3RoJTJDJTIwYmxvY2tfc2l6ZSklNUQlMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjBmb3IlMjBrJTJDJTIwdCUyMGluJTIwY29uY2F0ZW5hdGVkX2V4YW1wbGVzLml0ZW1zKCklMEElMjAlMjAlMjAlMjAlN0QlMEElMjAlMjAlMjAlMjByZXN1bHQlNUIlMjJsYWJlbHMlMjIlNUQlMjAlM0QlMjByZXN1bHQlNUIlMjJpbnB1dF9pZHMlMjIlNUQuY29weSgpJTBBJTIwJTIwJTIwJTIwcmV0dXJuJTIwcmVzdWx0",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span>block_size = <span class="hljs-number">128</span>


<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">def</span> <span class="hljs-title function_">group_texts</span>(<span class="hljs-params">examples</span>):
<span class="hljs-meta">... </span>    <span class="hljs-comment"># Concatenate all texts.</span>
<span class="hljs-meta">... </span>    concatenated_examples = {k: <span class="hljs-built_in">sum</span>(examples[k], []) <span class="hljs-keyword">for</span> k <span class="hljs-keyword">in</span> examples.keys()}
<span class="hljs-meta">... </span>    total_length = <span class="hljs-built_in">len</span>(concatenated_examples[<span class="hljs-built_in">list</span>(examples.keys())[<span class="hljs-number">0</span>]])
<span class="hljs-meta">... </span>    <span class="hljs-comment"># We drop the small remainder, we could add padding if the model supported it instead of this drop, you can</span>
<span class="hljs-meta">... </span>    <span class="hljs-comment"># customize this part to your needs.</span>
<span class="hljs-meta">... </span>    <span class="hljs-keyword">if</span> total_length &gt;= block_size:
<span class="hljs-meta">... </span>        total_length = (total_length // block_size) * block_size
<span class="hljs-meta">... </span>    <span class="hljs-comment"># Split by chunks of block_size.</span>
<span class="hljs-meta">... </span>    result = {
<span class="hljs-meta">... </span>        k: [t[i : i + block_size] <span class="hljs-keyword">for</span> i <span class="hljs-keyword">in</span> <span class="hljs-built_in">range</span>(<span class="hljs-number">0</span>, total_length, block_size)]
<span class="hljs-meta">... </span>        <span class="hljs-keyword">for</span> k, t <span class="hljs-keyword">in</span> concatenated_examples.items()
<span class="hljs-meta">... </span>    }
<span class="hljs-meta">... </span>    result[<span class="hljs-string">&quot;labels&quot;</span>] = result[<span class="hljs-string">&quot;input_ids&quot;</span>].copy()
<span class="hljs-meta">... </span>    <span class="hljs-keyword">return</span> result`,wrap:!1}}),xe=new I({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}}),D=new Tt({props:{pytorch:!0,tensorflow:!0,jax:!1,$$slots:{tensorflow:[ps],pytorch:[os]},$$scope:{ctx:U}}}),ke=new Xe({props:{title:"Train",local:"train",headingTag:"h2"}}),K=new Tt({props:{pytorch:!0,tensorflow:!0,jax:!1,$$slots:{tensorflow:[fs],pytorch:[cs]},$$scope:{ctx:U}}}),O=new jt({props:{$$slots:{default:[ds]},$$scope:{ctx:U}}}),Ue=new Xe({props:{title:"Inference",local:"inference",headingTag:"h2"}}),Ge=new I({props:{code:"cHJvbXB0JTIwJTNEJTIwJTIyU29tYXRpYyUyMGh5cGVybXV0YXRpb24lMjBhbGxvd3MlMjB0aGUlMjBpbW11bmUlMjBzeXN0ZW0lMjB0byUyMg==",highlighted:'<span class="hljs-meta">&gt;&gt;&gt; </span>prompt = <span class="hljs-string">&quot;Somatic hypermutation allows the immune system to&quot;</span>',wrap:!1}}),Ze=new I({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMHBpcGVsaW5lJTBBJTBBZ2VuZXJhdG9yJTIwJTNEJTIwcGlwZWxpbmUoJTIydGV4dC1nZW5lcmF0aW9uJTIyJTJDJTIwbW9kZWwlM0QlMjJteV9hd2Vzb21lX2VsaTVfY2xtLW1vZGVsJTIyKSUwQWdlbmVyYXRvcihwcm9tcHQp",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>generator = pipeline(<span class="hljs-string">&quot;text-generation&quot;</span>, model=<span class="hljs-string">&quot;my_awesome_eli5_clm-model&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>generator(prompt)
[{<span class="hljs-string">&#x27;generated_text&#x27;</span>: <span class="hljs-string">&quot;Somatic hypermutation allows the immune system to be able to effectively reverse the damage caused by an infection.\\n\\n\\nThe damage caused by an infection is caused by the immune system&#x27;s ability to perform its own self-correcting tasks.&quot;</span>}]`,wrap:!1}}),ee=new Tt({props:{pytorch:!0,tensorflow:!0,jax:!1,$$slots:{tensorflow:[bs],pytorch:[ys]},$$scope:{ctx:U}}}),{c(){t=$("meta"),c=i(),a=$("p"),r=i(),d(u.$$.fragment),f=i(),d(v.$$.fragment),Z=i(),C=$("p"),C.textContent=W,G=i(),d(X.$$.fragment),R=i(),x=$("p"),x.textContent=V,o=i(),_=$("p"),_.textContent=A,E=i(),F=$("ol"),F.innerHTML=Q,N=i(),d(B.$$.fragment),Y=i(),z=$("p"),z.textContent=h,k=i(),d(H.$$.fragment),P=i(),L=$("p"),L.textContent=We,S=i(),d(p.$$.fragment),J=i(),d(q.$$.fragment),Be=i(),se=$("p"),se.textContent=_t,Fe=i(),d(ae.$$.fragment),ze=i(),le=$("p"),le.innerHTML=xt,He=i(),d(ne.$$.fragment),Ee=i(),oe=$("p"),oe.textContent=Jt,Ye=i(),d(re.$$.fragment),Ae=i(),pe=$("p"),pe.innerHTML=kt,Le=i(),d(ie.$$.fragment),Qe=i(),d(me.$$.fragment),Ne=i(),ce=$("p"),ce.innerHTML=Ut,qe=i(),d(he.$$.fragment),Pe=i(),ue=$("p"),ue.innerHTML=vt,Se=i(),d(fe.$$.fragment),De=i(),de=$("p"),de.innerHTML=Ct,Ke=i(),ge=$("p"),ge.textContent=Gt,Oe=i(),d(ye.$$.fragment),et=i(),Me=$("p"),Me.innerHTML=It,tt=i(),d(be.$$.fragment),st=i(),we=$("p"),we.textContent=Zt,at=i(),$e=$("p"),$e.textContent=Rt,lt=i(),je=$("ul"),je.innerHTML=Wt,nt=i(),d(Te.$$.fragment),ot=i(),_e=$("p"),_e.innerHTML=Vt,rt=i(),d(xe.$$.fragment),pt=i(),Je=$("p"),Je.innerHTML=Xt,it=i(),d(D.$$.fragment),mt=i(),d(ke.$$.fragment),ct=i(),d(K.$$.fragment),ht=i(),d(O.$$.fragment),ut=i(),d(Ue.$$.fragment),ft=i(),ve=$("p"),ve.textContent=Bt,dt=i(),Ce=$("p"),Ce.textContent=Ft,gt=i(),d(Ge.$$.fragment),yt=i(),Ie=$("p"),Ie.innerHTML=zt,Mt=i(),d(Ze.$$.fragment),bt=i(),d(ee.$$.fragment),wt=i(),Ve=$("p"),this.h()},l(e){const n=ts("svelte-u9bgzb",document.head);t=j(n,"META",{name:!0,content:!0}),n.forEach(s),c=m(e),a=j(e,"P",{}),Qt(a).forEach(s),r=m(e),g(u.$$.fragment,e),f=m(e),g(v.$$.fragment,e),Z=m(e),C=j(e,"P",{"data-svelte-h":!0}),T(C)!=="svelte-1j29ona"&&(C.textContent=W),G=m(e),g(X.$$.fragment,e),R=m(e),x=j(e,"P",{"data-svelte-h":!0}),T(x)!=="svelte-nw6q3g"&&(x.textContent=V),o=m(e),_=j(e,"P",{"data-svelte-h":!0}),T(_)!=="svelte-1aff4p7"&&(_.textContent=A),E=m(e),F=j(e,"OL",{"data-svelte-h":!0}),T(F)!=="svelte-1h2f171"&&(F.innerHTML=Q),N=m(e),g(B.$$.fragment,e),Y=m(e),z=j(e,"P",{"data-svelte-h":!0}),T(z)!=="svelte-1c9nexd"&&(z.textContent=h),k=m(e),g(H.$$.fragment,e),P=m(e),L=j(e,"P",{"data-svelte-h":!0}),T(L)!=="svelte-27hn0u"&&(L.textContent=We),S=m(e),g(p.$$.fragment,e),J=m(e),g(q.$$.fragment,e),Be=m(e),se=j(e,"P",{"data-svelte-h":!0}),T(se)!=="svelte-mxq58u"&&(se.textContent=_t),Fe=m(e),g(ae.$$.fragment,e),ze=m(e),le=j(e,"P",{"data-svelte-h":!0}),T(le)!=="svelte-18klfk5"&&(le.innerHTML=xt),He=m(e),g(ne.$$.fragment,e),Ee=m(e),oe=j(e,"P",{"data-svelte-h":!0}),T(oe)!=="svelte-1m91ua0"&&(oe.textContent=Jt),Ye=m(e),g(re.$$.fragment,e),Ae=m(e),pe=j(e,"P",{"data-svelte-h":!0}),T(pe)!=="svelte-1wm9gdc"&&(pe.innerHTML=kt),Le=m(e),g(ie.$$.fragment,e),Qe=m(e),g(me.$$.fragment,e),Ne=m(e),ce=j(e,"P",{"data-svelte-h":!0}),T(ce)!=="svelte-1lrcpa6"&&(ce.innerHTML=Ut),qe=m(e),g(he.$$.fragment,e),Pe=m(e),ue=j(e,"P",{"data-svelte-h":!0}),T(ue)!=="svelte-z1itq1"&&(ue.innerHTML=vt),Se=m(e),g(fe.$$.fragment,e),De=m(e),de=j(e,"P",{"data-svelte-h":!0}),T(de)!=="svelte-1mdv3gu"&&(de.innerHTML=Ct),Ke=m(e),ge=j(e,"P",{"data-svelte-h":!0}),T(ge)!=="svelte-njkc6i"&&(ge.textContent=Gt),Oe=m(e),g(ye.$$.fragment,e),et=m(e),Me=j(e,"P",{"data-svelte-h":!0}),T(Me)!=="svelte-1xbgtq4"&&(Me.innerHTML=It),tt=m(e),g(be.$$.fragment,e),st=m(e),we=j(e,"P",{"data-svelte-h":!0}),T(we)!=="svelte-pz0l04"&&(we.textContent=Zt),at=m(e),$e=j(e,"P",{"data-svelte-h":!0}),T($e)!=="svelte-5guq64"&&($e.textContent=Rt),lt=m(e),je=j(e,"UL",{"data-svelte-h":!0}),T(je)!=="svelte-19gyadw"&&(je.innerHTML=Wt),nt=m(e),g(Te.$$.fragment,e),ot=m(e),_e=j(e,"P",{"data-svelte-h":!0}),T(_e)!=="svelte-1o69amy"&&(_e.innerHTML=Vt),rt=m(e),g(xe.$$.fragment,e),pt=m(e),Je=j(e,"P",{"data-svelte-h":!0}),T(Je)!=="svelte-ghlfnb"&&(Je.innerHTML=Xt),it=m(e),g(D.$$.fragment,e),mt=m(e),g(ke.$$.fragment,e),ct=m(e),g(K.$$.fragment,e),ht=m(e),g(O.$$.fragment,e),ut=m(e),g(Ue.$$.fragment,e),ft=m(e),ve=j(e,"P",{"data-svelte-h":!0}),T(ve)!=="svelte-633ppb"&&(ve.textContent=Bt),dt=m(e),Ce=j(e,"P",{"data-svelte-h":!0}),T(Ce)!=="svelte-12i1768"&&(Ce.textContent=Ft),gt=m(e),g(Ge.$$.fragment,e),yt=m(e),Ie=j(e,"P",{"data-svelte-h":!0}),T(Ie)!=="svelte-1t6v145"&&(Ie.innerHTML=zt),Mt=m(e),g(Ze.$$.fragment,e),bt=m(e),g(ee.$$.fragment,e),wt=m(e),Ve=j(e,"P",{}),Qt(Ve).forEach(s),this.h()},h(){Nt(t,"name","hf:doc:metadata"),Nt(t,"content",$s)},m(e,n){ss(document.head,t),l(e,c,n),l(e,a,n),l(e,r,n),y(u,e,n),l(e,f,n),y(v,e,n),l(e,Z,n),l(e,C,n),l(e,G,n),y(X,e,n),l(e,R,n),l(e,x,n),l(e,o,n),l(e,_,n),l(e,E,n),l(e,F,n),l(e,N,n),y(B,e,n),l(e,Y,n),l(e,z,n),l(e,k,n),y(H,e,n),l(e,P,n),l(e,L,n),l(e,S,n),y(p,e,n),l(e,J,n),y(q,e,n),l(e,Be,n),l(e,se,n),l(e,Fe,n),y(ae,e,n),l(e,ze,n),l(e,le,n),l(e,He,n),y(ne,e,n),l(e,Ee,n),l(e,oe,n),l(e,Ye,n),y(re,e,n),l(e,Ae,n),l(e,pe,n),l(e,Le,n),y(ie,e,n),l(e,Qe,n),y(me,e,n),l(e,Ne,n),l(e,ce,n),l(e,qe,n),y(he,e,n),l(e,Pe,n),l(e,ue,n),l(e,Se,n),y(fe,e,n),l(e,De,n),l(e,de,n),l(e,Ke,n),l(e,ge,n),l(e,Oe,n),y(ye,e,n),l(e,et,n),l(e,Me,n),l(e,tt,n),y(be,e,n),l(e,st,n),l(e,we,n),l(e,at,n),l(e,$e,n),l(e,lt,n),l(e,je,n),l(e,nt,n),y(Te,e,n),l(e,ot,n),l(e,_e,n),l(e,rt,n),y(xe,e,n),l(e,pt,n),l(e,Je,n),l(e,it,n),y(D,e,n),l(e,mt,n),y(ke,e,n),l(e,ct,n),y(K,e,n),l(e,ht,n),y(O,e,n),l(e,ut,n),y(Ue,e,n),l(e,ft,n),l(e,ve,n),l(e,dt,n),l(e,Ce,n),l(e,gt,n),y(Ge,e,n),l(e,yt,n),l(e,Ie,n),l(e,Mt,n),y(Ze,e,n),l(e,bt,n),y(ee,e,n),l(e,wt,n),l(e,Ve,n),$t=!0},p(e,[n]){const Ht={};n&2&&(Ht.$$scope={dirty:n,ctx:e}),B.$set(Ht);const Et={};n&2&&(Et.$$scope={dirty:n,ctx:e}),D.$set(Et);const Yt={};n&2&&(Yt.$$scope={dirty:n,ctx:e}),K.$set(Yt);const At={};n&2&&(At.$$scope={dirty:n,ctx:e}),O.$set(At);const Lt={};n&2&&(Lt.$$scope={dirty:n,ctx:e}),ee.$set(Lt)},i(e){$t||(M(u.$$.fragment,e),M(v.$$.fragment,e),M(X.$$.fragment,e),M(B.$$.fragment,e),M(H.$$.fragment,e),M(p.$$.fragment,e),M(q.$$.fragment,e),M(ae.$$.fragment,e),M(ne.$$.fragment,e),M(re.$$.fragment,e),M(ie.$$.fragment,e),M(me.$$.fragment,e),M(he.$$.fragment,e),M(fe.$$.fragment,e),M(ye.$$.fragment,e),M(be.$$.fragment,e),M(Te.$$.fragment,e),M(xe.$$.fragment,e),M(D.$$.fragment,e),M(ke.$$.fragment,e),M(K.$$.fragment,e),M(O.$$.fragment,e),M(Ue.$$.fragment,e),M(Ge.$$.fragment,e),M(Ze.$$.fragment,e),M(ee.$$.fragment,e),$t=!0)},o(e){b(u.$$.fragment,e),b(v.$$.fragment,e),b(X.$$.fragment,e),b(B.$$.fragment,e),b(H.$$.fragment,e),b(p.$$.fragment,e),b(q.$$.fragment,e),b(ae.$$.fragment,e),b(ne.$$.fragment,e),b(re.$$.fragment,e),b(ie.$$.fragment,e),b(me.$$.fragment,e),b(he.$$.fragment,e),b(fe.$$.fragment,e),b(ye.$$.fragment,e),b(be.$$.fragment,e),b(Te.$$.fragment,e),b(xe.$$.fragment,e),b(D.$$.fragment,e),b(ke.$$.fragment,e),b(K.$$.fragment,e),b(O.$$.fragment,e),b(Ue.$$.fragment,e),b(Ge.$$.fragment,e),b(Ze.$$.fragment,e),b(ee.$$.fragment,e),$t=!1},d(e){e&&(s(c),s(a),s(r),s(f),s(Z),s(C),s(G),s(R),s(x),s(o),s(_),s(E),s(F),s(N),s(Y),s(z),s(k),s(P),s(L),s(S),s(J),s(Be),s(se),s(Fe),s(ze),s(le),s(He),s(Ee),s(oe),s(Ye),s(Ae),s(pe),s(Le),s(Qe),s(Ne),s(ce),s(qe),s(Pe),s(ue),s(Se),s(De),s(de),s(Ke),s(ge),s(Oe),s(et),s(Me),s(tt),s(st),s(we),s(at),s($e),s(lt),s(je),s(nt),s(ot),s(_e),s(rt),s(pt),s(Je),s(it),s(mt),s(ct),s(ht),s(ut),s(ft),s(ve),s(dt),s(Ce),s(gt),s(yt),s(Ie),s(Mt),s(bt),s(wt),s(Ve)),s(t),w(u,e),w(v,e),w(X,e),w(B,e),w(H,e),w(p,e),w(q,e),w(ae,e),w(ne,e),w(re,e),w(ie,e),w(me,e),w(he,e),w(fe,e),w(ye,e),w(be,e),w(Te,e),w(xe,e),w(D,e),w(ke,e),w(K,e),w(O,e),w(Ue,e),w(Ge,e),w(Ze,e),w(ee,e)}}}const $s='{"title":"Causal language modeling","local":"causal-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 js(U){return Kt(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class Gs extends Ot{constructor(t){super(),es(this,t,js,ws,Dt,{})}}export{Gs as component};
