import{s as Ft,o as Yt,n as Ut}from"../chunks/scheduler.9bc65507.js";import{S as At,i as Nt,g as r,s as i,u as M,A as Lt,h as o,f as e,c as p,j as w,v,y as g,k as f,o as c,a as s,w as b,d as $,t as j,x as T}from"../chunks/index.78c82d43.js";import{T as xt}from"../chunks/Tip.87d55b76.js";import{Y as Zt}from"../chunks/Youtube.b19762b6.js";import{I as Oe}from"../chunks/IconCopyLink.bedaa44d.js";import{C as R}from"../chunks/CodeBlock.48618ec2.js";import{D as St}from"../chunks/DocNotebookDropdown.40f7599b.js";import{F as Vt,M as Gt}from"../chunks/Markdown.993b48ef.js";function Qt(Re){let d,k=`You will see a warning about some of the pretrained weights not being used and some weights being randomly
initialized. Don’t worry, this is completely normal! The pretrained head of the BERT model is discarded, and replaced with a randomly initialized classification head. You will fine-tune this new model head on your sequence classification task, transferring the knowledge of the pretrained model to it.`;return{c(){d=r("p"),d.textContent=k},l(h){d=o(h,"P",{"data-svelte-h":!0}),g(d)!=="svelte-19yjdqu"&&(d.textContent=k)},m(h,J){s(h,d,J)},p:Ut,d(h){h&&e(d)}}}function Pt(Re){let d,k,h,J,_,C,Ye,E,Ae="Train with PyTorch Trainer",pe,ke,et='🤗 Transformers provides a <a href="/docs/transformers/v4.33.3/en/main_classes/trainer#transformers.Trainer">Trainer</a> class optimized for training 🤗 Transformers models, making it easier to start training without manually writing your own training loop. The <a href="/docs/transformers/v4.33.3/en/main_classes/trainer#transformers.Trainer">Trainer</a> API supports a wide range of training options and features such as logging, gradient accumulation, and mixed precision.',P,V,he='Start by loading your model and specify the number of expected labels. From the Yelp Review <a href="https://huggingface.co/datasets/yelp_review_full#data-fields" rel="nofollow">dataset card</a>, you know there are five labels:',ne,re,Me,X,Pe,Z,de,me,x,Ue,ce,ve="Training hyperparameters",Je,Ne,Ee='Next, create a <a href="/docs/transformers/v4.33.3/en/main_classes/trainer#transformers.TrainingArguments">TrainingArguments</a> class which contains all the hyperparameters you can tune as well as flags for activating different training options. For this tutorial you can start with the default training <a href="https://huggingface.co/docs/transformers/main_classes/trainer#transformers.TrainingArguments" rel="nofollow">hyperparameters</a>, but feel free to experiment with these to find your optimal settings.',q,K,_e="Specify where to save the checkpoints from your training:",tt,D,O,ee,F,z,Y,oe,be,Xe="Evaluate",ue,xe,fe='<a href="/docs/transformers/v4.33.3/en/main_classes/trainer#transformers.Trainer">Trainer</a> does not automatically evaluate model performance during training. You’ll need to pass <a href="/docs/transformers/v4.33.3/en/main_classes/trainer#transformers.Trainer">Trainer</a> a function to compute and report metrics. The <a href="https://huggingface.co/docs/evaluate/index" rel="nofollow">🤗 Evaluate</a> library provides a simple <a href="https://huggingface.co/spaces/evaluate-metric/accuracy" rel="nofollow"><code>accuracy</code></a> function you can load with the <a href="https://huggingface.co/docs/evaluate/v0.4.0/en/package_reference/loading_methods#evaluate.load" rel="nofollow">evaluate.load</a> (see this <a href="https://huggingface.co/docs/evaluate/a_quick_tour" rel="nofollow">quicktour</a> for more information) function:',Ge,A,N,te,Ce="Call <code>compute</code> on <code>metric</code> to calculate the accuracy of your predictions. Before passing your predictions to <code>compute</code>, you need to convert the predictions to logits (remember all 🤗 Transformers models return logits):",ze,ae,L,S,ye="If you’d like to monitor your evaluation metrics during fine-tuning, specify the <code>evaluation_strategy</code> parameter in your training arguments to report the evaluation metric at the end of each epoch:",$e,G,Le,ge,U,st,je,I,Be,Te="Trainer",Ie,B,H='Create a <a href="/docs/transformers/v4.33.3/en/main_classes/trainer#transformers.Trainer">Trainer</a> object with your model, training arguments, training and test datasets, and evaluation function:',Se,W,He,ie,Ze='Then fine-tune your model by calling <a href="/docs/transformers/v4.33.3/en/main_classes/trainer#transformers.Trainer.train">train()</a>:',at,Q,se;return d=new Zt({props:{id:"nvBXf7s7vTI"}}),C=new Oe({}),re=new R({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMEF1dG9Nb2RlbEZvclNlcXVlbmNlQ2xhc3NpZmljYXRpb24lMEElMEFtb2RlbCUyMCUzRCUyMEF1dG9Nb2RlbEZvclNlcXVlbmNlQ2xhc3NpZmljYXRpb24uZnJvbV9wcmV0cmFpbmVkKCUyMmJlcnQtYmFzZS1jYXNlZCUyMiUyQyUyMG51bV9sYWJlbHMlM0Q1KQ==",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoModelForSequenceClassification

<span class="hljs-meta">&gt;&gt;&gt; </span>model = AutoModelForSequenceClassification.from_pretrained(<span class="hljs-string">&quot;bert-base-cased&quot;</span>, num_labels=<span class="hljs-number">5</span>)`}}),X=new xt({props:{$$slots:{default:[Qt]},$$scope:{ctx:Re}}}),x=new Oe({}),D=new R({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMFRyYWluaW5nQXJndW1lbnRzJTBBJTBBdHJhaW5pbmdfYXJncyUyMCUzRCUyMFRyYWluaW5nQXJndW1lbnRzKG91dHB1dF9kaXIlM0QlMjJ0ZXN0X3RyYWluZXIlMjIp",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> TrainingArguments

<span class="hljs-meta">&gt;&gt;&gt; </span>training_args = TrainingArguments(output_dir=<span class="hljs-string">&quot;test_trainer&quot;</span>)`}}),Y=new Oe({}),A=new R({props:{code:"aW1wb3J0JTIwbnVtcHklMjBhcyUyMG5wJTBBaW1wb3J0JTIwZXZhbHVhdGUlMEElMEFtZXRyaWMlMjAlM0QlMjBldmFsdWF0ZS5sb2FkKCUyMmFjY3VyYWN5JTIyKQ==",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">import</span> numpy <span class="hljs-keyword">as</span> np
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">import</span> evaluate

<span class="hljs-meta">&gt;&gt;&gt; </span>metric = evaluate.load(<span class="hljs-string">&quot;accuracy&quot;</span>)`}}),ae=new R({props:{code:"ZGVmJTIwY29tcHV0ZV9tZXRyaWNzKGV2YWxfcHJlZCklM0ElMEElMjAlMjAlMjAlMjBsb2dpdHMlMkMlMjBsYWJlbHMlMjAlM0QlMjBldmFsX3ByZWQlMEElMjAlMjAlMjAlMjBwcmVkaWN0aW9ucyUyMCUzRCUyMG5wLmFyZ21heChsb2dpdHMlMkMlMjBheGlzJTNELTEpJTBBJTIwJTIwJTIwJTIwcmV0dXJuJTIwbWV0cmljLmNvbXB1dGUocHJlZGljdGlvbnMlM0RwcmVkaWN0aW9ucyUyQyUyMHJlZmVyZW5jZXMlM0RsYWJlbHMp",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">def</span> <span class="hljs-title function_">compute_metrics</span>(<span class="hljs-params">eval_pred</span>):
<span class="hljs-meta">... </span>    logits, labels = eval_pred
<span class="hljs-meta">... </span>    predictions = np.argmax(logits, axis=-<span class="hljs-number">1</span>)
<span class="hljs-meta">... </span>    <span class="hljs-keyword">return</span> metric.compute(predictions=predictions, references=labels)`}}),G=new R({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMFRyYWluaW5nQXJndW1lbnRzJTJDJTIwVHJhaW5lciUwQSUwQXRyYWluaW5nX2FyZ3MlMjAlM0QlMjBUcmFpbmluZ0FyZ3VtZW50cyhvdXRwdXRfZGlyJTNEJTIydGVzdF90cmFpbmVyJTIyJTJDJTIwZXZhbHVhdGlvbl9zdHJhdGVneSUzRCUyMmVwb2NoJTIyKQ==",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> TrainingArguments, Trainer

<span class="hljs-meta">&gt;&gt;&gt; </span>training_args = TrainingArguments(output_dir=<span class="hljs-string">&quot;test_trainer&quot;</span>, evaluation_strategy=<span class="hljs-string">&quot;epoch&quot;</span>)`}}),je=new Oe({}),W=new R({props:{code:"dHJhaW5lciUyMCUzRCUyMFRyYWluZXIoJTBBJTIwJTIwJTIwJTIwbW9kZWwlM0Rtb2RlbCUyQyUwQSUyMCUyMCUyMCUyMGFyZ3MlM0R0cmFpbmluZ19hcmdzJTJDJTBBJTIwJTIwJTIwJTIwdHJhaW5fZGF0YXNldCUzRHNtYWxsX3RyYWluX2RhdGFzZXQlMkMlMEElMjAlMjAlMjAlMjBldmFsX2RhdGFzZXQlM0RzbWFsbF9ldmFsX2RhdGFzZXQlMkMlMEElMjAlMjAlMjAlMjBjb21wdXRlX21ldHJpY3MlM0Rjb21wdXRlX21ldHJpY3MlMkMlMEEp",highlighted:`<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=small_train_dataset,
<span class="hljs-meta">... </span>    eval_dataset=small_eval_dataset,
<span class="hljs-meta">... </span>    compute_metrics=compute_metrics,
<span class="hljs-meta">... </span>)`}}),Q=new R({props:{code:"dHJhaW5lci50cmFpbigp",highlighted:'<span class="hljs-meta">&gt;&gt;&gt; </span>trainer.train()'}}),{c(){M(d.$$.fragment),k=i(),h=r("h2"),J=r("a"),_=r("span"),M(C.$$.fragment),Ye=i(),E=r("span"),E.textContent=Ae,pe=i(),ke=r("p"),ke.innerHTML=et,P=i(),V=r("p"),V.innerHTML=he,ne=i(),M(re.$$.fragment),Me=i(),M(X.$$.fragment),Pe=i(),Z=r("h3"),de=r("a"),me=r("span"),M(x.$$.fragment),Ue=i(),ce=r("span"),ce.textContent=ve,Je=i(),Ne=r("p"),Ne.innerHTML=Ee,q=i(),K=r("p"),K.textContent=_e,tt=i(),M(D.$$.fragment),O=i(),ee=r("h3"),F=r("a"),z=r("span"),M(Y.$$.fragment),oe=i(),be=r("span"),be.textContent=Xe,ue=i(),xe=r("p"),xe.innerHTML=fe,Ge=i(),M(A.$$.fragment),N=i(),te=r("p"),te.innerHTML=Ce,ze=i(),M(ae.$$.fragment),L=i(),S=r("p"),S.innerHTML=ye,$e=i(),M(G.$$.fragment),Le=i(),ge=r("h3"),U=r("a"),st=r("span"),M(je.$$.fragment),I=i(),Be=r("span"),Be.textContent=Te,Ie=i(),B=r("p"),B.innerHTML=H,Se=i(),M(W.$$.fragment),He=i(),ie=r("p"),ie.innerHTML=Ze,at=i(),M(Q.$$.fragment),this.h()},l(n){v(d.$$.fragment,n),k=p(n),h=o(n,"H2",{class:!0});var t=w(h);J=o(t,"A",{id:!0,class:!0,href:!0});var m=w(J);_=o(m,"SPAN",{});var le=w(_);v(C.$$.fragment,le),le.forEach(e),m.forEach(e),Ye=p(t),E=o(t,"SPAN",{"data-svelte-h":!0}),g(E)!=="svelte-d2t9lx"&&(E.textContent=Ae),t.forEach(e),pe=p(n),ke=o(n,"P",{"data-svelte-h":!0}),g(ke)!=="svelte-xt8025"&&(ke.innerHTML=et),P=p(n),V=o(n,"P",{"data-svelte-h":!0}),g(V)!=="svelte-3dzt1s"&&(V.innerHTML=he),ne=p(n),v(re.$$.fragment,n),Me=p(n),v(X.$$.fragment,n),Pe=p(n),Z=o(n,"H3",{class:!0});var qe=w(Z);de=o(qe,"A",{id:!0,class:!0,href:!0});var We=w(de);me=o(We,"SPAN",{});var Ve=w(me);v(x.$$.fragment,Ve),Ve.forEach(e),We.forEach(e),Ue=p(qe),ce=o(qe,"SPAN",{"data-svelte-h":!0}),g(ce)!=="svelte-1volhx5"&&(ce.textContent=ve),qe.forEach(e),Je=p(n),Ne=o(n,"P",{"data-svelte-h":!0}),g(Ne)!=="svelte-udp1f5"&&(Ne.innerHTML=Ee),q=p(n),K=o(n,"P",{"data-svelte-h":!0}),g(K)!=="svelte-1v0ty1x"&&(K.textContent=_e),tt=p(n),v(D.$$.fragment,n),O=p(n),ee=o(n,"H3",{class:!0});var we=w(ee);F=o(we,"A",{id:!0,class:!0,href:!0});var Ke=w(F);z=o(Ke,"SPAN",{});var Qe=w(z);v(Y.$$.fragment,Qe),Qe.forEach(e),Ke.forEach(e),oe=p(we),be=o(we,"SPAN",{"data-svelte-h":!0}),g(be)!=="svelte-sh8s6s"&&(be.textContent=Xe),we.forEach(e),ue=p(n),xe=o(n,"P",{"data-svelte-h":!0}),g(xe)!=="svelte-ovm4zp"&&(xe.innerHTML=fe),Ge=p(n),v(A.$$.fragment,n),N=p(n),te=o(n,"P",{"data-svelte-h":!0}),g(te)!=="svelte-1wwwem6"&&(te.innerHTML=Ce),ze=p(n),v(ae.$$.fragment,n),L=p(n),S=o(n,"P",{"data-svelte-h":!0}),g(S)!=="svelte-v41bk4"&&(S.innerHTML=ye),$e=p(n),v(G.$$.fragment,n),Le=p(n),ge=o(n,"H3",{class:!0});var Fe=w(ge);U=o(Fe,"A",{id:!0,class:!0,href:!0});var lt=w(U);st=o(lt,"SPAN",{});var it=w(st);v(je.$$.fragment,it),it.forEach(e),lt.forEach(e),I=p(Fe),Be=o(Fe,"SPAN",{"data-svelte-h":!0}),g(Be)!=="svelte-1db8bfa"&&(Be.textContent=Te),Fe.forEach(e),Ie=p(n),B=o(n,"P",{"data-svelte-h":!0}),g(B)!=="svelte-1yu7hzp"&&(B.innerHTML=H),Se=p(n),v(W.$$.fragment,n),He=p(n),ie=o(n,"P",{"data-svelte-h":!0}),g(ie)!=="svelte-18ybfmf"&&(ie.innerHTML=Ze),at=p(n),v(Q.$$.fragment,n),this.h()},h(){f(J,"id","train-with-pytorch-trainer"),f(J,"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"),f(J,"href","#train-with-pytorch-trainer"),f(h,"class","relative group"),f(de,"id","training-hyperparameters"),f(de,"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"),f(de,"href","#training-hyperparameters"),f(Z,"class","relative group"),f(F,"id","evaluate"),f(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"),f(F,"href","#evaluate"),f(ee,"class","relative group"),f(U,"id","trainer"),f(U,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),f(U,"href","#trainer"),f(ge,"class","relative group")},m(n,t){b(d,n,t),s(n,k,t),s(n,h,t),c(h,J),c(J,_),b(C,_,null),c(h,Ye),c(h,E),s(n,pe,t),s(n,ke,t),s(n,P,t),s(n,V,t),s(n,ne,t),b(re,n,t),s(n,Me,t),b(X,n,t),s(n,Pe,t),s(n,Z,t),c(Z,de),c(de,me),b(x,me,null),c(Z,Ue),c(Z,ce),s(n,Je,t),s(n,Ne,t),s(n,q,t),s(n,K,t),s(n,tt,t),b(D,n,t),s(n,O,t),s(n,ee,t),c(ee,F),c(F,z),b(Y,z,null),c(ee,oe),c(ee,be),s(n,ue,t),s(n,xe,t),s(n,Ge,t),b(A,n,t),s(n,N,t),s(n,te,t),s(n,ze,t),b(ae,n,t),s(n,L,t),s(n,S,t),s(n,$e,t),b(G,n,t),s(n,Le,t),s(n,ge,t),c(ge,U),c(U,st),b(je,st,null),c(ge,I),c(ge,Be),s(n,Ie,t),s(n,B,t),s(n,Se,t),b(W,n,t),s(n,He,t),s(n,ie,t),s(n,at,t),b(Q,n,t),se=!0},p(n,t){const m={};t&2&&(m.$$scope={dirty:t,ctx:n}),X.$set(m)},i(n){se||($(d.$$.fragment,n),$(C.$$.fragment,n),$(re.$$.fragment,n),$(X.$$.fragment,n),$(x.$$.fragment,n),$(D.$$.fragment,n),$(Y.$$.fragment,n),$(A.$$.fragment,n),$(ae.$$.fragment,n),$(G.$$.fragment,n),$(je.$$.fragment,n),$(W.$$.fragment,n),$(Q.$$.fragment,n),se=!0)},o(n){j(d.$$.fragment,n),j(C.$$.fragment,n),j(re.$$.fragment,n),j(X.$$.fragment,n),j(x.$$.fragment,n),j(D.$$.fragment,n),j(Y.$$.fragment,n),j(A.$$.fragment,n),j(ae.$$.fragment,n),j(G.$$.fragment,n),j(je.$$.fragment,n),j(W.$$.fragment,n),j(Q.$$.fragment,n),se=!1},d(n){n&&(e(k),e(h),e(pe),e(ke),e(P),e(V),e(ne),e(Me),e(Pe),e(Z),e(Je),e(Ne),e(q),e(K),e(tt),e(O),e(ee),e(ue),e(xe),e(Ge),e(N),e(te),e(ze),e(L),e(S),e($e),e(Le),e(ge),e(Ie),e(B),e(Se),e(He),e(ie),e(at)),T(d,n),T(C),T(re,n),T(X,n),T(x),T(D,n),T(Y),T(A,n),T(ae,n),T(G,n),T(je),T(W,n),T(Q,n)}}}function qt(Re){let d,k;return d=new Gt({props:{$$slots:{default:[Pt]},$$scope:{ctx:Re}}}),{c(){M(d.$$.fragment)},l(h){v(d.$$.fragment,h)},m(h,J){b(d,h,J),k=!0},p(h,J){const _={};J&2&&(_.$$scope={dirty:J,ctx:h}),d.$set(_)},i(h){k||($(d.$$.fragment,h),k=!0)},o(h){j(d.$$.fragment,h),k=!1},d(h){T(d,h)}}}function Kt(Re){let d,k=`You don’t have to pass a loss argument to your models when you <code>compile()</code> them! Hugging Face models automatically
choose a loss that is appropriate for their task and model architecture if this argument is left blank. You can always
override this by specifying a loss yourself if you want to!`;return{c(){d=r("p"),d.innerHTML=k},l(h){d=o(h,"P",{"data-svelte-h":!0}),g(d)!=="svelte-z0w0oe"&&(d.innerHTML=k)},m(h,J){s(h,d,J)},p:Ut,d(h){h&&e(d)}}}function Dt(Re){let d,k,h,J,_,C,Ye,E,Ae,pe,ke="Train a TensorFlow model with Keras",et,P,V="You can also train 🤗 Transformers models in TensorFlow with the Keras API!",he,ne,re,Me,X,Pe,Z,de="Loading data for Keras",me,x,Ue=`When you want to train a 🤗 Transformers model with the Keras API, you need to convert your dataset to a format that
Keras understands. If your dataset is small, you can just convert the whole thing to NumPy arrays and pass it to Keras.
Let’s try that first before we do anything more complicated.`,ce,ve,Je=`First, load a dataset. We’ll use the CoLA dataset from the <a href="https://huggingface.co/datasets/glue" rel="nofollow">GLUE benchmark</a>,
since it’s a simple binary text classification task, and just take the training split for now.`,Ne,Ee,q,K,_e=`Next, load a tokenizer and tokenize the data as NumPy arrays. Note that the labels are already a list of 0 and 1s,
so we can just convert that directly to a NumPy array without tokenization!`,tt,D,O,ee,F='Finally, load, <a href="https://keras.io/api/models/model_training_apis/#compile-method" rel="nofollow"><code>compile</code></a>, and <a href="https://keras.io/api/models/model_training_apis/#fit-method" rel="nofollow"><code>fit</code></a> the model. Note that Transformers models all have a default task-relevant loss function, so you don’t need to specify one unless you want to:',z,Y,oe,be,Xe,ue,xe=`This approach works great for smaller datasets, but for larger datasets, you might find it starts to become a problem. Why?
Because the tokenized array and labels would have to be fully loaded into memory, and because NumPy doesn’t handle
“jagged” arrays, so every tokenized sample would have to be padded to the length of the longest sample in the whole
dataset. That’s going to make your array even bigger, and all those padding tokens will slow down training too!`,fe,Ge,A,N,te,Ce,ze,ae="Loading data as a tf.data.Dataset",L,S,ye=`If you want to avoid slowing down training, you can load your data as a <code>tf.data.Dataset</code> instead. Although you can write your own
<code>tf.data</code> pipeline if you want, we have two convenience methods for doing this:`,$e,G,Le=`<li><a href="/docs/transformers/v4.33.3/en/main_classes/model#transformers.TFPreTrainedModel.prepare_tf_dataset">prepare_tf_dataset()</a>: This is the method we recommend in most cases. Because it is a method
on your model, it can inspect the model to automatically figure out which columns are usable as model inputs, and
discard the others to make a simpler, more performant dataset.</li> <li><a href="https://huggingface.co/docs/datasets/v2.14.5/en/package_reference/main_classes#datasets.Dataset.to_tf_dataset" rel="nofollow">to_tf_dataset</a>: This method is more low-level, and is useful when you want to exactly control how
your dataset is created, by specifying exactly which <code>columns</code> and <code>label_cols</code> to include.</li>`,ge,U,st=`Before you can use <a href="/docs/transformers/v4.33.3/en/main_classes/model#transformers.TFPreTrainedModel.prepare_tf_dataset">prepare_tf_dataset()</a>, you will need to add the tokenizer outputs to your dataset as columns, as shown in
the following code sample:`,je,I,Be,Te,Ie=`Remember that Hugging Face datasets are stored on disk by default, so this will not inflate your memory usage! Once the
columns have been added, you can stream batches from the dataset and add padding to each batch, which greatly
reduces the number of padding tokens compared to padding the entire dataset.`,B,H,Se,W,He=`Note that in the code sample above, you need to pass the tokenizer to <code>prepare_tf_dataset</code> so it can correctly pad batches as they’re loaded.
If all the samples in your dataset are the same length and no padding is necessary, you can skip this argument.
If you need to do something more complex than just padding samples (e.g. corrupting tokens for masked language
modelling), you can use the <code>collate_fn</code> argument instead to pass a function that will be called to transform the
list of samples into a batch and apply any preprocessing you want. See our
<a href="https://github.com/huggingface/transformers/tree/main/examples" rel="nofollow">examples</a> or
<a href="https://huggingface.co/docs/transformers/notebooks" rel="nofollow">notebooks</a> to see this approach in action.`,ie,Ze,at="Once you’ve created a <code>tf.data.Dataset</code>, you can compile and fit the model as before:",Q,se,n;return h=new Zt({props:{id:"rnTGBy2ax1c"}}),E=new Oe({}),X=new Oe({}),Ee=new R({props:{code:"ZnJvbSUyMGRhdGFzZXRzJTIwaW1wb3J0JTIwbG9hZF9kYXRhc2V0JTBBJTBBZGF0YXNldCUyMCUzRCUyMGxvYWRfZGF0YXNldCglMjJnbHVlJTIyJTJDJTIwJTIyY29sYSUyMiklMEFkYXRhc2V0JTIwJTNEJTIwZGF0YXNldCU1QiUyMnRyYWluJTIyJTVEJTIwJTIwJTIzJTIwSnVzdCUyMHRha2UlMjB0aGUlMjB0cmFpbmluZyUyMHNwbGl0JTIwZm9yJTIwbm93",highlighted:`<span class="hljs-keyword">from</span> datasets <span class="hljs-keyword">import</span> load_dataset

dataset = load_dataset(<span class="hljs-string">&quot;glue&quot;</span>, <span class="hljs-string">&quot;cola&quot;</span>)
dataset = dataset[<span class="hljs-string">&quot;train&quot;</span>]  <span class="hljs-comment"># Just take the training split for now</span>`}}),D=new R({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMEF1dG9Ub2tlbml6ZXIlMEElMEF0b2tlbml6ZXIlMjAlM0QlMjBBdXRvVG9rZW5pemVyLmZyb21fcHJldHJhaW5lZCglMjJiZXJ0LWJhc2UtY2FzZWQlMjIpJTBBdG9rZW5pemVkX2RhdGElMjAlM0QlMjB0b2tlbml6ZXIoZGF0YXNldCU1QiUyMnNlbnRlbmNlJTIyJTVEJTJDJTIwcmV0dXJuX3RlbnNvcnMlM0QlMjJucCUyMiUyQyUyMHBhZGRpbmclM0RUcnVlKSUwQSUyMyUyMFRva2VuaXplciUyMHJldHVybnMlMjBhJTIwQmF0Y2hFbmNvZGluZyUyQyUyMGJ1dCUyMHdlJTIwY29udmVydCUyMHRoYXQlMjB0byUyMGElMjBkaWN0JTIwZm9yJTIwS2VyYXMlMEF0b2tlbml6ZWRfZGF0YSUyMCUzRCUyMGRpY3QodG9rZW5pemVkX2RhdGEpJTBBJTBBbGFiZWxzJTIwJTNEJTIwbnAuYXJyYXkoZGF0YXNldCU1QiUyMmxhYmVsJTIyJTVEKSUyMCUyMCUyMyUyMExhYmVsJTIwaXMlMjBhbHJlYWR5JTIwYW4lMjBhcnJheSUyMG9mJTIwMCUyMGFuZCUyMDE=",highlighted:`<span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoTokenizer

tokenizer = AutoTokenizer.from_pretrained(<span class="hljs-string">&quot;bert-base-cased&quot;</span>)
tokenized_data = tokenizer(dataset[<span class="hljs-string">&quot;sentence&quot;</span>], return_tensors=<span class="hljs-string">&quot;np&quot;</span>, padding=<span class="hljs-literal">True</span>)
<span class="hljs-comment"># Tokenizer returns a BatchEncoding, but we convert that to a dict for Keras</span>
tokenized_data = <span class="hljs-built_in">dict</span>(tokenized_data)

labels = np.array(dataset[<span class="hljs-string">&quot;label&quot;</span>])  <span class="hljs-comment"># Label is already an array of 0 and 1</span>`}}),Y=new R({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMFRGQXV0b01vZGVsRm9yU2VxdWVuY2VDbGFzc2lmaWNhdGlvbiUwQWZyb20lMjB0ZW5zb3JmbG93LmtlcmFzLm9wdGltaXplcnMlMjBpbXBvcnQlMjBBZGFtJTBBJTBBJTIzJTIwTG9hZCUyMGFuZCUyMGNvbXBpbGUlMjBvdXIlMjBtb2RlbCUwQW1vZGVsJTIwJTNEJTIwVEZBdXRvTW9kZWxGb3JTZXF1ZW5jZUNsYXNzaWZpY2F0aW9uLmZyb21fcHJldHJhaW5lZCglMjJiZXJ0LWJhc2UtY2FzZWQlMjIpJTBBJTIzJTIwTG93ZXIlMjBsZWFybmluZyUyMHJhdGVzJTIwYXJlJTIwb2Z0ZW4lMjBiZXR0ZXIlMjBmb3IlMjBmaW5lLXR1bmluZyUyMHRyYW5zZm9ybWVycyUwQW1vZGVsLmNvbXBpbGUob3B0aW1pemVyJTNEQWRhbSgzZS01KSklMjAlMjAlMjMlMjBObyUyMGxvc3MlMjBhcmd1bWVudCElMEElMEFtb2RlbC5maXQodG9rZW5pemVkX2RhdGElMkMlMjBsYWJlbHMp",highlighted:`<span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> TFAutoModelForSequenceClassification
<span class="hljs-keyword">from</span> tensorflow.keras.optimizers <span class="hljs-keyword">import</span> Adam

<span class="hljs-comment"># Load and compile our model</span>
model = TFAutoModelForSequenceClassification.from_pretrained(<span class="hljs-string">&quot;bert-base-cased&quot;</span>)
<span class="hljs-comment"># Lower learning rates are often better for fine-tuning transformers</span>
model.<span class="hljs-built_in">compile</span>(optimizer=Adam(<span class="hljs-number">3e-5</span>))  <span class="hljs-comment"># No loss argument!</span>

model.fit(tokenized_data, labels)`}}),be=new xt({props:{$$slots:{default:[Kt]},$$scope:{ctx:Re}}}),te=new Oe({}),I=new R({props:{code:"ZGVmJTIwdG9rZW5pemVfZGF0YXNldChkYXRhKSUzQSUwQSUyMCUyMCUyMCUyMCUyMyUyMEtleXMlMjBvZiUyMHRoZSUyMHJldHVybmVkJTIwZGljdGlvbmFyeSUyMHdpbGwlMjBiZSUyMGFkZGVkJTIwdG8lMjB0aGUlMjBkYXRhc2V0JTIwYXMlMjBjb2x1bW5zJTBBJTIwJTIwJTIwJTIwcmV0dXJuJTIwdG9rZW5pemVyKGRhdGElNUIlMjJ0ZXh0JTIyJTVEKSUwQSUwQSUwQWRhdGFzZXQlMjAlM0QlMjBkYXRhc2V0Lm1hcCh0b2tlbml6ZV9kYXRhc2V0KQ==",highlighted:`<span class="hljs-keyword">def</span> <span class="hljs-title function_">tokenize_dataset</span>(<span class="hljs-params">data</span>):
    <span class="hljs-comment"># Keys of the returned dictionary will be added to the dataset as columns</span>
    <span class="hljs-keyword">return</span> tokenizer(data[<span class="hljs-string">&quot;text&quot;</span>])


dataset = dataset.<span class="hljs-built_in">map</span>(tokenize_dataset)`}}),H=new R({props:{code:"dGZfZGF0YXNldCUyMCUzRCUyMG1vZGVsLnByZXBhcmVfdGZfZGF0YXNldChkYXRhc2V0JTVCJTIydHJhaW4lMjIlNUQlMkMlMjBiYXRjaF9zaXplJTNEMTYlMkMlMjBzaHVmZmxlJTNEVHJ1ZSUyQyUyMHRva2VuaXplciUzRHRva2VuaXplcik=",highlighted:'<span class="hljs-meta">&gt;&gt;&gt; </span>tf_dataset = model.prepare_tf_dataset(dataset[<span class="hljs-string">&quot;train&quot;</span>], batch_size=<span class="hljs-number">16</span>, shuffle=<span class="hljs-literal">True</span>, tokenizer=tokenizer)'}}),se=new R({props:{code:"bW9kZWwuY29tcGlsZShvcHRpbWl6ZXIlM0RBZGFtKDNlLTUpKSUyMCUyMCUyMyUyME5vJTIwbG9zcyUyMGFyZ3VtZW50ISUwQSUwQW1vZGVsLmZpdCh0Zl9kYXRhc2V0KQ==",highlighted:`model.<span class="hljs-built_in">compile</span>(optimizer=Adam(<span class="hljs-number">3e-5</span>))  <span class="hljs-comment"># No loss argument!</span>

model.fit(tf_dataset)`}}),{c(){d=r("a"),k=i(),M(h.$$.fragment),J=i(),_=r("h2"),C=r("a"),Ye=r("span"),M(E.$$.fragment),Ae=i(),pe=r("span"),pe.textContent=ke,et=i(),P=r("p"),P.textContent=V,he=i(),ne=r("h3"),re=r("a"),Me=r("span"),M(X.$$.fragment),Pe=i(),Z=r("span"),Z.textContent=de,me=i(),x=r("p"),x.textContent=Ue,ce=i(),ve=r("p"),ve.innerHTML=Je,Ne=i(),M(Ee.$$.fragment),q=i(),K=r("p"),K.textContent=_e,tt=i(),M(D.$$.fragment),O=i(),ee=r("p"),ee.innerHTML=F,z=i(),M(Y.$$.fragment),oe=i(),M(be.$$.fragment),Xe=i(),ue=r("p"),ue.textContent=xe,fe=i(),Ge=r("h3"),A=r("a"),N=r("span"),M(te.$$.fragment),Ce=i(),ze=r("span"),ze.textContent=ae,L=i(),S=r("p"),S.innerHTML=ye,$e=i(),G=r("ul"),G.innerHTML=Le,ge=i(),U=r("p"),U.innerHTML=st,je=i(),M(I.$$.fragment),Be=i(),Te=r("p"),Te.textContent=Ie,B=i(),M(H.$$.fragment),Se=i(),W=r("p"),W.innerHTML=He,ie=i(),Ze=r("p"),Ze.innerHTML=at,Q=i(),M(se.$$.fragment),this.h()},l(t){d=o(t,"A",{id:!0}),w(d).forEach(e),k=p(t),v(h.$$.fragment,t),J=p(t),_=o(t,"H2",{class:!0});var m=w(_);C=o(m,"A",{id:!0,class:!0,href:!0});var le=w(C);Ye=o(le,"SPAN",{});var qe=w(Ye);v(E.$$.fragment,qe),qe.forEach(e),le.forEach(e),Ae=p(m),pe=o(m,"SPAN",{"data-svelte-h":!0}),g(pe)!=="svelte-zqatjg"&&(pe.textContent=ke),m.forEach(e),et=p(t),P=o(t,"P",{"data-svelte-h":!0}),g(P)!=="svelte-pfehij"&&(P.textContent=V),he=p(t),ne=o(t,"H3",{class:!0});var We=w(ne);re=o(We,"A",{id:!0,class:!0,href:!0});var Ve=w(re);Me=o(Ve,"SPAN",{});var we=w(Me);v(X.$$.fragment,we),we.forEach(e),Ve.forEach(e),Pe=p(We),Z=o(We,"SPAN",{"data-svelte-h":!0}),g(Z)!=="svelte-1kouei"&&(Z.textContent=de),We.forEach(e),me=p(t),x=o(t,"P",{"data-svelte-h":!0}),g(x)!=="svelte-1koz3e5"&&(x.textContent=Ue),ce=p(t),ve=o(t,"P",{"data-svelte-h":!0}),g(ve)!=="svelte-12jkaap"&&(ve.innerHTML=Je),Ne=p(t),v(Ee.$$.fragment,t),q=p(t),K=o(t,"P",{"data-svelte-h":!0}),g(K)!=="svelte-1t3pc5r"&&(K.textContent=_e),tt=p(t),v(D.$$.fragment,t),O=p(t),ee=o(t,"P",{"data-svelte-h":!0}),g(ee)!=="svelte-t3abgj"&&(ee.innerHTML=F),z=p(t),v(Y.$$.fragment,t),oe=p(t),v(be.$$.fragment,t),Xe=p(t),ue=o(t,"P",{"data-svelte-h":!0}),g(ue)!=="svelte-janu8e"&&(ue.textContent=xe),fe=p(t),Ge=o(t,"H3",{class:!0});var Ke=w(Ge);A=o(Ke,"A",{id:!0,class:!0,href:!0});var Qe=w(A);N=o(Qe,"SPAN",{});var Fe=w(N);v(te.$$.fragment,Fe),Fe.forEach(e),Qe.forEach(e),Ce=p(Ke),ze=o(Ke,"SPAN",{"data-svelte-h":!0}),g(ze)!=="svelte-1fpicy2"&&(ze.textContent=ae),Ke.forEach(e),L=p(t),S=o(t,"P",{"data-svelte-h":!0}),g(S)!=="svelte-1ar86wm"&&(S.innerHTML=ye),$e=p(t),G=o(t,"UL",{"data-svelte-h":!0}),g(G)!=="svelte-1srqqo5"&&(G.innerHTML=Le),ge=p(t),U=o(t,"P",{"data-svelte-h":!0}),g(U)!=="svelte-1kwk5xq"&&(U.innerHTML=st),je=p(t),v(I.$$.fragment,t),Be=p(t),Te=o(t,"P",{"data-svelte-h":!0}),g(Te)!=="svelte-1n8nrqv"&&(Te.textContent=Ie),B=p(t),v(H.$$.fragment,t),Se=p(t),W=o(t,"P",{"data-svelte-h":!0}),g(W)!=="svelte-1hn9om"&&(W.innerHTML=He),ie=p(t),Ze=o(t,"P",{"data-svelte-h":!0}),g(Ze)!=="svelte-4nybjx"&&(Ze.innerHTML=at),Q=p(t),v(se.$$.fragment,t),this.h()},h(){f(d,"id","keras"),f(C,"id","train-a-tensorflow-model-with-keras"),f(C,"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"),f(C,"href","#train-a-tensorflow-model-with-keras"),f(_,"class","relative group"),f(re,"id","loading-data-for-keras"),f(re,"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"),f(re,"href","#loading-data-for-keras"),f(ne,"class","relative group"),f(A,"id","loading-data-as-a-tfdatadataset"),f(A,"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"),f(A,"href","#loading-data-as-a-tfdatadataset"),f(Ge,"class","relative group")},m(t,m){s(t,d,m),s(t,k,m),b(h,t,m),s(t,J,m),s(t,_,m),c(_,C),c(C,Ye),b(E,Ye,null),c(_,Ae),c(_,pe),s(t,et,m),s(t,P,m),s(t,he,m),s(t,ne,m),c(ne,re),c(re,Me),b(X,Me,null),c(ne,Pe),c(ne,Z),s(t,me,m),s(t,x,m),s(t,ce,m),s(t,ve,m),s(t,Ne,m),b(Ee,t,m),s(t,q,m),s(t,K,m),s(t,tt,m),b(D,t,m),s(t,O,m),s(t,ee,m),s(t,z,m),b(Y,t,m),s(t,oe,m),b(be,t,m),s(t,Xe,m),s(t,ue,m),s(t,fe,m),s(t,Ge,m),c(Ge,A),c(A,N),b(te,N,null),c(Ge,Ce),c(Ge,ze),s(t,L,m),s(t,S,m),s(t,$e,m),s(t,G,m),s(t,ge,m),s(t,U,m),s(t,je,m),b(I,t,m),s(t,Be,m),s(t,Te,m),s(t,B,m),b(H,t,m),s(t,Se,m),s(t,W,m),s(t,ie,m),s(t,Ze,m),s(t,Q,m),b(se,t,m),n=!0},p(t,m){const le={};m&2&&(le.$$scope={dirty:m,ctx:t}),be.$set(le)},i(t){n||($(h.$$.fragment,t),$(E.$$.fragment,t),$(X.$$.fragment,t),$(Ee.$$.fragment,t),$(D.$$.fragment,t),$(Y.$$.fragment,t),$(be.$$.fragment,t),$(te.$$.fragment,t),$(I.$$.fragment,t),$(H.$$.fragment,t),$(se.$$.fragment,t),n=!0)},o(t){j(h.$$.fragment,t),j(E.$$.fragment,t),j(X.$$.fragment,t),j(Ee.$$.fragment,t),j(D.$$.fragment,t),j(Y.$$.fragment,t),j(be.$$.fragment,t),j(te.$$.fragment,t),j(I.$$.fragment,t),j(H.$$.fragment,t),j(se.$$.fragment,t),n=!1},d(t){t&&(e(d),e(k),e(J),e(_),e(et),e(P),e(he),e(ne),e(me),e(x),e(ce),e(ve),e(Ne),e(q),e(K),e(tt),e(O),e(ee),e(z),e(oe),e(Xe),e(ue),e(fe),e(Ge),e(L),e(S),e($e),e(G),e(ge),e(U),e(je),e(Be),e(Te),e(B),e(Se),e(W),e(ie),e(Ze),e(Q)),T(h,t),T(E),T(X),T(Ee,t),T(D,t),T(Y,t),T(be,t),T(te),T(I,t),T(H,t),T(se,t)}}}function Ot(Re){let d,k;return d=new Gt({props:{$$slots:{default:[Dt]},$$scope:{ctx:Re}}}),{c(){M(d.$$.fragment)},l(h){v(d.$$.fragment,h)},m(h,J){b(d,h,J),k=!0},p(h,J){const _={};J&2&&(_.$$scope={dirty:J,ctx:h}),d.$set(_)},i(h){k||($(d.$$.fragment,h),k=!0)},o(h){j(d.$$.fragment,h),k=!1},d(h){T(d,h)}}}function ea(Re){let d,k='Get free access to a cloud GPU if you don’t have one with a hosted notebook like <a href="https://colab.research.google.com/" rel="nofollow">Colaboratory</a> or <a href="https://studiolab.sagemaker.aws/" rel="nofollow">SageMaker StudioLab</a>.';return{c(){d=r("p"),d.innerHTML=k},l(h){d=o(h,"P",{"data-svelte-h":!0}),g(d)!=="svelte-19nlkqe"&&(d.innerHTML=k)},m(h,J){s(h,d,J)},p:Ut,d(h){h&&e(d)}}}function ta(Re){let d,k,h,J='<a href="/docs/transformers/v4.33.3/en/main_classes/trainer#transformers.Trainer">Trainer</a> takes care of the training loop and allows you to fine-tune a model in a single line of code. For users who prefer to write their own training loop, you can also fine-tune a 🤗 Transformers model in native PyTorch.',_,C,Ye="At this point, you may need to restart your notebook or execute the following code to free some memory:",E,Ae,pe,ke,et="Next, manually postprocess <code>tokenized_dataset</code> to prepare it for training.",P,V,he,ne,re="Remove the <code>text</code> column because the model does not accept raw text as an input:",Me,X,Pe,Z,de,me="Rename the <code>label</code> column to <code>labels</code> because the model expects the argument to be named <code>labels</code>:",x,Ue,ce,ve,Je,Ne="Set the format of the dataset to return PyTorch tensors instead of lists:",Ee,q,K,_e,tt="Then create a smaller subset of the dataset as previously shown to speed up the fine-tuning:",D,O,ee,F,z,Y,oe,be,Xe,ue="DataLoader",xe,fe,Ge="Create a <code>DataLoader</code> for your training and test datasets so you can iterate over batches of data:",A,N,te,Ce,ze="Load your model with the number of expected labels:",ae,L,S,ye,$e,G,Le,ge,U,st="Optimizer and learning rate scheduler",je,I,Be='Create an optimizer and learning rate scheduler to fine-tune the model. Let’s use the <a href="https://pytorch.org/docs/stable/generated/torch.optim.AdamW.html" rel="nofollow"><code>AdamW</code></a> optimizer from PyTorch:',Te,Ie,B,H,Se='Create the default learning rate scheduler from <a href="/docs/transformers/v4.33.3/en/main_classes/trainer#transformers.Trainer">Trainer</a>:',W,He,ie,Ze,at="Lastly, specify <code>device</code> to use a GPU if you have access to one. Otherwise, training on a CPU may take several hours instead of a couple of minutes.",Q,se,n,t,m,le,qe="Great, now you are ready to train! 🥳",We,Ve,we,Ke,Qe,Fe,lt,it="Training loop",nt,pt,Mt='To keep track of your training progress, use the <a href="https://tqdm.github.io/" rel="nofollow">tqdm</a> library to add a progress bar over the number of training steps:',ht,rt,l,u,De,ot,dt,wt,ft,bt="Evaluate",yt,mt,$t='Just like how you added an evaluation function to <a href="/docs/transformers/v4.33.3/en/main_classes/trainer#transformers.Trainer">Trainer</a>, you need to do the same when you write your own training loop. But instead of calculating and reporting the metric at the end of each epoch, this time you’ll accumulate all the batches with <code>add_batch</code> and calculate the metric at the very end.',gt,ct,vt;return d=new Zt({props:{id:"Dh9CL8fyG80"}}),Ae=new R({props:{code:"ZGVsJTIwbW9kZWwlMEFkZWwlMjB0cmFpbmVyJTBBdG9yY2guY3VkYS5lbXB0eV9jYWNoZSgp",highlighted:`<span class="hljs-keyword">del</span> model
<span class="hljs-keyword">del</span> trainer
torch.cuda.empty_cache()`}}),X=new R({props:{code:"dG9rZW5pemVkX2RhdGFzZXRzJTIwJTNEJTIwdG9rZW5pemVkX2RhdGFzZXRzLnJlbW92ZV9jb2x1bW5zKCU1QiUyMnRleHQlMjIlNUQp",highlighted:'<span class="hljs-meta">&gt;&gt;&gt; </span>tokenized_datasets = tokenized_datasets.remove_columns([<span class="hljs-string">&quot;text&quot;</span>])'}}),Ue=new R({props:{code:"dG9rZW5pemVkX2RhdGFzZXRzJTIwJTNEJTIwdG9rZW5pemVkX2RhdGFzZXRzLnJlbmFtZV9jb2x1bW4oJTIybGFiZWwlMjIlMkMlMjAlMjJsYWJlbHMlMjIp",highlighted:'<span class="hljs-meta">&gt;&gt;&gt; </span>tokenized_datasets = tokenized_datasets.rename_column(<span class="hljs-string">&quot;label&quot;</span>, <span class="hljs-string">&quot;labels&quot;</span>)'}}),q=new R({props:{code:"dG9rZW5pemVkX2RhdGFzZXRzLnNldF9mb3JtYXQoJTIydG9yY2glMjIp",highlighted:'<span class="hljs-meta">&gt;&gt;&gt; </span>tokenized_datasets.set_format(<span class="hljs-string">&quot;torch&quot;</span>)'}}),O=new R({props:{code:"c21hbGxfdHJhaW5fZGF0YXNldCUyMCUzRCUyMHRva2VuaXplZF9kYXRhc2V0cyU1QiUyMnRyYWluJTIyJTVELnNodWZmbGUoc2VlZCUzRDQyKS5zZWxlY3QocmFuZ2UoMTAwMCkpJTBBc21hbGxfZXZhbF9kYXRhc2V0JTIwJTNEJTIwdG9rZW5pemVkX2RhdGFzZXRzJTVCJTIydGVzdCUyMiU1RC5zaHVmZmxlKHNlZWQlM0Q0Mikuc2VsZWN0KHJhbmdlKDEwMDApKQ==",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span>small_train_dataset = tokenized_datasets[<span class="hljs-string">&quot;train&quot;</span>].shuffle(seed=<span class="hljs-number">42</span>).select(<span class="hljs-built_in">range</span>(<span class="hljs-number">1000</span>))
<span class="hljs-meta">&gt;&gt;&gt; </span>small_eval_dataset = tokenized_datasets[<span class="hljs-string">&quot;test&quot;</span>].shuffle(seed=<span class="hljs-number">42</span>).select(<span class="hljs-built_in">range</span>(<span class="hljs-number">1000</span>))`}}),oe=new Oe({}),N=new R({props:{code:"ZnJvbSUyMHRvcmNoLnV0aWxzLmRhdGElMjBpbXBvcnQlMjBEYXRhTG9hZGVyJTBBJTBBdHJhaW5fZGF0YWxvYWRlciUyMCUzRCUyMERhdGFMb2FkZXIoc21hbGxfdHJhaW5fZGF0YXNldCUyQyUyMHNodWZmbGUlM0RUcnVlJTJDJTIwYmF0Y2hfc2l6ZSUzRDgpJTBBZXZhbF9kYXRhbG9hZGVyJTIwJTNEJTIwRGF0YUxvYWRlcihzbWFsbF9ldmFsX2RhdGFzZXQlMkMlMjBiYXRjaF9zaXplJTNEOCk=",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> torch.utils.data <span class="hljs-keyword">import</span> DataLoader

<span class="hljs-meta">&gt;&gt;&gt; </span>train_dataloader = DataLoader(small_train_dataset, shuffle=<span class="hljs-literal">True</span>, batch_size=<span class="hljs-number">8</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>eval_dataloader = DataLoader(small_eval_dataset, batch_size=<span class="hljs-number">8</span>)`}}),L=new R({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMEF1dG9Nb2RlbEZvclNlcXVlbmNlQ2xhc3NpZmljYXRpb24lMEElMEFtb2RlbCUyMCUzRCUyMEF1dG9Nb2RlbEZvclNlcXVlbmNlQ2xhc3NpZmljYXRpb24uZnJvbV9wcmV0cmFpbmVkKCUyMmJlcnQtYmFzZS1jYXNlZCUyMiUyQyUyMG51bV9sYWJlbHMlM0Q1KQ==",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoModelForSequenceClassification

<span class="hljs-meta">&gt;&gt;&gt; </span>model = AutoModelForSequenceClassification.from_pretrained(<span class="hljs-string">&quot;bert-base-cased&quot;</span>, num_labels=<span class="hljs-number">5</span>)`}}),Le=new Oe({}),Ie=new R({props:{code:"ZnJvbSUyMHRvcmNoLm9wdGltJTIwaW1wb3J0JTIwQWRhbVclMEElMEFvcHRpbWl6ZXIlMjAlM0QlMjBBZGFtVyhtb2RlbC5wYXJhbWV0ZXJzKCklMkMlMjBsciUzRDVlLTUp",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> torch.optim <span class="hljs-keyword">import</span> AdamW

<span class="hljs-meta">&gt;&gt;&gt; </span>optimizer = AdamW(model.parameters(), lr=<span class="hljs-number">5e-5</span>)`}}),He=new R({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMGdldF9zY2hlZHVsZXIlMEElMEFudW1fZXBvY2hzJTIwJTNEJTIwMyUwQW51bV90cmFpbmluZ19zdGVwcyUyMCUzRCUyMG51bV9lcG9jaHMlMjAqJTIwbGVuKHRyYWluX2RhdGFsb2FkZXIpJTBBbHJfc2NoZWR1bGVyJTIwJTNEJTIwZ2V0X3NjaGVkdWxlciglMEElMjAlMjAlMjAlMjBuYW1lJTNEJTIybGluZWFyJTIyJTJDJTIwb3B0aW1pemVyJTNEb3B0aW1pemVyJTJDJTIwbnVtX3dhcm11cF9zdGVwcyUzRDAlMkMlMjBudW1fdHJhaW5pbmdfc3RlcHMlM0RudW1fdHJhaW5pbmdfc3RlcHMlMEEp",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> get_scheduler

<span class="hljs-meta">&gt;&gt;&gt; </span>num_epochs = <span class="hljs-number">3</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>num_training_steps = num_epochs * <span class="hljs-built_in">len</span>(train_dataloader)
<span class="hljs-meta">&gt;&gt;&gt; </span>lr_scheduler = get_scheduler(
<span class="hljs-meta">... </span>    name=<span class="hljs-string">&quot;linear&quot;</span>, optimizer=optimizer, num_warmup_steps=<span class="hljs-number">0</span>, num_training_steps=num_training_steps
<span class="hljs-meta">... </span>)`}}),se=new R({props:{code:"aW1wb3J0JTIwdG9yY2glMEElMEFkZXZpY2UlMjAlM0QlMjB0b3JjaC5kZXZpY2UoJTIyY3VkYSUyMiklMjBpZiUyMHRvcmNoLmN1ZGEuaXNfYXZhaWxhYmxlKCklMjBlbHNlJTIwdG9yY2guZGV2aWNlKCUyMmNwdSUyMiklMEFtb2RlbC50byhkZXZpY2Up",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">import</span> torch

<span class="hljs-meta">&gt;&gt;&gt; </span>device = torch.device(<span class="hljs-string">&quot;cuda&quot;</span>) <span class="hljs-keyword">if</span> torch.cuda.is_available() <span class="hljs-keyword">else</span> torch.device(<span class="hljs-string">&quot;cpu&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>model.to(device)`}}),t=new xt({props:{$$slots:{default:[ea]},$$scope:{ctx:Re}}}),Qe=new Oe({}),rt=new R({props:{code:"ZnJvbSUyMHRxZG0uYXV0byUyMGltcG9ydCUyMHRxZG0lMEElMEFwcm9ncmVzc19iYXIlMjAlM0QlMjB0cWRtKHJhbmdlKG51bV90cmFpbmluZ19zdGVwcykpJTBBJTBBbW9kZWwudHJhaW4oKSUwQWZvciUyMGVwb2NoJTIwaW4lMjByYW5nZShudW1fZXBvY2hzKSUzQSUwQSUyMCUyMCUyMCUyMGZvciUyMGJhdGNoJTIwaW4lMjB0cmFpbl9kYXRhbG9hZGVyJTNBJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwYmF0Y2glMjAlM0QlMjAlN0JrJTNBJTIwdi50byhkZXZpY2UpJTIwZm9yJTIwayUyQyUyMHYlMjBpbiUyMGJhdGNoLml0ZW1zKCklN0QlMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjBvdXRwdXRzJTIwJTNEJTIwbW9kZWwoKipiYXRjaCklMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjBsb3NzJTIwJTNEJTIwb3V0cHV0cy5sb3NzJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwbG9zcy5iYWNrd2FyZCgpJTBBJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwb3B0aW1pemVyLnN0ZXAoKSUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMGxyX3NjaGVkdWxlci5zdGVwKCklMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjBvcHRpbWl6ZXIuemVyb19ncmFkKCklMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjBwcm9ncmVzc19iYXIudXBkYXRlKDEp",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> tqdm.auto <span class="hljs-keyword">import</span> tqdm

<span class="hljs-meta">&gt;&gt;&gt; </span>progress_bar = tqdm(<span class="hljs-built_in">range</span>(num_training_steps))

<span class="hljs-meta">&gt;&gt;&gt; </span>model.train()
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">for</span> epoch <span class="hljs-keyword">in</span> <span class="hljs-built_in">range</span>(num_epochs):
<span class="hljs-meta">... </span>    <span class="hljs-keyword">for</span> batch <span class="hljs-keyword">in</span> train_dataloader:
<span class="hljs-meta">... </span>        batch = {k: v.to(device) <span class="hljs-keyword">for</span> k, v <span class="hljs-keyword">in</span> batch.items()}
<span class="hljs-meta">... </span>        outputs = model(**batch)
<span class="hljs-meta">... </span>        loss = outputs.loss
<span class="hljs-meta">... </span>        loss.backward()

<span class="hljs-meta">... </span>        optimizer.step()
<span class="hljs-meta">... </span>        lr_scheduler.step()
<span class="hljs-meta">... </span>        optimizer.zero_grad()
<span class="hljs-meta">... </span>        progress_bar.update(<span class="hljs-number">1</span>)`}}),dt=new Oe({}),ct=new R({props:{code:"aW1wb3J0JTIwZXZhbHVhdGUlMEElMEFtZXRyaWMlMjAlM0QlMjBldmFsdWF0ZS5sb2FkKCUyMmFjY3VyYWN5JTIyKSUwQW1vZGVsLmV2YWwoKSUwQWZvciUyMGJhdGNoJTIwaW4lMjBldmFsX2RhdGFsb2FkZXIlM0ElMEElMjAlMjAlMjAlMjBiYXRjaCUyMCUzRCUyMCU3QmslM0ElMjB2LnRvKGRldmljZSklMjBmb3IlMjBrJTJDJTIwdiUyMGluJTIwYmF0Y2guaXRlbXMoKSU3RCUwQSUyMCUyMCUyMCUyMHdpdGglMjB0b3JjaC5ub19ncmFkKCklM0ElMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjBvdXRwdXRzJTIwJTNEJTIwbW9kZWwoKipiYXRjaCklMEElMEElMjAlMjAlMjAlMjBsb2dpdHMlMjAlM0QlMjBvdXRwdXRzLmxvZ2l0cyUwQSUyMCUyMCUyMCUyMHByZWRpY3Rpb25zJTIwJTNEJTIwdG9yY2guYXJnbWF4KGxvZ2l0cyUyQyUyMGRpbSUzRC0xKSUwQSUyMCUyMCUyMCUyMG1ldHJpYy5hZGRfYmF0Y2gocHJlZGljdGlvbnMlM0RwcmVkaWN0aW9ucyUyQyUyMHJlZmVyZW5jZXMlM0RiYXRjaCU1QiUyMmxhYmVscyUyMiU1RCklMEElMEFtZXRyaWMuY29tcHV0ZSgp",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">import</span> evaluate

<span class="hljs-meta">&gt;&gt;&gt; </span>metric = evaluate.load(<span class="hljs-string">&quot;accuracy&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>model.<span class="hljs-built_in">eval</span>()
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">for</span> batch <span class="hljs-keyword">in</span> eval_dataloader:
<span class="hljs-meta">... </span>    batch = {k: v.to(device) <span class="hljs-keyword">for</span> k, v <span class="hljs-keyword">in</span> batch.items()}
<span class="hljs-meta">... </span>    <span class="hljs-keyword">with</span> torch.no_grad():
<span class="hljs-meta">... </span>        outputs = model(**batch)

<span class="hljs-meta">... </span>    logits = outputs.logits
<span class="hljs-meta">... </span>    predictions = torch.argmax(logits, dim=-<span class="hljs-number">1</span>)
<span class="hljs-meta">... </span>    metric.add_batch(predictions=predictions, references=batch[<span class="hljs-string">&quot;labels&quot;</span>])

<span class="hljs-meta">&gt;&gt;&gt; </span>metric.compute()`}}),{c(){M(d.$$.fragment),k=i(),h=r("p"),h.innerHTML=J,_=i(),C=r("p"),C.textContent=Ye,E=i(),M(Ae.$$.fragment),pe=i(),ke=r("p"),ke.innerHTML=et,P=i(),V=r("ol"),he=r("li"),ne=r("p"),ne.innerHTML=re,Me=i(),M(X.$$.fragment),Pe=i(),Z=r("li"),de=r("p"),de.innerHTML=me,x=i(),M(Ue.$$.fragment),ce=i(),ve=r("li"),Je=r("p"),Je.textContent=Ne,Ee=i(),M(q.$$.fragment),K=i(),_e=r("p"),_e.textContent=tt,D=i(),M(O.$$.fragment),ee=i(),F=r("h3"),z=r("a"),Y=r("span"),M(oe.$$.fragment),be=i(),Xe=r("span"),Xe.textContent=ue,xe=i(),fe=r("p"),fe.innerHTML=Ge,A=i(),M(N.$$.fragment),te=i(),Ce=r("p"),Ce.textContent=ze,ae=i(),M(L.$$.fragment),S=i(),ye=r("h3"),$e=r("a"),G=r("span"),M(Le.$$.fragment),ge=i(),U=r("span"),U.textContent=st,je=i(),I=r("p"),I.innerHTML=Be,Te=i(),M(Ie.$$.fragment),B=i(),H=r("p"),H.innerHTML=Se,W=i(),M(He.$$.fragment),ie=i(),Ze=r("p"),Ze.innerHTML=at,Q=i(),M(se.$$.fragment),n=i(),M(t.$$.fragment),m=i(),le=r("p"),le.textContent=qe,We=i(),Ve=r("h3"),we=r("a"),Ke=r("span"),M(Qe.$$.fragment),Fe=i(),lt=r("span"),lt.textContent=it,nt=i(),pt=r("p"),pt.innerHTML=Mt,ht=i(),M(rt.$$.fragment),l=i(),u=r("h3"),De=r("a"),ot=r("span"),M(dt.$$.fragment),wt=i(),ft=r("span"),ft.textContent=bt,yt=i(),mt=r("p"),mt.innerHTML=$t,gt=i(),M(ct.$$.fragment),this.h()},l(a){v(d.$$.fragment,a),k=p(a),h=o(a,"P",{"data-svelte-h":!0}),g(h)!=="svelte-7ubk1d"&&(h.innerHTML=J),_=p(a),C=o(a,"P",{"data-svelte-h":!0}),g(C)!=="svelte-1fj5odk"&&(C.textContent=Ye),E=p(a),v(Ae.$$.fragment,a),pe=p(a),ke=o(a,"P",{"data-svelte-h":!0}),g(ke)!=="svelte-x8g0ya"&&(ke.innerHTML=et),P=p(a),V=o(a,"OL",{});var y=w(V);he=o(y,"LI",{});var ut=w(he);ne=o(ut,"P",{"data-svelte-h":!0}),g(ne)!=="svelte-1rn013d"&&(ne.innerHTML=re),Me=p(ut),v(X.$$.fragment,ut),ut.forEach(e),Pe=p(y),Z=o(y,"LI",{});var jt=w(Z);de=o(jt,"P",{"data-svelte-h":!0}),g(de)!=="svelte-14b1mbw"&&(de.innerHTML=me),x=p(jt),v(Ue.$$.fragment,jt),jt.forEach(e),ce=p(y),ve=o(y,"LI",{});var Tt=w(ve);Je=o(Tt,"P",{"data-svelte-h":!0}),g(Je)!=="svelte-1pkf4ls"&&(Je.textContent=Ne),Ee=p(Tt),v(q.$$.fragment,Tt),Tt.forEach(e),y.forEach(e),K=p(a),_e=o(a,"P",{"data-svelte-h":!0}),g(_e)!=="svelte-suyard"&&(_e.textContent=tt),D=p(a),v(O.$$.fragment,a),ee=p(a),F=o(a,"H3",{class:!0});var kt=w(F);z=o(kt,"A",{id:!0,class:!0,href:!0});var It=w(z);Y=o(It,"SPAN",{});var Wt=w(Y);v(oe.$$.fragment,Wt),Wt.forEach(e),It.forEach(e),be=p(kt),Xe=o(kt,"SPAN",{"data-svelte-h":!0}),g(Xe)!=="svelte-19b0x1w"&&(Xe.textContent=ue),kt.forEach(e),xe=p(a),fe=o(a,"P",{"data-svelte-h":!0}),g(fe)!=="svelte-ukozu9"&&(fe.innerHTML=Ge),A=p(a),v(N.$$.fragment,a),te=p(a),Ce=o(a,"P",{"data-svelte-h":!0}),g(Ce)!=="svelte-i6qo3i"&&(Ce.textContent=ze),ae=p(a),v(L.$$.fragment,a),S=p(a),ye=o(a,"H3",{class:!0});var Jt=w(ye);$e=o(Jt,"A",{id:!0,class:!0,href:!0});var Rt=w($e);G=o(Rt,"SPAN",{});var Et=w(G);v(Le.$$.fragment,Et),Et.forEach(e),Rt.forEach(e),ge=p(Jt),U=o(Jt,"SPAN",{"data-svelte-h":!0}),g(U)!=="svelte-14sd3us"&&(U.textContent=st),Jt.forEach(e),je=p(a),I=o(a,"P",{"data-svelte-h":!0}),g(I)!=="svelte-co458k"&&(I.innerHTML=Be),Te=p(a),v(Ie.$$.fragment,a),B=p(a),H=o(a,"P",{"data-svelte-h":!0}),g(H)!=="svelte-1e6d8x"&&(H.innerHTML=Se),W=p(a),v(He.$$.fragment,a),ie=p(a),Ze=o(a,"P",{"data-svelte-h":!0}),g(Ze)!=="svelte-3xf3g0"&&(Ze.innerHTML=at),Q=p(a),v(se.$$.fragment,a),n=p(a),v(t.$$.fragment,a),m=p(a),le=o(a,"P",{"data-svelte-h":!0}),g(le)!=="svelte-a8vh6y"&&(le.textContent=qe),We=p(a),Ve=o(a,"H3",{class:!0});var _t=w(Ve);we=o(_t,"A",{id:!0,class:!0,href:!0});var Xt=w(we);Ke=o(Xt,"SPAN",{});var zt=w(Ke);v(Qe.$$.fragment,zt),zt.forEach(e),Xt.forEach(e),Fe=p(_t),lt=o(_t,"SPAN",{"data-svelte-h":!0}),g(lt)!=="svelte-1pquwg7"&&(lt.textContent=it),_t.forEach(e),nt=p(a),pt=o(a,"P",{"data-svelte-h":!0}),g(pt)!=="svelte-s0vw3u"&&(pt.innerHTML=Mt),ht=p(a),v(rt.$$.fragment,a),l=p(a),u=o(a,"H3",{class:!0});var Ct=w(u);De=o(Ct,"A",{id:!0,class:!0,href:!0});var Bt=w(De);ot=o(Bt,"SPAN",{});var Ht=w(ot);v(dt.$$.fragment,Ht),Ht.forEach(e),Bt.forEach(e),wt=p(Ct),ft=o(Ct,"SPAN",{"data-svelte-h":!0}),g(ft)!=="svelte-sh8s6s"&&(ft.textContent=bt),Ct.forEach(e),yt=p(a),mt=o(a,"P",{"data-svelte-h":!0}),g(mt)!=="svelte-593vz1"&&(mt.innerHTML=$t),gt=p(a),v(ct.$$.fragment,a),this.h()},h(){f(z,"id","dataloader"),f(z,"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"),f(z,"href","#dataloader"),f(F,"class","relative group"),f($e,"id","optimizer-and-learning-rate-scheduler"),f($e,"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"),f($e,"href","#optimizer-and-learning-rate-scheduler"),f(ye,"class","relative group"),f(we,"id","training-loop"),f(we,"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"),f(we,"href","#training-loop"),f(Ve,"class","relative group"),f(De,"id","evaluate"),f(De,"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"),f(De,"href","#evaluate"),f(u,"class","relative group")},m(a,y){b(d,a,y),s(a,k,y),s(a,h,y),s(a,_,y),s(a,C,y),s(a,E,y),b(Ae,a,y),s(a,pe,y),s(a,ke,y),s(a,P,y),s(a,V,y),c(V,he),c(he,ne),c(he,Me),b(X,he,null),c(V,Pe),c(V,Z),c(Z,de),c(Z,x),b(Ue,Z,null),c(V,ce),c(V,ve),c(ve,Je),c(ve,Ee),b(q,ve,null),s(a,K,y),s(a,_e,y),s(a,D,y),b(O,a,y),s(a,ee,y),s(a,F,y),c(F,z),c(z,Y),b(oe,Y,null),c(F,be),c(F,Xe),s(a,xe,y),s(a,fe,y),s(a,A,y),b(N,a,y),s(a,te,y),s(a,Ce,y),s(a,ae,y),b(L,a,y),s(a,S,y),s(a,ye,y),c(ye,$e),c($e,G),b(Le,G,null),c(ye,ge),c(ye,U),s(a,je,y),s(a,I,y),s(a,Te,y),b(Ie,a,y),s(a,B,y),s(a,H,y),s(a,W,y),b(He,a,y),s(a,ie,y),s(a,Ze,y),s(a,Q,y),b(se,a,y),s(a,n,y),b(t,a,y),s(a,m,y),s(a,le,y),s(a,We,y),s(a,Ve,y),c(Ve,we),c(we,Ke),b(Qe,Ke,null),c(Ve,Fe),c(Ve,lt),s(a,nt,y),s(a,pt,y),s(a,ht,y),b(rt,a,y),s(a,l,y),s(a,u,y),c(u,De),c(De,ot),b(dt,ot,null),c(u,wt),c(u,ft),s(a,yt,y),s(a,mt,y),s(a,gt,y),b(ct,a,y),vt=!0},p(a,y){const ut={};y&2&&(ut.$$scope={dirty:y,ctx:a}),t.$set(ut)},i(a){vt||($(d.$$.fragment,a),$(Ae.$$.fragment,a),$(X.$$.fragment,a),$(Ue.$$.fragment,a),$(q.$$.fragment,a),$(O.$$.fragment,a),$(oe.$$.fragment,a),$(N.$$.fragment,a),$(L.$$.fragment,a),$(Le.$$.fragment,a),$(Ie.$$.fragment,a),$(He.$$.fragment,a),$(se.$$.fragment,a),$(t.$$.fragment,a),$(Qe.$$.fragment,a),$(rt.$$.fragment,a),$(dt.$$.fragment,a),$(ct.$$.fragment,a),vt=!0)},o(a){j(d.$$.fragment,a),j(Ae.$$.fragment,a),j(X.$$.fragment,a),j(Ue.$$.fragment,a),j(q.$$.fragment,a),j(O.$$.fragment,a),j(oe.$$.fragment,a),j(N.$$.fragment,a),j(L.$$.fragment,a),j(Le.$$.fragment,a),j(Ie.$$.fragment,a),j(He.$$.fragment,a),j(se.$$.fragment,a),j(t.$$.fragment,a),j(Qe.$$.fragment,a),j(rt.$$.fragment,a),j(dt.$$.fragment,a),j(ct.$$.fragment,a),vt=!1},d(a){a&&(e(k),e(h),e(_),e(C),e(E),e(pe),e(ke),e(P),e(V),e(K),e(_e),e(D),e(ee),e(F),e(xe),e(fe),e(A),e(te),e(Ce),e(ae),e(S),e(ye),e(je),e(I),e(Te),e(B),e(H),e(W),e(ie),e(Ze),e(Q),e(n),e(m),e(le),e(We),e(Ve),e(nt),e(pt),e(ht),e(l),e(u),e(yt),e(mt),e(gt)),T(d,a),T(Ae,a),T(X),T(Ue),T(q),T(O,a),T(oe),T(N,a),T(L,a),T(Le),T(Ie,a),T(He,a),T(se,a),T(t,a),T(Qe),T(rt,a),T(dt),T(ct,a)}}}function aa(Re){let d,k;return d=new Gt({props:{$$slots:{default:[ta]},$$scope:{ctx:Re}}}),{c(){M(d.$$.fragment)},l(h){v(d.$$.fragment,h)},m(h,J){b(d,h,J),k=!0},p(h,J){const _={};J&2&&(_.$$scope={dirty:J,ctx:h}),d.$set(_)},i(h){k||($(d.$$.fragment,h),k=!0)},o(h){j(d.$$.fragment,h),k=!1},d(h){T(d,h)}}}function sa(Re){let d,k,h,J,_,C,Ye,E,Ae,pe,ke="Fine-tune a pretrained model",et,P,V,he,ne="There are significant benefits to using a pretrained model. It reduces computation costs, your carbon footprint, and allows you to use state-of-the-art models without having to train one from scratch. 🤗 Transformers provides access to thousands of pretrained models for a wide range of tasks. When you use a pretrained model, you train it on a dataset specific to your task. This is known as fine-tuning, an incredibly powerful training technique. In this tutorial, you will fine-tune a pretrained model with a deep learning framework of your choice:",re,Me,X='<li>Fine-tune a pretrained model with 🤗 Transformers <a href="/docs/transformers/v4.33.3/en/main_classes/trainer#transformers.Trainer">Trainer</a>.</li> <li>Fine-tune a pretrained model in TensorFlow with Keras.</li> <li>Fine-tune a pretrained model in native PyTorch.</li>',Pe,Z,de,me,x,Ue,ce,ve,Je,Ne="Prepare a dataset",Ee,q,K,_e,tt="Before you can fine-tune a pretrained model, download a dataset and prepare it for training. The previous tutorial showed you how to process data for training, and now you get an opportunity to put those skills to the test!",D,O,ee='Begin by loading the <a href="https://huggingface.co/datasets/yelp_review_full" rel="nofollow">Yelp Reviews</a> dataset:',F,z,Y,oe,be='As you now know, you need a tokenizer to process the text and include a padding and truncation strategy to handle any variable sequence lengths. To process your dataset in one step, use 🤗 Datasets <a href="https://huggingface.co/docs/datasets/process.html#map" rel="nofollow"><code>map</code></a> method to apply a preprocessing function over the entire dataset:',Xe,ue,xe,fe,Ge="If you like, you can create a smaller subset of the full dataset to fine-tune on to reduce the time it takes:",A,N,te,Ce,ze,ae,L,S,ye,$e,G,Le="Train",ge,U,st=`At this point, you should follow the section corresponding to the framework you want to use. You can use the links
in the right sidebar to jump to the one you want - and if you want to hide all of the content for a given framework,
just use the button at the top-right of that framework’s block!`,je,I,Be,Te,Ie,B,H,Se,W,He,ie,Ze="Train in native PyTorch",at,Q,se,n,t,m,le,qe,We,Ve,we,Ke="Additional resources",Qe,Fe,lt="For more fine-tuning examples, refer to:",it,nt,pt=`<li><p><a href="https://github.com/huggingface/transformers/tree/main/examples" rel="nofollow">🤗 Transformers Examples</a> includes scripts
to train common NLP tasks in PyTorch and TensorFlow.</p></li> <li><p><a href="notebooks">🤗 Transformers Notebooks</a> contains various notebooks on how to fine-tune a model for specific tasks in PyTorch and TensorFlow.</p></li>`,Mt,ht,rt;return E=new Oe({}),P=new St({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/training.ipynb"},{label:"PyTorch",value:"https://colab.research.google.com/github/huggingface/notebooks/blob/main/transformers_doc/en/pytorch/training.ipynb"},{label:"TensorFlow",value:"https://colab.research.google.com/github/huggingface/notebooks/blob/main/transformers_doc/en/tensorflow/training.ipynb"},{label:"Mixed",value:"https://studiolab.sagemaker.aws/import/github/huggingface/notebooks/blob/main/transformers_doc/en/training.ipynb"},{label:"PyTorch",value:"https://studiolab.sagemaker.aws/import/github/huggingface/notebooks/blob/main/transformers_doc/en/pytorch/training.ipynb"},{label:"TensorFlow",value:"https://studiolab.sagemaker.aws/import/github/huggingface/notebooks/blob/main/transformers_doc/en/tensorflow/training.ipynb"}]}}),ce=new Oe({}),q=new Zt({props:{id:"_BZearw7f0w"}}),z=new R({props:{code:"ZnJvbSUyMGRhdGFzZXRzJTIwaW1wb3J0JTIwbG9hZF9kYXRhc2V0JTBBJTBBZGF0YXNldCUyMCUzRCUyMGxvYWRfZGF0YXNldCglMjJ5ZWxwX3Jldmlld19mdWxsJTIyKSUwQWRhdGFzZXQlNUIlMjJ0cmFpbiUyMiU1RCU1QjEwMCU1RA==",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>dataset = load_dataset(<span class="hljs-string">&quot;yelp_review_full&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>dataset[<span class="hljs-string">&quot;train&quot;</span>][<span class="hljs-number">100</span>]
{<span class="hljs-string">&#x27;label&#x27;</span>: <span class="hljs-number">0</span>,
 <span class="hljs-string">&#x27;text&#x27;</span>: <span class="hljs-string">&#x27;My expectations for McDonalds are t rarely high. But for one to still fail so spectacularly...that takes something special!\\\\nThe cashier took my friends\\&#x27;s order, then promptly ignored me. I had to force myself in front of a cashier who opened his register to wait on the person BEHIND me. I waited over five minutes for a gigantic order that included precisely one kid\\&#x27;s meal. After watching two people who ordered after me be handed their food, I asked where mine was. The manager started yelling at the cashiers for \\\\&quot;serving off their orders\\\\&quot; when they didn\\&#x27;t have their food. But neither cashier was anywhere near those controls, and the manager was the one serving food to customers and clearing the boards.\\\\nThe manager was rude when giving me my order. She didn\\&#x27;t make sure that I had everything ON MY RECEIPT, and never even had the decency to apologize that I felt I was getting poor service.\\\\nI\\&#x27;ve eaten at various McDonalds restaurants for over 30 years. I\\&#x27;ve worked at more than one location. I expect bad days, bad moods, and the occasional mistake. But I have yet to have a decent experience at this store. It will remain a place I avoid unless someone in my party needs to avoid illness from low blood sugar. Perhaps I should go back to the racially biased service of Steak n Shake instead!&#x27;</span>}`}}),ue=new R({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMEF1dG9Ub2tlbml6ZXIlMEElMEF0b2tlbml6ZXIlMjAlM0QlMjBBdXRvVG9rZW5pemVyLmZyb21fcHJldHJhaW5lZCglMjJiZXJ0LWJhc2UtY2FzZWQlMjIpJTBBJTBBJTBBZGVmJTIwdG9rZW5pemVfZnVuY3Rpb24oZXhhbXBsZXMpJTNBJTBBJTIwJTIwJTIwJTIwcmV0dXJuJTIwdG9rZW5pemVyKGV4YW1wbGVzJTVCJTIydGV4dCUyMiU1RCUyQyUyMHBhZGRpbmclM0QlMjJtYXhfbGVuZ3RoJTIyJTJDJTIwdHJ1bmNhdGlvbiUzRFRydWUpJTBBJTBBJTBBdG9rZW5pemVkX2RhdGFzZXRzJTIwJTNEJTIwZGF0YXNldC5tYXAodG9rZW5pemVfZnVuY3Rpb24lMkMlMjBiYXRjaGVkJTNEVHJ1ZSk=",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;bert-base-cased&quot;</span>)


<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">def</span> <span class="hljs-title function_">tokenize_function</span>(<span class="hljs-params">examples</span>):
<span class="hljs-meta">... </span>    <span class="hljs-keyword">return</span> tokenizer(examples[<span class="hljs-string">&quot;text&quot;</span>], padding=<span class="hljs-string">&quot;max_length&quot;</span>, truncation=<span class="hljs-literal">True</span>)


<span class="hljs-meta">&gt;&gt;&gt; </span>tokenized_datasets = dataset.<span class="hljs-built_in">map</span>(tokenize_function, batched=<span class="hljs-literal">True</span>)`}}),N=new R({props:{code:"c21hbGxfdHJhaW5fZGF0YXNldCUyMCUzRCUyMHRva2VuaXplZF9kYXRhc2V0cyU1QiUyMnRyYWluJTIyJTVELnNodWZmbGUoc2VlZCUzRDQyKS5zZWxlY3QocmFuZ2UoMTAwMCkpJTBBc21hbGxfZXZhbF9kYXRhc2V0JTIwJTNEJTIwdG9rZW5pemVkX2RhdGFzZXRzJTVCJTIydGVzdCUyMiU1RC5zaHVmZmxlKHNlZWQlM0Q0Mikuc2VsZWN0KHJhbmdlKDEwMDApKQ==",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span>small_train_dataset = tokenized_datasets[<span class="hljs-string">&quot;train&quot;</span>].shuffle(seed=<span class="hljs-number">42</span>).select(<span class="hljs-built_in">range</span>(<span class="hljs-number">1000</span>))
<span class="hljs-meta">&gt;&gt;&gt; </span>small_eval_dataset = tokenized_datasets[<span class="hljs-string">&quot;test&quot;</span>].shuffle(seed=<span class="hljs-number">42</span>).select(<span class="hljs-built_in">range</span>(<span class="hljs-number">1000</span>))`}}),ye=new Oe({}),I=new Vt({props:{pytorch:!0,tensorflow:!0,jax:!1,$$slots:{tensorflow:[Ot],pytorch:[qt]},$$scope:{ctx:Re}}}),W=new Oe({}),Q=new Vt({props:{pytorch:!0,tensorflow:!1,jax:!1,$$slots:{pytorch:[aa]},$$scope:{ctx:Re}}}),We=new Oe({}),{c(){d=r("meta"),k=i(),h=r("p"),J=i(),_=r("h1"),C=r("a"),Ye=r("span"),M(E.$$.fragment),Ae=i(),pe=r("span"),pe.textContent=ke,et=i(),M(P.$$.fragment),V=i(),he=r("p"),he.textContent=ne,re=i(),Me=r("ul"),Me.innerHTML=X,Pe=i(),Z=r("a"),de=i(),me=r("h2"),x=r("a"),Ue=r("span"),M(ce.$$.fragment),ve=i(),Je=r("span"),Je.textContent=Ne,Ee=i(),M(q.$$.fragment),K=i(),_e=r("p"),_e.textContent=tt,D=i(),O=r("p"),O.innerHTML=ee,F=i(),M(z.$$.fragment),Y=i(),oe=r("p"),oe.innerHTML=be,Xe=i(),M(ue.$$.fragment),xe=i(),fe=r("p"),fe.textContent=Ge,A=i(),M(N.$$.fragment),te=i(),Ce=r("a"),ze=i(),ae=r("h2"),L=r("a"),S=r("span"),M(ye.$$.fragment),$e=i(),G=r("span"),G.textContent=Le,ge=i(),U=r("p"),U.textContent=st,je=i(),M(I.$$.fragment),Be=i(),Te=r("a"),Ie=i(),B=r("h2"),H=r("a"),Se=r("span"),M(W.$$.fragment),He=i(),ie=r("span"),ie.textContent=Ze,at=i(),M(Q.$$.fragment),se=i(),n=r("a"),t=i(),m=r("h2"),le=r("a"),qe=r("span"),M(We.$$.fragment),Ve=i(),we=r("span"),we.textContent=Ke,Qe=i(),Fe=r("p"),Fe.textContent=lt,it=i(),nt=r("ul"),nt.innerHTML=pt,Mt=i(),ht=r("p"),this.h()},l(l){const u=Lt("svelte-1phssyn",document.head);d=o(u,"META",{name:!0,content:!0}),u.forEach(e),k=p(l),h=o(l,"P",{}),w(h).forEach(e),J=p(l),_=o(l,"H1",{class:!0});var De=w(_);C=o(De,"A",{id:!0,class:!0,href:!0});var ot=w(C);Ye=o(ot,"SPAN",{});var dt=w(Ye);v(E.$$.fragment,dt),dt.forEach(e),ot.forEach(e),Ae=p(De),pe=o(De,"SPAN",{"data-svelte-h":!0}),g(pe)!=="svelte-thoylo"&&(pe.textContent=ke),De.forEach(e),et=p(l),v(P.$$.fragment,l),V=p(l),he=o(l,"P",{"data-svelte-h":!0}),g(he)!=="svelte-12akn4f"&&(he.textContent=ne),re=p(l),Me=o(l,"UL",{"data-svelte-h":!0}),g(Me)!=="svelte-70j8v0"&&(Me.innerHTML=X),Pe=p(l),Z=o(l,"A",{id:!0}),w(Z).forEach(e),de=p(l),me=o(l,"H2",{class:!0});var wt=w(me);x=o(wt,"A",{id:!0,class:!0,href:!0});var ft=w(x);Ue=o(ft,"SPAN",{});var bt=w(Ue);v(ce.$$.fragment,bt),bt.forEach(e),ft.forEach(e),ve=p(wt),Je=o(wt,"SPAN",{"data-svelte-h":!0}),g(Je)!=="svelte-xm910n"&&(Je.textContent=Ne),wt.forEach(e),Ee=p(l),v(q.$$.fragment,l),K=p(l),_e=o(l,"P",{"data-svelte-h":!0}),g(_e)!=="svelte-1tgiufu"&&(_e.textContent=tt),D=p(l),O=o(l,"P",{"data-svelte-h":!0}),g(O)!=="svelte-1vrtere"&&(O.innerHTML=ee),F=p(l),v(z.$$.fragment,l),Y=p(l),oe=o(l,"P",{"data-svelte-h":!0}),g(oe)!=="svelte-wyr1dl"&&(oe.innerHTML=be),Xe=p(l),v(ue.$$.fragment,l),xe=p(l),fe=o(l,"P",{"data-svelte-h":!0}),g(fe)!=="svelte-1wp411h"&&(fe.textContent=Ge),A=p(l),v(N.$$.fragment,l),te=p(l),Ce=o(l,"A",{id:!0}),w(Ce).forEach(e),ze=p(l),ae=o(l,"H2",{class:!0});var yt=w(ae);L=o(yt,"A",{id:!0,class:!0,href:!0});var mt=w(L);S=o(mt,"SPAN",{});var $t=w(S);v(ye.$$.fragment,$t),$t.forEach(e),mt.forEach(e),$e=p(yt),G=o(yt,"SPAN",{"data-svelte-h":!0}),g(G)!=="svelte-5arm0l"&&(G.textContent=Le),yt.forEach(e),ge=p(l),U=o(l,"P",{"data-svelte-h":!0}),g(U)!=="svelte-4poo92"&&(U.textContent=st),je=p(l),v(I.$$.fragment,l),Be=p(l),Te=o(l,"A",{id:!0}),w(Te).forEach(e),Ie=p(l),B=o(l,"H2",{class:!0});var gt=w(B);H=o(gt,"A",{id:!0,class:!0,href:!0});var ct=w(H);Se=o(ct,"SPAN",{});var vt=w(Se);v(W.$$.fragment,vt),vt.forEach(e),ct.forEach(e),He=p(gt),ie=o(gt,"SPAN",{"data-svelte-h":!0}),g(ie)!=="svelte-1vzzi84"&&(ie.textContent=Ze),gt.forEach(e),at=p(l),v(Q.$$.fragment,l),se=p(l),n=o(l,"A",{id:!0}),w(n).forEach(e),t=p(l),m=o(l,"H2",{class:!0});var a=w(m);le=o(a,"A",{id:!0,class:!0,href:!0});var y=w(le);qe=o(y,"SPAN",{});var ut=w(qe);v(We.$$.fragment,ut),ut.forEach(e),y.forEach(e),Ve=p(a),we=o(a,"SPAN",{"data-svelte-h":!0}),g(we)!=="svelte-4447zp"&&(we.textContent=Ke),a.forEach(e),Qe=p(l),Fe=o(l,"P",{"data-svelte-h":!0}),g(Fe)!=="svelte-1keox1g"&&(Fe.textContent=lt),it=p(l),nt=o(l,"UL",{"data-svelte-h":!0}),g(nt)!=="svelte-4e1ihs"&&(nt.innerHTML=pt),Mt=p(l),ht=o(l,"P",{}),w(ht).forEach(e),this.h()},h(){f(d,"name","hf:doc:metadata"),f(d,"content",JSON.stringify(la)),f(C,"id","finetune-a-pretrained-model"),f(C,"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"),f(C,"href","#finetune-a-pretrained-model"),f(_,"class","relative group"),f(Z,"id","data-processing"),f(x,"id","prepare-a-dataset"),f(x,"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"),f(x,"href","#prepare-a-dataset"),f(me,"class","relative group"),f(Ce,"id","trainer"),f(L,"id","train"),f(L,"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"),f(L,"href","#train"),f(ae,"class","relative group"),f(Te,"id","pytorch_native"),f(H,"id","train-in-native-pytorch"),f(H,"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"),f(H,"href","#train-in-native-pytorch"),f(B,"class","relative group"),f(n,"id","additional-resources"),f(le,"id","additional-resources"),f(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"),f(le,"href","#additional-resources"),f(m,"class","relative group")},m(l,u){c(document.head,d),s(l,k,u),s(l,h,u),s(l,J,u),s(l,_,u),c(_,C),c(C,Ye),b(E,Ye,null),c(_,Ae),c(_,pe),s(l,et,u),b(P,l,u),s(l,V,u),s(l,he,u),s(l,re,u),s(l,Me,u),s(l,Pe,u),s(l,Z,u),s(l,de,u),s(l,me,u),c(me,x),c(x,Ue),b(ce,Ue,null),c(me,ve),c(me,Je),s(l,Ee,u),b(q,l,u),s(l,K,u),s(l,_e,u),s(l,D,u),s(l,O,u),s(l,F,u),b(z,l,u),s(l,Y,u),s(l,oe,u),s(l,Xe,u),b(ue,l,u),s(l,xe,u),s(l,fe,u),s(l,A,u),b(N,l,u),s(l,te,u),s(l,Ce,u),s(l,ze,u),s(l,ae,u),c(ae,L),c(L,S),b(ye,S,null),c(ae,$e),c(ae,G),s(l,ge,u),s(l,U,u),s(l,je,u),b(I,l,u),s(l,Be,u),s(l,Te,u),s(l,Ie,u),s(l,B,u),c(B,H),c(H,Se),b(W,Se,null),c(B,He),c(B,ie),s(l,at,u),b(Q,l,u),s(l,se,u),s(l,n,u),s(l,t,u),s(l,m,u),c(m,le),c(le,qe),b(We,qe,null),c(m,Ve),c(m,we),s(l,Qe,u),s(l,Fe,u),s(l,it,u),s(l,nt,u),s(l,Mt,u),s(l,ht,u),rt=!0},p(l,[u]){const De={};u&2&&(De.$$scope={dirty:u,ctx:l}),I.$set(De);const ot={};u&2&&(ot.$$scope={dirty:u,ctx:l}),Q.$set(ot)},i(l){rt||($(E.$$.fragment,l),$(P.$$.fragment,l),$(ce.$$.fragment,l),$(q.$$.fragment,l),$(z.$$.fragment,l),$(ue.$$.fragment,l),$(N.$$.fragment,l),$(ye.$$.fragment,l),$(I.$$.fragment,l),$(W.$$.fragment,l),$(Q.$$.fragment,l),$(We.$$.fragment,l),rt=!0)},o(l){j(E.$$.fragment,l),j(P.$$.fragment,l),j(ce.$$.fragment,l),j(q.$$.fragment,l),j(z.$$.fragment,l),j(ue.$$.fragment,l),j(N.$$.fragment,l),j(ye.$$.fragment,l),j(I.$$.fragment,l),j(W.$$.fragment,l),j(Q.$$.fragment,l),j(We.$$.fragment,l),rt=!1},d(l){l&&(e(k),e(h),e(J),e(_),e(et),e(V),e(he),e(re),e(Me),e(Pe),e(Z),e(de),e(me),e(Ee),e(K),e(_e),e(D),e(O),e(F),e(Y),e(oe),e(Xe),e(xe),e(fe),e(A),e(te),e(Ce),e(ze),e(ae),e(ge),e(U),e(je),e(Be),e(Te),e(Ie),e(B),e(at),e(se),e(n),e(t),e(m),e(Qe),e(Fe),e(it),e(nt),e(Mt),e(ht)),e(d),T(E),T(P,l),T(ce),T(q,l),T(z,l),T(ue,l),T(N,l),T(ye),T(I,l),T(W),T(Q,l),T(We)}}}const la={local:"finetune-a-pretrained-model",sections:[{local:"prepare-a-dataset",title:"Prepare a dataset"},{local:"train",title:"Train"},{local:"train-with-pytorch-trainer",sections:[{local:"training-hyperparameters",title:"Training hyperparameters"},{local:"evaluate",title:"Evaluate"},{local:"trainer",title:"Trainer"}],title:"Train with PyTorch Trainer"},{local:"train-a-tensorflow-model-with-keras",sections:[{local:"loading-data-for-keras",title:"Loading data for Keras"},{local:"loading-data-as-a-tfdatadataset",title:"Loading data as a tf.data.Dataset"}],title:"Train a TensorFlow model with Keras"},{local:"train-in-native-pytorch",sections:[{local:"dataloader",title:"DataLoader"},{local:"optimizer-and-learning-rate-scheduler",title:"Optimizer and learning rate scheduler"},{local:"training-loop",title:"Training loop"},{local:"evaluate",title:"Evaluate"}],title:"Train in native PyTorch"},{local:"additional-resources",title:"Additional resources"}],title:"Fine-tune a pretrained model"};function na(Re){return Yt(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class ua extends At{constructor(d){super(),Nt(this,d,na,sa,Ft,{})}}export{ua as component};
