import{s as Yt,o as St,n as ts}from"../chunks/scheduler.9bc65507.js";import{S as Lt,i as Dt,g as y,s as i,r as u,A as Pt,h as J,f as a,c as o,j as Nt,u as f,x as T,k as Qt,y as Kt,a as n,v as j,d as w,t as h,w as d}from"../chunks/index.707bf1b6.js";import{T as Tt}from"../chunks/Tip.c2ecdbf4.js";import{Y as qt}from"../chunks/Youtube.e1129c6f.js";import{C as R}from"../chunks/CodeBlock.54a9f38d.js";import{D as Ot}from"../chunks/DocNotebookDropdown.41f65cb5.js";import{F as gt,M as As}from"../chunks/Markdown.8ab98a13.js";import{H as Gs,E as se}from"../chunks/EditOnGithub.922df6ba.js";function te(I){let l,m='このタスクと互換性のあるすべてのアーキテクチャとチェックポイントを確認するには、<a href="https://huggingface.co/tasks/question-answering" rel="nofollow">タスクページ</a> を確認することをお勧めします。';return{c(){l=y("p"),l.innerHTML=m},l(e){l=J(e,"P",{"data-svelte-h":!0}),T(l)!=="svelte-c4xwg1"&&(l.innerHTML=m)},m(e,M){n(e,l,M)},p:ts,d(e){e&&a(l)}}}function ee(I){let l,m;return l=new R({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMERlZmF1bHREYXRhQ29sbGF0b3IlMEElMEFkYXRhX2NvbGxhdG9yJTIwJTNEJTIwRGVmYXVsdERhdGFDb2xsYXRvcigp",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> DefaultDataCollator

<span class="hljs-meta">&gt;&gt;&gt; </span>data_collator = DefaultDataCollator()`,wrap:!1}}),{c(){u(l.$$.fragment)},l(e){f(l.$$.fragment,e)},m(e,M){j(l,e,M),m=!0},p:ts,i(e){m||(w(l.$$.fragment,e),m=!0)},o(e){h(l.$$.fragment,e),m=!1},d(e){d(l,e)}}}function le(I){let l,m;return l=new As({props:{$$slots:{default:[ee]},$$scope:{ctx:I}}}),{c(){u(l.$$.fragment)},l(e){f(l.$$.fragment,e)},m(e,M){j(l,e,M),m=!0},p(e,M){const g={};M&2&&(g.$$scope={dirty:M,ctx:e}),l.$set(g)},i(e){m||(w(l.$$.fragment,e),m=!0)},o(e){h(l.$$.fragment,e),m=!1},d(e){d(l,e)}}}function ae(I){let l,m;return l=new R({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMERlZmF1bHREYXRhQ29sbGF0b3IlMEElMEFkYXRhX2NvbGxhdG9yJTIwJTNEJTIwRGVmYXVsdERhdGFDb2xsYXRvcihyZXR1cm5fdGVuc29ycyUzRCUyMnRmJTIyKQ==",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> DefaultDataCollator

<span class="hljs-meta">&gt;&gt;&gt; </span>data_collator = DefaultDataCollator(return_tensors=<span class="hljs-string">&quot;tf&quot;</span>)`,wrap:!1}}),{c(){u(l.$$.fragment)},l(e){f(l.$$.fragment,e)},m(e,M){j(l,e,M),m=!0},p:ts,i(e){m||(w(l.$$.fragment,e),m=!0)},o(e){h(l.$$.fragment,e),m=!1},d(e){d(l,e)}}}function ne(I){let l,m;return l=new As({props:{$$slots:{default:[ae]},$$scope:{ctx:I}}}),{c(){u(l.$$.fragment)},l(e){f(l.$$.fragment,e)},m(e,M){j(l,e,M),m=!0},p(e,M){const g={};M&2&&(g.$$scope={dirty:M,ctx:e}),l.$set(g)},i(e){m||(w(l.$$.fragment,e),m=!0)},o(e){h(l.$$.fragment,e),m=!1},d(e){d(l,e)}}}function pe(I){let l,m='<a href="/docs/transformers/pr_30079/ja/main_classes/trainer#transformers.Trainer">Trainer</a> を使用したモデルの微調整に慣れていない場合は、<a href="../training#train-with-pytorch-trainer">ここ</a> の基本的なチュートリアルをご覧ください。';return{c(){l=y("p"),l.innerHTML=m},l(e){l=J(e,"P",{"data-svelte-h":!0}),T(l)!=="svelte-1r8m3op"&&(l.innerHTML=m)},m(e,M){n(e,l,M)},p:ts,d(e){e&&a(l)}}}function re(I){let l,m,e,M='これでモデルのトレーニングを開始する準備が整いました。 <a href="/docs/transformers/pr_30079/ja/model_doc/auto#transformers.AutoModelForQuestionAnswering">AutoModelForQuestionAnswering</a> を使用して DitilBERT をロードします。',g,U,v,k,X="この時点で残っている手順は次の 3 つだけです。",A,$,F='<li><a href="/docs/transformers/pr_30079/ja/main_classes/trainer#transformers.TrainingArguments">TrainingArguments</a> でトレーニング ハイパーパラメータを定義します。唯一の必須パラメータは、モデルの保存場所を指定する <code>output_dir</code> です。 <code>push_to_hub=True</code>を設定して、このモデルをハブにプッシュします (モデルをアップロードするには、Hugging Face にサインインする必要があります)。</li> <li>トレーニング引数をモデル、データセット、トークナイザー、データ照合器とともに <a href="/docs/transformers/pr_30079/ja/main_classes/trainer#transformers.Trainer">Trainer</a> に渡します。</li> <li><a href="/docs/transformers/pr_30079/ja/main_classes/trainer#transformers.Trainer.train">train()</a> を呼び出してモデルを微調整します。</li>',x,C,W,_,V='トレーニングが完了したら、 <a href="/docs/transformers/pr_30079/ja/main_classes/trainer#transformers.Trainer.push_to_hub">push_to_hub()</a> メソッドを使用してモデルをハブに共有し、誰もがモデルを使用できるようにします。',G,Z,B;return l=new Tt({props:{$$slots:{default:[pe]},$$scope:{ctx:I}}}),U=new R({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMEF1dG9Nb2RlbEZvclF1ZXN0aW9uQW5zd2VyaW5nJTJDJTIwVHJhaW5pbmdBcmd1bWVudHMlMkMlMjBUcmFpbmVyJTBBJTBBbW9kZWwlMjAlM0QlMjBBdXRvTW9kZWxGb3JRdWVzdGlvbkFuc3dlcmluZy5mcm9tX3ByZXRyYWluZWQoJTIyZGlzdGlsYmVydCUyRmRpc3RpbGJlcnQtYmFzZS11bmNhc2VkJTIyKQ==",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoModelForQuestionAnswering, TrainingArguments, Trainer

<span class="hljs-meta">&gt;&gt;&gt; </span>model = AutoModelForQuestionAnswering.from_pretrained(<span class="hljs-string">&quot;distilbert/distilbert-base-uncased&quot;</span>)`,wrap:!1}}),C=new R({props:{code:"dHJhaW5pbmdfYXJncyUyMCUzRCUyMFRyYWluaW5nQXJndW1lbnRzKCUwQSUyMCUyMCUyMCUyMG91dHB1dF9kaXIlM0QlMjJteV9hd2Vzb21lX3FhX21vZGVsJTIyJTJDJTBBJTIwJTIwJTIwJTIwZXZhbF9zdHJhdGVneSUzRCUyMmVwb2NoJTIyJTJDJTBBJTIwJTIwJTIwJTIwbGVhcm5pbmdfcmF0ZSUzRDJlLTUlMkMlMEElMjAlMjAlMjAlMjBwZXJfZGV2aWNlX3RyYWluX2JhdGNoX3NpemUlM0QxNiUyQyUwQSUyMCUyMCUyMCUyMHBlcl9kZXZpY2VfZXZhbF9iYXRjaF9zaXplJTNEMTYlMkMlMEElMjAlMjAlMjAlMjBudW1fdHJhaW5fZXBvY2hzJTNEMyUyQyUwQSUyMCUyMCUyMCUyMHdlaWdodF9kZWNheSUzRDAuMDElMkMlMEElMjAlMjAlMjAlMjBwdXNoX3RvX2h1YiUzRFRydWUlMkMlMEEpJTBBJTBBdHJhaW5lciUyMCUzRCUyMFRyYWluZXIoJTBBJTIwJTIwJTIwJTIwbW9kZWwlM0Rtb2RlbCUyQyUwQSUyMCUyMCUyMCUyMGFyZ3MlM0R0cmFpbmluZ19hcmdzJTJDJTBBJTIwJTIwJTIwJTIwdHJhaW5fZGF0YXNldCUzRHRva2VuaXplZF9zcXVhZCU1QiUyMnRyYWluJTIyJTVEJTJDJTBBJTIwJTIwJTIwJTIwZXZhbF9kYXRhc2V0JTNEdG9rZW5pemVkX3NxdWFkJTVCJTIydGVzdCUyMiU1RCUyQyUwQSUyMCUyMCUyMCUyMHRva2VuaXplciUzRHRva2VuaXplciUyQyUwQSUyMCUyMCUyMCUyMGRhdGFfY29sbGF0b3IlM0RkYXRhX2NvbGxhdG9yJTJDJTBBKSUwQSUwQXRyYWluZXIudHJhaW4oKQ==",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_qa_model&quot;</span>,
<span class="hljs-meta">... </span>    eval_strategy=<span class="hljs-string">&quot;epoch&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">3</span>,
<span class="hljs-meta">... </span>    weight_decay=<span class="hljs-number">0.01</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_squad[<span class="hljs-string">&quot;train&quot;</span>],
<span class="hljs-meta">... </span>    eval_dataset=tokenized_squad[<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>)

<span class="hljs-meta">&gt;&gt;&gt; </span>trainer.train()`,wrap:!1}}),Z=new R({props:{code:"dHJhaW5lci5wdXNoX3RvX2h1Yigp",highlighted:'<span class="hljs-meta">&gt;&gt;&gt; </span>trainer.push_to_hub()',wrap:!1}}),{c(){u(l.$$.fragment),m=i(),e=y("p"),e.innerHTML=M,g=i(),u(U.$$.fragment),v=i(),k=y("p"),k.textContent=X,A=i(),$=y("ol"),$.innerHTML=F,x=i(),u(C.$$.fragment),W=i(),_=y("p"),_.innerHTML=V,G=i(),u(Z.$$.fragment)},l(t){f(l.$$.fragment,t),m=o(t),e=J(t,"P",{"data-svelte-h":!0}),T(e)!=="svelte-wkdvit"&&(e.innerHTML=M),g=o(t),f(U.$$.fragment,t),v=o(t),k=J(t,"P",{"data-svelte-h":!0}),T(k)!=="svelte-1j8bgyv"&&(k.textContent=X),A=o(t),$=J(t,"OL",{"data-svelte-h":!0}),T($)!=="svelte-2iinrl"&&($.innerHTML=F),x=o(t),f(C.$$.fragment,t),W=o(t),_=J(t,"P",{"data-svelte-h":!0}),T(_)!=="svelte-jzic5s"&&(_.innerHTML=V),G=o(t),f(Z.$$.fragment,t)},m(t,c){j(l,t,c),n(t,m,c),n(t,e,c),n(t,g,c),j(U,t,c),n(t,v,c),n(t,k,c),n(t,A,c),n(t,$,c),n(t,x,c),j(C,t,c),n(t,W,c),n(t,_,c),n(t,G,c),j(Z,t,c),B=!0},p(t,c){const z={};c&2&&(z.$$scope={dirty:c,ctx:t}),l.$set(z)},i(t){B||(w(l.$$.fragment,t),w(U.$$.fragment,t),w(C.$$.fragment,t),w(Z.$$.fragment,t),B=!0)},o(t){h(l.$$.fragment,t),h(U.$$.fragment,t),h(C.$$.fragment,t),h(Z.$$.fragment,t),B=!1},d(t){t&&(a(m),a(e),a(g),a(v),a(k),a(A),a($),a(x),a(W),a(_),a(G)),d(l,t),d(U,t),d(C,t),d(Z,t)}}}function ie(I){let l,m;return l=new As({props:{$$slots:{default:[re]},$$scope:{ctx:I}}}),{c(){u(l.$$.fragment)},l(e){f(l.$$.fragment,e)},m(e,M){j(l,e,M),m=!0},p(e,M){const g={};M&2&&(g.$$scope={dirty:M,ctx:e}),l.$set(g)},i(e){m||(w(l.$$.fragment,e),m=!0)},o(e){h(l.$$.fragment,e),m=!1},d(e){d(l,e)}}}function oe(I){let l,m='Keras を使用したモデルの微調整に慣れていない場合は、<a href="../training#train-a-tensorflow-model-with-keras">こちら</a> の基本的なチュートリアルをご覧ください。';return{c(){l=y("p"),l.innerHTML=m},l(e){l=J(e,"P",{"data-svelte-h":!0}),T(l)!=="svelte-1jwo7q8"&&(l.innerHTML=m)},m(e,M){n(e,l,M)},p:ts,d(e){e&&a(l)}}}function me(I){let l,m,e,M=`</ヒント>
TensorFlow でモデルを微調整するには、オプティマイザー関数、学習率スケジュール、およびいくつかのトレーニング ハイパーパラメーターをセットアップすることから始めます。`,g,U,v,k,X='次に、<a href="/docs/transformers/pr_30079/ja/model_doc/auto#transformers.TFAutoModelForQuestionAnswering">TFAutoModelForQuestionAnswering</a> を使用して DistilBERT をロードできます。',A,$,F,x,C='<a href="/docs/transformers/pr_30079/ja/main_classes/model#transformers.TFPreTrainedModel.prepare_tf_dataset">prepare_tf_dataset()</a> を使用して、データセットを <code>tf.data.Dataset</code> 形式に変換します。',W,_,V,G,Z='<a href="https://keras.io/api/models/model_training_apis/#compile-method" rel="nofollow"><code>compile</code></a> を使用してトレーニング用のモデルを設定します。',B,t,c,z,es='トレーニングを開始する前に最後にセットアップすることは、モデルをハブにプッシュする方法を提供することです。これは、モデルとトークナイザーを <a href="/docs/transformers/pr_30079/ja/main_classes/keras_callbacks#transformers.PushToHubCallback">PushToHubCallback</a> でプッシュする場所を指定することで実行できます。',N,Y,L,E,ls='ついに、モデルのトレーニングを開始する準備が整いました。トレーニングおよび検証データセット、エポック数、コールバックを指定して <a href="https://keras.io/api/models/model_training_apis/#fit-method" rel="nofollow"><code>fit</code></a> を呼び出し、モデルを微調整します。',Q,S,D,H,as="トレーニングが完了すると、モデルは自動的にハブにアップロードされ、誰でも使用できるようになります。",q;return l=new Tt({props:{$$slots:{default:[oe]},$$scope:{ctx:I}}}),U=new R({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMGNyZWF0ZV9vcHRpbWl6ZXIlMEElMEFiYXRjaF9zaXplJTIwJTNEJTIwMTYlMEFudW1fZXBvY2hzJTIwJTNEJTIwMiUwQXRvdGFsX3RyYWluX3N0ZXBzJTIwJTNEJTIwKGxlbih0b2tlbml6ZWRfc3F1YWQlNUIlMjJ0cmFpbiUyMiU1RCklMjAlMkYlMkYlMjBiYXRjaF9zaXplKSUyMColMjBudW1fZXBvY2hzJTBBb3B0aW1pemVyJTJDJTIwc2NoZWR1bGUlMjAlM0QlMjBjcmVhdGVfb3B0aW1pemVyKCUwQSUyMCUyMCUyMCUyMGluaXRfbHIlM0QyZS01JTJDJTBBJTIwJTIwJTIwJTIwbnVtX3dhcm11cF9zdGVwcyUzRDAlMkMlMEElMjAlMjAlMjAlMjBudW1fdHJhaW5fc3RlcHMlM0R0b3RhbF90cmFpbl9zdGVwcyUyQyUwQSk=",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_epochs = <span class="hljs-number">2</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>total_train_steps = (<span class="hljs-built_in">len</span>(tokenized_squad[<span class="hljs-string">&quot;train&quot;</span>]) // batch_size) * num_epochs
<span class="hljs-meta">&gt;&gt;&gt; </span>optimizer, schedule = create_optimizer(
<span class="hljs-meta">... </span>    init_lr=<span class="hljs-number">2e-5</span>,
<span class="hljs-meta">... </span>    num_warmup_steps=<span class="hljs-number">0</span>,
<span class="hljs-meta">... </span>    num_train_steps=total_train_steps,
<span class="hljs-meta">... </span>)`,wrap:!1}}),$=new R({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMFRGQXV0b01vZGVsRm9yUXVlc3Rpb25BbnN3ZXJpbmclMEElMEFtb2RlbCUyMCUzRCUyMFRGQXV0b01vZGVsRm9yUXVlc3Rpb25BbnN3ZXJpbmcoJTIyZGlzdGlsYmVydCUyRmRpc3RpbGJlcnQtYmFzZS11bmNhc2VkJTIyKQ==",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> TFAutoModelForQuestionAnswering

<span class="hljs-meta">&gt;&gt;&gt; </span>model = TFAutoModelForQuestionAnswering(<span class="hljs-string">&quot;distilbert/distilbert-base-uncased&quot;</span>)`,wrap:!1}}),_=new R({props:{code:"dGZfdHJhaW5fc2V0JTIwJTNEJTIwbW9kZWwucHJlcGFyZV90Zl9kYXRhc2V0KCUwQSUyMCUyMCUyMCUyMHRva2VuaXplZF9zcXVhZCU1QiUyMnRyYWluJTIyJTVEJTJDJTBBJTIwJTIwJTIwJTIwc2h1ZmZsZSUzRFRydWUlMkMlMEElMjAlMjAlMjAlMjBiYXRjaF9zaXplJTNEMTYlMkMlMEElMjAlMjAlMjAlMjBjb2xsYXRlX2ZuJTNEZGF0YV9jb2xsYXRvciUyQyUwQSklMEElMEF0Zl92YWxpZGF0aW9uX3NldCUyMCUzRCUyMG1vZGVsLnByZXBhcmVfdGZfZGF0YXNldCglMEElMjAlMjAlMjAlMjB0b2tlbml6ZWRfc3F1YWQlNUIlMjJ0ZXN0JTIyJTVEJTJDJTBBJTIwJTIwJTIwJTIwc2h1ZmZsZSUzREZhbHNlJTJDJTBBJTIwJTIwJTIwJTIwYmF0Y2hfc2l6ZSUzRDE2JTJDJTBBJTIwJTIwJTIwJTIwY29sbGF0ZV9mbiUzRGRhdGFfY29sbGF0b3IlMkMlMEEp",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span>tf_train_set = model.prepare_tf_dataset(
<span class="hljs-meta">... </span>    tokenized_squad[<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_squad[<span class="hljs-string">&quot;test&quot;</span>],
<span class="hljs-meta">... </span>    shuffle=<span class="hljs-literal">False</span>,
<span class="hljs-meta">... </span>    batch_size=<span class="hljs-number">16</span>,
<span class="hljs-meta">... </span>    collate_fn=data_collator,
<span class="hljs-meta">... </span>)`,wrap:!1}}),t=new R({props:{code:"aW1wb3J0JTIwdGVuc29yZmxvdyUyMGFzJTIwdGYlMEElMEFtb2RlbC5jb21waWxlKG9wdGltaXplciUzRG9wdGltaXplcik=",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)`,wrap:!1}}),Y=new R({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycy5rZXJhc19jYWxsYmFja3MlMjBpbXBvcnQlMjBQdXNoVG9IdWJDYWxsYmFjayUwQSUwQWNhbGxiYWNrJTIwJTNEJTIwUHVzaFRvSHViQ2FsbGJhY2soJTBBJTIwJTIwJTIwJTIwb3V0cHV0X2RpciUzRCUyMm15X2F3ZXNvbWVfcWFfbW9kZWwlMjIlMkMlMEElMjAlMjAlMjAlMjB0b2tlbml6ZXIlM0R0b2tlbml6ZXIlMkMlMEEp",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>callback = PushToHubCallback(
<span class="hljs-meta">... </span>    output_dir=<span class="hljs-string">&quot;my_awesome_qa_model&quot;</span>,
<span class="hljs-meta">... </span>    tokenizer=tokenizer,
<span class="hljs-meta">... </span>)`,wrap:!1}}),S=new R({props:{code:"bW9kZWwuZml0KHglM0R0Zl90cmFpbl9zZXQlMkMlMjB2YWxpZGF0aW9uX2RhdGElM0R0Zl92YWxpZGF0aW9uX3NldCUyQyUyMGVwb2NocyUzRDMlMkMlMjBjYWxsYmFja3MlM0QlNUJjYWxsYmFjayU1RCk=",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=[callback])',wrap:!1}}),{c(){u(l.$$.fragment),m=i(),e=y("p"),e.textContent=M,g=i(),u(U.$$.fragment),v=i(),k=y("p"),k.innerHTML=X,A=i(),u($.$$.fragment),F=i(),x=y("p"),x.innerHTML=C,W=i(),u(_.$$.fragment),V=i(),G=y("p"),G.innerHTML=Z,B=i(),u(t.$$.fragment),c=i(),z=y("p"),z.innerHTML=es,N=i(),u(Y.$$.fragment),L=i(),E=y("p"),E.innerHTML=ls,Q=i(),u(S.$$.fragment),D=i(),H=y("p"),H.textContent=as},l(r){f(l.$$.fragment,r),m=o(r),e=J(r,"P",{"data-svelte-h":!0}),T(e)!=="svelte-1v9esfa"&&(e.textContent=M),g=o(r),f(U.$$.fragment,r),v=o(r),k=J(r,"P",{"data-svelte-h":!0}),T(k)!=="svelte-8c525z"&&(k.innerHTML=X),A=o(r),f($.$$.fragment,r),F=o(r),x=J(r,"P",{"data-svelte-h":!0}),T(x)!=="svelte-25yvl9"&&(x.innerHTML=C),W=o(r),f(_.$$.fragment,r),V=o(r),G=J(r,"P",{"data-svelte-h":!0}),T(G)!=="svelte-kzu0b7"&&(G.innerHTML=Z),B=o(r),f(t.$$.fragment,r),c=o(r),z=J(r,"P",{"data-svelte-h":!0}),T(z)!=="svelte-lhyf51"&&(z.innerHTML=es),N=o(r),f(Y.$$.fragment,r),L=o(r),E=J(r,"P",{"data-svelte-h":!0}),T(E)!=="svelte-ffgub5"&&(E.innerHTML=ls),Q=o(r),f(S.$$.fragment,r),D=o(r),H=J(r,"P",{"data-svelte-h":!0}),T(H)!=="svelte-vh7z0v"&&(H.textContent=as)},m(r,b){j(l,r,b),n(r,m,b),n(r,e,b),n(r,g,b),j(U,r,b),n(r,v,b),n(r,k,b),n(r,A,b),j($,r,b),n(r,F,b),n(r,x,b),n(r,W,b),j(_,r,b),n(r,V,b),n(r,G,b),n(r,B,b),j(t,r,b),n(r,c,b),n(r,z,b),n(r,N,b),j(Y,r,b),n(r,L,b),n(r,E,b),n(r,Q,b),j(S,r,b),n(r,D,b),n(r,H,b),q=!0},p(r,b){const vs={};b&2&&(vs.$$scope={dirty:b,ctx:r}),l.$set(vs)},i(r){q||(w(l.$$.fragment,r),w(U.$$.fragment,r),w($.$$.fragment,r),w(_.$$.fragment,r),w(t.$$.fragment,r),w(Y.$$.fragment,r),w(S.$$.fragment,r),q=!0)},o(r){h(l.$$.fragment,r),h(U.$$.fragment,r),h($.$$.fragment,r),h(_.$$.fragment,r),h(t.$$.fragment,r),h(Y.$$.fragment,r),h(S.$$.fragment,r),q=!1},d(r){r&&(a(m),a(e),a(g),a(v),a(k),a(A),a(F),a(x),a(W),a(V),a(G),a(B),a(c),a(z),a(N),a(L),a(E),a(Q),a(D),a(H)),d(l,r),d(U,r),d($,r),d(_,r),d(t,r),d(Y,r),d(S,r)}}}function Me(I){let l,m;return l=new As({props:{$$slots:{default:[me]},$$scope:{ctx:I}}}),{c(){u(l.$$.fragment)},l(e){f(l.$$.fragment,e)},m(e,M){j(l,e,M),m=!0},p(e,M){const g={};M&2&&(g.$$scope={dirty:M,ctx:e}),l.$set(g)},i(e){m||(w(l.$$.fragment,e),m=!0)},o(e){h(l.$$.fragment,e),m=!1},d(e){d(l,e)}}}function ce(I){let l,m=`質問応答用のモデルを微調整する方法の詳細な例については、対応するドキュメントを参照してください。
<a href="https://colab.research.google.com/github/huggingface/notebooks/blob/main/examples/question_answering.ipynb" rel="nofollow">PyTorch ノートブック</a>
または <a href="https://colab.research.google.com/github/huggingface/notebooks/blob/main/examples/question_answering-tf.ipynb" rel="nofollow">TensorFlow ノートブック</a>。`;return{c(){l=y("p"),l.innerHTML=m},l(e){l=J(e,"P",{"data-svelte-h":!0}),T(l)!=="svelte-1n4kqih"&&(l.innerHTML=m)},m(e,M){n(e,l,M)},p:ts,d(e){e&&a(l)}}}function ue(I){let l,m="テキストをトークン化して PyTorch テンソルを返します。",e,M,g,U,v="入力をモデルに渡し、<code>logits</code>を返します。",k,X,A,$,F="モデル出力から開始位置と終了位置の最も高い確率を取得します。",x,C,W,_,V="予測されたトークンをデコードして答えを取得します。",G,Z,B;return M=new R({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMEF1dG9Ub2tlbml6ZXIlMEElMEF0b2tlbml6ZXIlMjAlM0QlMjBBdXRvVG9rZW5pemVyLmZyb21fcHJldHJhaW5lZCglMjJteV9hd2Vzb21lX3FhX21vZGVsJTIyKSUwQWlucHV0cyUyMCUzRCUyMHRva2VuaXplcihxdWVzdGlvbiUyQyUyMGNvbnRleHQlMkMlMjByZXR1cm5fdGVuc29ycyUzRCUyMnB0JTIyKQ==",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;my_awesome_qa_model&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>inputs = tokenizer(question, context, return_tensors=<span class="hljs-string">&quot;pt&quot;</span>)`,wrap:!1}}),X=new R({props:{code:"aW1wb3J0JTIwdG9yY2glMEFmcm9tJTIwdHJhbnNmb3JtZXJzJTIwaW1wb3J0JTIwQXV0b01vZGVsRm9yUXVlc3Rpb25BbnN3ZXJpbmclMEElMEFtb2RlbCUyMCUzRCUyMEF1dG9Nb2RlbEZvclF1ZXN0aW9uQW5zd2VyaW5nLmZyb21fcHJldHJhaW5lZCglMjJteV9hd2Vzb21lX3FhX21vZGVsJTIyKSUwQXdpdGglMjB0b3JjaC5ub19ncmFkKCklM0ElMEElMjAlMjAlMjAlMjBvdXRwdXRzJTIwJTNEJTIwbW9kZWwoKippbnB1dHMp",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">import</span> torch
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoModelForQuestionAnswering

<span class="hljs-meta">&gt;&gt;&gt; </span>model = AutoModelForQuestionAnswering.from_pretrained(<span class="hljs-string">&quot;my_awesome_qa_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>    outputs = model(**inputs)`,wrap:!1}}),C=new R({props:{code:"YW5zd2VyX3N0YXJ0X2luZGV4JTIwJTNEJTIwb3V0cHV0cy5zdGFydF9sb2dpdHMuYXJnbWF4KCklMEFhbnN3ZXJfZW5kX2luZGV4JTIwJTNEJTIwb3V0cHV0cy5lbmRfbG9naXRzLmFyZ21heCgp",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span>answer_start_index = outputs.start_logits.argmax()
<span class="hljs-meta">&gt;&gt;&gt; </span>answer_end_index = outputs.end_logits.argmax()`,wrap:!1}}),Z=new R({props:{code:"cHJlZGljdF9hbnN3ZXJfdG9rZW5zJTIwJTNEJTIwaW5wdXRzLmlucHV0X2lkcyU1QjAlMkMlMjBhbnN3ZXJfc3RhcnRfaW5kZXglMjAlM0ElMjBhbnN3ZXJfZW5kX2luZGV4JTIwJTJCJTIwMSU1RCUwQXRva2VuaXplci5kZWNvZGUocHJlZGljdF9hbnN3ZXJfdG9rZW5zKQ==",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span>predict_answer_tokens = inputs.input_ids[<span class="hljs-number">0</span>, answer_start_index : answer_end_index + <span class="hljs-number">1</span>]
<span class="hljs-meta">&gt;&gt;&gt; </span>tokenizer.decode(predict_answer_tokens)
<span class="hljs-string">&#x27;176 billion parameters and can generate text in 46 languages natural languages and 13&#x27;</span>`,wrap:!1}}),{c(){l=y("p"),l.textContent=m,e=i(),u(M.$$.fragment),g=i(),U=y("p"),U.innerHTML=v,k=i(),u(X.$$.fragment),A=i(),$=y("p"),$.textContent=F,x=i(),u(C.$$.fragment),W=i(),_=y("p"),_.textContent=V,G=i(),u(Z.$$.fragment)},l(t){l=J(t,"P",{"data-svelte-h":!0}),T(l)!=="svelte-1n0k6or"&&(l.textContent=m),e=o(t),f(M.$$.fragment,t),g=o(t),U=J(t,"P",{"data-svelte-h":!0}),T(U)!=="svelte-1rvunpz"&&(U.innerHTML=v),k=o(t),f(X.$$.fragment,t),A=o(t),$=J(t,"P",{"data-svelte-h":!0}),T($)!=="svelte-bytl0h"&&($.textContent=F),x=o(t),f(C.$$.fragment,t),W=o(t),_=J(t,"P",{"data-svelte-h":!0}),T(_)!=="svelte-1yq6861"&&(_.textContent=V),G=o(t),f(Z.$$.fragment,t)},m(t,c){n(t,l,c),n(t,e,c),j(M,t,c),n(t,g,c),n(t,U,c),n(t,k,c),j(X,t,c),n(t,A,c),n(t,$,c),n(t,x,c),j(C,t,c),n(t,W,c),n(t,_,c),n(t,G,c),j(Z,t,c),B=!0},p:ts,i(t){B||(w(M.$$.fragment,t),w(X.$$.fragment,t),w(C.$$.fragment,t),w(Z.$$.fragment,t),B=!0)},o(t){h(M.$$.fragment,t),h(X.$$.fragment,t),h(C.$$.fragment,t),h(Z.$$.fragment,t),B=!1},d(t){t&&(a(l),a(e),a(g),a(U),a(k),a(A),a($),a(x),a(W),a(_),a(G)),d(M,t),d(X,t),d(C,t),d(Z,t)}}}function fe(I){let l,m;return l=new As({props:{$$slots:{default:[ue]},$$scope:{ctx:I}}}),{c(){u(l.$$.fragment)},l(e){f(l.$$.fragment,e)},m(e,M){j(l,e,M),m=!0},p(e,M){const g={};M&2&&(g.$$scope={dirty:M,ctx:e}),l.$set(g)},i(e){m||(w(l.$$.fragment,e),m=!0)},o(e){h(l.$$.fragment,e),m=!1},d(e){d(l,e)}}}function je(I){let l,m="テキストをトークン化し、TensorFlow テンソルを返します。",e,M,g,U,v="入力をモデルに渡し、<code>logits</code>を返します。",k,X,A,$,F="モデル出力から開始位置と終了位置の最も高い確率を取得します。",x,C,W,_,V="予測されたトークンをデコードして答えを取得します。",G,Z,B;return M=new R({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMEF1dG9Ub2tlbml6ZXIlMEElMEF0b2tlbml6ZXIlMjAlM0QlMjBBdXRvVG9rZW5pemVyLmZyb21fcHJldHJhaW5lZCglMjJteV9hd2Vzb21lX3FhX21vZGVsJTIyKSUwQWlucHV0cyUyMCUzRCUyMHRva2VuaXplcihxdWVzdGlvbiUyQyUyMHRleHQlMkMlMjByZXR1cm5fdGVuc29ycyUzRCUyMnRmJTIyKQ==",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;my_awesome_qa_model&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>inputs = tokenizer(question, text, return_tensors=<span class="hljs-string">&quot;tf&quot;</span>)`,wrap:!1}}),X=new R({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMFRGQXV0b01vZGVsRm9yUXVlc3Rpb25BbnN3ZXJpbmclMEElMEFtb2RlbCUyMCUzRCUyMFRGQXV0b01vZGVsRm9yUXVlc3Rpb25BbnN3ZXJpbmcuZnJvbV9wcmV0cmFpbmVkKCUyMm15X2F3ZXNvbWVfcWFfbW9kZWwlMjIpJTBBb3V0cHV0cyUyMCUzRCUyMG1vZGVsKCoqaW5wdXRzKQ==",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> TFAutoModelForQuestionAnswering

<span class="hljs-meta">&gt;&gt;&gt; </span>model = TFAutoModelForQuestionAnswering.from_pretrained(<span class="hljs-string">&quot;my_awesome_qa_model&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>outputs = model(**inputs)`,wrap:!1}}),C=new R({props:{code:"YW5zd2VyX3N0YXJ0X2luZGV4JTIwJTNEJTIwaW50KHRmLm1hdGguYXJnbWF4KG91dHB1dHMuc3RhcnRfbG9naXRzJTJDJTIwYXhpcyUzRC0xKSU1QjAlNUQpJTBBYW5zd2VyX2VuZF9pbmRleCUyMCUzRCUyMGludCh0Zi5tYXRoLmFyZ21heChvdXRwdXRzLmVuZF9sb2dpdHMlMkMlMjBheGlzJTNELTEpJTVCMCU1RCk=",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span>answer_start_index = <span class="hljs-built_in">int</span>(tf.math.argmax(outputs.start_logits, axis=-<span class="hljs-number">1</span>)[<span class="hljs-number">0</span>])
<span class="hljs-meta">&gt;&gt;&gt; </span>answer_end_index = <span class="hljs-built_in">int</span>(tf.math.argmax(outputs.end_logits, axis=-<span class="hljs-number">1</span>)[<span class="hljs-number">0</span>])`,wrap:!1}}),Z=new R({props:{code:"cHJlZGljdF9hbnN3ZXJfdG9rZW5zJTIwJTNEJTIwaW5wdXRzLmlucHV0X2lkcyU1QjAlMkMlMjBhbnN3ZXJfc3RhcnRfaW5kZXglMjAlM0ElMjBhbnN3ZXJfZW5kX2luZGV4JTIwJTJCJTIwMSU1RCUwQXRva2VuaXplci5kZWNvZGUocHJlZGljdF9hbnN3ZXJfdG9rZW5zKQ==",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span>predict_answer_tokens = inputs.input_ids[<span class="hljs-number">0</span>, answer_start_index : answer_end_index + <span class="hljs-number">1</span>]
<span class="hljs-meta">&gt;&gt;&gt; </span>tokenizer.decode(predict_answer_tokens)
<span class="hljs-string">&#x27;176 billion parameters and can generate text in 46 languages natural languages and 13&#x27;</span>`,wrap:!1}}),{c(){l=y("p"),l.textContent=m,e=i(),u(M.$$.fragment),g=i(),U=y("p"),U.innerHTML=v,k=i(),u(X.$$.fragment),A=i(),$=y("p"),$.textContent=F,x=i(),u(C.$$.fragment),W=i(),_=y("p"),_.textContent=V,G=i(),u(Z.$$.fragment)},l(t){l=J(t,"P",{"data-svelte-h":!0}),T(l)!=="svelte-1bnmfqq"&&(l.textContent=m),e=o(t),f(M.$$.fragment,t),g=o(t),U=J(t,"P",{"data-svelte-h":!0}),T(U)!=="svelte-1rvunpz"&&(U.innerHTML=v),k=o(t),f(X.$$.fragment,t),A=o(t),$=J(t,"P",{"data-svelte-h":!0}),T($)!=="svelte-bytl0h"&&($.textContent=F),x=o(t),f(C.$$.fragment,t),W=o(t),_=J(t,"P",{"data-svelte-h":!0}),T(_)!=="svelte-1yq6861"&&(_.textContent=V),G=o(t),f(Z.$$.fragment,t)},m(t,c){n(t,l,c),n(t,e,c),j(M,t,c),n(t,g,c),n(t,U,c),n(t,k,c),j(X,t,c),n(t,A,c),n(t,$,c),n(t,x,c),j(C,t,c),n(t,W,c),n(t,_,c),n(t,G,c),j(Z,t,c),B=!0},p:ts,i(t){B||(w(M.$$.fragment,t),w(X.$$.fragment,t),w(C.$$.fragment,t),w(Z.$$.fragment,t),B=!0)},o(t){h(M.$$.fragment,t),h(X.$$.fragment,t),h(C.$$.fragment,t),h(Z.$$.fragment,t),B=!1},d(t){t&&(a(l),a(e),a(g),a(U),a(k),a(A),a($),a(x),a(W),a(_),a(G)),d(M,t),d(X,t),d(C,t),d(Z,t)}}}function we(I){let l,m;return l=new As({props:{$$slots:{default:[je]},$$scope:{ctx:I}}}),{c(){u(l.$$.fragment)},l(e){f(l.$$.fragment,e)},m(e,M){j(l,e,M),m=!0},p(e,M){const g={};M&2&&(g.$$scope={dirty:M,ctx:e}),l.$set(g)},i(e){m||(w(l.$$.fragment,e),m=!0)},o(e){h(l.$$.fragment,e),m=!1},d(e){d(l,e)}}}function he(I){let l,m,e,M,g,U,v,k,X,A,$,F="質問応答タスクは、質問に対して回答を返します。 Alexa、Siri、Google などの仮想アシスタントに天気を尋ねたことがあるなら、質問応答モデルを使用したことがあるはずです。質問応答タスクには一般的に 2 つのタイプがあります。",x,C,W="<li>抽出: 与えられたコンテキストから回答を抽出します。</li> <li>抽象的: 質問に正しく答えるコンテキストから回答を生成します。</li>",_,V,G="このガイドでは、次の方法を説明します。",Z,B,t='<li>抽出的質問応答用に <a href="https://huggingface.co/datasets/squad" rel="nofollow">SQuAD</a> データセット上の <a href="https://huggingface.co/distilbert/distilbert-base-uncased" rel="nofollow">DistilBERT</a> を微調整します。</li> <li>微調整したモデルを推論に使用します。</li>',c,z,es,N,Y="始める前に、必要なライブラリがすべてインストールされていることを確認してください。",L,E,ls,Q,S="モデルをアップロードしてコミュニティと共有できるように、Hugging Face アカウントにログインすることをお勧めします。プロンプトが表示されたら、トークンを入力してログインします。",D,H,as,q,r,b,vs="まず、🤗 データセット ライブラリから SQuAD データセットの小さいサブセットを読み込みます。これにより、完全なデータセットのトレーニングにさらに時間を費やす前に、実験してすべてが機能することを確認する機会が得られます。",Vs,ns,zs,ps,$t="<code>train_test_split</code> メソッドを使用して、データセットの <code>train</code> 分割をトレイン セットとテスト セットに分割します。",Fs,rs,Es,is,bt="次に、例を見てみましょう。",Hs,os,Ns,ms,Ut="ここにはいくつかの重要なフィールドがあります。",Qs,Ms,_t="<li><code>answers</code>: 回答トークンと回答テキストの開始位置。</li> <li><code>context</code>: モデルが答えを抽出するために必要な背景情報。</li> <li><code>question</code>: モデルが答える必要がある質問。</li>",qs,cs,Ys,us,Ss,fs,Ct="次のステップでは、DistilBERT トークナイザーをロードして<code>question</code>フィールドと<code>context</code>フィールドを処理します。",Ls,js,Ds,ws,It="質問応答タスクに特有の、注意すべき前処理手順がいくつかあります。",Ps,hs,Zt=`<li>データセット内の一部の例には、モデルの最大入力長を超える非常に長い「コンテキスト」が含まれる場合があります。より長いシーケンスを処理するには、<code>truncation=&quot;only_second&quot;</code> を設定して <code>context</code> のみを切り捨てます。</li> <li>次に、設定によって、回答の開始位置と終了位置を元の <code>context</code>にマッピングします。
「<code>return_offset_mapping=True</code>」。</li> <li>マッピングが手元にあるので、答えの開始トークンと終了トークンを見つけることができます。 <code>sequence_ids</code> メソッドを使用して、
オフセットのどの部分が<code>question</code>に対応し、どの部分が<code>context</code>に対応するかを見つけます。</li>`,Ks,ds,kt="以下に、<code>answer</code>の開始トークンと終了トークンを切り詰めて<code>context</code>にマッピングする関数を作成する方法を示します。",Os,ys,st,Js,Xt="データセット全体に前処理関数を適用するには、🤗 Datasets <code>map</code> 関数を使用します。 <code>batched=True</code> を設定してデータセットの複数の要素を一度に処理することで、<code>map</code> 関数を高速化できます。不要な列を削除します。",tt,Ts,et,gs,Rt="次に、<code>DefaultDataCollat​​or</code> を使用してサンプルのバッチを作成します。 🤗 Transformers の他のデータ照合器とは異なり、<code>DefaultDataCollat​​or</code> はパディングなどの追加の前処理を適用しません。",lt,P,at,$s,nt,K,pt,O,rt,bs,it,Us,xt='質問応答の評価には、大量の後処理が必要です。時間がかかりすぎないように、このガイドでは評価ステップを省略しています。 <a href="/docs/transformers/pr_30079/ja/main_classes/trainer#transformers.Trainer">Trainer</a> はトレーニング中に評価損失を計算するため、モデルのパフォーマンスについて完全に分からないわけではありません。',ot,_s,Bt='もっと時間があり、質問応答用のモデルを評価する方法に興味がある場合は、<a href="https://huggingface.co/course/chapter7/7?fw=pt#postprocessing" rel="nofollow">質問応答</a> の章を参照してください。 🤗ハグフェイスコースから！',mt,Cs,Mt,Is,Gt="モデルを微調整したので、それを推論に使用できるようになりました。",ct,Zs,At="質問と、モデルに予測させたいコンテキストを考え出します。",ut,ks,ft,Xs,vt='推論用に微調整されたモデルを試す最も簡単な方法は、それを <a href="/docs/transformers/pr_30079/ja/main_classes/pipelines#transformers.pipeline">pipeline()</a> で使用することです。モデルを使用して質問応答用の<code>pipeline</code>をインスタンス化し、それにテキストを渡します。',jt,Rs,wt,xs,Wt="必要に応じて、<code>pipeline</code>の結果を手動で複製することもできます。",ht,ss,dt,Bs,yt,Ws,Jt;return g=new Gs({props:{title:"Question answering",local:"question-answering",headingTag:"h1"}}),v=new Ot({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/question_answering.ipynb"},{label:"PyTorch",value:"https://colab.research.google.com/github/huggingface/notebooks/blob/main/transformers_doc/ja/pytorch/question_answering.ipynb"},{label:"TensorFlow",value:"https://colab.research.google.com/github/huggingface/notebooks/blob/main/transformers_doc/ja/tensorflow/question_answering.ipynb"},{label:"Mixed",value:"https://studiolab.sagemaker.aws/import/github/huggingface/notebooks/blob/main/transformers_doc/ja/question_answering.ipynb"},{label:"PyTorch",value:"https://studiolab.sagemaker.aws/import/github/huggingface/notebooks/blob/main/transformers_doc/ja/pytorch/question_answering.ipynb"},{label:"TensorFlow",value:"https://studiolab.sagemaker.aws/import/github/huggingface/notebooks/blob/main/transformers_doc/ja/tensorflow/question_answering.ipynb"}]}}),X=new qt({props:{id:"ajPx5LwJD-I"}}),z=new Tt({props:{$$slots:{default:[te]},$$scope:{ctx:I}}}),E=new R({props:{code:"cGlwJTIwaW5zdGFsbCUyMHRyYW5zZm9ybWVycyUyMGRhdGFzZXRzJTIwZXZhbHVhdGU=",highlighted:"pip install transformers datasets evaluate",wrap:!1}}),H=new R({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 Gs({props:{title:"Load SQuAD dataset",local:"load-squad-dataset",headingTag:"h2"}}),ns=new R({props:{code:"ZnJvbSUyMGRhdGFzZXRzJTIwaW1wb3J0JTIwbG9hZF9kYXRhc2V0JTBBJTBBc3F1YWQlMjAlM0QlMjBsb2FkX2RhdGFzZXQoJTIyc3F1YWQlMjIlMkMlMjBzcGxpdCUzRCUyMnRyYWluJTVCJTNBNTAwMCU1RCUyMik=",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>squad = load_dataset(<span class="hljs-string">&quot;squad&quot;</span>, split=<span class="hljs-string">&quot;train[:5000]&quot;</span>)`,wrap:!1}}),rs=new R({props:{code:"c3F1YWQlMjAlM0QlMjBzcXVhZC50cmFpbl90ZXN0X3NwbGl0KHRlc3Rfc2l6ZSUzRDAuMik=",highlighted:'<span class="hljs-meta">&gt;&gt;&gt; </span>squad = squad.train_test_split(test_size=<span class="hljs-number">0.2</span>)',wrap:!1}}),os=new R({props:{code:"c3F1YWQlNUIlMjJ0cmFpbiUyMiU1RCU1QjAlNUQ=",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span>squad[<span class="hljs-string">&quot;train&quot;</span>][<span class="hljs-number">0</span>]
{<span class="hljs-string">&#x27;answers&#x27;</span>: {<span class="hljs-string">&#x27;answer_start&#x27;</span>: [<span class="hljs-number">515</span>], <span class="hljs-string">&#x27;text&#x27;</span>: [<span class="hljs-string">&#x27;Saint Bernadette Soubirous&#x27;</span>]},
 <span class="hljs-string">&#x27;context&#x27;</span>: <span class="hljs-string">&#x27;Architecturally, the school has a Catholic character. Atop the Main Building\\&#x27;s gold dome is a golden statue of the Virgin Mary. Immediately in front of the Main Building and facing it, is a copper statue of Christ with arms upraised with the legend &quot;Venite Ad Me Omnes&quot;. Next to the Main Building is the Basilica of the Sacred Heart. Immediately behind the basilica is the Grotto, a Marian place of prayer and reflection. It is a replica of the grotto at Lourdes, France where the Virgin Mary reputedly appeared to Saint Bernadette Soubirous in 1858. At the end of the main drive (and in a direct line that connects through 3 statues and the Gold Dome), is a simple, modern stone statue of Mary.&#x27;</span>,
 <span class="hljs-string">&#x27;id&#x27;</span>: <span class="hljs-string">&#x27;5733be284776f41900661182&#x27;</span>,
 <span class="hljs-string">&#x27;question&#x27;</span>: <span class="hljs-string">&#x27;To whom did the Virgin Mary allegedly appear in 1858 in Lourdes France?&#x27;</span>,
 <span class="hljs-string">&#x27;title&#x27;</span>: <span class="hljs-string">&#x27;University_of_Notre_Dame&#x27;</span>
}`,wrap:!1}}),cs=new Gs({props:{title:"Preprocess",local:"preprocess",headingTag:"h2"}}),us=new qt({props:{id:"qgaM0weJHpA"}}),js=new R({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}}),ys=new R({props:{code:"ZGVmJTIwcHJlcHJvY2Vzc19mdW5jdGlvbihleGFtcGxlcyklM0ElMEElMjAlMjAlMjAlMjBxdWVzdGlvbnMlMjAlM0QlMjAlNUJxLnN0cmlwKCklMjBmb3IlMjBxJTIwaW4lMjBleGFtcGxlcyU1QiUyMnF1ZXN0aW9uJTIyJTVEJTVEJTBBJTIwJTIwJTIwJTIwaW5wdXRzJTIwJTNEJTIwdG9rZW5pemVyKCUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMHF1ZXN0aW9ucyUyQyUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMGV4YW1wbGVzJTVCJTIyY29udGV4dCUyMiU1RCUyQyUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMG1heF9sZW5ndGglM0QzODQlMkMlMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjB0cnVuY2F0aW9uJTNEJTIyb25seV9zZWNvbmQlMjIlMkMlMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjByZXR1cm5fb2Zmc2V0c19tYXBwaW5nJTNEVHJ1ZSUyQyUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMHBhZGRpbmclM0QlMjJtYXhfbGVuZ3RoJTIyJTJDJTBBJTIwJTIwJTIwJTIwKSUwQSUwQSUyMCUyMCUyMCUyMG9mZnNldF9tYXBwaW5nJTIwJTNEJTIwaW5wdXRzLnBvcCglMjJvZmZzZXRfbWFwcGluZyUyMiklMEElMjAlMjAlMjAlMjBhbnN3ZXJzJTIwJTNEJTIwZXhhbXBsZXMlNUIlMjJhbnN3ZXJzJTIyJTVEJTBBJTIwJTIwJTIwJTIwc3RhcnRfcG9zaXRpb25zJTIwJTNEJTIwJTVCJTVEJTBBJTIwJTIwJTIwJTIwZW5kX3Bvc2l0aW9ucyUyMCUzRCUyMCU1QiU1RCUwQSUwQSUyMCUyMCUyMCUyMGZvciUyMGklMkMlMjBvZmZzZXQlMjBpbiUyMGVudW1lcmF0ZShvZmZzZXRfbWFwcGluZyklM0ElMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjBhbnN3ZXIlMjAlM0QlMjBhbnN3ZXJzJTVCaSU1RCUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMHN0YXJ0X2NoYXIlMjAlM0QlMjBhbnN3ZXIlNUIlMjJhbnN3ZXJfc3RhcnQlMjIlNUQlNUIwJTVEJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwZW5kX2NoYXIlMjAlM0QlMjBhbnN3ZXIlNUIlMjJhbnN3ZXJfc3RhcnQlMjIlNUQlNUIwJTVEJTIwJTJCJTIwbGVuKGFuc3dlciU1QiUyMnRleHQlMjIlNUQlNUIwJTVEKSUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMHNlcXVlbmNlX2lkcyUyMCUzRCUyMGlucHV0cy5zZXF1ZW5jZV9pZHMoaSklMEElMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjMlMjBGaW5kJTIwdGhlJTIwc3RhcnQlMjBhbmQlMjBlbmQlMjBvZiUyMHRoZSUyMGNvbnRleHQlMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjBpZHglMjAlM0QlMjAwJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwd2hpbGUlMjBzZXF1ZW5jZV9pZHMlNUJpZHglNUQlMjAhJTNEJTIwMSUzQSUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMGlkeCUyMCUyQiUzRCUyMDElMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjBjb250ZXh0X3N0YXJ0JTIwJTNEJTIwaWR4JTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwd2hpbGUlMjBzZXF1ZW5jZV9pZHMlNUJpZHglNUQlMjAlM0QlM0QlMjAxJTNBJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwaWR4JTIwJTJCJTNEJTIwMSUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMGNvbnRleHRfZW5kJTIwJTNEJTIwaWR4JTIwLSUyMDElMEElMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjMlMjBJZiUyMHRoZSUyMGFuc3dlciUyMGlzJTIwbm90JTIwZnVsbHklMjBpbnNpZGUlMjB0aGUlMjBjb250ZXh0JTJDJTIwbGFiZWwlMjBpdCUyMCgwJTJDJTIwMCklMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjBpZiUyMG9mZnNldCU1QmNvbnRleHRfc3RhcnQlNUQlNUIwJTVEJTIwJTNFJTIwZW5kX2NoYXIlMjBvciUyMG9mZnNldCU1QmNvbnRleHRfZW5kJTVEJTVCMSU1RCUyMCUzQyUyMHN0YXJ0X2NoYXIlM0ElMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjBzdGFydF9wb3NpdGlvbnMuYXBwZW5kKDApJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwZW5kX3Bvc2l0aW9ucy5hcHBlbmQoMCklMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjBlbHNlJTNBJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIzJTIwT3RoZXJ3aXNlJTIwaXQncyUyMHRoZSUyMHN0YXJ0JTIwYW5kJTIwZW5kJTIwdG9rZW4lMjBwb3NpdGlvbnMlMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjBpZHglMjAlM0QlMjBjb250ZXh0X3N0YXJ0JTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwd2hpbGUlMjBpZHglMjAlM0MlM0QlMjBjb250ZXh0X2VuZCUyMGFuZCUyMG9mZnNldCU1QmlkeCU1RCU1QjAlNUQlMjAlM0MlM0QlMjBzdGFydF9jaGFyJTNBJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwaWR4JTIwJTJCJTNEJTIwMSUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMHN0YXJ0X3Bvc2l0aW9ucy5hcHBlbmQoaWR4JTIwLSUyMDEpJTBBJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwaWR4JTIwJTNEJTIwY29udGV4dF9lbmQlMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjB3aGlsZSUyMGlkeCUyMCUzRSUzRCUyMGNvbnRleHRfc3RhcnQlMjBhbmQlMjBvZmZzZXQlNUJpZHglNUQlNUIxJTVEJTIwJTNFJTNEJTIwZW5kX2NoYXIlM0ElMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjBpZHglMjAtJTNEJTIwMSUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMGVuZF9wb3NpdGlvbnMuYXBwZW5kKGlkeCUyMCUyQiUyMDEpJTBBJTBBJTIwJTIwJTIwJTIwaW5wdXRzJTVCJTIyc3RhcnRfcG9zaXRpb25zJTIyJTVEJTIwJTNEJTIwc3RhcnRfcG9zaXRpb25zJTBBJTIwJTIwJTIwJTIwaW5wdXRzJTVCJTIyZW5kX3Bvc2l0aW9ucyUyMiU1RCUyMCUzRCUyMGVuZF9wb3NpdGlvbnMlMEElMjAlMjAlMjAlMjByZXR1cm4lMjBpbnB1dHM=",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">def</span> <span class="hljs-title function_">preprocess_function</span>(<span class="hljs-params">examples</span>):
<span class="hljs-meta">... </span>    questions = [q.strip() <span class="hljs-keyword">for</span> q <span class="hljs-keyword">in</span> examples[<span class="hljs-string">&quot;question&quot;</span>]]
<span class="hljs-meta">... </span>    inputs = tokenizer(
<span class="hljs-meta">... </span>        questions,
<span class="hljs-meta">... </span>        examples[<span class="hljs-string">&quot;context&quot;</span>],
<span class="hljs-meta">... </span>        max_length=<span class="hljs-number">384</span>,
<span class="hljs-meta">... </span>        truncation=<span class="hljs-string">&quot;only_second&quot;</span>,
<span class="hljs-meta">... </span>        return_offsets_mapping=<span class="hljs-literal">True</span>,
<span class="hljs-meta">... </span>        padding=<span class="hljs-string">&quot;max_length&quot;</span>,
<span class="hljs-meta">... </span>    )

<span class="hljs-meta">... </span>    offset_mapping = inputs.pop(<span class="hljs-string">&quot;offset_mapping&quot;</span>)
<span class="hljs-meta">... </span>    answers = examples[<span class="hljs-string">&quot;answers&quot;</span>]
<span class="hljs-meta">... </span>    start_positions = []
<span class="hljs-meta">... </span>    end_positions = []

<span class="hljs-meta">... </span>    <span class="hljs-keyword">for</span> i, offset <span class="hljs-keyword">in</span> <span class="hljs-built_in">enumerate</span>(offset_mapping):
<span class="hljs-meta">... </span>        answer = answers[i]
<span class="hljs-meta">... </span>        start_char = answer[<span class="hljs-string">&quot;answer_start&quot;</span>][<span class="hljs-number">0</span>]
<span class="hljs-meta">... </span>        end_char = answer[<span class="hljs-string">&quot;answer_start&quot;</span>][<span class="hljs-number">0</span>] + <span class="hljs-built_in">len</span>(answer[<span class="hljs-string">&quot;text&quot;</span>][<span class="hljs-number">0</span>])
<span class="hljs-meta">... </span>        sequence_ids = inputs.sequence_ids(i)

<span class="hljs-meta">... </span>        <span class="hljs-comment"># Find the start and end of the context</span>
<span class="hljs-meta">... </span>        idx = <span class="hljs-number">0</span>
<span class="hljs-meta">... </span>        <span class="hljs-keyword">while</span> sequence_ids[idx] != <span class="hljs-number">1</span>:
<span class="hljs-meta">... </span>            idx += <span class="hljs-number">1</span>
<span class="hljs-meta">... </span>        context_start = idx
<span class="hljs-meta">... </span>        <span class="hljs-keyword">while</span> sequence_ids[idx] == <span class="hljs-number">1</span>:
<span class="hljs-meta">... </span>            idx += <span class="hljs-number">1</span>
<span class="hljs-meta">... </span>        context_end = idx - <span class="hljs-number">1</span>

<span class="hljs-meta">... </span>        <span class="hljs-comment"># If the answer is not fully inside the context, label it (0, 0)</span>
<span class="hljs-meta">... </span>        <span class="hljs-keyword">if</span> offset[context_start][<span class="hljs-number">0</span>] &gt; end_char <span class="hljs-keyword">or</span> offset[context_end][<span class="hljs-number">1</span>] &lt; start_char:
<span class="hljs-meta">... </span>            start_positions.append(<span class="hljs-number">0</span>)
<span class="hljs-meta">... </span>            end_positions.append(<span class="hljs-number">0</span>)
<span class="hljs-meta">... </span>        <span class="hljs-keyword">else</span>:
<span class="hljs-meta">... </span>            <span class="hljs-comment"># Otherwise it&#x27;s the start and end token positions</span>
<span class="hljs-meta">... </span>            idx = context_start
<span class="hljs-meta">... </span>            <span class="hljs-keyword">while</span> idx &lt;= context_end <span class="hljs-keyword">and</span> offset[idx][<span class="hljs-number">0</span>] &lt;= start_char:
<span class="hljs-meta">... </span>                idx += <span class="hljs-number">1</span>
<span class="hljs-meta">... </span>            start_positions.append(idx - <span class="hljs-number">1</span>)

<span class="hljs-meta">... </span>            idx = context_end
<span class="hljs-meta">... </span>            <span class="hljs-keyword">while</span> idx &gt;= context_start <span class="hljs-keyword">and</span> offset[idx][<span class="hljs-number">1</span>] &gt;= end_char:
<span class="hljs-meta">... </span>                idx -= <span class="hljs-number">1</span>
<span class="hljs-meta">... </span>            end_positions.append(idx + <span class="hljs-number">1</span>)

<span class="hljs-meta">... </span>    inputs[<span class="hljs-string">&quot;start_positions&quot;</span>] = start_positions
<span class="hljs-meta">... </span>    inputs[<span class="hljs-string">&quot;end_positions&quot;</span>] = end_positions
<span class="hljs-meta">... </span>    <span class="hljs-keyword">return</span> inputs`,wrap:!1}}),Ts=new R({props:{code:"dG9rZW5pemVkX3NxdWFkJTIwJTNEJTIwc3F1YWQubWFwKHByZXByb2Nlc3NfZnVuY3Rpb24lMkMlMjBiYXRjaGVkJTNEVHJ1ZSUyQyUyMHJlbW92ZV9jb2x1bW5zJTNEc3F1YWQlNUIlMjJ0cmFpbiUyMiU1RC5jb2x1bW5fbmFtZXMp",highlighted:'<span class="hljs-meta">&gt;&gt;&gt; </span>tokenized_squad = squad.<span class="hljs-built_in">map</span>(preprocess_function, batched=<span class="hljs-literal">True</span>, remove_columns=squad[<span class="hljs-string">&quot;train&quot;</span>].column_names)',wrap:!1}}),P=new gt({props:{pytorch:!0,tensorflow:!0,jax:!1,$$slots:{tensorflow:[ne],pytorch:[le]},$$scope:{ctx:I}}}),$s=new Gs({props:{title:"Train",local:"train",headingTag:"h2"}}),K=new gt({props:{pytorch:!0,tensorflow:!0,jax:!1,$$slots:{tensorflow:[Me],pytorch:[ie]},$$scope:{ctx:I}}}),O=new Tt({props:{$$slots:{default:[ce]},$$scope:{ctx:I}}}),bs=new Gs({props:{title:"Evaluate",local:"evaluate",headingTag:"h2"}}),Cs=new Gs({props:{title:"Inference",local:"inference",headingTag:"h2"}}),ks=new R({props:{code:"cXVlc3Rpb24lMjAlM0QlMjAlMjJIb3clMjBtYW55JTIwcHJvZ3JhbW1pbmclMjBsYW5ndWFnZXMlMjBkb2VzJTIwQkxPT00lMjBzdXBwb3J0JTNGJTIyJTBBY29udGV4dCUyMCUzRCUyMCUyMkJMT09NJTIwaGFzJTIwMTc2JTIwYmlsbGlvbiUyMHBhcmFtZXRlcnMlMjBhbmQlMjBjYW4lMjBnZW5lcmF0ZSUyMHRleHQlMjBpbiUyMDQ2JTIwbGFuZ3VhZ2VzJTIwbmF0dXJhbCUyMGxhbmd1YWdlcyUyMGFuZCUyMDEzJTIwcHJvZ3JhbW1pbmclMjBsYW5ndWFnZXMuJTIy",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span>question = <span class="hljs-string">&quot;How many programming languages does BLOOM support?&quot;</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>context = <span class="hljs-string">&quot;BLOOM has 176 billion parameters and can generate text in 46 languages natural languages and 13 programming languages.&quot;</span>`,wrap:!1}}),Rs=new R({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMHBpcGVsaW5lJTBBJTBBcXVlc3Rpb25fYW5zd2VyZXIlMjAlM0QlMjBwaXBlbGluZSglMjJxdWVzdGlvbi1hbnN3ZXJpbmclMjIlMkMlMjBtb2RlbCUzRCUyMm15X2F3ZXNvbWVfcWFfbW9kZWwlMjIpJTBBcXVlc3Rpb25fYW5zd2VyZXIocXVlc3Rpb24lM0RxdWVzdGlvbiUyQyUyMGNvbnRleHQlM0Rjb250ZXh0KQ==",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>question_answerer = pipeline(<span class="hljs-string">&quot;question-answering&quot;</span>, model=<span class="hljs-string">&quot;my_awesome_qa_model&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>question_answerer(question=question, context=context)
{<span class="hljs-string">&#x27;score&#x27;</span>: <span class="hljs-number">0.2058267742395401</span>,
 <span class="hljs-string">&#x27;start&#x27;</span>: <span class="hljs-number">10</span>,
 <span class="hljs-string">&#x27;end&#x27;</span>: <span class="hljs-number">95</span>,
 <span class="hljs-string">&#x27;answer&#x27;</span>: <span class="hljs-string">&#x27;176 billion parameters and can generate text in 46 languages natural languages and 13&#x27;</span>}`,wrap:!1}}),ss=new gt({props:{pytorch:!0,tensorflow:!0,jax:!1,$$slots:{tensorflow:[we],pytorch:[fe]},$$scope:{ctx:I}}}),Bs=new se({props:{source:"https://github.com/huggingface/transformers/blob/main/docs/source/ja/tasks/question_answering.md"}}),{c(){l=y("meta"),m=i(),e=y("p"),M=i(),u(g.$$.fragment),U=i(),u(v.$$.fragment),k=i(),u(X.$$.fragment),A=i(),$=y("p"),$.textContent=F,x=i(),C=y("ul"),C.innerHTML=W,_=i(),V=y("p"),V.textContent=G,Z=i(),B=y("ol"),B.innerHTML=t,c=i(),u(z.$$.fragment),es=i(),N=y("p"),N.textContent=Y,L=i(),u(E.$$.fragment),ls=i(),Q=y("p"),Q.textContent=S,D=i(),u(H.$$.fragment),as=i(),u(q.$$.fragment),r=i(),b=y("p"),b.textContent=vs,Vs=i(),u(ns.$$.fragment),zs=i(),ps=y("p"),ps.innerHTML=$t,Fs=i(),u(rs.$$.fragment),Es=i(),is=y("p"),is.textContent=bt,Hs=i(),u(os.$$.fragment),Ns=i(),ms=y("p"),ms.textContent=Ut,Qs=i(),Ms=y("ul"),Ms.innerHTML=_t,qs=i(),u(cs.$$.fragment),Ys=i(),u(us.$$.fragment),Ss=i(),fs=y("p"),fs.innerHTML=Ct,Ls=i(),u(js.$$.fragment),Ds=i(),ws=y("p"),ws.textContent=It,Ps=i(),hs=y("ol"),hs.innerHTML=Zt,Ks=i(),ds=y("p"),ds.innerHTML=kt,Os=i(),u(ys.$$.fragment),st=i(),Js=y("p"),Js.innerHTML=Xt,tt=i(),u(Ts.$$.fragment),et=i(),gs=y("p"),gs.innerHTML=Rt,lt=i(),u(P.$$.fragment),at=i(),u($s.$$.fragment),nt=i(),u(K.$$.fragment),pt=i(),u(O.$$.fragment),rt=i(),u(bs.$$.fragment),it=i(),Us=y("p"),Us.innerHTML=xt,ot=i(),_s=y("p"),_s.innerHTML=Bt,mt=i(),u(Cs.$$.fragment),Mt=i(),Is=y("p"),Is.textContent=Gt,ct=i(),Zs=y("p"),Zs.textContent=At,ut=i(),u(ks.$$.fragment),ft=i(),Xs=y("p"),Xs.innerHTML=vt,jt=i(),u(Rs.$$.fragment),wt=i(),xs=y("p"),xs.innerHTML=Wt,ht=i(),u(ss.$$.fragment),dt=i(),u(Bs.$$.fragment),yt=i(),Ws=y("p"),this.h()},l(s){const p=Pt("svelte-u9bgzb",document.head);l=J(p,"META",{name:!0,content:!0}),p.forEach(a),m=o(s),e=J(s,"P",{}),Nt(e).forEach(a),M=o(s),f(g.$$.fragment,s),U=o(s),f(v.$$.fragment,s),k=o(s),f(X.$$.fragment,s),A=o(s),$=J(s,"P",{"data-svelte-h":!0}),T($)!=="svelte-1tgwu4t"&&($.textContent=F),x=o(s),C=J(s,"UL",{"data-svelte-h":!0}),T(C)!=="svelte-ku9lav"&&(C.innerHTML=W),_=o(s),V=J(s,"P",{"data-svelte-h":!0}),T(V)!=="svelte-w5jzhi"&&(V.textContent=G),Z=o(s),B=J(s,"OL",{"data-svelte-h":!0}),T(B)!=="svelte-o857bo"&&(B.innerHTML=t),c=o(s),f(z.$$.fragment,s),es=o(s),N=J(s,"P",{"data-svelte-h":!0}),T(N)!=="svelte-1lya3k8"&&(N.textContent=Y),L=o(s),f(E.$$.fragment,s),ls=o(s),Q=J(s,"P",{"data-svelte-h":!0}),T(Q)!=="svelte-193zy02"&&(Q.textContent=S),D=o(s),f(H.$$.fragment,s),as=o(s),f(q.$$.fragment,s),r=o(s),b=J(s,"P",{"data-svelte-h":!0}),T(b)!=="svelte-12zmynt"&&(b.textContent=vs),Vs=o(s),f(ns.$$.fragment,s),zs=o(s),ps=J(s,"P",{"data-svelte-h":!0}),T(ps)!=="svelte-m4w3yq"&&(ps.innerHTML=$t),Fs=o(s),f(rs.$$.fragment,s),Es=o(s),is=J(s,"P",{"data-svelte-h":!0}),T(is)!=="svelte-1r6oj5w"&&(is.textContent=bt),Hs=o(s),f(os.$$.fragment,s),Ns=o(s),ms=J(s,"P",{"data-svelte-h":!0}),T(ms)!=="svelte-y9dab"&&(ms.textContent=Ut),Qs=o(s),Ms=J(s,"UL",{"data-svelte-h":!0}),T(Ms)!=="svelte-1kxnjgl"&&(Ms.innerHTML=_t),qs=o(s),f(cs.$$.fragment,s),Ys=o(s),f(us.$$.fragment,s),Ss=o(s),fs=J(s,"P",{"data-svelte-h":!0}),T(fs)!=="svelte-1bamyze"&&(fs.innerHTML=Ct),Ls=o(s),f(js.$$.fragment,s),Ds=o(s),ws=J(s,"P",{"data-svelte-h":!0}),T(ws)!=="svelte-lhw9mt"&&(ws.textContent=It),Ps=o(s),hs=J(s,"OL",{"data-svelte-h":!0}),T(hs)!=="svelte-1syxwtd"&&(hs.innerHTML=Zt),Ks=o(s),ds=J(s,"P",{"data-svelte-h":!0}),T(ds)!=="svelte-1ryfrne"&&(ds.innerHTML=kt),Os=o(s),f(ys.$$.fragment,s),st=o(s),Js=J(s,"P",{"data-svelte-h":!0}),T(Js)!=="svelte-t1eqy4"&&(Js.innerHTML=Xt),tt=o(s),f(Ts.$$.fragment,s),et=o(s),gs=J(s,"P",{"data-svelte-h":!0}),T(gs)!=="svelte-me6jz3"&&(gs.innerHTML=Rt),lt=o(s),f(P.$$.fragment,s),at=o(s),f($s.$$.fragment,s),nt=o(s),f(K.$$.fragment,s),pt=o(s),f(O.$$.fragment,s),rt=o(s),f(bs.$$.fragment,s),it=o(s),Us=J(s,"P",{"data-svelte-h":!0}),T(Us)!=="svelte-rc8aco"&&(Us.innerHTML=xt),ot=o(s),_s=J(s,"P",{"data-svelte-h":!0}),T(_s)!=="svelte-ihy4ok"&&(_s.innerHTML=Bt),mt=o(s),f(Cs.$$.fragment,s),Mt=o(s),Is=J(s,"P",{"data-svelte-h":!0}),T(Is)!=="svelte-cyrfc8"&&(Is.textContent=Gt),ct=o(s),Zs=J(s,"P",{"data-svelte-h":!0}),T(Zs)!=="svelte-151wogl"&&(Zs.textContent=At),ut=o(s),f(ks.$$.fragment,s),ft=o(s),Xs=J(s,"P",{"data-svelte-h":!0}),T(Xs)!=="svelte-1vu1t8c"&&(Xs.innerHTML=vt),jt=o(s),f(Rs.$$.fragment,s),wt=o(s),xs=J(s,"P",{"data-svelte-h":!0}),T(xs)!=="svelte-p649vi"&&(xs.innerHTML=Wt),ht=o(s),f(ss.$$.fragment,s),dt=o(s),f(Bs.$$.fragment,s),yt=o(s),Ws=J(s,"P",{}),Nt(Ws).forEach(a),this.h()},h(){Qt(l,"name","hf:doc:metadata"),Qt(l,"content",de)},m(s,p){Kt(document.head,l),n(s,m,p),n(s,e,p),n(s,M,p),j(g,s,p),n(s,U,p),j(v,s,p),n(s,k,p),j(X,s,p),n(s,A,p),n(s,$,p),n(s,x,p),n(s,C,p),n(s,_,p),n(s,V,p),n(s,Z,p),n(s,B,p),n(s,c,p),j(z,s,p),n(s,es,p),n(s,N,p),n(s,L,p),j(E,s,p),n(s,ls,p),n(s,Q,p),n(s,D,p),j(H,s,p),n(s,as,p),j(q,s,p),n(s,r,p),n(s,b,p),n(s,Vs,p),j(ns,s,p),n(s,zs,p),n(s,ps,p),n(s,Fs,p),j(rs,s,p),n(s,Es,p),n(s,is,p),n(s,Hs,p),j(os,s,p),n(s,Ns,p),n(s,ms,p),n(s,Qs,p),n(s,Ms,p),n(s,qs,p),j(cs,s,p),n(s,Ys,p),j(us,s,p),n(s,Ss,p),n(s,fs,p),n(s,Ls,p),j(js,s,p),n(s,Ds,p),n(s,ws,p),n(s,Ps,p),n(s,hs,p),n(s,Ks,p),n(s,ds,p),n(s,Os,p),j(ys,s,p),n(s,st,p),n(s,Js,p),n(s,tt,p),j(Ts,s,p),n(s,et,p),n(s,gs,p),n(s,lt,p),j(P,s,p),n(s,at,p),j($s,s,p),n(s,nt,p),j(K,s,p),n(s,pt,p),j(O,s,p),n(s,rt,p),j(bs,s,p),n(s,it,p),n(s,Us,p),n(s,ot,p),n(s,_s,p),n(s,mt,p),j(Cs,s,p),n(s,Mt,p),n(s,Is,p),n(s,ct,p),n(s,Zs,p),n(s,ut,p),j(ks,s,p),n(s,ft,p),n(s,Xs,p),n(s,jt,p),j(Rs,s,p),n(s,wt,p),n(s,xs,p),n(s,ht,p),j(ss,s,p),n(s,dt,p),j(Bs,s,p),n(s,yt,p),n(s,Ws,p),Jt=!0},p(s,[p]){const Vt={};p&2&&(Vt.$$scope={dirty:p,ctx:s}),z.$set(Vt);const zt={};p&2&&(zt.$$scope={dirty:p,ctx:s}),P.$set(zt);const Ft={};p&2&&(Ft.$$scope={dirty:p,ctx:s}),K.$set(Ft);const Et={};p&2&&(Et.$$scope={dirty:p,ctx:s}),O.$set(Et);const Ht={};p&2&&(Ht.$$scope={dirty:p,ctx:s}),ss.$set(Ht)},i(s){Jt||(w(g.$$.fragment,s),w(v.$$.fragment,s),w(X.$$.fragment,s),w(z.$$.fragment,s),w(E.$$.fragment,s),w(H.$$.fragment,s),w(q.$$.fragment,s),w(ns.$$.fragment,s),w(rs.$$.fragment,s),w(os.$$.fragment,s),w(cs.$$.fragment,s),w(us.$$.fragment,s),w(js.$$.fragment,s),w(ys.$$.fragment,s),w(Ts.$$.fragment,s),w(P.$$.fragment,s),w($s.$$.fragment,s),w(K.$$.fragment,s),w(O.$$.fragment,s),w(bs.$$.fragment,s),w(Cs.$$.fragment,s),w(ks.$$.fragment,s),w(Rs.$$.fragment,s),w(ss.$$.fragment,s),w(Bs.$$.fragment,s),Jt=!0)},o(s){h(g.$$.fragment,s),h(v.$$.fragment,s),h(X.$$.fragment,s),h(z.$$.fragment,s),h(E.$$.fragment,s),h(H.$$.fragment,s),h(q.$$.fragment,s),h(ns.$$.fragment,s),h(rs.$$.fragment,s),h(os.$$.fragment,s),h(cs.$$.fragment,s),h(us.$$.fragment,s),h(js.$$.fragment,s),h(ys.$$.fragment,s),h(Ts.$$.fragment,s),h(P.$$.fragment,s),h($s.$$.fragment,s),h(K.$$.fragment,s),h(O.$$.fragment,s),h(bs.$$.fragment,s),h(Cs.$$.fragment,s),h(ks.$$.fragment,s),h(Rs.$$.fragment,s),h(ss.$$.fragment,s),h(Bs.$$.fragment,s),Jt=!1},d(s){s&&(a(m),a(e),a(M),a(U),a(k),a(A),a($),a(x),a(C),a(_),a(V),a(Z),a(B),a(c),a(es),a(N),a(L),a(ls),a(Q),a(D),a(as),a(r),a(b),a(Vs),a(zs),a(ps),a(Fs),a(Es),a(is),a(Hs),a(Ns),a(ms),a(Qs),a(Ms),a(qs),a(Ys),a(Ss),a(fs),a(Ls),a(Ds),a(ws),a(Ps),a(hs),a(Ks),a(ds),a(Os),a(st),a(Js),a(tt),a(et),a(gs),a(lt),a(at),a(nt),a(pt),a(rt),a(it),a(Us),a(ot),a(_s),a(mt),a(Mt),a(Is),a(ct),a(Zs),a(ut),a(ft),a(Xs),a(jt),a(wt),a(xs),a(ht),a(dt),a(yt),a(Ws)),a(l),d(g,s),d(v,s),d(X,s),d(z,s),d(E,s),d(H,s),d(q,s),d(ns,s),d(rs,s),d(os,s),d(cs,s),d(us,s),d(js,s),d(ys,s),d(Ts,s),d(P,s),d($s,s),d(K,s),d(O,s),d(bs,s),d(Cs,s),d(ks,s),d(Rs,s),d(ss,s),d(Bs,s)}}}const de='{"title":"Question answering","local":"question-answering","sections":[{"title":"Load SQuAD dataset","local":"load-squad-dataset","sections":[],"depth":2},{"title":"Preprocess","local":"preprocess","sections":[],"depth":2},{"title":"Train","local":"train","sections":[],"depth":2},{"title":"Evaluate","local":"evaluate","sections":[],"depth":2},{"title":"Inference","local":"inference","sections":[],"depth":2}],"depth":1}';function ye(I){return St(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class Ie extends Lt{constructor(l){super(),Dt(this,l,ye,he,Yt,{})}}export{Ie as component};
