import{s as Ea,o as Na,n as fe}from"../chunks/scheduler.9bc65507.js";import{S as Ha,i as Ba,g as f,s as i,u as y,A as Ya,h as d,f as t,c as p,j as H,v as g,y as _,k as V,o as I,a as l,w as b,d as M,t as $,x as w,m as Va,n as Ia}from"../chunks/index.78c82d43.js";import{T as bt}from"../chunks/Tip.87d55b76.js";import{Y as Fa}from"../chunks/Youtube.b19762b6.js";import{I as nt}from"../chunks/IconCopyLink.bedaa44d.js";import{C}from"../chunks/CodeBlock.48618ec2.js";import{D as za}from"../chunks/DocNotebookDropdown.40f7599b.js";import{F as ra,M as ot}from"../chunks/Markdown.993b48ef.js";function La(k){let a,c,s='<a href="../model_doc/albert">ALBERT</a>, <a href="../model_doc/bart">BART</a>, <a href="../model_doc/bert">BERT</a>, <a href="../model_doc/big_bird">BigBird</a>, <a href="../model_doc/bigbird_pegasus">BigBird-Pegasus</a>, <a href="../model_doc/biogpt">BioGpt</a>, <a href="../model_doc/bloom">BLOOM</a>, <a href="../model_doc/camembert">CamemBERT</a>, <a href="../model_doc/canine">CANINE</a>, <a href="../model_doc/code_llama">CodeLlama</a>, <a href="../model_doc/convbert">ConvBERT</a>, <a href="../model_doc/ctrl">CTRL</a>, <a href="../model_doc/data2vec-text">Data2VecText</a>, <a href="../model_doc/deberta">DeBERTa</a>, <a href="../model_doc/deberta-v2">DeBERTa-v2</a>, <a href="../model_doc/distilbert">DistilBERT</a>, <a href="../model_doc/electra">ELECTRA</a>, <a href="../model_doc/ernie">ERNIE</a>, <a href="../model_doc/ernie_m">ErnieM</a>, <a href="../model_doc/esm">ESM</a>, <a href="../model_doc/falcon">Falcon</a>, <a href="../model_doc/flaubert">FlauBERT</a>, <a href="../model_doc/fnet">FNet</a>, <a href="../model_doc/funnel">Funnel Transformer</a>, <a href="../model_doc/gpt-sw3">GPT-Sw3</a>, <a href="../model_doc/gpt2">OpenAI GPT-2</a>, <a href="../model_doc/gpt_bigcode">GPTBigCode</a>, <a href="../model_doc/gpt_neo">GPT Neo</a>, <a href="../model_doc/gpt_neox">GPT NeoX</a>, <a href="../model_doc/gptj">GPT-J</a>, <a href="../model_doc/ibert">I-BERT</a>, <a href="../model_doc/layoutlm">LayoutLM</a>, <a href="../model_doc/layoutlmv2">LayoutLMv2</a>, <a href="../model_doc/layoutlmv3">LayoutLMv3</a>, <a href="../model_doc/led">LED</a>, <a href="../model_doc/lilt">LiLT</a>, <a href="../model_doc/llama">LLaMA</a>, <a href="../model_doc/longformer">Longformer</a>, <a href="../model_doc/luke">LUKE</a>, <a href="../model_doc/markuplm">MarkupLM</a>, <a href="../model_doc/mbart">mBART</a>, <a href="../model_doc/mega">MEGA</a>, <a href="../model_doc/megatron-bert">Megatron-BERT</a>, <a href="../model_doc/mobilebert">MobileBERT</a>, <a href="../model_doc/mpnet">MPNet</a>, <a href="../model_doc/mpt">MPT</a>, <a href="../model_doc/mra">MRA</a>, <a href="../model_doc/mt5">MT5</a>, <a href="../model_doc/mvp">MVP</a>, <a href="../model_doc/nezha">Nezha</a>, <a href="../model_doc/nystromformer">Nyströmformer</a>, <a href="../model_doc/open-llama">OpenLlama</a>, <a href="../model_doc/openai-gpt">OpenAI GPT</a>, <a href="../model_doc/opt">OPT</a>, <a href="../model_doc/perceiver">Perceiver</a>, <a href="../model_doc/plbart">PLBart</a>, <a href="../model_doc/qdqbert">QDQBert</a>, <a href="../model_doc/reformer">Reformer</a>, <a href="../model_doc/rembert">RemBERT</a>, <a href="../model_doc/roberta">RoBERTa</a>, <a href="../model_doc/roberta-prelayernorm">RoBERTa-PreLayerNorm</a>, <a href="../model_doc/roc_bert">RoCBert</a>, <a href="../model_doc/roformer">RoFormer</a>, <a href="../model_doc/squeezebert">SqueezeBERT</a>, <a href="../model_doc/t5">T5</a>, <a href="../model_doc/tapas">TAPAS</a>, <a href="../model_doc/transfo-xl">Transformer-XL</a>, <a href="../model_doc/umt5">UMT5</a>, <a href="../model_doc/xlm">XLM</a>, <a href="../model_doc/xlm-roberta">XLM-RoBERTa</a>, <a href="../model_doc/xlm-roberta-xl">XLM-RoBERTa-XL</a>, <a href="../model_doc/xlnet">XLNet</a>, <a href="../model_doc/xmod">X-MOD</a>, <a href="../model_doc/yoso">YOSO</a>';return{c(){a=Va(`The task illustrated in this tutorial is supported by the following model architectures:

`),c=f("p"),c.innerHTML=s},l(m){a=Ia(m,`The task illustrated in this tutorial is supported by the following model architectures:

`),c=d(m,"P",{"data-svelte-h":!0}),_(c)!=="svelte-1s70b8o"&&(c.innerHTML=s)},m(m,u){l(m,a,u),l(m,c,u)},p:fe,d(m){m&&(t(a),t(c))}}}function Qa(k){let a,c;return a=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)`}}),{c(){y(a.$$.fragment)},l(s){g(a.$$.fragment,s)},m(s,m){b(a,s,m),c=!0},p:fe,i(s){c||(M(a.$$.fragment,s),c=!0)},o(s){$(a.$$.fragment,s),c=!1},d(s){w(a,s)}}}function Aa(k){let a,c;return a=new ot({props:{$$slots:{default:[Qa]},$$scope:{ctx:k}}}),{c(){y(a.$$.fragment)},l(s){g(a.$$.fragment,s)},m(s,m){b(a,s,m),c=!0},p(s,m){const u={};m&2&&(u.$$scope={dirty:m,ctx:s}),a.$set(u)},i(s){c||(M(a.$$.fragment,s),c=!0)},o(s){$(a.$$.fragment,s),c=!1},d(s){w(a,s)}}}function Sa(k){let a,c;return a=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>)`}}),{c(){y(a.$$.fragment)},l(s){g(a.$$.fragment,s)},m(s,m){b(a,s,m),c=!0},p:fe,i(s){c||(M(a.$$.fragment,s),c=!0)},o(s){$(a.$$.fragment,s),c=!1},d(s){w(a,s)}}}function qa(k){let a,c;return a=new ot({props:{$$slots:{default:[Sa]},$$scope:{ctx:k}}}),{c(){y(a.$$.fragment)},l(s){g(a.$$.fragment,s)},m(s,m){b(a,s,m),c=!0},p(s,m){const u={};m&2&&(u.$$scope={dirty:m,ctx:s}),a.$set(u)},i(s){c||(M(a.$$.fragment,s),c=!0)},o(s){$(a.$$.fragment,s),c=!1},d(s){w(a,s)}}}function Pa(k){let a,c='If you aren’t familiar with finetuning a model with the <a href="/docs/transformers/v4.33.3/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(){a=f("p"),a.innerHTML=c},l(s){a=d(s,"P",{"data-svelte-h":!0}),_(a)!=="svelte-1kww4sq"&&(a.innerHTML=c)},m(s,m){l(s,a,m)},p:fe,d(s){s&&t(a)}}}function Da(k){let a,c='<a href="/docs/transformers/v4.33.3/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(){a=f("p"),a.innerHTML=c},l(s){a=d(s,"P",{"data-svelte-h":!0}),_(a)!=="svelte-1sltps8"&&(a.innerHTML=c)},m(s,m){l(s,a,m)},p:fe,d(s){s&&t(a)}}}function Ka(k){let a,c,s,m='You’re ready to start training your model now! Load DistilBERT with <a href="/docs/transformers/v4.33.3/en/model_doc/auto#transformers.AutoModelForSequenceClassification">AutoModelForSequenceClassification</a> along with the number of expected labels, and the label mappings:',u,v,E,J,X="At this point, only three steps remain:",W,R,Y='<li>Define your training hyperparameters in <a href="/docs/transformers/v4.33.3/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.33.3/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.33.3/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.33.3/en/main_classes/trainer#transformers.Trainer.train">train()</a> to finetune your model.</li>',Z,U,x,r,T,F,O='Once training is completed, share your model to the Hub with the <a href="/docs/transformers/v4.33.3/en/main_classes/trainer#transformers.Trainer.push_to_hub">push_to_hub()</a> method so everyone can use your model:',N,K,P;return a=new bt({props:{$$slots:{default:[Pa]},$$scope:{ctx:k}}}),v=new C({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMEF1dG9Nb2RlbEZvclNlcXVlbmNlQ2xhc3NpZmljYXRpb24lMkMlMjBUcmFpbmluZ0FyZ3VtZW50cyUyQyUyMFRyYWluZXIlMEElMEFtb2RlbCUyMCUzRCUyMEF1dG9Nb2RlbEZvclNlcXVlbmNlQ2xhc3NpZmljYXRpb24uZnJvbV9wcmV0cmFpbmVkKCUwQSUyMCUyMCUyMCUyMCUyMmRpc3RpbGJlcnQtYmFzZS11bmNhc2VkJTIyJTJDJTIwbnVtX2xhYmVscyUzRDIlMkMlMjBpZDJsYWJlbCUzRGlkMmxhYmVsJTJDJTIwbGFiZWwyaWQlM0RsYWJlbDJpZCUwQSk=",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-base-uncased&quot;</span>, num_labels=<span class="hljs-number">2</span>, id2label=id2label, label2id=label2id
<span class="hljs-meta">... </span>)`}}),U=new C({props:{code:"dHJhaW5pbmdfYXJncyUyMCUzRCUyMFRyYWluaW5nQXJndW1lbnRzKCUwQSUyMCUyMCUyMCUyMG91dHB1dF9kaXIlM0QlMjJteV9hd2Vzb21lX21vZGVsJTIyJTJDJTBBJTIwJTIwJTIwJTIwbGVhcm5pbmdfcmF0ZSUzRDJlLTUlMkMlMEElMjAlMjAlMjAlMjBwZXJfZGV2aWNlX3RyYWluX2JhdGNoX3NpemUlM0QxNiUyQyUwQSUyMCUyMCUyMCUyMHBlcl9kZXZpY2VfZXZhbF9iYXRjaF9zaXplJTNEMTYlMkMlMEElMjAlMjAlMjAlMjBudW1fdHJhaW5fZXBvY2hzJTNEMiUyQyUwQSUyMCUyMCUyMCUyMHdlaWdodF9kZWNheSUzRDAuMDElMkMlMEElMjAlMjAlMjAlMjBldmFsdWF0aW9uX3N0cmF0ZWd5JTNEJTIyZXBvY2glMjIlMkMlMEElMjAlMjAlMjAlMjBzYXZlX3N0cmF0ZWd5JTNEJTIyZXBvY2glMjIlMkMlMEElMjAlMjAlMjAlMjBsb2FkX2Jlc3RfbW9kZWxfYXRfZW5kJTNEVHJ1ZSUyQyUwQSUyMCUyMCUyMCUyMHB1c2hfdG9faHViJTNEVHJ1ZSUyQyUwQSklMEElMEF0cmFpbmVyJTIwJTNEJTIwVHJhaW5lciglMEElMjAlMjAlMjAlMjBtb2RlbCUzRG1vZGVsJTJDJTBBJTIwJTIwJTIwJTIwYXJncyUzRHRyYWluaW5nX2FyZ3MlMkMlMEElMjAlMjAlMjAlMjB0cmFpbl9kYXRhc2V0JTNEdG9rZW5pemVkX2ltZGIlNUIlMjJ0cmFpbiUyMiU1RCUyQyUwQSUyMCUyMCUyMCUyMGV2YWxfZGF0YXNldCUzRHRva2VuaXplZF9pbWRiJTVCJTIydGVzdCUyMiU1RCUyQyUwQSUyMCUyMCUyMCUyMHRva2VuaXplciUzRHRva2VuaXplciUyQyUwQSUyMCUyMCUyMCUyMGRhdGFfY29sbGF0b3IlM0RkYXRhX2NvbGxhdG9yJTJDJTBBJTIwJTIwJTIwJTIwY29tcHV0ZV9tZXRyaWNzJTNEY29tcHV0ZV9tZXRyaWNzJTJDJTBBKSUwQSUwQXRyYWluZXIudHJhaW4oKQ==",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>    evaluation_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()`}}),r=new bt({props:{$$slots:{default:[Da]},$$scope:{ctx:k}}}),K=new C({props:{code:"dHJhaW5lci5wdXNoX3RvX2h1Yigp",highlighted:'<span class="hljs-meta">&gt;&gt;&gt; </span>trainer.push_to_hub()'}}),{c(){y(a.$$.fragment),c=i(),s=f("p"),s.innerHTML=m,u=i(),y(v.$$.fragment),E=i(),J=f("p"),J.textContent=X,W=i(),R=f("ol"),R.innerHTML=Y,Z=i(),y(U.$$.fragment),x=i(),y(r.$$.fragment),T=i(),F=f("p"),F.innerHTML=O,N=i(),y(K.$$.fragment)},l(h){g(a.$$.fragment,h),c=p(h),s=d(h,"P",{"data-svelte-h":!0}),_(s)!=="svelte-18fkwq"&&(s.innerHTML=m),u=p(h),g(v.$$.fragment,h),E=p(h),J=d(h,"P",{"data-svelte-h":!0}),_(J)!=="svelte-l42k0i"&&(J.textContent=X),W=p(h),R=d(h,"OL",{"data-svelte-h":!0}),_(R)!=="svelte-12t2yet"&&(R.innerHTML=Y),Z=p(h),g(U.$$.fragment,h),x=p(h),g(r.$$.fragment,h),T=p(h),F=d(h,"P",{"data-svelte-h":!0}),_(F)!=="svelte-158pnaw"&&(F.innerHTML=O),N=p(h),g(K.$$.fragment,h)},m(h,G){b(a,h,G),l(h,c,G),l(h,s,G),l(h,u,G),b(v,h,G),l(h,E,G),l(h,J,G),l(h,W,G),l(h,R,G),l(h,Z,G),b(U,h,G),l(h,x,G),b(r,h,G),l(h,T,G),l(h,F,G),l(h,N,G),b(K,h,G),P=!0},p(h,G){const ee={};G&2&&(ee.$$scope={dirty:G,ctx:h}),a.$set(ee);const B={};G&2&&(B.$$scope={dirty:G,ctx:h}),r.$set(B)},i(h){P||(M(a.$$.fragment,h),M(v.$$.fragment,h),M(U.$$.fragment,h),M(r.$$.fragment,h),M(K.$$.fragment,h),P=!0)},o(h){$(a.$$.fragment,h),$(v.$$.fragment,h),$(U.$$.fragment,h),$(r.$$.fragment,h),$(K.$$.fragment,h),P=!1},d(h){h&&(t(c),t(s),t(u),t(E),t(J),t(W),t(R),t(Z),t(x),t(T),t(F),t(N)),w(a,h),w(v,h),w(U,h),w(r,h),w(K,h)}}}function Oa(k){let a,c;return a=new ot({props:{$$slots:{default:[Ka]},$$scope:{ctx:k}}}),{c(){y(a.$$.fragment)},l(s){g(a.$$.fragment,s)},m(s,m){b(a,s,m),c=!0},p(s,m){const u={};m&2&&(u.$$scope={dirty:m,ctx:s}),a.$set(u)},i(s){c||(M(a.$$.fragment,s),c=!0)},o(s){$(a.$$.fragment,s),c=!1},d(s){w(a,s)}}}function es(k){let a,c='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(){a=f("p"),a.innerHTML=c},l(s){a=d(s,"P",{"data-svelte-h":!0}),_(a)!=="svelte-1rd4nl8"&&(a.innerHTML=c)},m(s,m){l(s,a,m)},p:fe,d(s){s&&t(a)}}}function ts(k){let a,c,s,m,u,v='Then you can load DistilBERT with <a href="/docs/transformers/v4.33.3/en/model_doc/auto#transformers.TFAutoModelForSequenceClassification">TFAutoModelForSequenceClassification</a> along with the number of expected labels, and the label mappings:',E,J,X,W,R='Convert your datasets to the <code>tf.data.Dataset</code> format with <a href="/docs/transformers/v4.33.3/en/main_classes/model#transformers.TFPreTrainedModel.prepare_tf_dataset">prepare_tf_dataset()</a>:',Y,Z,U,x,r='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:',T,F,O,N,K='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>.',P,h,G='Pass your <code>compute_metrics</code> function to <a href="/docs/transformers/v4.33.3/en/main_classes/keras_callbacks#transformers.KerasMetricCallback">KerasMetricCallback</a>:',ee,B,se,L,rt='Specify where to push your model and tokenizer in the <a href="/docs/transformers/v4.33.3/en/main_classes/keras_callbacks#transformers.PushToHubCallback">PushToHubCallback</a>:',le,Q,ne,A,it="Then bundle your callbacks together:",oe,S,re,z,te='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:',ae,q,de,D,pt="Once training is completed, your model is automatically uploaded to the Hub so everyone can use it!",ie;return a=new bt({props:{$$slots:{default:[es]},$$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)`}}),J=new C({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMFRGQXV0b01vZGVsRm9yU2VxdWVuY2VDbGFzc2lmaWNhdGlvbiUwQSUwQW1vZGVsJTIwJTNEJTIwVEZBdXRvTW9kZWxGb3JTZXF1ZW5jZUNsYXNzaWZpY2F0aW9uLmZyb21fcHJldHJhaW5lZCglMEElMjAlMjAlMjAlMjAlMjJkaXN0aWxiZXJ0LWJhc2UtdW5jYXNlZCUyMiUyQyUyMG51bV9sYWJlbHMlM0QyJTJDJTIwaWQybGFiZWwlM0RpZDJsYWJlbCUyQyUyMGxhYmVsMmlkJTNEbGFiZWwyaWQlMEEp",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-base-uncased&quot;</span>, num_labels=<span class="hljs-number">2</span>, id2label=id2label, label2id=label2id
<span class="hljs-meta">... </span>)`}}),Z=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>)`}}),F=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>`}}),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)`}}),Q=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>)`}}),S=new C({props:{code:"Y2FsbGJhY2tzJTIwJTNEJTIwJTVCbWV0cmljX2NhbGxiYWNrJTJDJTIwcHVzaF90b19odWJfY2FsbGJhY2slNUQ=",highlighted:'<span class="hljs-meta">&gt;&gt;&gt; </span>callbacks = [metric_callback, push_to_hub_callback]'}}),q=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)'}}),{c(){y(a.$$.fragment),c=Va(`
To finetune a model in TensorFlow, start by setting up an optimizer function, learning rate schedule, and some training hyperparameters:

	`),y(s.$$.fragment),m=i(),u=f("p"),u.innerHTML=v,E=i(),y(J.$$.fragment),X=i(),W=f("p"),W.innerHTML=R,Y=i(),y(Z.$$.fragment),U=i(),x=f("p"),x.innerHTML=r,T=i(),y(F.$$.fragment),O=i(),N=f("p"),N.innerHTML=K,P=i(),h=f("p"),h.innerHTML=G,ee=i(),y(B.$$.fragment),se=i(),L=f("p"),L.innerHTML=rt,le=i(),y(Q.$$.fragment),ne=i(),A=f("p"),A.textContent=it,oe=i(),y(S.$$.fragment),re=i(),z=f("p"),z.innerHTML=te,ae=i(),y(q.$$.fragment),de=i(),D=f("p"),D.textContent=pt},l(n){g(a.$$.fragment,n),c=Ia(n,`
