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

`),c=u("p"),c.innerHTML=l},l(o){s=Xs(o,`You can finetune other architectures for causal language modeling following the same steps in this guide.
Choose one of the following architectures:

`),c=d(o,"P",{"data-svelte-h":!0}),T(c)!=="svelte-ep3wzt"&&(c.innerHTML=l)},m(o,g){a(o,s,g),a(o,c,g)},p:ce,d(o){o&&(t(s),t(c))}}}function Ns(v){let s,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:",l,o,g;return o=new U({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(){s=u("p"),s.innerHTML=c,l=r(),y(o.$$.fragment)},l(f){s=d(f,"P",{"data-svelte-h":!0}),T(s)!=="svelte-su9ugx"&&(s.innerHTML=c),l=p(f),M(o.$$.fragment,f)},m(f,Z){a(f,s,Z),a(f,l,Z),b(o,f,Z),g=!0},p:ce,i(f){g||(w(o.$$.fragment,f),g=!0)},o(f){$(o.$$.fragment,f),g=!1},d(f){f&&(t(s),t(l)),j(o,f)}}}function Ls(v){let s,c;return s=new tt({props:{$$slots:{default:[Ns]},$$scope:{ctx:v}}}),{c(){y(s.$$.fragment)},l(l){M(s.$$.fragment,l)},m(l,o){b(s,l,o),c=!0},p(l,o){const g={};o&2&&(g.$$scope={dirty:o,ctx:l}),s.$set(g)},i(l){c||(w(s.$$.fragment,l),c=!0)},o(l){$(s.$$.fragment,l),c=!1},d(l){j(s,l)}}}function Qs(v){let s,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:",l,o,g;return o=new U({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(){s=u("p"),s.innerHTML=c,l=r(),y(o.$$.fragment)},l(f){s=d(f,"P",{"data-svelte-h":!0}),T(s)!=="svelte-su9ugx"&&(s.innerHTML=c),l=p(f),M(o.$$.fragment,f)},m(f,Z){a(f,s,Z),a(f,l,Z),b(o,f,Z),g=!0},p:ce,i(f){g||(w(o.$$.fragment,f),g=!0)},o(f){$(o.$$.fragment,f),g=!1},d(f){f&&(t(s),t(l)),j(o,f)}}}function qs(v){let s,c;return s=new tt({props:{$$slots:{default:[Qs]},$$scope:{ctx:v}}}),{c(){y(s.$$.fragment)},l(l){M(s.$$.fragment,l)},m(l,o){b(s,l,o),c=!0},p(l,o){const g={};o&2&&(g.$$scope={dirty:o,ctx:l}),s.$set(g)},i(l){c||(w(s.$$.fragment,l),c=!0)},o(l){$(s.$$.fragment,l),c=!1},d(l){j(s,l)}}}function Ps(v){let s,c='If you aren’t familiar with finetuning a model with the <a href="/docs/transformers/v4.34.0/en/main_classes/trainer#transformers.Trainer">Trainer</a>, take a look at the <a href="../training#train-with-pytorch-trainer">basic tutorial</a>!';return{c(){s=u("p"),s.innerHTML=c},l(l){s=d(l,"P",{"data-svelte-h":!0}),T(s)!=="svelte-tdrp9m"&&(s.innerHTML=c)},m(l,o){a(l,s,o)},p:ce,d(l){l&&t(s)}}}function Ss(v){let s,c,l,o='You’re ready to start training your model now! Load DistilGPT2 with <a href="/docs/transformers/v4.34.0/en/model_doc/auto#transformers.AutoModelForCausalLM">AutoModelForCausalLM</a>:',g,f,Z,J,V="At this point, only three steps remain:",R,W,E='<li>Define your training hyperparameters in <a href="/docs/transformers/v4.34.0/en/main_classes/trainer#transformers.TrainingArguments">TrainingArguments</a>. The only required parameter is <code>output_dir</code> which specifies where to save your model. You’ll push this model to the Hub by setting <code>push_to_hub=True</code> (you need to be signed in to Hugging Face to upload your model).</li> <li>Pass the training arguments to <a href="/docs/transformers/v4.34.0/en/main_classes/trainer#transformers.Trainer">Trainer</a> along with the model, datasets, and data collator.</li> <li>Call <a href="/docs/transformers/v4.34.0/en/main_classes/trainer#transformers.Trainer.train">train()</a> to finetune your model.</li>',C,k,G,i,_='Once training is completed, use the <a href="/docs/transformers/v4.34.0/en/main_classes/trainer#transformers.Trainer.evaluate">evaluate()</a> method to evaluate your model and get its perplexity:',F,A,H,q,S='Then share your model to the Hub with the <a href="/docs/transformers/v4.34.0/en/main_classes/trainer#transformers.Trainer.push_to_hub">push_to_hub()</a> method so everyone can use your model:',z,L,Y;return s=new es({props:{$$slots:{default:[Ps]},$$scope:{ctx:v}}}),f=new U({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}}),k=new U({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}}),A=new U({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}}),L=new U({props:{code:"dHJhaW5lci5wdXNoX3RvX2h1Yigp",highlighted:'<span class="hljs-meta">&gt;&gt;&gt; </span>trainer.push_to_hub()',wrap:!1}}),{c(){y(s.$$.fragment),c=r(),l=u("p"),l.innerHTML=o,g=r(),y(f.$$.fragment),Z=r(),J=u("p"),J.textContent=V,R=r(),W=u("ol"),W.innerHTML=E,C=r(),y(k.$$.fragment),G=r(),i=u("p"),i.innerHTML=_,F=r(),y(A.$$.fragment),H=r(),q=u("p"),q.innerHTML=S,z=r(),y(L.$$.fragment)},l(h){M(s.$$.fragment,h),c=p(h),l=d(h,"P",{"data-svelte-h":!0}),T(l)!=="svelte-10h47a8"&&(l.innerHTML=o),g=p(h),M(f.$$.fragment,h),Z=p(h),J=d(h,"P",{"data-svelte-h":!0}),T(J)!=="svelte-l42k0i"&&(J.textContent=V),R=p(h),W=d(h,"OL",{"data-svelte-h":!0}),T(W)!=="svelte-6uyzj4"&&(W.innerHTML=E),C=p(h),M(k.$$.fragment,h),G=p(h),i=d(h,"P",{"data-svelte-h":!0}),T(i)!=="svelte-1h6sduc"&&(i.innerHTML=_),F=p(h),M(A.$$.fragment,h),H=p(h),q=d(h,"P",{"data-svelte-h":!0}),T(q)!=="svelte-xx2cfv"&&(q.innerHTML=S),z=p(h),M(L.$$.fragment,h)},m(h,I){b(s,h,I),a(h,c,I),a(h,l,I),a(h,g,I),b(f,h,I),a(h,Z,I),a(h,J,I),a(h,R,I),a(h,W,I),a(h,C,I),b(k,h,I),a(h,G,I),a(h,i,I),a(h,F,I),b(A,h,I),a(h,H,I),a(h,q,I),a(h,z,I),b(L,h,I),Y=!0},p(h,I){const Q={};I&2&&(Q.$$scope={dirty:I,ctx:h}),s.$set(Q)},i(h){Y||(w(s.$$.fragment,h),w(f.$$.fragment,h),w(k.$$.fragment,h),w(A.$$.fragment,h),w(L.$$.fragment,h),Y=!0)},o(h){$(s.$$.fragment,h),$(f.$$.fragment,h),$(k.$$.fragment,h),$(A.$$.fragment,h),$(L.$$.fragment,h),Y=!1},d(h){h&&(t(c),t(l),t(g),t(Z),t(J),t(R),t(W),t(C),t(G),t(i),t(F),t(H),t(q),t(z)),j(s,h),j(f,h),j(k,h),j(A,h),j(L,h)}}}function Ds(v){let s,c;return s=new tt({props:{$$slots:{default:[Ss]},$$scope:{ctx:v}}}),{c(){y(s.$$.fragment)},l(l){M(s.$$.fragment,l)},m(l,o){b(s,l,o),c=!0},p(l,o){const g={};o&2&&(g.$$scope={dirty:o,ctx:l}),s.$set(g)},i(l){c||(w(s.$$.fragment,l),c=!0)},o(l){$(s.$$.fragment,l),c=!1},d(l){j(s,l)}}}function Ks(v){let s,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(){s=u("p"),s.innerHTML=c},l(l){s=d(l,"P",{"data-svelte-h":!0}),T(s)!=="svelte-1mqyx4y"&&(s.innerHTML=c)},m(l,o){a(l,s,o)},p:ce,d(l){l&&t(s)}}}function Os(v){let s,c,l,o,g,f='Then you can load DistilGPT2 with <a href="/docs/transformers/v4.34.0/en/model_doc/auto#transformers.TFAutoModelForCausalLM">TFAutoModelForCausalLM</a>:',Z,J,V,R,W='Convert your datasets to the <code>tf.data.Dataset</code> format with <a href="/docs/transformers/v4.34.0/en/main_classes/model#transformers.TFPreTrainedModel.prepare_tf_dataset">prepare_tf_dataset()</a>:',E,C,k,G,i='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:',_,F,A,H,q='This can be done by specifying where to push your model and tokenizer in the <a href="/docs/transformers/v4.34.0/en/main_classes/keras_callbacks#transformers.PushToHubCallback">PushToHubCallback</a>:',S,z,L,Y,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:',I,Q,P,D,K="Once training is completed, your model is automatically uploaded to the Hub so everyone can use it!",he;return s=new es({props:{$$slots:{default:[Ks]},$$scope:{ctx:v}}}),l=new U({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}}),J=new U({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}}),C=new U({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}}),F=new U({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}}),z=new U({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}}),Q=new U({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(){y(s.$$.fragment),c=Vs(`
To finetune a model in TensorFlow, start by setting up an optimizer function, learning rate schedule, and some training hyperparameters:

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

	`),M(l.$$.fragment,m),o=p(m),g=d(m,"P",{"data-svelte-h":!0}),T(g)!=="svelte-tm6376"&&(g.innerHTML=f),Z=p(m),M(J.$$.fragment,m),V=p(m),R=d(m,"P",{"data-svelte-h":!0}),T(R)!=="svelte-qmwuyd"&&(R.innerHTML=W),E=p(m),M(C.$$.fragment,m),k=p(m),G=d(m,"P",{"data-svelte-h":!0}),T(G)!=="svelte-17cxx5e"&&(G.innerHTML=i),_=p(m),M(F.$$.fragment,m),A=p(m),H=d(m,"P",{"data-svelte-h":!0}),T(H)!=="svelte-ufj5fr"&&(H.innerHTML=q),S=p(m),M(z.$$.fragment,m),L=p(m),Y=d(m,"P",{"data-svelte-h":!0}),T(Y)!=="svelte-1pfsro2"&&(Y.innerHTML=h),I=p(m),M(Q.$$.fragment,m),P=p(m),D=d(m,"P",{"data-svelte-h":!0}),T(D)!=="svelte-2s71om"&&(D.textContent=K)},m(m,x){b(s,m,x),a(m,c,x),b(l,m,x),a(m,o,x),a(m,g,x),a(m,Z,x),b(J,m,x),a(m,V,x),a(m,R,x),a(m,E,x),b(C,m,x),a(m,k,x),a(m,G,x),a(m,_,x),b(F,m,x),a(m,A,x),a(m,H,x),a(m,S,x),b(z,m,x),a(m,L,x),a(m,Y,x),a(m,I,x),b(Q,m,x),a(m,P,x),a(m,D,x),he=!0},p(m,x){const ue={};x&2&&(ue.$$scope={dirty:x,ctx:m}),s.$set(ue)},i(m){he||(w(s.$$.fragment,m),w(l.$$.fragment,m),w(J.$$.fragment,m),w(C.$$.fragment,m),w(F.$$.fragment,m),w(z.$$.fragment,m),w(Q.$$.fragment,m),he=!0)},o(m){$(s.$$.fragment,m),$(l.$$.fragment,m),$(J.$$.fragment,m),$(C.$$.fragment,m),$(F.$$.fragment,m),$(z.$$.fragment,m),$(Q.$$.fragment,m),he=!1},d(m){m&&(t(c),t(o),t(g),t(Z),t(V),t(R),t(E),t(k),t(G),t(_),t(A),t(H),t(S),t(L),t(Y),t(I),t(P),t(D)),j(s,m),j(l,m),j(J,m),j(C,m),j(F,m),j(z,m),j(Q,m)}}}function ea(v){let s,c;return s=new tt({props:{$$slots:{default:[Os]},$$scope:{ctx:v}}}),{c(){y(s.$$.fragment)},l(l){M(s.$$.fragment,l)},m(l,o){b(s,l,o),c=!0},p(l,o){const g={};o&2&&(g.$$scope={dirty:o,ctx:l}),s.$set(g)},i(l){c||(w(s.$$.fragment,l),c=!0)},o(l){$(s.$$.fragment,l),c=!1},d(l){j(s,l)}}}function ta(v){let s,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(){s=u("p"),s.innerHTML=c},l(l){s=d(l,"P",{"data-svelte-h":!0}),T(s)!=="svelte-bbjpvr"&&(s.innerHTML=c)},m(l,o){a(l,s,o)},p:ce,d(l){l&&t(s)}}}function sa(v){let s,c="Tokenize the text and return the <code>input_ids</code> as PyTorch tensors:",l,o,g,f,Z=`Use the <a href="/docs/transformers/v4.34.0/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.`,J,V,R,W,E="Decode the generated token ids back into text:",C,k,G;return o=new U({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}}),V=new U({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}}),k=new U({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(){s=u("p"),s.innerHTML=c,l=r(),y(o.$$.fragment),g=r(),f=u("p"),f.innerHTML=Z,J=r(),y(V.$$.fragment),R=r(),W=u("p"),W.textContent=E,C=r(),y(k.$$.fragment)},l(i){s=d(i,"P",{"data-svelte-h":!0}),T(s)!=="svelte-1c2y1ia"&&(s.innerHTML=c),l=p(i),M(o.$$.fragment,i),g=p(i),f=d(i,"P",{"data-svelte-h":!0}),T(f)!=="svelte-13iao8h"&&(f.innerHTML=Z),J=p(i),M(V.$$.fragment,i),R=p(i),W=d(i,"P",{"data-svelte-h":!0}),T(W)!=="svelte-1918fu9"&&(W.textContent=E),C=p(i),M(k.$$.fragment,i)},m(i,_){a(i,s,_),a(i,l,_),b(o,i,_),a(i,g,_),a(i,f,_),a(i,J,_),b(V,i,_),a(i,R,_),a(i,W,_),a(i,C,_),b(k,i,_),G=!0},p:ce,i(i){G||(w(o.$$.fragment,i),w(V.$$.fragment,i),w(k.$$.fragment,i),G=!0)},o(i){$(o.$$.fragment,i),$(V.$$.fragment,i),$(k.$$.fragment,i),G=!1},d(i){i&&(t(s),t(l),t(g),t(f),t(J),t(R),t(W),t(C)),j(o,i),j(V,i),j(k,i)}}}function aa(v){let s,c;return s=new tt({props:{$$slots:{default:[sa]},$$scope:{ctx:v}}}),{c(){y(s.$$.fragment)},l(l){M(s.$$.fragment,l)},m(l,o){b(s,l,o),c=!0},p(l,o){const g={};o&2&&(g.$$scope={dirty:o,ctx:l}),s.$set(g)},i(l){c||(w(s.$$.fragment,l),c=!0)},o(l){$(s.$$.fragment,l),c=!1},d(l){j(s,l)}}}function la(v){let s,c="Tokenize the text and return the <code>input_ids</code> as TensorFlow tensors:",l,o,g,f,Z='Use the <a href="/docs/transformers/v4.34.0/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.',J,V,R,W,E="Decode the generated token ids back into text:",C,k,G;return o=new U({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}}),V=new U({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}}),k=new U({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(){s=u("p"),s.innerHTML=c,l=r(),y(o.$$.fragment),g=r(),f=u("p"),f.innerHTML=Z,J=r(),y(V.$$.fragment),R=r(),W=u("p"),W.textContent=E,C=r(),y(k.$$.fragment)},l(i){s=d(i,"P",{"data-svelte-h":!0}),T(s)!=="svelte-hw2mu6"&&(s.innerHTML=c),l=p(i),M(o.$$.fragment,i),g=p(i),f=d(i,"P",{"data-svelte-h":!0}),T(f)!=="svelte-1yoge13"&&(f.innerHTML=Z),J=p(i),M(V.$$.fragment,i),R=p(i),W=d(i,"P",{"data-svelte-h":!0}),T(W)!=="svelte-1918fu9"&&(W.textContent=E),C=p(i),M(k.$$.fragment,i)},m(i,_){a(i,s,_),a(i,l,_),b(o,i,_),a(i,g,_),a(i,f,_),a(i,J,_),b(V,i,_),a(i,R,_),a(i,W,_),a(i,C,_),b(k,i,_),G=!0},p:ce,i(i){G||(w(o.$$.fragment,i),w(V.$$.fragment,i),w(k.$$.fragment,i),G=!0)},o(i){$(o.$$.fragment,i),$(V.$$.fragment,i),$(k.$$.fragment,i),G=!1},d(i){i&&(t(s),t(l),t(g),t(f),t(J),t(R),t(W),t(C)),j(o,i),j(V,i),j(k,i)}}}function na(v){let s,c;return s=new tt({props:{$$slots:{default:[la]},$$scope:{ctx:v}}}),{c(){y(s.$$.fragment)},l(l){M(s.$$.fragment,l)},m(l,o){b(s,l,o),c=!0},p(l,o){const g={};o&2&&(g.$$scope={dirty:o,ctx:l}),s.$set(g)},i(l){c||(w(s.$$.fragment,l),c=!0)},o(l){$(s.$$.fragment,l),c=!1},d(l){j(s,l)}}}function oa(v){let s,c,l,o,g,f,Z,J,V,R,W="Causal language modeling",E,C,k,G,i=`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.`,_,F,A,H,q=`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.`,S,z,L="This guide will show you how to:",Y,h,I='<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>',Q,P,D,K,he="Before you begin, make sure you have all the necessary libraries installed:",m,x,ue,de,os="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:",ct,fe,ht,O,ae,st,ge,ts,De,rs="Load ELI5 dataset",ut,ye,ps=`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.`,dt,Me,ft,be,is='Split the dataset’s <code>train_asks</code> split into a train and test set with the <a href="https://huggingface.co/docs/datasets/v2.14.5/en/package_reference/main_classes#datasets.Dataset.train_test_split" rel="nofollow">train_test_split</a> method:',gt,we,yt,$e,ms="Then take a look at an example:",Mt,je,bt,Te,cs=`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.`,wt,ee,le,at,_e,ss,Ke,hs="Preprocess",$t,xe,jt,Je,us="The next step is to load a DistilGPT2 tokenizer to process the <code>text</code> subfield:",Tt,ke,_t,ve,ds=`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:`,xt,Ue,Jt,Ce,fs=`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.`,kt,Ge,gs="Here is a first preprocessing function to join the list of strings for each example and tokenize the result:",vt,Ie,Ut,Ze,ys='To apply this preprocessing function over the entire dataset, use the 🤗 Datasets <a href="https://huggingface.co/docs/datasets/v2.14.5/en/package_reference/main_classes#datasets.Dataset.map" rel="nofollow">map</a> method. You can speed up the <code>map</code> function by setting <code>batched=True</code> to process multiple elements of the dataset at once, and increasing the number of processes with <code>num_proc</code>. Remove any columns you don’t need:',Ct,Re,Gt,We,Ms="This dataset contains the token sequences, but some of these are longer than the maximum input length for the model.",It,Ve,bs="You can now use a second preprocessing function to",Zt,Xe,ws="<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>",Rt,Be,Wt,Fe,$s="Apply the <code>group_texts</code> function over the entire dataset:",Vt,He,Xt,ze,js=`Now create a batch of examples using <a href="/docs/transformers/v4.34.0/en/main_classes/data_collator#transformers.DataCollatorForLanguageModeling">DataCollatorForLanguageModeling</a>. It’s more efficient to <em>dynamically pad</em> the
