import{s as ra,o as ia,n as cs}from"../chunks/scheduler.9bc65507.js";import{S as ca,i as oa,g as b,s as i,r as M,A as ma,h as d,f as t,c,j as na,u as h,x as J,k as ea,y as ja,a as n,v as u,d as y,t as f,w as g,m as Ma,n as ha}from"../chunks/index.707bf1b6.js";import{T as Bl}from"../chunks/Tip.c2ecdbf4.js";import{Y as pa}from"../chunks/Youtube.e1129c6f.js";import{C as _}from"../chunks/CodeBlock.54a9f38d.js";import{D as ua}from"../chunks/DocNotebookDropdown.41f65cb5.js";import{F as Wl,M as Ls}from"../chunks/Markdown.8ab98a13.js";import{H as Ss,E as ya}from"../chunks/EditOnGithub.922df6ba.js";function fa(k){let a,o='このタスクと互換性のあるすべてのアーキテクチャとチェックポイントを確認するには、<a href="https://huggingface.co/tasks/token-classification" rel="nofollow">タスクページ</a> を確認することをお勧めします。';return{c(){a=b("p"),a.innerHTML=o},l(l){a=d(l,"P",{"data-svelte-h":!0}),J(a)!=="svelte-62918c"&&(a.innerHTML=o)},m(l,m){n(l,a,m)},p:cs,d(l){l&&t(a)}}}function ga(k){let a,o;return a=new _({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(a.$$.fragment)},l(l){h(a.$$.fragment,l)},m(l,m){u(a,l,m),o=!0},p:cs,i(l){o||(y(a.$$.fragment,l),o=!0)},o(l){f(a.$$.fragment,l),o=!1},d(l){g(a,l)}}}function ba(k){let a,o;return a=new Ls({props:{$$slots:{default:[ga]},$$scope:{ctx:k}}}),{c(){M(a.$$.fragment)},l(l){h(a.$$.fragment,l)},m(l,m){u(a,l,m),o=!0},p(l,m){const w={};m&2&&(w.$$scope={dirty:m,ctx:l}),a.$set(w)},i(l){o||(y(a.$$.fragment,l),o=!0)},o(l){f(a.$$.fragment,l),o=!1},d(l){g(a,l)}}}function da(k){let a,o;return a=new _({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(a.$$.fragment)},l(l){h(a.$$.fragment,l)},m(l,m){u(a,l,m),o=!0},p:cs,i(l){o||(y(a.$$.fragment,l),o=!0)},o(l){f(a.$$.fragment,l),o=!1},d(l){g(a,l)}}}function wa(k){let a,o;return a=new Ls({props:{$$slots:{default:[da]},$$scope:{ctx:k}}}),{c(){M(a.$$.fragment)},l(l){h(a.$$.fragment,l)},m(l,m){u(a,l,m),o=!0},p(l,m){const w={};m&2&&(w.$$scope={dirty:m,ctx:l}),a.$set(w)},i(l){o||(y(a.$$.fragment,l),o=!0)},o(l){f(a.$$.fragment,l),o=!1},d(l){g(a,l)}}}function Ja(k){let a,o='<a href="/docs/transformers/pr_30929/ja/main_classes/trainer#transformers.Trainer">Trainer</a> を使用したモデルの微調整に慣れていない場合は、<a href="../training#train-with-pytorch-trainer">ここ</a> の基本的なチュートリアルをご覧ください。';return{c(){a=b("p"),a.innerHTML=o},l(l){a=d(l,"P",{"data-svelte-h":!0}),J(a)!=="svelte-sp3oib"&&(a.innerHTML=o)},m(l,m){n(l,a,m)},p:cs,d(l){l&&t(a)}}}function Ta(k){let a,o,l,m='これでモデルのトレーニングを開始する準備が整いました。 <a href="/docs/transformers/pr_30929/ja/model_doc/auto#transformers.AutoModelForTokenClassification">AutoModelForTokenClassification</a> を使用して、予期されるラベルの数とラベル マッピングを指定して DistilBERT を読み込みます。',w,C,A,v,I="この時点で残っているステップは 3 つだけです。",G,x,V='<li><a href="/docs/transformers/pr_30929/ja/main_classes/trainer#transformers.TrainingArguments">TrainingArguments</a> でトレーニング ハイパーパラメータを定義します。唯一の必須パラメータは、モデルの保存場所を指定する <code>output_dir</code> です。 <code>push_to_hub=True</code>を設定して、このモデルをハブにプッシュします (モデルをアップロードするには、Hugging Face にサインインする必要があります)。各エポックの終了時に、<a href="/docs/transformers/pr_30929/ja/main_classes/trainer#transformers.Trainer">Trainer</a> は連続スコアを評価し、トレーニング チェックポイントを保存します。</li> <li>トレーニング引数を、モデル、データセット、トークナイザー、データ照合器、および <code>compute_metrics</code> 関数とともに <a href="/docs/transformers/pr_30929/ja/main_classes/trainer#transformers.Trainer">Trainer</a> に渡します。</li> <li><a href="/docs/transformers/pr_30929/ja/main_classes/trainer#transformers.Trainer.train">train()</a> を呼び出してモデルを微調整します。</li>',B,U,W,r,$='トレーニングが完了したら、 <a href="/docs/transformers/pr_30929/ja/main_classes/trainer#transformers.Trainer.push_to_hub">push_to_hub()</a> メソッドを使用してモデルをハブに共有し、誰もがモデルを使用できるようにします。',E,X,R;return a=new Bl({props:{$$slots:{default:[Ja]},$$scope:{ctx:k}}}),C=new _({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}}),U=new _({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 _({props:{code:"dHJhaW5lci5wdXNoX3RvX2h1Yigp",highlighted:'<span class="hljs-meta">&gt;&gt;&gt; </span>trainer.push_to_hub()',wrap:!1}}),{c(){M(a.$$.fragment),o=i(),l=b("p"),l.innerHTML=m,w=i(),M(C.$$.fragment),A=i(),v=b("p"),v.textContent=I,G=i(),x=b("ol"),x.innerHTML=V,B=i(),M(U.$$.fragment),W=i(),r=b("p"),r.innerHTML=$,E=i(),M(X.$$.fragment)},l(j){h(a.$$.fragment,j),o=c(j),l=d(j,"P",{"data-svelte-h":!0}),J(l)!=="svelte-1aw6zcg"&&(l.innerHTML=m),w=c(j),h(C.$$.fragment,j),A=c(j),v=d(j,"P",{"data-svelte-h":!0}),J(v)!=="svelte-5p19xw"&&(v.textContent=I),G=c(j),x=d(j,"OL",{"data-svelte-h":!0}),J(x)!=="svelte-15amwqd"&&(x.innerHTML=V),B=c(j),h(U.$$.fragment,j),W=c(j),r=d(j,"P",{"data-svelte-h":!0}),J(r)!=="svelte-yyrlr6"&&(r.innerHTML=$),E=c(j),h(X.$$.fragment,j)},m(j,Z){u(a,j,Z),n(j,o,Z),n(j,l,Z),n(j,w,Z),u(C,j,Z),n(j,A,Z),n(j,v,Z),n(j,G,Z),n(j,x,Z),n(j,B,Z),u(U,j,Z),n(j,W,Z),n(j,r,Z),n(j,E,Z),u(X,j,Z),R=!0},p(j,Z){const F={};Z&2&&(F.$$scope={dirty:Z,ctx:j}),a.$set(F)},i(j){R||(y(a.$$.fragment,j),y(C.$$.fragment,j),y(U.$$.fragment,j),y(X.$$.fragment,j),R=!0)},o(j){f(a.$$.fragment,j),f(C.$$.fragment,j),f(U.$$.fragment,j),f(X.$$.fragment,j),R=!1},d(j){j&&(t(o),t(l),t(w),t(A),t(v),t(G),t(x),t(B),t(W),t(r),t(E)),g(a,j),g(C,j),g(U,j),g(X,j)}}}function $a(k){let a,o;return a=new Ls({props:{$$slots:{default:[Ta]},$$scope:{ctx:k}}}),{c(){M(a.$$.fragment)},l(l){h(a.$$.fragment,l)},m(l,m){u(a,l,m),o=!0},p(l,m){const w={};m&2&&(w.$$scope={dirty:m,ctx:l}),a.$set(w)},i(l){o||(y(a.$$.fragment,l),o=!0)},o(l){f(a.$$.fragment,l),o=!1},d(l){g(a,l)}}}function Ua(k){let a,o='Keras を使用したモデルの微調整に慣れていない場合は、<a href="../training#train-a-tensorflow-model-with-keras">こちら</a> の基本的なチュートリアルをご覧ください。';return{c(){a=b("p"),a.innerHTML=o},l(l){a=d(l,"P",{"data-svelte-h":!0}),J(a)!=="svelte-1jwo7q8"&&(a.innerHTML=o)},m(l,m){n(l,a,m)},p:cs,d(l){l&&t(a)}}}function xa(k){let a,o,l,m,w,C='次に、<a href="/docs/transformers/pr_30929/ja/model_doc/auto#transformers.TFAutoModelForTokenClassification">TFAutoModelForTokenClassification</a> を使用して、予期されるラベルの数とラベル マッピングを指定して DistilBERT をロードできます。',A,v,I,G,x='<a href="/docs/transformers/pr_30929/ja/main_classes/model#transformers.TFPreTrainedModel.prepare_tf_dataset">prepare_tf_dataset()</a> を使用して、データセットを <code>tf.data.Dataset</code> 形式に変換します。',V,B,U,W,r='<a href="https://keras.io/api/models/model_training_apis/#compile-method" rel="nofollow"><code>compile</code></a> を使用してトレーニング用のモデルを設定します。 Transformers モデルにはすべてデフォルトのタスク関連の損失関数があるため、次の場合を除き、損失関数を指定する必要はないことに注意してください。',$,E,X,R,j='トレーニングを開始する前にセットアップする最後の 2 つのことは、予測から連続スコアを計算することと、モデルをハブにプッシュする方法を提供することです。どちらも <a href="../main_classes/keras_callbacks">Keras コールバック</a> を使用して行われます。',Z,F,os='<code>compute_metrics</code> 関数を <a href="/docs/transformers/pr_30929/ja/main_classes/keras_callbacks#transformers.KerasMetricCallback">KerasMetricCallback</a> に渡します。',H,z,Q,ls,ms='<a href="/docs/transformers/pr_30929/ja/main_classes/keras_callbacks#transformers.PushToHubCallback">PushToHubCallback</a> でモデルとトークナイザーをプッシュする場所を指定します。',N,Y,q,S,as="次に、コールバックをまとめてバンドルします。",js,L,D,P,ts='ついに、モデルのトレーニングを開始する準備が整いました。トレーニングおよび検証データセット、エポック数、コールバックを指定して <a href="https://keras.io/api/models/model_training_apis/#fit-method" rel="nofollow"><code>fit</code></a> を呼び出し、モデルを微調整します。',Ms,K,O,ss,ns="トレーニングが完了すると、モデルは自動的にハブにアップロードされ、誰でも使用できるようになります。",hs;return a=new Bl({props:{$$slots:{default:[Ua]},$$scope:{ctx:k}}}),l=new _({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 _({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 _({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 _({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 _({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 _({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 _({props:{code:"Y2FsbGJhY2tzJTIwJTNEJTIwJTVCbWV0cmljX2NhbGxiYWNrJTJDJTIwcHVzaF90b19odWJfY2FsbGJhY2slNUQ=",highlighted:'<span class="hljs-meta">&gt;&gt;&gt; </span>callbacks = [metric_callback, push_to_hub_callback]',wrap:!1}}),K=new _({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(a.$$.fragment),o=Ma(`
TensorFlow でモデルを微調整するには、オプティマイザー関数、学習率スケジュール、およびいくつかのトレーニング ハイパーパラメーターをセットアップすることから始めます。

	`),M(l.$$.fragment),m=i(),w=b("p"),w.innerHTML=C,A=i(),M(v.$$.fragment),I=i(),G=b("p"),G.innerHTML=x,V=i(),M(B.$$.fragment),U=i(),W=b("p"),W.innerHTML=r,$=i(),M(E.$$.fragment),X=i(),R=b("p"),R.innerHTML=j,Z=i(),F=b("p"),F.innerHTML=os,H=i(),M(z.$$.fragment),Q=i(),ls=b("p"),ls.innerHTML=ms,N=i(),M(Y.$$.fragment),q=i(),S=b("p"),S.textContent=as,js=i(),M(L.$$.fragment),D=i(),P=b("p"),P.innerHTML=ts,Ms=i(),M(K.$$.fragment),O=i(),ss=b("p"),ss.textContent=ns},l(p){h(a.$$.fragment,p),o=ha(p,`
TensorFlow でモデルを微調整するには、オプティマイザー関数、学習率スケジュール、およびいくつかのトレーニング ハイパーパラメーターをセットアップすることから始めます。

	`),h(l.$$.fragment,p),m=c(p),w=d(p,"P",{"data-svelte-h":!0}),J(w)!=="svelte-1adw9wj"&&(w.innerHTML=C),A=c(p),h(v.$$.fragment,p),I=c(p),G=d(p,"P",{"data-svelte-h":!0}),J(G)!=="svelte-vie6qn"&&(G.innerHTML=x),V=c(p),h(B.$$.fragment,p),U=c(p),W=d(p,"P",{"data-svelte-h":!0}),J(W)!=="svelte-1pd5few"&&(W.innerHTML=r),$=c(p),h(E.$$.fragment,p),X=c(p),R=d(p,"P",{"data-svelte-h":!0}),J(R)!=="svelte-ggt0vi"&&(R.innerHTML=j),Z=c(p),F=d(p,"P",{"data-svelte-h":!0}),J(F)!=="svelte-1cziamt"&&(F.innerHTML=os),H=c(p),h(z.$$.fragment,p),Q=c(p),ls=d(p,"P",{"data-svelte-h":!0}),J(ls)!=="svelte-19ulcpi"&&(ls.innerHTML=ms),N=c(p),h(Y.$$.fragment,p),q=c(p),S=d(p,"P",{"data-svelte-h":!0}),J(S)!=="svelte-r16oc5"&&(S.textContent=as),js=c(p),h(L.$$.fragment,p),D=c(p),P=d(p,"P",{"data-svelte-h":!0}),J(P)!=="svelte-ffgub5"&&(P.innerHTML=ts),Ms=c(p),h(K.$$.fragment,p),O=c(p),ss=d(p,"P",{"data-svelte-h":!0}),J(ss)!=="svelte-vh7z0v"&&(ss.textContent=ns)},m(p,T){u(a,p,T),n(p,o,T),u(l,p,T),n(p,m,T),n(p,w,T),n(p,A,T),u(v,p,T),n(p,I,T),n(p,G,T),n(p,V,T),u(B,p,T),n(p,U,T),n(p,W,T),n(p,$,T),u(E,p,T),n(p,X,T),n(p,R,T),n(p,Z,T),n(p,F,T),n(p,H,T),u(z,p,T),n(p,Q,T),n(p,ls,T),n(p,N,T),u(Y,p,T),n(p,q,T),n(p,S,T),n(p,js,T),u(L,p,T),n(p,D,T),n(p,P,T),n(p,Ms,T),u(K,p,T),n(p,O,T),n(p,ss,T),hs=!0},p(p,T){const us={};T&2&&(us.$$scope={dirty:T,ctx:p}),a.$set(us)},i(p){hs||(y(a.$$.fragment,p),y(l.$$.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),hs=!0)},o(p){f(a.$$.fragment,p),f(l.$$.fragment,p),f(v.$$.fragment,p),f(B.$$.fragment,p),f(E.$$.fragment,p),f(z.$$.fragment,p),f(Y.$$.fragment,p),f(L.$$.fragment,p),f(K.$$.fragment,p),hs=!1},d(p){p&&(t(o),t(m),t(w),t(A),t(I),t(G),t(V),t(U),t(W),t($),t(X),t(R),t(Z),t(F),t(H),t(Q),t(ls),t(N),t(q),t(S),t(js),t(D),t(P),t(Ms),t(O),t(ss)),g(a,p),g(l,p),g(v,p),g(B,p),g(E,p),g(z,p),g(Y,p),g(L,p),g(K,p)}}}function _a(k){let a,o;return a=new Ls({props:{$$slots:{default:[xa]},$$scope:{ctx:k}}}),{c(){M(a.$$.fragment)},l(l){h(a.$$.fragment,l)},m(l,m){u(a,l,m),o=!0},p(l,m){const w={};m&2&&(w.$$scope={dirty:m,ctx:l}),a.$set(w)},i(l){o||(y(a.$$.fragment,l),o=!0)},o(l){f(a.$$.fragment,l),o=!1},d(l){g(a,l)}}}function ka(k){let a,o=`トークン分類のモデルを微調整する方法のより詳細な例については、対応するセクションを参照してください。
<a href="https://colab.research.google.com/github/huggingface/notebooks/blob/main/examples/token_classification.ipynb" rel="nofollow">PyTorch ノートブック</a>
または <a href="https://colab.research.google.com/github/huggingface/notebooks/blob/main/examples/token_classification-tf.ipynb" rel="nofollow">TensorFlow ノートブック</a>。`;return{c(){a=b("p"),a.innerHTML=o},l(l){a=d(l,"P",{"data-svelte-h":!0}),J(a)!=="svelte-bbxcky"&&(a.innerHTML=o)},m(l,m){n(l,a,m)},p:cs,d(l){l&&t(a)}}}function Ca(k){let a,o="テキストをトークン化して PyTorch テンソルを返します。",l,m,w,C,A="入力をモデルに渡し、<code>logits</code>を返します。",v,I,G,x,V="最も高い確率でクラスを取得し、モデルの <code>id2label</code> マッピングを使用してそれをテキスト ラベルに変換します。",B,U,W;return m=new _({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 _({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}}),U=new _({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(){a=b("p"),a.textContent=o,l=i(),M(m.$$.fragment),w=i(),C=b("p"),C.innerHTML=A,v=i(),M(I.$$.fragment),G=i(),x=b("p"),x.innerHTML=V,B=i(),M(U.$$.fragment)},l(r){a=d(r,"P",{"data-svelte-h":!0}),J(a)!=="svelte-1n0k6or"&&(a.textContent=o),l=c(r),h(m.$$.fragment,r),w=c(r),C=d(r,"P",{"data-svelte-h":!0}),J(C)!=="svelte-1rvunpz"&&(C.innerHTML=A),v=c(r),h(I.$$.fragment,r),G=c(r),x=d(r,"P",{"data-svelte-h":!0}),J(x)!=="svelte-37ihfr"&&(x.innerHTML=V),B=c(r),h(U.$$.fragment,r)},m(r,$){n(r,a,$),n(r,l,$),u(m,r,$),n(r,w,$),n(r,C,$),n(r,v,$),u(I,r,$),n(r,G,$),n(r,x,$),n(r,B,$),u(U,r,$),W=!0},p:cs,i(r){W||(y(m.$$.fragment,r),y(I.$$.fragment,r),y(U.$$.fragment,r),W=!0)},o(r){f(m.$$.fragment,r),f(I.$$.fragment,r),f(U.$$.fragment,r),W=!1},d(r){r&&(t(a),t(l),t(w),t(C),t(v),t(G),t(x),t(B)),g(m,r),g(I,r),g(U,r)}}}function Ia(k){let a,o;return a=new Ls({props:{$$slots:{default:[Ca]},$$scope:{ctx:k}}}),{c(){M(a.$$.fragment)},l(l){h(a.$$.fragment,l)},m(l,m){u(a,l,m),o=!0},p(l,m){const w={};m&2&&(w.$$scope={dirty:m,ctx:l}),a.$set(w)},i(l){o||(y(a.$$.fragment,l),o=!0)},o(l){f(a.$$.fragment,l),o=!1},d(l){g(a,l)}}}function Za(k){let a,o="テキストをトークン化し、TensorFlow テンソルを返します。",l,m,w,C,A="入力をモデルに渡し、<code>logits</code>を返します。",v,I,G,x,V="最も高い確率でクラスを取得し、モデルの <code>id2label</code> マッピングを使用してそれをテキスト ラベルに変換します。",B,U,W;return m=new _({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 _({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}}),U=new _({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(){a=b("p"),a.textContent=o,l=i(),M(m.$$.fragment),w=i(),C=b("p"),C.innerHTML=A,v=i(),M(I.$$.fragment),G=i(),x=b("p"),x.innerHTML=V,B=i(),M(U.$$.fragment)},l(r){a=d(r,"P",{"data-svelte-h":!0}),J(a)!=="svelte-1bnmfqq"&&(a.textContent=o),l=c(r),h(m.$$.fragment,r),w=c(r),C=d(r,"P",{"data-svelte-h":!0}),J(C)!=="svelte-1rvunpz"&&(C.innerHTML=A),v=c(r),h(I.$$.fragment,r),G=c(r),x=d(r,"P",{"data-svelte-h":!0}),J(x)!=="svelte-37ihfr"&&(x.innerHTML=V),B=c(r),h(U.$$.fragment,r)},m(r,$){n(r,a,$),n(r,l,$),u(m,r,$),n(r,w,$),n(r,C,$),n(r,v,$),u(I,r,$),n(r,G,$),n(r,x,$),n(r,B,$),u(U,r,$),W=!0},p:cs,i(r){W||(y(m.$$.fragment,r),y(I.$$.fragment,r),y(U.$$.fragment,r),W=!0)},o(r){f(m.$$.fragment,r),f(I.$$.fragment,r),f(U.$$.fragment,r),W=!1},d(r){r&&(t(a),t(l),t(w),t(C),t(v),t(G),t(x),t(B)),g(m,r),g(I,r),g(U,r)}}}function va(k){let a,o;return a=new Ls({props:{$$slots:{default:[Za]},$$scope:{ctx:k}}}),{c(){M(a.$$.fragment)},l(l){h(a.$$.fragment,l)},m(l,m){u(a,l,m),o=!0},p(l,m){const w={};m&2&&(w.$$scope={dirty:m,ctx:l}),a.$set(w)},i(l){o||(y(a.$$.fragment,l),o=!0)},o(l){f(a.$$.fragment,l),o=!1},d(l){g(a,l)}}}function Ga(k){let a,o,l,m,w,C,A,v,I,G,x,V="トークン分類では、文内の個々のトークンにラベルを割り当てます。最も一般的なトークン分類タスクの 1 つは、固有表現認識 (NER) です。 NER は、人、場所、組織など、文内の各エンティティのラベルを見つけようとします。",B,U,W="このガイドでは、次の方法を説明します。",r,$,E='<li><a href="https://huggingface.co/datasets/wnut_17" rel="nofollow">WNUT 17</a> データセットで <a href="https://huggingface.co/distilbert/distilbert-base-uncased" rel="nofollow">DistilBERT</a> を微調整して、新しいエンティティを検出します。</li> <li>微調整されたモデルを推論に使用します。</li>',X,R,j,Z,F="始める前に、必要なライブラリがすべてインストールされていることを確認してください。",os,H,z,Q,ls="モデルをアップロードしてコミュニティと共有できるように、Hugging Face アカウントにログインすることをお勧めします。プロンプトが表示されたら、トークンを入力してログインします。",ms,N,Y,q,S,as,js="まず、🤗 データセット ライブラリから WNUT 17 データセットをロードします。",L,D,P,ts,Ms="次に、例を見てみましょう。",K,O,ss,ns,hs="<code>ner_tags</code>内の各数字はエンティティを表します。数値をラベル名に変換して、エンティティが何であるかを調べます。",p,T,us,ys,Al="各 <code>ner_tag</code> の前に付く文字は、エンティティのトークンの位置を示します。",Ps,fs,Rl=`<li><code>B-</code> はエンティティの始まりを示します。</li> <li><code>I-</code> は、トークンが同じエンティティ内に含まれていることを示します (たとえば、<code>State</code> トークンは次のようなエンティティの一部です)
<code>Empire State Building</code>）。</li> <li><code>0</code> は、トークンがどのエンティティにも対応しないことを示します。</li>`,Ks,gs,Os,bs,sl,ds,Xl="次のステップでは、DistilBERT トークナイザーをロードして<code>tokens</code>フィールドを前処理します。",ll,ws,al,Js,Vl="上の <code>tokens</code>フィールドの例で見たように、入力はすでにトークン化されているようです。しかし、実際には入力はまだトークン化されていないため、単語をサブワードにトークン化するには<code>is_split_into_words=True</code> を設定する必要があります。例えば：",tl,Ts,nl,$s,El="ただし、これによりいくつかの特別なトークン <code>[CLS]</code> と <code>[SEP]</code> が追加され、サブワードのトークン化により入力とラベルの間に不一致が生じます。 1 つのラベルに対応する 1 つの単語を 2 つのサブワードに分割できるようになりました。次の方法でトークンとラベルを再調整する必要があります。",el,Us,Fl='<li><a href="https://huggingface.co/docs/transformers/main_classes/tokenizer#transformers.BatchEncoding.word_ids" rel="nofollow"><code>word_ids</code></a> メソッドを使用して、すべてのトークンを対応する単語にマッピングします。</li> <li>特別なトークン <code>[CLS]</code> と <code>[SEP]</code> にラベル <code>-100</code> を割り当て、それらが PyTorch 損失関数によって無視されるようにします (<a href="https://pytorch.org/docs/stable/generated/torch.nn.CrossEntropyLoss.html" rel="nofollow">CrossEntropyLoss</a>)。</li> <li>特定の単語の最初のトークンのみにラベルを付けます。同じ単語の他のサブトークンに <code>-100</code>を割り当てます。</li>',pl,xs,Hl="トークンとラベルを再調整し、シーケンスを DistilBERT の最大入力長以下に切り詰める関数を作成する方法を次に示します。",rl,_s,il,ks,zl="データセット全体に前処理関数を適用するには、🤗 Datasets <code>map</code> 関数を使用します。 <code>batched=True</code> を設定してデータセットの複数の要素を一度に処理することで、<code>map</code> 関数を高速化できます。",cl,Cs,ol,Is,Ql="次に、<code>DataCollat​​orWithPadding</code> を使用してサンプルのバッチを作成します。データセット全体を最大長までパディングするのではなく、照合中にバッチ内の最長の長さまで文を <em>動的にパディング</em> する方が効率的です。",ml,es,jl,Zs,Ml,vs,Nl='トレーニング中にメトリクスを含めると、多くの場合、モデルのパフォーマンスを評価するのに役立ちます。 🤗 <a href="https://huggingface.co/docs/evaluate/index" rel="nofollow">Evaluate</a> ライブラリを使用して、評価メソッドをすばやくロードできます。このタスクでは、<a href="https://huggingface.co/spaces/evaluate-metric/seqeval" rel="nofollow">seqeval</a> フレームワークを読み込みます (🤗 Evaluate <a href="https://huggingface.co/docs/evaluate/a_quick_tour" rel="nofollow">クイック ツアー</a> を参照してください) ) メトリクスの読み込みと計算の方法について詳しくは、こちらをご覧ください)。 Seqeval は実際に、精度、再現率、F1、精度などのいくつかのスコアを生成します。',hl,Gs,ul,Bs,Yl="まず NER ラベルを取得してから、真の予測と真のラベルを <code>compute</code> に渡してスコアを計算する関数を作成します。",yl,Ws,fl,As,ql="これで<code>compute_metrics</code>関数の準備が整いました。トレーニングをセットアップするときにこの関数に戻ります。",gl,Rs,bl,Xs,Sl="モデルのトレーニングを開始する前に、<code>id2label</code>と<code>label2id</code>を使用して、予想される ID とそのラベルのマップを作成します。",dl,Vs,wl,ps,Jl,rs,Tl,Es,$l,Fs,Ll="モデルを微調整したので、それを推論に使用できるようになりました。",Ul,Hs,Dl="推論を実行したいテキストをいくつか取得します。",xl,zs,_l,Qs,Pl='推論用に微調整されたモデルを試す最も簡単な方法は、それを <a href="/docs/transformers/pr_30929/ja/main_classes/pipelines#transformers.pipeline">pipeline()</a> で使用することです。モデルを使用して NER の<code>pipeline</code>をインスタンス化し、テキストをそれに渡します。',kl,Ns,Cl,Ys,Kl="必要に応じて、<code>pipeline</code>の結果を手動で複製することもできます。",Il,is,Zl,qs,vl,Ds,Gl;return w=new Ss({props:{title:"Token classification",local:"token-classification",headingTag:"h1"}}),A=new ua({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/ja/token_classification.ipynb"},{label:"PyTorch",value:"https://colab.research.google.com/github/huggingface/notebooks/blob/main/transformers_doc/ja/pytorch/token_classification.ipynb"},{label:"TensorFlow",value:"https://colab.research.google.com/github/huggingface/notebooks/blob/main/transformers_doc/ja/tensorflow/token_classification.ipynb"},{label:"Mixed",value:"https://studiolab.sagemaker.aws/import/github/huggingface/notebooks/blob/main/transformers_doc/ja/token_classification.ipynb"},{label:"PyTorch",value:"https://studiolab.sagemaker.aws/import/github/huggingface/notebooks/blob/main/transformers_doc/ja/pytorch/token_classification.ipynb"},{label:"TensorFlow",value:"https://studiolab.sagemaker.aws/import/github/huggingface/notebooks/blob/main/transformers_doc/ja/tensorflow/token_classification.ipynb"}]}}),I=new pa({props:{id:"wVHdVlPScxA"}}),R=new Bl({props:{$$slots:{default:[fa]},$$scope:{ctx:k}}}),H=new _({props:{code:"cGlwJTIwaW5zdGFsbCUyMHRyYW5zZm9ybWVycyUyMGRhdGFzZXRzJTIwZXZhbHVhdGUlMjBzZXFldmFs",highlighted:"pip install transformers datasets evaluate seqeval",wrap:!1}}),N=new _({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 _({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 _({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 _({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}}),gs=new Ss({props:{title:"Preprocess",local:"preprocess",headingTag:"h2"}}),bs=new pa({props:{id:"iY2AZYdZAr0"}}),ws=new _({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 _({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}}),_s=new _({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 _({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}}),es=new Wl({props:{pytorch:!0,tensorflow:!0,jax:!1,$$slots:{tensorflow:[wa],pytorch:[ba]},$$scope:{ctx:k}}}),Zs=new Ss({props:{title:"Evaluate",local:"evaluate",headingTag:"h2"}}),Gs=new _({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 _({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 _({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 Wl({props:{pytorch:!0,tensorflow:!0,jax:!1,$$slots:{tensorflow:[_a],pytorch:[$a]},$$scope:{ctx:k}}}),rs=new Bl({props:{$$slots:{default:[ka]},$$scope:{ctx:k}}}),Es=new Ss({props:{title:"Inference",local:"inference",headingTag:"h2"}}),zs=new _({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}}),Ns=new _({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 Wl({props:{pytorch:!0,tensorflow:!0,jax:!1,$$slots:{tensorflow:[va],pytorch:[Ia]},$$scope:{ctx:k}}}),qs=new ya({props:{source:"https://github.com/huggingface/transformers/blob/main/docs/source/ja/tasks/token_classification.md"}}),{c(){a=b("meta"),o=i(),l=b("p"),m=i(),M(w.$$.fragment),C=i(),M(A.$$.fragment),v=i(),M(I.$$.fragment),G=i(),x=b("p"),x.textContent=V,B=i(),U=b("p"),U.textContent=W,r=i(),$=b("ol"),$.innerHTML=E,X=i(),M(R.$$.fragment),j=i(),Z=b("p"),Z.textContent=F,os=i(),M(H.$$.fragment),z=i(),Q=b("p"),Q.textContent=ls,ms=i(),M(N.$$.fragment),Y=i(),M(q.$$.fragment),S=i(),as=b("p"),as.textContent=js,L=i(),M(D.$$.fragment),P=i(),ts=b("p"),ts.textContent=Ms,K=i(),M(O.$$.fragment),ss=i(),ns=b("p"),ns.innerHTML=hs,p=i(),M(T.$$.fragment),us=i(),ys=b("p"),ys.innerHTML=Al,Ps=i(),fs=b("ul"),fs.innerHTML=Rl,Ks=i(),M(gs.$$.fragment),Os=i(),M(bs.$$.fragment),sl=i(),ds=b("p"),ds.innerHTML=Xl,ll=i(),M(ws.$$.fragment),al=i(),Js=b("p"),Js.innerHTML=Vl,tl=i(),M(Ts.$$.fragment),nl=i(),$s=b("p"),$s.innerHTML=El,el=i(),Us=b("ol"),Us.innerHTML=Fl,pl=i(),xs=b("p"),xs.textContent=Hl,rl=i(),M(_s.$$.fragment),il=i(),ks=b("p"),ks.innerHTML=zl,cl=i(),M(Cs.$$.fragment),ol=i(),Is=b("p"),Is.innerHTML=Ql,ml=i(),M(es.$$.fragment),jl=i(),M(Zs.$$.fragment),Ml=i(),vs=b("p"),vs.innerHTML=Nl,hl=i(),M(Gs.$$.fragment),ul=i(),Bs=b("p"),Bs.innerHTML=Yl,yl=i(),M(Ws.$$.fragment),fl=i(),As=b("p"),As.innerHTML=ql,gl=i(),M(Rs.$$.fragment),bl=i(),Xs=b("p"),Xs.innerHTML=Sl,dl=i(),M(Vs.$$.fragment),wl=i(),M(ps.$$.fragment),Jl=i(),M(rs.$$.fragment),Tl=i(),M(Es.$$.fragment),$l=i(),Fs=b("p"),Fs.textContent=Ll,Ul=i(),Hs=b("p"),Hs.textContent=Dl,xl=i(),M(zs.$$.fragment),_l=i(),Qs=b("p"),Qs.innerHTML=Pl,kl=i(),M(Ns.$$.fragment),Cl=i(),Ys=b("p"),Ys.innerHTML=Kl,Il=i(),M(is.$$.fragment),Zl=i(),M(qs.$$.fragment),vl=i(),Ds=b("p"),this.h()},l(s){const e=ma("svelte-u9bgzb",document.head);a=d(e,"META",{name:!0,content:!0}),e.forEach(t),o=c(s),l=d(s,"P",{}),na(l).forEach(t),m=c(s),h(w.$$.fragment,s),C=c(s),h(A.$$.fragment,s),v=c(s),h(I.$$.fragment,s),G=c(s),x=d(s,"P",{"data-svelte-h":!0}),J(x)!=="svelte-1pzr9oy"&&(x.textContent=V),B=c(s),U=d(s,"P",{"data-svelte-h":!0}),J(U)!=="svelte-w5jzhi"&&(U.textContent=W),r=c(s),$=d(s,"OL",{"data-svelte-h":!0}),J($)!=="svelte-s4jtml"&&($.innerHTML=E),X=c(s),h(R.$$.fragment,s),j=c(s),Z=d(s,"P",{"data-svelte-h":!0}),J(Z)!=="svelte-1lya3k8"&&(Z.textContent=F),os=c(s),h(H.$$.fragment,s),z=c(s),Q=d(s,"P",{"data-svelte-h":!0}),J(Q)!=="svelte-193zy02"&&(Q.textContent=ls),ms=c(s),h(N.$$.fragment,s),Y=c(s),h(q.$$.fragment,s),S=c(s),as=d(s,"P",{"data-svelte-h":!0}),J(as)!=="svelte-l7eyn2"&&(as.textContent=js),L=c(s),h(D.$$.fragment,s),P=c(s),ts=d(s,"P",{"data-svelte-h":!0}),J(ts)!=="svelte-1r6oj5w"&&(ts.textContent=Ms),K=c(s),h(O.$$.fragment,s),ss=c(s),ns=d(s,"P",{"data-svelte-h":!0}),J(ns)!=="svelte-oegc1b"&&(ns.innerHTML=hs),p=c(s),h(T.$$.fragment,s),us=c(s),ys=d(s,"P",{"data-svelte-h":!0}),J(ys)!=="svelte-ojxi8i"&&(ys.innerHTML=Al),Ps=c(s),fs=d(s,"UL",{"data-svelte-h":!0}),J(fs)!=="svelte-84dn3u"&&(fs.innerHTML=Rl),Ks=c(s),h(gs.$$.fragment,s),Os=c(s),h(bs.$$.fragment,s),sl=c(s),ds=d(s,"P",{"data-svelte-h":!0}),J(ds)!=="svelte-cnh8zx"&&(ds.innerHTML=Xl),ll=c(s),h(ws.$$.fragment,s),al=c(s),Js=d(s,"P",{"data-svelte-h":!0}),J(Js)!=="svelte-1iw1brp"&&(Js.innerHTML=Vl),tl=c(s),h(Ts.$$.fragment,s),nl=c(s),$s=d(s,"P",{"data-svelte-h":!0}),J($s)!=="svelte-5b435g"&&($s.innerHTML=El),el=c(s),Us=d(s,"OL",{"data-svelte-h":!0}),J(Us)!=="svelte-11v861c"&&(Us.innerHTML=Fl),pl=c(s),xs=d(s,"P",{"data-svelte-h":!0}),J(xs)!=="svelte-173aflj"&&(xs.textContent=Hl),rl=c(s),h(_s.$$.fragment,s),il=c(s),ks=d(s,"P",{"data-svelte-h":!0}),J(ks)!=="svelte-1rpvj99"&&(ks.innerHTML=zl),cl=c(s),h(Cs.$$.fragment,s),ol=c(s),Is=d(s,"P",{"data-svelte-h":!0}),J(Is)!=="svelte-qd498c"&&(Is.innerHTML=Ql),ml=c(s),h(es.$$.fragment,s),jl=c(s),h(Zs.$$.fragment,s),Ml=c(s),vs=d(s,"P",{"data-svelte-h":!0}),J(vs)!=="svelte-1ym9fv4"&&(vs.innerHTML=Nl),hl=c(s),h(Gs.$$.fragment,s),ul=c(s),Bs=d(s,"P",{"data-svelte-h":!0}),J(Bs)!=="svelte-1wshevw"&&(Bs.innerHTML=Yl),yl=c(s),h(Ws.$$.fragment,s),fl=c(s),As=d(s,"P",{"data-svelte-h":!0}),J(As)!=="svelte-18cw5xr"&&(As.innerHTML=ql),gl=c(s),h(Rs.$$.fragment,s),bl=c(s),Xs=d(s,"P",{"data-svelte-h":!0}),J(Xs)!=="svelte-i6dg18"&&(Xs.innerHTML=Sl),dl=c(s),h(Vs.$$.fragment,s),wl=c(s),h(ps.$$.fragment,s),Jl=c(s),h(rs.$$.fragment,s),Tl=c(s),h(Es.$$.fragment,s),$l=c(s),Fs=d(s,"P",{"data-svelte-h":!0}),J(Fs)!=="svelte-cyrfc8"&&(Fs.textContent=Ll),Ul=c(s),Hs=d(s,"P",{"data-svelte-h":!0}),J(Hs)!=="svelte-tzt2ke"&&(Hs.textContent=Dl),xl=c(s),h(zs.$$.fragment,s),_l=c(s),Qs=d(s,"P",{"data-svelte-h":!0}),J(Qs)!=="svelte-bkljnc"&&(Qs.innerHTML=Pl),kl=c(s),h(Ns.$$.fragment,s),Cl=c(s),Ys=d(s,"P",{"data-svelte-h":!0}),J(Ys)!=="svelte-p649vi"&&(Ys.innerHTML=Kl),Il=c(s),h(is.$$.fragment,s),Zl=c(s),h(qs.$$.fragment,s),vl=c(s),Ds=d(s,"P",{}),na(Ds).forEach(t),this.h()},h(){ea(a,"name","hf:doc:metadata"),ea(a,"content",Ba)},m(s,e){ja(document.head,a),n(s,o,e),n(s,l,e),n(s,m,e),u(w,s,e),n(s,C,e),u(A,s,e),n(s,v,e),u(I,s,e),n(s,G,e),n(s,x,e),n(s,B,e),n(s,U,e),n(s,r,e),n(s,$,e),n(s,X,e),u(R,s,e),n(s,j,e),n(s,Z,e),n(s,os,e),u(H,s,e),n(s,z,e),n(s,Q,e),n(s,ms,e),u(N,s,e),n(s,Y,e),u(q,s,e),n(s,S,e),n(s,as,e),n(s,L,e),u(D,s,e),n(s,P,e),n(s,ts,e),n(s,K,e),u(O,s,e),n(s,ss,e),n(s,ns,e),n(s,p,e),u(T,s,e),n(s,us,e),n(s,ys,e),n(s,Ps,e),n(s,fs,e),n(s,Ks,e),u(gs,s,e),n(s,Os,e),u(bs,s,e),n(s,sl,e),n(s,ds,e),n(s,ll,e),u(ws,s,e),n(s,al,e),n(s,Js,e),n(s,tl,e),u(Ts,s,e),n(s,nl,e),n(s,$s,e),n(s,el,e),n(s,Us,e),n(s,pl,e),n(s,xs,e),n(s,rl,e),u(_s,s,e),n(s,il,e),n(s,ks,e),n(s,cl,e),u(Cs,s,e),n(s,ol,e),n(s,Is,e),n(s,ml,e),u(es,s,e),n(s,jl,e),u(Zs,s,e),n(s,Ml,e),n(s,vs,e),n(s,hl,e),u(Gs,s,e),n(s,ul,e),n(s,Bs,e),n(s,yl,e),u(Ws,s,e),n(s,fl,e),n(s,As,e),n(s,gl,e),u(Rs,s,e),n(s,bl,e),n(s,Xs,e),n(s,dl,e),u(Vs,s,e),n(s,wl,e),u(ps,s,e),n(s,Jl,e),u(rs,s,e),n(s,Tl,e),u(Es,s,e),n(s,$l,e),n(s,Fs,e),n(s,Ul,e),n(s,Hs,e),n(s,xl,e),u(zs,s,e),n(s,_l,e),n(s,Qs,e),n(s,kl,e),u(Ns,s,e),n(s,Cl,e),n(s,Ys,e),n(s,Il,e),u(is,s,e),n(s,Zl,e),u(qs,s,e),n(s,vl,e),n(s,Ds,e),Gl=!0},p(s,[e]){const Ol={};e&2&&(Ol.$$scope={dirty:e,ctx:s}),R.$set(Ol);const sa={};e&2&&(sa.$$scope={dirty:e,ctx:s}),es.$set(sa);const la={};e&2&&(la.$$scope={dirty:e,ctx:s}),ps.$set(la);const aa={};e&2&&(aa.$$scope={dirty:e,ctx:s}),rs.$set(aa);const ta={};e&2&&(ta.$$scope={dirty:e,ctx:s}),is.$set(ta)},i(s){Gl||(y(w.$$.fragment,s),y(A.$$.fragment,s),y(I.$$.fragment,s),y(R.$$.fragment,s),y(H.$$.fragment,s),y(N.$$.fragment,s),y(q.$$.fragment,s),y(D.$$.fragment,s),y(O.$$.fragment,s),y(T.$$.fragment,s),y(gs.$$.fragment,s),y(bs.$$.fragment,s),y(ws.$$.fragment,s),y(Ts.$$.fragment,s),y(_s.$$.fragment,s),y(Cs.$$.fragment,s),y(es.$$.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(Ns.$$.fragment,s),y(is.$$.fragment,s),y(qs.$$.fragment,s),Gl=!0)},o(s){f(w.$$.fragment,s),f(A.$$.fragment,s),f(I.$$.fragment,s),f(R.$$.fragment,s),f(H.$$.fragment,s),f(N.$$.fragment,s),f(q.$$.fragment,s),f(D.$$.fragment,s),f(O.$$.fragment,s),f(T.$$.fragment,s),f(gs.$$.fragment,s),f(bs.$$.fragment,s),f(ws.$$.fragment,s),f(Ts.$$.fragment,s),f(_s.$$.fragment,s),f(Cs.$$.fragment,s),f(es.$$.fragment,s),f(Zs.$$.fragment,s),f(Gs.$$.fragment,s),f(Ws.$$.fragment,s),f(Rs.$$.fragment,s),f(Vs.$$.fragment,s),f(ps.$$.fragment,s),f(rs.$$.fragment,s),f(Es.$$.fragment,s),f(zs.$$.fragment,s),f(Ns.$$.fragment,s),f(is.$$.fragment,s),f(qs.$$.fragment,s),Gl=!1},d(s){s&&(t(o),t(l),t(m),t(C),t(v),t(G),t(x),t(B),t(U),t(r),t($),t(X),t(j),t(Z),t(os),t(z),t(Q),t(ms),t(Y),t(S),t(as),t(L),t(P),t(ts),t(K),t(ss),t(ns),t(p),t(us),t(ys),t(Ps),t(fs),t(Ks),t(Os),t(sl),t(ds),t(ll),t(al),t(Js),t(tl),t(nl),t($s),t(el),t(Us),t(pl),t(xs),t(rl),t(il),t(ks),t(cl),t(ol),t(Is),t(ml),t(jl),t(Ml),t(vs),t(hl),t(ul),t(Bs),t(yl),t(fl),t(As),t(gl),t(bl),t(Xs),t(dl),t(wl),t(Jl),t(Tl),t($l),t(Fs),t(Ul),t(Hs),t(xl),t(_l),t(Qs),t(kl),t(Cl),t(Ys),t(Il),t(Zl),t(vl),t(Ds)),t(a),g(w,s),g(A,s),g(I,s),g(R,s),g(H,s),g(N,s),g(q,s),g(D,s),g(O,s),g(T,s),g(gs,s),g(bs,s),g(ws,s),g(Ts,s),g(_s,s),g(Cs,s),g(es,s),g(Zs,s),g(Gs,s),g(Ws,s),g(Rs,s),g(Vs,s),g(ps,s),g(rs,s),g(Es,s),g(zs,s),g(Ns,s),g(is,s),g(qs,s)}}}const Ba='{"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 Wa(k){return ia(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class Qa extends ca{constructor(a){super(),oa(this,a,Wa,Ga,ra,{})}}export{Qa as component};