To finetune a model in TensorFlow, start by setting up an optimizer function, learning rate schedule, and some training hyperparameters:

	`),g(s.$$.fragment,n),m=p(n),u=d(n,"P",{"data-svelte-h":!0}),_(u)!=="svelte-1piwbzk"&&(u.innerHTML=v),E=p(n),g(J.$$.fragment,n),X=p(n),W=d(n,"P",{"data-svelte-h":!0}),_(W)!=="svelte-1hx2ar1"&&(W.innerHTML=R),Y=p(n),g(Z.$$.fragment,n),U=p(n),x=d(n,"P",{"data-svelte-h":!0}),_(x)!=="svelte-17cxx5e"&&(x.innerHTML=r),T=p(n),g(F.$$.fragment,n),O=p(n),N=d(n,"P",{"data-svelte-h":!0}),_(N)!=="svelte-6l1wkp"&&(N.innerHTML=K),P=p(n),h=d(n,"P",{"data-svelte-h":!0}),_(h)!=="svelte-1gikp1p"&&(h.innerHTML=G),ee=p(n),g(B.$$.fragment,n),se=p(n),L=d(n,"P",{"data-svelte-h":!0}),_(L)!=="svelte-173qpz1"&&(L.innerHTML=rt),le=p(n),g(Q.$$.fragment,n),ne=p(n),A=d(n,"P",{"data-svelte-h":!0}),_(A)!=="svelte-1lw9xm8"&&(A.textContent=it),oe=p(n),g(S.$$.fragment,n),re=p(n),z=d(n,"P",{"data-svelte-h":!0}),_(z)!=="svelte-1hrpv1v"&&(z.innerHTML=te),ae=p(n),g(q.$$.fragment,n),de=p(n),D=d(n,"P",{"data-svelte-h":!0}),_(D)!=="svelte-2s71om"&&(D.textContent=pt)},m(n,j){b(a,n,j),l(n,c,j),b(s,n,j),l(n,m,j),l(n,u,j),l(n,E,j),b(J,n,j),l(n,X,j),l(n,W,j),l(n,Y,j),b(Z,n,j),l(n,U,j),l(n,x,j),l(n,T,j),b(F,n,j),l(n,O,j),l(n,N,j),l(n,P,j),l(n,h,j),l(n,ee,j),b(B,n,j),l(n,se,j),l(n,L,j),l(n,le,j),b(Q,n,j),l(n,ne,j),l(n,A,j),l(n,oe,j),b(S,n,j),l(n,re,j),l(n,z,j),l(n,ae,j),b(q,n,j),l(n,de,j),l(n,D,j),ie=!0},p(n,j){const Te={};j&2&&(Te.$$scope={dirty:j,ctx:n}),a.$set(Te)},i(n){ie||(M(a.$$.fragment,n),M(s.$$.fragment,n),M(J.$$.fragment,n),M(Z.$$.fragment,n),M(F.$$.fragment,n),M(B.$$.fragment,n),M(Q.$$.fragment,n),M(S.$$.fragment,n),M(q.$$.fragment,n),ie=!0)},o(n){$(a.$$.fragment,n),$(s.$$.fragment,n),$(J.$$.fragment,n),$(Z.$$.fragment,n),$(F.$$.fragment,n),$(B.$$.fragment,n),$(Q.$$.fragment,n),$(S.$$.fragment,n),$(q.$$.fragment,n),ie=!1},d(n){n&&(t(c),t(m),t(u),t(E),t(X),t(W),t(Y),t(U),t(x),t(T),t(O),t(N),t(P),t(h),t(ee),t(se),t(L),t(le),t(ne),t(A),t(oe),t(re),t(z),t(ae),t(de),t(D)),w(a,n),w(s,n),w(J,n),w(Z,n),w(F,n),w(B,n),w(Q,n),w(S,n),w(q,n)}}}function as(k){let a,c;return a=new ot({props:{$$slots:{default:[ts]},$$scope:{ctx:k}}}),{c(){y(a.$$.fragment)},l(s){g(a.$$.fragment,s)},m(s,m){b(a,s,m),c=!0},p(s,m){const u={};m&2&&(u.$$scope={dirty:m,ctx:s}),a.$set(u)},i(s){c||(M(a.$$.fragment,s),c=!0)},o(s){$(a.$$.fragment,s),c=!1},d(s){w(a,s)}}}function ss(k){let a,c=`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(){a=f("p"),a.innerHTML=c},l(s){a=d(s,"P",{"data-svelte-h":!0}),_(a)!=="svelte-m6bho8"&&(a.innerHTML=c)},m(s,m){l(s,a,m)},p:fe,d(s){s&&t(a)}}}function ls(k){let a,c="Tokenize the text and return PyTorch tensors:",s,m,u,v,E="Pass your inputs to the model and return the <code>logits</code>:",J,X,W,R,Y="Get the class with the highest probability, and use the model’s <code>id2label</code> mapping to convert it to a text label:",Z,U,x;return m=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>)`}}),X=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`}}),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>`}}),{c(){a=f("p"),a.textContent=c,s=i(),y(m.$$.fragment),u=i(),v=f("p"),v.innerHTML=E,J=i(),y(X.$$.fragment),W=i(),R=f("p"),R.innerHTML=Y,Z=i(),y(U.$$.fragment)},l(r){a=d(r,"P",{"data-svelte-h":!0}),_(a)!=="svelte-1qcz1wr"&&(a.textContent=c),s=p(r),g(m.$$.fragment,r),u=p(r),v=d(r,"P",{"data-svelte-h":!0}),_(v)!=="svelte-f3g043"&&(v.innerHTML=E),J=p(r),g(X.$$.fragment,r),W=p(r),R=d(r,"P",{"data-svelte-h":!0}),_(R)!=="svelte-6mgrol"&&(R.innerHTML=Y),Z=p(r),g(U.$$.fragment,r)},m(r,T){l(r,a,T),l(r,s,T),b(m,r,T),l(r,u,T),l(r,v,T),l(r,J,T),b(X,r,T),l(r,W,T),l(r,R,T),l(r,Z,T),b(U,r,T),x=!0},p:fe,i(r){x||(M(m.$$.fragment,r),M(X.$$.fragment,r),M(U.$$.fragment,r),x=!0)},o(r){$(m.$$.fragment,r),$(X.$$.fragment,r),$(U.$$.fragment,r),x=!1},d(r){r&&(t(a),t(s),t(u),t(v),t(J),t(W),t(R),t(Z)),w(m,r),w(X,r),w(U,r)}}}function ns(k){let a,c;return a=new ot({props:{$$slots:{default:[ls]},$$scope:{ctx:k}}}),{c(){y(a.$$.fragment)},l(s){g(a.$$.fragment,s)},m(s,m){b(a,s,m),c=!0},p(s,m){const u={};m&2&&(u.$$scope={dirty:m,ctx:s}),a.$set(u)},i(s){c||(M(a.$$.fragment,s),c=!0)},o(s){$(a.$$.fragment,s),c=!1},d(s){w(a,s)}}}function os(k){let a,c="Tokenize the text and return TensorFlow tensors:",s,m,u,v,E="Pass your inputs to the model and return the <code>logits</code>:",J,X,W,R,Y="Get the class with the highest probability, and use the model’s <code>id2label</code> mapping to convert it to a text label:",Z,U,x;return m=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>)`}}),X=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`}}),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>`}}),{c(){a=f("p"),a.textContent=c,s=i(),y(m.$$.fragment),u=i(),v=f("p"),v.innerHTML=E,J=i(),y(X.$$.fragment),W=i(),R=f("p"),R.innerHTML=Y,Z=i(),y(U.$$.fragment)},l(r){a=d(r,"P",{"data-svelte-h":!0}),_(a)!=="svelte-s1qr7b"&&(a.textContent=c),s=p(r),g(m.$$.fragment,r),u=p(r),v=d(r,"P",{"data-svelte-h":!0}),_(v)!=="svelte-f3g043"&&(v.innerHTML=E),J=p(r),g(X.$$.fragment,r),W=p(r),R=d(r,"P",{"data-svelte-h":!0}),_(R)!=="svelte-6mgrol"&&(R.innerHTML=Y),Z=p(r),g(U.$$.fragment,r)},m(r,T){l(r,a,T),l(r,s,T),b(m,r,T),l(r,u,T),l(r,v,T),l(r,J,T),b(X,r,T),l(r,W,T),l(r,R,T),l(r,Z,T),b(U,r,T),x=!0},p:fe,i(r){x||(M(m.$$.fragment,r),M(X.$$.fragment,r),M(U.$$.fragment,r),x=!0)},o(r){$(m.$$.fragment,r),$(X.$$.fragment,r),$(U.$$.fragment,r),x=!1},d(r){r&&(t(a),t(s),t(u),t(v),t(J),t(W),t(R),t(Z)),w(m,r),w(X,r),w(U,r)}}}function rs(k){let a,c;return a=new ot({props:{$$slots:{default:[os]},$$scope:{ctx:k}}}),{c(){y(a.$$.fragment)},l(s){g(a.$$.fragment,s)},m(s,m){b(a,s,m),c=!0},p(s,m){const u={};m&2&&(u.$$scope={dirty:m,ctx:s}),a.$set(u)},i(s){c||(M(a.$$.fragment,s),c=!0)},o(s){$(a.$$.fragment,s),c=!1},d(s){w(a,s)}}}function is(k){let a,c,s,m,u,v,E,J,X,W,R="Text classification",Y,Z,U,x,r,T,F="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.",O,N,K="This guide will show you how to:",P,h,G='<li>Finetune <a href="https://huggingface.co/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>',ee,B,se,L,rt="Before you begin, make sure you have all the necessary libraries installed:",le,Q,ne,A,it="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:",oe,S,re,z,te,ae,q,de,D,pt="Load IMDb dataset",ie,n,j="Start by loading the IMDb dataset from the 🤗 Datasets library:",Te,je,Mt,ve,ia="Then take a look at an example:",$t,ke,wt,Je,pa="There are two fields in this dataset:",_t,Ue,ca="<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>",Tt,pe,ue,ct,Ce,sa,tt,ma="Preprocess",jt,Ze,ha="The next step is to load a DistilBERT tokenizer to preprocess the <code>text</code> field:",vt,xe,kt,We,fa="Create a preprocessing function to tokenize <code>text</code> and truncate sequences to be no longer than DistilBERT’s maximum input length:",Jt,Re,Ut,Ge,da='To apply the preprocessing function over the entire dataset, use 🤗 Datasets <a href="https://huggingface.co/docs/datasets/v2.14.5/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:',Ct,Xe,Zt,Ve,ua='Now create a batch of examples using <a href="/docs/transformers/v4.33.3/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.',xt,ye,Wt,ce,ge,mt,Ie,la,at,ya="Evaluate",Rt,Ee,ga='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):',Gt,Ne,Xt,He,ba='Then create a function that passes your predictions and labels to <a href="https://huggingface.co/docs/evaluate/v0.4.0/en/package_reference/main_classes#evaluate.EvaluationModule.compute" rel="nofollow">compute</a> to calculate the accuracy:',Vt,Be,It,Ye,Ma="Your <code>compute_metrics</code> function is ready to go now, and you’ll return to it when you setup your training.",Et,me,be,ht,Fe,na,st,$a="Train",Nt,ze,wa="Before you start training your model, create a map of the expected ids to their labels with <code>id2label</code> and <code>label2id</code>:",Ht,Le,Bt,Me,Yt,$e,Ft,he,we,ft,Qe,oa,lt,_a="Inference",zt,Ae,Ta="Great, now that you’ve finetuned a model, you can use it for inference!",Lt,Se,ja="Grab some text you’d like to run inference on:",Qt,qe,At,Pe,va='The simplest way to try out your finetuned model for inference is to use it in a <a href="/docs/transformers/v4.33.3/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:',St,De,qt,Ke,ka="You can also manually replicate the results of the <code>pipeline</code> if you’d like:",Pt,_e,Dt,dt,Kt;return J=new nt({}),Z=new za({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"}]}}),x=new Fa({props:{id:"leNG9fN9FQU"}}),B=new bt({props:{$$slots:{default:[La]},$$scope:{ctx:k}}}),Q=new C({props:{code:"cGlwJTIwaW5zdGFsbCUyMHRyYW5zZm9ybWVycyUyMGRhdGFzZXRzJTIwZXZhbHVhdGU=",highlighted:"pip install transformers datasets evaluate"}}),S=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()`}}),q=new nt({}),je=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>)`}}),ke=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>,
}`}}),Ce=new nt({}),xe=new C({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMEF1dG9Ub2tlbml6ZXIlMEElMEF0b2tlbml6ZXIlMjAlM0QlMjBBdXRvVG9rZW5pemVyLmZyb21fcHJldHJhaW5lZCglMjJkaXN0aWxiZXJ0LWJhc2UtdW5jYXNlZCUyMik=",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-base-uncased&quot;</span>)`}}),Re=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>)`}}),Xe=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>)'}}),ye=new ra({props:{pytorch:!0,tensorflow:!0,jax:!1,$$slots:{tensorflow:[qa],pytorch:[Aa]},$$scope:{ctx:k}}}),Ie=new nt({}),Ne=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>)`}}),Be=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)`}}),Fe=new nt({}),Le=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>}`}}),Me=new ra({props:{pytorch:!0,tensorflow:!0,jax:!1,$$slots:{tensorflow:[as],pytorch:[Oa]},$$scope:{ctx:k}}}),$e=new bt({props:{$$slots:{default:[ss]},$$scope:{ctx:k}}}),Qe=new nt({}),qe=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>'}}),De=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>}]`}}),_e=new ra({props:{pytorch:!0,tensorflow:!0,jax:!1,$$slots:{tensorflow:[rs],pytorch:[ns]},$$scope:{ctx:k}}}),{c(){a=f("meta"),c=i(),s=f("p"),m=i(),u=f("h1"),v=f("a"),E=f("span"),y(J.$$.fragment),X=i(),W=f("span"),W.textContent=R,Y=i(),y(Z.$$.fragment),U=i(),y(x.$$.fragment),r=i(),T=f("p"),T.textContent=F,O=i(),N=f("p"),N.textContent=K,P=i(),h=f("ol"),h.innerHTML=G,ee=i(),y(B.$$.fragment),se=i(),L=f("p"),L.textContent=rt,le=i(),y(Q.$$.fragment),ne=i(),A=f("p"),A.textContent=it,oe=i(),y(S.$$.fragment),re=i(),z=f("h2"),te=f("a"),ae=f("span"),y(q.$$.fragment),de=i(),D=f("span"),D.textContent=pt,ie=i(),n=f("p"),n.textContent=j,Te=i(),y(je.$$.fragment),Mt=i(),ve=f("p"),ve.textContent=ia,$t=i(),y(ke.$$.fragment),wt=i(),Je=f("p"),Je.textContent=pa,_t=i(),Ue=f("ul"),Ue.innerHTML=ca,Tt=i(),pe=f("h2"),ue=f("a"),ct=f("span"),y(Ce.$$.fragment),sa=i(),tt=f("span"),tt.textContent=ma,jt=i(),Ze=f("p"),Ze.innerHTML=ha,vt=i(),y(xe.$$.fragment),kt=i(),We=f("p"),We.innerHTML=fa,Jt=i(),y(Re.$$.fragment),Ut=i(),Ge=f("p"),Ge.innerHTML=da,Ct=i(),y(Xe.$$.fragment),Zt=i(),Ve=f("p"),Ve.innerHTML=ua,xt=i(),y(ye.$$.fragment),Wt=i(),ce=f("h2"),ge=f("a"),mt=f("span"),y(Ie.$$.fragment),la=i(),at=f("span"),at.textContent=ya,Rt=i(),Ee=f("p"),Ee.innerHTML=ga,Gt=i(),y(Ne.$$.fragment),Xt=i(),He=f("p"),He.innerHTML=ba,Vt=i(),y(Be.$$.fragment),It=i(),Ye=f("p"),Ye.innerHTML=Ma,Et=i(),me=f("h2"),be=f("a"),ht=f("span"),y(Fe.$$.fragment),na=i(),st=f("span"),st.textContent=$a,Nt=i(),ze=f("p"),ze.innerHTML=wa,Ht=i(),y(Le.$$.fragment),Bt=i(),y(Me.$$.fragment),Yt=i(),y($e.$$.fragment),Ft=i(),he=f("h2"),we=f("a"),ft=f("span"),y(Qe.$$.fragment),oa=i(),lt=f("span"),lt.textContent=_a,zt=i(),Ae=f("p"),Ae.textContent=Ta,Lt=i(),Se=f("p"),Se.textContent=ja,Qt=i(),y(qe.$$.fragment),At=i(),Pe=f("p"),Pe.innerHTML=va,St=i(),y(De.$$.fragment),qt=i(),Ke=f("p"),Ke.innerHTML=ka,Pt=i(),y(_e.$$.fragment),Dt=i(),dt=f("p"),this.h()},l(e){const o=Ya("svelte-1phssyn",document.head);a=d(o,"META",{name:!0,content:!0}),o.forEach(t),c=p(e),s=d(e,"P",{}),H(s).forEach(t),m=p(e),u=d(e,"H1",{class:!0});var Oe=H(u);v=d(Oe,"A",{id:!0,class:!0,href:!0});var ut=H(v);E=d(ut,"SPAN",{});var yt=H(E);g(J.$$.fragment,yt),yt.forEach(t),ut.forEach(t),X=p(Oe),W=d(Oe,"SPAN",{"data-svelte-h":!0}),_(W)!=="svelte-1olarbu"&&(W.textContent=R),Oe.forEach(t),Y=p(e),g(Z.$$.fragment,e),U=p(e),g(x.$$.fragment,e),r=p(e),T=d(e,"P",{"data-svelte-h":!0}),_(T)!=="svelte-a44la3"&&(T.textContent=F),O=p(e),N=d(e,"P",{"data-svelte-h":!0}),_(N)!=="svelte-1aff4p7"&&(N.textContent=K),P=p(e),h=d(e,"OL",{"data-svelte-h":!0}),_(h)!=="svelte-15fvapo"&&(h.innerHTML=G),ee=p(e),g(B.$$.fragment,e),se=p(e),L=d(e,"P",{"data-svelte-h":!0}),_(L)!=="svelte-1c9nexd"&&(L.textContent=rt),le=p(e),g(Q.$$.fragment,e),ne=p(e),A=d(e,"P",{"data-svelte-h":!0}),_(A)!=="svelte-k76o1m"&&(A.textContent=it),oe=p(e),g(S.$$.fragment,e),re=p(e),z=d(e,"H2",{class:!0});var et=H(z);te=d(et,"A",{id:!0,class:!0,href:!0});var gt=H(te);ae=d(gt,"SPAN",{});var Ja=H(ae);g(q.$$.fragment,Ja),Ja.forEach(t),gt.forEach(t),de=p(et),D=d(et,"SPAN",{"data-svelte-h":!0}),_(D)!=="svelte-17xlbj3"&&(D.textContent=pt),et.forEach(t),ie=p(e),n=d(e,"P",{"data-svelte-h":!0}),_(n)!=="svelte-cx4bj0"&&(n.textContent=j),Te=p(e),g(je.$$.fragment,e),Mt=p(e),ve=d(e,"P",{"data-svelte-h":!0}),_(ve)!=="svelte-1m91ua0"&&(ve.textContent=ia),$t=p(e),g(ke.$$.fragment,e),wt=p(e),Je=d(e,"P",{"data-svelte-h":!0}),_(Je)!=="svelte-q802b4"&&(Je.textContent=pa),_t=p(e),Ue=d(e,"UL",{"data-svelte-h":!0}),_(Ue)!=="svelte-4d5l79"&&(Ue.innerHTML=ca),Tt=p(e),pe=d(e,"H2",{class:!0});var Ot=H(pe);ue=d(Ot,"A",{id:!0,class:!0,href:!0});var Ua=H(ue);ct=d(Ua,"SPAN",{});var Ca=H(ct);g(Ce.$$.fragment,Ca),Ca.forEach(t),Ua.forEach(t),sa=p(Ot),tt=d(Ot,"SPAN",{"data-svelte-h":!0}),_(tt)!=="svelte-1cg9qj"&&(tt.textContent=ma),Ot.forEach(t),jt=p(e),Ze=d(e,"P",{"data-svelte-h":!0}),_(Ze)!=="svelte-1gepr51"&&(Ze.innerHTML=ha),vt=p(e),g(xe.$$.fragment,e),kt=p(e),We=d(e,"P",{"data-svelte-h":!0}),_(We)!=="svelte-1xsc197"&&(We.innerHTML=fa),Jt=p(e),g(Re.$$.fragment,e),Ut=p(e),Ge=d(e,"P",{"data-svelte-h":!0}),_(Ge)!=="svelte-1n6dr0t"&&(Ge.innerHTML=da),Ct=p(e),g(Xe.$$.fragment,e),Zt=p(e),Ve=d(e,"P",{"data-svelte-h":!0}),_(Ve)!=="svelte-lsqz9r"&&(Ve.innerHTML=ua),xt=p(e),g(ye.$$.fragment,e),Wt=p(e),ce=d(e,"H2",{class:!0});var ea=H(ce);ge=d(ea,"A",{id:!0,class:!0,href:!0});var Za=H(ge);mt=d(Za,"SPAN",{});var xa=H(mt);g(Ie.$$.fragment,xa),xa.forEach(t),Za.forEach(t),la=p(ea),at=d(ea,"SPAN",{"data-svelte-h":!0}),_(at)!=="svelte-sh8s6s"&&(at.textContent=ya),ea.forEach(t),Rt=p(e),Ee=d(e,"P",{"data-svelte-h":!0}),_(Ee)!=="svelte-j1ipe9"&&(Ee.innerHTML=ga),Gt=p(e),g(Ne.$$.fragment,e),Xt=p(e),He=d(e,"P",{"data-svelte-h":!0}),_(He)!=="svelte-14oy2j6"&&(He.innerHTML=ba),Vt=p(e),g(Be.$$.fragment,e),It=p(e),Ye=d(e,"P",{"data-svelte-h":!0}),_(Ye)!=="svelte-183aynn"&&(Ye.innerHTML=Ma),Et=p(e),me=d(e,"H2",{class:!0});var ta=H(me);be=d(ta,"A",{id:!0,class:!0,href:!0});var Wa=H(be);ht=d(Wa,"SPAN",{});var Ra=H(ht);g(Fe.$$.fragment,Ra),Ra.forEach(t),Wa.forEach(t),na=p(ta),st=d(ta,"SPAN",{"data-svelte-h":!0}),_(st)!=="svelte-5arm0l"&&(st.textContent=$a),ta.forEach(t),Nt=p(e),ze=d(e,"P",{"data-svelte-h":!0}),_(ze)!=="svelte-18c6io4"&&(ze.innerHTML=wa),Ht=p(e),g(Le.$$.fragment,e),Bt=p(e),g(Me.$$.fragment,e),Yt=p(e),g($e.$$.fragment,e),Ft=p(e),he=d(e,"H2",{class:!0});var aa=H(he);we=d(aa,"A",{id:!0,class:!0,href:!0});var Ga=H(we);ft=d(Ga,"SPAN",{});var Xa=H(ft);g(Qe.$$.fragment,Xa),Xa.forEach(t),Ga.forEach(t),oa=p(aa),lt=d(aa,"SPAN",{"data-svelte-h":!0}),_(lt)!=="svelte-199uz7g"&&(lt.textContent=_a),aa.forEach(t),zt=p(e),Ae=d(e,"P",{"data-svelte-h":!0}),_(Ae)!=="svelte-633ppb"&&(Ae.textContent=Ta),Lt=p(e),Se=d(e,"P",{"data-svelte-h":!0}),_(Se)!=="svelte-o1jbfg"&&(Se.textContent=ja),Qt=p(e),g(qe.$$.fragment,e),At=p(e),Pe=d(e,"P",{"data-svelte-h":!0}),_(Pe)!=="svelte-19p2l79"&&(Pe.innerHTML=va),St=p(e),g(De.$$.fragment,e),qt=p(e),Ke=d(e,"P",{"data-svelte-h":!0}),_(Ke)!=="svelte-1njl8vm"&&(Ke.innerHTML=ka),Pt=p(e),g(_e.$$.fragment,e),Dt=p(e),dt=d(e,"P",{}),H(dt).forEach(t),this.h()},h(){V(a,"name","hf:doc:metadata"),V(a,"content",JSON.stringify(ps)),V(v,"id","text-classification"),V(v,"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"),V(v,"href","#text-classification"),V(u,"class","relative group"),V(te,"id","load-imdb-dataset"),V(te,"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"),V(te,"href","#load-imdb-dataset"),V(z,"class","relative group"),V(ue,"id","preprocess"),V(ue,"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"),V(ue,"href","#preprocess"),V(pe,"class","relative group"),V(ge,"id","evaluate"),V(ge,"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"),V(ge,"href","#evaluate"),V(ce,"class","relative group"),V(be,"id","train"),V(be,"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"),V(be,"href","#train"),V(me,"class","relative group"),V(we,"id","inference"),V(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"),V(we,"href","#inference"),V(he,"class","relative group")},m(e,o){I(document.head,a),l(e,c,o),l(e,s,o),l(e,m,o),l(e,u,o),I(u,v),I(v,E),b(J,E,null),I(u,X),I(u,W),l(e,Y,o),b(Z,e,o),l(e,U,o),b(x,e,o),l(e,r,o),l(e,T,o),l(e,O,o),l(e,N,o),l(e,P,o),l(e,h,o),l(e,ee,o),b(B,e,o),l(e,se,o),l(e,L,o),l(e,le,o),b(Q,e,o),l(e,ne,o),l(e,A,o),l(e,oe,o),b(S,e,o),l(e,re,o),l(e,z,o),I(z,te),I(te,ae),b(q,ae,null),I(z,de),I(z,D),l(e,ie,o),l(e,n,o),l(e,Te,o),b(je,e,o),l(e,Mt,o),l(e,ve,o),l(e,$t,o),b(ke,e,o),l(e,wt,o),l(e,Je,o),l(e,_t,o),l(e,Ue,o),l(e,Tt,o),l(e,pe,o),I(pe,ue),I(ue,ct),b(Ce,ct,null),I(pe,sa),I(pe,tt),l(e,jt,o),l(e,Ze,o),l(e,vt,o),b(xe,e,o),l(e,kt,o),l(e,We,o),l(e,Jt,o),b(Re,e,o),l(e,Ut,o),l(e,Ge,o),l(e,Ct,o),b(Xe,e,o),l(e,Zt,o),l(e,Ve,o),l(e,xt,o),b(ye,e,o),l(e,Wt,o),l(e,ce,o),I(ce,ge),I(ge,mt),b(Ie,mt,null),I(ce,la),I(ce,at),l(e,Rt,o),l(e,Ee,o),l(e,Gt,o),b(Ne,e,o),l(e,Xt,o),l(e,He,o),l(e,Vt,o),b(Be,e,o),l(e,It,o),l(e,Ye,o),l(e,Et,o),l(e,me,o),I(me,be),I(be,ht),b(Fe,ht,null),I(me,na),I(me,st),l(e,Nt,o),l(e,ze,o),l(e,Ht,o),b(Le,e,o),l(e,Bt,o),b(Me,e,o),l(e,Yt,o),b($e,e,o),l(e,Ft,o),l(e,he,o),I(he,we),I(we,ft),b(Qe,ft,null),I(he,oa),I(he,lt),l(e,zt,o),l(e,Ae,o),l(e,Lt,o),l(e,Se,o),l(e,Qt,o),b(qe,e,o),l(e,At,o),l(e,Pe,o),l(e,St,o),b(De,e,o),l(e,qt,o),l(e,Ke,o),l(e,Pt,o),b(_e,e,o),l(e,Dt,o),l(e,dt,o),Kt=!0},p(e,[o]){const Oe={};o&2&&(Oe.$$scope={dirty:o,ctx:e}),B.$set(Oe);const ut={};o&2&&(ut.$$scope={dirty:o,ctx:e}),ye.$set(ut);const yt={};o&2&&(yt.$$scope={dirty:o,ctx:e}),Me.$set(yt);const et={};o&2&&(et.$$scope={dirty:o,ctx:e}),$e.$set(et);const gt={};o&2&&(gt.$$scope={dirty:o,ctx:e}),_e.$set(gt)},i(e){Kt||(M(J.$$.fragment,e),M(Z.$$.fragment,e),M(x.$$.fragment,e),M(B.$$.fragment,e),M(Q.$$.fragment,e),M(S.$$.fragment,e),M(q.$$.fragment,e),M(je.$$.fragment,e),M(ke.$$.fragment,e),M(Ce.$$.fragment,e),M(xe.$$.fragment,e),M(Re.$$.fragment,e),M(Xe.$$.fragment,e),M(ye.$$.fragment,e),M(Ie.$$.fragment,e),M(Ne.$$.fragment,e),M(Be.$$.fragment,e),M(Fe.$$.fragment,e),M(Le.$$.fragment,e),M(Me.$$.fragment,e),M($e.$$.fragment,e),M(Qe.$$.fragment,e),M(qe.$$.fragment,e),M(De.$$.fragment,e),M(_e.$$.fragment,e),Kt=!0)},o(e){$(J.$$.fragment,e),$(Z.$$.fragment,e),$(x.$$.fragment,e),$(B.$$.fragment,e),$(Q.$$.fragment,e),$(S.$$.fragment,e),$(q.$$.fragment,e),$(je.$$.fragment,e),$(ke.$$.fragment,e),$(Ce.$$.fragment,e),$(xe.$$.fragment,e),$(Re.$$.fragment,e),$(Xe.$$.fragment,e),$(ye.$$.fragment,e),$(Ie.$$.fragment,e),$(Ne.$$.fragment,e),$(Be.$$.fragment,e),$(Fe.$$.fragment,e),$(Le.$$.fragment,e),$(Me.$$.fragment,e),$($e.$$.fragment,e),$(Qe.$$.fragment,e),$(qe.$$.fragment,e),$(De.$$.fragment,e),$(_e.$$.fragment,e),Kt=!1},d(e){e&&(t(c),t(s),t(m),t(u),t(Y),t(U),t(r),t(T),t(O),t(N),t(P),t(h),t(ee),t(se),t(L),t(le),t(ne),t(A),t(oe),t(re),t(z),t(ie),t(n),t(Te),t(Mt),t(ve),t($t),t(wt),t(Je),t(_t),t(Ue),t(Tt),t(pe),t(jt),t(Ze),t(vt),t(kt),t(We),t(Jt),t(Ut),t(Ge),t(Ct),t(Zt),t(Ve),t(xt),t(Wt),t(ce),t(Rt),t(Ee),t(Gt),t(Xt),t(He),t(Vt),t(It),t(Ye),t(Et),t(me),t(Nt),t(ze),t(Ht),t(Bt),t(Yt),t(Ft),t(he),t(zt),t(Ae),t(Lt),t(Se),t(Qt),t(At),t(Pe),t(St),t(qt),t(Ke),t(Pt),t(Dt),t(dt)),t(a),w(J),w(Z,e),w(x,e),w(B,e),w(Q,e),w(S,e),w(q),w(je,e),w(ke,e),w(Ce),w(xe,e),w(Re,e),w(Xe,e),w(ye,e),w(Ie),w(Ne,e),w(Be,e),w(Fe),w(Le,e),w(Me,e),w($e,e),w(Qe),w(qe,e),w(De,e),w(_e,e)}}}const ps={local:"text-classification",sections:[{local:"load-imdb-dataset",title:"Load IMDb dataset"},{local:"preprocess",title:"Preprocess"},{local:"evaluate",title:"Evaluate"},{local:"train",title:"Train"},{local:"inference",title:"Inference"}],title:"Text classification"};function cs(k){return Na(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class Ms extends Ha{constructor(a){super(),Ba(this,a,cs,is,Ea,{})}}export{Ms as component};
