import{s as Dt,o as Kt,n as te}from"../chunks/scheduler.9bc65507.js";import{S as Ot,i as es,g as j,s as i,r as u,A as ts,h as $,f as s,c as m,j as Qt,u as g,x as T,k as At,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 $t}from"../chunks/Tip.c2ecdbf4.js";import{Y as qt}from"../chunks/Youtube.e1129c6f.js";import{C as Z}from"../chunks/CodeBlock.54a9f38d.js";import{D as as}from"../chunks/DocNotebookDropdown.41f65cb5.js";import{F as Tt,M as We}from"../chunks/Markdown.fef84341.js";import{H as Ve}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/gemma">Gemma</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/mamba">Mamba</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/mixtral">Mixtral</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/phi">Phi</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/qwen2">Qwen2</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/stablelm">StableLm</a>, <a href="../model_doc/starcoder2">Starcoder2</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=j("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=$(r,"P",{"data-svelte-h":!0}),T(c)!=="svelte-3tg236"&&(c.innerHTML=a)},m(r,d){l(r,t,d),l(r,c,d)},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,d;return r=new Z({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=j("p"),t.innerHTML=c,a=i(),u(r.$$.fragment)},l(f){t=$(f,"P",{"data-svelte-h":!0}),T(t)!=="svelte-su9ugx"&&(t.innerHTML=c),a=m(f),g(r.$$.fragment,f)},m(f,G){l(f,t,G),l(f,a,G),y(r,f,G),d=!0},p:te,i(f){d||(M(r.$$.fragment,f),d=!0)},o(f){b(r.$$.fragment,f),d=!1},d(f){f&&(s(t),s(a)),w(r,f)}}}function os(U){let t,c;return t=new We({props:{$$slots:{default:[ns]},$$scope:{ctx:U}}}),{c(){u(t.$$.fragment)},l(a){g(t.$$.fragment,a)},m(a,r){y(t,a,r),c=!0},p(a,r){const d={};r&2&&(d.$$scope={dirty:r,ctx:a}),t.$set(d)},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,d;return r=new Z({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=j("p"),t.innerHTML=c,a=i(),u(r.$$.fragment)},l(f){t=$(f,"P",{"data-svelte-h":!0}),T(t)!=="svelte-su9ugx"&&(t.innerHTML=c),a=m(f),g(r.$$.fragment,f)},m(f,G){l(f,t,G),l(f,a,G),y(r,f,G),d=!0},p:te,i(f){d||(M(r.$$.fragment,f),d=!0)},o(f){b(r.$$.fragment,f),d=!1},d(f){f&&(s(t),s(a)),w(r,f)}}}function ps(U){let t,c;return t=new We({props:{$$slots:{default:[rs]},$$scope:{ctx:U}}}),{c(){u(t.$$.fragment)},l(a){g(t.$$.fragment,a)},m(a,r){y(t,a,r),c=!0},p(a,r){const d={};r&2&&(d.$$scope={dirty:r,ctx:a}),t.$set(d)},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=j("p"),t.innerHTML=c},l(a){t=$(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>:',d,f,G,I,v="At this point, only three steps remain:",R,C,V='<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>',W,x,X,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:',N,E,F,Q,A='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 $t({props:{$$slots:{default:[is]},$$scope:{ctx:U}}}),f=new Z({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMEF1dG9Nb2RlbEZvckNhdXNhbExNJTJDJTIwVHJhaW5pbmdBcmd1bWVudHMlMkMlMjBUcmFpbmVyJTBBJTBBbW9kZWwlMjAlM0QlMjBBdXRvTW9kZWxGb3JDYXVzYWxMTS5mcm9tX3ByZXRyYWluZWQoJTIyZGlzdGlsYmVydCUyRmRpc3RpbGdwdDIlMjIp",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;distilbert/distilgpt2&quot;</span>)`,wrap:!1}}),x=new Z({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 Z({props:{code:"aW1wb3J0JTIwbWF0aCUwQSUwQWV2YWxfcmVzdWx0cyUyMCUzRCUyMHRyYWluZXIuZXZhbHVhdGUoKSUwQXByaW50KGYlMjJQZXJwbGV4aXR5JTNBJTIwJTdCbWF0aC5leHAoZXZhbF9yZXN1bHRzJTVCJ2V2YWxfbG9zcyclNUQpJTNBLjJmJTdEJTIyKQ==",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">import</span> math

<span class="hljs-meta">&gt;&gt;&gt; </span>eval_results = trainer.evaluate()
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-built_in">print</span>(<span class="hljs-string">f&quot;Perplexity: <span class="hljs-subst">{math.exp(eval_results[<span class="hljs-string">&#x27;eval_loss&#x27;</span>]):<span class="hljs-number">.2</span>f}</span>&quot;</span>)
Perplexity: <span class="hljs-number">49.61</span>`,wrap:!1}}),Y=new Z({props:{code:"dHJhaW5lci5wdXNoX3RvX2h1Yigp",highlighted:'<span class="hljs-meta">&gt;&gt;&gt; </span>trainer.push_to_hub()',wrap:!1}}),{c(){u(t.$$.fragment),c=i(),a=j("p"),a.innerHTML=r,d=i(),u(f.$$.fragment),G=i(),I=j("p"),I.textContent=v,R=i(),C=j("ol"),C.innerHTML=V,W=i(),u(x.$$.fragment),X=i(),o=j("p"),o.innerHTML=_,N=i(),u(E.$$.fragment),F=i(),Q=j("p"),Q.innerHTML=A,B=i(),u(Y.$$.fragment)},l(h){g(t.$$.fragment,h),c=m(h),a=$(h,"P",{"data-svelte-h":!0}),T(a)!=="svelte-1q2so56"&&(a.innerHTML=r),d=m(h),g(f.$$.fragment,h),G=m(h),I=$(h,"P",{"data-svelte-h":!0}),T(I)!=="svelte-l42k0i"&&(I.textContent=v),R=m(h),C=$(h,"OL",{"data-svelte-h":!0}),T(C)!=="svelte-9nzdq0"&&(C.innerHTML=V),W=m(h),g(x.$$.fragment,h),X=m(h),o=$(h,"P",{"data-svelte-h":!0}),T(o)!=="svelte-18h3zoe"&&(o.innerHTML=_),N=m(h),g(E.$$.fragment,h),F=m(h),Q=$(h,"P",{"data-svelte-h":!0}),T(Q)!=="svelte-1ofhil3"&&(Q.innerHTML=A),B=m(h),g(Y.$$.fragment,h)},m(h,k){y(t,h,k),l(h,c,k),l(h,a,k),l(h,d,k),y(f,h,k),l(h,G,k),l(h,I,k),l(h,R,k),l(h,C,k),l(h,W,k),y(x,h,k),l(h,X,k),l(h,o,k),l(h,N,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(d),s(G),s(I),s(R),s(C),s(W),s(X),s(o),s(N),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 We({props:{$$slots:{default:[ms]},$$scope:{ctx:U}}}),{c(){u(t.$$.fragment)},l(a){g(t.$$.fragment,a)},m(a,r){y(t,a,r),c=!0},p(a,r){const d={};r&2&&(d.$$scope={dirty:r,ctx:a}),t.$set(d)},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=j("p"),t.innerHTML=c},l(a){t=$(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 ds(U){let t,c,a,r,d,f='Then you can load DistilGPT2 with <a href="/docs/transformers/main/en/model_doc/auto#transformers.TFAutoModelForCausalLM">TFAutoModelForCausalLM</a>:',G,I,v,R,C='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>:',V,W,x,X,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:',_,N,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>:',A,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,Re="Once training is completed, your model is automatically uploaded to the Hub so everyone can use it!",S;return t=new $t({props:{$$slots:{default:[hs]},$$scope:{ctx:U}}}),a=new Z({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMGNyZWF0ZV9vcHRpbWl6ZXIlMkMlMjBBZGFtV2VpZ2h0RGVjYXklMEElMEFvcHRpbWl6ZXIlMjAlM0QlMjBBZGFtV2VpZ2h0RGVjYXkobGVhcm5pbmdfcmF0ZSUzRDJlLTUlMkMlMjB3ZWlnaHRfZGVjYXlfcmF0ZSUzRDAuMDEp",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> create_optimizer, AdamWeightDecay

<span class="hljs-meta">&gt;&gt;&gt; </span>optimizer = AdamWeightDecay(learning_rate=<span class="hljs-number">2e-5</span>, weight_decay_rate=<span class="hljs-number">0.01</span>)`,wrap:!1}}),I=new Z({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMFRGQXV0b01vZGVsRm9yQ2F1c2FsTE0lMEElMEFtb2RlbCUyMCUzRCUyMFRGQXV0b01vZGVsRm9yQ2F1c2FsTE0uZnJvbV9wcmV0cmFpbmVkKCUyMmRpc3RpbGJlcnQlMkZkaXN0aWxncHQyJTIyKQ==",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;distilbert/distilgpt2&quot;</span>)`,wrap:!1}}),W=new Z({props:{code:"dGZfdHJhaW5fc2V0JTIwJTNEJTIwbW9kZWwucHJlcGFyZV90Zl9kYXRhc2V0KCUwQSUyMCUyMCUyMCUyMGxtX2RhdGFzZXQlNUIlMjJ0cmFpbiUyMiU1RCUyQyUwQSUyMCUyMCUyMCUyMHNodWZmbGUlM0RUcnVlJTJDJTBBJTIwJTIwJTIwJTIwYmF0Y2hfc2l6ZSUzRDE2JTJDJTBBJTIwJTIwJTIwJTIwY29sbGF0ZV9mbiUzRGRhdGFfY29sbGF0b3IlMkMlMEEpJTBBJTBBdGZfdGVzdF9zZXQlMjAlM0QlMjBtb2RlbC5wcmVwYXJlX3RmX2RhdGFzZXQoJTBBJTIwJTIwJTIwJTIwbG1fZGF0YXNldCU1QiUyMnRlc3QlMjIlNUQlMkMlMEElMjAlMjAlMjAlMjBzaHVmZmxlJTNERmFsc2UlMkMlMEElMjAlMjAlMjAlMjBiYXRjaF9zaXplJTNEMTYlMkMlMEElMjAlMjAlMjAlMjBjb2xsYXRlX2ZuJTNEZGF0YV9jb2xsYXRvciUyQyUwQSk=",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span>tf_train_set = model.prepare_tf_dataset(
<span class="hljs-meta">... </span>    lm_dataset[<span class="hljs-string">&quot;train&quot;</span>],
<span class="hljs-meta">... </span>    shuffle=<span class="hljs-literal">True</span>,
<span class="hljs-meta">... </span>    batch_size=<span class="hljs-number">16</span>,
<span class="hljs-meta">... </span>    collate_fn=data_collator,
<span class="hljs-meta">... </span>)

<span class="hljs-meta">&gt;&gt;&gt; </span>tf_test_set = model.prepare_tf_dataset(
<span class="hljs-meta">... </span>    lm_dataset[<span class="hljs-string">&quot;test&quot;</span>],
<span class="hljs-meta">... </span>    shuffle=<span class="hljs-literal">False</span>,
<span class="hljs-meta">... </span>    batch_size=<span class="hljs-number">16</span>,
<span class="hljs-meta">... </span>    collate_fn=data_collator,
<span class="hljs-meta">... </span>)`,wrap:!1}}),N=new Z({props:{code:"aW1wb3J0JTIwdGVuc29yZmxvdyUyMGFzJTIwdGYlMEElMEFtb2RlbC5jb21waWxlKG9wdGltaXplciUzRG9wdGltaXplciklMjAlMjAlMjMlMjBObyUyMGxvc3MlMjBhcmd1bWVudCE=",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">import</span> tensorflow <span class="hljs-keyword">as</span> tf

<span class="hljs-meta">&gt;&gt;&gt; </span>model.<span class="hljs-built_in">compile</span>(optimizer=optimizer)  <span class="hljs-comment"># No loss argument!</span>`,wrap:!1}}),B=new Z({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 Z({props:{code:"bW9kZWwuZml0KHglM0R0Zl90cmFpbl9zZXQlMkMlMjB2YWxpZGF0aW9uX2RhdGElM0R0Zl90ZXN0X3NldCUyQyUyMGVwb2NocyUzRDMlMkMlMjBjYWxsYmFja3MlM0QlNUJjYWxsYmFjayU1RCk=",highlighted:'<span class="hljs-meta">&gt;&gt;&gt; </span>model.fit(x=tf_train_set, validation_data=tf_test_set, epochs=<span class="hljs-number">3</span>, callbacks=[callback])',wrap:!1}}),{c(){u(t.$$.fragment),c=Pt(`
To finetune a model in TensorFlow, start by setting up an optimizer function, learning rate schedule, and some training hyperparameters:

	`),u(a.$$.fragment),r=i(),d=j("p"),d.innerHTML=f,G=i(),u(I.$$.fragment),v=i(),R=j("p"),R.innerHTML=C,V=i(),u(W.$$.fragment),x=i(),X=j("p"),X.innerHTML=o,_=i(),u(N.$$.fragment),E=i(),F=j("p"),F.innerHTML=Q,A=i(),u(B.$$.fragment),Y=i(),z=j("p"),z.innerHTML=h,k=i(),u(H.$$.fragment),P=i(),L=j("p"),L.textContent=Re},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),d=$(p,"P",{"data-svelte-h":!0}),T(d)!=="svelte-dt80o4"&&(d.innerHTML=f),G=m(p),g(I.$$.fragment,p),v=m(p),R=$(p,"P",{"data-svelte-h":!0}),T(R)!=="svelte-9ymftz"&&(R.innerHTML=C),V=m(p),g(W.$$.fragment,p),x=m(p),X=$(p,"P",{"data-svelte-h":!0}),T(X)!=="svelte-17cxx5e"&&(X.innerHTML=o),_=m(p),g(N.$$.fragment,p),E=m(p),F=$(p,"P",{"data-svelte-h":!0}),T(F)!=="svelte-1aajtcp"&&(F.innerHTML=Q),A=m(p),g(B.$$.fragment,p),Y=m(p),z=$(p,"P",{"data-svelte-h":!0}),T(z)!=="svelte-1pfsro2"&&(z.innerHTML=h),k=m(p),g(H.$$.fragment,p),P=m(p),L=$(p,"P",{"data-svelte-h":!0}),T(L)!=="svelte-2s71om"&&(L.textContent=Re)},m(p,J){y(t,p,J),l(p,c,J),y(a,p,J),l(p,r,J),l(p,d,J),l(p,G,J),y(I,p,J),l(p,v,J),l(p,R,J),l(p,V,J),y(W,p,J),l(p,x,J),l(p,X,J),l(p,_,J),y(N,p,J),l(p,E,J),l(p,F,J),l(p,A,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(I.$$.fragment,p),M(W.$$.fragment,p),M(N.$$.fragment,p),M(B.$$.fragment,p),M(H.$$.fragment,p),S=!0)},o(p){b(t.$$.fragment,p),b(a.$$.fragment,p),b(I.$$.fragment,p),b(W.$$.fragment,p),b(N.$$.fragment,p),b(B.$$.fragment,p),b(H.$$.fragment,p),S=!1},d(p){p&&(s(c),s(r),s(d),s(G),s(v),s(R),s(V),s(x),s(X),s(_),s(E),s(F),s(A),s(Y),s(z),s(k),s(P),s(L)),w(t,p),w(a,p),w(I,p),w(W,p),w(N,p),w(B,p),w(H,p)}}}function fs(U){let t,c;return t=new We({props:{$$slots:{default:[ds]},$$scope:{ctx:U}}}),{c(){u(t.$$.fragment)},l(a){g(t.$$.fragment,a)},m(a,r){y(t,a,r),c=!0},p(a,r){const d={};r&2&&(d.$$scope={dirty:r,ctx:a}),t.$set(d)},i(a){c||(M(t.$$.fragment,a),c=!0)},o(a){b(t.$$.fragment,a),c=!1},d(a){w(t,a)}}}function us(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=j("p"),t.innerHTML=c},l(a){t=$(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,d,f,G=`Use the <a href="/docs/transformers/main/en/model_doc/phi#transformers.PhiForCausalLM.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.`,I,v,R,C,V="Decode the generated token ids back into text:",W,x,X;return r=new Z({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMEF1dG9Ub2tlbml6ZXIlMEElMEF0b2tlbml6ZXIlMjAlM0QlMjBBdXRvVG9rZW5pemVyLmZyb21fcHJldHJhaW5lZCglMjJ1c2VybmFtZSUyRm15X2F3ZXNvbWVfZWxpNV9jbG0tbW9kZWwlMjIpJTBBaW5wdXRzJTIwJTNEJTIwdG9rZW5pemVyKHByb21wdCUyQyUyMHJldHVybl90ZW5zb3JzJTNEJTIycHQlMjIpLmlucHV0X2lkcw==",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoTokenizer

<span class="hljs-meta">&gt;&gt;&gt; </span>tokenizer = AutoTokenizer.from_pretrained(<span class="hljs-string">&quot;username/my_awesome_eli5_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 Z({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMEF1dG9Nb2RlbEZvckNhdXNhbExNJTBBJTBBbW9kZWwlMjAlM0QlMjBBdXRvTW9kZWxGb3JDYXVzYWxMTS5mcm9tX3ByZXRyYWluZWQoJTIydXNlcm5hbWUlMkZteV9hd2Vzb21lX2VsaTVfY2xtLW1vZGVsJTIyKSUwQW91dHB1dHMlMjAlM0QlMjBtb2RlbC5nZW5lcmF0ZShpbnB1dHMlMkMlMjBtYXhfbmV3X3Rva2VucyUzRDEwMCUyQyUyMGRvX3NhbXBsZSUzRFRydWUlMkMlMjB0b3BfayUzRDUwJTJDJTIwdG9wX3AlM0QwLjk1KQ==",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;username/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 Z({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=j("p"),t.innerHTML=c,a=i(),u(r.$$.fragment),d=i(),f=j("p"),f.innerHTML=G,I=i(),u(v.$$.fragment),R=i(),C=j("p"),C.textContent=V,W=i(),u(x.$$.fragment)},l(o){t=$(o,"P",{"data-svelte-h":!0}),T(t)!=="svelte-1c2y1ia"&&(t.innerHTML=c),a=m(o),g(r.$$.fragment,o),d=m(o),f=$(o,"P",{"data-svelte-h":!0}),T(f)!=="svelte-118pydh"&&(f.innerHTML=G),I=m(o),g(v.$$.fragment,o),R=m(o),C=$(o,"P",{"data-svelte-h":!0}),T(C)!=="svelte-1918fu9"&&(C.textContent=V),W=m(o),g(x.$$.fragment,o)},m(o,_){l(o,t,_),l(o,a,_),y(r,o,_),l(o,d,_),l(o,f,_),l(o,I,_),y(v,o,_),l(o,R,_),l(o,C,_),l(o,W,_),y(x,o,_),X=!0},p:te,i(o){X||(M(r.$$.fragment,o),M(v.$$.fragment,o),M(x.$$.fragment,o),X=!0)},o(o){b(r.$$.fragment,o),b(v.$$.fragment,o),b(x.$$.fragment,o),X=!1},d(o){o&&(s(t),s(a),s(d),s(f),s(I),s(R),s(C),s(W)),w(r,o),w(v,o),w(x,o)}}}function ys(U){let t,c;return t=new We({props:{$$slots:{default:[gs]},$$scope:{ctx:U}}}),{c(){u(t.$$.fragment)},l(a){g(t.$$.fragment,a)},m(a,r){y(t,a,r),c=!0},p(a,r){const d={};r&2&&(d.$$scope={dirty:r,ctx:a}),t.$set(d)},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,d,f,G='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.',I,v,R,C,V="Decode the generated token ids back into text:",W,x,X;return r=new Z({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMEF1dG9Ub2tlbml6ZXIlMEElMEF0b2tlbml6ZXIlMjAlM0QlMjBBdXRvVG9rZW5pemVyLmZyb21fcHJldHJhaW5lZCglMjJ1c2VybmFtZSUyRm15X2F3ZXNvbWVfZWxpNV9jbG0tbW9kZWwlMjIpJTBBaW5wdXRzJTIwJTNEJTIwdG9rZW5pemVyKHByb21wdCUyQyUyMHJldHVybl90ZW5zb3JzJTNEJTIydGYlMjIpLmlucHV0X2lkcw==",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoTokenizer

<span class="hljs-meta">&gt;&gt;&gt; </span>tokenizer = AutoTokenizer.from_pretrained(<span class="hljs-string">&quot;username/my_awesome_eli5_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 Z({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMFRGQXV0b01vZGVsRm9yQ2F1c2FsTE0lMEElMEFtb2RlbCUyMCUzRCUyMFRGQXV0b01vZGVsRm9yQ2F1c2FsTE0uZnJvbV9wcmV0cmFpbmVkKCUyMnVzZXJuYW1lJTJGbXlfYXdlc29tZV9lbGk1X2NsbS1tb2RlbCUyMiklMEFvdXRwdXRzJTIwJTNEJTIwbW9kZWwuZ2VuZXJhdGUoaW5wdXRfaWRzJTNEaW5wdXRzJTJDJTIwbWF4X25ld190b2tlbnMlM0QxMDAlMkMlMjBkb19zYW1wbGUlM0RUcnVlJTJDJTIwdG9wX2slM0Q1MCUyQyUyMHRvcF9wJTNEMC45NSk=",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;username/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 Z({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=j("p"),t.innerHTML=c,a=i(),u(r.$$.fragment),d=i(),f=j("p"),f.innerHTML=G,I=i(),u(v.$$.fragment),R=i(),C=j("p"),C.textContent=V,W=i(),u(x.$$.fragment)},l(o){t=$(o,"P",{"data-svelte-h":!0}),T(t)!=="svelte-hw2mu6"&&(t.innerHTML=c),a=m(o),g(r.$$.fragment,o),d=m(o),f=$(o,"P",{"data-svelte-h":!0}),T(f)!=="svelte-sk8f6j"&&(f.innerHTML=G),I=m(o),g(v.$$.fragment,o),R=m(o),C=$(o,"P",{"data-svelte-h":!0}),T(C)!=="svelte-1918fu9"&&(C.textContent=V),W=m(o),g(x.$$.fragment,o)},m(o,_){l(o,t,_),l(o,a,_),y(r,o,_),l(o,d,_),l(o,f,_),l(o,I,_),y(v,o,_),l(o,R,_),l(o,C,_),l(o,W,_),y(x,o,_),X=!0},p:te,i(o){X||(M(r.$$.fragment,o),M(v.$$.fragment,o),M(x.$$.fragment,o),X=!0)},o(o){b(r.$$.fragment,o),b(v.$$.fragment,o),b(x.$$.fragment,o),X=!1},d(o){o&&(s(t),s(a),s(d),s(f),s(I),s(R),s(C),s(W)),w(r,o),w(v,o),w(x,o)}}}function bs(U){let t,c;return t=new We({props:{$$slots:{default:[Ms]},$$scope:{ctx:U}}}),{c(){u(t.$$.fragment)},l(a){g(t.$$.fragment,a)},m(a,r){y(t,a,r),c=!0},p(a,r){const d={};r&2&&(d.$$scope={dirty:r,ctx:a}),t.$set(d)},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,d,f,G,I,v,R=`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.`,C,V,W,x,X=`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,_,N="This guide will show you how to:",E,F,Q='<li>Finetune <a href="https://huggingface.co/distilbert/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>',A,B,Y,z,h="Before you begin, make sure you have all the necessary libraries installed:",k,H,P,L,Re="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 the first 5000 examples from the <a href="https://huggingface.co/datasets/eli5_category" rel="nofollow">ELI5-Category</a> dataset with the 🤗 Datasets library. This’ll give you a chance to experiment and make sure everything works before spending more time training on the full dataset.',Fe,ae,ze,le,xt='Split the dataset’s <code>train</code> split into a train and test set with the <a href="https://huggingface.co/docs/datasets/main/en/package_reference/main_classes#datasets.Dataset.train_test_split" rel="nofollow">train_test_split</a> method:',He,ne,Ee,oe,Jt="Then take a look at an example:",Ye,re,Ne,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,Ae,ce,Ut="The next step is to load a DistilGPT2 tokenizer to process the <code>text</code> subfield:",qe,he,Pe,de,Gt=`You’ll notice from the example above, the <code>text</code> field is actually nested inside <code>answers</code>. This means you’ll need to
extract the <code>text</code> subfield from its nested structure with the <a href="https://huggingface.co/docs/datasets/process#flatten" rel="nofollow"><code>flatten</code></a> method:`,Se,fe,De,ue,vt=`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,Ct="Here is a first preprocessing function to join the list of strings for each example and tokenize the result:",Oe,ye,et,Me,Zt='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,It="This dataset contains the token sequences, but some of these are longer than the maximum input length for the model.",at,je,Wt="You can now use a second preprocessing function to",lt,$e,Rt="<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,Xt="Apply the <code>group_texts</code> function over the entire dataset:",rt,xe,pt,Je,Vt=`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,dt,Ue,ft,Ge,Bt="Great, now that you’ve finetuned a model, you can use it for inference!",ut,ve,Ft="Come up with a prompt you’d like to generate text from:",gt,Ce,yt,Ze,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,Ie,bt,ee,wt,Xe,jt;return d=new Ve({props:{title:"Causal language modeling",local:"causal-language-modeling",headingTag:"h1"}}),G=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"}]}}),V=new qt({props:{id:"Vpjb1lu0MDk"}}),B=new $t({props:{$$slots:{default:[ls]},$$scope:{ctx:U}}}),H=new Z({props:{code:"cGlwJTIwaW5zdGFsbCUyMHRyYW5zZm9ybWVycyUyMGRhdGFzZXRzJTIwZXZhbHVhdGU=",highlighted:"pip install transformers datasets evaluate",wrap:!1}}),p=new Z({props:{code:"ZnJvbSUyMGh1Z2dpbmdmYWNlX2h1YiUyMGltcG9ydCUyMG5vdGVib29rX2xvZ2luJTBBJTBBbm90ZWJvb2tfbG9naW4oKQ==",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> huggingface_hub <span class="hljs-keyword">import</span> notebook_login

<span class="hljs-meta">&gt;&gt;&gt; </span>notebook_login()`,wrap:!1}}),q=new Ve({props:{title:"Load ELI5 dataset",local:"load-eli5-dataset",headingTag:"h2"}}),ae=new Z({props:{code:"ZnJvbSUyMGRhdGFzZXRzJTIwaW1wb3J0JTIwbG9hZF9kYXRhc2V0JTBBJTBBZWxpNSUyMCUzRCUyMGxvYWRfZGF0YXNldCglMjJlbGk1X2NhdGVnb3J5JTIyJTJDJTIwc3BsaXQlM0QlMjJ0cmFpbiU1QiUzQTUwMDAlNUQlMjIp",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> datasets <span class="hljs-keyword">import</span> load_dataset

<span class="hljs-meta">&gt;&gt;&gt; </span>eli5 = load_dataset(<span class="hljs-string">&quot;eli5_category&quot;</span>, split=<span class="hljs-string">&quot;train[:5000]&quot;</span>)`,wrap:!1}}),ne=new Z({props:{code:"ZWxpNSUyMCUzRCUyMGVsaTUudHJhaW5fdGVzdF9zcGxpdCh0ZXN0X3NpemUlM0QwLjIp",highlighted:'<span class="hljs-meta">&gt;&gt;&gt; </span>eli5 = eli5.train_test_split(test_size=<span class="hljs-number">0.2</span>)',wrap:!1}}),re=new Z({props:{code:"ZWxpNSU1QiUyMnRyYWluJTIyJTVEJTVCMCU1RA==",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span>eli5[<span class="hljs-string">&quot;train&quot;</span>][<span class="hljs-number">0</span>]
{<span class="hljs-string">&#x27;q_id&#x27;</span>: <span class="hljs-string">&#x27;7h191n&#x27;</span>,
 <span class="hljs-string">&#x27;title&#x27;</span>: <span class="hljs-string">&#x27;What does the tax bill that was passed today mean? How will it affect Americans in each tax bracket?&#x27;</span>,
 <span class="hljs-string">&#x27;selftext&#x27;</span>: <span class="hljs-string">&#x27;&#x27;</span>,
 <span class="hljs-string">&#x27;category&#x27;</span>: <span class="hljs-string">&#x27;Economics&#x27;</span>,
 <span class="hljs-string">&#x27;subreddit&#x27;</span>: <span class="hljs-string">&#x27;explainlikeimfive&#x27;</span>,
 <span class="hljs-string">&#x27;answers&#x27;</span>: {<span class="hljs-string">&#x27;a_id&#x27;</span>: [<span class="hljs-string">&#x27;dqnds8l&#x27;</span>, <span class="hljs-string">&#x27;dqnd1jl&#x27;</span>, <span class="hljs-string">&#x27;dqng3i1&#x27;</span>, <span class="hljs-string">&#x27;dqnku5x&#x27;</span>],
  <span class="hljs-string">&#x27;text&#x27;</span>: [<span class="hljs-string">&quot;The tax bill is 500 pages long and there were a lot of changes still going on right to the end. It&#x27;s not just an adjustment to the income tax brackets, it&#x27;s a whole bunch of changes. As such there is no good answer to your question. The big take aways are: - Big reduction in corporate income tax rate will make large companies very happy. - Pass through rate change will make certain styles of business (law firms, hedge funds) extremely happy - Income tax changes are moderate, and are set to expire (though it&#x27;s the kind of thing that might just always get re-applied without being made permanent) - People in high tax states (California, New York) lose out, and many of them will end up with their taxes raised.&quot;</span>,
   <span class="hljs-string">&#x27;None yet. It has to be reconciled with a vastly different house bill and then passed again.&#x27;</span>,
   <span class="hljs-string">&#x27;Also: does this apply to 2017 taxes? Or does it start with 2018 taxes?&#x27;</span>,
   <span class="hljs-string">&#x27;This article explains both the House and senate bills, including the proposed changes to your income taxes based on your income level. URL_0&#x27;</span>],
  <span class="hljs-string">&#x27;score&#x27;</span>: [<span class="hljs-number">21</span>, <span class="hljs-number">19</span>, <span class="hljs-number">5</span>, <span class="hljs-number">3</span>],
  <span class="hljs-string">&#x27;text_urls&#x27;</span>: [[],
   [],
   [],
   [<span class="hljs-string">&#x27;https://www.investopedia.com/news/trumps-tax-reform-what-can-be-done/&#x27;</span>]]},
 <span class="hljs-string">&#x27;title_urls&#x27;</span>: [<span class="hljs-string">&#x27;url&#x27;</span>],
 <span class="hljs-string">&#x27;selftext_urls&#x27;</span>: [<span class="hljs-string">&#x27;url&#x27;</span>]}`,wrap:!1}}),ie=new Ve({props:{title:"Preprocess",local:"preprocess",headingTag:"h2"}}),me=new qt({props:{id:"ma1TrR7gE7I"}}),he=new Z({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMEF1dG9Ub2tlbml6ZXIlMEElMEF0b2tlbml6ZXIlMjAlM0QlMjBBdXRvVG9rZW5pemVyLmZyb21fcHJldHJhaW5lZCglMjJkaXN0aWxiZXJ0JTJGZGlzdGlsZ3B0MiUyMik=",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoTokenizer

<span class="hljs-meta">&gt;&gt;&gt; </span>tokenizer = AutoTokenizer.from_pretrained(<span class="hljs-string">&quot;distilbert/distilgpt2&quot;</span>)`,wrap:!1}}),fe=new Z({props:{code:"ZWxpNSUyMCUzRCUyMGVsaTUuZmxhdHRlbigpJTBBZWxpNSU1QiUyMnRyYWluJTIyJTVEJTVCMCU1RA==",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span>eli5 = eli5.flatten()
<span class="hljs-meta">&gt;&gt;&gt; </span>eli5[<span class="hljs-string">&quot;train&quot;</span>][<span class="hljs-number">0</span>]
{<span class="hljs-string">&#x27;q_id&#x27;</span>: <span class="hljs-string">&#x27;7h191n&#x27;</span>,
 <span class="hljs-string">&#x27;title&#x27;</span>: <span class="hljs-string">&#x27;What does the tax bill that was passed today mean? How will it affect Americans in each tax bracket?&#x27;</span>,
 <span class="hljs-string">&#x27;selftext&#x27;</span>: <span class="hljs-string">&#x27;&#x27;</span>,
 <span class="hljs-string">&#x27;category&#x27;</span>: <span class="hljs-string">&#x27;Economics&#x27;</span>,
 <span class="hljs-string">&#x27;subreddit&#x27;</span>: <span class="hljs-string">&#x27;explainlikeimfive&#x27;</span>,
 <span class="hljs-string">&#x27;answers.a_id&#x27;</span>: [<span class="hljs-string">&#x27;dqnds8l&#x27;</span>, <span class="hljs-string">&#x27;dqnd1jl&#x27;</span>, <span class="hljs-string">&#x27;dqng3i1&#x27;</span>, <span class="hljs-string">&#x27;dqnku5x&#x27;</span>],
 <span class="hljs-string">&#x27;answers.text&#x27;</span>: [<span class="hljs-string">&quot;The tax bill is 500 pages long and there were a lot of changes still going on right to the end. It&#x27;s not just an adjustment to the income tax brackets, it&#x27;s a whole bunch of changes. As such there is no good answer to your question. The big take aways are: - Big reduction in corporate income tax rate will make large companies very happy. - Pass through rate change will make certain styles of business (law firms, hedge funds) extremely happy - Income tax changes are moderate, and are set to expire (though it&#x27;s the kind of thing that might just always get re-applied without being made permanent) - People in high tax states (California, New York) lose out, and many of them will end up with their taxes raised.&quot;</span>,
  <span class="hljs-string">&#x27;None yet. It has to be reconciled with a vastly different house bill and then passed again.&#x27;</span>,
  <span class="hljs-string">&#x27;Also: does this apply to 2017 taxes? Or does it start with 2018 taxes?&#x27;</span>,
  <span class="hljs-string">&#x27;This article explains both the House and senate bills, including the proposed changes to your income taxes based on your income level. URL_0&#x27;</span>],
 <span class="hljs-string">&#x27;answers.score&#x27;</span>: [<span class="hljs-number">21</span>, <span class="hljs-number">19</span>, <span class="hljs-number">5</span>, <span class="hljs-number">3</span>],
 <span class="hljs-string">&#x27;answers.text_urls&#x27;</span>: [[],
  [],
  [],
  [<span class="hljs-string">&#x27;https://www.investopedia.com/news/trumps-tax-reform-what-can-be-done/&#x27;</span>]],
 <span class="hljs-string">&#x27;title_urls&#x27;</span>: [<span class="hljs-string">&#x27;url&#x27;</span>],
 <span class="hljs-string">&#x27;selftext_urls&#x27;</span>: [<span class="hljs-string">&#x27;url&#x27;</span>]}`,wrap:!1}}),ye=new Z({props:{code:"ZGVmJTIwcHJlcHJvY2Vzc19mdW5jdGlvbihleGFtcGxlcyklM0ElMEElMjAlMjAlMjAlMjByZXR1cm4lMjB0b2tlbml6ZXIoJTVCJTIyJTIwJTIyLmpvaW4oeCklMjBmb3IlMjB4JTIwaW4lMjBleGFtcGxlcyU1QiUyMmFuc3dlcnMudGV4dCUyMiU1RCU1RCk=",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">def</span> <span class="hljs-title function_">preprocess_function</span>(<span class="hljs-params">examples</span>):
<span class="hljs-meta">... </span>    <span class="hljs-keyword">return</span> tokenizer([<span class="hljs-string">&quot; &quot;</span>.join(x) <span class="hljs-keyword">for</span> x <span class="hljs-keyword">in</span> examples[<span class="hljs-string">&quot;answers.text&quot;</span>]])`,wrap:!1}}),be=new Z({props:{code:"dG9rZW5pemVkX2VsaTUlMjAlM0QlMjBlbGk1Lm1hcCglMEElMjAlMjAlMjAlMjBwcmVwcm9jZXNzX2Z1bmN0aW9uJTJDJTBBJTIwJTIwJTIwJTIwYmF0Y2hlZCUzRFRydWUlMkMlMEElMjAlMjAlMjAlMjBudW1fcHJvYyUzRDQlMkMlMEElMjAlMjAlMjAlMjByZW1vdmVfY29sdW1ucyUzRGVsaTUlNUIlMjJ0cmFpbiUyMiU1RC5jb2x1bW5fbmFtZXMlMkMlMEEp",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span>tokenized_eli5 = eli5.<span class="hljs-built_in">map</span>(
<span class="hljs-meta">... </span>    preprocess_function,
<span class="hljs-meta">... </span>    batched=<span class="hljs-literal">True</span>,
<span class="hljs-meta">... </span>    num_proc=<span class="hljs-number">4</span>,
<span class="hljs-meta">... </span>    remove_columns=eli5[<span class="hljs-string">&quot;train&quot;</span>].column_names,
<span class="hljs-meta">... </span>)`,wrap:!1}}),Te=new Z({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 Z({props:{code:"bG1fZGF0YXNldCUyMCUzRCUyMHRva2VuaXplZF9lbGk1Lm1hcChncm91cF90ZXh0cyUyQyUyMGJhdGNoZWQlM0RUcnVlJTJDJTIwbnVtX3Byb2MlM0Q0KQ==",highlighted:'<span class="hljs-meta">&gt;&gt;&gt; </span>lm_dataset = tokenized_eli5.<span class="hljs-built_in">map</span>(group_texts, batched=<span class="hljs-literal">True</span>, num_proc=<span class="hljs-number">4</span>)',wrap:!1}}),D=new Tt({props:{pytorch:!0,tensorflow:!0,jax:!1,$$slots:{tensorflow:[ps],pytorch:[os]},$$scope:{ctx:U}}}),ke=new Ve({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 $t({props:{$$slots:{default:[us]},$$scope:{ctx:U}}}),Ue=new Ve({props:{title:"Inference",local:"inference",headingTag:"h2"}}),Ce=new Z({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}}),Ie=new Z({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMHBpcGVsaW5lJTBBJTBBZ2VuZXJhdG9yJTIwJTNEJTIwcGlwZWxpbmUoJTIydGV4dC1nZW5lcmF0aW9uJTIyJTJDJTIwbW9kZWwlM0QlMjJ1c2VybmFtZSUyRm15X2F3ZXNvbWVfZWxpNV9jbG0tbW9kZWwlMjIpJTBBZ2VuZXJhdG9yKHByb21wdCk=",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;username/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=j("meta"),c=i(),a=j("p"),r=i(),u(d.$$.fragment),f=i(),u(G.$$.fragment),I=i(),v=j("p"),v.textContent=R,C=i(),u(V.$$.fragment),W=i(),x=j("p"),x.textContent=X,o=i(),_=j("p"),_.textContent=N,E=i(),F=j("ol"),F.innerHTML=Q,A=i(),u(B.$$.fragment),Y=i(),z=j("p"),z.textContent=h,k=i(),u(H.$$.fragment),P=i(),L=j("p"),L.textContent=Re,S=i(),u(p.$$.fragment),J=i(),u(q.$$.fragment),Be=i(),se=j("p"),se.innerHTML=_t,Fe=i(),u(ae.$$.fragment),ze=i(),le=j("p"),le.innerHTML=xt,He=i(),u(ne.$$.fragment),Ee=i(),oe=j("p"),oe.textContent=Jt,Ye=i(),u(re.$$.fragment),Ne=i(),pe=j("p"),pe.innerHTML=kt,Le=i(),u(ie.$$.fragment),Qe=i(),u(me.$$.fragment),Ae=i(),ce=j("p"),ce.innerHTML=Ut,qe=i(),u(he.$$.fragment),Pe=i(),de=j("p"),de.innerHTML=Gt,Se=i(),u(fe.$$.fragment),De=i(),ue=j("p"),ue.innerHTML=vt,Ke=i(),ge=j("p"),ge.textContent=Ct,Oe=i(),u(ye.$$.fragment),et=i(),Me=j("p"),Me.innerHTML=Zt,tt=i(),u(be.$$.fragment),st=i(),we=j("p"),we.textContent=It,at=i(),je=j("p"),je.textContent=Wt,lt=i(),$e=j("ul"),$e.innerHTML=Rt,nt=i(),u(Te.$$.fragment),ot=i(),_e=j("p"),_e.innerHTML=Xt,rt=i(),u(xe.$$.fragment),pt=i(),Je=j("p"),Je.innerHTML=Vt,it=i(),u(D.$$.fragment),mt=i(),u(ke.$$.fragment),ct=i(),u(K.$$.fragment),ht=i(),u(O.$$.fragment),dt=i(),u(Ue.$$.fragment),ft=i(),Ge=j("p"),Ge.textContent=Bt,ut=i(),ve=j("p"),ve.textContent=Ft,gt=i(),u(Ce.$$.fragment),yt=i(),Ze=j("p"),Ze.innerHTML=zt,Mt=i(),u(Ie.$$.fragment),bt=i(),u(ee.$$.fragment),wt=i(),Xe=j("p"),this.h()},l(e){const n=ts("svelte-u9bgzb",document.head);t=$(n,"META",{name:!0,content:!0}),n.forEach(s),c=m(e),a=$(e,"P",{}),Qt(a).forEach(s),r=m(e),g(d.$$.fragment,e),f=m(e),g(G.$$.fragment,e),I=m(e),v=$(e,"P",{"data-svelte-h":!0}),T(v)!=="svelte-1j29ona"&&(v.textContent=R),C=m(e),g(V.$$.fragment,e),W=m(e),x=$(e,"P",{"data-svelte-h":!0}),T(x)!=="svelte-nw6q3g"&&(x.textContent=X),o=m(e),_=$(e,"P",{"data-svelte-h":!0}),T(_)!=="svelte-1aff4p7"&&(_.textContent=N),E=m(e),F=$(e,"OL",{"data-svelte-h":!0}),T(F)!=="svelte-27cdvu"&&(F.innerHTML=Q),A=m(e),g(B.$$.fragment,e),Y=m(e),z=$(e,"P",{"data-svelte-h":!0}),T(z)!=="svelte-1c9nexd"&&(z.textContent=h),k=m(e),g(H.$$.fragment,e),P=m(e),L=$(e,"P",{"data-svelte-h":!0}),T(L)!=="svelte-27hn0u"&&(L.textContent=Re),S=m(e),g(p.$$.fragment,e),J=m(e),g(q.$$.fragment,e),Be=m(e),se=$(e,"P",{"data-svelte-h":!0}),T(se)!=="svelte-1172m8d"&&(se.innerHTML=_t),Fe=m(e),g(ae.$$.fragment,e),ze=m(e),le=$(e,"P",{"data-svelte-h":!0}),T(le)!=="svelte-rugbz4"&&(le.innerHTML=xt),He=m(e),g(ne.$$.fragment,e),Ee=m(e),oe=$(e,"P",{"data-svelte-h":!0}),T(oe)!=="svelte-1m91ua0"&&(oe.textContent=Jt),Ye=m(e),g(re.$$.fragment,e),Ne=m(e),pe=$(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),Ae=m(e),ce=$(e,"P",{"data-svelte-h":!0}),T(ce)!=="svelte-1lrcpa6"&&(ce.innerHTML=Ut),qe=m(e),g(he.$$.fragment,e),Pe=m(e),de=$(e,"P",{"data-svelte-h":!0}),T(de)!=="svelte-1tms5jm"&&(de.innerHTML=Gt),Se=m(e),g(fe.$$.fragment,e),De=m(e),ue=$(e,"P",{"data-svelte-h":!0}),T(ue)!=="svelte-1mdv3gu"&&(ue.innerHTML=vt),Ke=m(e),ge=$(e,"P",{"data-svelte-h":!0}),T(ge)!=="svelte-njkc6i"&&(ge.textContent=Ct),Oe=m(e),g(ye.$$.fragment,e),et=m(e),Me=$(e,"P",{"data-svelte-h":!0}),T(Me)!=="svelte-1xbgtq4"&&(Me.innerHTML=Zt),tt=m(e),g(be.$$.fragment,e),st=m(e),we=$(e,"P",{"data-svelte-h":!0}),T(we)!=="svelte-pz0l04"&&(we.textContent=It),at=m(e),je=$(e,"P",{"data-svelte-h":!0}),T(je)!=="svelte-5guq64"&&(je.textContent=Wt),lt=m(e),$e=$(e,"UL",{"data-svelte-h":!0}),T($e)!=="svelte-19gyadw"&&($e.innerHTML=Rt),nt=m(e),g(Te.$$.fragment,e),ot=m(e),_e=$(e,"P",{"data-svelte-h":!0}),T(_e)!=="svelte-1o69amy"&&(_e.innerHTML=Xt),rt=m(e),g(xe.$$.fragment,e),pt=m(e),Je=$(e,"P",{"data-svelte-h":!0}),T(Je)!=="svelte-ghlfnb"&&(Je.innerHTML=Vt),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),dt=m(e),g(Ue.$$.fragment,e),ft=m(e),Ge=$(e,"P",{"data-svelte-h":!0}),T(Ge)!=="svelte-633ppb"&&(Ge.textContent=Bt),ut=m(e),ve=$(e,"P",{"data-svelte-h":!0}),T(ve)!=="svelte-12i1768"&&(ve.textContent=Ft),gt=m(e),g(Ce.$$.fragment,e),yt=m(e),Ze=$(e,"P",{"data-svelte-h":!0}),T(Ze)!=="svelte-1t6v145"&&(Ze.innerHTML=zt),Mt=m(e),g(Ie.$$.fragment,e),bt=m(e),g(ee.$$.fragment,e),wt=m(e),Xe=$(e,"P",{}),Qt(Xe).forEach(s),this.h()},h(){At(t,"name","hf:doc:metadata"),At(t,"content",js)},m(e,n){ss(document.head,t),l(e,c,n),l(e,a,n),l(e,r,n),y(d,e,n),l(e,f,n),y(G,e,n),l(e,I,n),l(e,v,n),l(e,C,n),y(V,e,n),l(e,W,n),l(e,x,n),l(e,o,n),l(e,_,n),l(e,E,n),l(e,F,n),l(e,A,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,Ne,n),l(e,pe,n),l(e,Le,n),y(ie,e,n),l(e,Qe,n),y(me,e,n),l(e,Ae,n),l(e,ce,n),l(e,qe,n),y(he,e,n),l(e,Pe,n),l(e,de,n),l(e,Se,n),y(fe,e,n),l(e,De,n),l(e,ue,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,je,n),l(e,lt,n),l(e,$e,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,dt,n),y(Ue,e,n),l(e,ft,n),l(e,Ge,n),l(e,ut,n),l(e,ve,n),l(e,gt,n),y(Ce,e,n),l(e,yt,n),l(e,Ze,n),l(e,Mt,n),y(Ie,e,n),l(e,bt,n),y(ee,e,n),l(e,wt,n),l(e,Xe,n),jt=!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 Nt={};n&2&&(Nt.$$scope={dirty:n,ctx:e}),O.$set(Nt);const Lt={};n&2&&(Lt.$$scope={dirty:n,ctx:e}),ee.$set(Lt)},i(e){jt||(M(d.$$.fragment,e),M(G.$$.fragment,e),M(V.$$.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(Ce.$$.fragment,e),M(Ie.$$.fragment,e),M(ee.$$.fragment,e),jt=!0)},o(e){b(d.$$.fragment,e),b(G.$$.fragment,e),b(V.$$.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(Ce.$$.fragment,e),b(Ie.$$.fragment,e),b(ee.$$.fragment,e),jt=!1},d(e){e&&(s(c),s(a),s(r),s(f),s(I),s(v),s(C),s(W),s(x),s(o),s(_),s(E),s(F),s(A),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(Ne),s(pe),s(Le),s(Qe),s(Ae),s(ce),s(qe),s(Pe),s(de),s(Se),s(De),s(ue),s(Ke),s(ge),s(Oe),s(et),s(Me),s(tt),s(st),s(we),s(at),s(je),s(lt),s($e),s(nt),s(ot),s(_e),s(rt),s(pt),s(Je),s(it),s(mt),s(ct),s(ht),s(dt),s(ft),s(Ge),s(ut),s(ve),s(gt),s(yt),s(Ze),s(Mt),s(bt),s(wt),s(Xe)),s(t),w(d,e),w(G,e),w(V,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(Ce,e),w(Ie,e),w(ee,e)}}}const js='{"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 $s(U){return Kt(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class Cs extends Ot{constructor(t){super(),es(this,t,$s,ws,Dt,{})}}export{Cs as component};
