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 Ht,u as j,x as T,k as Qt,y as Kt,a as n,v as f,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 x}from"../chunks/CodeBlock.54a9f38d.js";import{D as Ot}from"../chunks/DocNotebookDropdown.41f65cb5.js";import{F as gt,M as Gs}from"../chunks/Markdown.8ab98a13.js";import{H as As,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 x({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){j(l.$$.fragment,e)},m(e,M){f(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 Gs({props:{$$slots:{default:[ee]},$$scope:{ctx:I}}}),{c(){u(l.$$.fragment)},l(e){j(l.$$.fragment,e)},m(e,M){f(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 x({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){j(l.$$.fragment,e)},m(e,M){f(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 Gs({props:{$$slots:{default:[ae]},$$scope:{ctx:I}}}),{c(){u(l.$$.fragment)},l(e){j(l.$$.fragment,e)},m(e,M){f(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/main/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-1ubngji"&&(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/main/ja/model_doc/auto#transformers.AutoModelForQuestionAnswering">AutoModelForQuestionAnswering</a> を使用して DitilBERT をロードします。',g,U,v,k,X="この時点で残っている手順は次の 3 つだけです。",G,b,E='<li><a href="/docs/transformers/main/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/main/ja/main_classes/trainer#transformers.Trainer">Trainer</a> に渡します。</li> <li><a href="/docs/transformers/main/ja/main_classes/trainer#transformers.Trainer.train">train()</a> を呼び出してモデルを微調整します。</li>',R,C,W,_,V='トレーニングが完了したら、 <a href="/docs/transformers/main/ja/main_classes/trainer#transformers.Trainer.push_to_hub">push_to_hub()</a> メソッドを使用してモデルをハブに共有し、誰もがモデルを使用できるようにします。',A,Z,B;return l=new Tt({props:{$$slots:{default:[pe]},$$scope:{ctx:I}}}),U=new x({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 x({props:{code:"dHJhaW5pbmdfYXJncyUyMCUzRCUyMFRyYWluaW5nQXJndW1lbnRzKCUwQSUyMCUyMCUyMCUyMG91dHB1dF9kaXIlM0QlMjJteV9hd2Vzb21lX3FhX21vZGVsJTIyJTJDJTBBJTIwJTIwJTIwJTIwZXZhbF9zdHJhdGVneSUzRCUyMmVwb2NoJTIyJTJDJTBBJTIwJTIwJTIwJTIwbGVhcm5pbmdfcmF0ZSUzRDJlLTUlMkMlMEElMjAlMjAlMjAlMjBwZXJfZGV2aWNlX3RyYWluX2JhdGNoX3NpemUlM0QxNiUyQyUwQSUyMCUyMCUyMCUyMHBlcl9kZXZpY2VfZXZhbF9iYXRjaF9zaXplJTNEMTYlMkMlMEElMjAlMjAlMjAlMjBudW1fdHJhaW5fZXBvY2hzJTNEMyUyQyUwQSUyMCUyMCUyMCUyMHdlaWdodF9kZWNheSUzRDAuMDElMkMlMEElMjAlMjAlMjAlMjBwdXNoX3RvX2h1YiUzRFRydWUlMkMlMEEpJTBBJTBBdHJhaW5lciUyMCUzRCUyMFRyYWluZXIoJTBBJTIwJTIwJTIwJTIwbW9kZWwlM0Rtb2RlbCUyQyUwQSUyMCUyMCUyMCUyMGFyZ3MlM0R0cmFpbmluZ19hcmdzJTJDJTBBJTIwJTIwJTIwJTIwdHJhaW5fZGF0YXNldCUzRHRva2VuaXplZF9zcXVhZCU1QiUyMnRyYWluJTIyJTVEJTJDJTBBJTIwJTIwJTIwJTIwZXZhbF9kYXRhc2V0JTNEdG9rZW5pemVkX3NxdWFkJTVCJTIydGVzdCUyMiU1RCUyQyUwQSUyMCUyMCUyMCUyMHByb2Nlc3NpbmdfY2xhc3MlM0R0b2tlbml6ZXIlMkMlMEElMjAlMjAlMjAlMjBkYXRhX2NvbGxhdG9yJTNEZGF0YV9jb2xsYXRvciUyQyUwQSklMEElMEF0cmFpbmVyLnRyYWluKCk=",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>    processing_class=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 x({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,G=i(),b=y("ol"),b.innerHTML=E,R=i(),u(C.$$.fragment),W=i(),_=y("p"),_.innerHTML=V,A=i(),u(Z.$$.fragment)},l(t){j(l.$$.fragment,t),m=o(t),e=J(t,"P",{"data-svelte-h":!0}),T(e)!=="svelte-1ccw3g6"&&(e.innerHTML=M),g=o(t),j(U.$$.fragment,t),v=o(t),k=J(t,"P",{"data-svelte-h":!0}),T(k)!=="svelte-1j8bgyv"&&(k.textContent=X),G=o(t),b=J(t,"OL",{"data-svelte-h":!0}),T(b)!=="svelte-6a0gim"&&(b.innerHTML=E),R=o(t),j(C.$$.fragment,t),W=o(t),_=J(t,"P",{"data-svelte-h":!0}),T(_)!=="svelte-ngexm3"&&(_.innerHTML=V),A=o(t),j(Z.$$.fragment,t)},m(t,c){f(l,t,c),n(t,m,c),n(t,e,c),n(t,g,c),f(U,t,c),n(t,v,c),n(t,k,c),n(t,G,c),n(t,b,c),n(t,R,c),f(C,t,c),n(t,W,c),n(t,_,c),n(t,A,c),f(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(G),a(b),a(R),a(W),a(_),a(A)),d(l,t),d(U,t),d(C,t),d(Z,t)}}}function ie(I){let l,m;return l=new Gs({props:{$$slots:{default:[re]},$$scope:{ctx:I}}}),{c(){u(l.$$.fragment)},l(e){j(l.$$.fragment,e)},m(e,M){f(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/main/ja/model_doc/auto#transformers.TFAutoModelForQuestionAnswering">TFAutoModelForQuestionAnswering</a> を使用して DistilBERT をロードできます。',G,b,E,R,C='<a href="/docs/transformers/main/ja/main_classes/model#transformers.TFPreTrainedModel.prepare_tf_dataset">prepare_tf_dataset()</a> を使用して、データセットを <code>tf.data.Dataset</code> 形式に変換します。',W,_,V,A,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/main/ja/main_classes/keras_callbacks#transformers.PushToHubCallback">PushToHubCallback</a> でプッシュする場所を指定することで実行できます。',H,Y,L,F,ls='ついに、モデルのトレーニングを開始する準備が整いました。トレーニングおよび検証データセット、エポック数、コールバックを指定して <a href="https://keras.io/api/models/model_training_apis/#fit-method" rel="nofollow"><code>fit</code></a> を呼び出し、モデルを微調整します。',Q,S,D,N,as="トレーニングが完了すると、モデルは自動的にハブにアップロードされ、誰でも使用できるようになります。",q;return l=new Tt({props:{$$slots:{default:[oe]},$$scope:{ctx:I}}}),U=new x({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}}),b=new x({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 x({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 x({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 x({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 x({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,G=i(),u(b.$$.fragment),E=i(),R=y("p"),R.innerHTML=C,W=i(),u(_.$$.fragment),V=i(),A=y("p"),A.innerHTML=Z,B=i(),u(t.$$.fragment),c=i(),z=y("p"),z.innerHTML=es,H=i(),u(Y.$$.fragment),L=i(),F=y("p"),F.innerHTML=ls,Q=i(),u(S.$$.fragment),D=i(),N=y("p"),N.textContent=as},l(r){j(l.$$.fragment,r),m=o(r),e=J(r,"P",{"data-svelte-h":!0}),T(e)!=="svelte-1v9esfa"&&(e.textContent=M),g=o(r),j(U.$$.fragment,r),v=o(r),k=J(r,"P",{"data-svelte-h":!0}),T(k)!=="svelte-v7z9oi"&&(k.innerHTML=X),G=o(r),j(b.$$.fragment,r),E=o(r),R=J(r,"P",{"data-svelte-h":!0}),T(R)!=="svelte-1mdvspu"&&(R.innerHTML=C),W=o(r),j(_.$$.fragment,r),V=o(r),A=J(r,"P",{"data-svelte-h":!0}),T(A)!=="svelte-kzu0b7"&&(A.innerHTML=Z),B=o(r),j(t.$$.fragment,r),c=o(r),z=J(r,"P",{"data-svelte-h":!0}),T(z)!=="svelte-1pxwj56"&&(z.innerHTML=es),H=o(r),j(Y.$$.fragment,r),L=o(r),F=J(r,"P",{"data-svelte-h":!0}),T(F)!=="svelte-ffgub5"&&(F.innerHTML=ls),Q=o(r),j(S.$$.fragment,r),D=o(r),N=J(r,"P",{"data-svelte-h":!0}),T(N)!=="svelte-vh7z0v"&&(N.textContent=as)},m(r,$){f(l,r,$),n(r,m,$),n(r,e,$),n(r,g,$),f(U,r,$),n(r,v,$),n(r,k,$),n(r,G,$),f(b,r,$),n(r,E,$),n(r,R,$),n(r,W,$),f(_,r,$),n(r,V,$),n(r,A,$),n(r,B,$),f(t,r,$),n(r,c,$),n(r,z,$),n(r,H,$),f(Y,r,$),n(r,L,$),n(r,F,$),n(r,Q,$),f(S,r,$),n(r,D,$),n(r,N,$),q=!0},p(r,$){const vs={};$&2&&(vs.$$scope={dirty:$,ctx:r}),l.$set(vs)},i(r){q||(w(l.$$.fragment,r),w(U.$$.fragment,r),w(b.$$.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(b.$$.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(G),a(E),a(R),a(W),a(V),a(A),a(B),a(c),a(z),a(H),a(L),a(F),a(Q),a(D),a(N)),d(l,r),d(U,r),d(b,r),d(_,r),d(t,r),d(Y,r),d(S,r)}}}function Me(I){let l,m;return l=new Gs({props:{$$slots:{default:[me]},$$scope:{ctx:I}}}),{c(){u(l.$$.fragment)},l(e){j(l.$$.fragment,e)},m(e,M){f(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,G,b,E="モデル出力から開始位置と終了位置の最も高い確率を取得します。",R,C,W,_,V="予測されたトークンをデコードして答えを取得します。",A,Z,B;return M=new x({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 x({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 x({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 x({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),G=i(),b=y("p"),b.textContent=E,R=i(),u(C.$$.fragment),W=i(),_=y("p"),_.textContent=V,A=i(),u(Z.$$.fragment)},l(t){l=J(t,"P",{"data-svelte-h":!0}),T(l)!=="svelte-1n0k6or"&&(l.textContent=m),e=o(t),j(M.$$.fragment,t),g=o(t),U=J(t,"P",{"data-svelte-h":!0}),T(U)!=="svelte-1rvunpz"&&(U.innerHTML=v),k=o(t),j(X.$$.fragment,t),G=o(t),b=J(t,"P",{"data-svelte-h":!0}),T(b)!=="svelte-bytl0h"&&(b.textContent=E),R=o(t),j(C.$$.fragment,t),W=o(t),_=J(t,"P",{"data-svelte-h":!0}),T(_)!=="svelte-1yq6861"&&(_.textContent=V),A=o(t),j(Z.$$.fragment,t)},m(t,c){n(t,l,c),n(t,e,c),f(M,t,c),n(t,g,c),n(t,U,c),n(t,k,c),f(X,t,c),n(t,G,c),n(t,b,c),n(t,R,c),f(C,t,c),n(t,W,c),n(t,_,c),n(t,A,c),f(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(G),a(b),a(R),a(W),a(_),a(A)),d(M,t),d(X,t),d(C,t),d(Z,t)}}}function je(I){let l,m;return l=new Gs({props:{$$slots:{default:[ue]},$$scope:{ctx:I}}}),{c(){u(l.$$.fragment)},l(e){j(l.$$.fragment,e)},m(e,M){f(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 fe(I){let l,m="テキストをトークン化し、TensorFlow テンソルを返します。",e,M,g,U,v="入力をモデルに渡し、<code>logits</code>を返します。",k,X,G,b,E="モデル出力から開始位置と終了位置の最も高い確率を取得します。",R,C,W,_,V="予測されたトークンをデコードして答えを取得します。",A,Z,B;return M=new x({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 x({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 x({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 x({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),G=i(),b=y("p"),b.textContent=E,R=i(),u(C.$$.fragment),W=i(),_=y("p"),_.textContent=V,A=i(),u(Z.$$.fragment)},l(t){l=J(t,"P",{"data-svelte-h":!0}),T(l)!=="svelte-1bnmfqq"&&(l.textContent=m),e=o(t),j(M.$$.fragment,t),g=o(t),U=J(t,"P",{"data-svelte-h":!0}),T(U)!=="svelte-1rvunpz"&&(U.innerHTML=v),k=o(t),j(X.$$.fragment,t),G=o(t),b=J(t,"P",{"data-svelte-h":!0}),T(b)!=="svelte-bytl0h"&&(b.textContent=E),R=o(t),j(C.$$.fragment,t),W=o(t),_=J(t,"P",{"data-svelte-h":!0}),T(_)!=="svelte-1yq6861"&&(_.textContent=V),A=o(t),j(Z.$$.fragment,t)},m(t,c){n(t,l,c),n(t,e,c),f(M,t,c),n(t,g,c),n(t,U,c),n(t,k,c),f(X,t,c),n(t,G,c),n(t,b,c),n(t,R,c),f(C,t,c),n(t,W,c),n(t,_,c),n(t,A,c),f(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(G),a(b),a(R),a(W),a(_),a(A)),d(M,t),d(X,t),d(C,t),d(Z,t)}}}function we(I){let l,m;return l=new Gs({props:{$$slots:{default:[fe]},$$scope:{ctx:I}}}),{c(){u(l.$$.fragment)},l(e){j(l.$$.fragment,e)},m(e,M){f(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,G,b,E="質問応答タスクは、質問に対して回答を返します。 Alexa、Siri、Google などの仮想アシスタントに天気を尋ねたことがあるなら、質問応答モデルを使用したことがあるはずです。質問応答タスクには一般的に 2 つのタイプがあります。",R,C,W="<li>抽出: 与えられたコンテキストから回答を抽出します。</li> <li>抽象的: 質問に正しく答えるコンテキストから回答を生成します。</li>",_,V,A="このガイドでは、次の方法を説明します。",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,H,Y="始める前に、必要なライブラリがすべてインストールされていることを確認してください。",L,F,ls,Q,S="モデルをアップロードしてコミュニティと共有できるように、Hugging Face アカウントにログインすることをお勧めします。プロンプトが表示されたら、トークンを入力してログインします。",D,N,as,q,r,$,vs="まず、🤗 データセット ライブラリから SQuAD データセットの小さいサブセットを読み込みます。これにより、完全なデータセットのトレーニングにさらに時間を費やす前に、実験してすべてが機能することを確認する機会が得られます。",Vs,ns,zs,ps,bt="<code>train_test_split</code> メソッドを使用して、データセットの <code>train</code> 分割をトレイン セットとテスト セットに分割します。",Es,rs,Fs,is,$t="次に、例を見てみましょう。",Ns,os,Hs,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,js,Ct="次のステップでは、DistilBERT トークナイザーをロードして<code>question</code>フィールドと<code>context</code>フィールドを処理します。",Ls,fs,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,xt="次に、<code>DefaultDataCollat​​or</code> を使用してサンプルのバッチを作成します。 🤗 Transformers の他のデータ照合器とは異なり、<code>DefaultDataCollat​​or</code> はパディングなどの追加の前処理を適用しません。",lt,P,at,bs,nt,K,pt,O,rt,$s,it,Us,Rt='質問応答の評価には、大量の後処理が必要です。時間がかかりすぎないように、このガイドでは評価ステップを省略しています。 <a href="/docs/transformers/main/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,At="モデルを微調整したので、それを推論に使用できるようになりました。",ct,Zs,Gt="質問と、モデルに予測させたいコンテキストを考え出します。",ut,ks,jt,Xs,vt='推論用に微調整されたモデルを試す最も簡単な方法は、それを <a href="/docs/transformers/main/ja/main_classes/pipelines#transformers.pipeline">pipeline()</a> で使用することです。モデルを使用して質問応答用の<code>pipeline</code>をインスタンス化し、それにテキストを渡します。',ft,xs,wt,Rs,Wt="必要に応じて、<code>pipeline</code>の結果を手動で複製することもできます。",ht,ss,dt,Bs,yt,Ws,Jt;return g=new As({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}}}),F=new x({props:{code:"cGlwJTIwaW5zdGFsbCUyMHRyYW5zZm9ybWVycyUyMGRhdGFzZXRzJTIwZXZhbHVhdGU=",highlighted:"pip install transformers datasets evaluate",wrap:!1}}),N=new x({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 As({props:{title:"Load SQuAD dataset",local:"load-squad-dataset",headingTag:"h2"}}),ns=new x({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 x({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 x({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 As({props:{title:"Preprocess",local:"preprocess",headingTag:"h2"}}),us=new qt({props:{id:"qgaM0weJHpA"}}),fs=new x({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 x({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 x({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}}}),bs=new As({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}}}),$s=new As({props:{title:"Evaluate",local:"evaluate",headingTag:"h2"}}),Cs=new As({props:{title:"Inference",local:"inference",headingTag:"h2"}}),ks=new x({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}}),xs=new x({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:[je]},$$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),G=i(),b=y("p"),b.textContent=E,R=i(),C=y("ul"),C.innerHTML=W,_=i(),V=y("p"),V.textContent=A,Z=i(),B=y("ol"),B.innerHTML=t,c=i(),u(z.$$.fragment),es=i(),H=y("p"),H.textContent=Y,L=i(),u(F.$$.fragment),ls=i(),Q=y("p"),Q.textContent=S,D=i(),u(N.$$.fragment),as=i(),u(q.$$.fragment),r=i(),$=y("p"),$.textContent=vs,Vs=i(),u(ns.$$.fragment),zs=i(),ps=y("p"),ps.innerHTML=bt,Es=i(),u(rs.$$.fragment),Fs=i(),is=y("p"),is.textContent=$t,Ns=i(),u(os.$$.fragment),Hs=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(),js=y("p"),js.innerHTML=Ct,Ls=i(),u(fs.$$.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=xt,lt=i(),u(P.$$.fragment),at=i(),u(bs.$$.fragment),nt=i(),u(K.$$.fragment),pt=i(),u(O.$$.fragment),rt=i(),u($s.$$.fragment),it=i(),Us=y("p"),Us.innerHTML=Rt,ot=i(),_s=y("p"),_s.innerHTML=Bt,mt=i(),u(Cs.$$.fragment),Mt=i(),Is=y("p"),Is.textContent=At,ct=i(),Zs=y("p"),Zs.textContent=Gt,ut=i(),u(ks.$$.fragment),jt=i(),Xs=y("p"),Xs.innerHTML=vt,ft=i(),u(xs.$$.fragment),wt=i(),Rs=y("p"),Rs.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",{}),Ht(e).forEach(a),M=o(s),j(g.$$.fragment,s),U=o(s),j(v.$$.fragment,s),k=o(s),j(X.$$.fragment,s),G=o(s),b=J(s,"P",{"data-svelte-h":!0}),T(b)!=="svelte-1tgwu4t"&&(b.textContent=E),R=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=A),Z=o(s),B=J(s,"OL",{"data-svelte-h":!0}),T(B)!=="svelte-o857bo"&&(B.innerHTML=t),c=o(s),j(z.$$.fragment,s),es=o(s),H=J(s,"P",{"data-svelte-h":!0}),T(H)!=="svelte-1lya3k8"&&(H.textContent=Y),L=o(s),j(F.$$.fragment,s),ls=o(s),Q=J(s,"P",{"data-svelte-h":!0}),T(Q)!=="svelte-193zy02"&&(Q.textContent=S),D=o(s),j(N.$$.fragment,s),as=o(s),j(q.$$.fragment,s),r=o(s),$=J(s,"P",{"data-svelte-h":!0}),T($)!=="svelte-12zmynt"&&($.textContent=vs),Vs=o(s),j(ns.$$.fragment,s),zs=o(s),ps=J(s,"P",{"data-svelte-h":!0}),T(ps)!=="svelte-m4w3yq"&&(ps.innerHTML=bt),Es=o(s),j(rs.$$.fragment,s),Fs=o(s),is=J(s,"P",{"data-svelte-h":!0}),T(is)!=="svelte-1r6oj5w"&&(is.textContent=$t),Ns=o(s),j(os.$$.fragment,s),Hs=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),j(cs.$$.fragment,s),Ys=o(s),j(us.$$.fragment,s),Ss=o(s),js=J(s,"P",{"data-svelte-h":!0}),T(js)!=="svelte-1bamyze"&&(js.innerHTML=Ct),Ls=o(s),j(fs.$$.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),j(ys.$$.fragment,s),st=o(s),Js=J(s,"P",{"data-svelte-h":!0}),T(Js)!=="svelte-t1eqy4"&&(Js.innerHTML=Xt),tt=o(s),j(Ts.$$.fragment,s),et=o(s),gs=J(s,"P",{"data-svelte-h":!0}),T(gs)!=="svelte-me6jz3"&&(gs.innerHTML=xt),lt=o(s),j(P.$$.fragment,s),at=o(s),j(bs.$$.fragment,s),nt=o(s),j(K.$$.fragment,s),pt=o(s),j(O.$$.fragment,s),rt=o(s),j($s.$$.fragment,s),it=o(s),Us=J(s,"P",{"data-svelte-h":!0}),T(Us)!=="svelte-ymflc5"&&(Us.innerHTML=Rt),ot=o(s),_s=J(s,"P",{"data-svelte-h":!0}),T(_s)!=="svelte-ihy4ok"&&(_s.innerHTML=Bt),mt=o(s),j(Cs.$$.fragment,s),Mt=o(s),Is=J(s,"P",{"data-svelte-h":!0}),T(Is)!=="svelte-cyrfc8"&&(Is.textContent=At),ct=o(s),Zs=J(s,"P",{"data-svelte-h":!0}),T(Zs)!=="svelte-151wogl"&&(Zs.textContent=Gt),ut=o(s),j(ks.$$.fragment,s),jt=o(s),Xs=J(s,"P",{"data-svelte-h":!0}),T(Xs)!=="svelte-1u43xdx"&&(Xs.innerHTML=vt),ft=o(s),j(xs.$$.fragment,s),wt=o(s),Rs=J(s,"P",{"data-svelte-h":!0}),T(Rs)!=="svelte-p649vi"&&(Rs.innerHTML=Wt),ht=o(s),j(ss.$$.fragment,s),dt=o(s),j(Bs.$$.fragment,s),yt=o(s),Ws=J(s,"P",{}),Ht(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),f(g,s,p),n(s,U,p),f(v,s,p),n(s,k,p),f(X,s,p),n(s,G,p),n(s,b,p),n(s,R,p),n(s,C,p),n(s,_,p),n(s,V,p),n(s,Z,p),n(s,B,p),n(s,c,p),f(z,s,p),n(s,es,p),n(s,H,p),n(s,L,p),f(F,s,p),n(s,ls,p),n(s,Q,p),n(s,D,p),f(N,s,p),n(s,as,p),f(q,s,p),n(s,r,p),n(s,$,p),n(s,Vs,p),f(ns,s,p),n(s,zs,p),n(s,ps,p),n(s,Es,p),f(rs,s,p),n(s,Fs,p),n(s,is,p),n(s,Ns,p),f(os,s,p),n(s,Hs,p),n(s,ms,p),n(s,Qs,p),n(s,Ms,p),n(s,qs,p),f(cs,s,p),n(s,Ys,p),f(us,s,p),n(s,Ss,p),n(s,js,p),n(s,Ls,p),f(fs,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),f(ys,s,p),n(s,st,p),n(s,Js,p),n(s,tt,p),f(Ts,s,p),n(s,et,p),n(s,gs,p),n(s,lt,p),f(P,s,p),n(s,at,p),f(bs,s,p),n(s,nt,p),f(K,s,p),n(s,pt,p),f(O,s,p),n(s,rt,p),f($s,s,p),n(s,it,p),n(s,Us,p),n(s,ot,p),n(s,_s,p),n(s,mt,p),f(Cs,s,p),n(s,Mt,p),n(s,Is,p),n(s,ct,p),n(s,Zs,p),n(s,ut,p),f(ks,s,p),n(s,jt,p),n(s,Xs,p),n(s,ft,p),f(xs,s,p),n(s,wt,p),n(s,Rs,p),n(s,ht,p),f(ss,s,p),n(s,dt,p),f(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 Et={};p&2&&(Et.$$scope={dirty:p,ctx:s}),K.$set(Et);const Ft={};p&2&&(Ft.$$scope={dirty:p,ctx:s}),O.$set(Ft);const Nt={};p&2&&(Nt.$$scope={dirty:p,ctx:s}),ss.$set(Nt)},i(s){Jt||(w(g.$$.fragment,s),w(v.$$.fragment,s),w(X.$$.fragment,s),w(z.$$.fragment,s),w(F.$$.fragment,s),w(N.$$.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(fs.$$.fragment,s),w(ys.$$.fragment,s),w(Ts.$$.fragment,s),w(P.$$.fragment,s),w(bs.$$.fragment,s),w(K.$$.fragment,s),w(O.$$.fragment,s),w($s.$$.fragment,s),w(Cs.$$.fragment,s),w(ks.$$.fragment,s),w(xs.$$.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(F.$$.fragment,s),h(N.$$.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(fs.$$.fragment,s),h(ys.$$.fragment,s),h(Ts.$$.fragment,s),h(P.$$.fragment,s),h(bs.$$.fragment,s),h(K.$$.fragment,s),h(O.$$.fragment,s),h($s.$$.fragment,s),h(Cs.$$.fragment,s),h(ks.$$.fragment,s),h(xs.$$.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(G),a(b),a(R),a(C),a(_),a(V),a(Z),a(B),a(c),a(es),a(H),a(L),a(ls),a(Q),a(D),a(as),a(r),a($),a(Vs),a(zs),a(ps),a(Es),a(Fs),a(is),a(Ns),a(Hs),a(ms),a(Qs),a(Ms),a(qs),a(Ys),a(Ss),a(js),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(jt),a(Xs),a(ft),a(wt),a(Rs),a(ht),a(dt),a(yt),a(Ws)),a(l),d(g,s),d(v,s),d(X,s),d(z,s),d(F,s),d(N,s),d(q,s),d(ns,s),d(rs,s),d(os,s),d(cs,s),d(us,s),d(fs,s),d(ys,s),d(Ts,s),d(P,s),d(bs,s),d(K,s),d(O,s),d($s,s),d(Cs,s),d(ks,s),d(xs,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};
