import{s as Ea,o as Na,n as he}from"../chunks/scheduler.9bc65507.js";import{S as Ha,i as Ba,g as h,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.73e038be.js";import{D as za}from"../chunks/DocNotebookDropdown.31840a23.js";import{F as oa,M as rt}from"../chunks/Markdown.1b9b4e1c.js";function La(k){let a,m,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/mistral">Mistral</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/persimmon">Persimmon</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:

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

`),m=d(c,"P",{"data-svelte-h":!0}),_(m)!=="svelte-1f5s7ya"&&(m.innerHTML=s)},m(c,u){l(c,a,u),l(c,m,u)},p:he,d(c){c&&(t(a),t(m))}}}function Qa(k){let a,m;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)`,wrap:!1}}),{c(){y(a.$$.fragment)},l(s){g(a.$$.fragment,s)},m(s,c){b(a,s,c),m=!0},p:he,i(s){m||(M(a.$$.fragment,s),m=!0)},o(s){$(a.$$.fragment,s),m=!1},d(s){w(a,s)}}}function Aa(k){let a,m;return a=new rt({props:{$$slots:{default:[Qa]},$$scope:{ctx:k}}}),{c(){y(a.$$.fragment)},l(s){g(a.$$.fragment,s)},m(s,c){b(a,s,c),m=!0},p(s,c){const u={};c&2&&(u.$$scope={dirty:c,ctx:s}),a.$set(u)},i(s){m||(M(a.$$.fragment,s),m=!0)},o(s){$(a.$$.fragment,s),m=!1},d(s){w(a,s)}}}function Sa(k){let a,m;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>)`,wrap:!1}}),{c(){y(a.$$.fragment)},l(s){g(a.$$.fragment,s)},m(s,c){b(a,s,c),m=!0},p:he,i(s){m||(M(a.$$.fragment,s),m=!0)},o(s){$(a.$$.fragment,s),m=!1},d(s){w(a,s)}}}function Pa(k){let a,m;return a=new rt({props:{$$slots:{default:[Sa]},$$scope:{ctx:k}}}),{c(){y(a.$$.fragment)},l(s){g(a.$$.fragment,s)},m(s,c){b(a,s,c),m=!0},p(s,c){const u={};c&2&&(u.$$scope={dirty:c,ctx:s}),a.$set(u)},i(s){m||(M(a.$$.fragment,s),m=!0)},o(s){$(a.$$.fragment,s),m=!1},d(s){w(a,s)}}}function qa(k){let a,m='If you aren’t familiar with finetuning a model with the <a href="/docs/transformers/v4.34.0/en/main_classes/trainer#transformers.Trainer">Trainer</a>, take a look at the basic tutorial <a href="../training#train-with-pytorch-trainer">here</a>!';return{c(){a=h("p"),a.innerHTML=m},l(s){a=d(s,"P",{"data-svelte-h":!0}),_(a)!=="svelte-1ufp0ay"&&(a.innerHTML=m)},m(s,c){l(s,a,c)},p:he,d(s){s&&t(a)}}}function Da(k){let a,m='<a href="/docs/transformers/v4.34.0/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=h("p"),a.innerHTML=m},l(s){a=d(s,"P",{"data-svelte-h":!0}),_(a)!=="svelte-8kgkso"&&(a.innerHTML=m)},m(s,c){l(s,a,c)},p:he,d(s){s&&t(a)}}}function Ka(k){let a,m,s,c='You’re ready to start training your model now! Load DistilBERT with <a href="/docs/transformers/v4.34.0/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.34.0/en/main_classes/trainer#transformers.TrainingArguments">TrainingArguments</a>. The only required parameter is <code>output_dir</code> which specifies where to save your model. You’ll push this model to the Hub by setting <code>push_to_hub=True</code> (you need to be signed in to Hugging Face to upload your model). At the end of each epoch, the <a href="/docs/transformers/v4.34.0/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.34.0/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.34.0/en/main_classes/trainer#transformers.Trainer.train">train()</a> to finetune your model.</li>',Z,U,x,o,T,F,O='Once training is completed, share your model to the Hub with the <a href="/docs/transformers/v4.34.0/en/main_classes/trainer#transformers.Trainer.push_to_hub">push_to_hub()</a> method so everyone can use your model:',N,K,q;return a=new bt({props:{$$slots:{default:[qa]},$$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>)`,wrap:!1}}),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()`,wrap:!1}}),o=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()',wrap:!1}}),{c(){y(a.$$.fragment),m=i(),s=h("p"),s.innerHTML=c,u=i(),y(v.$$.fragment),E=i(),J=h("p"),J.textContent=X,W=i(),R=h("ol"),R.innerHTML=Y,Z=i(),y(U.$$.fragment),x=i(),y(o.$$.fragment),T=i(),F=h("p"),F.innerHTML=O,N=i(),y(K.$$.fragment)},l(f){g(a.$$.fragment,f),m=p(f),s=d(f,"P",{"data-svelte-h":!0}),_(s)!=="svelte-iwtp6q"&&(s.innerHTML=c),u=p(f),g(v.$$.fragment,f),E=p(f),J=d(f,"P",{"data-svelte-h":!0}),_(J)!=="svelte-l42k0i"&&(J.textContent=X),W=p(f),R=d(f,"OL",{"data-svelte-h":!0}),_(R)!=="svelte-777kp9"&&(R.innerHTML=Y),Z=p(f),g(U.$$.fragment,f),x=p(f),g(o.$$.fragment,f),T=p(f),F=d(f,"P",{"data-svelte-h":!0}),_(F)!=="svelte-cv8z08"&&(F.innerHTML=O),N=p(f),g(K.$$.fragment,f)},m(f,G){b(a,f,G),l(f,m,G),l(f,s,G),l(f,u,G),b(v,f,G),l(f,E,G),l(f,J,G),l(f,W,G),l(f,R,G),l(f,Z,G),b(U,f,G),l(f,x,G),b(o,f,G),l(f,T,G),l(f,F,G),l(f,N,G),b(K,f,G),q=!0},p(f,G){const ee={};G&2&&(ee.$$scope={dirty:G,ctx:f}),a.$set(ee);const B={};G&2&&(B.$$scope={dirty:G,ctx:f}),o.$set(B)},i(f){q||(M(a.$$.fragment,f),M(v.$$.fragment,f),M(U.$$.fragment,f),M(o.$$.fragment,f),M(K.$$.fragment,f),q=!0)},o(f){$(a.$$.fragment,f),$(v.$$.fragment,f),$(U.$$.fragment,f),$(o.$$.fragment,f),$(K.$$.fragment,f),q=!1},d(f){f&&(t(m),t(s),t(u),t(E),t(J),t(W),t(R),t(Z),t(x),t(T),t(F),t(N)),w(a,f),w(v,f),w(U,f),w(o,f),w(K,f)}}}function Oa(k){let a,m;return a=new rt({props:{$$slots:{default:[Ka]},$$scope:{ctx:k}}}),{c(){y(a.$$.fragment)},l(s){g(a.$$.fragment,s)},m(s,c){b(a,s,c),m=!0},p(s,c){const u={};c&2&&(u.$$scope={dirty:c,ctx:s}),a.$set(u)},i(s){m||(M(a.$$.fragment,s),m=!0)},o(s){$(a.$$.fragment,s),m=!1},d(s){w(a,s)}}}function es(k){let a,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(){a=h("p"),a.innerHTML=m},l(s){a=d(s,"P",{"data-svelte-h":!0}),_(a)!=="svelte-1rd4nl8"&&(a.innerHTML=m)},m(s,c){l(s,a,c)},p:he,d(s){s&&t(a)}}}function ts(k){let a,m,s,c,u,v='Then you can load DistilBERT with <a href="/docs/transformers/v4.34.0/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.34.0/en/main_classes/model#transformers.TFPreTrainedModel.prepare_tf_dataset">prepare_tf_dataset()</a>:',Y,Z,U,x,o='Configure the model for training with <a href="https://keras.io/api/models/model_training_apis/#compile-method" rel="nofollow"><code>compile</code></a>. Note that Transformers models all have a default task-relevant loss function, so you don’t need to specify one unless you want to:',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>.',q,f,G='Pass your <code>compute_metrics</code> function to <a href="/docs/transformers/v4.34.0/en/main_classes/keras_callbacks#transformers.KerasMetricCallback">KerasMetricCallback</a>:',ee,B,se,L,ot='Specify where to push your model and tokenizer in the <a href="/docs/transformers/v4.34.0/en/main_classes/keras_callbacks#transformers.PushToHubCallback">PushToHubCallback</a>:',le,Q,ne,A,it="Then bundle your callbacks together:",re,S,oe,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,P,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)`,wrap:!1}}),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>)`,wrap:!1}}),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>)`,wrap:!1}}),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>`,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}}),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>)`,wrap:!1}}),S=new C({props:{code:"Y2FsbGJhY2tzJTIwJTNEJTIwJTVCbWV0cmljX2NhbGxiYWNrJTJDJTIwcHVzaF90b19odWJfY2FsbGJhY2slNUQ=",highlighted:'<span class="hljs-meta">&gt;&gt;&gt; </span>callbacks = [metric_callback, push_to_hub_callback]',wrap:!1}}),P=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(){y(a.$$.fragment),m=Va(`
To finetune a model in TensorFlow, start by setting up an optimizer function, learning rate schedule, and some training hyperparameters:

	`),y(s.$$.fragment),c=i(),u=h("p"),u.innerHTML=v,E=i(),y(J.$$.fragment),X=i(),W=h("p"),W.innerHTML=R,Y=i(),y(Z.$$.fragment),U=i(),x=h("p"),x.innerHTML=o,T=i(),y(F.$$.fragment),O=i(),N=h("p"),N.innerHTML=K,q=i(),f=h("p"),f.innerHTML=G,ee=i(),y(B.$$.fragment),se=i(),L=h("p"),L.innerHTML=ot,le=i(),y(Q.$$.fragment),ne=i(),A=h("p"),A.textContent=it,re=i(),y(S.$$.fragment),oe=i(),z=h("p"),z.innerHTML=te,ae=i(),y(P.$$.fragment),de=i(),D=h("p"),D.textContent=pt},l(n){g(a.$$.fragment,n),m=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),c=p(n),u=d(n,"P",{"data-svelte-h":!0}),_(u)!=="svelte-1dn4blc"&&(u.innerHTML=v),E=p(n),g(J.$$.fragment,n),X=p(n),W=d(n,"P",{"data-svelte-h":!0}),_(W)!=="svelte-qmwuyd"&&(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=o),T=p(n),g(F.$$.fragment,n),O=p(n),N=d(n,"P",{"data-svelte-h":!0}),_(N)!=="svelte-6l1wkp"&&(N.innerHTML=K),q=p(n),f=d(n,"P",{"data-svelte-h":!0}),_(f)!=="svelte-6vs5z9"&&(f.innerHTML=G),ee=p(n),g(B.$$.fragment,n),se=p(n),L=d(n,"P",{"data-svelte-h":!0}),_(L)!=="svelte-b2vwd"&&(L.innerHTML=ot),le=p(n),g(Q.$$.fragment,n),ne=p(n),A=d(n,"P",{"data-svelte-h":!0}),_(A)!=="svelte-1lw9xm8"&&(A.textContent=it),re=p(n),g(S.$$.fragment,n),oe=p(n),z=d(n,"P",{"data-svelte-h":!0}),_(z)!=="svelte-1hrpv1v"&&(z.innerHTML=te),ae=p(n),g(P.$$.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,m,j),b(s,n,j),l(n,c,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,q,j),l(n,f,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,re,j),b(S,n,j),l(n,oe,j),l(n,z,j),l(n,ae,j),b(P,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(P.$$.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),$(P.$$.fragment,n),ie=!1},d(n){n&&(t(m),t(c),t(u),t(E),t(X),t(W),t(Y),t(U),t(x),t(T),t(O),t(N),t(q),t(f),t(ee),t(se),t(L),t(le),t(ne),t(A),t(re),t(oe),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(P,n)}}}function as(k){let a,m;return a=new rt({props:{$$slots:{default:[ts]},$$scope:{ctx:k}}}),{c(){y(a.$$.fragment)},l(s){g(a.$$.fragment,s)},m(s,c){b(a,s,c),m=!0},p(s,c){const u={};c&2&&(u.$$scope={dirty:c,ctx:s}),a.$set(u)},i(s){m||(M(a.$$.fragment,s),m=!0)},o(s){$(a.$$.fragment,s),m=!1},d(s){w(a,s)}}}function ss(k){let a,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(){a=h("p"),a.innerHTML=m},l(s){a=d(s,"P",{"data-svelte-h":!0}),_(a)!=="svelte-m6bho8"&&(a.innerHTML=m)},m(s,c){l(s,a,c)},p:he,d(s){s&&t(a)}}}function ls(k){let a,m="Tokenize the text and return PyTorch tensors:",s,c,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 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}}),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`,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(){a=h("p"),a.textContent=m,s=i(),y(c.$$.fragment),u=i(),v=h("p"),v.innerHTML=E,J=i(),y(X.$$.fragment),W=i(),R=h("p"),R.innerHTML=Y,Z=i(),y(U.$$.fragment)},l(o){a=d(o,"P",{"data-svelte-h":!0}),_(a)!=="svelte-1qcz1wr"&&(a.textContent=m),s=p(o),g(c.$$.fragment,o),u=p(o),v=d(o,"P",{"data-svelte-h":!0}),_(v)!=="svelte-f3g043"&&(v.innerHTML=E),J=p(o),g(X.$$.fragment,o),W=p(o),R=d(o,"P",{"data-svelte-h":!0}),_(R)!=="svelte-6mgrol"&&(R.innerHTML=Y),Z=p(o),g(U.$$.fragment,o)},m(o,T){l(o,a,T),l(o,s,T),b(c,o,T),l(o,u,T),l(o,v,T),l(o,J,T),b(X,o,T),l(o,W,T),l(o,R,T),l(o,Z,T),b(U,o,T),x=!0},p:he,i(o){x||(M(c.$$.fragment,o),M(X.$$.fragment,o),M(U.$$.fragment,o),x=!0)},o(o){$(c.$$.fragment,o),$(X.$$.fragment,o),$(U.$$.fragment,o),x=!1},d(o){o&&(t(a),t(s),t(u),t(v),t(J),t(W),t(R),t(Z)),w(c,o),w(X,o),w(U,o)}}}function ns(k){let a,m;return a=new rt({props:{$$slots:{default:[ls]},$$scope:{ctx:k}}}),{c(){y(a.$$.fragment)},l(s){g(a.$$.fragment,s)},m(s,c){b(a,s,c),m=!0},p(s,c){const u={};c&2&&(u.$$scope={dirty:c,ctx:s}),a.$set(u)},i(s){m||(M(a.$$.fragment,s),m=!0)},o(s){$(a.$$.fragment,s),m=!1},d(s){w(a,s)}}}function rs(k){let a,m="Tokenize the text and return TensorFlow tensors:",s,c,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 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}}),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`,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(){a=h("p"),a.textContent=m,s=i(),y(c.$$.fragment),u=i(),v=h("p"),v.innerHTML=E,J=i(),y(X.$$.fragment),W=i(),R=h("p"),R.innerHTML=Y,Z=i(),y(U.$$.fragment)},l(o){a=d(o,"P",{"data-svelte-h":!0}),_(a)!=="svelte-s1qr7b"&&(a.textContent=m),s=p(o),g(c.$$.fragment,o),u=p(o),v=d(o,"P",{"data-svelte-h":!0}),_(v)!=="svelte-f3g043"&&(v.innerHTML=E),J=p(o),g(X.$$.fragment,o),W=p(o),R=d(o,"P",{"data-svelte-h":!0}),_(R)!=="svelte-6mgrol"&&(R.innerHTML=Y),Z=p(o),g(U.$$.fragment,o)},m(o,T){l(o,a,T),l(o,s,T),b(c,o,T),l(o,u,T),l(o,v,T),l(o,J,T),b(X,o,T),l(o,W,T),l(o,R,T),l(o,Z,T),b(U,o,T),x=!0},p:he,i(o){x||(M(c.$$.fragment,o),M(X.$$.fragment,o),M(U.$$.fragment,o),x=!0)},o(o){$(c.$$.fragment,o),$(X.$$.fragment,o),$(U.$$.fragment,o),x=!1},d(o){o&&(t(a),t(s),t(u),t(v),t(J),t(W),t(R),t(Z)),w(c,o),w(X,o),w(U,o)}}}function os(k){let a,m;return a=new rt({props:{$$slots:{default:[rs]},$$scope:{ctx:k}}}),{c(){y(a.$$.fragment)},l(s){g(a.$$.fragment,s)},m(s,c){b(a,s,c),m=!0},p(s,c){const u={};c&2&&(u.$$scope={dirty:c,ctx:s}),a.$set(u)},i(s){m||(M(a.$$.fragment,s),m=!0)},o(s){$(a.$$.fragment,s),m=!1},d(s){w(a,s)}}}function is(k){let a,m,s,c,u,v,E,J,X,W,R="Text classification",Y,Z,U,x,o,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:",q,f,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,ot="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:",re,S,oe,z,te,ae,P,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,ma="<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,mt,Ce,sa,tt,ca="Preprocess",jt,Ze,fa="The next step is to load a DistilBERT tokenizer to preprocess the <code>text</code> field:",vt,xe,kt,We,ha="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.34.0/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,me,ge,ct,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,ce,be,ft,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,fe,we,ht,Qe,ra,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,Pe,At,qe,va='The simplest way to try out your finetuned model for inference is to use it in a <a href="/docs/transformers/v4.34.0/en/main_classes/pipelines#transformers.pipeline">pipeline()</a>. Instantiate a <code>pipeline</code> for sentiment analysis with your model, and pass your text to it:',St,De,Pt,Ke,ka="You can also manually replicate the results of the <code>pipeline</code> if you’d like:",qt,_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",wrap:!1}}),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()`,wrap:!1}}),P=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>)`,wrap:!1}}),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>,
}`,wrap:!1}}),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>)`,wrap:!1}}),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>)`,wrap:!1}}),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>)',wrap:!1}}),ye=new oa({props:{pytorch:!0,tensorflow:!0,jax:!1,$$slots:{tensorflow:[Pa],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>)`,wrap:!1}}),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)`,wrap:!1}}),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>}`,wrap:!1}}),Me=new oa({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({}),Pe=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}}),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>}]`,wrap:!1}}),_e=new oa({props:{pytorch:!0,tensorflow:!0,jax:!1,$$slots:{tensorflow:[os],pytorch:[ns]},$$scope:{ctx:k}}}),{c(){a=h("meta"),m=i(),s=h("p"),c=i(),u=h("h1"),v=h("a"),E=h("span"),y(J.$$.fragment),X=i(),W=h("span"),W.textContent=R,Y=i(),y(Z.$$.fragment),U=i(),y(x.$$.fragment),o=i(),T=h("p"),T.textContent=F,O=i(),N=h("p"),N.textContent=K,q=i(),f=h("ol"),f.innerHTML=G,ee=i(),y(B.$$.fragment),se=i(),L=h("p"),L.textContent=ot,le=i(),y(Q.$$.fragment),ne=i(),A=h("p"),A.textContent=it,re=i(),y(S.$$.fragment),oe=i(),z=h("h2"),te=h("a"),ae=h("span"),y(P.$$.fragment),de=i(),D=h("span"),D.textContent=pt,ie=i(),n=h("p"),n.textContent=j,Te=i(),y(je.$$.fragment),Mt=i(),ve=h("p"),ve.textContent=ia,$t=i(),y(ke.$$.fragment),wt=i(),Je=h("p"),Je.textContent=pa,_t=i(),Ue=h("ul"),Ue.innerHTML=ma,Tt=i(),pe=h("h2"),ue=h("a"),mt=h("span"),y(Ce.$$.fragment),sa=i(),tt=h("span"),tt.textContent=ca,jt=i(),Ze=h("p"),Ze.innerHTML=fa,vt=i(),y(xe.$$.fragment),kt=i(),We=h("p"),We.innerHTML=ha,Jt=i(),y(Re.$$.fragment),Ut=i(),Ge=h("p"),Ge.innerHTML=da,Ct=i(),y(Xe.$$.fragment),Zt=i(),Ve=h("p"),Ve.innerHTML=ua,xt=i(),y(ye.$$.fragment),Wt=i(),me=h("h2"),ge=h("a"),ct=h("span"),y(Ie.$$.fragment),la=i(),at=h("span"),at.textContent=ya,Rt=i(),Ee=h("p"),Ee.innerHTML=ga,Gt=i(),y(Ne.$$.fragment),Xt=i(),He=h("p"),He.innerHTML=ba,Vt=i(),y(Be.$$.fragment),It=i(),Ye=h("p"),Ye.innerHTML=Ma,Et=i(),ce=h("h2"),be=h("a"),ft=h("span"),y(Fe.$$.fragment),na=i(),st=h("span"),st.textContent=$a,Nt=i(),ze=h("p"),ze.innerHTML=wa,Ht=i(),y(Le.$$.fragment),Bt=i(),y(Me.$$.fragment),Yt=i(),y($e.$$.fragment),Ft=i(),fe=h("h2"),we=h("a"),ht=h("span"),y(Qe.$$.fragment),ra=i(),lt=h("span"),lt.textContent=_a,zt=i(),Ae=h("p"),Ae.textContent=Ta,Lt=i(),Se=h("p"),Se.textContent=ja,Qt=i(),y(Pe.$$.fragment),At=i(),qe=h("p"),qe.innerHTML=va,St=i(),y(De.$$.fragment),Pt=i(),Ke=h("p"),Ke.innerHTML=ka,qt=i(),y(_e.$$.fragment),Dt=i(),dt=h("p"),this.h()},l(e){const r=Ya("svelte-1phssyn",document.head);a=d(r,"META",{name:!0,content:!0}),r.forEach(t),m=p(e),s=d(e,"P",{}),H(s).forEach(t),c=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),o=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),q=p(e),f=d(e,"OL",{"data-svelte-h":!0}),_(f)!=="svelte-15fvapo"&&(f.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=ot),le=p(e),g(Q.$$.fragment,e),ne=p(e),A=d(e,"P",{"data-svelte-h":!0}),_(A)!=="svelte-k76o1m"&&(A.textContent=it),re=p(e),g(S.$$.fragment,e),oe=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(P.$$.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=ma),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);mt=d(Ua,"SPAN",{});var Ca=H(mt);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=ca),Ot.forEach(t),jt=p(e),Ze=d(e,"P",{"data-svelte-h":!0}),_(Ze)!=="svelte-1gepr51"&&(Ze.innerHTML=fa),vt=p(e),g(xe.$$.fragment,e),kt=p(e),We=d(e,"P",{"data-svelte-h":!0}),_(We)!=="svelte-1xsc197"&&(We.innerHTML=ha),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-1f1ft0n"&&(Ve.innerHTML=ua),xt=p(e),g(ye.$$.fragment,e),Wt=p(e),me=d(e,"H2",{class:!0});var ea=H(me);ge=d(ea,"A",{id:!0,class:!0,href:!0});var Za=H(ge);ct=d(Za,"SPAN",{});var xa=H(ct);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),ce=d(e,"H2",{class:!0});var ta=H(ce);be=d(ta,"A",{id:!0,class:!0,href:!0});var Wa=H(be);ft=d(Wa,"SPAN",{});var Ra=H(ft);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),fe=d(e,"H2",{class:!0});var aa=H(fe);we=d(aa,"A",{id:!0,class:!0,href:!0});var Ga=H(we);ht=d(Ga,"SPAN",{});var Xa=H(ht);g(Qe.$$.fragment,Xa),Xa.forEach(t),Ga.forEach(t),ra=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(Pe.$$.fragment,e),At=p(e),qe=d(e,"P",{"data-svelte-h":!0}),_(qe)!=="svelte-1kkp80l"&&(qe.innerHTML=va),St=p(e),g(De.$$.fragment,e),Pt=p(e),Ke=d(e,"P",{"data-svelte-h":!0}),_(Ke)!=="svelte-1njl8vm"&&(Ke.innerHTML=ka),qt=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(me,"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(ce,"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(fe,"class","relative group")},m(e,r){I(document.head,a),l(e,m,r),l(e,s,r),l(e,c,r),l(e,u,r),I(u,v),I(v,E),b(J,E,null),I(u,X),I(u,W),l(e,Y,r),b(Z,e,r),l(e,U,r),b(x,e,r),l(e,o,r),l(e,T,r),l(e,O,r),l(e,N,r),l(e,q,r),l(e,f,r),l(e,ee,r),b(B,e,r),l(e,se,r),l(e,L,r),l(e,le,r),b(Q,e,r),l(e,ne,r),l(e,A,r),l(e,re,r),b(S,e,r),l(e,oe,r),l(e,z,r),I(z,te),I(te,ae),b(P,ae,null),I(z,de),I(z,D),l(e,ie,r),l(e,n,r),l(e,Te,r),b(je,e,r),l(e,Mt,r),l(e,ve,r),l(e,$t,r),b(ke,e,r),l(e,wt,r),l(e,Je,r),l(e,_t,r),l(e,Ue,r),l(e,Tt,r),l(e,pe,r),I(pe,ue),I(ue,mt),b(Ce,mt,null),I(pe,sa),I(pe,tt),l(e,jt,r),l(e,Ze,r),l(e,vt,r),b(xe,e,r),l(e,kt,r),l(e,We,r),l(e,Jt,r),b(Re,e,r),l(e,Ut,r),l(e,Ge,r),l(e,Ct,r),b(Xe,e,r),l(e,Zt,r),l(e,Ve,r),l(e,xt,r),b(ye,e,r),l(e,Wt,r),l(e,me,r),I(me,ge),I(ge,ct),b(Ie,ct,null),I(me,la),I(me,at),l(e,Rt,r),l(e,Ee,r),l(e,Gt,r),b(Ne,e,r),l(e,Xt,r),l(e,He,r),l(e,Vt,r),b(Be,e,r),l(e,It,r),l(e,Ye,r),l(e,Et,r),l(e,ce,r),I(ce,be),I(be,ft),b(Fe,ft,null),I(ce,na),I(ce,st),l(e,Nt,r),l(e,ze,r),l(e,Ht,r),b(Le,e,r),l(e,Bt,r),b(Me,e,r),l(e,Yt,r),b($e,e,r),l(e,Ft,r),l(e,fe,r),I(fe,we),I(we,ht),b(Qe,ht,null),I(fe,ra),I(fe,lt),l(e,zt,r),l(e,Ae,r),l(e,Lt,r),l(e,Se,r),l(e,Qt,r),b(Pe,e,r),l(e,At,r),l(e,qe,r),l(e,St,r),b(De,e,r),l(e,Pt,r),l(e,Ke,r),l(e,qt,r),b(_e,e,r),l(e,Dt,r),l(e,dt,r),Kt=!0},p(e,[r]){const Oe={};r&2&&(Oe.$$scope={dirty:r,ctx:e}),B.$set(Oe);const ut={};r&2&&(ut.$$scope={dirty:r,ctx:e}),ye.$set(ut);const yt={};r&2&&(yt.$$scope={dirty:r,ctx:e}),Me.$set(yt);const et={};r&2&&(et.$$scope={dirty:r,ctx:e}),$e.$set(et);const gt={};r&2&&(gt.$$scope={dirty:r,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(P.$$.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(Pe.$$.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),$(P.$$.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),$(Pe.$$.fragment,e),$(De.$$.fragment,e),$(_e.$$.fragment,e),Kt=!1},d(e){e&&(t(m),t(s),t(c),t(u),t(Y),t(U),t(o),t(T),t(O),t(N),t(q),t(f),t(ee),t(se),t(L),t(le),t(ne),t(A),t(re),t(oe),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(me),t(Rt),t(Ee),t(Gt),t(Xt),t(He),t(Vt),t(It),t(Ye),t(Et),t(ce),t(Nt),t(ze),t(Ht),t(Bt),t(Yt),t(Ft),t(fe),t(zt),t(Ae),t(Lt),t(Se),t(Qt),t(At),t(qe),t(St),t(Pt),t(Ke),t(qt),t(Dt),t(dt)),t(a),w(J),w(Z,e),w(x,e),w(B,e),w(Q,e),w(S,e),w(P),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(Pe,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 ms(k){return Na(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class Ms extends Ha{constructor(a){super(),Ba(this,a,ms,is,Ea,{})}}export{Ms as component};
