import{s as rl,o as il,n as os}from"../chunks/scheduler.25b97de1.js";import{S as ol,i as cl,g,s as i,r as M,A as ml,h as b,f as t,c as o,j as el,u as j,x as J,k as nl,y as hl,a as e,v as u,d,t as y,w as f,m as Ml,n as jl}from"../chunks/index.d9030fc9.js";import{T as Ba}from"../chunks/Tip.baa67368.js";import{Y as pl}from"../chunks/Youtube.eaf1a617.js";import{C as k}from"../chunks/CodeBlock.e6cd0d95.js";import{D as ul}from"../chunks/DocNotebookDropdown.5ea6cb78.js";import{F as Wa,M as Ls}from"../chunks/Markdown.7217f838.js";import{H as Ss,E as dl}from"../chunks/EditOnGithub.91d95064.js";function yl(_){let l,c='To see all architectures and checkpoints compatible with this task, we recommend checking the <a href="https://huggingface.co/tasks/token-classification" rel="nofollow">task-page</a>.';return{c(){l=g("p"),l.innerHTML=c},l(a){l=b(a,"P",{"data-svelte-h":!0}),J(l)!=="svelte-17xuz9c"&&(l.innerHTML=c)},m(a,m){e(a,l,m)},p:os,d(a){a&&t(l)}}}function fl(_){let l,c;return l=new k({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMERhdGFDb2xsYXRvckZvclRva2VuQ2xhc3NpZmljYXRpb24lMEElMEFkYXRhX2NvbGxhdG9yJTIwJTNEJTIwRGF0YUNvbGxhdG9yRm9yVG9rZW5DbGFzc2lmaWNhdGlvbih0b2tlbml6ZXIlM0R0b2tlbml6ZXIp",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> DataCollatorForTokenClassification

<span class="hljs-meta">&gt;&gt;&gt; </span>data_collator = DataCollatorForTokenClassification(tokenizer=tokenizer)`,wrap:!1}}),{c(){M(l.$$.fragment)},l(a){j(l.$$.fragment,a)},m(a,m){u(l,a,m),c=!0},p:os,i(a){c||(d(l.$$.fragment,a),c=!0)},o(a){y(l.$$.fragment,a),c=!1},d(a){f(l,a)}}}function gl(_){let l,c;return l=new Ls({props:{$$slots:{default:[fl]},$$scope:{ctx:_}}}),{c(){M(l.$$.fragment)},l(a){j(l.$$.fragment,a)},m(a,m){u(l,a,m),c=!0},p(a,m){const w={};m&2&&(w.$$scope={dirty:m,ctx:a}),l.$set(w)},i(a){c||(d(l.$$.fragment,a),c=!0)},o(a){y(l.$$.fragment,a),c=!1},d(a){f(l,a)}}}function bl(_){let l,c;return l=new k({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMERhdGFDb2xsYXRvckZvclRva2VuQ2xhc3NpZmljYXRpb24lMEElMEFkYXRhX2NvbGxhdG9yJTIwJTNEJTIwRGF0YUNvbGxhdG9yRm9yVG9rZW5DbGFzc2lmaWNhdGlvbih0b2tlbml6ZXIlM0R0b2tlbml6ZXIlMkMlMjByZXR1cm5fdGVuc29ycyUzRCUyMnRmJTIyKQ==",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> DataCollatorForTokenClassification

<span class="hljs-meta">&gt;&gt;&gt; </span>data_collator = DataCollatorForTokenClassification(tokenizer=tokenizer, return_tensors=<span class="hljs-string">&quot;tf&quot;</span>)`,wrap:!1}}),{c(){M(l.$$.fragment)},l(a){j(l.$$.fragment,a)},m(a,m){u(l,a,m),c=!0},p:os,i(a){c||(d(l.$$.fragment,a),c=!0)},o(a){y(l.$$.fragment,a),c=!1},d(a){f(l,a)}}}function wl(_){let l,c;return l=new Ls({props:{$$slots:{default:[bl]},$$scope:{ctx:_}}}),{c(){M(l.$$.fragment)},l(a){j(l.$$.fragment,a)},m(a,m){u(l,a,m),c=!0},p(a,m){const w={};m&2&&(w.$$scope={dirty:m,ctx:a}),l.$set(w)},i(a){c||(d(l.$$.fragment,a),c=!0)},o(a){y(l.$$.fragment,a),c=!1},d(a){f(l,a)}}}function Jl(_){let l,c='If you aren’t familiar with finetuning a model with the <a href="/docs/transformers/pr_31172/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(){l=g("p"),l.innerHTML=c},l(a){l=b(a,"P",{"data-svelte-h":!0}),J(l)!=="svelte-erc2u6"&&(l.innerHTML=c)},m(a,m){e(a,l,m)},p:os,d(a){a&&t(l)}}}function Tl(_){let l,c,a,m='You’re ready to start training your model now! Load DistilBERT with <a href="/docs/transformers/pr_31172/en/model_doc/auto#transformers.AutoModelForTokenClassification">AutoModelForTokenClassification</a> along with the number of expected labels, and the label mappings:',w,C,A,v,I="At this point, only three steps remain:",G,x,V='<li>Define your training hyperparameters in <a href="/docs/transformers/pr_31172/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/pr_31172/en/main_classes/trainer#transformers.Trainer">Trainer</a> will evaluate the seqeval scores and save the training checkpoint.</li> <li>Pass the training arguments to <a href="/docs/transformers/pr_31172/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/pr_31172/en/main_classes/trainer#transformers.Trainer.train">train()</a> to finetune your model.</li>',B,$,W,r,U='Once training is completed, share your model to the Hub with the <a href="/docs/transformers/pr_31172/en/main_classes/trainer#transformers.Trainer.push_to_hub">push_to_hub()</a> method so everyone can use your model:',E,X,R;return l=new Ba({props:{$$slots:{default:[Jl]},$$scope:{ctx:_}}}),C=new k({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMEF1dG9Nb2RlbEZvclRva2VuQ2xhc3NpZmljYXRpb24lMkMlMjBUcmFpbmluZ0FyZ3VtZW50cyUyQyUyMFRyYWluZXIlMEElMEFtb2RlbCUyMCUzRCUyMEF1dG9Nb2RlbEZvclRva2VuQ2xhc3NpZmljYXRpb24uZnJvbV9wcmV0cmFpbmVkKCUwQSUyMCUyMCUyMCUyMCUyMmRpc3RpbGJlcnQlMkZkaXN0aWxiZXJ0LWJhc2UtdW5jYXNlZCUyMiUyQyUyMG51bV9sYWJlbHMlM0QxMyUyQyUyMGlkMmxhYmVsJTNEaWQybGFiZWwlMkMlMjBsYWJlbDJpZCUzRGxhYmVsMmlkJTBBKQ==",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoModelForTokenClassification, TrainingArguments, Trainer

<span class="hljs-meta">&gt;&gt;&gt; </span>model = AutoModelForTokenClassification.from_pretrained(
<span class="hljs-meta">... </span>    <span class="hljs-string">&quot;distilbert/distilbert-base-uncased&quot;</span>, num_labels=<span class="hljs-number">13</span>, id2label=id2label, label2id=label2id
<span class="hljs-meta">... </span>)`,wrap:!1}}),$=new k({props:{code:"dHJhaW5pbmdfYXJncyUyMCUzRCUyMFRyYWluaW5nQXJndW1lbnRzKCUwQSUyMCUyMCUyMCUyMG91dHB1dF9kaXIlM0QlMjJteV9hd2Vzb21lX3dudXRfbW9kZWwlMjIlMkMlMEElMjAlMjAlMjAlMjBsZWFybmluZ19yYXRlJTNEMmUtNSUyQyUwQSUyMCUyMCUyMCUyMHBlcl9kZXZpY2VfdHJhaW5fYmF0Y2hfc2l6ZSUzRDE2JTJDJTBBJTIwJTIwJTIwJTIwcGVyX2RldmljZV9ldmFsX2JhdGNoX3NpemUlM0QxNiUyQyUwQSUyMCUyMCUyMCUyMG51bV90cmFpbl9lcG9jaHMlM0QyJTJDJTBBJTIwJTIwJTIwJTIwd2VpZ2h0X2RlY2F5JTNEMC4wMSUyQyUwQSUyMCUyMCUyMCUyMGV2YWxfc3RyYXRlZ3klM0QlMjJlcG9jaCUyMiUyQyUwQSUyMCUyMCUyMCUyMHNhdmVfc3RyYXRlZ3klM0QlMjJlcG9jaCUyMiUyQyUwQSUyMCUyMCUyMCUyMGxvYWRfYmVzdF9tb2RlbF9hdF9lbmQlM0RUcnVlJTJDJTBBJTIwJTIwJTIwJTIwcHVzaF90b19odWIlM0RUcnVlJTJDJTBBKSUwQSUwQXRyYWluZXIlMjAlM0QlMjBUcmFpbmVyKCUwQSUyMCUyMCUyMCUyMG1vZGVsJTNEbW9kZWwlMkMlMEElMjAlMjAlMjAlMjBhcmdzJTNEdHJhaW5pbmdfYXJncyUyQyUwQSUyMCUyMCUyMCUyMHRyYWluX2RhdGFzZXQlM0R0b2tlbml6ZWRfd251dCU1QiUyMnRyYWluJTIyJTVEJTJDJTBBJTIwJTIwJTIwJTIwZXZhbF9kYXRhc2V0JTNEdG9rZW5pemVkX3dudXQlNUIlMjJ0ZXN0JTIyJTVEJTJDJTBBJTIwJTIwJTIwJTIwdG9rZW5pemVyJTNEdG9rZW5pemVyJTJDJTBBJTIwJTIwJTIwJTIwZGF0YV9jb2xsYXRvciUzRGRhdGFfY29sbGF0b3IlMkMlMEElMjAlMjAlMjAlMjBjb21wdXRlX21ldHJpY3MlM0Rjb21wdXRlX21ldHJpY3MlMkMlMEEpJTBBJTBBdHJhaW5lci50cmFpbigp",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_wnut_model&quot;</span>,
<span class="hljs-meta">... </span>    learning_rate=<span class="hljs-number">2e-5</span>,
<span class="hljs-meta">... </span>    per_device_train_batch_size=<span class="hljs-number">16</span>,
<span class="hljs-meta">... </span>    per_device_eval_batch_size=<span class="hljs-number">16</span>,
<span class="hljs-meta">... </span>    num_train_epochs=<span class="hljs-number">2</span>,
<span class="hljs-meta">... </span>    weight_decay=<span class="hljs-number">0.01</span>,
<span class="hljs-meta">... </span>    eval_strategy=<span class="hljs-string">&quot;epoch&quot;</span>,
<span class="hljs-meta">... </span>    save_strategy=<span class="hljs-string">&quot;epoch&quot;</span>,
<span class="hljs-meta">... </span>    load_best_model_at_end=<span class="hljs-literal">True</span>,
<span class="hljs-meta">... </span>    push_to_hub=<span class="hljs-literal">True</span>,
<span class="hljs-meta">... </span>)

<span class="hljs-meta">&gt;&gt;&gt; </span>trainer = Trainer(
<span class="hljs-meta">... </span>    model=model,
<span class="hljs-meta">... </span>    args=training_args,
<span class="hljs-meta">... </span>    train_dataset=tokenized_wnut[<span class="hljs-string">&quot;train&quot;</span>],
<span class="hljs-meta">... </span>    eval_dataset=tokenized_wnut[<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}}),X=new k({props:{code:"dHJhaW5lci5wdXNoX3RvX2h1Yigp",highlighted:'<span class="hljs-meta">&gt;&gt;&gt; </span>trainer.push_to_hub()',wrap:!1}}),{c(){M(l.$$.fragment),c=i(),a=g("p"),a.innerHTML=m,w=i(),M(C.$$.fragment),A=i(),v=g("p"),v.textContent=I,G=i(),x=g("ol"),x.innerHTML=V,B=i(),M($.$$.fragment),W=i(),r=g("p"),r.innerHTML=U,E=i(),M(X.$$.fragment)},l(h){j(l.$$.fragment,h),c=o(h),a=b(h,"P",{"data-svelte-h":!0}),J(a)!=="svelte-1q03pfm"&&(a.innerHTML=m),w=o(h),j(C.$$.fragment,h),A=o(h),v=b(h,"P",{"data-svelte-h":!0}),J(v)!=="svelte-l42k0i"&&(v.textContent=I),G=o(h),x=b(h,"OL",{"data-svelte-h":!0}),J(x)!=="svelte-hgfza"&&(x.innerHTML=V),B=o(h),j($.$$.fragment,h),W=o(h),r=b(h,"P",{"data-svelte-h":!0}),J(r)!=="svelte-1wbze62"&&(r.innerHTML=U),E=o(h),j(X.$$.fragment,h)},m(h,Z){u(l,h,Z),e(h,c,Z),e(h,a,Z),e(h,w,Z),u(C,h,Z),e(h,A,Z),e(h,v,Z),e(h,G,Z),e(h,x,Z),e(h,B,Z),u($,h,Z),e(h,W,Z),e(h,r,Z),e(h,E,Z),u(X,h,Z),R=!0},p(h,Z){const F={};Z&2&&(F.$$scope={dirty:Z,ctx:h}),l.$set(F)},i(h){R||(d(l.$$.fragment,h),d(C.$$.fragment,h),d($.$$.fragment,h),d(X.$$.fragment,h),R=!0)},o(h){y(l.$$.fragment,h),y(C.$$.fragment,h),y($.$$.fragment,h),y(X.$$.fragment,h),R=!1},d(h){h&&(t(c),t(a),t(w),t(A),t(v),t(G),t(x),t(B),t(W),t(r),t(E)),f(l,h),f(C,h),f($,h),f(X,h)}}}function Ul(_){let l,c;return l=new Ls({props:{$$slots:{default:[Tl]},$$scope:{ctx:_}}}),{c(){M(l.$$.fragment)},l(a){j(l.$$.fragment,a)},m(a,m){u(l,a,m),c=!0},p(a,m){const w={};m&2&&(w.$$scope={dirty:m,ctx:a}),l.$set(w)},i(a){c||(d(l.$$.fragment,a),c=!0)},o(a){y(l.$$.fragment,a),c=!1},d(a){f(l,a)}}}function $l(_){let l,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(){l=g("p"),l.innerHTML=c},l(a){l=b(a,"P",{"data-svelte-h":!0}),J(l)!=="svelte-1rd4nl8"&&(l.innerHTML=c)},m(a,m){e(a,l,m)},p:os,d(a){a&&t(l)}}}function xl(_){let l,c,a,m,w,C='Then you can load DistilBERT with <a href="/docs/transformers/pr_31172/en/model_doc/auto#transformers.TFAutoModelForTokenClassification">TFAutoModelForTokenClassification</a> along with the number of expected labels, and the label mappings:',A,v,I,G,x='Convert your datasets to the <code>tf.data.Dataset</code> format with <a href="/docs/transformers/pr_31172/en/main_classes/model#transformers.TFPreTrainedModel.prepare_tf_dataset">prepare_tf_dataset()</a>:',V,B,$,W,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:',U,E,X,R,h='The last two things to setup before you start training is to compute the seqeval scores 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>.',Z,F,cs='Pass your <code>compute_metrics</code> function to <a href="/docs/transformers/pr_31172/en/main_classes/keras_callbacks#transformers.KerasMetricCallback">KerasMetricCallback</a>:',H,z,N,as,ms='Specify where to push your model and tokenizer in the <a href="/docs/transformers/pr_31172/en/main_classes/keras_callbacks#transformers.PushToHubCallback">PushToHubCallback</a>:',Q,Y,q,S,ls="Then bundle your callbacks together:",hs,L,D,P,ts='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:',Ms,K,O,ss,es="Once training is completed, your model is automatically uploaded to the Hub so everyone can use it!",js;return l=new Ba({props:{$$slots:{default:[$l]},$$scope:{ctx:_}}}),a=new k({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMGNyZWF0ZV9vcHRpbWl6ZXIlMEElMEFiYXRjaF9zaXplJTIwJTNEJTIwMTYlMEFudW1fdHJhaW5fZXBvY2hzJTIwJTNEJTIwMyUwQW51bV90cmFpbl9zdGVwcyUyMCUzRCUyMChsZW4odG9rZW5pemVkX3dudXQlNUIlMjJ0cmFpbiUyMiU1RCklMjAlMkYlMkYlMjBiYXRjaF9zaXplKSUyMColMjBudW1fdHJhaW5fZXBvY2hzJTBBb3B0aW1pemVyJTJDJTIwbHJfc2NoZWR1bGUlMjAlM0QlMjBjcmVhdGVfb3B0aW1pemVyKCUwQSUyMCUyMCUyMCUyMGluaXRfbHIlM0QyZS01JTJDJTBBJTIwJTIwJTIwJTIwbnVtX3RyYWluX3N0ZXBzJTNEbnVtX3RyYWluX3N0ZXBzJTJDJTBBJTIwJTIwJTIwJTIwd2VpZ2h0X2RlY2F5X3JhdGUlM0QwLjAxJTJDJTBBJTIwJTIwJTIwJTIwbnVtX3dhcm11cF9zdGVwcyUzRDAlMkMlMEEp",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>batch_size = <span class="hljs-number">16</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>num_train_epochs = <span class="hljs-number">3</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>num_train_steps = (<span class="hljs-built_in">len</span>(tokenized_wnut[<span class="hljs-string">&quot;train&quot;</span>]) // batch_size) * num_train_epochs
<span class="hljs-meta">&gt;&gt;&gt; </span>optimizer, lr_schedule = create_optimizer(
<span class="hljs-meta">... </span>    init_lr=<span class="hljs-number">2e-5</span>,
<span class="hljs-meta">... </span>    num_train_steps=num_train_steps,
<span class="hljs-meta">... </span>    weight_decay_rate=<span class="hljs-number">0.01</span>,
<span class="hljs-meta">... </span>    num_warmup_steps=<span class="hljs-number">0</span>,
<span class="hljs-meta">... </span>)`,wrap:!1}}),v=new k({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMFRGQXV0b01vZGVsRm9yVG9rZW5DbGFzc2lmaWNhdGlvbiUwQSUwQW1vZGVsJTIwJTNEJTIwVEZBdXRvTW9kZWxGb3JUb2tlbkNsYXNzaWZpY2F0aW9uLmZyb21fcHJldHJhaW5lZCglMEElMjAlMjAlMjAlMjAlMjJkaXN0aWxiZXJ0JTJGZGlzdGlsYmVydC1iYXNlLXVuY2FzZWQlMjIlMkMlMjBudW1fbGFiZWxzJTNEMTMlMkMlMjBpZDJsYWJlbCUzRGlkMmxhYmVsJTJDJTIwbGFiZWwyaWQlM0RsYWJlbDJpZCUwQSk=",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> TFAutoModelForTokenClassification

<span class="hljs-meta">&gt;&gt;&gt; </span>model = TFAutoModelForTokenClassification.from_pretrained(
<span class="hljs-meta">... </span>    <span class="hljs-string">&quot;distilbert/distilbert-base-uncased&quot;</span>, num_labels=<span class="hljs-number">13</span>, id2label=id2label, label2id=label2id
<span class="hljs-meta">... </span>)`,wrap:!1}}),B=new k({props:{code:"dGZfdHJhaW5fc2V0JTIwJTNEJTIwbW9kZWwucHJlcGFyZV90Zl9kYXRhc2V0KCUwQSUyMCUyMCUyMCUyMHRva2VuaXplZF93bnV0JTVCJTIydHJhaW4lMjIlNUQlMkMlMEElMjAlMjAlMjAlMjBzaHVmZmxlJTNEVHJ1ZSUyQyUwQSUyMCUyMCUyMCUyMGJhdGNoX3NpemUlM0QxNiUyQyUwQSUyMCUyMCUyMCUyMGNvbGxhdGVfZm4lM0RkYXRhX2NvbGxhdG9yJTJDJTBBKSUwQSUwQXRmX3ZhbGlkYXRpb25fc2V0JTIwJTNEJTIwbW9kZWwucHJlcGFyZV90Zl9kYXRhc2V0KCUwQSUyMCUyMCUyMCUyMHRva2VuaXplZF93bnV0JTVCJTIydmFsaWRhdGlvbiUyMiU1RCUyQyUwQSUyMCUyMCUyMCUyMHNodWZmbGUlM0RGYWxzZSUyQyUwQSUyMCUyMCUyMCUyMGJhdGNoX3NpemUlM0QxNiUyQyUwQSUyMCUyMCUyMCUyMGNvbGxhdGVfZm4lM0RkYXRhX2NvbGxhdG9yJTJDJTBBKQ==",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span>tf_train_set = model.prepare_tf_dataset(
<span class="hljs-meta">... </span>    tokenized_wnut[<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_wnut[<span class="hljs-string">&quot;validation&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}}),E=new k({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}}),z=new k({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}}),Y=new k({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycy5rZXJhc19jYWxsYmFja3MlMjBpbXBvcnQlMjBQdXNoVG9IdWJDYWxsYmFjayUwQSUwQXB1c2hfdG9faHViX2NhbGxiYWNrJTIwJTNEJTIwUHVzaFRvSHViQ2FsbGJhY2soJTBBJTIwJTIwJTIwJTIwb3V0cHV0X2RpciUzRCUyMm15X2F3ZXNvbWVfd251dF9tb2RlbCUyMiUyQyUwQSUyMCUyMCUyMCUyMHRva2VuaXplciUzRHRva2VuaXplciUyQyUwQSk=",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_wnut_model&quot;</span>,
<span class="hljs-meta">... </span>    tokenizer=tokenizer,
<span class="hljs-meta">... </span>)`,wrap:!1}}),L=new k({props:{code:"Y2FsbGJhY2tzJTIwJTNEJTIwJTVCbWV0cmljX2NhbGxiYWNrJTJDJTIwcHVzaF90b19odWJfY2FsbGJhY2slNUQ=",highlighted:'<span class="hljs-meta">&gt;&gt;&gt; </span>callbacks = [metric_callback, push_to_hub_callback]',wrap:!1}}),K=new k({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(){M(l.$$.fragment),c=Ml(`
To finetune a model in TensorFlow, start by setting up an optimizer function, learning rate schedule, and some training hyperparameters:

	`),M(a.$$.fragment),m=i(),w=g("p"),w.innerHTML=C,A=i(),M(v.$$.fragment),I=i(),G=g("p"),G.innerHTML=x,V=i(),M(B.$$.fragment),$=i(),W=g("p"),W.innerHTML=r,U=i(),M(E.$$.fragment),X=i(),R=g("p"),R.innerHTML=h,Z=i(),F=g("p"),F.innerHTML=cs,H=i(),M(z.$$.fragment),N=i(),as=g("p"),as.innerHTML=ms,Q=i(),M(Y.$$.fragment),q=i(),S=g("p"),S.textContent=ls,hs=i(),M(L.$$.fragment),D=i(),P=g("p"),P.innerHTML=ts,Ms=i(),M(K.$$.fragment),O=i(),ss=g("p"),ss.textContent=es},l(p){j(l.$$.fragment,p),c=jl(p,`
To finetune a model in TensorFlow, start by setting up an optimizer function, learning rate schedule, and some training hyperparameters:

	`),j(a.$$.fragment,p),m=o(p),w=b(p,"P",{"data-svelte-h":!0}),J(w)!=="svelte-rcs9cg"&&(w.innerHTML=C),A=o(p),j(v.$$.fragment,p),I=o(p),G=b(p,"P",{"data-svelte-h":!0}),J(G)!=="svelte-erpxg9"&&(G.innerHTML=x),V=o(p),j(B.$$.fragment,p),$=o(p),W=b(p,"P",{"data-svelte-h":!0}),J(W)!=="svelte-17cxx5e"&&(W.innerHTML=r),U=o(p),j(E.$$.fragment,p),X=o(p),R=b(p,"P",{"data-svelte-h":!0}),J(R)!=="svelte-nf8aa0"&&(R.innerHTML=h),Z=o(p),F=b(p,"P",{"data-svelte-h":!0}),J(F)!=="svelte-123ar69"&&(F.innerHTML=cs),H=o(p),j(z.$$.fragment,p),N=o(p),as=b(p,"P",{"data-svelte-h":!0}),J(as)!=="svelte-1nt46k9"&&(as.innerHTML=ms),Q=o(p),j(Y.$$.fragment,p),q=o(p),S=b(p,"P",{"data-svelte-h":!0}),J(S)!=="svelte-1lw9xm8"&&(S.textContent=ls),hs=o(p),j(L.$$.fragment,p),D=o(p),P=b(p,"P",{"data-svelte-h":!0}),J(P)!=="svelte-1hrpv1v"&&(P.innerHTML=ts),Ms=o(p),j(K.$$.fragment,p),O=o(p),ss=b(p,"P",{"data-svelte-h":!0}),J(ss)!=="svelte-2s71om"&&(ss.textContent=es)},m(p,T){u(l,p,T),e(p,c,T),u(a,p,T),e(p,m,T),e(p,w,T),e(p,A,T),u(v,p,T),e(p,I,T),e(p,G,T),e(p,V,T),u(B,p,T),e(p,$,T),e(p,W,T),e(p,U,T),u(E,p,T),e(p,X,T),e(p,R,T),e(p,Z,T),e(p,F,T),e(p,H,T),u(z,p,T),e(p,N,T),e(p,as,T),e(p,Q,T),u(Y,p,T),e(p,q,T),e(p,S,T),e(p,hs,T),u(L,p,T),e(p,D,T),e(p,P,T),e(p,Ms,T),u(K,p,T),e(p,O,T),e(p,ss,T),js=!0},p(p,T){const us={};T&2&&(us.$$scope={dirty:T,ctx:p}),l.$set(us)},i(p){js||(d(l.$$.fragment,p),d(a.$$.fragment,p),d(v.$$.fragment,p),d(B.$$.fragment,p),d(E.$$.fragment,p),d(z.$$.fragment,p),d(Y.$$.fragment,p),d(L.$$.fragment,p),d(K.$$.fragment,p),js=!0)},o(p){y(l.$$.fragment,p),y(a.$$.fragment,p),y(v.$$.fragment,p),y(B.$$.fragment,p),y(E.$$.fragment,p),y(z.$$.fragment,p),y(Y.$$.fragment,p),y(L.$$.fragment,p),y(K.$$.fragment,p),js=!1},d(p){p&&(t(c),t(m),t(w),t(A),t(I),t(G),t(V),t($),t(W),t(U),t(X),t(R),t(Z),t(F),t(H),t(N),t(as),t(Q),t(q),t(S),t(hs),t(D),t(P),t(Ms),t(O),t(ss)),f(l,p),f(a,p),f(v,p),f(B,p),f(E,p),f(z,p),f(Y,p),f(L,p),f(K,p)}}}function kl(_){let l,c;return l=new Ls({props:{$$slots:{default:[xl]},$$scope:{ctx:_}}}),{c(){M(l.$$.fragment)},l(a){j(l.$$.fragment,a)},m(a,m){u(l,a,m),c=!0},p(a,m){const w={};m&2&&(w.$$scope={dirty:m,ctx:a}),l.$set(w)},i(a){c||(d(l.$$.fragment,a),c=!0)},o(a){y(l.$$.fragment,a),c=!1},d(a){f(l,a)}}}function _l(_){let l,c=`For a more in-depth example of how to finetune a model for token classification, take a look at the corresponding
<a href="https://colab.research.google.com/github/huggingface/notebooks/blob/main/examples/token_classification.ipynb" rel="nofollow">PyTorch notebook</a>
or <a href="https://colab.research.google.com/github/huggingface/notebooks/blob/main/examples/token_classification-tf.ipynb" rel="nofollow">TensorFlow notebook</a>.`;return{c(){l=g("p"),l.innerHTML=c},l(a){l=b(a,"P",{"data-svelte-h":!0}),J(l)!=="svelte-j7j3qo"&&(l.innerHTML=c)},m(a,m){e(a,l,m)},p:os,d(a){a&&t(l)}}}function Cl(_){let l,c="Tokenize the text and return PyTorch tensors:",a,m,w,C,A="Pass your inputs to the model and return the <code>logits</code>:",v,I,G,x,V="Get the class with the highest probability, and use the model’s <code>id2label</code> mapping to convert it to a text label:",B,$,W;return m=new k({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMEF1dG9Ub2tlbml6ZXIlMEElMEF0b2tlbml6ZXIlMjAlM0QlMjBBdXRvVG9rZW5pemVyLmZyb21fcHJldHJhaW5lZCglMjJzdGV2aGxpdSUyRm15X2F3ZXNvbWVfd251dF9tb2RlbCUyMiklMEFpbnB1dHMlMjAlM0QlMjB0b2tlbml6ZXIodGV4dCUyQyUyMHJldHVybl90ZW5zb3JzJTNEJTIycHQlMjIp",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_wnut_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}}),I=new k({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMEF1dG9Nb2RlbEZvclRva2VuQ2xhc3NpZmljYXRpb24lMEElMEFtb2RlbCUyMCUzRCUyMEF1dG9Nb2RlbEZvclRva2VuQ2xhc3NpZmljYXRpb24uZnJvbV9wcmV0cmFpbmVkKCUyMnN0ZXZobGl1JTJGbXlfYXdlc29tZV93bnV0X21vZGVsJTIyKSUwQXdpdGglMjB0b3JjaC5ub19ncmFkKCklM0ElMEElMjAlMjAlMjAlMjBsb2dpdHMlMjAlM0QlMjBtb2RlbCgqKmlucHV0cykubG9naXRz",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoModelForTokenClassification

<span class="hljs-meta">&gt;&gt;&gt; </span>model = AutoModelForTokenClassification.from_pretrained(<span class="hljs-string">&quot;stevhliu/my_awesome_wnut_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}}),$=new k({props:{code:"cHJlZGljdGlvbnMlMjAlM0QlMjB0b3JjaC5hcmdtYXgobG9naXRzJTJDJTIwZGltJTNEMiklMEFwcmVkaWN0ZWRfdG9rZW5fY2xhc3MlMjAlM0QlMjAlNUJtb2RlbC5jb25maWcuaWQybGFiZWwlNUJ0Lml0ZW0oKSU1RCUyMGZvciUyMHQlMjBpbiUyMHByZWRpY3Rpb25zJTVCMCU1RCU1RCUwQXByZWRpY3RlZF90b2tlbl9jbGFzcw==",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span>predictions = torch.argmax(logits, dim=<span class="hljs-number">2</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>predicted_token_class = [model.config.id2label[t.item()] <span class="hljs-keyword">for</span> t <span class="hljs-keyword">in</span> predictions[<span class="hljs-number">0</span>]]
<span class="hljs-meta">&gt;&gt;&gt; </span>predicted_token_class
[<span class="hljs-string">&#x27;O&#x27;</span>,
 <span class="hljs-string">&#x27;O&#x27;</span>,
 <span class="hljs-string">&#x27;B-location&#x27;</span>,
 <span class="hljs-string">&#x27;I-location&#x27;</span>,
 <span class="hljs-string">&#x27;B-group&#x27;</span>,
 <span class="hljs-string">&#x27;O&#x27;</span>,
 <span class="hljs-string">&#x27;O&#x27;</span>,
 <span class="hljs-string">&#x27;O&#x27;</span>,
 <span class="hljs-string">&#x27;O&#x27;</span>,
 <span class="hljs-string">&#x27;O&#x27;</span>,
 <span class="hljs-string">&#x27;O&#x27;</span>,
 <span class="hljs-string">&#x27;O&#x27;</span>,
 <span class="hljs-string">&#x27;O&#x27;</span>,
 <span class="hljs-string">&#x27;B-location&#x27;</span>,
 <span class="hljs-string">&#x27;B-location&#x27;</span>,
 <span class="hljs-string">&#x27;O&#x27;</span>,
 <span class="hljs-string">&#x27;O&#x27;</span>]`,wrap:!1}}),{c(){l=g("p"),l.textContent=c,a=i(),M(m.$$.fragment),w=i(),C=g("p"),C.innerHTML=A,v=i(),M(I.$$.fragment),G=i(),x=g("p"),x.innerHTML=V,B=i(),M($.$$.fragment)},l(r){l=b(r,"P",{"data-svelte-h":!0}),J(l)!=="svelte-1qcz1wr"&&(l.textContent=c),a=o(r),j(m.$$.fragment,r),w=o(r),C=b(r,"P",{"data-svelte-h":!0}),J(C)!=="svelte-f3g043"&&(C.innerHTML=A),v=o(r),j(I.$$.fragment,r),G=o(r),x=b(r,"P",{"data-svelte-h":!0}),J(x)!=="svelte-6mgrol"&&(x.innerHTML=V),B=o(r),j($.$$.fragment,r)},m(r,U){e(r,l,U),e(r,a,U),u(m,r,U),e(r,w,U),e(r,C,U),e(r,v,U),u(I,r,U),e(r,G,U),e(r,x,U),e(r,B,U),u($,r,U),W=!0},p:os,i(r){W||(d(m.$$.fragment,r),d(I.$$.fragment,r),d($.$$.fragment,r),W=!0)},o(r){y(m.$$.fragment,r),y(I.$$.fragment,r),y($.$$.fragment,r),W=!1},d(r){r&&(t(l),t(a),t(w),t(C),t(v),t(G),t(x),t(B)),f(m,r),f(I,r),f($,r)}}}function Il(_){let l,c;return l=new Ls({props:{$$slots:{default:[Cl]},$$scope:{ctx:_}}}),{c(){M(l.$$.fragment)},l(a){j(l.$$.fragment,a)},m(a,m){u(l,a,m),c=!0},p(a,m){const w={};m&2&&(w.$$scope={dirty:m,ctx:a}),l.$set(w)},i(a){c||(d(l.$$.fragment,a),c=!0)},o(a){y(l.$$.fragment,a),c=!1},d(a){f(l,a)}}}function Zl(_){let l,c="Tokenize the text and return TensorFlow tensors:",a,m,w,C,A="Pass your inputs to the model and return the <code>logits</code>:",v,I,G,x,V="Get the class with the highest probability, and use the model’s <code>id2label</code> mapping to convert it to a text label:",B,$,W;return m=new k({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMEF1dG9Ub2tlbml6ZXIlMEElMEF0b2tlbml6ZXIlMjAlM0QlMjBBdXRvVG9rZW5pemVyLmZyb21fcHJldHJhaW5lZCglMjJzdGV2aGxpdSUyRm15X2F3ZXNvbWVfd251dF9tb2RlbCUyMiklMEFpbnB1dHMlMjAlM0QlMjB0b2tlbml6ZXIodGV4dCUyQyUyMHJldHVybl90ZW5zb3JzJTNEJTIydGYlMjIp",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_wnut_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}}),I=new k({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMFRGQXV0b01vZGVsRm9yVG9rZW5DbGFzc2lmaWNhdGlvbiUwQSUwQW1vZGVsJTIwJTNEJTIwVEZBdXRvTW9kZWxGb3JUb2tlbkNsYXNzaWZpY2F0aW9uLmZyb21fcHJldHJhaW5lZCglMjJzdGV2aGxpdSUyRm15X2F3ZXNvbWVfd251dF9tb2RlbCUyMiklMEFsb2dpdHMlMjAlM0QlMjBtb2RlbCgqKmlucHV0cykubG9naXRz",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> TFAutoModelForTokenClassification

<span class="hljs-meta">&gt;&gt;&gt; </span>model = TFAutoModelForTokenClassification.from_pretrained(<span class="hljs-string">&quot;stevhliu/my_awesome_wnut_model&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>logits = model(**inputs).logits`,wrap:!1}}),$=new k({props:{code:"cHJlZGljdGVkX3Rva2VuX2NsYXNzX2lkcyUyMCUzRCUyMHRmLm1hdGguYXJnbWF4KGxvZ2l0cyUyQyUyMGF4aXMlM0QtMSklMEFwcmVkaWN0ZWRfdG9rZW5fY2xhc3MlMjAlM0QlMjAlNUJtb2RlbC5jb25maWcuaWQybGFiZWwlNUJ0JTVEJTIwZm9yJTIwdCUyMGluJTIwcHJlZGljdGVkX3Rva2VuX2NsYXNzX2lkcyU1QjAlNUQubnVtcHkoKS50b2xpc3QoKSU1RCUwQXByZWRpY3RlZF90b2tlbl9jbGFzcw==",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span>predicted_token_class_ids = tf.math.argmax(logits, axis=-<span class="hljs-number">1</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>predicted_token_class = [model.config.id2label[t] <span class="hljs-keyword">for</span> t <span class="hljs-keyword">in</span> predicted_token_class_ids[<span class="hljs-number">0</span>].numpy().tolist()]
<span class="hljs-meta">&gt;&gt;&gt; </span>predicted_token_class
[<span class="hljs-string">&#x27;O&#x27;</span>,
 <span class="hljs-string">&#x27;O&#x27;</span>,
 <span class="hljs-string">&#x27;B-location&#x27;</span>,
 <span class="hljs-string">&#x27;I-location&#x27;</span>,
 <span class="hljs-string">&#x27;B-group&#x27;</span>,
 <span class="hljs-string">&#x27;O&#x27;</span>,
 <span class="hljs-string">&#x27;O&#x27;</span>,
 <span class="hljs-string">&#x27;O&#x27;</span>,
 <span class="hljs-string">&#x27;O&#x27;</span>,
 <span class="hljs-string">&#x27;O&#x27;</span>,
 <span class="hljs-string">&#x27;O&#x27;</span>,
 <span class="hljs-string">&#x27;O&#x27;</span>,
 <span class="hljs-string">&#x27;O&#x27;</span>,
 <span class="hljs-string">&#x27;B-location&#x27;</span>,
 <span class="hljs-string">&#x27;B-location&#x27;</span>,
 <span class="hljs-string">&#x27;O&#x27;</span>,
 <span class="hljs-string">&#x27;O&#x27;</span>]`,wrap:!1}}),{c(){l=g("p"),l.textContent=c,a=i(),M(m.$$.fragment),w=i(),C=g("p"),C.innerHTML=A,v=i(),M(I.$$.fragment),G=i(),x=g("p"),x.innerHTML=V,B=i(),M($.$$.fragment)},l(r){l=b(r,"P",{"data-svelte-h":!0}),J(l)!=="svelte-s1qr7b"&&(l.textContent=c),a=o(r),j(m.$$.fragment,r),w=o(r),C=b(r,"P",{"data-svelte-h":!0}),J(C)!=="svelte-f3g043"&&(C.innerHTML=A),v=o(r),j(I.$$.fragment,r),G=o(r),x=b(r,"P",{"data-svelte-h":!0}),J(x)!=="svelte-6mgrol"&&(x.innerHTML=V),B=o(r),j($.$$.fragment,r)},m(r,U){e(r,l,U),e(r,a,U),u(m,r,U),e(r,w,U),e(r,C,U),e(r,v,U),u(I,r,U),e(r,G,U),e(r,x,U),e(r,B,U),u($,r,U),W=!0},p:os,i(r){W||(d(m.$$.fragment,r),d(I.$$.fragment,r),d($.$$.fragment,r),W=!0)},o(r){y(m.$$.fragment,r),y(I.$$.fragment,r),y($.$$.fragment,r),W=!1},d(r){r&&(t(l),t(a),t(w),t(C),t(v),t(G),t(x),t(B)),f(m,r),f(I,r),f($,r)}}}function vl(_){let l,c;return l=new Ls({props:{$$slots:{default:[Zl]},$$scope:{ctx:_}}}),{c(){M(l.$$.fragment)},l(a){j(l.$$.fragment,a)},m(a,m){u(l,a,m),c=!0},p(a,m){const w={};m&2&&(w.$$scope={dirty:m,ctx:a}),l.$set(w)},i(a){c||(d(l.$$.fragment,a),c=!0)},o(a){y(l.$$.fragment,a),c=!1},d(a){f(l,a)}}}function Gl(_){let l,c,a,m,w,C,A,v,I,G,x,V="Token classification assigns a label to individual tokens in a sentence. One of the most common token classification tasks is Named Entity Recognition (NER). NER attempts to find a label for each entity in a sentence, such as a person, location, or organization.",B,$,W="This guide will show you how to:",r,U,E='<li>Finetune <a href="https://huggingface.co/distilbert/distilbert-base-uncased" rel="nofollow">DistilBERT</a> on the <a href="https://huggingface.co/datasets/wnut_17" rel="nofollow">WNUT 17</a> dataset to detect new entities.</li> <li>Use your finetuned model for inference.</li>',X,R,h,Z,F="Before you begin, make sure you have all the necessary libraries installed:",cs,H,z,N,as="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:",ms,Q,Y,q,S,ls,hs="Start by loading the WNUT 17 dataset from the 🤗 Datasets library:",L,D,P,ts,Ms="Then take a look at an example:",K,O,ss,es,js="Each number in <code>ner_tags</code> represents an entity. Convert the numbers to their label names to find out what the entities are:",p,T,us,ds,Aa="The letter that prefixes each <code>ner_tag</code> indicates the token position of the entity:",Ps,ys,Ra=`<li><code>B-</code> indicates the beginning of an entity.</li> <li><code>I-</code> indicates a token is contained inside the same entity (for example, the <code>State</code> token is a part of an entity like
<code>Empire State Building</code>).</li> <li><code>0</code> indicates the token doesn’t correspond to any entity.</li>`,Ks,fs,Os,gs,sa,bs,Xa="The next step is to load a DistilBERT tokenizer to preprocess the <code>tokens</code> field:",aa,ws,la,Js,Va="As you saw in the example <code>tokens</code> field above, it looks like the input has already been tokenized. But the input actually hasn’t been tokenized yet and you’ll need to set <code>is_split_into_words=True</code> to tokenize the words into subwords. For example:",ta,Ts,ea,Us,Ea="However, this adds some special tokens <code>[CLS]</code> and <code>[SEP]</code> and the subword tokenization creates a mismatch between the input and labels. A single word corresponding to a single label may now be split into two subwords. You’ll need to realign the tokens and labels by:",na,$s,Fa='<li>Mapping all tokens to their corresponding word with the <a href="https://huggingface.co/docs/transformers/main_classes/tokenizer#transformers.BatchEncoding.word_ids" rel="nofollow"><code>word_ids</code></a> method.</li> <li>Assigning the label <code>-100</code> to the special tokens <code>[CLS]</code> and <code>[SEP]</code> so they’re ignored by the PyTorch loss function (see <a href="https://pytorch.org/docs/stable/generated/torch.nn.CrossEntropyLoss.html" rel="nofollow">CrossEntropyLoss</a>).</li> <li>Only labeling the first token of a given word. Assign <code>-100</code> to other subtokens from the same word.</li>',pa,xs,Ha="Here is how you can create a function to realign the tokens and labels, and truncate sequences to be no longer than DistilBERT’s maximum input length:",ra,ks,ia,_s,za='To apply the preprocessing function over the entire dataset, use 🤗 Datasets <a href="https://huggingface.co/docs/datasets/main/en/package_reference/main_classes#datasets.Dataset.map" rel="nofollow">map</a> function. You can speed up the <code>map</code> function by setting <code>batched=True</code> to process multiple elements of the dataset at once:',oa,Cs,ca,Is,Na='Now create a batch of examples using <a href="/docs/transformers/pr_31172/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.',ma,ns,ha,Zs,Ma,vs,Qa='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/seqeval" rel="nofollow">seqeval</a> framework (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). Seqeval actually produces several scores: precision, recall, F1, and accuracy.',ja,Gs,ua,Bs,Ya='Get the NER labels first, and then create a function that passes your true predictions and true labels to <a href="https://huggingface.co/docs/evaluate/main/en/package_reference/main_classes#evaluate.EvaluationModule.compute" rel="nofollow">compute</a> to calculate the scores:',da,Ws,ya,As,qa="Your <code>compute_metrics</code> function is ready to go now, and you’ll return to it when you setup your training.",fa,Rs,ga,Xs,Sa="Before you start training your model, create a map of the expected ids to their labels with <code>id2label</code> and <code>label2id</code>:",ba,Vs,wa,ps,Ja,rs,Ta,Es,Ua,Fs,La="Great, now that you’ve finetuned a model, you can use it for inference!",$a,Hs,Da="Grab some text you’d like to run inference on:",xa,zs,ka,Ns,Pa='The simplest way to try out your finetuned model for inference is to use it in a <a href="/docs/transformers/pr_31172/en/main_classes/pipelines#transformers.pipeline">pipeline()</a>. Instantiate a <code>pipeline</code> for NER with your model, and pass your text to it:',_a,Qs,Ca,Ys,Ka="You can also manually replicate the results of the <code>pipeline</code> if you’d like:",Ia,is,Za,qs,va,Ds,Ga;return w=new Ss({props:{title:"Token classification",local:"token-classification",headingTag:"h1"}}),A=new ul({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/token_classification.ipynb"},{label:"PyTorch",value:"https://colab.research.google.com/github/huggingface/notebooks/blob/main/transformers_doc/en/pytorch/token_classification.ipynb"},{label:"TensorFlow",value:"https://colab.research.google.com/github/huggingface/notebooks/blob/main/transformers_doc/en/tensorflow/token_classification.ipynb"},{label:"Mixed",value:"https://studiolab.sagemaker.aws/import/github/huggingface/notebooks/blob/main/transformers_doc/en/token_classification.ipynb"},{label:"PyTorch",value:"https://studiolab.sagemaker.aws/import/github/huggingface/notebooks/blob/main/transformers_doc/en/pytorch/token_classification.ipynb"},{label:"TensorFlow",value:"https://studiolab.sagemaker.aws/import/github/huggingface/notebooks/blob/main/transformers_doc/en/tensorflow/token_classification.ipynb"}]}}),I=new pl({props:{id:"wVHdVlPScxA"}}),R=new Ba({props:{$$slots:{default:[yl]},$$scope:{ctx:_}}}),H=new k({props:{code:"cGlwJTIwaW5zdGFsbCUyMHRyYW5zZm9ybWVycyUyMGRhdGFzZXRzJTIwZXZhbHVhdGUlMjBzZXFldmFs",highlighted:"pip install transformers datasets evaluate seqeval",wrap:!1}}),Q=new k({props:{code:"ZnJvbSUyMGh1Z2dpbmdmYWNlX2h1YiUyMGltcG9ydCUyMG5vdGVib29rX2xvZ2luJTBBJTBBbm90ZWJvb2tfbG9naW4oKQ==",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> huggingface_hub <span class="hljs-keyword">import</span> notebook_login

<span class="hljs-meta">&gt;&gt;&gt; </span>notebook_login()`,wrap:!1}}),q=new Ss({props:{title:"Load WNUT 17 dataset",local:"load-wnut-17-dataset",headingTag:"h2"}}),D=new k({props:{code:"ZnJvbSUyMGRhdGFzZXRzJTIwaW1wb3J0JTIwbG9hZF9kYXRhc2V0JTBBJTBBd251dCUyMCUzRCUyMGxvYWRfZGF0YXNldCglMjJ3bnV0XzE3JTIyKQ==",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>wnut = load_dataset(<span class="hljs-string">&quot;wnut_17&quot;</span>)`,wrap:!1}}),O=new k({props:{code:"d251dCU1QiUyMnRyYWluJTIyJTVEJTVCMCU1RA==",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span>wnut[<span class="hljs-string">&quot;train&quot;</span>][<span class="hljs-number">0</span>]
{<span class="hljs-string">&#x27;id&#x27;</span>: <span class="hljs-string">&#x27;0&#x27;</span>,
 <span class="hljs-string">&#x27;ner_tags&#x27;</span>: [<span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">7</span>, <span class="hljs-number">8</span>, <span class="hljs-number">8</span>, <span class="hljs-number">0</span>, <span class="hljs-number">7</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>],
 <span class="hljs-string">&#x27;tokens&#x27;</span>: [<span class="hljs-string">&#x27;@paulwalk&#x27;</span>, <span class="hljs-string">&#x27;It&#x27;</span>, <span class="hljs-string">&quot;&#x27;s&quot;</span>, <span class="hljs-string">&#x27;the&#x27;</span>, <span class="hljs-string">&#x27;view&#x27;</span>, <span class="hljs-string">&#x27;from&#x27;</span>, <span class="hljs-string">&#x27;where&#x27;</span>, <span class="hljs-string">&#x27;I&#x27;</span>, <span class="hljs-string">&quot;&#x27;m&quot;</span>, <span class="hljs-string">&#x27;living&#x27;</span>, <span class="hljs-string">&#x27;for&#x27;</span>, <span class="hljs-string">&#x27;two&#x27;</span>, <span class="hljs-string">&#x27;weeks&#x27;</span>, <span class="hljs-string">&#x27;.&#x27;</span>, <span class="hljs-string">&#x27;Empire&#x27;</span>, <span class="hljs-string">&#x27;State&#x27;</span>, <span class="hljs-string">&#x27;Building&#x27;</span>, <span class="hljs-string">&#x27;=&#x27;</span>, <span class="hljs-string">&#x27;ESB&#x27;</span>, <span class="hljs-string">&#x27;.&#x27;</span>, <span class="hljs-string">&#x27;Pretty&#x27;</span>, <span class="hljs-string">&#x27;bad&#x27;</span>, <span class="hljs-string">&#x27;storm&#x27;</span>, <span class="hljs-string">&#x27;here&#x27;</span>, <span class="hljs-string">&#x27;last&#x27;</span>, <span class="hljs-string">&#x27;evening&#x27;</span>, <span class="hljs-string">&#x27;.&#x27;</span>]
}`,wrap:!1}}),T=new k({props:{code:"bGFiZWxfbGlzdCUyMCUzRCUyMHdudXQlNUIlMjJ0cmFpbiUyMiU1RC5mZWF0dXJlcyU1QmYlMjJuZXJfdGFncyUyMiU1RC5mZWF0dXJlLm5hbWVzJTBBbGFiZWxfbGlzdA==",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span>label_list = wnut[<span class="hljs-string">&quot;train&quot;</span>].features[<span class="hljs-string">f&quot;ner_tags&quot;</span>].feature.names
<span class="hljs-meta">&gt;&gt;&gt; </span>label_list
[
    <span class="hljs-string">&quot;O&quot;</span>,
    <span class="hljs-string">&quot;B-corporation&quot;</span>,
    <span class="hljs-string">&quot;I-corporation&quot;</span>,
    <span class="hljs-string">&quot;B-creative-work&quot;</span>,
    <span class="hljs-string">&quot;I-creative-work&quot;</span>,
    <span class="hljs-string">&quot;B-group&quot;</span>,
    <span class="hljs-string">&quot;I-group&quot;</span>,
    <span class="hljs-string">&quot;B-location&quot;</span>,
    <span class="hljs-string">&quot;I-location&quot;</span>,
    <span class="hljs-string">&quot;B-person&quot;</span>,
    <span class="hljs-string">&quot;I-person&quot;</span>,
    <span class="hljs-string">&quot;B-product&quot;</span>,
    <span class="hljs-string">&quot;I-product&quot;</span>,
]`,wrap:!1}}),fs=new Ss({props:{title:"Preprocess",local:"preprocess",headingTag:"h2"}}),gs=new pl({props:{id:"iY2AZYdZAr0"}}),ws=new k({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMEF1dG9Ub2tlbml6ZXIlMEElMEF0b2tlbml6ZXIlMjAlM0QlMjBBdXRvVG9rZW5pemVyLmZyb21fcHJldHJhaW5lZCglMjJkaXN0aWxiZXJ0JTJGZGlzdGlsYmVydC1iYXNlLXVuY2FzZWQlMjIp",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoTokenizer

<span class="hljs-meta">&gt;&gt;&gt; </span>tokenizer = AutoTokenizer.from_pretrained(<span class="hljs-string">&quot;distilbert/distilbert-base-uncased&quot;</span>)`,wrap:!1}}),Ts=new k({props:{code:"ZXhhbXBsZSUyMCUzRCUyMHdudXQlNUIlMjJ0cmFpbiUyMiU1RCU1QjAlNUQlMEF0b2tlbml6ZWRfaW5wdXQlMjAlM0QlMjB0b2tlbml6ZXIoZXhhbXBsZSU1QiUyMnRva2VucyUyMiU1RCUyQyUyMGlzX3NwbGl0X2ludG9fd29yZHMlM0RUcnVlKSUwQXRva2VucyUyMCUzRCUyMHRva2VuaXplci5jb252ZXJ0X2lkc190b190b2tlbnModG9rZW5pemVkX2lucHV0JTVCJTIyaW5wdXRfaWRzJTIyJTVEKSUwQXRva2Vucw==",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span>example = wnut[<span class="hljs-string">&quot;train&quot;</span>][<span class="hljs-number">0</span>]
<span class="hljs-meta">&gt;&gt;&gt; </span>tokenized_input = tokenizer(example[<span class="hljs-string">&quot;tokens&quot;</span>], is_split_into_words=<span class="hljs-literal">True</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>tokens = tokenizer.convert_ids_to_tokens(tokenized_input[<span class="hljs-string">&quot;input_ids&quot;</span>])
<span class="hljs-meta">&gt;&gt;&gt; </span>tokens
[<span class="hljs-string">&#x27;[CLS]&#x27;</span>, <span class="hljs-string">&#x27;@&#x27;</span>, <span class="hljs-string">&#x27;paul&#x27;</span>, <span class="hljs-string">&#x27;##walk&#x27;</span>, <span class="hljs-string">&#x27;it&#x27;</span>, <span class="hljs-string">&quot;&#x27;&quot;</span>, <span class="hljs-string">&#x27;s&#x27;</span>, <span class="hljs-string">&#x27;the&#x27;</span>, <span class="hljs-string">&#x27;view&#x27;</span>, <span class="hljs-string">&#x27;from&#x27;</span>, <span class="hljs-string">&#x27;where&#x27;</span>, <span class="hljs-string">&#x27;i&#x27;</span>, <span class="hljs-string">&quot;&#x27;&quot;</span>, <span class="hljs-string">&#x27;m&#x27;</span>, <span class="hljs-string">&#x27;living&#x27;</span>, <span class="hljs-string">&#x27;for&#x27;</span>, <span class="hljs-string">&#x27;two&#x27;</span>, <span class="hljs-string">&#x27;weeks&#x27;</span>, <span class="hljs-string">&#x27;.&#x27;</span>, <span class="hljs-string">&#x27;empire&#x27;</span>, <span class="hljs-string">&#x27;state&#x27;</span>, <span class="hljs-string">&#x27;building&#x27;</span>, <span class="hljs-string">&#x27;=&#x27;</span>, <span class="hljs-string">&#x27;es&#x27;</span>, <span class="hljs-string">&#x27;##b&#x27;</span>, <span class="hljs-string">&#x27;.&#x27;</span>, <span class="hljs-string">&#x27;pretty&#x27;</span>, <span class="hljs-string">&#x27;bad&#x27;</span>, <span class="hljs-string">&#x27;storm&#x27;</span>, <span class="hljs-string">&#x27;here&#x27;</span>, <span class="hljs-string">&#x27;last&#x27;</span>, <span class="hljs-string">&#x27;evening&#x27;</span>, <span class="hljs-string">&#x27;.&#x27;</span>, <span class="hljs-string">&#x27;[SEP]&#x27;</span>]`,wrap:!1}}),ks=new k({props:{code:"ZGVmJTIwdG9rZW5pemVfYW5kX2FsaWduX2xhYmVscyhleGFtcGxlcyklM0ElMEElMjAlMjAlMjAlMjB0b2tlbml6ZWRfaW5wdXRzJTIwJTNEJTIwdG9rZW5pemVyKGV4YW1wbGVzJTVCJTIydG9rZW5zJTIyJTVEJTJDJTIwdHJ1bmNhdGlvbiUzRFRydWUlMkMlMjBpc19zcGxpdF9pbnRvX3dvcmRzJTNEVHJ1ZSklMEElMEElMjAlMjAlMjAlMjBsYWJlbHMlMjAlM0QlMjAlNUIlNUQlMEElMjAlMjAlMjAlMjBmb3IlMjBpJTJDJTIwbGFiZWwlMjBpbiUyMGVudW1lcmF0ZShleGFtcGxlcyU1QmYlMjJuZXJfdGFncyUyMiU1RCklM0ElMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjB3b3JkX2lkcyUyMCUzRCUyMHRva2VuaXplZF9pbnB1dHMud29yZF9pZHMoYmF0Y2hfaW5kZXglM0RpKSUyMCUyMCUyMyUyME1hcCUyMHRva2VucyUyMHRvJTIwdGhlaXIlMjByZXNwZWN0aXZlJTIwd29yZC4lMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjBwcmV2aW91c193b3JkX2lkeCUyMCUzRCUyME5vbmUlMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjBsYWJlbF9pZHMlMjAlM0QlMjAlNUIlNUQlMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjBmb3IlMjB3b3JkX2lkeCUyMGluJTIwd29yZF9pZHMlM0ElMjAlMjAlMjMlMjBTZXQlMjB0aGUlMjBzcGVjaWFsJTIwdG9rZW5zJTIwdG8lMjAtMTAwLiUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMGlmJTIwd29yZF9pZHglMjBpcyUyME5vbmUlM0ElMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjBsYWJlbF9pZHMuYXBwZW5kKC0xMDApJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwZWxpZiUyMHdvcmRfaWR4JTIwISUzRCUyMHByZXZpb3VzX3dvcmRfaWR4JTNBJTIwJTIwJTIzJTIwT25seSUyMGxhYmVsJTIwdGhlJTIwZmlyc3QlMjB0b2tlbiUyMG9mJTIwYSUyMGdpdmVuJTIwd29yZC4lMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjBsYWJlbF9pZHMuYXBwZW5kKGxhYmVsJTVCd29yZF9pZHglNUQpJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwZWxzZSUzQSUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMGxhYmVsX2lkcy5hcHBlbmQoLTEwMCklMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjBwcmV2aW91c193b3JkX2lkeCUyMCUzRCUyMHdvcmRfaWR4JTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwbGFiZWxzLmFwcGVuZChsYWJlbF9pZHMpJTBBJTBBJTIwJTIwJTIwJTIwdG9rZW5pemVkX2lucHV0cyU1QiUyMmxhYmVscyUyMiU1RCUyMCUzRCUyMGxhYmVscyUwQSUyMCUyMCUyMCUyMHJldHVybiUyMHRva2VuaXplZF9pbnB1dHM=",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">def</span> <span class="hljs-title function_">tokenize_and_align_labels</span>(<span class="hljs-params">examples</span>):
<span class="hljs-meta">... </span>    tokenized_inputs = tokenizer(examples[<span class="hljs-string">&quot;tokens&quot;</span>], truncation=<span class="hljs-literal">True</span>, is_split_into_words=<span class="hljs-literal">True</span>)

<span class="hljs-meta">... </span>    labels = []
<span class="hljs-meta">... </span>    <span class="hljs-keyword">for</span> i, label <span class="hljs-keyword">in</span> <span class="hljs-built_in">enumerate</span>(examples[<span class="hljs-string">f&quot;ner_tags&quot;</span>]):
<span class="hljs-meta">... </span>        word_ids = tokenized_inputs.word_ids(batch_index=i)  <span class="hljs-comment"># Map tokens to their respective word.</span>
<span class="hljs-meta">... </span>        previous_word_idx = <span class="hljs-literal">None</span>
<span class="hljs-meta">... </span>        label_ids = []
<span class="hljs-meta">... </span>        <span class="hljs-keyword">for</span> word_idx <span class="hljs-keyword">in</span> word_ids:  <span class="hljs-comment"># Set the special tokens to -100.</span>
<span class="hljs-meta">... </span>            <span class="hljs-keyword">if</span> word_idx <span class="hljs-keyword">is</span> <span class="hljs-literal">None</span>:
<span class="hljs-meta">... </span>                label_ids.append(-<span class="hljs-number">100</span>)
<span class="hljs-meta">... </span>            <span class="hljs-keyword">elif</span> word_idx != previous_word_idx:  <span class="hljs-comment"># Only label the first token of a given word.</span>
<span class="hljs-meta">... </span>                label_ids.append(label[word_idx])
<span class="hljs-meta">... </span>            <span class="hljs-keyword">else</span>:
<span class="hljs-meta">... </span>                label_ids.append(-<span class="hljs-number">100</span>)
<span class="hljs-meta">... </span>            previous_word_idx = word_idx
<span class="hljs-meta">... </span>        labels.append(label_ids)

<span class="hljs-meta">... </span>    tokenized_inputs[<span class="hljs-string">&quot;labels&quot;</span>] = labels
<span class="hljs-meta">... </span>    <span class="hljs-keyword">return</span> tokenized_inputs`,wrap:!1}}),Cs=new k({props:{code:"dG9rZW5pemVkX3dudXQlMjAlM0QlMjB3bnV0Lm1hcCh0b2tlbml6ZV9hbmRfYWxpZ25fbGFiZWxzJTJDJTIwYmF0Y2hlZCUzRFRydWUp",highlighted:'<span class="hljs-meta">&gt;&gt;&gt; </span>tokenized_wnut = wnut.<span class="hljs-built_in">map</span>(tokenize_and_align_labels, batched=<span class="hljs-literal">True</span>)',wrap:!1}}),ns=new Wa({props:{pytorch:!0,tensorflow:!0,jax:!1,$$slots:{tensorflow:[wl],pytorch:[gl]},$$scope:{ctx:_}}}),Zs=new Ss({props:{title:"Evaluate",local:"evaluate",headingTag:"h2"}}),Gs=new k({props:{code:"aW1wb3J0JTIwZXZhbHVhdGUlMEElMEFzZXFldmFsJTIwJTNEJTIwZXZhbHVhdGUubG9hZCglMjJzZXFldmFsJTIyKQ==",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">import</span> evaluate

<span class="hljs-meta">&gt;&gt;&gt; </span>seqeval = evaluate.load(<span class="hljs-string">&quot;seqeval&quot;</span>)`,wrap:!1}}),Ws=new k({props:{code:"aW1wb3J0JTIwbnVtcHklMjBhcyUyMG5wJTBBJTBBbGFiZWxzJTIwJTNEJTIwJTVCbGFiZWxfbGlzdCU1QmklNUQlMjBmb3IlMjBpJTIwaW4lMjBleGFtcGxlJTVCZiUyMm5lcl90YWdzJTIyJTVEJTVEJTBBJTBBJTBBZGVmJTIwY29tcHV0ZV9tZXRyaWNzKHApJTNBJTBBJTIwJTIwJTIwJTIwcHJlZGljdGlvbnMlMkMlMjBsYWJlbHMlMjAlM0QlMjBwJTBBJTIwJTIwJTIwJTIwcHJlZGljdGlvbnMlMjAlM0QlMjBucC5hcmdtYXgocHJlZGljdGlvbnMlMkMlMjBheGlzJTNEMiklMEElMEElMjAlMjAlMjAlMjB0cnVlX3ByZWRpY3Rpb25zJTIwJTNEJTIwJTVCJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTVCbGFiZWxfbGlzdCU1QnAlNUQlMjBmb3IlMjAocCUyQyUyMGwpJTIwaW4lMjB6aXAocHJlZGljdGlvbiUyQyUyMGxhYmVsKSUyMGlmJTIwbCUyMCElM0QlMjAtMTAwJTVEJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwZm9yJTIwcHJlZGljdGlvbiUyQyUyMGxhYmVsJTIwaW4lMjB6aXAocHJlZGljdGlvbnMlMkMlMjBsYWJlbHMpJTBBJTIwJTIwJTIwJTIwJTVEJTBBJTIwJTIwJTIwJTIwdHJ1ZV9sYWJlbHMlMjAlM0QlMjAlNUIlMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlNUJsYWJlbF9saXN0JTVCbCU1RCUyMGZvciUyMChwJTJDJTIwbCklMjBpbiUyMHppcChwcmVkaWN0aW9uJTJDJTIwbGFiZWwpJTIwaWYlMjBsJTIwISUzRCUyMC0xMDAlNUQlMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjBmb3IlMjBwcmVkaWN0aW9uJTJDJTIwbGFiZWwlMjBpbiUyMHppcChwcmVkaWN0aW9ucyUyQyUyMGxhYmVscyklMEElMjAlMjAlMjAlMjAlNUQlMEElMEElMjAlMjAlMjAlMjByZXN1bHRzJTIwJTNEJTIwc2VxZXZhbC5jb21wdXRlKHByZWRpY3Rpb25zJTNEdHJ1ZV9wcmVkaWN0aW9ucyUyQyUyMHJlZmVyZW5jZXMlM0R0cnVlX2xhYmVscyklMEElMjAlMjAlMjAlMjByZXR1cm4lMjAlN0IlMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjJwcmVjaXNpb24lMjIlM0ElMjByZXN1bHRzJTVCJTIyb3ZlcmFsbF9wcmVjaXNpb24lMjIlNUQlMkMlMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjJyZWNhbGwlMjIlM0ElMjByZXN1bHRzJTVCJTIyb3ZlcmFsbF9yZWNhbGwlMjIlNUQlMkMlMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjJmMSUyMiUzQSUyMHJlc3VsdHMlNUIlMjJvdmVyYWxsX2YxJTIyJTVEJTJDJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIyYWNjdXJhY3klMjIlM0ElMjByZXN1bHRzJTVCJTIyb3ZlcmFsbF9hY2N1cmFjeSUyMiU1RCUyQyUwQSUyMCUyMCUyMCUyMCU3RA==",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>labels = [label_list[i] <span class="hljs-keyword">for</span> i <span class="hljs-keyword">in</span> example[<span class="hljs-string">f&quot;ner_tags&quot;</span>]]


<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">p</span>):
<span class="hljs-meta">... </span>    predictions, labels = p
<span class="hljs-meta">... </span>    predictions = np.argmax(predictions, axis=<span class="hljs-number">2</span>)

<span class="hljs-meta">... </span>    true_predictions = [
<span class="hljs-meta">... </span>        [label_list[p] <span class="hljs-keyword">for</span> (p, l) <span class="hljs-keyword">in</span> <span class="hljs-built_in">zip</span>(prediction, label) <span class="hljs-keyword">if</span> l != -<span class="hljs-number">100</span>]
<span class="hljs-meta">... </span>        <span class="hljs-keyword">for</span> prediction, label <span class="hljs-keyword">in</span> <span class="hljs-built_in">zip</span>(predictions, labels)
<span class="hljs-meta">... </span>    ]
<span class="hljs-meta">... </span>    true_labels = [
<span class="hljs-meta">... </span>        [label_list[l] <span class="hljs-keyword">for</span> (p, l) <span class="hljs-keyword">in</span> <span class="hljs-built_in">zip</span>(prediction, label) <span class="hljs-keyword">if</span> l != -<span class="hljs-number">100</span>]
<span class="hljs-meta">... </span>        <span class="hljs-keyword">for</span> prediction, label <span class="hljs-keyword">in</span> <span class="hljs-built_in">zip</span>(predictions, labels)
<span class="hljs-meta">... </span>    ]

<span class="hljs-meta">... </span>    results = seqeval.compute(predictions=true_predictions, references=true_labels)
<span class="hljs-meta">... </span>    <span class="hljs-keyword">return</span> {
<span class="hljs-meta">... </span>        <span class="hljs-string">&quot;precision&quot;</span>: results[<span class="hljs-string">&quot;overall_precision&quot;</span>],
<span class="hljs-meta">... </span>        <span class="hljs-string">&quot;recall&quot;</span>: results[<span class="hljs-string">&quot;overall_recall&quot;</span>],
<span class="hljs-meta">... </span>        <span class="hljs-string">&quot;f1&quot;</span>: results[<span class="hljs-string">&quot;overall_f1&quot;</span>],
<span class="hljs-meta">... </span>        <span class="hljs-string">&quot;accuracy&quot;</span>: results[<span class="hljs-string">&quot;overall_accuracy&quot;</span>],
<span class="hljs-meta">... </span>    }`,wrap:!1}}),Rs=new Ss({props:{title:"Train",local:"train",headingTag:"h2"}}),Vs=new k({props:{code:"aWQybGFiZWwlMjAlM0QlMjAlN0IlMEElMjAlMjAlMjAlMjAwJTNBJTIwJTIyTyUyMiUyQyUwQSUyMCUyMCUyMCUyMDElM0ElMjAlMjJCLWNvcnBvcmF0aW9uJTIyJTJDJTBBJTIwJTIwJTIwJTIwMiUzQSUyMCUyMkktY29ycG9yYXRpb24lMjIlMkMlMEElMjAlMjAlMjAlMjAzJTNBJTIwJTIyQi1jcmVhdGl2ZS13b3JrJTIyJTJDJTBBJTIwJTIwJTIwJTIwNCUzQSUyMCUyMkktY3JlYXRpdmUtd29yayUyMiUyQyUwQSUyMCUyMCUyMCUyMDUlM0ElMjAlMjJCLWdyb3VwJTIyJTJDJTBBJTIwJTIwJTIwJTIwNiUzQSUyMCUyMkktZ3JvdXAlMjIlMkMlMEElMjAlMjAlMjAlMjA3JTNBJTIwJTIyQi1sb2NhdGlvbiUyMiUyQyUwQSUyMCUyMCUyMCUyMDglM0ElMjAlMjJJLWxvY2F0aW9uJTIyJTJDJTBBJTIwJTIwJTIwJTIwOSUzQSUyMCUyMkItcGVyc29uJTIyJTJDJTBBJTIwJTIwJTIwJTIwMTAlM0ElMjAlMjJJLXBlcnNvbiUyMiUyQyUwQSUyMCUyMCUyMCUyMDExJTNBJTIwJTIyQi1wcm9kdWN0JTIyJTJDJTBBJTIwJTIwJTIwJTIwMTIlM0ElMjAlMjJJLXByb2R1Y3QlMjIlMkMlMEElN0QlMEFsYWJlbDJpZCUyMCUzRCUyMCU3QiUwQSUyMCUyMCUyMCUyMCUyMk8lMjIlM0ElMjAwJTJDJTBBJTIwJTIwJTIwJTIwJTIyQi1jb3Jwb3JhdGlvbiUyMiUzQSUyMDElMkMlMEElMjAlMjAlMjAlMjAlMjJJLWNvcnBvcmF0aW9uJTIyJTNBJTIwMiUyQyUwQSUyMCUyMCUyMCUyMCUyMkItY3JlYXRpdmUtd29yayUyMiUzQSUyMDMlMkMlMEElMjAlMjAlMjAlMjAlMjJJLWNyZWF0aXZlLXdvcmslMjIlM0ElMjA0JTJDJTBBJTIwJTIwJTIwJTIwJTIyQi1ncm91cCUyMiUzQSUyMDUlMkMlMEElMjAlMjAlMjAlMjAlMjJJLWdyb3VwJTIyJTNBJTIwNiUyQyUwQSUyMCUyMCUyMCUyMCUyMkItbG9jYXRpb24lMjIlM0ElMjA3JTJDJTBBJTIwJTIwJTIwJTIwJTIySS1sb2NhdGlvbiUyMiUzQSUyMDglMkMlMEElMjAlMjAlMjAlMjAlMjJCLXBlcnNvbiUyMiUzQSUyMDklMkMlMEElMjAlMjAlMjAlMjAlMjJJLXBlcnNvbiUyMiUzQSUyMDEwJTJDJTBBJTIwJTIwJTIwJTIwJTIyQi1wcm9kdWN0JTIyJTNBJTIwMTElMkMlMEElMjAlMjAlMjAlMjAlMjJJLXByb2R1Y3QlMjIlM0ElMjAxMiUyQyUwQSU3RA==",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span>id2label = {
<span class="hljs-meta">... </span>    <span class="hljs-number">0</span>: <span class="hljs-string">&quot;O&quot;</span>,
<span class="hljs-meta">... </span>    <span class="hljs-number">1</span>: <span class="hljs-string">&quot;B-corporation&quot;</span>,
<span class="hljs-meta">... </span>    <span class="hljs-number">2</span>: <span class="hljs-string">&quot;I-corporation&quot;</span>,
<span class="hljs-meta">... </span>    <span class="hljs-number">3</span>: <span class="hljs-string">&quot;B-creative-work&quot;</span>,
<span class="hljs-meta">... </span>    <span class="hljs-number">4</span>: <span class="hljs-string">&quot;I-creative-work&quot;</span>,
<span class="hljs-meta">... </span>    <span class="hljs-number">5</span>: <span class="hljs-string">&quot;B-group&quot;</span>,
<span class="hljs-meta">... </span>    <span class="hljs-number">6</span>: <span class="hljs-string">&quot;I-group&quot;</span>,
<span class="hljs-meta">... </span>    <span class="hljs-number">7</span>: <span class="hljs-string">&quot;B-location&quot;</span>,
<span class="hljs-meta">... </span>    <span class="hljs-number">8</span>: <span class="hljs-string">&quot;I-location&quot;</span>,
<span class="hljs-meta">... </span>    <span class="hljs-number">9</span>: <span class="hljs-string">&quot;B-person&quot;</span>,
<span class="hljs-meta">... </span>    <span class="hljs-number">10</span>: <span class="hljs-string">&quot;I-person&quot;</span>,
<span class="hljs-meta">... </span>    <span class="hljs-number">11</span>: <span class="hljs-string">&quot;B-product&quot;</span>,
<span class="hljs-meta">... </span>    <span class="hljs-number">12</span>: <span class="hljs-string">&quot;I-product&quot;</span>,
<span class="hljs-meta">... </span>}
<span class="hljs-meta">&gt;&gt;&gt; </span>label2id = {
<span class="hljs-meta">... </span>    <span class="hljs-string">&quot;O&quot;</span>: <span class="hljs-number">0</span>,
<span class="hljs-meta">... </span>    <span class="hljs-string">&quot;B-corporation&quot;</span>: <span class="hljs-number">1</span>,
<span class="hljs-meta">... </span>    <span class="hljs-string">&quot;I-corporation&quot;</span>: <span class="hljs-number">2</span>,
<span class="hljs-meta">... </span>    <span class="hljs-string">&quot;B-creative-work&quot;</span>: <span class="hljs-number">3</span>,
<span class="hljs-meta">... </span>    <span class="hljs-string">&quot;I-creative-work&quot;</span>: <span class="hljs-number">4</span>,
<span class="hljs-meta">... </span>    <span class="hljs-string">&quot;B-group&quot;</span>: <span class="hljs-number">5</span>,
<span class="hljs-meta">... </span>    <span class="hljs-string">&quot;I-group&quot;</span>: <span class="hljs-number">6</span>,
<span class="hljs-meta">... </span>    <span class="hljs-string">&quot;B-location&quot;</span>: <span class="hljs-number">7</span>,
<span class="hljs-meta">... </span>    <span class="hljs-string">&quot;I-location&quot;</span>: <span class="hljs-number">8</span>,
<span class="hljs-meta">... </span>    <span class="hljs-string">&quot;B-person&quot;</span>: <span class="hljs-number">9</span>,
<span class="hljs-meta">... </span>    <span class="hljs-string">&quot;I-person&quot;</span>: <span class="hljs-number">10</span>,
<span class="hljs-meta">... </span>    <span class="hljs-string">&quot;B-product&quot;</span>: <span class="hljs-number">11</span>,
<span class="hljs-meta">... </span>    <span class="hljs-string">&quot;I-product&quot;</span>: <span class="hljs-number">12</span>,
<span class="hljs-meta">... </span>}`,wrap:!1}}),ps=new Wa({props:{pytorch:!0,tensorflow:!0,jax:!1,$$slots:{tensorflow:[kl],pytorch:[Ul]},$$scope:{ctx:_}}}),rs=new Ba({props:{$$slots:{default:[_l]},$$scope:{ctx:_}}}),Es=new Ss({props:{title:"Inference",local:"inference",headingTag:"h2"}}),zs=new k({props:{code:"dGV4dCUyMCUzRCUyMCUyMlRoZSUyMEdvbGRlbiUyMFN0YXRlJTIwV2FycmlvcnMlMjBhcmUlMjBhbiUyMEFtZXJpY2FuJTIwcHJvZmVzc2lvbmFsJTIwYmFza2V0YmFsbCUyMHRlYW0lMjBiYXNlZCUyMGluJTIwU2FuJTIwRnJhbmNpc2NvLiUyMg==",highlighted:'<span class="hljs-meta">&gt;&gt;&gt; </span>text = <span class="hljs-string">&quot;The Golden State Warriors are an American professional basketball team based in San Francisco.&quot;</span>',wrap:!1}}),Qs=new k({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMHBpcGVsaW5lJTBBJTBBY2xhc3NpZmllciUyMCUzRCUyMHBpcGVsaW5lKCUyMm5lciUyMiUyQyUyMG1vZGVsJTNEJTIyc3RldmhsaXUlMkZteV9hd2Vzb21lX3dudXRfbW9kZWwlMjIpJTBBY2xhc3NpZmllcih0ZXh0KQ==",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;ner&quot;</span>, model=<span class="hljs-string">&quot;stevhliu/my_awesome_wnut_model&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>classifier(text)
[{<span class="hljs-string">&#x27;entity&#x27;</span>: <span class="hljs-string">&#x27;B-location&#x27;</span>,
  <span class="hljs-string">&#x27;score&#x27;</span>: <span class="hljs-number">0.42658573</span>,
  <span class="hljs-string">&#x27;index&#x27;</span>: <span class="hljs-number">2</span>,
  <span class="hljs-string">&#x27;word&#x27;</span>: <span class="hljs-string">&#x27;golden&#x27;</span>,
  <span class="hljs-string">&#x27;start&#x27;</span>: <span class="hljs-number">4</span>,
  <span class="hljs-string">&#x27;end&#x27;</span>: <span class="hljs-number">10</span>},
 {<span class="hljs-string">&#x27;entity&#x27;</span>: <span class="hljs-string">&#x27;I-location&#x27;</span>,
  <span class="hljs-string">&#x27;score&#x27;</span>: <span class="hljs-number">0.35856336</span>,
  <span class="hljs-string">&#x27;index&#x27;</span>: <span class="hljs-number">3</span>,
  <span class="hljs-string">&#x27;word&#x27;</span>: <span class="hljs-string">&#x27;state&#x27;</span>,
  <span class="hljs-string">&#x27;start&#x27;</span>: <span class="hljs-number">11</span>,
  <span class="hljs-string">&#x27;end&#x27;</span>: <span class="hljs-number">16</span>},
 {<span class="hljs-string">&#x27;entity&#x27;</span>: <span class="hljs-string">&#x27;B-group&#x27;</span>,
  <span class="hljs-string">&#x27;score&#x27;</span>: <span class="hljs-number">0.3064001</span>,
  <span class="hljs-string">&#x27;index&#x27;</span>: <span class="hljs-number">4</span>,
  <span class="hljs-string">&#x27;word&#x27;</span>: <span class="hljs-string">&#x27;warriors&#x27;</span>,
  <span class="hljs-string">&#x27;start&#x27;</span>: <span class="hljs-number">17</span>,
  <span class="hljs-string">&#x27;end&#x27;</span>: <span class="hljs-number">25</span>},
 {<span class="hljs-string">&#x27;entity&#x27;</span>: <span class="hljs-string">&#x27;B-location&#x27;</span>,
  <span class="hljs-string">&#x27;score&#x27;</span>: <span class="hljs-number">0.65523505</span>,
  <span class="hljs-string">&#x27;index&#x27;</span>: <span class="hljs-number">13</span>,
  <span class="hljs-string">&#x27;word&#x27;</span>: <span class="hljs-string">&#x27;san&#x27;</span>,
  <span class="hljs-string">&#x27;start&#x27;</span>: <span class="hljs-number">80</span>,
  <span class="hljs-string">&#x27;end&#x27;</span>: <span class="hljs-number">83</span>},
 {<span class="hljs-string">&#x27;entity&#x27;</span>: <span class="hljs-string">&#x27;B-location&#x27;</span>,
  <span class="hljs-string">&#x27;score&#x27;</span>: <span class="hljs-number">0.4668663</span>,
  <span class="hljs-string">&#x27;index&#x27;</span>: <span class="hljs-number">14</span>,
  <span class="hljs-string">&#x27;word&#x27;</span>: <span class="hljs-string">&#x27;francisco&#x27;</span>,
  <span class="hljs-string">&#x27;start&#x27;</span>: <span class="hljs-number">84</span>,
  <span class="hljs-string">&#x27;end&#x27;</span>: <span class="hljs-number">93</span>}]`,wrap:!1}}),is=new Wa({props:{pytorch:!0,tensorflow:!0,jax:!1,$$slots:{tensorflow:[vl],pytorch:[Il]},$$scope:{ctx:_}}}),qs=new dl({props:{source:"https://github.com/huggingface/transformers/blob/main/docs/source/en/tasks/token_classification.md"}}),{c(){l=g("meta"),c=i(),a=g("p"),m=i(),M(w.$$.fragment),C=i(),M(A.$$.fragment),v=i(),M(I.$$.fragment),G=i(),x=g("p"),x.textContent=V,B=i(),$=g("p"),$.textContent=W,r=i(),U=g("ol"),U.innerHTML=E,X=i(),M(R.$$.fragment),h=i(),Z=g("p"),Z.textContent=F,cs=i(),M(H.$$.fragment),z=i(),N=g("p"),N.textContent=as,ms=i(),M(Q.$$.fragment),Y=i(),M(q.$$.fragment),S=i(),ls=g("p"),ls.textContent=hs,L=i(),M(D.$$.fragment),P=i(),ts=g("p"),ts.textContent=Ms,K=i(),M(O.$$.fragment),ss=i(),es=g("p"),es.innerHTML=js,p=i(),M(T.$$.fragment),us=i(),ds=g("p"),ds.innerHTML=Aa,Ps=i(),ys=g("ul"),ys.innerHTML=Ra,Ks=i(),M(fs.$$.fragment),Os=i(),M(gs.$$.fragment),sa=i(),bs=g("p"),bs.innerHTML=Xa,aa=i(),M(ws.$$.fragment),la=i(),Js=g("p"),Js.innerHTML=Va,ta=i(),M(Ts.$$.fragment),ea=i(),Us=g("p"),Us.innerHTML=Ea,na=i(),$s=g("ol"),$s.innerHTML=Fa,pa=i(),xs=g("p"),xs.textContent=Ha,ra=i(),M(ks.$$.fragment),ia=i(),_s=g("p"),_s.innerHTML=za,oa=i(),M(Cs.$$.fragment),ca=i(),Is=g("p"),Is.innerHTML=Na,ma=i(),M(ns.$$.fragment),ha=i(),M(Zs.$$.fragment),Ma=i(),vs=g("p"),vs.innerHTML=Qa,ja=i(),M(Gs.$$.fragment),ua=i(),Bs=g("p"),Bs.innerHTML=Ya,da=i(),M(Ws.$$.fragment),ya=i(),As=g("p"),As.innerHTML=qa,fa=i(),M(Rs.$$.fragment),ga=i(),Xs=g("p"),Xs.innerHTML=Sa,ba=i(),M(Vs.$$.fragment),wa=i(),M(ps.$$.fragment),Ja=i(),M(rs.$$.fragment),Ta=i(),M(Es.$$.fragment),Ua=i(),Fs=g("p"),Fs.textContent=La,$a=i(),Hs=g("p"),Hs.textContent=Da,xa=i(),M(zs.$$.fragment),ka=i(),Ns=g("p"),Ns.innerHTML=Pa,_a=i(),M(Qs.$$.fragment),Ca=i(),Ys=g("p"),Ys.innerHTML=Ka,Ia=i(),M(is.$$.fragment),Za=i(),M(qs.$$.fragment),va=i(),Ds=g("p"),this.h()},l(s){const n=ml("svelte-u9bgzb",document.head);l=b(n,"META",{name:!0,content:!0}),n.forEach(t),c=o(s),a=b(s,"P",{}),el(a).forEach(t),m=o(s),j(w.$$.fragment,s),C=o(s),j(A.$$.fragment,s),v=o(s),j(I.$$.fragment,s),G=o(s),x=b(s,"P",{"data-svelte-h":!0}),J(x)!=="svelte-o0annf"&&(x.textContent=V),B=o(s),$=b(s,"P",{"data-svelte-h":!0}),J($)!=="svelte-1aff4p7"&&($.textContent=W),r=o(s),U=b(s,"OL",{"data-svelte-h":!0}),J(U)!=="svelte-oqtrz6"&&(U.innerHTML=E),X=o(s),j(R.$$.fragment,s),h=o(s),Z=b(s,"P",{"data-svelte-h":!0}),J(Z)!=="svelte-1c9nexd"&&(Z.textContent=F),cs=o(s),j(H.$$.fragment,s),z=o(s),N=b(s,"P",{"data-svelte-h":!0}),J(N)!=="svelte-k76o1m"&&(N.textContent=as),ms=o(s),j(Q.$$.fragment,s),Y=o(s),j(q.$$.fragment,s),S=o(s),ls=b(s,"P",{"data-svelte-h":!0}),J(ls)!=="svelte-tluco0"&&(ls.textContent=hs),L=o(s),j(D.$$.fragment,s),P=o(s),ts=b(s,"P",{"data-svelte-h":!0}),J(ts)!=="svelte-1m91ua0"&&(ts.textContent=Ms),K=o(s),j(O.$$.fragment,s),ss=o(s),es=b(s,"P",{"data-svelte-h":!0}),J(es)!=="svelte-1684qxr"&&(es.innerHTML=js),p=o(s),j(T.$$.fragment,s),us=o(s),ds=b(s,"P",{"data-svelte-h":!0}),J(ds)!=="svelte-b2md1a"&&(ds.innerHTML=Aa),Ps=o(s),ys=b(s,"UL",{"data-svelte-h":!0}),J(ys)!=="svelte-13punrg"&&(ys.innerHTML=Ra),Ks=o(s),j(fs.$$.fragment,s),Os=o(s),j(gs.$$.fragment,s),sa=o(s),bs=b(s,"P",{"data-svelte-h":!0}),J(bs)!=="svelte-1pk56gi"&&(bs.innerHTML=Xa),aa=o(s),j(ws.$$.fragment,s),la=o(s),Js=b(s,"P",{"data-svelte-h":!0}),J(Js)!=="svelte-el75ld"&&(Js.innerHTML=Va),ta=o(s),j(Ts.$$.fragment,s),ea=o(s),Us=b(s,"P",{"data-svelte-h":!0}),J(Us)!=="svelte-1lf9iv0"&&(Us.innerHTML=Ea),na=o(s),$s=b(s,"OL",{"data-svelte-h":!0}),J($s)!=="svelte-1heekds"&&($s.innerHTML=Fa),pa=o(s),xs=b(s,"P",{"data-svelte-h":!0}),J(xs)!=="svelte-yddais"&&(xs.textContent=Ha),ra=o(s),j(ks.$$.fragment,s),ia=o(s),_s=b(s,"P",{"data-svelte-h":!0}),J(_s)!=="svelte-1fasmjz"&&(_s.innerHTML=za),oa=o(s),j(Cs.$$.fragment,s),ca=o(s),Is=b(s,"P",{"data-svelte-h":!0}),J(Is)!=="svelte-1xz4dmz"&&(Is.innerHTML=Na),ma=o(s),j(ns.$$.fragment,s),ha=o(s),j(Zs.$$.fragment,s),Ma=o(s),vs=b(s,"P",{"data-svelte-h":!0}),J(vs)!=="svelte-434hvn"&&(vs.innerHTML=Qa),ja=o(s),j(Gs.$$.fragment,s),ua=o(s),Bs=b(s,"P",{"data-svelte-h":!0}),J(Bs)!=="svelte-np7vj3"&&(Bs.innerHTML=Ya),da=o(s),j(Ws.$$.fragment,s),ya=o(s),As=b(s,"P",{"data-svelte-h":!0}),J(As)!=="svelte-183aynn"&&(As.innerHTML=qa),fa=o(s),j(Rs.$$.fragment,s),ga=o(s),Xs=b(s,"P",{"data-svelte-h":!0}),J(Xs)!=="svelte-18c6io4"&&(Xs.innerHTML=Sa),ba=o(s),j(Vs.$$.fragment,s),wa=o(s),j(ps.$$.fragment,s),Ja=o(s),j(rs.$$.fragment,s),Ta=o(s),j(Es.$$.fragment,s),Ua=o(s),Fs=b(s,"P",{"data-svelte-h":!0}),J(Fs)!=="svelte-633ppb"&&(Fs.textContent=La),$a=o(s),Hs=b(s,"P",{"data-svelte-h":!0}),J(Hs)!=="svelte-o1jbfg"&&(Hs.textContent=Da),xa=o(s),j(zs.$$.fragment,s),ka=o(s),Ns=b(s,"P",{"data-svelte-h":!0}),J(Ns)!=="svelte-coiufp"&&(Ns.innerHTML=Pa),_a=o(s),j(Qs.$$.fragment,s),Ca=o(s),Ys=b(s,"P",{"data-svelte-h":!0}),J(Ys)!=="svelte-1njl8vm"&&(Ys.innerHTML=Ka),Ia=o(s),j(is.$$.fragment,s),Za=o(s),j(qs.$$.fragment,s),va=o(s),Ds=b(s,"P",{}),el(Ds).forEach(t),this.h()},h(){nl(l,"name","hf:doc:metadata"),nl(l,"content",Bl)},m(s,n){hl(document.head,l),e(s,c,n),e(s,a,n),e(s,m,n),u(w,s,n),e(s,C,n),u(A,s,n),e(s,v,n),u(I,s,n),e(s,G,n),e(s,x,n),e(s,B,n),e(s,$,n),e(s,r,n),e(s,U,n),e(s,X,n),u(R,s,n),e(s,h,n),e(s,Z,n),e(s,cs,n),u(H,s,n),e(s,z,n),e(s,N,n),e(s,ms,n),u(Q,s,n),e(s,Y,n),u(q,s,n),e(s,S,n),e(s,ls,n),e(s,L,n),u(D,s,n),e(s,P,n),e(s,ts,n),e(s,K,n),u(O,s,n),e(s,ss,n),e(s,es,n),e(s,p,n),u(T,s,n),e(s,us,n),e(s,ds,n),e(s,Ps,n),e(s,ys,n),e(s,Ks,n),u(fs,s,n),e(s,Os,n),u(gs,s,n),e(s,sa,n),e(s,bs,n),e(s,aa,n),u(ws,s,n),e(s,la,n),e(s,Js,n),e(s,ta,n),u(Ts,s,n),e(s,ea,n),e(s,Us,n),e(s,na,n),e(s,$s,n),e(s,pa,n),e(s,xs,n),e(s,ra,n),u(ks,s,n),e(s,ia,n),e(s,_s,n),e(s,oa,n),u(Cs,s,n),e(s,ca,n),e(s,Is,n),e(s,ma,n),u(ns,s,n),e(s,ha,n),u(Zs,s,n),e(s,Ma,n),e(s,vs,n),e(s,ja,n),u(Gs,s,n),e(s,ua,n),e(s,Bs,n),e(s,da,n),u(Ws,s,n),e(s,ya,n),e(s,As,n),e(s,fa,n),u(Rs,s,n),e(s,ga,n),e(s,Xs,n),e(s,ba,n),u(Vs,s,n),e(s,wa,n),u(ps,s,n),e(s,Ja,n),u(rs,s,n),e(s,Ta,n),u(Es,s,n),e(s,Ua,n),e(s,Fs,n),e(s,$a,n),e(s,Hs,n),e(s,xa,n),u(zs,s,n),e(s,ka,n),e(s,Ns,n),e(s,_a,n),u(Qs,s,n),e(s,Ca,n),e(s,Ys,n),e(s,Ia,n),u(is,s,n),e(s,Za,n),u(qs,s,n),e(s,va,n),e(s,Ds,n),Ga=!0},p(s,[n]){const Oa={};n&2&&(Oa.$$scope={dirty:n,ctx:s}),R.$set(Oa);const sl={};n&2&&(sl.$$scope={dirty:n,ctx:s}),ns.$set(sl);const al={};n&2&&(al.$$scope={dirty:n,ctx:s}),ps.$set(al);const ll={};n&2&&(ll.$$scope={dirty:n,ctx:s}),rs.$set(ll);const tl={};n&2&&(tl.$$scope={dirty:n,ctx:s}),is.$set(tl)},i(s){Ga||(d(w.$$.fragment,s),d(A.$$.fragment,s),d(I.$$.fragment,s),d(R.$$.fragment,s),d(H.$$.fragment,s),d(Q.$$.fragment,s),d(q.$$.fragment,s),d(D.$$.fragment,s),d(O.$$.fragment,s),d(T.$$.fragment,s),d(fs.$$.fragment,s),d(gs.$$.fragment,s),d(ws.$$.fragment,s),d(Ts.$$.fragment,s),d(ks.$$.fragment,s),d(Cs.$$.fragment,s),d(ns.$$.fragment,s),d(Zs.$$.fragment,s),d(Gs.$$.fragment,s),d(Ws.$$.fragment,s),d(Rs.$$.fragment,s),d(Vs.$$.fragment,s),d(ps.$$.fragment,s),d(rs.$$.fragment,s),d(Es.$$.fragment,s),d(zs.$$.fragment,s),d(Qs.$$.fragment,s),d(is.$$.fragment,s),d(qs.$$.fragment,s),Ga=!0)},o(s){y(w.$$.fragment,s),y(A.$$.fragment,s),y(I.$$.fragment,s),y(R.$$.fragment,s),y(H.$$.fragment,s),y(Q.$$.fragment,s),y(q.$$.fragment,s),y(D.$$.fragment,s),y(O.$$.fragment,s),y(T.$$.fragment,s),y(fs.$$.fragment,s),y(gs.$$.fragment,s),y(ws.$$.fragment,s),y(Ts.$$.fragment,s),y(ks.$$.fragment,s),y(Cs.$$.fragment,s),y(ns.$$.fragment,s),y(Zs.$$.fragment,s),y(Gs.$$.fragment,s),y(Ws.$$.fragment,s),y(Rs.$$.fragment,s),y(Vs.$$.fragment,s),y(ps.$$.fragment,s),y(rs.$$.fragment,s),y(Es.$$.fragment,s),y(zs.$$.fragment,s),y(Qs.$$.fragment,s),y(is.$$.fragment,s),y(qs.$$.fragment,s),Ga=!1},d(s){s&&(t(c),t(a),t(m),t(C),t(v),t(G),t(x),t(B),t($),t(r),t(U),t(X),t(h),t(Z),t(cs),t(z),t(N),t(ms),t(Y),t(S),t(ls),t(L),t(P),t(ts),t(K),t(ss),t(es),t(p),t(us),t(ds),t(Ps),t(ys),t(Ks),t(Os),t(sa),t(bs),t(aa),t(la),t(Js),t(ta),t(ea),t(Us),t(na),t($s),t(pa),t(xs),t(ra),t(ia),t(_s),t(oa),t(ca),t(Is),t(ma),t(ha),t(Ma),t(vs),t(ja),t(ua),t(Bs),t(da),t(ya),t(As),t(fa),t(ga),t(Xs),t(ba),t(wa),t(Ja),t(Ta),t(Ua),t(Fs),t($a),t(Hs),t(xa),t(ka),t(Ns),t(_a),t(Ca),t(Ys),t(Ia),t(Za),t(va),t(Ds)),t(l),f(w,s),f(A,s),f(I,s),f(R,s),f(H,s),f(Q,s),f(q,s),f(D,s),f(O,s),f(T,s),f(fs,s),f(gs,s),f(ws,s),f(Ts,s),f(ks,s),f(Cs,s),f(ns,s),f(Zs,s),f(Gs,s),f(Ws,s),f(Rs,s),f(Vs,s),f(ps,s),f(rs,s),f(Es,s),f(zs,s),f(Qs,s),f(is,s),f(qs,s)}}}const Bl='{"title":"Token classification","local":"token-classification","sections":[{"title":"Load WNUT 17 dataset","local":"load-wnut-17-dataset","sections":[],"depth":2},{"title":"Preprocess","local":"preprocess","sections":[],"depth":2},{"title":"Evaluate","local":"evaluate","sections":[],"depth":2},{"title":"Train","local":"train","sections":[],"depth":2},{"title":"Inference","local":"inference","sections":[],"depth":2}],"depth":1}';function Wl(_){return il(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class Nl extends ol{constructor(l){super(),cl(this,l,Wl,Gl,rl,{})}}export{Nl as component};