sentences to the longest length in a batch during collation, instead of padding the whole dataset to the maximum length.`,Bt,ne,Ft,te,oe,lt,Ee,as,Oe,Ts="Train",Ht,re,zt,pe,Et,se,ie,nt,Ae,ls,et,_s="Inference",At,Ye,xs="Great, now that you’ve finetuned a model, you can use it for inference!",Yt,Ne,Js="Come up with a prompt you’d like to generate text from:",Nt,Le,Lt,Qe,ks='The simplest way to try out your finetuned model for inference is to use it in a <a href="/docs/transformers/v4.34.0/en/main_classes/pipelines#transformers.pipeline">pipeline()</a>. Instantiate a <code>pipeline</code> for text generation with your model, and pass your text to it:',Qt,qe,qt,me,Pt,ot,St;return J=new mt({}),C=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"}]}}),F=new Ws({props:{id:"Vpjb1lu0MDk"}}),P=new es({props:{$$slots:{default:[Ys]},$$scope:{ctx:v}}}),x=new U({props:{code:"cGlwJTIwaW5zdGFsbCUyMHRyYW5zZm9ybWVycyUyMGRhdGFzZXRzJTIwZXZhbHVhdGU=",highlighted:"pip install transformers datasets evaluate",wrap:!1}}),fe=new U({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}}),ge=new mt({}),Me=new U({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}}),we=new U({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}}),je=new U({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}}),_e=new mt({}),xe=new Ws({props:{id:"ma1TrR7gE7I"}}),ke=new U({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}}),Ue=new U({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}}),Ie=new U({props:{code:"ZGVmJTIwcHJlcHJvY2Vzc19mdW5jdGlvbihleGFtcGxlcyklM0ElMEElMjAlMjAlMjAlMjByZXR1cm4lMjB0b2tlbml6ZXIoJTVCJTIyJTIwJTIyLmpvaW4oeCklMjBmb3IlMjB4JTIwaW4lMjBleGFtcGxlcyU1QiUyMmFuc3dlcnMudGV4dCUyMiU1RCU1RCk=",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">def</span> <span class="hljs-title function_">preprocess_function</span>(<span class="hljs-params">examples</span>):
<span class="hljs-meta">... </span>    <span class="hljs-keyword">return</span> tokenizer([<span class="hljs-string">&quot; &quot;</span>.join(x) <span class="hljs-keyword">for</span> x <span class="hljs-keyword">in</span> examples[<span class="hljs-string">&quot;answers.text&quot;</span>]])`,wrap:!1}}),Re=new U({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}}),Be=new U({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}}),He=new U({props:{code:"bG1fZGF0YXNldCUyMCUzRCUyMHRva2VuaXplZF9lbGk1Lm1hcChncm91cF90ZXh0cyUyQyUyMGJhdGNoZWQlM0RUcnVlJTJDJTIwbnVtX3Byb2MlM0Q0KQ==",highlighted:'<span class="hljs-meta">&gt;&gt;&gt; </span>lm_dataset = tokenized_eli5.<span class="hljs-built_in">map</span>(group_texts, batched=<span class="hljs-literal">True</span>, num_proc=<span class="hljs-number">4</span>)',wrap:!1}}),ne=new ns({props:{pytorch:!0,tensorflow:!0,jax:!1,$$slots:{tensorflow:[qs],pytorch:[Ls]},$$scope:{ctx:v}}}),Ee=new mt({}),re=new ns({props:{pytorch:!0,tensorflow:!0,jax:!1,$$slots:{tensorflow:[ea],pytorch:[Ds]},$$scope:{ctx:v}}}),pe=new es({props:{$$slots:{default:[ta]},$$scope:{ctx:v}}}),Ae=new mt({}),Le=new U({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}}),qe=new U({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}}),me=new ns({props:{pytorch:!0,tensorflow:!0,jax:!1,$$slots:{tensorflow:[na],pytorch:[aa]},$$scope:{ctx:v}}}),{c(){s=u("meta"),c=r(),l=u("p"),o=r(),g=u("h1"),f=u("a"),Z=u("span"),y(J.$$.fragment),V=r(),R=u("span"),R.textContent=W,E=r(),y(C.$$.fragment),k=r(),G=u("p"),G.textContent=i,_=r(),y(F.$$.fragment),A=r(),H=u("p"),H.textContent=q,S=r(),z=u("p"),z.textContent=L,Y=r(),h=u("ol"),h.innerHTML=I,Q=r(),y(P.$$.fragment),D=r(),K=u("p"),K.textContent=he,m=r(),y(x.$$.fragment),ue=r(),de=u("p"),de.textContent=os,ct=r(),y(fe.$$.fragment),ht=r(),O=u("h2"),ae=u("a"),st=u("span"),y(ge.$$.fragment),ts=r(),De=u("span"),De.textContent=rs,ut=r(),ye=u("p"),ye.textContent=ps,dt=r(),y(Me.$$.fragment),ft=r(),be=u("p"),be.innerHTML=is,gt=r(),y(we.$$.fragment),yt=r(),$e=u("p"),$e.textContent=ms,Mt=r(),y(je.$$.fragment),bt=r(),Te=u("p"),Te.innerHTML=cs,wt=r(),ee=u("h2"),le=u("a"),at=u("span"),y(_e.$$.fragment),ss=r(),Ke=u("span"),Ke.textContent=hs,$t=r(),y(xe.$$.fragment),jt=r(),Je=u("p"),Je.innerHTML=us,Tt=r(),y(ke.$$.fragment),_t=r(),ve=u("p"),ve.innerHTML=ds,xt=r(),y(Ue.$$.fragment),Jt=r(),Ce=u("p"),Ce.innerHTML=fs,kt=r(),Ge=u("p"),Ge.textContent=gs,vt=r(),y(Ie.$$.fragment),Ut=r(),Ze=u("p"),Ze.innerHTML=ys,Ct=r(),y(Re.$$.fragment),Gt=r(),We=u("p"),We.textContent=Ms,It=r(),Ve=u("p"),Ve.textContent=bs,Zt=r(),Xe=u("ul"),Xe.innerHTML=ws,Rt=r(),y(Be.$$.fragment),Wt=r(),Fe=u("p"),Fe.innerHTML=$s,Vt=r(),y(He.$$.fragment),Xt=r(),ze=u("p"),ze.innerHTML=js,Bt=r(),y(ne.$$.fragment),Ft=r(),te=u("h2"),oe=u("a"),lt=u("span"),y(Ee.$$.fragment),as=r(),Oe=u("span"),Oe.textContent=Ts,Ht=r(),y(re.$$.fragment),zt=r(),y(pe.$$.fragment),Et=r(),se=u("h2"),ie=u("a"),nt=u("span"),y(Ae.$$.fragment),ls=r(),et=u("span"),et.textContent=_s,At=r(),Ye=u("p"),Ye.textContent=xs,Yt=r(),Ne=u("p"),Ne.textContent=Js,Nt=r(),y(Le.$$.fragment),Lt=r(),Qe=u("p"),Qe.innerHTML=ks,Qt=r(),y(qe.$$.fragment),qt=r(),y(me.$$.fragment),Pt=r(),ot=u("p"),this.h()},l(e){const n=Es("svelte-1phssyn",document.head);s=d(n,"META",{name:!0,content:!0}),n.forEach(t),c=p(e),l=d(e,"P",{}),N(l).forEach(t),o=p(e),g=d(e,"H1",{class:!0});var Pe=N(g);f=d(Pe,"A",{id:!0,class:!0,href:!0});var rt=N(f);Z=d(rt,"SPAN",{});var pt=N(Z);M(J.$$.fragment,pt),pt.forEach(t),rt.forEach(t),V=p(Pe),R=d(Pe,"SPAN",{"data-svelte-h":!0}),T(R)!=="svelte-vcsbqx"&&(R.textContent=W),Pe.forEach(t),E=p(e),M(C.$$.fragment,e),k=p(e),G=d(e,"P",{"data-svelte-h":!0}),T(G)!=="svelte-1j29ona"&&(G.textContent=i),_=p(e),M(F.$$.fragment,e),A=p(e),H=d(e,"P",{"data-svelte-h":!0}),T(H)!=="svelte-nw6q3g"&&(H.textContent=q),S=p(e),z=d(e,"P",{"data-svelte-h":!0}),T(z)!=="svelte-1aff4p7"&&(z.textContent=L),Y=p(e),h=d(e,"OL",{"data-svelte-h":!0}),T(h)!=="svelte-1h2f171"&&(h.innerHTML=I),Q=p(e),M(P.$$.fragment,e),D=p(e),K=d(e,"P",{"data-svelte-h":!0}),T(K)!=="svelte-1c9nexd"&&(K.textContent=he),m=p(e),M(x.$$.fragment,e),ue=p(e),de=d(e,"P",{"data-svelte-h":!0}),T(de)!=="svelte-27hn0u"&&(de.textContent=os),ct=p(e),M(fe.$$.fragment,e),ht=p(e),O=d(e,"H2",{class:!0});var Se=N(O);ae=d(Se,"A",{id:!0,class:!0,href:!0});var it=N(ae);st=d(it,"SPAN",{});var vs=N(st);M(ge.$$.fragment,vs),vs.forEach(t),it.forEach(t),ts=p(Se),De=d(Se,"SPAN",{"data-svelte-h":!0}),T(De)!=="svelte-vt5erg"&&(De.textContent=rs),Se.forEach(t),ut=p(e),ye=d(e,"P",{"data-svelte-h":!0}),T(ye)!=="svelte-mxq58u"&&(ye.textContent=ps),dt=p(e),M(Me.$$.fragment,e),ft=p(e),be=d(e,"P",{"data-svelte-h":!0}),T(be)!=="svelte-4cgbu8"&&(be.innerHTML=is),gt=p(e),M(we.$$.fragment,e),yt=p(e),$e=d(e,"P",{"data-svelte-h":!0}),T($e)!=="svelte-1m91ua0"&&($e.textContent=ms),Mt=p(e),M(je.$$.fragment,e),bt=p(e),Te=d(e,"P",{"data-svelte-h":!0}),T(Te)!=="svelte-1wm9gdc"&&(Te.innerHTML=cs),wt=p(e),ee=d(e,"H2",{class:!0});var Dt=N(ee);le=d(Dt,"A",{id:!0,class:!0,href:!0});var Us=N(le);at=d(Us,"SPAN",{});var Cs=N(at);M(_e.$$.fragment,Cs),Cs.forEach(t),Us.forEach(t),ss=p(Dt),Ke=d(Dt,"SPAN",{"data-svelte-h":!0}),T(Ke)!=="svelte-1cg9qj"&&(Ke.textContent=hs),Dt.forEach(t),$t=p(e),M(xe.$$.fragment,e),jt=p(e),Je=d(e,"P",{"data-svelte-h":!0}),T(Je)!=="svelte-1lrcpa6"&&(Je.innerHTML=us),Tt=p(e),M(ke.$$.fragment,e),_t=p(e),ve=d(e,"P",{"data-svelte-h":!0}),T(ve)!=="svelte-z1itq1"&&(ve.innerHTML=ds),xt=p(e),M(Ue.$$.fragment,e),Jt=p(e),Ce=d(e,"P",{"data-svelte-h":!0}),T(Ce)!=="svelte-1mdv3gu"&&(Ce.innerHTML=fs),kt=p(e),Ge=d(e,"P",{"data-svelte-h":!0}),T(Ge)!=="svelte-njkc6i"&&(Ge.textContent=gs),vt=p(e),M(Ie.$$.fragment,e),Ut=p(e),Ze=d(e,"P",{"data-svelte-h":!0}),T(Ze)!=="svelte-1iccbqj"&&(Ze.innerHTML=ys),Ct=p(e),M(Re.$$.fragment,e),Gt=p(e),We=d(e,"P",{"data-svelte-h":!0}),T(We)!=="svelte-pz0l04"&&(We.textContent=Ms),It=p(e),Ve=d(e,"P",{"data-svelte-h":!0}),T(Ve)!=="svelte-5guq64"&&(Ve.textContent=bs),Zt=p(e),Xe=d(e,"UL",{"data-svelte-h":!0}),T(Xe)!=="svelte-19gyadw"&&(Xe.innerHTML=ws),Rt=p(e),M(Be.$$.fragment,e),Wt=p(e),Fe=d(e,"P",{"data-svelte-h":!0}),T(Fe)!=="svelte-1o69amy"&&(Fe.innerHTML=$s),Vt=p(e),M(He.$$.fragment,e),Xt=p(e),ze=d(e,"P",{"data-svelte-h":!0}),T(ze)!=="svelte-1pqegmx"&&(ze.innerHTML=js),Bt=p(e),M(ne.$$.fragment,e),Ft=p(e),te=d(e,"H2",{class:!0});var Kt=N(te);oe=d(Kt,"A",{id:!0,class:!0,href:!0});var Gs=N(oe);lt=d(Gs,"SPAN",{});var Is=N(lt);M(Ee.$$.fragment,Is),Is.forEach(t),Gs.forEach(t),as=p(Kt),Oe=d(Kt,"SPAN",{"data-svelte-h":!0}),T(Oe)!=="svelte-5arm0l"&&(Oe.textContent=Ts),Kt.forEach(t),Ht=p(e),M(re.$$.fragment,e),zt=p(e),M(pe.$$.fragment,e),Et=p(e),se=d(e,"H2",{class:!0});var Ot=N(se);ie=d(Ot,"A",{id:!0,class:!0,href:!0});var Zs=N(ie);nt=d(Zs,"SPAN",{});var Rs=N(nt);M(Ae.$$.fragment,Rs),Rs.forEach(t),Zs.forEach(t),ls=p(Ot),et=d(Ot,"SPAN",{"data-svelte-h":!0}),T(et)!=="svelte-199uz7g"&&(et.textContent=_s),Ot.forEach(t),At=p(e),Ye=d(e,"P",{"data-svelte-h":!0}),T(Ye)!=="svelte-633ppb"&&(Ye.textContent=xs),Yt=p(e),Ne=d(e,"P",{"data-svelte-h":!0}),T(Ne)!=="svelte-12i1768"&&(Ne.textContent=Js),Nt=p(e),M(Le.$$.fragment,e),Lt=p(e),Qe=d(e,"P",{"data-svelte-h":!0}),T(Qe)!=="svelte-1532y41"&&(Qe.innerHTML=ks),Qt=p(e),M(qe.$$.fragment,e),qt=p(e),M(me.$$.fragment,e),Pt=p(e),ot=d(e,"P",{}),N(ot).forEach(t),this.h()},h(){X(s,"name","hf:doc:metadata"),X(s,"content",JSON.stringify(ra)),X(f,"id","causal-language-modeling"),X(f,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),X(f,"href","#causal-language-modeling"),X(g,"class","relative group"),X(ae,"id","load-eli5-dataset"),X(ae,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),X(ae,"href","#load-eli5-dataset"),X(O,"class","relative group"),X(le,"id","preprocess"),X(le,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),X(le,"href","#preprocess"),X(ee,"class","relative group"),X(oe,"id","train"),X(oe,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),X(oe,"href","#train"),X(te,"class","relative group"),X(ie,"id","inference"),X(ie,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),X(ie,"href","#inference"),X(se,"class","relative group")},m(e,n){B(document.head,s),a(e,c,n),a(e,l,n),a(e,o,n),a(e,g,n),B(g,f),B(f,Z),b(J,Z,null),B(g,V),B(g,R),a(e,E,n),b(C,e,n),a(e,k,n),a(e,G,n),a(e,_,n),b(F,e,n),a(e,A,n),a(e,H,n),a(e,S,n),a(e,z,n),a(e,Y,n),a(e,h,n),a(e,Q,n),b(P,e,n),a(e,D,n),a(e,K,n),a(e,m,n),b(x,e,n),a(e,ue,n),a(e,de,n),a(e,ct,n),b(fe,e,n),a(e,ht,n),a(e,O,n),B(O,ae),B(ae,st),b(ge,st,null),B(O,ts),B(O,De),a(e,ut,n),a(e,ye,n),a(e,dt,n),b(Me,e,n),a(e,ft,n),a(e,be,n),a(e,gt,n),b(we,e,n),a(e,yt,n),a(e,$e,n),a(e,Mt,n),b(je,e,n),a(e,bt,n),a(e,Te,n),a(e,wt,n),a(e,ee,n),B(ee,le),B(le,at),b(_e,at,null),B(ee,ss),B(ee,Ke),a(e,$t,n),b(xe,e,n),a(e,jt,n),a(e,Je,n),a(e,Tt,n),b(ke,e,n),a(e,_t,n),a(e,ve,n),a(e,xt,n),b(Ue,e,n),a(e,Jt,n),a(e,Ce,n),a(e,kt,n),a(e,Ge,n),a(e,vt,n),b(Ie,e,n),a(e,Ut,n),a(e,Ze,n),a(e,Ct,n),b(Re,e,n),a(e,Gt,n),a(e,We,n),a(e,It,n),a(e,Ve,n),a(e,Zt,n),a(e,Xe,n),a(e,Rt,n),b(Be,e,n),a(e,Wt,n),a(e,Fe,n),a(e,Vt,n),b(He,e,n),a(e,Xt,n),a(e,ze,n),a(e,Bt,n),b(ne,e,n),a(e,Ft,n),a(e,te,n),B(te,oe),B(oe,lt),b(Ee,lt,null),B(te,as),B(te,Oe),a(e,Ht,n),b(re,e,n),a(e,zt,n),b(pe,e,n),a(e,Et,n),a(e,se,n),B(se,ie),B(ie,nt),b(Ae,nt,null),B(se,ls),B(se,et),a(e,At,n),a(e,Ye,n),a(e,Yt,n),a(e,Ne,n),a(e,Nt,n),b(Le,e,n),a(e,Lt,n),a(e,Qe,n),a(e,Qt,n),b(qe,e,n),a(e,qt,n),b(me,e,n),a(e,Pt,n),a(e,ot,n),St=!0},p(e,[n]){const Pe={};n&2&&(Pe.$$scope={dirty:n,ctx:e}),P.$set(Pe);const rt={};n&2&&(rt.$$scope={dirty:n,ctx:e}),ne.$set(rt);const pt={};n&2&&(pt.$$scope={dirty:n,ctx:e}),re.$set(pt);const Se={};n&2&&(Se.$$scope={dirty:n,ctx:e}),pe.$set(Se);const it={};n&2&&(it.$$scope={dirty:n,ctx:e}),me.$set(it)},i(e){St||(w(J.$$.fragment,e),w(C.$$.fragment,e),w(F.$$.fragment,e),w(P.$$.fragment,e),w(x.$$.fragment,e),w(fe.$$.fragment,e),w(ge.$$.fragment,e),w(Me.$$.fragment,e),w(we.$$.fragment,e),w(je.$$.fragment,e),w(_e.$$.fragment,e),w(xe.$$.fragment,e),w(ke.$$.fragment,e),w(Ue.$$.fragment,e),w(Ie.$$.fragment,e),w(Re.$$.fragment,e),w(Be.$$.fragment,e),w(He.$$.fragment,e),w(ne.$$.fragment,e),w(Ee.$$.fragment,e),w(re.$$.fragment,e),w(pe.$$.fragment,e),w(Ae.$$.fragment,e),w(Le.$$.fragment,e),w(qe.$$.fragment,e),w(me.$$.fragment,e),St=!0)},o(e){$(J.$$.fragment,e),$(C.$$.fragment,e),$(F.$$.fragment,e),$(P.$$.fragment,e),$(x.$$.fragment,e),$(fe.$$.fragment,e),$(ge.$$.fragment,e),$(Me.$$.fragment,e),$(we.$$.fragment,e),$(je.$$.fragment,e),$(_e.$$.fragment,e),$(xe.$$.fragment,e),$(ke.$$.fragment,e),$(Ue.$$.fragment,e),$(Ie.$$.fragment,e),$(Re.$$.fragment,e),$(Be.$$.fragment,e),$(He.$$.fragment,e),$(ne.$$.fragment,e),$(Ee.$$.fragment,e),$(re.$$.fragment,e),$(pe.$$.fragment,e),$(Ae.$$.fragment,e),$(Le.$$.fragment,e),$(qe.$$.fragment,e),$(me.$$.fragment,e),St=!1},d(e){e&&(t(c),t(l),t(o),t(g),t(E),t(k),t(G),t(_),t(A),t(H),t(S),t(z),t(Y),t(h),t(Q),t(D),t(K),t(m),t(ue),t(de),t(ct),t(ht),t(O),t(ut),t(ye),t(dt),t(ft),t(be),t(gt),t(yt),t($e),t(Mt),t(bt),t(Te),t(wt),t(ee),t($t),t(jt),t(Je),t(Tt),t(_t),t(ve),t(xt),t(Jt),t(Ce),t(kt),t(Ge),t(vt),t(Ut),t(Ze),t(Ct),t(Gt),t(We),t(It),t(Ve),t(Zt),t(Xe),t(Rt),t(Wt),t(Fe),t(Vt),t(Xt),t(ze),t(Bt),t(Ft),t(te),t(Ht),t(zt),t(Et),t(se),t(At),t(Ye),t(Yt),t(Ne),t(Nt),t(Lt),t(Qe),t(Qt),t(qt),t(Pt),t(ot)),t(s),j(J),j(C,e),j(F,e),j(P,e),j(x,e),j(fe,e),j(ge),j(Me,e),j(we,e),j(je,e),j(_e),j(xe,e),j(ke,e),j(Ue,e),j(Ie,e),j(Re,e),j(Be,e),j(He,e),j(ne,e),j(Ee),j(re,e),j(pe,e),j(Ae),j(Le,e),j(qe,e),j(me,e)}}}const ra={local:"causal-language-modeling",sections:[{local:"load-eli5-dataset",title:"Load ELI5 dataset"},{local:"preprocess",title:"Preprocess"},{local:"train",title:"Train"},{local:"inference",title:"Inference"}],title:"Causal language modeling"};function pa(v){return Fs(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class ya extends Hs{constructor(s){super(),zs(this,s,pa,oa,Bs,{})}}export{ya as component};
