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 Ht,u as h,x as J,k as Qt,y as Kt,a as n,v as f,d,t as w,w as j,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){j(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 y={};c&2&&(y.$$scope={dirty:c,ctx:s}),a.$set(y)},i(s){m||(d(a.$$.fragment,s),m=!0)},o(s){w(a.$$.fragment,s),m=!1},d(s){j(a,s)}}}function ps(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){j(a,s)}}}function rs(C){let a,m;return a=new Re({props:{$$slots:{default:[ps]},$$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 y={};c&2&&(y.$$scope={dirty:c,ctx:s}),a.$set(y)},i(s){m||(d(a.$$.fragment,s),m=!0)},o(s){w(a.$$.fragment,s),m=!1},d(s){j(a,s)}}}function os(C){let a,m='If you aren’t familiar with finetuning a model with the <a href="/docs/transformers/main/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-15s4um0"&&(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/main/en/model_doc/auto#transformers.AutoModelForQuestionAnswering">AutoModelForQuestionAnswering</a>:',y,I,W,x,k="At this point, only three steps remain:",v,$,E='<li>Define your training hyperparameters in <a href="/docs/transformers/main/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/main/en/main_classes/trainer#transformers.Trainer">Trainer</a> along with the model, dataset, tokenizer, and data collator.</li> <li>Call <a href="/docs/transformers/main/en/main_classes/trainer#transformers.Trainer.train">train()</a> to finetune your model.</li>',A,b,B,Z,V='Once training is completed, share your model to the Hub with the <a href="/docs/transformers/main/en/main_classes/trainer#transformers.Trainer.push_to_hub">push_to_hub()</a> method so everyone can use your model:',G,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:"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}}),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,y=o(),M(I.$$.fragment),W=o(),x=g("p"),x.textContent=k,v=o(),$=g("ol"),$.innerHTML=E,A=o(),M(b.$$.fragment),B=o(),Z=g("p"),Z.innerHTML=V,G=o(),M(U.$$.fragment)},l(t){h(a.$$.fragment,t),m=i(t),s=T(t,"P",{"data-svelte-h":!0}),J(s)!=="svelte-ymj5iq"&&(s.innerHTML=c),y=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-uz043g"&&($.innerHTML=E),A=i(t),h(b.$$.fragment,t),B=i(t),Z=T(t,"P",{"data-svelte-h":!0}),J(Z)!=="svelte-1v13hlo"&&(Z.innerHTML=V),G=i(t),h(U.$$.fragment,t)},m(t,u){f(a,t,u),n(t,m,u),n(t,s,u),n(t,y,u),f(I,t,u),n(t,W,u),n(t,x,u),n(t,v,u),n(t,$,u),n(t,A,u),f(b,t,u),n(t,B,u),n(t,Z,u),n(t,G,u),f(U,t,u),X=!0},p(t,u){const F={};u&2&&(F.$$scope={dirty:u,ctx:t}),a.$set(F)},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(y),l(W),l(x),l(v),l($),l(A),l(B),l(Z),l(G)),j(a,t),j(I,t),j(b,t),j(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 y={};c&2&&(y.$$scope={dirty:c,ctx:s}),a.$set(y)},i(s){m||(d(a.$$.fragment,s),m=!0)},o(s){w(a.$$.fragment,s),m=!1},d(s){j(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,y,I='Then you can load DistilBERT with <a href="/docs/transformers/main/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/main/en/main_classes/model#transformers.TFPreTrainedModel.prepare_tf_dataset">prepare_tf_dataset()</a>:',E,A,b,B,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,G,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/main/en/main_classes/keras_callbacks#transformers.PushToHubCallback">PushToHubCallback</a>:',u,F,q,z,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,N,S,H,Ae="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}}),A=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}}),G=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}}),F=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}}),N=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(),y=g("p"),y.innerHTML=I,W=o(),M(x.$$.fragment),k=o(),v=g("p"),v.innerHTML=$,E=o(),M(A.$$.fragment),b=o(),B=g("p"),B.innerHTML=Z,V=o(),M(G.$$.fragment),U=o(),X=g("p"),X.innerHTML=t,u=o(),M(F.$$.fragment),q=o(),z=g("p"),z.innerHTML=ve,Y=o(),M(N.$$.fragment),S=o(),H=g("p"),H.textContent=Ae},l(r){h(a.$$.fragment,r),m=es(r,`
To finetune a model in TensorFlow, start by setting up an optimizer function, learning rate schedule, and some training hyperparameters:

	`),h(s.$$.fragment,r),c=i(r),y=T(r,"P",{"data-svelte-h":!0}),J(y)!=="svelte-14d13tk"&&(y.innerHTML=I),W=i(r),h(x.$$.fragment,r),k=i(r),v=T(r,"P",{"data-svelte-h":!0}),J(v)!=="svelte-9ymftz"&&(v.innerHTML=$),E=i(r),h(A.$$.fragment,r),b=i(r),B=T(r,"P",{"data-svelte-h":!0}),J(B)!=="svelte-rt1r5v"&&(B.innerHTML=Z),V=i(r),h(G.$$.fragment,r),U=i(r),X=T(r,"P",{"data-svelte-h":!0}),J(X)!=="svelte-1iofjok"&&(X.innerHTML=t),u=i(r),h(F.$$.fragment,r),q=i(r),z=T(r,"P",{"data-svelte-h":!0}),J(z)!=="svelte-1pfsro2"&&(z.innerHTML=ve),Y=i(r),h(N.$$.fragment,r),S=i(r),H=T(r,"P",{"data-svelte-h":!0}),J(H)!=="svelte-2s71om"&&(H.textContent=Ae)},m(r,_){f(a,r,_),n(r,m,_),f(s,r,_),n(r,c,_),n(r,y,_),n(r,W,_),f(x,r,_),n(r,k,_),n(r,v,_),n(r,E,_),f(A,r,_),n(r,b,_),n(r,B,_),n(r,V,_),f(G,r,_),n(r,U,_),n(r,X,_),n(r,u,_),f(F,r,_),n(r,q,_),n(r,z,_),n(r,Y,_),f(N,r,_),n(r,S,_),n(r,H,_),L=!0},p(r,_){const Q={};_&2&&(Q.$$scope={dirty:_,ctx:r}),a.$set(Q)},i(r){L||(d(a.$$.fragment,r),d(s.$$.fragment,r),d(x.$$.fragment,r),d(A.$$.fragment,r),d(G.$$.fragment,r),d(F.$$.fragment,r),d(N.$$.fragment,r),L=!0)},o(r){w(a.$$.fragment,r),w(s.$$.fragment,r),w(x.$$.fragment,r),w(A.$$.fragment,r),w(G.$$.fragment,r),w(F.$$.fragment,r),w(N.$$.fragment,r),L=!1},d(r){r&&(l(m),l(c),l(y),l(W),l(k),l(v),l(E),l(b),l(B),l(V),l(U),l(X),l(u),l(q),l(z),l(Y),l(S),l(H)),j(a,r),j(s,r),j(x,r),j(A,r),j(G,r),j(F,r),j(N,r)}}}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 y={};c&2&&(y.$$scope={dirty:c,ctx:s}),a.$set(y)},i(s){m||(d(a.$$.fragment,s),m=!0)},o(s){w(a.$$.fragment,s),m=!1},d(s){j(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,y,I,W="Pass your inputs to the model and return the <code>logits</code>:",x,k,v,$,E="Get the highest probability from the model output for the start and end positions:",A,b,B,Z,V="Decode the predicted tokens to get the answer:",G,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),y=o(),I=g("p"),I.innerHTML=W,x=o(),M(k.$$.fragment),v=o(),$=g("p"),$.textContent=E,A=o(),M(b.$$.fragment),B=o(),Z=g("p"),Z.textContent=V,G=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),y=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=E),A=i(t),h(b.$$.fragment,t),B=i(t),Z=T(t,"P",{"data-svelte-h":!0}),J(Z)!=="svelte-66bsyj"&&(Z.textContent=V),G=i(t),h(U.$$.fragment,t)},m(t,u){n(t,a,u),n(t,s,u),f(c,t,u),n(t,y,u),n(t,I,u),n(t,x,u),f(k,t,u),n(t,v,u),n(t,$,u),n(t,A,u),f(b,t,u),n(t,B,u),n(t,Z,u),n(t,G,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(y),l(I),l(x),l(v),l($),l(A),l(B),l(Z),l(G)),j(c,t),j(k,t),j(b,t),j(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 y={};c&2&&(y.$$scope={dirty:c,ctx:s}),a.$set(y)},i(s){m||(d(a.$$.fragment,s),m=!0)},o(s){w(a.$$.fragment,s),m=!1},d(s){j(a,s)}}}function ws(C){let a,m="Tokenize the text and return TensorFlow tensors:",s,c,y,I,W="Pass your inputs to the model and return the <code>logits</code>:",x,k,v,$,E="Get the highest probability from the model output for the start and end positions:",A,b,B,Z,V="Decode the predicted tokens to get the answer:",G,U,X;return c=new R({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMEF1dG9Ub2tlbml6ZXIlMEElMEF0b2tlbml6ZXIlMjAlM0QlMjBBdXRvVG9rZW5pemVyLmZyb21fcHJldHJhaW5lZCglMjJteV9hd2Vzb21lX3FhX21vZGVsJTIyKSUwQWlucHV0cyUyMCUzRCUyMHRva2VuaXplcihxdWVzdGlvbiUyQyUyMGNvbnRleHQlMkMlMjByZXR1cm5fdGVuc29ycyUzRCUyMnRmJTIyKQ==",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;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),y=o(),I=g("p"),I.innerHTML=W,x=o(),M(k.$$.fragment),v=o(),$=g("p"),$.textContent=E,A=o(),M(b.$$.fragment),B=o(),Z=g("p"),Z.textContent=V,G=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),y=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=E),A=i(t),h(b.$$.fragment,t),B=i(t),Z=T(t,"P",{"data-svelte-h":!0}),J(Z)!=="svelte-66bsyj"&&(Z.textContent=V),G=i(t),h(U.$$.fragment,t)},m(t,u){n(t,a,u),n(t,s,u),f(c,t,u),n(t,y,u),n(t,I,u),n(t,x,u),f(k,t,u),n(t,v,u),n(t,$,u),n(t,A,u),f(b,t,u),n(t,B,u),n(t,Z,u),n(t,G,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(y),l(I),l(x),l(v),l($),l(A),l(B),l(Z),l(G)),j(c,t),j(k,t),j(b,t),j(U,t)}}}function js(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 y={};c&2&&(y.$$scope={dirty:c,ctx:s}),a.$set(y)},i(s){m||(d(a.$$.fragment,s),m=!0)},o(s){w(a.$$.fragment,s),m=!1},d(s){j(a,s)}}}function ys(C){let a,m,s,c,y,I,W,x,k,v,$,E="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:",A,b,B="<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,G="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,F,q,z,ve="Before you begin, make sure you have all the necessary libraries installed:",Y,N,S,H,Ae="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,r,_,Q,Ge,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:',Fe,le,Ee,ne,$t="Then take a look at an example:",ze,pe,Ne,re,Ut="There are several important fields here:",He,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,je,tt,ye,Xt='Now create a batch of examples using <a href="/docs/transformers/main/en/main_classes/data_collator#transformers.DefaultDataCollator">DefaultDataCollator</a>. Unlike other data collators in 🤗 Transformers, the <a href="/docs/transformers/main/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,pt,Te,rt,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/main/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 you 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,At="Great, now that you’ve finetuned a model, you can use it for inference!",ct,_e,Bt="Come up with a question and some context you’d like the model to predict:",ut,Ce,Mt,Ie,Gt='The simplest way to try out your finetuned model for inference is to use it in a <a href="/docs/transformers/main/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,jt,Be,yt;return y=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"}}),F=new gt({props:{$$slots:{default:[as]},$$scope:{ctx:C}}}),N=new R({props:{code:"cGlwJTIwaW5zdGFsbCUyMHRyYW5zZm9ybWVycyUyMGRhdGFzZXRzJTIwZXZhbHVhdGU=",highlighted:"pip install transformers datasets evaluate",wrap:!1}}),r=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}}),pe=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-meta">&gt;&gt;&gt; </span>tokenizer = AutoTokenizer.from_pretrained(<span class="hljs-string">&quot;distilbert/distilbert-base-uncased&quot;</span>)`,wrap:!1}}),de=new R({props:{code:"ZGVmJTIwcHJlcHJvY2Vzc19mdW5jdGlvbihleGFtcGxlcyklM0ElMEElMjAlMjAlMjAlMjBxdWVzdGlvbnMlMjAlM0QlMjAlNUJxLnN0cmlwKCklMjBmb3IlMjBxJTIwaW4lMjBleGFtcGxlcyU1QiUyMnF1ZXN0aW9uJTIyJTVEJTVEJTBBJTIwJTIwJTIwJTIwaW5wdXRzJTIwJTNEJTIwdG9rZW5pemVyKCUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMHF1ZXN0aW9ucyUyQyUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMGV4YW1wbGVzJTVCJTIyY29udGV4dCUyMiU1RCUyQyUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMG1heF9sZW5ndGglM0QzODQlMkMlMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjB0cnVuY2F0aW9uJTNEJTIyb25seV9zZWNvbmQlMjIlMkMlMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjByZXR1cm5fb2Zmc2V0c19tYXBwaW5nJTNEVHJ1ZSUyQyUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMHBhZGRpbmclM0QlMjJtYXhfbGVuZ3RoJTIyJTJDJTBBJTIwJTIwJTIwJTIwKSUwQSUwQSUyMCUyMCUyMCUyMG9mZnNldF9tYXBwaW5nJTIwJTNEJTIwaW5wdXRzLnBvcCglMjJvZmZzZXRfbWFwcGluZyUyMiklMEElMjAlMjAlMjAlMjBhbnN3ZXJzJTIwJTNEJTIwZXhhbXBsZXMlNUIlMjJhbnN3ZXJzJTIyJTVEJTBBJTIwJTIwJTIwJTIwc3RhcnRfcG9zaXRpb25zJTIwJTNEJTIwJTVCJTVEJTBBJTIwJTIwJTIwJTIwZW5kX3Bvc2l0aW9ucyUyMCUzRCUyMCU1QiU1RCUwQSUwQSUyMCUyMCUyMCUyMGZvciUyMGklMkMlMjBvZmZzZXQlMjBpbiUyMGVudW1lcmF0ZShvZmZzZXRfbWFwcGluZyklM0ElMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjBhbnN3ZXIlMjAlM0QlMjBhbnN3ZXJzJTVCaSU1RCUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMHN0YXJ0X2NoYXIlMjAlM0QlMjBhbnN3ZXIlNUIlMjJhbnN3ZXJfc3RhcnQlMjIlNUQlNUIwJTVEJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwZW5kX2NoYXIlMjAlM0QlMjBhbnN3ZXIlNUIlMjJhbnN3ZXJfc3RhcnQlMjIlNUQlNUIwJTVEJTIwJTJCJTIwbGVuKGFuc3dlciU1QiUyMnRleHQlMjIlNUQlNUIwJTVEKSUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMHNlcXVlbmNlX2lkcyUyMCUzRCUyMGlucHV0cy5zZXF1ZW5jZV9pZHMoaSklMEElMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjMlMjBGaW5kJTIwdGhlJTIwc3RhcnQlMjBhbmQlMjBlbmQlMjBvZiUyMHRoZSUyMGNvbnRleHQlMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjBpZHglMjAlM0QlMjAwJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwd2hpbGUlMjBzZXF1ZW5jZV9pZHMlNUJpZHglNUQlMjAhJTNEJTIwMSUzQSUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMGlkeCUyMCUyQiUzRCUyMDElMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjBjb250ZXh0X3N0YXJ0JTIwJTNEJTIwaWR4JTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwd2hpbGUlMjBzZXF1ZW5jZV9pZHMlNUJpZHglNUQlMjAlM0QlM0QlMjAxJTNBJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwaWR4JTIwJTJCJTNEJTIwMSUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMGNvbnRleHRfZW5kJTIwJTNEJTIwaWR4JTIwLSUyMDElMEElMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjMlMjBJZiUyMHRoZSUyMGFuc3dlciUyMGlzJTIwbm90JTIwZnVsbHklMjBpbnNpZGUlMjB0aGUlMjBjb250ZXh0JTJDJTIwbGFiZWwlMjBpdCUyMCgwJTJDJTIwMCklMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjBpZiUyMG9mZnNldCU1QmNvbnRleHRfc3RhcnQlNUQlNUIwJTVEJTIwJTNFJTIwZW5kX2NoYXIlMjBvciUyMG9mZnNldCU1QmNvbnRleHRfZW5kJTVEJTVCMSU1RCUyMCUzQyUyMHN0YXJ0X2NoYXIlM0ElMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjBzdGFydF9wb3NpdGlvbnMuYXBwZW5kKDApJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwZW5kX3Bvc2l0aW9ucy5hcHBlbmQoMCklMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjBlbHNlJTNBJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIzJTIwT3RoZXJ3aXNlJTIwaXQncyUyMHRoZSUyMHN0YXJ0JTIwYW5kJTIwZW5kJTIwdG9rZW4lMjBwb3NpdGlvbnMlMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjBpZHglMjAlM0QlMjBjb250ZXh0X3N0YXJ0JTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwd2hpbGUlMjBpZHglMjAlM0MlM0QlMjBjb250ZXh0X2VuZCUyMGFuZCUyMG9mZnNldCU1QmlkeCU1RCU1QjAlNUQlMjAlM0MlM0QlMjBzdGFydF9jaGFyJTNBJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwaWR4JTIwJTJCJTNEJTIwMSUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMHN0YXJ0X3Bvc2l0aW9ucy5hcHBlbmQoaWR4JTIwLSUyMDEpJTBBJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwaWR4JTIwJTNEJTIwY29udGV4dF9lbmQlMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjB3aGlsZSUyMGlkeCUyMCUzRSUzRCUyMGNvbnRleHRfc3RhcnQlMjBhbmQlMjBvZmZzZXQlNUJpZHglNUQlNUIxJTVEJTIwJTNFJTNEJTIwZW5kX2NoYXIlM0ElMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjBpZHglMjAtJTNEJTIwMSUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMGVuZF9wb3NpdGlvbnMuYXBwZW5kKGlkeCUyMCUyQiUyMDEpJTBBJTBBJTIwJTIwJTIwJTIwaW5wdXRzJTVCJTIyc3RhcnRfcG9zaXRpb25zJTIyJTVEJTIwJTNEJTIwc3RhcnRfcG9zaXRpb25zJTBBJTIwJTIwJTIwJTIwaW5wdXRzJTVCJTIyZW5kX3Bvc2l0aW9ucyUyMiU1RCUyMCUzRCUyMGVuZF9wb3NpdGlvbnMlMEElMjAlMjAlMjAlMjByZXR1cm4lMjBpbnB1dHM=",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">def</span> <span class="hljs-title function_">preprocess_function</span>(<span class="hljs-params">examples</span>):
<span class="hljs-meta">... </span>    questions = [q.strip() <span class="hljs-keyword">for</span> q <span class="hljs-keyword">in</span> examples[<span class="hljs-string">&quot;question&quot;</span>]]
<span class="hljs-meta">... </span>    inputs = tokenizer(
<span class="hljs-meta">... </span>        questions,
<span class="hljs-meta">... </span>        examples[<span class="hljs-string">&quot;context&quot;</span>],
<span class="hljs-meta">... </span>        max_length=<span class="hljs-number">384</span>,
<span class="hljs-meta">... </span>        truncation=<span class="hljs-string">&quot;only_second&quot;</span>,
<span class="hljs-meta">... </span>        return_offsets_mapping=<span class="hljs-literal">True</span>,
<span class="hljs-meta">... </span>        padding=<span class="hljs-string">&quot;max_length&quot;</span>,
<span class="hljs-meta">... </span>    )

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

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

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

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

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

<span class="hljs-meta">... </span>    inputs[<span class="hljs-string">&quot;start_positions&quot;</span>] = start_positions
<span class="hljs-meta">... </span>    inputs[<span class="hljs-string">&quot;end_positions&quot;</span>] = end_positions
<span class="hljs-meta">... </span>    <span class="hljs-keyword">return</span> inputs`,wrap:!1}}),je=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:[rs],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:[js],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(y.$$.fragment),I=o(),M(W.$$.fragment),x=o(),M(k.$$.fragment),v=o(),$=g("p"),$.textContent=E,A=o(),b=g("ul"),b.innerHTML=B,Z=o(),V=g("p"),V.textContent=G,U=o(),X=g("ol"),X.innerHTML=t,u=o(),M(F.$$.fragment),q=o(),z=g("p"),z.textContent=ve,Y=o(),M(N.$$.fragment),S=o(),H=g("p"),H.textContent=Ae,L=o(),M(r.$$.fragment),_=o(),M(Q.$$.fragment),Ge=o(),te=g("p"),te.textContent=Jt,We=o(),M(se.$$.fragment),Ve=o(),ae=g("p"),ae.innerHTML=bt,Fe=o(),M(le.$$.fragment),Ee=o(),ne=g("p"),ne.textContent=$t,ze=o(),M(pe.$$.fragment),Ne=o(),re=g("p"),re.textContent=Ut,He=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(je.$$.fragment),tt=o(),ye=g("p"),ye.innerHTML=Xt,st=o(),M(D.$$.fragment),at=o(),M(ge.$$.fragment),lt=o(),M(P.$$.fragment),nt=o(),M(K.$$.fragment),pt=o(),M(Te.$$.fragment),rt=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=At,ct=o(),_e=g("p"),_e.textContent=Bt,ut=o(),M(Ce.$$.fragment),Mt=o(),Ie=g("p"),Ie.innerHTML=Gt,ht=o(),M(ke.$$.fragment),ft=o(),Ze=g("p"),Ze.innerHTML=Wt,dt=o(),M(O.$$.fragment),wt=o(),M(xe.$$.fragment),jt=o(),Be=g("p"),this.h()},l(e){const p=Pt("svelte-u9bgzb",document.head);a=T(p,"META",{name:!0,content:!0}),p.forEach(l),m=i(e),s=T(e,"P",{}),Ht(s).forEach(l),c=i(e),h(y.$$.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=E),A=i(e),b=T(e,"UL",{"data-svelte-h":!0}),J(b)!=="svelte-juxaac"&&(b.innerHTML=B),Z=i(e),V=T(e,"P",{"data-svelte-h":!0}),J(V)!=="svelte-1aff4p7"&&(V.textContent=G),U=i(e),X=T(e,"OL",{"data-svelte-h":!0}),J(X)!=="svelte-1par97w"&&(X.innerHTML=t),u=i(e),h(F.$$.fragment,e),q=i(e),z=T(e,"P",{"data-svelte-h":!0}),J(z)!=="svelte-1c9nexd"&&(z.textContent=ve),Y=i(e),h(N.$$.fragment,e),S=i(e),H=T(e,"P",{"data-svelte-h":!0}),J(H)!=="svelte-k76o1m"&&(H.textContent=Ae),L=i(e),h(r.$$.fragment,e),_=i(e),h(Q.$$.fragment,e),Ge=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),Fe=i(e),h(le.$$.fragment,e),Ee=i(e),ne=T(e,"P",{"data-svelte-h":!0}),J(ne)!=="svelte-1m91ua0"&&(ne.textContent=$t),ze=i(e),h(pe.$$.fragment,e),Ne=i(e),re=T(e,"P",{"data-svelte-h":!0}),J(re)!=="svelte-ixla8d"&&(re.textContent=Ut),He=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(je.$$.fragment,e),tt=i(e),ye=T(e,"P",{"data-svelte-h":!0}),J(ye)!=="svelte-1cisvfs"&&(ye.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),pt=i(e),h(Te.$$.fragment,e),rt=i(e),Je=T(e,"P",{"data-svelte-h":!0}),J(Je)!=="svelte-1nnb2lp"&&(Je.innerHTML=Rt),ot=i(e),be=T(e,"P",{"data-svelte-h":!0}),J(be)!=="svelte-14u5qx8"&&(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=At),ct=i(e),_e=T(e,"P",{"data-svelte-h":!0}),J(_e)!=="svelte-1wy7p4p"&&(_e.textContent=Bt),ut=i(e),h(Ce.$$.fragment,e),Mt=i(e),Ie=T(e,"P",{"data-svelte-h":!0}),J(Ie)!=="svelte-1pyk5cg"&&(Ie.innerHTML=Gt),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),jt=i(e),Be=T(e,"P",{}),Ht(Be).forEach(l),this.h()},h(){Qt(a,"name","hf:doc:metadata"),Qt(a,"content",gs)},m(e,p){Kt(document.head,a),n(e,m,p),n(e,s,p),n(e,c,p),f(y,e,p),n(e,I,p),f(W,e,p),n(e,x,p),f(k,e,p),n(e,v,p),n(e,$,p),n(e,A,p),n(e,b,p),n(e,Z,p),n(e,V,p),n(e,U,p),n(e,X,p),n(e,u,p),f(F,e,p),n(e,q,p),n(e,z,p),n(e,Y,p),f(N,e,p),n(e,S,p),n(e,H,p),n(e,L,p),f(r,e,p),n(e,_,p),f(Q,e,p),n(e,Ge,p),n(e,te,p),n(e,We,p),f(se,e,p),n(e,Ve,p),n(e,ae,p),n(e,Fe,p),f(le,e,p),n(e,Ee,p),n(e,ne,p),n(e,ze,p),f(pe,e,p),n(e,Ne,p),n(e,re,p),n(e,He,p),n(e,oe,p),n(e,Qe,p),f(ie,e,p),n(e,qe,p),f(me,e,p),n(e,Ye,p),n(e,ce,p),n(e,Se,p),f(ue,e,p),n(e,Le,p),n(e,Me,p),n(e,De,p),n(e,he,p),n(e,Pe,p),n(e,fe,p),n(e,Ke,p),f(de,e,p),n(e,Oe,p),n(e,we,p),n(e,et,p),f(je,e,p),n(e,tt,p),n(e,ye,p),n(e,st,p),f(D,e,p),n(e,at,p),f(ge,e,p),n(e,lt,p),f(P,e,p),n(e,nt,p),f(K,e,p),n(e,pt,p),f(Te,e,p),n(e,rt,p),n(e,Je,p),n(e,ot,p),n(e,be,p),n(e,it,p),f($e,e,p),n(e,mt,p),n(e,Ue,p),n(e,ct,p),n(e,_e,p),n(e,ut,p),f(Ce,e,p),n(e,Mt,p),n(e,Ie,p),n(e,ht,p),f(ke,e,p),n(e,ft,p),n(e,Ze,p),n(e,dt,p),f(O,e,p),n(e,wt,p),f(xe,e,p),n(e,jt,p),n(e,Be,p),yt=!0},p(e,[p]){const Vt={};p&2&&(Vt.$$scope={dirty:p,ctx:e}),F.$set(Vt);const Ft={};p&2&&(Ft.$$scope={dirty:p,ctx:e}),D.$set(Ft);const Et={};p&2&&(Et.$$scope={dirty:p,ctx:e}),P.$set(Et);const zt={};p&2&&(zt.$$scope={dirty:p,ctx:e}),K.$set(zt);const Nt={};p&2&&(Nt.$$scope={dirty:p,ctx:e}),O.$set(Nt)},i(e){yt||(d(y.$$.fragment,e),d(W.$$.fragment,e),d(k.$$.fragment,e),d(F.$$.fragment,e),d(N.$$.fragment,e),d(r.$$.fragment,e),d(Q.$$.fragment,e),d(se.$$.fragment,e),d(le.$$.fragment,e),d(pe.$$.fragment,e),d(ie.$$.fragment,e),d(me.$$.fragment,e),d(ue.$$.fragment,e),d(de.$$.fragment,e),d(je.$$.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),yt=!0)},o(e){w(y.$$.fragment,e),w(W.$$.fragment,e),w(k.$$.fragment,e),w(F.$$.fragment,e),w(N.$$.fragment,e),w(r.$$.fragment,e),w(Q.$$.fragment,e),w(se.$$.fragment,e),w(le.$$.fragment,e),w(pe.$$.fragment,e),w(ie.$$.fragment,e),w(me.$$.fragment,e),w(ue.$$.fragment,e),w(de.$$.fragment,e),w(je.$$.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),yt=!1},d(e){e&&(l(m),l(s),l(c),l(I),l(x),l(v),l($),l(A),l(b),l(Z),l(V),l(U),l(X),l(u),l(q),l(z),l(Y),l(S),l(H),l(L),l(_),l(Ge),l(te),l(We),l(Ve),l(ae),l(Fe),l(Ee),l(ne),l(ze),l(Ne),l(re),l(He),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(ye),l(st),l(at),l(lt),l(nt),l(pt),l(rt),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(jt),l(Be)),l(a),j(y,e),j(W,e),j(k,e),j(F,e),j(N,e),j(r,e),j(Q,e),j(se,e),j(le,e),j(pe,e),j(ie,e),j(me,e),j(ue,e),j(de,e),j(je,e),j(D,e),j(ge,e),j(P,e),j(K,e),j(Te,e),j($e,e),j(Ce,e),j(ke,e),j(O,e),j(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,ys,Yt,{})}}export{Zs as component};
