import{s as Yt,o as St,n as ee}from"../chunks/scheduler.25b97de1.js";import{S as Lt,i as Dt,g,s as o,r as M,A as Pt,h as T,f as l,c as i,j as Nt,u as h,x as J,k as Qt,y as Kt,a as n,v as f,d,t as w,w as y,m as Ot,n as es}from"../chunks/index.d9030fc9.js";import{T as gt}from"../chunks/Tip.baa67368.js";import{Y as qt}from"../chunks/Youtube.eaf1a617.js";import{C as R}from"../chunks/CodeBlock.e6cd0d95.js";import{D as ts}from"../chunks/DocNotebookDropdown.5ea6cb78.js";import{F as Tt,M as Re}from"../chunks/Markdown.7217f838.js";import{H as xe,E as ss}from"../chunks/EditOnGithub.91d95064.js";function as(C){let a,m='To see all architectures and checkpoints compatible with this task, we recommend checking the <a href="https://huggingface.co/tasks/question-answering" rel="nofollow">task-page</a>';return{c(){a=g("p"),a.innerHTML=m},l(s){a=T(s,"P",{"data-svelte-h":!0}),J(a)!=="svelte-19lbpy7"&&(a.innerHTML=m)},m(s,c){n(s,a,c)},p:ee,d(s){s&&l(a)}}}function ls(C){let a,m;return a=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(){M(a.$$.fragment)},l(s){h(a.$$.fragment,s)},m(s,c){f(a,s,c),m=!0},p:ee,i(s){m||(d(a.$$.fragment,s),m=!0)},o(s){w(a.$$.fragment,s),m=!1},d(s){y(a,s)}}}function ns(C){let a,m;return a=new Re({props:{$$slots:{default:[ls]},$$scope:{ctx:C}}}),{c(){M(a.$$.fragment)},l(s){h(a.$$.fragment,s)},m(s,c){f(a,s,c),m=!0},p(s,c){const j={};c&2&&(j.$$scope={dirty:c,ctx:s}),a.$set(j)},i(s){m||(d(a.$$.fragment,s),m=!0)},o(s){w(a.$$.fragment,s),m=!1},d(s){y(a,s)}}}function rs(C){let a,m;return a=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(){M(a.$$.fragment)},l(s){h(a.$$.fragment,s)},m(s,c){f(a,s,c),m=!0},p:ee,i(s){m||(d(a.$$.fragment,s),m=!0)},o(s){w(a.$$.fragment,s),m=!1},d(s){y(a,s)}}}function ps(C){let a,m;return a=new Re({props:{$$slots:{default:[rs]},$$scope:{ctx:C}}}),{c(){M(a.$$.fragment)},l(s){h(a.$$.fragment,s)},m(s,c){f(a,s,c),m=!0},p(s,c){const j={};c&2&&(j.$$scope={dirty:c,ctx:s}),a.$set(j)},i(s){m||(d(a.$$.fragment,s),m=!0)},o(s){w(a.$$.fragment,s),m=!1},d(s){y(a,s)}}}function os(C){let a,m='If you aren’t familiar with finetuning a model with the <a href="/docs/transformers/pr_29693/en/main_classes/trainer#transformers.Trainer">Trainer</a>, take a look at the basic tutorial <a href="../training#train-with-pytorch-trainer">here</a>!';return{c(){a=g("p"),a.innerHTML=m},l(s){a=T(s,"P",{"data-svelte-h":!0}),J(a)!=="svelte-1tjah5b"&&(a.innerHTML=m)},m(s,c){n(s,a,c)},p:ee,d(s){s&&l(a)}}}function is(C){let a,m,s,c='You’re ready to start training your model now! Load DistilBERT with <a href="/docs/transformers/pr_29693/en/model_doc/auto#transformers.AutoModelForQuestionAnswering">AutoModelForQuestionAnswering</a>:',j,I,W,X,k="At this point, only three steps remain:",v,$,F='<li>Define your training hyperparameters in <a href="/docs/transformers/pr_29693/en/main_classes/trainer#transformers.TrainingArguments">TrainingArguments</a>. The only required parameter is <code>output_dir</code> which specifies where to save your model. You’ll push this model to the Hub by setting <code>push_to_hub=True</code> (you need to be signed in to Hugging Face to upload your model).</li> <li>Pass the training arguments to <a href="/docs/transformers/pr_29693/en/main_classes/trainer#transformers.Trainer">Trainer</a> along with the model, dataset, tokenizer, and data collator.</li> <li>Call <a href="/docs/transformers/pr_29693/en/main_classes/trainer#transformers.Trainer.train">train()</a> to finetune your model.</li>',B,b,G,Z,V='Once training is completed, share your model to the Hub with the <a href="/docs/transformers/pr_29693/en/main_classes/trainer#transformers.Trainer.push_to_hub">push_to_hub()</a> method so everyone can use your model:',A,U,x;return a=new gt({props:{$$slots:{default:[os]},$$scope:{ctx:C}}}),I=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}}),b=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}}),U=new R({props:{code:"dHJhaW5lci5wdXNoX3RvX2h1Yigp",highlighted:'<span class="hljs-meta">&gt;&gt;&gt; </span>trainer.push_to_hub()',wrap:!1}}),{c(){M(a.$$.fragment),m=o(),s=g("p"),s.innerHTML=c,j=o(),M(I.$$.fragment),W=o(),X=g("p"),X.textContent=k,v=o(),$=g("ol"),$.innerHTML=F,B=o(),M(b.$$.fragment),G=o(),Z=g("p"),Z.innerHTML=V,A=o(),M(U.$$.fragment)},l(t){h(a.$$.fragment,t),m=i(t),s=T(t,"P",{"data-svelte-h":!0}),J(s)!=="svelte-rpy45t"&&(s.innerHTML=c),j=i(t),h(I.$$.fragment,t),W=i(t),X=T(t,"P",{"data-svelte-h":!0}),J(X)!=="svelte-l42k0i"&&(X.textContent=k),v=i(t),$=T(t,"OL",{"data-svelte-h":!0}),J($)!=="svelte-bimhnd"&&($.innerHTML=F),B=i(t),h(b.$$.fragment,t),G=i(t),Z=T(t,"P",{"data-svelte-h":!0}),J(Z)!=="svelte-1rrz0ht"&&(Z.innerHTML=V),A=i(t),h(U.$$.fragment,t)},m(t,u){f(a,t,u),n(t,m,u),n(t,s,u),n(t,j,u),f(I,t,u),n(t,W,u),n(t,X,u),n(t,v,u),n(t,$,u),n(t,B,u),f(b,t,u),n(t,G,u),n(t,Z,u),n(t,A,u),f(U,t,u),x=!0},p(t,u){const z={};u&2&&(z.$$scope={dirty:u,ctx:t}),a.$set(z)},i(t){x||(d(a.$$.fragment,t),d(I.$$.fragment,t),d(b.$$.fragment,t),d(U.$$.fragment,t),x=!0)},o(t){w(a.$$.fragment,t),w(I.$$.fragment,t),w(b.$$.fragment,t),w(U.$$.fragment,t),x=!1},d(t){t&&(l(m),l(s),l(j),l(W),l(X),l(v),l($),l(B),l(G),l(Z),l(A)),y(a,t),y(I,t),y(b,t),y(U,t)}}}function ms(C){let a,m;return a=new Re({props:{$$slots:{default:[is]},$$scope:{ctx:C}}}),{c(){M(a.$$.fragment)},l(s){h(a.$$.fragment,s)},m(s,c){f(a,s,c),m=!0},p(s,c){const j={};c&2&&(j.$$scope={dirty:c,ctx:s}),a.$set(j)},i(s){m||(d(a.$$.fragment,s),m=!0)},o(s){w(a.$$.fragment,s),m=!1},d(s){y(a,s)}}}function cs(C){let a,m='If you aren’t familiar with finetuning a model with Keras, take a look at the basic tutorial <a href="../training#train-a-tensorflow-model-with-keras">here</a>!';return{c(){a=g("p"),a.innerHTML=m},l(s){a=T(s,"P",{"data-svelte-h":!0}),J(a)!=="svelte-1rd4nl8"&&(a.innerHTML=m)},m(s,c){n(s,a,c)},p:ee,d(s){s&&l(a)}}}function us(C){let a,m,s,c,j,I='Then you can load DistilBERT with <a href="/docs/transformers/pr_29693/en/model_doc/auto#transformers.TFAutoModelForQuestionAnswering">TFAutoModelForQuestionAnswering</a>:',W,X,k,v,$='Convert your datasets to the <code>tf.data.Dataset</code> format with <a href="/docs/transformers/pr_29693/en/main_classes/model#transformers.TFPreTrainedModel.prepare_tf_dataset">prepare_tf_dataset()</a>:',F,B,b,G,Z='Configure the model for training with <a href="https://keras.io/api/models/model_training_apis/#compile-method" rel="nofollow"><code>compile</code></a>:',V,A,U,x,t='The last thing to setup before you start training is to provide a way to push your model to the Hub. This can be done by specifying where to push your model and tokenizer in the <a href="/docs/transformers/pr_29693/en/main_classes/keras_callbacks#transformers.PushToHubCallback">PushToHubCallback</a>:',u,z,q,E,ve='Finally, you’re ready to start training your model! Call <a href="https://keras.io/api/models/model_training_apis/#fit-method" rel="nofollow"><code>fit</code></a> with your training and validation datasets, the number of epochs, and your callback to finetune the model:',Y,H,S,N,Be="Once training is completed, your model is automatically uploaded to the Hub so everyone can use it!",L;return a=new gt({props:{$$slots:{default:[cs]},$$scope:{ctx:C}}}),s=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}}),X=new R({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMFRGQXV0b01vZGVsRm9yUXVlc3Rpb25BbnN3ZXJpbmclMEElMEFtb2RlbCUyMCUzRCUyMFRGQXV0b01vZGVsRm9yUXVlc3Rpb25BbnN3ZXJpbmcuZnJvbV9wcmV0cmFpbmVkKCUyMmRpc3RpbGJlcnQlMkZkaXN0aWxiZXJ0LWJhc2UtdW5jYXNlZCUyMik=",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;distilbert/distilbert-base-uncased&quot;</span>)`,wrap:!1}}),B=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}}),A=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}}),z=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}}),H=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(){M(a.$$.fragment),m=Ot(`
To finetune a model in TensorFlow, start by setting up an optimizer function, learning rate schedule, and some training hyperparameters:

	`),M(s.$$.fragment),c=o(),j=g("p"),j.innerHTML=I,W=o(),M(X.$$.fragment),k=o(),v=g("p"),v.innerHTML=$,F=o(),M(B.$$.fragment),b=o(),G=g("p"),G.innerHTML=Z,V=o(),M(A.$$.fragment),U=o(),x=g("p"),x.innerHTML=t,u=o(),M(z.$$.fragment),q=o(),E=g("p"),E.innerHTML=ve,Y=o(),M(H.$$.fragment),S=o(),N=g("p"),N.textContent=Be},l(p){h(a.$$.fragment,p),m=es(p,`
To finetune a model in TensorFlow, start by setting up an optimizer function, learning rate schedule, and some training hyperparameters:

	`),h(s.$$.fragment,p),c=i(p),j=T(p,"P",{"data-svelte-h":!0}),J(j)!=="svelte-7mk4tf"&&(j.innerHTML=I),W=i(p),h(X.$$.fragment,p),k=i(p),v=T(p,"P",{"data-svelte-h":!0}),J(v)!=="svelte-ua9jbs"&&(v.innerHTML=$),F=i(p),h(B.$$.fragment,p),b=i(p),G=T(p,"P",{"data-svelte-h":!0}),J(G)!=="svelte-rt1r5v"&&(G.innerHTML=Z),V=i(p),h(A.$$.fragment,p),U=i(p),x=T(p,"P",{"data-svelte-h":!0}),J(x)!=="svelte-3brwsr"&&(x.innerHTML=t),u=i(p),h(z.$$.fragment,p),q=i(p),E=T(p,"P",{"data-svelte-h":!0}),J(E)!=="svelte-1pfsro2"&&(E.innerHTML=ve),Y=i(p),h(H.$$.fragment,p),S=i(p),N=T(p,"P",{"data-svelte-h":!0}),J(N)!=="svelte-2s71om"&&(N.textContent=Be)},m(p,_){f(a,p,_),n(p,m,_),f(s,p,_),n(p,c,_),n(p,j,_),n(p,W,_),f(X,p,_),n(p,k,_),n(p,v,_),n(p,F,_),f(B,p,_),n(p,b,_),n(p,G,_),n(p,V,_),f(A,p,_),n(p,U,_),n(p,x,_),n(p,u,_),f(z,p,_),n(p,q,_),n(p,E,_),n(p,Y,_),f(H,p,_),n(p,S,_),n(p,N,_),L=!0},p(p,_){const Q={};_&2&&(Q.$$scope={dirty:_,ctx:p}),a.$set(Q)},i(p){L||(d(a.$$.fragment,p),d(s.$$.fragment,p),d(X.$$.fragment,p),d(B.$$.fragment,p),d(A.$$.fragment,p),d(z.$$.fragment,p),d(H.$$.fragment,p),L=!0)},o(p){w(a.$$.fragment,p),w(s.$$.fragment,p),w(X.$$.fragment,p),w(B.$$.fragment,p),w(A.$$.fragment,p),w(z.$$.fragment,p),w(H.$$.fragment,p),L=!1},d(p){p&&(l(m),l(c),l(j),l(W),l(k),l(v),l(F),l(b),l(G),l(V),l(U),l(x),l(u),l(q),l(E),l(Y),l(S),l(N)),y(a,p),y(s,p),y(X,p),y(B,p),y(A,p),y(z,p),y(H,p)}}}function Ms(C){let a,m;return a=new Re({props:{$$slots:{default:[us]},$$scope:{ctx:C}}}),{c(){M(a.$$.fragment)},l(s){h(a.$$.fragment,s)},m(s,c){f(a,s,c),m=!0},p(s,c){const j={};c&2&&(j.$$scope={dirty:c,ctx:s}),a.$set(j)},i(s){m||(d(a.$$.fragment,s),m=!0)},o(s){w(a.$$.fragment,s),m=!1},d(s){y(a,s)}}}function hs(C){let a,m=`For a more in-depth example of how to finetune a model for question answering, take a look at the corresponding
<a href="https://colab.research.google.com/github/huggingface/notebooks/blob/main/examples/question_answering.ipynb" rel="nofollow">PyTorch notebook</a>
or <a href="https://colab.research.google.com/github/huggingface/notebooks/blob/main/examples/question_answering-tf.ipynb" rel="nofollow">TensorFlow notebook</a>.`;return{c(){a=g("p"),a.innerHTML=m},l(s){a=T(s,"P",{"data-svelte-h":!0}),J(a)!=="svelte-14amlb3"&&(a.innerHTML=m)},m(s,c){n(s,a,c)},p:ee,d(s){s&&l(a)}}}function fs(C){let a,m="Tokenize the text and return PyTorch tensors:",s,c,j,I,W="Pass your inputs to the model and return the <code>logits</code>:",X,k,v,$,F="Get the highest probability from the model output for the start and end positions:",B,b,G,Z,V="Decode the predicted tokens to get the answer:",A,U,x;return c=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}}),k=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}}),b=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}}),U=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(){a=g("p"),a.textContent=m,s=o(),M(c.$$.fragment),j=o(),I=g("p"),I.innerHTML=W,X=o(),M(k.$$.fragment),v=o(),$=g("p"),$.textContent=F,B=o(),M(b.$$.fragment),G=o(),Z=g("p"),Z.textContent=V,A=o(),M(U.$$.fragment)},l(t){a=T(t,"P",{"data-svelte-h":!0}),J(a)!=="svelte-1qcz1wr"&&(a.textContent=m),s=i(t),h(c.$$.fragment,t),j=i(t),I=T(t,"P",{"data-svelte-h":!0}),J(I)!=="svelte-f3g043"&&(I.innerHTML=W),X=i(t),h(k.$$.fragment,t),v=i(t),$=T(t,"P",{"data-svelte-h":!0}),J($)!=="svelte-v8itmt"&&($.textContent=F),B=i(t),h(b.$$.fragment,t),G=i(t),Z=T(t,"P",{"data-svelte-h":!0}),J(Z)!=="svelte-66bsyj"&&(Z.textContent=V),A=i(t),h(U.$$.fragment,t)},m(t,u){n(t,a,u),n(t,s,u),f(c,t,u),n(t,j,u),n(t,I,u),n(t,X,u),f(k,t,u),n(t,v,u),n(t,$,u),n(t,B,u),f(b,t,u),n(t,G,u),n(t,Z,u),n(t,A,u),f(U,t,u),x=!0},p:ee,i(t){x||(d(c.$$.fragment,t),d(k.$$.fragment,t),d(b.$$.fragment,t),d(U.$$.fragment,t),x=!0)},o(t){w(c.$$.fragment,t),w(k.$$.fragment,t),w(b.$$.fragment,t),w(U.$$.fragment,t),x=!1},d(t){t&&(l(a),l(s),l(j),l(I),l(X),l(v),l($),l(B),l(G),l(Z),l(A)),y(c,t),y(k,t),y(b,t),y(U,t)}}}function ds(C){let a,m;return a=new Re({props:{$$slots:{default:[fs]},$$scope:{ctx:C}}}),{c(){M(a.$$.fragment)},l(s){h(a.$$.fragment,s)},m(s,c){f(a,s,c),m=!0},p(s,c){const j={};c&2&&(j.$$scope={dirty:c,ctx:s}),a.$set(j)},i(s){m||(d(a.$$.fragment,s),m=!0)},o(s){w(a.$$.fragment,s),m=!1},d(s){y(a,s)}}}function ws(C){let a,m="Tokenize the text and return TensorFlow tensors:",s,c,j,I,W="Pass your inputs to the model and return the <code>logits</code>:",X,k,v,$,F="Get the highest probability from the model output for the start and end positions:",B,b,G,Z,V="Decode the predicted tokens to get the answer:",A,U,x;return c=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}}),k=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}}),b=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}}),U=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(){a=g("p"),a.textContent=m,s=o(),M(c.$$.fragment),j=o(),I=g("p"),I.innerHTML=W,X=o(),M(k.$$.fragment),v=o(),$=g("p"),$.textContent=F,B=o(),M(b.$$.fragment),G=o(),Z=g("p"),Z.textContent=V,A=o(),M(U.$$.fragment)},l(t){a=T(t,"P",{"data-svelte-h":!0}),J(a)!=="svelte-s1qr7b"&&(a.textContent=m),s=i(t),h(c.$$.fragment,t),j=i(t),I=T(t,"P",{"data-svelte-h":!0}),J(I)!=="svelte-f3g043"&&(I.innerHTML=W),X=i(t),h(k.$$.fragment,t),v=i(t),$=T(t,"P",{"data-svelte-h":!0}),J($)!=="svelte-v8itmt"&&($.textContent=F),B=i(t),h(b.$$.fragment,t),G=i(t),Z=T(t,"P",{"data-svelte-h":!0}),J(Z)!=="svelte-66bsyj"&&(Z.textContent=V),A=i(t),h(U.$$.fragment,t)},m(t,u){n(t,a,u),n(t,s,u),f(c,t,u),n(t,j,u),n(t,I,u),n(t,X,u),f(k,t,u),n(t,v,u),n(t,$,u),n(t,B,u),f(b,t,u),n(t,G,u),n(t,Z,u),n(t,A,u),f(U,t,u),x=!0},p:ee,i(t){x||(d(c.$$.fragment,t),d(k.$$.fragment,t),d(b.$$.fragment,t),d(U.$$.fragment,t),x=!0)},o(t){w(c.$$.fragment,t),w(k.$$.fragment,t),w(b.$$.fragment,t),w(U.$$.fragment,t),x=!1},d(t){t&&(l(a),l(s),l(j),l(I),l(X),l(v),l($),l(B),l(G),l(Z),l(A)),y(c,t),y(k,t),y(b,t),y(U,t)}}}function ys(C){let a,m;return a=new Re({props:{$$slots:{default:[ws]},$$scope:{ctx:C}}}),{c(){M(a.$$.fragment)},l(s){h(a.$$.fragment,s)},m(s,c){f(a,s,c),m=!0},p(s,c){const j={};c&2&&(j.$$scope={dirty:c,ctx:s}),a.$set(j)},i(s){m||(d(a.$$.fragment,s),m=!0)},o(s){w(a.$$.fragment,s),m=!1},d(s){y(a,s)}}}function js(C){let a,m,s,c,j,I,W,X,k,v,$,F="Question answering tasks return an answer given a question. If you’ve ever asked a virtual assistant like Alexa, Siri or Google what the weather is, then you’ve used a question answering model before. There are two common types of question answering tasks:",B,b,G="<li>Extractive: extract the answer from the given context.</li> <li>Abstractive: generate an answer from the context that correctly answers the question.</li>",Z,V,A="This guide will show you how to:",U,x,t='<li>Finetune <a href="https://huggingface.co/distilbert/distilbert-base-uncased" rel="nofollow">DistilBERT</a> on the <a href="https://huggingface.co/datasets/squad" rel="nofollow">SQuAD</a> dataset for extractive question answering.</li> <li>Use your finetuned model for inference.</li>',u,z,q,E,ve="Before you begin, make sure you have all the necessary libraries installed:",Y,H,S,N,Be="We encourage you to login to your Hugging Face account so you can upload and share your model with the community. When prompted, enter your token to login:",L,p,_,Q,Ae,te,Jt="Start by loading a smaller subset of the SQuAD dataset from the 🤗 Datasets library. This’ll give you a chance to experiment and make sure everything works before spending more time training on the full dataset.",We,se,Ve,ae,bt='Split the dataset’s <code>train</code> split into a train and test set with the <a href="https://huggingface.co/docs/datasets/main/en/package_reference/main_classes#datasets.Dataset.train_test_split" rel="nofollow">train_test_split</a> method:',ze,le,Fe,ne,$t="Then take a look at an example:",Ee,re,He,pe,Ut="There are several important fields here:",Ne,oe,_t="<li><code>answers</code>: the starting location of the answer token and the answer text.</li> <li><code>context</code>: background information from which the model needs to extract the answer.</li> <li><code>question</code>: the question a model should answer.</li>",Qe,ie,qe,me,Ye,ce,Ct="The next step is to load a DistilBERT tokenizer to process the <code>question</code> and <code>context</code> fields:",Se,ue,Le,Me,It="There are a few preprocessing steps particular to question answering tasks you should be aware of:",De,he,kt=`<li>Some examples in a dataset may have a very long <code>context</code> that exceeds the maximum input length of the model. To deal with longer sequences, truncate only the <code>context</code> by setting <code>truncation=&quot;only_second&quot;</code>.</li> <li>Next, map the start and end positions of the answer to the original <code>context</code> by setting
<code>return_offset_mapping=True</code>.</li> <li>With the mapping in hand, now you can find the start and end tokens of the answer. Use the <a href="https://huggingface.co/docs/tokenizers/main/en/api/encoding#tokenizers.Encoding.sequence_ids" rel="nofollow">sequence_ids</a> method to
find which part of the offset corresponds to the <code>question</code> and which corresponds to the <code>context</code>.</li>`,Pe,fe,Zt="Here is how you can create a function to truncate and map the start and end tokens of the <code>answer</code> to the <code>context</code>:",Ke,de,Oe,we,Xt='To apply the preprocessing function over the entire dataset, use 🤗 Datasets <a href="https://huggingface.co/docs/datasets/main/en/package_reference/main_classes#datasets.Dataset.map" rel="nofollow">map</a> function. You can speed up the <code>map</code> function by setting <code>batched=True</code> to process multiple elements of the dataset at once. Remove any columns you don’t need:',et,ye,tt,je,xt='Now create a batch of examples using <a href="/docs/transformers/pr_29693/en/main_classes/data_collator#transformers.DefaultDataCollator">DefaultDataCollator</a>. Unlike other data collators in 🤗 Transformers, the <a href="/docs/transformers/pr_29693/en/main_classes/data_collator#transformers.DefaultDataCollator">DefaultDataCollator</a> does not apply any additional preprocessing such as padding.',st,D,at,ge,lt,P,nt,K,rt,Te,pt,Je,Rt='Evaluation for question answering requires a significant amount of postprocessing. To avoid taking up too much of your time, this guide skips the evaluation step. The <a href="/docs/transformers/pr_29693/en/main_classes/trainer#transformers.Trainer">Trainer</a> still calculates the evaluation loss during training so you’re not completely in the dark about your model’s performance.',ot,be,vt='If have more time and you’re interested in how to evaluate your model for question answering, take a look at the <a href="https://huggingface.co/course/chapter7/7?fw=pt#post-processing" rel="nofollow">Question answering</a> chapter from the 🤗 Hugging Face Course!',it,$e,mt,Ue,Bt="Great, now that you’ve finetuned a model, you can use it for inference!",ct,_e,Gt="Come up with a question and some context you’d like the model to predict:",ut,Ce,Mt,Ie,At='The simplest way to try out your finetuned model for inference is to use it in a <a href="/docs/transformers/pr_29693/en/main_classes/pipelines#transformers.pipeline">pipeline()</a>. Instantiate a <code>pipeline</code> for question answering with your model, and pass your text to it:',ht,ke,ft,Ze,Wt="You can also manually replicate the results of the <code>pipeline</code> if you’d like:",dt,O,wt,Xe,yt,Ge,jt;return j=new xe({props:{title:"Question answering",local:"question-answering",headingTag:"h1"}}),W=new ts({props:{classNames:"absolute z-10 right-0 top-0",options:[{label:"Mixed",value:"https://colab.research.google.com/github/huggingface/notebooks/blob/main/transformers_doc/en/question_answering.ipynb"},{label:"PyTorch",value:"https://colab.research.google.com/github/huggingface/notebooks/blob/main/transformers_doc/en/pytorch/question_answering.ipynb"},{label:"TensorFlow",value:"https://colab.research.google.com/github/huggingface/notebooks/blob/main/transformers_doc/en/tensorflow/question_answering.ipynb"},{label:"Mixed",value:"https://studiolab.sagemaker.aws/import/github/huggingface/notebooks/blob/main/transformers_doc/en/question_answering.ipynb"},{label:"PyTorch",value:"https://studiolab.sagemaker.aws/import/github/huggingface/notebooks/blob/main/transformers_doc/en/pytorch/question_answering.ipynb"},{label:"TensorFlow",value:"https://studiolab.sagemaker.aws/import/github/huggingface/notebooks/blob/main/transformers_doc/en/tensorflow/question_answering.ipynb"}]}}),k=new qt({props:{id:"ajPx5LwJD-I"}}),z=new gt({props:{$$slots:{default:[as]},$$scope:{ctx:C}}}),H=new R({props:{code:"cGlwJTIwaW5zdGFsbCUyMHRyYW5zZm9ybWVycyUyMGRhdGFzZXRzJTIwZXZhbHVhdGU=",highlighted:"pip install transformers datasets evaluate",wrap:!1}}),p=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 xe({props:{title:"Load SQuAD dataset",local:"load-squad-dataset",headingTag:"h2"}}),se=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}}),le=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}}),re=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}}),ie=new xe({props:{title:"Preprocess",local:"preprocess",headingTag:"h2"}}),me=new qt({props:{id:"qgaM0weJHpA"}}),ue=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-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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}}),ye=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}}),D=new Tt({props:{pytorch:!0,tensorflow:!0,jax:!1,$$slots:{tensorflow:[ps],pytorch:[ns]},$$scope:{ctx:C}}}),ge=new xe({props:{title:"Train",local:"train",headingTag:"h2"}}),P=new Tt({props:{pytorch:!0,tensorflow:!0,jax:!1,$$slots:{tensorflow:[Ms],pytorch:[ms]},$$scope:{ctx:C}}}),K=new gt({props:{$$slots:{default:[hs]},$$scope:{ctx:C}}}),Te=new xe({props:{title:"Evaluate",local:"evaluate",headingTag:"h2"}}),$e=new xe({props:{title:"Inference",local:"inference",headingTag:"h2"}}),Ce=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}}),ke=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}}),O=new Tt({props:{pytorch:!0,tensorflow:!0,jax:!1,$$slots:{tensorflow:[ys],pytorch:[ds]},$$scope:{ctx:C}}}),Xe=new ss({props:{source:"https://github.com/huggingface/transformers/blob/main/docs/source/en/tasks/question_answering.md"}}),{c(){a=g("meta"),m=o(),s=g("p"),c=o(),M(j.$$.fragment),I=o(),M(W.$$.fragment),X=o(),M(k.$$.fragment),v=o(),$=g("p"),$.textContent=F,B=o(),b=g("ul"),b.innerHTML=G,Z=o(),V=g("p"),V.textContent=A,U=o(),x=g("ol"),x.innerHTML=t,u=o(),M(z.$$.fragment),q=o(),E=g("p"),E.textContent=ve,Y=o(),M(H.$$.fragment),S=o(),N=g("p"),N.textContent=Be,L=o(),M(p.$$.fragment),_=o(),M(Q.$$.fragment),Ae=o(),te=g("p"),te.textContent=Jt,We=o(),M(se.$$.fragment),Ve=o(),ae=g("p"),ae.innerHTML=bt,ze=o(),M(le.$$.fragment),Fe=o(),ne=g("p"),ne.textContent=$t,Ee=o(),M(re.$$.fragment),He=o(),pe=g("p"),pe.textContent=Ut,Ne=o(),oe=g("ul"),oe.innerHTML=_t,Qe=o(),M(ie.$$.fragment),qe=o(),M(me.$$.fragment),Ye=o(),ce=g("p"),ce.innerHTML=Ct,Se=o(),M(ue.$$.fragment),Le=o(),Me=g("p"),Me.textContent=It,De=o(),he=g("ol"),he.innerHTML=kt,Pe=o(),fe=g("p"),fe.innerHTML=Zt,Ke=o(),M(de.$$.fragment),Oe=o(),we=g("p"),we.innerHTML=Xt,et=o(),M(ye.$$.fragment),tt=o(),je=g("p"),je.innerHTML=xt,st=o(),M(D.$$.fragment),at=o(),M(ge.$$.fragment),lt=o(),M(P.$$.fragment),nt=o(),M(K.$$.fragment),rt=o(),M(Te.$$.fragment),pt=o(),Je=g("p"),Je.innerHTML=Rt,ot=o(),be=g("p"),be.innerHTML=vt,it=o(),M($e.$$.fragment),mt=o(),Ue=g("p"),Ue.textContent=Bt,ct=o(),_e=g("p"),_e.textContent=Gt,ut=o(),M(Ce.$$.fragment),Mt=o(),Ie=g("p"),Ie.innerHTML=At,ht=o(),M(ke.$$.fragment),ft=o(),Ze=g("p"),Ze.innerHTML=Wt,dt=o(),M(O.$$.fragment),wt=o(),M(Xe.$$.fragment),yt=o(),Ge=g("p"),this.h()},l(e){const r=Pt("svelte-u9bgzb",document.head);a=T(r,"META",{name:!0,content:!0}),r.forEach(l),m=i(e),s=T(e,"P",{}),Nt(s).forEach(l),c=i(e),h(j.$$.fragment,e),I=i(e),h(W.$$.fragment,e),X=i(e),h(k.$$.fragment,e),v=i(e),$=T(e,"P",{"data-svelte-h":!0}),J($)!=="svelte-wddg3q"&&($.textContent=F),B=i(e),b=T(e,"UL",{"data-svelte-h":!0}),J(b)!=="svelte-juxaac"&&(b.innerHTML=G),Z=i(e),V=T(e,"P",{"data-svelte-h":!0}),J(V)!=="svelte-1aff4p7"&&(V.textContent=A),U=i(e),x=T(e,"OL",{"data-svelte-h":!0}),J(x)!=="svelte-1par97w"&&(x.innerHTML=t),u=i(e),h(z.$$.fragment,e),q=i(e),E=T(e,"P",{"data-svelte-h":!0}),J(E)!=="svelte-1c9nexd"&&(E.textContent=ve),Y=i(e),h(H.$$.fragment,e),S=i(e),N=T(e,"P",{"data-svelte-h":!0}),J(N)!=="svelte-k76o1m"&&(N.textContent=Be),L=i(e),h(p.$$.fragment,e),_=i(e),h(Q.$$.fragment,e),Ae=i(e),te=T(e,"P",{"data-svelte-h":!0}),J(te)!=="svelte-86lsp1"&&(te.textContent=Jt),We=i(e),h(se.$$.fragment,e),Ve=i(e),ae=T(e,"P",{"data-svelte-h":!0}),J(ae)!=="svelte-rugbz4"&&(ae.innerHTML=bt),ze=i(e),h(le.$$.fragment,e),Fe=i(e),ne=T(e,"P",{"data-svelte-h":!0}),J(ne)!=="svelte-1m91ua0"&&(ne.textContent=$t),Ee=i(e),h(re.$$.fragment,e),He=i(e),pe=T(e,"P",{"data-svelte-h":!0}),J(pe)!=="svelte-ixla8d"&&(pe.textContent=Ut),Ne=i(e),oe=T(e,"UL",{"data-svelte-h":!0}),J(oe)!=="svelte-13sugm7"&&(oe.innerHTML=_t),Qe=i(e),h(ie.$$.fragment,e),qe=i(e),h(me.$$.fragment,e),Ye=i(e),ce=T(e,"P",{"data-svelte-h":!0}),J(ce)!=="svelte-1l87utj"&&(ce.innerHTML=Ct),Se=i(e),h(ue.$$.fragment,e),Le=i(e),Me=T(e,"P",{"data-svelte-h":!0}),J(Me)!=="svelte-6fi1jw"&&(Me.textContent=It),De=i(e),he=T(e,"OL",{"data-svelte-h":!0}),J(he)!=="svelte-twn3no"&&(he.innerHTML=kt),Pe=i(e),fe=T(e,"P",{"data-svelte-h":!0}),J(fe)!=="svelte-1l18kqg"&&(fe.innerHTML=Zt),Ke=i(e),h(de.$$.fragment,e),Oe=i(e),we=T(e,"P",{"data-svelte-h":!0}),J(we)!=="svelte-504s7j"&&(we.innerHTML=Xt),et=i(e),h(ye.$$.fragment,e),tt=i(e),je=T(e,"P",{"data-svelte-h":!0}),J(je)!=="svelte-4sp3aa"&&(je.innerHTML=xt),st=i(e),h(D.$$.fragment,e),at=i(e),h(ge.$$.fragment,e),lt=i(e),h(P.$$.fragment,e),nt=i(e),h(K.$$.fragment,e),rt=i(e),h(Te.$$.fragment,e),pt=i(e),Je=T(e,"P",{"data-svelte-h":!0}),J(Je)!=="svelte-u4kbmc"&&(Je.innerHTML=Rt),ot=i(e),be=T(e,"P",{"data-svelte-h":!0}),J(be)!=="svelte-rje05l"&&(be.innerHTML=vt),it=i(e),h($e.$$.fragment,e),mt=i(e),Ue=T(e,"P",{"data-svelte-h":!0}),J(Ue)!=="svelte-633ppb"&&(Ue.textContent=Bt),ct=i(e),_e=T(e,"P",{"data-svelte-h":!0}),J(_e)!=="svelte-1wy7p4p"&&(_e.textContent=Gt),ut=i(e),h(Ce.$$.fragment,e),Mt=i(e),Ie=T(e,"P",{"data-svelte-h":!0}),J(Ie)!=="svelte-1i8yfc9"&&(Ie.innerHTML=At),ht=i(e),h(ke.$$.fragment,e),ft=i(e),Ze=T(e,"P",{"data-svelte-h":!0}),J(Ze)!=="svelte-1njl8vm"&&(Ze.innerHTML=Wt),dt=i(e),h(O.$$.fragment,e),wt=i(e),h(Xe.$$.fragment,e),yt=i(e),Ge=T(e,"P",{}),Nt(Ge).forEach(l),this.h()},h(){Qt(a,"name","hf:doc:metadata"),Qt(a,"content",gs)},m(e,r){Kt(document.head,a),n(e,m,r),n(e,s,r),n(e,c,r),f(j,e,r),n(e,I,r),f(W,e,r),n(e,X,r),f(k,e,r),n(e,v,r),n(e,$,r),n(e,B,r),n(e,b,r),n(e,Z,r),n(e,V,r),n(e,U,r),n(e,x,r),n(e,u,r),f(z,e,r),n(e,q,r),n(e,E,r),n(e,Y,r),f(H,e,r),n(e,S,r),n(e,N,r),n(e,L,r),f(p,e,r),n(e,_,r),f(Q,e,r),n(e,Ae,r),n(e,te,r),n(e,We,r),f(se,e,r),n(e,Ve,r),n(e,ae,r),n(e,ze,r),f(le,e,r),n(e,Fe,r),n(e,ne,r),n(e,Ee,r),f(re,e,r),n(e,He,r),n(e,pe,r),n(e,Ne,r),n(e,oe,r),n(e,Qe,r),f(ie,e,r),n(e,qe,r),f(me,e,r),n(e,Ye,r),n(e,ce,r),n(e,Se,r),f(ue,e,r),n(e,Le,r),n(e,Me,r),n(e,De,r),n(e,he,r),n(e,Pe,r),n(e,fe,r),n(e,Ke,r),f(de,e,r),n(e,Oe,r),n(e,we,r),n(e,et,r),f(ye,e,r),n(e,tt,r),n(e,je,r),n(e,st,r),f(D,e,r),n(e,at,r),f(ge,e,r),n(e,lt,r),f(P,e,r),n(e,nt,r),f(K,e,r),n(e,rt,r),f(Te,e,r),n(e,pt,r),n(e,Je,r),n(e,ot,r),n(e,be,r),n(e,it,r),f($e,e,r),n(e,mt,r),n(e,Ue,r),n(e,ct,r),n(e,_e,r),n(e,ut,r),f(Ce,e,r),n(e,Mt,r),n(e,Ie,r),n(e,ht,r),f(ke,e,r),n(e,ft,r),n(e,Ze,r),n(e,dt,r),f(O,e,r),n(e,wt,r),f(Xe,e,r),n(e,yt,r),n(e,Ge,r),jt=!0},p(e,[r]){const Vt={};r&2&&(Vt.$$scope={dirty:r,ctx:e}),z.$set(Vt);const zt={};r&2&&(zt.$$scope={dirty:r,ctx:e}),D.$set(zt);const Ft={};r&2&&(Ft.$$scope={dirty:r,ctx:e}),P.$set(Ft);const Et={};r&2&&(Et.$$scope={dirty:r,ctx:e}),K.$set(Et);const Ht={};r&2&&(Ht.$$scope={dirty:r,ctx:e}),O.$set(Ht)},i(e){jt||(d(j.$$.fragment,e),d(W.$$.fragment,e),d(k.$$.fragment,e),d(z.$$.fragment,e),d(H.$$.fragment,e),d(p.$$.fragment,e),d(Q.$$.fragment,e),d(se.$$.fragment,e),d(le.$$.fragment,e),d(re.$$.fragment,e),d(ie.$$.fragment,e),d(me.$$.fragment,e),d(ue.$$.fragment,e),d(de.$$.fragment,e),d(ye.$$.fragment,e),d(D.$$.fragment,e),d(ge.$$.fragment,e),d(P.$$.fragment,e),d(K.$$.fragment,e),d(Te.$$.fragment,e),d($e.$$.fragment,e),d(Ce.$$.fragment,e),d(ke.$$.fragment,e),d(O.$$.fragment,e),d(Xe.$$.fragment,e),jt=!0)},o(e){w(j.$$.fragment,e),w(W.$$.fragment,e),w(k.$$.fragment,e),w(z.$$.fragment,e),w(H.$$.fragment,e),w(p.$$.fragment,e),w(Q.$$.fragment,e),w(se.$$.fragment,e),w(le.$$.fragment,e),w(re.$$.fragment,e),w(ie.$$.fragment,e),w(me.$$.fragment,e),w(ue.$$.fragment,e),w(de.$$.fragment,e),w(ye.$$.fragment,e),w(D.$$.fragment,e),w(ge.$$.fragment,e),w(P.$$.fragment,e),w(K.$$.fragment,e),w(Te.$$.fragment,e),w($e.$$.fragment,e),w(Ce.$$.fragment,e),w(ke.$$.fragment,e),w(O.$$.fragment,e),w(Xe.$$.fragment,e),jt=!1},d(e){e&&(l(m),l(s),l(c),l(I),l(X),l(v),l($),l(B),l(b),l(Z),l(V),l(U),l(x),l(u),l(q),l(E),l(Y),l(S),l(N),l(L),l(_),l(Ae),l(te),l(We),l(Ve),l(ae),l(ze),l(Fe),l(ne),l(Ee),l(He),l(pe),l(Ne),l(oe),l(Qe),l(qe),l(Ye),l(ce),l(Se),l(Le),l(Me),l(De),l(he),l(Pe),l(fe),l(Ke),l(Oe),l(we),l(et),l(tt),l(je),l(st),l(at),l(lt),l(nt),l(rt),l(pt),l(Je),l(ot),l(be),l(it),l(mt),l(Ue),l(ct),l(_e),l(ut),l(Mt),l(Ie),l(ht),l(ft),l(Ze),l(dt),l(wt),l(yt),l(Ge)),l(a),y(j,e),y(W,e),y(k,e),y(z,e),y(H,e),y(p,e),y(Q,e),y(se,e),y(le,e),y(re,e),y(ie,e),y(me,e),y(ue,e),y(de,e),y(ye,e),y(D,e),y(ge,e),y(P,e),y(K,e),y(Te,e),y($e,e),y(Ce,e),y(ke,e),y(O,e),y(Xe,e)}}}const gs='{"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 Ts(C){return St(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class Zs extends Lt{constructor(a){super(),Dt(this,a,Ts,js,Yt,{})}}export{Zs as component};
