import{s as Ft,o as Bt,n as re}from"../chunks/scheduler.25b97de1.js";import{S as Et,i as Qt,g as M,s as o,r as u,A as qt,h as w,f as a,c as p,j as Nt,u as h,x as T,k as zt,y as St,a as l,v as d,d as y,t as g,w as b,m as Lt,n as At}from"../chunks/index.d9030fc9.js";import{T as Ee}from"../chunks/Tip.baa67368.js";import{Y as Pt}from"../chunks/Youtube.eaf1a617.js";import{C}from"../chunks/CodeBlock.e6cd0d95.js";import{D as Dt}from"../chunks/DocNotebookDropdown.5ea6cb78.js";import{F as jt,M as ze}from"../chunks/Markdown.7217f838.js";import{H as Ne,E as Kt}from"../chunks/EditOnGithub.91d95064.js";function Ot(k){let t,m='To see all architectures and checkpoints compatible with this task, we recommend checking the <a href="https://huggingface.co/tasks/text-classification" rel="nofollow">task-page</a>.';return{c(){t=M("p"),t.innerHTML=m},l(s){t=w(s,"P",{"data-svelte-h":!0}),T(t)!=="svelte-1cytdew"&&(t.innerHTML=m)},m(s,c){l(s,t,c)},p:re,d(s){s&&a(t)}}}function es(k){let t,m;return t=new C({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMERhdGFDb2xsYXRvcldpdGhQYWRkaW5nJTBBJTBBZGF0YV9jb2xsYXRvciUyMCUzRCUyMERhdGFDb2xsYXRvcldpdGhQYWRkaW5nKHRva2VuaXplciUzRHRva2VuaXplcik=",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> DataCollatorWithPadding

<span class="hljs-meta">&gt;&gt;&gt; </span>data_collator = DataCollatorWithPadding(tokenizer=tokenizer)`,wrap:!1}}),{c(){u(t.$$.fragment)},l(s){h(t.$$.fragment,s)},m(s,c){d(t,s,c),m=!0},p:re,i(s){m||(y(t.$$.fragment,s),m=!0)},o(s){g(t.$$.fragment,s),m=!1},d(s){b(t,s)}}}function ts(k){let t,m;return t=new ze({props:{$$slots:{default:[es]},$$scope:{ctx:k}}}),{c(){u(t.$$.fragment)},l(s){h(t.$$.fragment,s)},m(s,c){d(t,s,c),m=!0},p(s,c){const $={};c&2&&($.$$scope={dirty:c,ctx:s}),t.$set($)},i(s){m||(y(t.$$.fragment,s),m=!0)},o(s){g(t.$$.fragment,s),m=!1},d(s){b(t,s)}}}function ss(k){let t,m;return t=new C({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMERhdGFDb2xsYXRvcldpdGhQYWRkaW5nJTBBJTBBZGF0YV9jb2xsYXRvciUyMCUzRCUyMERhdGFDb2xsYXRvcldpdGhQYWRkaW5nKHRva2VuaXplciUzRHRva2VuaXplciUyQyUyMHJldHVybl90ZW5zb3JzJTNEJTIydGYlMjIp",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> DataCollatorWithPadding

<span class="hljs-meta">&gt;&gt;&gt; </span>data_collator = DataCollatorWithPadding(tokenizer=tokenizer, return_tensors=<span class="hljs-string">&quot;tf&quot;</span>)`,wrap:!1}}),{c(){u(t.$$.fragment)},l(s){h(t.$$.fragment,s)},m(s,c){d(t,s,c),m=!0},p:re,i(s){m||(y(t.$$.fragment,s),m=!0)},o(s){g(t.$$.fragment,s),m=!1},d(s){b(t,s)}}}function as(k){let t,m;return t=new ze({props:{$$slots:{default:[ss]},$$scope:{ctx:k}}}),{c(){u(t.$$.fragment)},l(s){h(t.$$.fragment,s)},m(s,c){d(t,s,c),m=!0},p(s,c){const $={};c&2&&($.$$scope={dirty:c,ctx:s}),t.$set($)},i(s){m||(y(t.$$.fragment,s),m=!0)},o(s){g(t.$$.fragment,s),m=!1},d(s){b(t,s)}}}function ls(k){let t,m='If you aren’t familiar with finetuning a model with the <a href="/docs/transformers/v4.42.4/en/main_classes/trainer#transformers.Trainer">Trainer</a>, take a look at the basic tutorial <a href="../training#train-with-pytorch-trainer">here</a>!';return{c(){t=M("p"),t.innerHTML=m},l(s){t=w(s,"P",{"data-svelte-h":!0}),T(t)!=="svelte-1kle7br"&&(t.innerHTML=m)},m(s,c){l(s,t,c)},p:re,d(s){s&&a(t)}}}function ns(k){let t,m='<a href="/docs/transformers/v4.42.4/en/main_classes/trainer#transformers.Trainer">Trainer</a> applies dynamic padding by default when you pass <code>tokenizer</code> to it. In this case, you don’t need to specify a data collator explicitly.';return{c(){t=M("p"),t.innerHTML=m},l(s){t=w(s,"P",{"data-svelte-h":!0}),T(t)!=="svelte-75wr1p"&&(t.innerHTML=m)},m(s,c){l(s,t,c)},p:re,d(s){s&&a(t)}}}function rs(k){let t,m,s,c='You’re ready to start training your model now! Load DistilBERT with <a href="/docs/transformers/v4.42.4/en/model_doc/auto#transformers.AutoModelForSequenceClassification">AutoModelForSequenceClassification</a> along with the number of expected labels, and the label mappings:',$,v,V,W,Z="At this point, only three steps remain:",x,_,N='<li>Define your training hyperparameters in <a href="/docs/transformers/v4.42.4/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). At the end of each epoch, the <a href="/docs/transformers/v4.42.4/en/main_classes/trainer#transformers.Trainer">Trainer</a> will evaluate the accuracy and save the training checkpoint.</li> <li>Pass the training arguments to <a href="/docs/transformers/v4.42.4/en/main_classes/trainer#transformers.Trainer">Trainer</a> along with the model, dataset, tokenizer, data collator, and <code>compute_metrics</code> function.</li> <li>Call <a href="/docs/transformers/v4.42.4/en/main_classes/trainer#transformers.Trainer.train">train()</a> to finetune your model.</li>',R,U,X,i,J,Y,E='Once training is completed, share your model to the Hub with the <a href="/docs/transformers/v4.42.4/en/main_classes/trainer#transformers.Trainer.push_to_hub">push_to_hub()</a> method so everyone can use your model:',I,z,H;return t=new Ee({props:{$$slots:{default:[ls]},$$scope:{ctx:k}}}),v=new C({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMEF1dG9Nb2RlbEZvclNlcXVlbmNlQ2xhc3NpZmljYXRpb24lMkMlMjBUcmFpbmluZ0FyZ3VtZW50cyUyQyUyMFRyYWluZXIlMEElMEFtb2RlbCUyMCUzRCUyMEF1dG9Nb2RlbEZvclNlcXVlbmNlQ2xhc3NpZmljYXRpb24uZnJvbV9wcmV0cmFpbmVkKCUwQSUyMCUyMCUyMCUyMCUyMmRpc3RpbGJlcnQlMkZkaXN0aWxiZXJ0LWJhc2UtdW5jYXNlZCUyMiUyQyUyMG51bV9sYWJlbHMlM0QyJTJDJTIwaWQybGFiZWwlM0RpZDJsYWJlbCUyQyUyMGxhYmVsMmlkJTNEbGFiZWwyaWQlMEEp",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoModelForSequenceClassification, TrainingArguments, Trainer

<span class="hljs-meta">&gt;&gt;&gt; </span>model = AutoModelForSequenceClassification.from_pretrained(
<span class="hljs-meta">... </span>    <span class="hljs-string">&quot;distilbert/distilbert-base-uncased&quot;</span>, num_labels=<span class="hljs-number">2</span>, id2label=id2label, label2id=label2id
<span class="hljs-meta">... </span>)`,wrap:!1}}),U=new C({props:{code:"dHJhaW5pbmdfYXJncyUyMCUzRCUyMFRyYWluaW5nQXJndW1lbnRzKCUwQSUyMCUyMCUyMCUyMG91dHB1dF9kaXIlM0QlMjJteV9hd2Vzb21lX21vZGVsJTIyJTJDJTBBJTIwJTIwJTIwJTIwbGVhcm5pbmdfcmF0ZSUzRDJlLTUlMkMlMEElMjAlMjAlMjAlMjBwZXJfZGV2aWNlX3RyYWluX2JhdGNoX3NpemUlM0QxNiUyQyUwQSUyMCUyMCUyMCUyMHBlcl9kZXZpY2VfZXZhbF9iYXRjaF9zaXplJTNEMTYlMkMlMEElMjAlMjAlMjAlMjBudW1fdHJhaW5fZXBvY2hzJTNEMiUyQyUwQSUyMCUyMCUyMCUyMHdlaWdodF9kZWNheSUzRDAuMDElMkMlMEElMjAlMjAlMjAlMjBldmFsX3N0cmF0ZWd5JTNEJTIyZXBvY2glMjIlMkMlMEElMjAlMjAlMjAlMjBzYXZlX3N0cmF0ZWd5JTNEJTIyZXBvY2glMjIlMkMlMEElMjAlMjAlMjAlMjBsb2FkX2Jlc3RfbW9kZWxfYXRfZW5kJTNEVHJ1ZSUyQyUwQSUyMCUyMCUyMCUyMHB1c2hfdG9faHViJTNEVHJ1ZSUyQyUwQSklMEElMEF0cmFpbmVyJTIwJTNEJTIwVHJhaW5lciglMEElMjAlMjAlMjAlMjBtb2RlbCUzRG1vZGVsJTJDJTBBJTIwJTIwJTIwJTIwYXJncyUzRHRyYWluaW5nX2FyZ3MlMkMlMEElMjAlMjAlMjAlMjB0cmFpbl9kYXRhc2V0JTNEdG9rZW5pemVkX2ltZGIlNUIlMjJ0cmFpbiUyMiU1RCUyQyUwQSUyMCUyMCUyMCUyMGV2YWxfZGF0YXNldCUzRHRva2VuaXplZF9pbWRiJTVCJTIydGVzdCUyMiU1RCUyQyUwQSUyMCUyMCUyMCUyMHRva2VuaXplciUzRHRva2VuaXplciUyQyUwQSUyMCUyMCUyMCUyMGRhdGFfY29sbGF0b3IlM0RkYXRhX2NvbGxhdG9yJTJDJTBBJTIwJTIwJTIwJTIwY29tcHV0ZV9tZXRyaWNzJTNEY29tcHV0ZV9tZXRyaWNzJTJDJTBBKSUwQSUwQXRyYWluZXIudHJhaW4oKQ==",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_model&quot;</span>,
<span class="hljs-meta">... </span>    learning_rate=<span class="hljs-number">2e-5</span>,
<span class="hljs-meta">... </span>    per_device_train_batch_size=<span class="hljs-number">16</span>,
<span class="hljs-meta">... </span>    per_device_eval_batch_size=<span class="hljs-number">16</span>,
<span class="hljs-meta">... </span>    num_train_epochs=<span class="hljs-number">2</span>,
<span class="hljs-meta">... </span>    weight_decay=<span class="hljs-number">0.01</span>,
<span class="hljs-meta">... </span>    eval_strategy=<span class="hljs-string">&quot;epoch&quot;</span>,
<span class="hljs-meta">... </span>    save_strategy=<span class="hljs-string">&quot;epoch&quot;</span>,
<span class="hljs-meta">... </span>    load_best_model_at_end=<span class="hljs-literal">True</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=tokenized_imdb[<span class="hljs-string">&quot;train&quot;</span>],
<span class="hljs-meta">... </span>    eval_dataset=tokenized_imdb[<span class="hljs-string">&quot;test&quot;</span>],
<span class="hljs-meta">... </span>    tokenizer=tokenizer,
<span class="hljs-meta">... </span>    data_collator=data_collator,
<span class="hljs-meta">... </span>    compute_metrics=compute_metrics,
<span class="hljs-meta">... </span>)

<span class="hljs-meta">&gt;&gt;&gt; </span>trainer.train()`,wrap:!1}}),i=new Ee({props:{$$slots:{default:[ns]},$$scope:{ctx:k}}}),z=new C({props:{code:"dHJhaW5lci5wdXNoX3RvX2h1Yigp",highlighted:'<span class="hljs-meta">&gt;&gt;&gt; </span>trainer.push_to_hub()',wrap:!1}}),{c(){u(t.$$.fragment),m=o(),s=M("p"),s.innerHTML=c,$=o(),u(v.$$.fragment),V=o(),W=M("p"),W.textContent=Z,x=o(),_=M("ol"),_.innerHTML=N,R=o(),u(U.$$.fragment),X=o(),u(i.$$.fragment),J=o(),Y=M("p"),Y.innerHTML=E,I=o(),u(z.$$.fragment)},l(f){h(t.$$.fragment,f),m=p(f),s=w(f,"P",{"data-svelte-h":!0}),T(s)!=="svelte-uav7kz"&&(s.innerHTML=c),$=p(f),h(v.$$.fragment,f),V=p(f),W=w(f,"P",{"data-svelte-h":!0}),T(W)!=="svelte-l42k0i"&&(W.textContent=Z),x=p(f),_=w(f,"OL",{"data-svelte-h":!0}),T(_)!=="svelte-1dyl1l1"&&(_.innerHTML=N),R=p(f),h(U.$$.fragment,f),X=p(f),h(i.$$.fragment,f),J=p(f),Y=w(f,"P",{"data-svelte-h":!0}),T(Y)!=="svelte-1hcmaoz"&&(Y.innerHTML=E),I=p(f),h(z.$$.fragment,f)},m(f,G){d(t,f,G),l(f,m,G),l(f,s,G),l(f,$,G),d(v,f,G),l(f,V,G),l(f,W,G),l(f,x,G),l(f,_,G),l(f,R,G),d(U,f,G),l(f,X,G),d(i,f,G),l(f,J,G),l(f,Y,G),l(f,I,G),d(z,f,G),H=!0},p(f,G){const F={};G&2&&(F.$$scope={dirty:G,ctx:f}),t.$set(F);const B={};G&2&&(B.$$scope={dirty:G,ctx:f}),i.$set(B)},i(f){H||(y(t.$$.fragment,f),y(v.$$.fragment,f),y(U.$$.fragment,f),y(i.$$.fragment,f),y(z.$$.fragment,f),H=!0)},o(f){g(t.$$.fragment,f),g(v.$$.fragment,f),g(U.$$.fragment,f),g(i.$$.fragment,f),g(z.$$.fragment,f),H=!1},d(f){f&&(a(m),a(s),a($),a(V),a(W),a(x),a(_),a(R),a(X),a(J),a(Y),a(I)),b(t,f),b(v,f),b(U,f),b(i,f),b(z,f)}}}function is(k){let t,m;return t=new ze({props:{$$slots:{default:[rs]},$$scope:{ctx:k}}}),{c(){u(t.$$.fragment)},l(s){h(t.$$.fragment,s)},m(s,c){d(t,s,c),m=!0},p(s,c){const $={};c&2&&($.$$scope={dirty:c,ctx:s}),t.$set($)},i(s){m||(y(t.$$.fragment,s),m=!0)},o(s){g(t.$$.fragment,s),m=!1},d(s){b(t,s)}}}function os(k){let t,m='If you aren’t familiar with finetuning a model with Keras, take a look at the basic tutorial <a href="../training#train-a-tensorflow-model-with-keras">here</a>!';return{c(){t=M("p"),t.innerHTML=m},l(s){t=w(s,"P",{"data-svelte-h":!0}),T(t)!=="svelte-1rd4nl8"&&(t.innerHTML=m)},m(s,c){l(s,t,c)},p:re,d(s){s&&a(t)}}}function ps(k){let t,m,s,c,$,v='Then you can load DistilBERT with <a href="/docs/transformers/v4.42.4/en/model_doc/auto#transformers.TFAutoModelForSequenceClassification">TFAutoModelForSequenceClassification</a> along with the number of expected labels, and the label mappings:',V,W,Z,x,_='Convert your datasets to the <code>tf.data.Dataset</code> format with <a href="/docs/transformers/v4.42.4/en/main_classes/model#transformers.TFPreTrainedModel.prepare_tf_dataset">prepare_tf_dataset()</a>:',N,R,U,X,i='Configure the model for training with <a href="https://keras.io/api/models/model_training_apis/#compile-method" rel="nofollow"><code>compile</code></a>. Note that Transformers models all have a default task-relevant loss function, so you don’t need to specify one unless you want to:',J,Y,E,I,z='The last two things to setup before you start training is to compute the accuracy from the predictions, and provide a way to push your model to the Hub. Both are done by using <a href="../main_classes/keras_callbacks">Keras callbacks</a>.',H,f,G='Pass your <code>compute_metrics</code> function to <a href="/docs/transformers/v4.42.4/en/main_classes/keras_callbacks#transformers.KerasMetricCallback">KerasMetricCallback</a>:',F,B,Q,se,ce='Specify where to push your model and tokenizer in the <a href="/docs/transformers/v4.42.4/en/main_classes/keras_callbacks#transformers.PushToHubCallback">PushToHubCallback</a>:',q,S,L,A,ae="Then bundle your callbacks together:",fe,P,D,K,le='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 callbacks to finetune the model:',ue,O,ee,te,ne="Once training is completed, your model is automatically uploaded to the Hub so everyone can use it!",he;return t=new Ee({props:{$$slots:{default:[os]},$$scope:{ctx:k}}}),s=new C({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMGNyZWF0ZV9vcHRpbWl6ZXIlMEFpbXBvcnQlMjB0ZW5zb3JmbG93JTIwYXMlMjB0ZiUwQSUwQWJhdGNoX3NpemUlMjAlM0QlMjAxNiUwQW51bV9lcG9jaHMlMjAlM0QlMjA1JTBBYmF0Y2hlc19wZXJfZXBvY2glMjAlM0QlMjBsZW4odG9rZW5pemVkX2ltZGIlNUIlMjJ0cmFpbiUyMiU1RCklMjAlMkYlMkYlMjBiYXRjaF9zaXplJTBBdG90YWxfdHJhaW5fc3RlcHMlMjAlM0QlMjBpbnQoYmF0Y2hlc19wZXJfZXBvY2glMjAqJTIwbnVtX2Vwb2NocyklMEFvcHRpbWl6ZXIlMkMlMjBzY2hlZHVsZSUyMCUzRCUyMGNyZWF0ZV9vcHRpbWl6ZXIoaW5pdF9sciUzRDJlLTUlMkMlMjBudW1fd2FybXVwX3N0ZXBzJTNEMCUyQyUyMG51bV90cmFpbl9zdGVwcyUzRHRvdGFsX3RyYWluX3N0ZXBzKQ==",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> create_optimizer
<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>batch_size = <span class="hljs-number">16</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>num_epochs = <span class="hljs-number">5</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>batches_per_epoch = <span class="hljs-built_in">len</span>(tokenized_imdb[<span class="hljs-string">&quot;train&quot;</span>]) // batch_size
<span class="hljs-meta">&gt;&gt;&gt; </span>total_train_steps = <span class="hljs-built_in">int</span>(batches_per_epoch * num_epochs)
<span class="hljs-meta">&gt;&gt;&gt; </span>optimizer, schedule = create_optimizer(init_lr=<span class="hljs-number">2e-5</span>, num_warmup_steps=<span class="hljs-number">0</span>, num_train_steps=total_train_steps)`,wrap:!1}}),W=new C({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMFRGQXV0b01vZGVsRm9yU2VxdWVuY2VDbGFzc2lmaWNhdGlvbiUwQSUwQW1vZGVsJTIwJTNEJTIwVEZBdXRvTW9kZWxGb3JTZXF1ZW5jZUNsYXNzaWZpY2F0aW9uLmZyb21fcHJldHJhaW5lZCglMEElMjAlMjAlMjAlMjAlMjJkaXN0aWxiZXJ0JTJGZGlzdGlsYmVydC1iYXNlLXVuY2FzZWQlMjIlMkMlMjBudW1fbGFiZWxzJTNEMiUyQyUyMGlkMmxhYmVsJTNEaWQybGFiZWwlMkMlMjBsYWJlbDJpZCUzRGxhYmVsMmlkJTBBKQ==",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> TFAutoModelForSequenceClassification

<span class="hljs-meta">&gt;&gt;&gt; </span>model = TFAutoModelForSequenceClassification.from_pretrained(
<span class="hljs-meta">... </span>    <span class="hljs-string">&quot;distilbert/distilbert-base-uncased&quot;</span>, num_labels=<span class="hljs-number">2</span>, id2label=id2label, label2id=label2id
<span class="hljs-meta">... </span>)`,wrap:!1}}),R=new C({props:{code:"dGZfdHJhaW5fc2V0JTIwJTNEJTIwbW9kZWwucHJlcGFyZV90Zl9kYXRhc2V0KCUwQSUyMCUyMCUyMCUyMHRva2VuaXplZF9pbWRiJTVCJTIydHJhaW4lMjIlNUQlMkMlMEElMjAlMjAlMjAlMjBzaHVmZmxlJTNEVHJ1ZSUyQyUwQSUyMCUyMCUyMCUyMGJhdGNoX3NpemUlM0QxNiUyQyUwQSUyMCUyMCUyMCUyMGNvbGxhdGVfZm4lM0RkYXRhX2NvbGxhdG9yJTJDJTBBKSUwQSUwQXRmX3ZhbGlkYXRpb25fc2V0JTIwJTNEJTIwbW9kZWwucHJlcGFyZV90Zl9kYXRhc2V0KCUwQSUyMCUyMCUyMCUyMHRva2VuaXplZF9pbWRiJTVCJTIydGVzdCUyMiU1RCUyQyUwQSUyMCUyMCUyMCUyMHNodWZmbGUlM0RGYWxzZSUyQyUwQSUyMCUyMCUyMCUyMGJhdGNoX3NpemUlM0QxNiUyQyUwQSUyMCUyMCUyMCUyMGNvbGxhdGVfZm4lM0RkYXRhX2NvbGxhdG9yJTJDJTBBKQ==",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span>tf_train_set = model.prepare_tf_dataset(
<span class="hljs-meta">... </span>    tokenized_imdb[<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_validation_set = model.prepare_tf_dataset(
<span class="hljs-meta">... </span>    tokenized_imdb[<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}}),Y=new C({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 C({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycy5rZXJhc19jYWxsYmFja3MlMjBpbXBvcnQlMjBLZXJhc01ldHJpY0NhbGxiYWNrJTBBJTBBbWV0cmljX2NhbGxiYWNrJTIwJTNEJTIwS2VyYXNNZXRyaWNDYWxsYmFjayhtZXRyaWNfZm4lM0Rjb21wdXRlX21ldHJpY3MlMkMlMjBldmFsX2RhdGFzZXQlM0R0Zl92YWxpZGF0aW9uX3NldCk=",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers.keras_callbacks <span class="hljs-keyword">import</span> KerasMetricCallback

<span class="hljs-meta">&gt;&gt;&gt; </span>metric_callback = KerasMetricCallback(metric_fn=compute_metrics, eval_dataset=tf_validation_set)`,wrap:!1}}),S=new C({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycy5rZXJhc19jYWxsYmFja3MlMjBpbXBvcnQlMjBQdXNoVG9IdWJDYWxsYmFjayUwQSUwQXB1c2hfdG9faHViX2NhbGxiYWNrJTIwJTNEJTIwUHVzaFRvSHViQ2FsbGJhY2soJTBBJTIwJTIwJTIwJTIwb3V0cHV0X2RpciUzRCUyMm15X2F3ZXNvbWVfbW9kZWwlMjIlMkMlMEElMjAlMjAlMjAlMjB0b2tlbml6ZXIlM0R0b2tlbml6ZXIlMkMlMEEp",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>push_to_hub_callback = PushToHubCallback(
<span class="hljs-meta">... </span>    output_dir=<span class="hljs-string">&quot;my_awesome_model&quot;</span>,
<span class="hljs-meta">... </span>    tokenizer=tokenizer,
<span class="hljs-meta">... </span>)`,wrap:!1}}),P=new C({props:{code:"Y2FsbGJhY2tzJTIwJTNEJTIwJTVCbWV0cmljX2NhbGxiYWNrJTJDJTIwcHVzaF90b19odWJfY2FsbGJhY2slNUQ=",highlighted:'<span class="hljs-meta">&gt;&gt;&gt; </span>callbacks = [metric_callback, push_to_hub_callback]',wrap:!1}}),O=new C({props:{code:"bW9kZWwuZml0KHglM0R0Zl90cmFpbl9zZXQlMkMlMjB2YWxpZGF0aW9uX2RhdGElM0R0Zl92YWxpZGF0aW9uX3NldCUyQyUyMGVwb2NocyUzRDMlMkMlMjBjYWxsYmFja3MlM0RjYWxsYmFja3Mp",highlighted:'<span class="hljs-meta">&gt;&gt;&gt; </span>model.fit(x=tf_train_set, validation_data=tf_validation_set, epochs=<span class="hljs-number">3</span>, callbacks=callbacks)',wrap:!1}}),{c(){u(t.$$.fragment),m=Lt(`
To finetune a model in TensorFlow, start by setting up an optimizer function, learning rate schedule, and some training hyperparameters:

	`),u(s.$$.fragment),c=o(),$=M("p"),$.innerHTML=v,V=o(),u(W.$$.fragment),Z=o(),x=M("p"),x.innerHTML=_,N=o(),u(R.$$.fragment),U=o(),X=M("p"),X.innerHTML=i,J=o(),u(Y.$$.fragment),E=o(),I=M("p"),I.innerHTML=z,H=o(),f=M("p"),f.innerHTML=G,F=o(),u(B.$$.fragment),Q=o(),se=M("p"),se.innerHTML=ce,q=o(),u(S.$$.fragment),L=o(),A=M("p"),A.textContent=ae,fe=o(),u(P.$$.fragment),D=o(),K=M("p"),K.innerHTML=le,ue=o(),u(O.$$.fragment),ee=o(),te=M("p"),te.textContent=ne},l(r){h(t.$$.fragment,r),m=At(r,`
To finetune a model in TensorFlow, start by setting up an optimizer function, learning rate schedule, and some training hyperparameters:

	`),h(s.$$.fragment,r),c=p(r),$=w(r,"P",{"data-svelte-h":!0}),T($)!=="svelte-1xattfp"&&($.innerHTML=v),V=p(r),h(W.$$.fragment,r),Z=p(r),x=w(r,"P",{"data-svelte-h":!0}),T(x)!=="svelte-1lg7gaw"&&(x.innerHTML=_),N=p(r),h(R.$$.fragment,r),U=p(r),X=w(r,"P",{"data-svelte-h":!0}),T(X)!=="svelte-17cxx5e"&&(X.innerHTML=i),J=p(r),h(Y.$$.fragment,r),E=p(r),I=w(r,"P",{"data-svelte-h":!0}),T(I)!=="svelte-6l1wkp"&&(I.innerHTML=z),H=p(r),f=w(r,"P",{"data-svelte-h":!0}),T(f)!=="svelte-eipp9u"&&(f.innerHTML=G),F=p(r),h(B.$$.fragment,r),Q=p(r),se=w(r,"P",{"data-svelte-h":!0}),T(se)!=="svelte-188hoec"&&(se.innerHTML=ce),q=p(r),h(S.$$.fragment,r),L=p(r),A=w(r,"P",{"data-svelte-h":!0}),T(A)!=="svelte-1lw9xm8"&&(A.textContent=ae),fe=p(r),h(P.$$.fragment,r),D=p(r),K=w(r,"P",{"data-svelte-h":!0}),T(K)!=="svelte-1hrpv1v"&&(K.innerHTML=le),ue=p(r),h(O.$$.fragment,r),ee=p(r),te=w(r,"P",{"data-svelte-h":!0}),T(te)!=="svelte-2s71om"&&(te.textContent=ne)},m(r,j){d(t,r,j),l(r,m,j),d(s,r,j),l(r,c,j),l(r,$,j),l(r,V,j),d(W,r,j),l(r,Z,j),l(r,x,j),l(r,N,j),d(R,r,j),l(r,U,j),l(r,X,j),l(r,J,j),d(Y,r,j),l(r,E,j),l(r,I,j),l(r,H,j),l(r,f,j),l(r,F,j),d(B,r,j),l(r,Q,j),l(r,se,j),l(r,q,j),d(S,r,j),l(r,L,j),l(r,A,j),l(r,fe,j),d(P,r,j),l(r,D,j),l(r,K,j),l(r,ue,j),d(O,r,j),l(r,ee,j),l(r,te,j),he=!0},p(r,j){const Fe={};j&2&&(Fe.$$scope={dirty:j,ctx:r}),t.$set(Fe)},i(r){he||(y(t.$$.fragment,r),y(s.$$.fragment,r),y(W.$$.fragment,r),y(R.$$.fragment,r),y(Y.$$.fragment,r),y(B.$$.fragment,r),y(S.$$.fragment,r),y(P.$$.fragment,r),y(O.$$.fragment,r),he=!0)},o(r){g(t.$$.fragment,r),g(s.$$.fragment,r),g(W.$$.fragment,r),g(R.$$.fragment,r),g(Y.$$.fragment,r),g(B.$$.fragment,r),g(S.$$.fragment,r),g(P.$$.fragment,r),g(O.$$.fragment,r),he=!1},d(r){r&&(a(m),a(c),a($),a(V),a(Z),a(x),a(N),a(U),a(X),a(J),a(E),a(I),a(H),a(f),a(F),a(Q),a(se),a(q),a(L),a(A),a(fe),a(D),a(K),a(ue),a(ee),a(te)),b(t,r),b(s,r),b(W,r),b(R,r),b(Y,r),b(B,r),b(S,r),b(P,r),b(O,r)}}}function ms(k){let t,m;return t=new ze({props:{$$slots:{default:[ps]},$$scope:{ctx:k}}}),{c(){u(t.$$.fragment)},l(s){h(t.$$.fragment,s)},m(s,c){d(t,s,c),m=!0},p(s,c){const $={};c&2&&($.$$scope={dirty:c,ctx:s}),t.$set($)},i(s){m||(y(t.$$.fragment,s),m=!0)},o(s){g(t.$$.fragment,s),m=!1},d(s){b(t,s)}}}function cs(k){let t,m=`For a more in-depth example of how to finetune a model for text classification, take a look at the corresponding
<a href="https://colab.research.google.com/github/huggingface/notebooks/blob/main/examples/text_classification.ipynb" rel="nofollow">PyTorch notebook</a>
or <a href="https://colab.research.google.com/github/huggingface/notebooks/blob/main/examples/text_classification-tf.ipynb" rel="nofollow">TensorFlow notebook</a>.`;return{c(){t=M("p"),t.innerHTML=m},l(s){t=w(s,"P",{"data-svelte-h":!0}),T(t)!=="svelte-m6bho8"&&(t.innerHTML=m)},m(s,c){l(s,t,c)},p:re,d(s){s&&a(t)}}}function fs(k){let t,m="Tokenize the text and return PyTorch tensors:",s,c,$,v,V="Pass your inputs to the model and return the <code>logits</code>:",W,Z,x,_,N="Get the class with the highest probability, and use the model’s <code>id2label</code> mapping to convert it to a text label:",R,U,X;return c=new C({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMEF1dG9Ub2tlbml6ZXIlMEElMEF0b2tlbml6ZXIlMjAlM0QlMjBBdXRvVG9rZW5pemVyLmZyb21fcHJldHJhaW5lZCglMjJzdGV2aGxpdSUyRm15X2F3ZXNvbWVfbW9kZWwlMjIpJTBBaW5wdXRzJTIwJTNEJTIwdG9rZW5pemVyKHRleHQlMkMlMjByZXR1cm5fdGVuc29ycyUzRCUyMnB0JTIyKQ==",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;stevhliu/my_awesome_model&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>inputs = tokenizer(text, return_tensors=<span class="hljs-string">&quot;pt&quot;</span>)`,wrap:!1}}),Z=new C({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMEF1dG9Nb2RlbEZvclNlcXVlbmNlQ2xhc3NpZmljYXRpb24lMEElMEFtb2RlbCUyMCUzRCUyMEF1dG9Nb2RlbEZvclNlcXVlbmNlQ2xhc3NpZmljYXRpb24uZnJvbV9wcmV0cmFpbmVkKCUyMnN0ZXZobGl1JTJGbXlfYXdlc29tZV9tb2RlbCUyMiklMEF3aXRoJTIwdG9yY2gubm9fZ3JhZCgpJTNBJTBBJTIwJTIwJTIwJTIwbG9naXRzJTIwJTNEJTIwbW9kZWwoKippbnB1dHMpLmxvZ2l0cw==",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;stevhliu/my_awesome_model&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">with</span> torch.no_grad():
<span class="hljs-meta">... </span>    logits = model(**inputs).logits`,wrap:!1}}),U=new C({props:{code:"cHJlZGljdGVkX2NsYXNzX2lkJTIwJTNEJTIwbG9naXRzLmFyZ21heCgpLml0ZW0oKSUwQW1vZGVsLmNvbmZpZy5pZDJsYWJlbCU1QnByZWRpY3RlZF9jbGFzc19pZCU1RA==",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span>predicted_class_id = logits.argmax().item()
<span class="hljs-meta">&gt;&gt;&gt; </span>model.config.id2label[predicted_class_id]
<span class="hljs-string">&#x27;POSITIVE&#x27;</span>`,wrap:!1}}),{c(){t=M("p"),t.textContent=m,s=o(),u(c.$$.fragment),$=o(),v=M("p"),v.innerHTML=V,W=o(),u(Z.$$.fragment),x=o(),_=M("p"),_.innerHTML=N,R=o(),u(U.$$.fragment)},l(i){t=w(i,"P",{"data-svelte-h":!0}),T(t)!=="svelte-1qcz1wr"&&(t.textContent=m),s=p(i),h(c.$$.fragment,i),$=p(i),v=w(i,"P",{"data-svelte-h":!0}),T(v)!=="svelte-f3g043"&&(v.innerHTML=V),W=p(i),h(Z.$$.fragment,i),x=p(i),_=w(i,"P",{"data-svelte-h":!0}),T(_)!=="svelte-6mgrol"&&(_.innerHTML=N),R=p(i),h(U.$$.fragment,i)},m(i,J){l(i,t,J),l(i,s,J),d(c,i,J),l(i,$,J),l(i,v,J),l(i,W,J),d(Z,i,J),l(i,x,J),l(i,_,J),l(i,R,J),d(U,i,J),X=!0},p:re,i(i){X||(y(c.$$.fragment,i),y(Z.$$.fragment,i),y(U.$$.fragment,i),X=!0)},o(i){g(c.$$.fragment,i),g(Z.$$.fragment,i),g(U.$$.fragment,i),X=!1},d(i){i&&(a(t),a(s),a($),a(v),a(W),a(x),a(_),a(R)),b(c,i),b(Z,i),b(U,i)}}}function us(k){let t,m;return t=new ze({props:{$$slots:{default:[fs]},$$scope:{ctx:k}}}),{c(){u(t.$$.fragment)},l(s){h(t.$$.fragment,s)},m(s,c){d(t,s,c),m=!0},p(s,c){const $={};c&2&&($.$$scope={dirty:c,ctx:s}),t.$set($)},i(s){m||(y(t.$$.fragment,s),m=!0)},o(s){g(t.$$.fragment,s),m=!1},d(s){b(t,s)}}}function hs(k){let t,m="Tokenize the text and return TensorFlow tensors:",s,c,$,v,V="Pass your inputs to the model and return the <code>logits</code>:",W,Z,x,_,N="Get the class with the highest probability, and use the model’s <code>id2label</code> mapping to convert it to a text label:",R,U,X;return c=new C({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMEF1dG9Ub2tlbml6ZXIlMEElMEF0b2tlbml6ZXIlMjAlM0QlMjBBdXRvVG9rZW5pemVyLmZyb21fcHJldHJhaW5lZCglMjJzdGV2aGxpdSUyRm15X2F3ZXNvbWVfbW9kZWwlMjIpJTBBaW5wdXRzJTIwJTNEJTIwdG9rZW5pemVyKHRleHQlMkMlMjByZXR1cm5fdGVuc29ycyUzRCUyMnRmJTIyKQ==",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;stevhliu/my_awesome_model&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>inputs = tokenizer(text, return_tensors=<span class="hljs-string">&quot;tf&quot;</span>)`,wrap:!1}}),Z=new C({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMFRGQXV0b01vZGVsRm9yU2VxdWVuY2VDbGFzc2lmaWNhdGlvbiUwQSUwQW1vZGVsJTIwJTNEJTIwVEZBdXRvTW9kZWxGb3JTZXF1ZW5jZUNsYXNzaWZpY2F0aW9uLmZyb21fcHJldHJhaW5lZCglMjJzdGV2aGxpdSUyRm15X2F3ZXNvbWVfbW9kZWwlMjIpJTBBbG9naXRzJTIwJTNEJTIwbW9kZWwoKippbnB1dHMpLmxvZ2l0cw==",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> TFAutoModelForSequenceClassification

<span class="hljs-meta">&gt;&gt;&gt; </span>model = TFAutoModelForSequenceClassification.from_pretrained(<span class="hljs-string">&quot;stevhliu/my_awesome_model&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>logits = model(**inputs).logits`,wrap:!1}}),U=new C({props:{code:"cHJlZGljdGVkX2NsYXNzX2lkJTIwJTNEJTIwaW50KHRmLm1hdGguYXJnbWF4KGxvZ2l0cyUyQyUyMGF4aXMlM0QtMSklNUIwJTVEKSUwQW1vZGVsLmNvbmZpZy5pZDJsYWJlbCU1QnByZWRpY3RlZF9jbGFzc19pZCU1RA==",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span>predicted_class_id = <span class="hljs-built_in">int</span>(tf.math.argmax(logits, axis=-<span class="hljs-number">1</span>)[<span class="hljs-number">0</span>])
<span class="hljs-meta">&gt;&gt;&gt; </span>model.config.id2label[predicted_class_id]
<span class="hljs-string">&#x27;POSITIVE&#x27;</span>`,wrap:!1}}),{c(){t=M("p"),t.textContent=m,s=o(),u(c.$$.fragment),$=o(),v=M("p"),v.innerHTML=V,W=o(),u(Z.$$.fragment),x=o(),_=M("p"),_.innerHTML=N,R=o(),u(U.$$.fragment)},l(i){t=w(i,"P",{"data-svelte-h":!0}),T(t)!=="svelte-s1qr7b"&&(t.textContent=m),s=p(i),h(c.$$.fragment,i),$=p(i),v=w(i,"P",{"data-svelte-h":!0}),T(v)!=="svelte-f3g043"&&(v.innerHTML=V),W=p(i),h(Z.$$.fragment,i),x=p(i),_=w(i,"P",{"data-svelte-h":!0}),T(_)!=="svelte-6mgrol"&&(_.innerHTML=N),R=p(i),h(U.$$.fragment,i)},m(i,J){l(i,t,J),l(i,s,J),d(c,i,J),l(i,$,J),l(i,v,J),l(i,W,J),d(Z,i,J),l(i,x,J),l(i,_,J),l(i,R,J),d(U,i,J),X=!0},p:re,i(i){X||(y(c.$$.fragment,i),y(Z.$$.fragment,i),y(U.$$.fragment,i),X=!0)},o(i){g(c.$$.fragment,i),g(Z.$$.fragment,i),g(U.$$.fragment,i),X=!1},d(i){i&&(a(t),a(s),a($),a(v),a(W),a(x),a(_),a(R)),b(c,i),b(Z,i),b(U,i)}}}function ds(k){let t,m;return t=new ze({props:{$$slots:{default:[hs]},$$scope:{ctx:k}}}),{c(){u(t.$$.fragment)},l(s){h(t.$$.fragment,s)},m(s,c){d(t,s,c),m=!0},p(s,c){const $={};c&2&&($.$$scope={dirty:c,ctx:s}),t.$set($)},i(s){m||(y(t.$$.fragment,s),m=!0)},o(s){g(t.$$.fragment,s),m=!1},d(s){b(t,s)}}}function ys(k){let t,m,s,c,$,v,V,W,Z,x,_,N="Text classification is a common NLP task that assigns a label or class to text. Some of the largest companies run text classification in production for a wide range of practical applications. One of the most popular forms of text classification is sentiment analysis, which assigns a label like 🙂 positive, 🙁 negative, or 😐 neutral to a sequence of text.",R,U,X="This guide will show you how to:",i,J,Y='<li>Finetune <a href="https://huggingface.co/distilbert/distilbert-base-uncased" rel="nofollow">DistilBERT</a> on the <a href="https://huggingface.co/datasets/imdb" rel="nofollow">IMDb</a> dataset to determine whether a movie review is positive or negative.</li> <li>Use your finetuned model for inference.</li>',E,I,z,H,f="Before you begin, make sure you have all the necessary libraries installed:",G,F,B,Q,se="We encourage you to login to your Hugging Face account so you can upload and share your model with the community. When prompted, enter your token to login:",ce,q,S,L,A,ae,fe="Start by loading the IMDb dataset from the 🤗 Datasets library:",P,D,K,le,ue="Then take a look at an example:",O,ee,te,ne,he="There are two fields in this dataset:",r,j,Fe="<li><code>text</code>: the movie review text.</li> <li><code>label</code>: a value that is either <code>0</code> for a negative review or <code>1</code> for a positive review.</li>",Qe,de,qe,ye,Tt="The next step is to load a DistilBERT tokenizer to preprocess the <code>text</code> field:",Se,ge,Le,be,Jt="Create a preprocessing function to tokenize <code>text</code> and truncate sequences to be no longer than DistilBERT’s maximum input length:",Ae,$e,Pe,Me,Ut='To apply the preprocessing function over the entire dataset, use 🤗 Datasets <a href="https://huggingface.co/docs/datasets/v3.0.0/en/package_reference/main_classes#datasets.Dataset.map" rel="nofollow">map</a> function. You can speed up <code>map</code> by setting <code>batched=True</code> to process multiple elements of the dataset at once:',De,we,Ke,je,_t='Now create a batch of examples using <a href="/docs/transformers/v4.42.4/en/main_classes/data_collator#transformers.DataCollatorWithPadding">DataCollatorWithPadding</a>. It’s more efficient to <em>dynamically pad</em> the sentences to the longest length in a batch during collation, instead of padding the whole dataset to the maximum length.',Oe,ie,et,Te,tt,Je,kt='Including a metric during training is often helpful for evaluating your model’s performance. You can quickly load a evaluation method with the 🤗 <a href="https://huggingface.co/docs/evaluate/index" rel="nofollow">Evaluate</a> library. For this task, load the <a href="https://huggingface.co/spaces/evaluate-metric/accuracy" rel="nofollow">accuracy</a> metric (see the 🤗 Evaluate <a href="https://huggingface.co/docs/evaluate/a_quick_tour" rel="nofollow">quick tour</a> to learn more about how to load and compute a metric):',st,Ue,at,_e,vt="Then create a function that passes your predictions and labels to <code>compute</code> to calculate the accuracy:",lt,ke,nt,ve,Zt="Your <code>compute_metrics</code> function is ready to go now, and you’ll return to it when you setup your training.",rt,Ze,it,Ce,Ct="Before you start training your model, create a map of the expected ids to their labels with <code>id2label</code> and <code>label2id</code>:",ot,We,pt,oe,mt,pe,ct,Ge,ft,xe,Wt="Great, now that you’ve finetuned a model, you can use it for inference!",ut,Re,Gt="Grab some text you’d like to run inference on:",ht,Xe,dt,Ve,xt='The simplest way to try out your finetuned model for inference is to use it in a <a href="/docs/transformers/v4.42.4/en/main_classes/pipelines#transformers.pipeline">pipeline()</a>. Instantiate a <code>pipeline</code> for sentiment analysis with your model, and pass your text to it:',yt,Ie,gt,Ye,Rt="You can also manually replicate the results of the <code>pipeline</code> if you’d like:",bt,me,$t,He,Mt,Be,wt;return $=new Ne({props:{title:"Text classification",local:"text-classification",headingTag:"h1"}}),V=new Dt({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/sequence_classification.ipynb"},{label:"PyTorch",value:"https://colab.research.google.com/github/huggingface/notebooks/blob/main/transformers_doc/en/pytorch/sequence_classification.ipynb"},{label:"TensorFlow",value:"https://colab.research.google.com/github/huggingface/notebooks/blob/main/transformers_doc/en/tensorflow/sequence_classification.ipynb"},{label:"Mixed",value:"https://studiolab.sagemaker.aws/import/github/huggingface/notebooks/blob/main/transformers_doc/en/sequence_classification.ipynb"},{label:"PyTorch",value:"https://studiolab.sagemaker.aws/import/github/huggingface/notebooks/blob/main/transformers_doc/en/pytorch/sequence_classification.ipynb"},{label:"TensorFlow",value:"https://studiolab.sagemaker.aws/import/github/huggingface/notebooks/blob/main/transformers_doc/en/tensorflow/sequence_classification.ipynb"}]}}),Z=new Pt({props:{id:"leNG9fN9FQU"}}),I=new Ee({props:{$$slots:{default:[Ot]},$$scope:{ctx:k}}}),F=new C({props:{code:"cGlwJTIwaW5zdGFsbCUyMHRyYW5zZm9ybWVycyUyMGRhdGFzZXRzJTIwZXZhbHVhdGUlMjBhY2NlbGVyYXRl",highlighted:"pip install transformers datasets evaluate accelerate",wrap:!1}}),q=new C({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}}),L=new Ne({props:{title:"Load IMDb dataset",local:"load-imdb-dataset",headingTag:"h2"}}),D=new C({props:{code:"ZnJvbSUyMGRhdGFzZXRzJTIwaW1wb3J0JTIwbG9hZF9kYXRhc2V0JTBBJTBBaW1kYiUyMCUzRCUyMGxvYWRfZGF0YXNldCglMjJpbWRiJTIyKQ==",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>imdb = load_dataset(<span class="hljs-string">&quot;imdb&quot;</span>)`,wrap:!1}}),ee=new C({props:{code:"aW1kYiU1QiUyMnRlc3QlMjIlNUQlNUIwJTVE",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span>imdb[<span class="hljs-string">&quot;test&quot;</span>][<span class="hljs-number">0</span>]
{
    <span class="hljs-string">&quot;label&quot;</span>: <span class="hljs-number">0</span>,
    <span class="hljs-string">&quot;text&quot;</span>: <span class="hljs-string">&quot;I love sci-fi and am willing to put up with a lot. Sci-fi movies/TV are usually underfunded, under-appreciated and misunderstood. I tried to like this, I really did, but it is to good TV sci-fi as Babylon 5 is to Star Trek (the original). Silly prosthetics, cheap cardboard sets, stilted dialogues, CG that doesn&#x27;t match the background, and painfully one-dimensional characters cannot be overcome with a &#x27;sci-fi&#x27; setting. (I&#x27;m sure there are those of you out there who think Babylon 5 is good sci-fi TV. It&#x27;s not. It&#x27;s clichéd and uninspiring.) While US viewers might like emotion and character development, sci-fi is a genre that does not take itself seriously (cf. Star Trek). It may treat important issues, yet not as a serious philosophy. It&#x27;s really difficult to care about the characters here as they are not simply foolish, just missing a spark of life. Their actions and reactions are wooden and predictable, often painful to watch. The makers of Earth KNOW it&#x27;s rubbish as they have to always say \\&quot;Gene Roddenberry&#x27;s Earth...\\&quot; otherwise people would not continue watching. Roddenberry&#x27;s ashes must be turning in their orbit as this dull, cheap, poorly edited (watching it without advert breaks really brings this home) trudging Trabant of a show lumbers into space. Spoiler. So, kill off a main character. And then bring him back as another actor. Jeeez! Dallas all over again.&quot;</span>,
}`,wrap:!1}}),de=new Ne({props:{title:"Preprocess",local:"preprocess",headingTag:"h2"}}),ge=new C({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMEF1dG9Ub2tlbml6ZXIlMEElMEF0b2tlbml6ZXIlMjAlM0QlMjBBdXRvVG9rZW5pemVyLmZyb21fcHJldHJhaW5lZCglMjJkaXN0aWxiZXJ0JTJGZGlzdGlsYmVydC1iYXNlLXVuY2FzZWQlMjIp",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/distilbert-base-uncased&quot;</span>)`,wrap:!1}}),$e=new C({props:{code:"ZGVmJTIwcHJlcHJvY2Vzc19mdW5jdGlvbihleGFtcGxlcyklM0ElMEElMjAlMjAlMjAlMjByZXR1cm4lMjB0b2tlbml6ZXIoZXhhbXBsZXMlNUIlMjJ0ZXh0JTIyJTVEJTJDJTIwdHJ1bmNhdGlvbiUzRFRydWUp",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(examples[<span class="hljs-string">&quot;text&quot;</span>], truncation=<span class="hljs-literal">True</span>)`,wrap:!1}}),we=new C({props:{code:"dG9rZW5pemVkX2ltZGIlMjAlM0QlMjBpbWRiLm1hcChwcmVwcm9jZXNzX2Z1bmN0aW9uJTJDJTIwYmF0Y2hlZCUzRFRydWUp",highlighted:'tokenized_imdb = imdb.<span class="hljs-built_in">map</span>(preprocess_function, batched=<span class="hljs-literal">True</span>)',wrap:!1}}),ie=new jt({props:{pytorch:!0,tensorflow:!0,jax:!1,$$slots:{tensorflow:[as],pytorch:[ts]},$$scope:{ctx:k}}}),Te=new Ne({props:{title:"Evaluate",local:"evaluate",headingTag:"h2"}}),Ue=new C({props:{code:"aW1wb3J0JTIwZXZhbHVhdGUlMEElMEFhY2N1cmFjeSUyMCUzRCUyMGV2YWx1YXRlLmxvYWQoJTIyYWNjdXJhY3klMjIp",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">import</span> evaluate

<span class="hljs-meta">&gt;&gt;&gt; </span>accuracy = evaluate.load(<span class="hljs-string">&quot;accuracy&quot;</span>)`,wrap:!1}}),ke=new C({props:{code:"aW1wb3J0JTIwbnVtcHklMjBhcyUyMG5wJTBBJTBBJTBBZGVmJTIwY29tcHV0ZV9tZXRyaWNzKGV2YWxfcHJlZCklM0ElMEElMjAlMjAlMjAlMjBwcmVkaWN0aW9ucyUyQyUyMGxhYmVscyUyMCUzRCUyMGV2YWxfcHJlZCUwQSUyMCUyMCUyMCUyMHByZWRpY3Rpb25zJTIwJTNEJTIwbnAuYXJnbWF4KHByZWRpY3Rpb25zJTJDJTIwYXhpcyUzRDEpJTBBJTIwJTIwJTIwJTIwcmV0dXJuJTIwYWNjdXJhY3kuY29tcHV0ZShwcmVkaWN0aW9ucyUzRHByZWRpY3Rpb25zJTJDJTIwcmVmZXJlbmNlcyUzRGxhYmVscyk=",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">def</span> <span class="hljs-title function_">compute_metrics</span>(<span class="hljs-params">eval_pred</span>):
<span class="hljs-meta">... </span>    predictions, labels = eval_pred
<span class="hljs-meta">... </span>    predictions = np.argmax(predictions, axis=<span class="hljs-number">1</span>)
<span class="hljs-meta">... </span>    <span class="hljs-keyword">return</span> accuracy.compute(predictions=predictions, references=labels)`,wrap:!1}}),Ze=new Ne({props:{title:"Train",local:"train",headingTag:"h2"}}),We=new C({props:{code:"aWQybGFiZWwlMjAlM0QlMjAlN0IwJTNBJTIwJTIyTkVHQVRJVkUlMjIlMkMlMjAxJTNBJTIwJTIyUE9TSVRJVkUlMjIlN0QlMEFsYWJlbDJpZCUyMCUzRCUyMCU3QiUyMk5FR0FUSVZFJTIyJTNBJTIwMCUyQyUyMCUyMlBPU0lUSVZFJTIyJTNBJTIwMSU3RA==",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span>id2label = {<span class="hljs-number">0</span>: <span class="hljs-string">&quot;NEGATIVE&quot;</span>, <span class="hljs-number">1</span>: <span class="hljs-string">&quot;POSITIVE&quot;</span>}
<span class="hljs-meta">&gt;&gt;&gt; </span>label2id = {<span class="hljs-string">&quot;NEGATIVE&quot;</span>: <span class="hljs-number">0</span>, <span class="hljs-string">&quot;POSITIVE&quot;</span>: <span class="hljs-number">1</span>}`,wrap:!1}}),oe=new jt({props:{pytorch:!0,tensorflow:!0,jax:!1,$$slots:{tensorflow:[ms],pytorch:[is]},$$scope:{ctx:k}}}),pe=new Ee({props:{$$slots:{default:[cs]},$$scope:{ctx:k}}}),Ge=new Ne({props:{title:"Inference",local:"inference",headingTag:"h2"}}),Xe=new C({props:{code:"dGV4dCUyMCUzRCUyMCUyMlRoaXMlMjB3YXMlMjBhJTIwbWFzdGVycGllY2UuJTIwTm90JTIwY29tcGxldGVseSUyMGZhaXRoZnVsJTIwdG8lMjB0aGUlMjBib29rcyUyQyUyMGJ1dCUyMGVudGhyYWxsaW5nJTIwZnJvbSUyMGJlZ2lubmluZyUyMHRvJTIwZW5kLiUyME1pZ2h0JTIwYmUlMjBteSUyMGZhdm9yaXRlJTIwb2YlMjB0aGUlMjB0aHJlZS4lMjI=",highlighted:'<span class="hljs-meta">&gt;&gt;&gt; </span>text = <span class="hljs-string">&quot;This was a masterpiece. Not completely faithful to the books, but enthralling from beginning to end. Might be my favorite of the three.&quot;</span>',wrap:!1}}),Ie=new C({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMHBpcGVsaW5lJTBBJTBBY2xhc3NpZmllciUyMCUzRCUyMHBpcGVsaW5lKCUyMnNlbnRpbWVudC1hbmFseXNpcyUyMiUyQyUyMG1vZGVsJTNEJTIyc3RldmhsaXUlMkZteV9hd2Vzb21lX21vZGVsJTIyKSUwQWNsYXNzaWZpZXIodGV4dCk=",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>classifier = pipeline(<span class="hljs-string">&quot;sentiment-analysis&quot;</span>, model=<span class="hljs-string">&quot;stevhliu/my_awesome_model&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>classifier(text)
[{<span class="hljs-string">&#x27;label&#x27;</span>: <span class="hljs-string">&#x27;POSITIVE&#x27;</span>, <span class="hljs-string">&#x27;score&#x27;</span>: <span class="hljs-number">0.9994940757751465</span>}]`,wrap:!1}}),me=new jt({props:{pytorch:!0,tensorflow:!0,jax:!1,$$slots:{tensorflow:[ds],pytorch:[us]},$$scope:{ctx:k}}}),He=new Kt({props:{source:"https://github.com/huggingface/transformers/blob/main/docs/source/en/tasks/sequence_classification.md"}}),{c(){t=M("meta"),m=o(),s=M("p"),c=o(),u($.$$.fragment),v=o(),u(V.$$.fragment),W=o(),u(Z.$$.fragment),x=o(),_=M("p"),_.textContent=N,R=o(),U=M("p"),U.textContent=X,i=o(),J=M("ol"),J.innerHTML=Y,E=o(),u(I.$$.fragment),z=o(),H=M("p"),H.textContent=f,G=o(),u(F.$$.fragment),B=o(),Q=M("p"),Q.textContent=se,ce=o(),u(q.$$.fragment),S=o(),u(L.$$.fragment),A=o(),ae=M("p"),ae.textContent=fe,P=o(),u(D.$$.fragment),K=o(),le=M("p"),le.textContent=ue,O=o(),u(ee.$$.fragment),te=o(),ne=M("p"),ne.textContent=he,r=o(),j=M("ul"),j.innerHTML=Fe,Qe=o(),u(de.$$.fragment),qe=o(),ye=M("p"),ye.innerHTML=Tt,Se=o(),u(ge.$$.fragment),Le=o(),be=M("p"),be.innerHTML=Jt,Ae=o(),u($e.$$.fragment),Pe=o(),Me=M("p"),Me.innerHTML=Ut,De=o(),u(we.$$.fragment),Ke=o(),je=M("p"),je.innerHTML=_t,Oe=o(),u(ie.$$.fragment),et=o(),u(Te.$$.fragment),tt=o(),Je=M("p"),Je.innerHTML=kt,st=o(),u(Ue.$$.fragment),at=o(),_e=M("p"),_e.innerHTML=vt,lt=o(),u(ke.$$.fragment),nt=o(),ve=M("p"),ve.innerHTML=Zt,rt=o(),u(Ze.$$.fragment),it=o(),Ce=M("p"),Ce.innerHTML=Ct,ot=o(),u(We.$$.fragment),pt=o(),u(oe.$$.fragment),mt=o(),u(pe.$$.fragment),ct=o(),u(Ge.$$.fragment),ft=o(),xe=M("p"),xe.textContent=Wt,ut=o(),Re=M("p"),Re.textContent=Gt,ht=o(),u(Xe.$$.fragment),dt=o(),Ve=M("p"),Ve.innerHTML=xt,yt=o(),u(Ie.$$.fragment),gt=o(),Ye=M("p"),Ye.innerHTML=Rt,bt=o(),u(me.$$.fragment),$t=o(),u(He.$$.fragment),Mt=o(),Be=M("p"),this.h()},l(e){const n=qt("svelte-u9bgzb",document.head);t=w(n,"META",{name:!0,content:!0}),n.forEach(a),m=p(e),s=w(e,"P",{}),Nt(s).forEach(a),c=p(e),h($.$$.fragment,e),v=p(e),h(V.$$.fragment,e),W=p(e),h(Z.$$.fragment,e),x=p(e),_=w(e,"P",{"data-svelte-h":!0}),T(_)!=="svelte-a44la3"&&(_.textContent=N),R=p(e),U=w(e,"P",{"data-svelte-h":!0}),T(U)!=="svelte-1aff4p7"&&(U.textContent=X),i=p(e),J=w(e,"OL",{"data-svelte-h":!0}),T(J)!=="svelte-g478nj"&&(J.innerHTML=Y),E=p(e),h(I.$$.fragment,e),z=p(e),H=w(e,"P",{"data-svelte-h":!0}),T(H)!=="svelte-1c9nexd"&&(H.textContent=f),G=p(e),h(F.$$.fragment,e),B=p(e),Q=w(e,"P",{"data-svelte-h":!0}),T(Q)!=="svelte-k76o1m"&&(Q.textContent=se),ce=p(e),h(q.$$.fragment,e),S=p(e),h(L.$$.fragment,e),A=p(e),ae=w(e,"P",{"data-svelte-h":!0}),T(ae)!=="svelte-cx4bj0"&&(ae.textContent=fe),P=p(e),h(D.$$.fragment,e),K=p(e),le=w(e,"P",{"data-svelte-h":!0}),T(le)!=="svelte-1m91ua0"&&(le.textContent=ue),O=p(e),h(ee.$$.fragment,e),te=p(e),ne=w(e,"P",{"data-svelte-h":!0}),T(ne)!=="svelte-q802b4"&&(ne.textContent=he),r=p(e),j=w(e,"UL",{"data-svelte-h":!0}),T(j)!=="svelte-4d5l79"&&(j.innerHTML=Fe),Qe=p(e),h(de.$$.fragment,e),qe=p(e),ye=w(e,"P",{"data-svelte-h":!0}),T(ye)!=="svelte-1gepr51"&&(ye.innerHTML=Tt),Se=p(e),h(ge.$$.fragment,e),Le=p(e),be=w(e,"P",{"data-svelte-h":!0}),T(be)!=="svelte-1xsc197"&&(be.innerHTML=Jt),Ae=p(e),h($e.$$.fragment,e),Pe=p(e),Me=w(e,"P",{"data-svelte-h":!0}),T(Me)!=="svelte-cqhsdq"&&(Me.innerHTML=Ut),De=p(e),h(we.$$.fragment,e),Ke=p(e),je=w(e,"P",{"data-svelte-h":!0}),T(je)!=="svelte-h0rsf4"&&(je.innerHTML=_t),Oe=p(e),h(ie.$$.fragment,e),et=p(e),h(Te.$$.fragment,e),tt=p(e),Je=w(e,"P",{"data-svelte-h":!0}),T(Je)!=="svelte-j1ipe9"&&(Je.innerHTML=kt),st=p(e),h(Ue.$$.fragment,e),at=p(e),_e=w(e,"P",{"data-svelte-h":!0}),T(_e)!=="svelte-o3o85z"&&(_e.innerHTML=vt),lt=p(e),h(ke.$$.fragment,e),nt=p(e),ve=w(e,"P",{"data-svelte-h":!0}),T(ve)!=="svelte-183aynn"&&(ve.innerHTML=Zt),rt=p(e),h(Ze.$$.fragment,e),it=p(e),Ce=w(e,"P",{"data-svelte-h":!0}),T(Ce)!=="svelte-18c6io4"&&(Ce.innerHTML=Ct),ot=p(e),h(We.$$.fragment,e),pt=p(e),h(oe.$$.fragment,e),mt=p(e),h(pe.$$.fragment,e),ct=p(e),h(Ge.$$.fragment,e),ft=p(e),xe=w(e,"P",{"data-svelte-h":!0}),T(xe)!=="svelte-633ppb"&&(xe.textContent=Wt),ut=p(e),Re=w(e,"P",{"data-svelte-h":!0}),T(Re)!=="svelte-o1jbfg"&&(Re.textContent=Gt),ht=p(e),h(Xe.$$.fragment,e),dt=p(e),Ve=w(e,"P",{"data-svelte-h":!0}),T(Ve)!=="svelte-55o07q"&&(Ve.innerHTML=xt),yt=p(e),h(Ie.$$.fragment,e),gt=p(e),Ye=w(e,"P",{"data-svelte-h":!0}),T(Ye)!=="svelte-1njl8vm"&&(Ye.innerHTML=Rt),bt=p(e),h(me.$$.fragment,e),$t=p(e),h(He.$$.fragment,e),Mt=p(e),Be=w(e,"P",{}),Nt(Be).forEach(a),this.h()},h(){zt(t,"name","hf:doc:metadata"),zt(t,"content",gs)},m(e,n){St(document.head,t),l(e,m,n),l(e,s,n),l(e,c,n),d($,e,n),l(e,v,n),d(V,e,n),l(e,W,n),d(Z,e,n),l(e,x,n),l(e,_,n),l(e,R,n),l(e,U,n),l(e,i,n),l(e,J,n),l(e,E,n),d(I,e,n),l(e,z,n),l(e,H,n),l(e,G,n),d(F,e,n),l(e,B,n),l(e,Q,n),l(e,ce,n),d(q,e,n),l(e,S,n),d(L,e,n),l(e,A,n),l(e,ae,n),l(e,P,n),d(D,e,n),l(e,K,n),l(e,le,n),l(e,O,n),d(ee,e,n),l(e,te,n),l(e,ne,n),l(e,r,n),l(e,j,n),l(e,Qe,n),d(de,e,n),l(e,qe,n),l(e,ye,n),l(e,Se,n),d(ge,e,n),l(e,Le,n),l(e,be,n),l(e,Ae,n),d($e,e,n),l(e,Pe,n),l(e,Me,n),l(e,De,n),d(we,e,n),l(e,Ke,n),l(e,je,n),l(e,Oe,n),d(ie,e,n),l(e,et,n),d(Te,e,n),l(e,tt,n),l(e,Je,n),l(e,st,n),d(Ue,e,n),l(e,at,n),l(e,_e,n),l(e,lt,n),d(ke,e,n),l(e,nt,n),l(e,ve,n),l(e,rt,n),d(Ze,e,n),l(e,it,n),l(e,Ce,n),l(e,ot,n),d(We,e,n),l(e,pt,n),d(oe,e,n),l(e,mt,n),d(pe,e,n),l(e,ct,n),d(Ge,e,n),l(e,ft,n),l(e,xe,n),l(e,ut,n),l(e,Re,n),l(e,ht,n),d(Xe,e,n),l(e,dt,n),l(e,Ve,n),l(e,yt,n),d(Ie,e,n),l(e,gt,n),l(e,Ye,n),l(e,bt,n),d(me,e,n),l(e,$t,n),d(He,e,n),l(e,Mt,n),l(e,Be,n),wt=!0},p(e,[n]){const Xt={};n&2&&(Xt.$$scope={dirty:n,ctx:e}),I.$set(Xt);const Vt={};n&2&&(Vt.$$scope={dirty:n,ctx:e}),ie.$set(Vt);const It={};n&2&&(It.$$scope={dirty:n,ctx:e}),oe.$set(It);const Yt={};n&2&&(Yt.$$scope={dirty:n,ctx:e}),pe.$set(Yt);const Ht={};n&2&&(Ht.$$scope={dirty:n,ctx:e}),me.$set(Ht)},i(e){wt||(y($.$$.fragment,e),y(V.$$.fragment,e),y(Z.$$.fragment,e),y(I.$$.fragment,e),y(F.$$.fragment,e),y(q.$$.fragment,e),y(L.$$.fragment,e),y(D.$$.fragment,e),y(ee.$$.fragment,e),y(de.$$.fragment,e),y(ge.$$.fragment,e),y($e.$$.fragment,e),y(we.$$.fragment,e),y(ie.$$.fragment,e),y(Te.$$.fragment,e),y(Ue.$$.fragment,e),y(ke.$$.fragment,e),y(Ze.$$.fragment,e),y(We.$$.fragment,e),y(oe.$$.fragment,e),y(pe.$$.fragment,e),y(Ge.$$.fragment,e),y(Xe.$$.fragment,e),y(Ie.$$.fragment,e),y(me.$$.fragment,e),y(He.$$.fragment,e),wt=!0)},o(e){g($.$$.fragment,e),g(V.$$.fragment,e),g(Z.$$.fragment,e),g(I.$$.fragment,e),g(F.$$.fragment,e),g(q.$$.fragment,e),g(L.$$.fragment,e),g(D.$$.fragment,e),g(ee.$$.fragment,e),g(de.$$.fragment,e),g(ge.$$.fragment,e),g($e.$$.fragment,e),g(we.$$.fragment,e),g(ie.$$.fragment,e),g(Te.$$.fragment,e),g(Ue.$$.fragment,e),g(ke.$$.fragment,e),g(Ze.$$.fragment,e),g(We.$$.fragment,e),g(oe.$$.fragment,e),g(pe.$$.fragment,e),g(Ge.$$.fragment,e),g(Xe.$$.fragment,e),g(Ie.$$.fragment,e),g(me.$$.fragment,e),g(He.$$.fragment,e),wt=!1},d(e){e&&(a(m),a(s),a(c),a(v),a(W),a(x),a(_),a(R),a(U),a(i),a(J),a(E),a(z),a(H),a(G),a(B),a(Q),a(ce),a(S),a(A),a(ae),a(P),a(K),a(le),a(O),a(te),a(ne),a(r),a(j),a(Qe),a(qe),a(ye),a(Se),a(Le),a(be),a(Ae),a(Pe),a(Me),a(De),a(Ke),a(je),a(Oe),a(et),a(tt),a(Je),a(st),a(at),a(_e),a(lt),a(nt),a(ve),a(rt),a(it),a(Ce),a(ot),a(pt),a(mt),a(ct),a(ft),a(xe),a(ut),a(Re),a(ht),a(dt),a(Ve),a(yt),a(gt),a(Ye),a(bt),a($t),a(Mt),a(Be)),a(t),b($,e),b(V,e),b(Z,e),b(I,e),b(F,e),b(q,e),b(L,e),b(D,e),b(ee,e),b(de,e),b(ge,e),b($e,e),b(we,e),b(ie,e),b(Te,e),b(Ue,e),b(ke,e),b(Ze,e),b(We,e),b(oe,e),b(pe,e),b(Ge,e),b(Xe,e),b(Ie,e),b(me,e),b(He,e)}}}const gs='{"title":"Text classification","local":"text-classification","sections":[{"title":"Load IMDb dataset","local":"load-imdb-dataset","sections":[],"depth":2},{"title":"Preprocess","local":"preprocess","sections":[],"depth":2},{"title":"Evaluate","local":"evaluate","sections":[],"depth":2},{"title":"Train","local":"train","sections":[],"depth":2},{"title":"Inference","local":"inference","sections":[],"depth":2}],"depth":1}';function bs(k){return Bt(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class ks extends Et{constructor(t){super(),Qt(this,t,bs,ys,Ft,{})}}export{ks as component};
