import{s as Rs,o as Ws,n as Ts}from"../chunks/scheduler.36a0863c.js";import{S as Bs,i as zs,g as T,s as o,r as y,A as Es,h as f,f as t,c as i,j as ks,u as d,x as g,k as As,y as Qs,a as n,v as h,d as u,t as U,w as J}from"../chunks/index.f891bdb2.js";import{T as Xs}from"../chunks/Tip.a8272f7f.js";import{C as R}from"../chunks/CodeBlock.3ec784ea.js";import{F as Vs,M as fs}from"../chunks/Markdown.7b58822e.js";import{H as ws,E as Ys}from"../chunks/EditOnGithub.a58e27a9.js";function xs(C){let a,c;return a=new R({props:{code:"ZnJvbSUyMGRhdGFjbGFzc2VzJTIwaW1wb3J0JTIwZGF0YWNsYXNzJTBBZnJvbSUyMHRyYW5zZm9ybWVycy50b2tlbml6YXRpb25fdXRpbHNfYmFzZSUyMGltcG9ydCUyMFByZVRyYWluZWRUb2tlbml6ZXJCYXNlJTJDJTIwUGFkZGluZ1N0cmF0ZWd5JTBBZnJvbSUyMHR5cGluZyUyMGltcG9ydCUyME9wdGlvbmFsJTJDJTIwVW5pb24lMEFpbXBvcnQlMjB0b3JjaCUwQSUwQSUwQSU0MGRhdGFjbGFzcyUwQWNsYXNzJTIwRGF0YUNvbGxhdG9yRm9yTXVsdGlwbGVDaG9pY2UlM0ElMEElMjAlMjAlMjAlMjAlMjIlMjIlMjIlMEElMjAlMjAlMjAlMjBDb2xsYXRvciUyMGRlJTIwZGF0b3MlMjBxdWUlMjBsZSUyMGElQzMlQjFhZGlyJUMzJUExJTIwcmVsbGVubyUyMGRlJTIwZm9ybWElMjBhdXRvbSVDMyVBMXRpY2ElMjBhJTIwbGFzJTIwZW50cmFkYXMlMjByZWNpYmlkYXMlMjBwYXJhJTBBJTIwJTIwJTIwJTIwdW5hJTIwdGFyZWElMjBkZSUyMHNlbGVjY2klQzMlQjNuJTIwbSVDMyVCQWx0aXBsZS4lMEElMjAlMjAlMjAlMjAlMjIlMjIlMjIlMEElMEElMjAlMjAlMjAlMjB0b2tlbml6ZXIlM0ElMjBQcm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IwdiUyMGluJTIwYmF0Y2guaXRlbXMoKSU3RCUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMGJhdGNoJTVCJTIybGFiZWxzJTIyJTVEJTIwJTNEJTIwdG9yY2gudGVuc29yKGxhYmVscyUyQyUyMGR0eXBlJTNEdG9yY2guaW50NjQpJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwcmV0dXJuJTIwYmF0Y2g=",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> dataclasses <span class="hljs-keyword">import</span> dataclass
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers.tokenization_utils_base <span class="hljs-keyword">import</span> PreTrainedTokenizerBase, PaddingStrategy
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> typing <span class="hljs-keyword">import</span> <span class="hljs-type">Optional</span>, <span class="hljs-type">Union</span>
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">import</span> torch


<span class="hljs-meta">&gt;&gt;&gt; </span>@dataclass
<span class="hljs-meta">... </span><span class="hljs-keyword">class</span> <span class="hljs-title class_">DataCollatorForMultipleChoice</span>:
<span class="hljs-meta">... </span>    <span class="hljs-string">&quot;&quot;&quot;
<span class="hljs-meta">... </span>    Collator de datos que le añadirá relleno de forma automática a las entradas recibidas para
<span class="hljs-meta">... </span>    una tarea de selección múltiple.
<span class="hljs-meta">... </span>    &quot;&quot;&quot;</span>

<span class="hljs-meta">... </span>    tokenizer: PreTrainedTokenizerBase
<span class="hljs-meta">... </span>    padding: <span class="hljs-type">Union</span>[<span class="hljs-built_in">bool</span>, <span class="hljs-built_in">str</span>, PaddingStrategy] = <span class="hljs-literal">True</span>
<span class="hljs-meta">... </span>    max_length: <span class="hljs-type">Optional</span>[<span class="hljs-built_in">int</span>] = <span class="hljs-literal">None</span>
<span class="hljs-meta">... </span>    pad_to_multiple_of: <span class="hljs-type">Optional</span>[<span class="hljs-built_in">int</span>] = <span class="hljs-literal">None</span>

<span class="hljs-meta">... </span>    <span class="hljs-keyword">def</span> <span class="hljs-title function_">__call__</span>(<span class="hljs-params">self, features</span>):
<span class="hljs-meta">... </span>        label_name = <span class="hljs-string">&quot;label&quot;</span> <span class="hljs-keyword">if</span> <span class="hljs-string">&quot;label&quot;</span> <span class="hljs-keyword">in</span> features[<span class="hljs-number">0</span>].keys() <span class="hljs-keyword">else</span> <span class="hljs-string">&quot;labels&quot;</span>
<span class="hljs-meta">... </span>        labels = [feature.pop(label_name) <span class="hljs-keyword">for</span> feature <span class="hljs-keyword">in</span> features]
<span class="hljs-meta">... </span>        batch_size = <span class="hljs-built_in">len</span>(features)
<span class="hljs-meta">... </span>        num_choices = <span class="hljs-built_in">len</span>(features[<span class="hljs-number">0</span>][<span class="hljs-string">&quot;input_ids&quot;</span>])
<span class="hljs-meta">... </span>        flattened_features = [
<span class="hljs-meta">... </span>            [{k: v[i] <span class="hljs-keyword">for</span> k, v <span class="hljs-keyword">in</span> feature.items()} <span class="hljs-keyword">for</span> i <span class="hljs-keyword">in</span> <span class="hljs-built_in">range</span>(num_choices)] <span class="hljs-keyword">for</span> feature <span class="hljs-keyword">in</span> features
<span class="hljs-meta">... </span>        ]
<span class="hljs-meta">... </span>        flattened_features = <span class="hljs-built_in">sum</span>(flattened_features, [])

<span class="hljs-meta">... </span>        batch = self.tokenizer.pad(
<span class="hljs-meta">... </span>            flattened_features,
<span class="hljs-meta">... </span>            padding=self.padding,
<span class="hljs-meta">... </span>            max_length=self.max_length,
<span class="hljs-meta">... </span>            pad_to_multiple_of=self.pad_to_multiple_of,
<span class="hljs-meta">... </span>            return_tensors=<span class="hljs-string">&quot;pt&quot;</span>,
<span class="hljs-meta">... </span>        )

<span class="hljs-meta">... </span>        batch = {k: v.view(batch_size, num_choices, -<span class="hljs-number">1</span>) <span class="hljs-keyword">for</span> k, v <span class="hljs-keyword">in</span> batch.items()}
<span class="hljs-meta">... </span>        batch[<span class="hljs-string">&quot;labels&quot;</span>] = torch.tensor(labels, dtype=torch.int64)
<span class="hljs-meta">... </span>        <span class="hljs-keyword">return</span> batch`,wrap:!1}}),{c(){y(a.$$.fragment)},l(l){d(a.$$.fragment,l)},m(l,r){h(a,l,r),c=!0},p:Ts,i(l){c||(u(a.$$.fragment,l),c=!0)},o(l){U(a.$$.fragment,l),c=!1},d(l){J(a,l)}}}function Fs(C){let a,c;return a=new fs({props:{$$slots:{default:[xs]},$$scope:{ctx:C}}}),{c(){y(a.$$.fragment)},l(l){d(a.$$.fragment,l)},m(l,r){h(a,l,r),c=!0},p(l,r){const m={};r&2&&(m.$$scope={dirty:r,ctx:l}),a.$set(m)},i(l){c||(u(a.$$.fragment,l),c=!0)},o(l){U(a.$$.fragment,l),c=!1},d(l){J(a,l)}}}function Ns(C){let a,c;return a=new R({props:{code:"ZnJvbSUyMGRhdGFjbGFzc2VzJTIwaW1wb3J0JTIwZGF0YWNsYXNzJTBBZnJvbSUyMHRyYW5zZm9ybWVycy50b2tlbml6YXRpb25fdXRpbHNfYmFzZSUyMGltcG9ydCUyMFByZVRyYWluZWRUb2tlbml6ZXJCYXNlJTJDJTIwUGFkZGluZ1N0cmF0ZWd5JTBBZnJvbSUyMHR5cGluZyUyMGltcG9ydCUyME9wdGlvbmFsJTJDJTIwVW5pb24lMEFpbXBvcnQlMjB0ZW5zb3JmbG93JTIwYXMlMjB0ZiUwQSUwQSUwQSU0MGRhdGFjbGFzcyUwQWNsYXNzJTIwRGF0YUNvbGxhdG9yRm9yTXVsdGlwbGVDaG9pY2UlM0ElMEElMjAlMjAlMjAlMjAlMjIlMjIlMjIlMEElMjAlMjAlMjAlMjBEYXRhJTIwY29sbGF0b3IlMjB0aGF0JTIwd2lsbCUyMGR5bmFtaWNhbGx5JTIwcGFkJTIwdGhlJTIwaW5wdXRzJTIwZm9yJTIwbXVsdGlwbGUlMjBjaG9pY2UlMjByZWNlaXZlZC4lMEElMjAlMjAlMjAlMjAlMjIlMjIlMjIlMEElME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XplJTJDJTIwbnVtX2Nob2ljZXMlMkMlMjAtMSkpJTIwZm9yJTIwayUyQyUyMHYlMjBpbiUyMGJhdGNoLml0ZW1zKCklN0QlMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjBiYXRjaCU1QiUyMmxhYmVscyUyMiU1RCUyMCUzRCUyMHRmLmNvbnZlcnRfdG9fdGVuc29yKGxhYmVscyUyQyUyMGR0eXBlJTNEdGYuaW50NjQpJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwcmV0dXJuJTIwYmF0Y2g=",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> dataclasses <span class="hljs-keyword">import</span> dataclass
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers.tokenization_utils_base <span class="hljs-keyword">import</span> PreTrainedTokenizerBase, PaddingStrategy
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> typing <span class="hljs-keyword">import</span> <span class="hljs-type">Optional</span>, <span class="hljs-type">Union</span>
<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>@dataclass
<span class="hljs-meta">... </span><span class="hljs-keyword">class</span> <span class="hljs-title class_">DataCollatorForMultipleChoice</span>:
<span class="hljs-meta">... </span>    <span class="hljs-string">&quot;&quot;&quot;
<span class="hljs-meta">... </span>    Data collator that will dynamically pad the inputs for multiple choice received.
<span class="hljs-meta">... </span>    &quot;&quot;&quot;</span>

<span class="hljs-meta">... </span>    tokenizer: PreTrainedTokenizerBase
<span class="hljs-meta">... </span>    padding: <span class="hljs-type">Union</span>[<span class="hljs-built_in">bool</span>, <span class="hljs-built_in">str</span>, PaddingStrategy] = <span class="hljs-literal">True</span>
<span class="hljs-meta">... </span>    max_length: <span class="hljs-type">Optional</span>[<span class="hljs-built_in">int</span>] = <span class="hljs-literal">None</span>
<span class="hljs-meta">... </span>    pad_to_multiple_of: <span class="hljs-type">Optional</span>[<span class="hljs-built_in">int</span>] = <span class="hljs-literal">None</span>

<span class="hljs-meta">... </span>    <span class="hljs-keyword">def</span> <span class="hljs-title function_">__call__</span>(<span class="hljs-params">self, features</span>):
<span class="hljs-meta">... </span>        label_name = <span class="hljs-string">&quot;label&quot;</span> <span class="hljs-keyword">if</span> <span class="hljs-string">&quot;label&quot;</span> <span class="hljs-keyword">in</span> features[<span class="hljs-number">0</span>].keys() <span class="hljs-keyword">else</span> <span class="hljs-string">&quot;labels&quot;</span>
<span class="hljs-meta">... </span>        labels = [feature.pop(label_name) <span class="hljs-keyword">for</span> feature <span class="hljs-keyword">in</span> features]
<span class="hljs-meta">... </span>        batch_size = <span class="hljs-built_in">len</span>(features)
<span class="hljs-meta">... </span>        num_choices = <span class="hljs-built_in">len</span>(features[<span class="hljs-number">0</span>][<span class="hljs-string">&quot;input_ids&quot;</span>])
<span class="hljs-meta">... </span>        flattened_features = [
<span class="hljs-meta">... </span>            [{k: v[i] <span class="hljs-keyword">for</span> k, v <span class="hljs-keyword">in</span> feature.items()} <span class="hljs-keyword">for</span> i <span class="hljs-keyword">in</span> <span class="hljs-built_in">range</span>(num_choices)] <span class="hljs-keyword">for</span> feature <span class="hljs-keyword">in</span> features
<span class="hljs-meta">... </span>        ]
<span class="hljs-meta">... </span>        flattened_features = <span class="hljs-built_in">sum</span>(flattened_features, [])

<span class="hljs-meta">... </span>        batch = self.tokenizer.pad(
<span class="hljs-meta">... </span>            flattened_features,
<span class="hljs-meta">... </span>            padding=self.padding,
<span class="hljs-meta">... </span>            max_length=self.max_length,
<span class="hljs-meta">... </span>            pad_to_multiple_of=self.pad_to_multiple_of,
<span class="hljs-meta">... </span>            return_tensors=<span class="hljs-string">&quot;tf&quot;</span>,
<span class="hljs-meta">... </span>        )

<span class="hljs-meta">... </span>        batch = {k: tf.reshape(v, (batch_size, num_choices, -<span class="hljs-number">1</span>)) <span class="hljs-keyword">for</span> k, v <span class="hljs-keyword">in</span> batch.items()}
<span class="hljs-meta">... </span>        batch[<span class="hljs-string">&quot;labels&quot;</span>] = tf.convert_to_tensor(labels, dtype=tf.int64)
<span class="hljs-meta">... </span>        <span class="hljs-keyword">return</span> batch`,wrap:!1}}),{c(){y(a.$$.fragment)},l(l){d(a.$$.fragment,l)},m(l,r){h(a,l,r),c=!0},p:Ts,i(l){c||(u(a.$$.fragment,l),c=!0)},o(l){U(a.$$.fragment,l),c=!1},d(l){J(a,l)}}}function vs(C){let a,c;return a=new fs({props:{$$slots:{default:[Ns]},$$scope:{ctx:C}}}),{c(){y(a.$$.fragment)},l(l){d(a.$$.fragment,l)},m(l,r){h(a,l,r),c=!0},p(l,r){const m={};r&2&&(m.$$scope={dirty:r,ctx:l}),a.$set(m)},i(l){c||(u(a.$$.fragment,l),c=!0)},o(l){U(a.$$.fragment,l),c=!1},d(l){J(a,l)}}}function Ss(C){let a,c='Para familiarizarte con el fine-tuning con <code>Trainer</code>, ¡mira el tutorial básico <a href="../training#finetune-with-trainer">aquí</a>!';return{c(){a=T("p"),a.innerHTML=c},l(l){a=f(l,"P",{"data-svelte-h":!0}),g(a)!=="svelte-1sco78m"&&(a.innerHTML=c)},m(l,r){n(l,a,r)},p:Ts,d(l){l&&t(a)}}}function Hs(C){let a,c="Carga el modelo BERT con <code>AutoModelForMultipleChoice</code>:",l,r,m,b,_,I,E="En este punto, solo quedan tres pasos:",k,G,W="<li>Definir tus hiperparámetros de entrenamiento en <code>TrainingArguments</code>.</li> <li>Pasarle los argumentos del entrenamiento al <code>Trainer</code> jnto con el modelo, el dataset, el tokenizer y el collator de datos.</li> <li>Invocar el método <code>train()</code> para realizar el fine-tuning del modelo.</li>",Z,V,A;return r=new R({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMEF1dG9Nb2RlbEZvck11bHRpcGxlQ2hvaWNlJTJDJTIwVHJhaW5pbmdBcmd1bWVudHMlMkMlMjBUcmFpbmVyJTBBJTBBbW9kZWwlMjAlM0QlMjBBdXRvTW9kZWxGb3JNdWx0aXBsZUNob2ljZS5mcm9tX3ByZXRyYWluZWQoJTIyZ29vZ2xlLWJlcnQlMkZiZXJ0LWJhc2UtdW5jYXNlZCUyMik=",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoModelForMultipleChoice, TrainingArguments, Trainer

<span class="hljs-meta">&gt;&gt;&gt; </span>model = AutoModelForMultipleChoice.from_pretrained(<span class="hljs-string">&quot;google-bert/bert-base-uncased&quot;</span>)`,wrap:!1}}),b=new Xs({props:{$$slots:{default:[Ss]},$$scope:{ctx:C}}}),V=new R({props:{code:"dHJhaW5pbmdfYXJncyUyMCUzRCUyMFRyYWluaW5nQXJndW1lbnRzKCUwQSUyMCUyMCUyMCUyMG91dHB1dF9kaXIlM0QlMjIuJTJGcmVzdWx0cyUyMiUyQyUwQSUyMCUyMCUyMCUyMGV2YWxfc3RyYXRlZ3klM0QlMjJlcG9jaCUyMiUyQyUwQSUyMCUyMCUyMCUyMGxlYXJuaW5nX3JhdGUlM0Q1ZS01JTJDJTBBJTIwJTIwJTIwJTIwcGVyX2RldmljZV90cmFpbl9iYXRjaF9zaXplJTNEMTYlMkMlMEElMjAlMjAlMjAlMjBwZXJfZGV2aWNlX2V2YWxfYmF0Y2hfc2l6ZSUzRDE2JTJDJTBBJTIwJTIwJTIwJTIwbnVtX3RyYWluX2Vwb2NocyUzRDMlMkMlMEElMjAlMjAlMjAlMjB3ZWlnaHRfZGVjYXklM0QwLjAxJTJDJTBBKSUwQSUwQXRyYWluZXIlMjAlM0QlMjBUcmFpbmVyKCUwQSUyMCUyMCUyMCUyMG1vZGVsJTNEbW9kZWwlMkMlMEElMjAlMjAlMjAlMjBhcmdzJTNEdHJhaW5pbmdfYXJncyUyQyUwQSUyMCUyMCUyMCUyMHRyYWluX2RhdGFzZXQlM0R0b2tlbml6ZWRfc3dhZyU1QiUyMnRyYWluJTIyJTVEJTJDJTBBJTIwJTIwJTIwJTIwZXZhbF9kYXRhc2V0JTNEdG9rZW5pemVkX3N3YWclNUIlMjJ2YWxpZGF0aW9uJTIyJTVEJTJDJTBBJTIwJTIwJTIwJTIwcHJvY2Vzc2luZ19jbGFzcyUzRHRva2VuaXplciUyQyUwQSUyMCUyMCUyMCUyMGRhdGFfY29sbGF0b3IlM0REYXRhQ29sbGF0b3JGb3JNdWx0aXBsZUNob2ljZSh0b2tlbml6ZXIlM0R0b2tlbml6ZXIpJTJDJTBBKSUwQSUwQXRyYWluZXIudHJhaW4oKQ==",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span>training_args = TrainingArguments(
<span class="hljs-meta">... </span>    output_dir=<span class="hljs-string">&quot;./results&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">5e-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>)

<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_swag[<span class="hljs-string">&quot;train&quot;</span>],
<span class="hljs-meta">... </span>    eval_dataset=tokenized_swag[<span class="hljs-string">&quot;validation&quot;</span>],
<span class="hljs-meta">... </span>    processing_class=tokenizer,
<span class="hljs-meta">... </span>    data_collator=DataCollatorForMultipleChoice(tokenizer=tokenizer),
<span class="hljs-meta">... </span>)

<span class="hljs-meta">&gt;&gt;&gt; </span>trainer.train()`,wrap:!1}}),{c(){a=T("p"),a.innerHTML=c,l=o(),y(r.$$.fragment),m=o(),y(b.$$.fragment),_=o(),I=T("p"),I.textContent=E,k=o(),G=T("ol"),G.innerHTML=W,Z=o(),y(V.$$.fragment)},l(M){a=f(M,"P",{"data-svelte-h":!0}),g(a)!=="svelte-6bdz67"&&(a.innerHTML=c),l=i(M),d(r.$$.fragment,M),m=i(M),d(b.$$.fragment,M),_=i(M),I=f(M,"P",{"data-svelte-h":!0}),g(I)!=="svelte-bd5x35"&&(I.textContent=E),k=i(M),G=f(M,"OL",{"data-svelte-h":!0}),g(G)!=="svelte-k4ouyy"&&(G.innerHTML=W),Z=i(M),d(V.$$.fragment,M)},m(M,w){n(M,a,w),n(M,l,w),h(r,M,w),n(M,m,w),h(b,M,w),n(M,_,w),n(M,I,w),n(M,k,w),n(M,G,w),n(M,Z,w),h(V,M,w),A=!0},p(M,w){const $={};w&2&&($.$$scope={dirty:w,ctx:M}),b.$set($)},i(M){A||(u(r.$$.fragment,M),u(b.$$.fragment,M),u(V.$$.fragment,M),A=!0)},o(M){U(r.$$.fragment,M),U(b.$$.fragment,M),U(V.$$.fragment,M),A=!1},d(M){M&&(t(a),t(l),t(m),t(_),t(I),t(k),t(G),t(Z)),J(r,M),J(b,M),J(V,M)}}}function qs(C){let a,c;return a=new fs({props:{$$slots:{default:[Hs]},$$scope:{ctx:C}}}),{c(){y(a.$$.fragment)},l(l){d(a.$$.fragment,l)},m(l,r){h(a,l,r),c=!0},p(l,r){const m={};r&2&&(m.$$scope={dirty:r,ctx:l}),a.$set(m)},i(l){c||(u(a.$$.fragment,l),c=!0)},o(l){U(a.$$.fragment,l),c=!1},d(l){J(a,l)}}}function Ds(C){let a,c='Para familiarizarte con el fine-tuning con Keras, ¡mira el tutorial básico <a href="training#finetune-with-keras">aquí</a>!';return{c(){a=T("p"),a.innerHTML=c},l(l){a=f(l,"P",{"data-svelte-h":!0}),g(a)!=="svelte-66s4ry"&&(a.innerHTML=c)},m(l,r){n(l,a,r)},p:Ts,d(l){l&&t(a)}}}function Ls(C){let a,c="Para realizar el fine-tuning de un modelo en TensorFlow, primero convierte tus datasets al formato <code>tf.data.Dataset</code> con el método <code>prepare_tf_dataset()</code>.",l,r,m,b,_,I,E="Prepara una función de optimización, un programa para la tasa de aprendizaje y algunos hiperparámetros de entrenamiento:",k,G,W,Z,V="Carga el modelo BERT con <code>TFAutoModelForMultipleChoice</code>:",A,M,w,$,H='Configura el modelo para entrenarlo con <a href="https://keras.io/api/models/model_training_apis/#compile-method" rel="nofollow"><code>compile</code></a>:',B,Q,F,X,q='Invoca el método <a href="https://keras.io/api/models/model_training_apis/#fit-method" rel="nofollow"><code>fit</code></a> para realizar el fine-tuning del modelo:',z,Y,N;return r=new R({props:{code:"ZGF0YV9jb2xsYXRvciUyMCUzRCUyMERhdGFDb2xsYXRvckZvck11bHRpcGxlQ2hvaWNlKHRva2VuaXplciUzRHRva2VuaXplciklMEF0Zl90cmFpbl9zZXQlMjAlM0QlMjBtb2RlbC5wcmVwYXJlX3RmX2RhdGFzZXQoJTBBJTIwJTIwJTIwJTIwdG9rZW5pemVkX3N3YWclNUIlMjJ0cmFpbiUyMiU1RCUyQyUwQSUyMCUyMCUyMCUyMHNodWZmbGUlM0RUcnVlJTJDJTBBJTIwJTIwJTIwJTIwYmF0Y2hfc2l6ZSUzRGJhdGNoX3NpemUlMkMlMEElMjAlMjAlMjAlMjBjb2xsYXRlX2ZuJTNEZGF0YV9jb2xsYXRvciUyQyUwQSklMEElMEF0Zl92YWxpZGF0aW9uX3NldCUyMCUzRCUyMG1vZGVsLnByZXBhcmVfdGZfZGF0YXNldCglMEElMjAlMjAlMjAlMjB0b2tlbml6ZWRfc3dhZyU1QiUyMnZhbGlkYXRpb24lMjIlNUQlMkMlMEElMjAlMjAlMjAlMjBzaHVmZmxlJTNERmFsc2UlMkMlMEElMjAlMjAlMjAlMjBiYXRjaF9zaXplJTNEYmF0Y2hfc2l6ZSUyQyUwQSUyMCUyMCUyMCUyMGNvbGxhdGVfZm4lM0RkYXRhX2NvbGxhdG9yJTJDJTBBKQ==",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span>data_collator = DataCollatorForMultipleChoice(tokenizer=tokenizer)
<span class="hljs-meta">&gt;&gt;&gt; </span>tf_train_set = model.prepare_tf_dataset(
<span class="hljs-meta">... </span>    tokenized_swag[<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=batch_size,
<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_swag[<span class="hljs-string">&quot;validation&quot;</span>],
<span class="hljs-meta">... </span>    shuffle=<span class="hljs-literal">False</span>,
<span class="hljs-meta">... </span>    batch_size=batch_size,
<span class="hljs-meta">... </span>    collate_fn=data_collator,
<span class="hljs-meta">... </span>)`,wrap:!1}}),b=new Xs({props:{$$slots:{default:[Ds]},$$scope:{ctx:C}}}),G=new R({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMGNyZWF0ZV9vcHRpbWl6ZXIlMEElMEFiYXRjaF9zaXplJTIwJTNEJTIwMTYlMEFudW1fdHJhaW5fZXBvY2hzJTIwJTNEJTIwMiUwQXRvdGFsX3RyYWluX3N0ZXBzJTIwJTNEJTIwKGxlbih0b2tlbml6ZWRfc3dhZyU1QiUyMnRyYWluJTIyJTVEKSUyMCUyRiUyRiUyMGJhdGNoX3NpemUpJTIwKiUyMG51bV90cmFpbl9lcG9jaHMlMEFvcHRpbWl6ZXIlMkMlMjBzY2hlZHVsZSUyMCUzRCUyMGNyZWF0ZV9vcHRpbWl6ZXIoaW5pdF9sciUzRDVlLTUlMkMlMjBudW1fd2FybXVwX3N0ZXBzJTNEMCUyQyUyMG51bV90cmFpbl9zdGVwcyUzRHRvdGFsX3RyYWluX3N0ZXBzKQ==",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> create_optimizer

<span class="hljs-meta">&gt;&gt;&gt; </span>batch_size = <span class="hljs-number">16</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>num_train_epochs = <span class="hljs-number">2</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>total_train_steps = (<span class="hljs-built_in">len</span>(tokenized_swag[<span class="hljs-string">&quot;train&quot;</span>]) // batch_size) * num_train_epochs
<span class="hljs-meta">&gt;&gt;&gt; </span>optimizer, schedule = create_optimizer(init_lr=<span class="hljs-number">5e-5</span>, num_warmup_steps=<span class="hljs-number">0</span>, num_train_steps=total_train_steps)`,wrap:!1}}),M=new R({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMFRGQXV0b01vZGVsRm9yTXVsdGlwbGVDaG9pY2UlMEElMEFtb2RlbCUyMCUzRCUyMFRGQXV0b01vZGVsRm9yTXVsdGlwbGVDaG9pY2UuZnJvbV9wcmV0cmFpbmVkKCUyMmdvb2dsZS1iZXJ0JTJGYmVydC1iYXNlLXVuY2FzZWQlMjIp",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> TFAutoModelForMultipleChoice

<span class="hljs-meta">&gt;&gt;&gt; </span>model = TFAutoModelForMultipleChoice.from_pretrained(<span class="hljs-string">&quot;google-bert/bert-base-uncased&quot;</span>)`,wrap:!1}}),Q=new R({props:{code:"bW9kZWwuY29tcGlsZShvcHRpbWl6ZXIlM0RvcHRpbWl6ZXIp",highlighted:'<span class="hljs-meta">&gt;&gt;&gt; </span>model.<span class="hljs-built_in">compile</span>(optimizer=optimizer)',wrap:!1}}),Y=new R({props:{code:"bW9kZWwuZml0KHglM0R0Zl90cmFpbl9zZXQlMkMlMjB2YWxpZGF0aW9uX2RhdGElM0R0Zl92YWxpZGF0aW9uX3NldCUyQyUyMGVwb2NocyUzRDIp",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">2</span>)',wrap:!1}}),{c(){a=T("p"),a.innerHTML=c,l=o(),y(r.$$.fragment),m=o(),y(b.$$.fragment),_=o(),I=T("p"),I.textContent=E,k=o(),y(G.$$.fragment),W=o(),Z=T("p"),Z.innerHTML=V,A=o(),y(M.$$.fragment),w=o(),$=T("p"),$.innerHTML=H,B=o(),y(Q.$$.fragment),F=o(),X=T("p"),X.innerHTML=q,z=o(),y(Y.$$.fragment)},l(e){a=f(e,"P",{"data-svelte-h":!0}),g(a)!=="svelte-1dn6k4v"&&(a.innerHTML=c),l=i(e),d(r.$$.fragment,e),m=i(e),d(b.$$.fragment,e),_=i(e),I=f(e,"P",{"data-svelte-h":!0}),g(I)!=="svelte-81yq28"&&(I.textContent=E),k=i(e),d(G.$$.fragment,e),W=i(e),Z=f(e,"P",{"data-svelte-h":!0}),g(Z)!=="svelte-1v9x5sp"&&(Z.innerHTML=V),A=i(e),d(M.$$.fragment,e),w=i(e),$=f(e,"P",{"data-svelte-h":!0}),g($)!=="svelte-jy7mgr"&&($.innerHTML=H),B=i(e),d(Q.$$.fragment,e),F=i(e),X=f(e,"P",{"data-svelte-h":!0}),g(X)!=="svelte-1dz4xz1"&&(X.innerHTML=q),z=i(e),d(Y.$$.fragment,e)},m(e,j){n(e,a,j),n(e,l,j),h(r,e,j),n(e,m,j),h(b,e,j),n(e,_,j),n(e,I,j),n(e,k,j),h(G,e,j),n(e,W,j),n(e,Z,j),n(e,A,j),h(M,e,j),n(e,w,j),n(e,$,j),n(e,B,j),h(Q,e,j),n(e,F,j),n(e,X,j),n(e,z,j),h(Y,e,j),N=!0},p(e,j){const x={};j&2&&(x.$$scope={dirty:j,ctx:e}),b.$set(x)},i(e){N||(u(r.$$.fragment,e),u(b.$$.fragment,e),u(G.$$.fragment,e),u(M.$$.fragment,e),u(Q.$$.fragment,e),u(Y.$$.fragment,e),N=!0)},o(e){U(r.$$.fragment,e),U(b.$$.fragment,e),U(G.$$.fragment,e),U(M.$$.fragment,e),U(Q.$$.fragment,e),U(Y.$$.fragment,e),N=!1},d(e){e&&(t(a),t(l),t(m),t(_),t(I),t(k),t(W),t(Z),t(A),t(w),t($),t(B),t(F),t(X),t(z)),J(r,e),J(b,e),J(G,e),J(M,e),J(Q,e),J(Y,e)}}}function Ps(C){let a,c;return a=new fs({props:{$$slots:{default:[Ls]},$$scope:{ctx:C}}}),{c(){y(a.$$.fragment)},l(l){d(a.$$.fragment,l)},m(l,r){h(a,l,r),c=!0},p(l,r){const m={};r&2&&(m.$$scope={dirty:r,ctx:l}),a.$set(m)},i(l){c||(u(a.$$.fragment,l),c=!0)},o(l){U(a.$$.fragment,l),c=!1},d(l){J(a,l)}}}function Ks(C){let a,c,l,r,m,b,_,I=`La tarea de selección múltiple es parecida a la de responder preguntas, con la excepción de que se dan varias opciones de respuesta junto con el contexto. El modelo se entrena para escoger la respuesta correcta
entre varias opciones a partir del contexto dado.`,E,k,G=`Esta guía te mostrará como hacerle fine-tuning a <a href="https://huggingface.co/google-bert/bert-base-uncased" rel="nofollow">BERT</a> en la configuración <code>regular</code> del dataset <a href="https://huggingface.co/datasets/swag" rel="nofollow">SWAG</a>, de forma
que seleccione la mejor respuesta a partir de varias opciones y algún contexto.`,W,Z,V,A,M="Carga el dataset SWAG con la biblioteca 🤗 Datasets:",w,$,H,B,Q="Ahora, échale un vistazo a un ejemplo del dataset:",F,X,q,z,Y="Los campos <code>sent1</code> y <code>sent2</code> muestran cómo comienza una oración, y cada campo <code>ending</code> indica cómo podría terminar. Dado el comienzo de la oración, el modelo debe escoger el final de oración correcto indicado por el campo <code>label</code>.",N,e,j,x,bs="Carga el tokenizer de BERT para procesar el comienzo de cada oración y los cuatro finales posibles:",ps,D,Ms,L,gs="La función de preprocesmaiento debe hacer lo siguiente:",rs,P,Cs="<li>Hacer cuatro copias del campo <code>sent1</code> de forma que se pueda combinar cada una con el campo <code>sent2</code> para recrear la forma en que empieza la oración.</li> <li>Combinar <code>sent2</code> con cada uno de los cuatro finales de oración posibles.</li> <li>Aplanar las dos listas para que puedas tokenizarlas, y luego des-aplanarlas para que cada ejemplo tenga los campos <code>input_ids</code>, <code>attention_mask</code> y <code>labels</code> correspondientes.</li>",cs,K,os,O,Zs="Usa la función <code>map</code> de 🤗 Datasets para aplicarle la función de preprocesamiento al dataset entero. Puedes acelerar la función <code>map</code> haciendo <code>batched=True</code> para procesar varios elementos del dataset a la vez.",is,ss,ms,ls,Is=`🤗 Transformers no tiene un collator de datos para la tarea de selección múltiple, así que tendrías que crear uno. Puedes adaptar el <code>DataCollatorWithPadding</code> para crear un lote de ejemplos para selección múltiple. Este también
le <em>añadirá relleno de manera dinámica</em> a tu texto y a las etiquetas para que tengan la longitud del elemento más largo en su lote, de forma que tengan una longitud uniforme. Aunque es posible rellenar el texto en la función <code>tokenizer</code> haciendo
<code>padding=True</code>, el rellenado dinámico es más eficiente.`,js,as,Gs="El <code>DataCollatorForMultipleChoice</code> aplanará todas las entradas del modelo, les aplicará relleno y luego des-aplanará los resultados:",ys,v,ds,es,hs,S,us,ts,Us,ns,Js;return m=new ws({props:{title:"Selección múltiple",local:"selección-múltiple",headingTag:"h1"}}),Z=new ws({props:{title:"Cargar el dataset SWAG",local:"cargar-el-dataset-swag",headingTag:"h2"}}),$=new R({props:{code:"ZnJvbSUyMGRhdGFzZXRzJTIwaW1wb3J0JTIwbG9hZF9kYXRhc2V0JTBBJTBBc3dhZyUyMCUzRCUyMGxvYWRfZGF0YXNldCglMjJzd2FnJTIyJTJDJTIwJTIycmVndWxhciUyMik=",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>swag = load_dataset(<span class="hljs-string">&quot;swag&quot;</span>, <span class="hljs-string">&quot;regular&quot;</span>)`,wrap:!1}}),X=new R({props:{code:"c3dhZyU1QiUyMnRyYWluJTIyJTVEJTVCMCU1RA==",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span>swag[<span class="hljs-string">&quot;train&quot;</span>][<span class="hljs-number">0</span>]
{<span class="hljs-string">&#x27;ending0&#x27;</span>: <span class="hljs-string">&#x27;passes by walking down the street playing their instruments.&#x27;</span>,
 <span class="hljs-string">&#x27;ending1&#x27;</span>: <span class="hljs-string">&#x27;has heard approaching them.&#x27;</span>,
 <span class="hljs-string">&#x27;ending2&#x27;</span>: <span class="hljs-string">&quot;arrives and they&#x27;re outside dancing and asleep.&quot;</span>,
 <span class="hljs-string">&#x27;ending3&#x27;</span>: <span class="hljs-string">&#x27;turns the lead singer watches the performance.&#x27;</span>,
 <span class="hljs-string">&#x27;fold-ind&#x27;</span>: <span class="hljs-string">&#x27;3416&#x27;</span>,
 <span class="hljs-string">&#x27;gold-source&#x27;</span>: <span class="hljs-string">&#x27;gold&#x27;</span>,
 <span class="hljs-string">&#x27;label&#x27;</span>: <span class="hljs-number">0</span>,
 <span class="hljs-string">&#x27;sent1&#x27;</span>: <span class="hljs-string">&#x27;Members of the procession walk down the street holding small horn brass instruments.&#x27;</span>,
 <span class="hljs-string">&#x27;sent2&#x27;</span>: <span class="hljs-string">&#x27;A drum line&#x27;</span>,
 <span class="hljs-string">&#x27;startphrase&#x27;</span>: <span class="hljs-string">&#x27;Members of the procession walk down the street holding small horn brass instruments. A drum line&#x27;</span>,
 <span class="hljs-string">&#x27;video-id&#x27;</span>: <span class="hljs-string">&#x27;anetv_jkn6uvmqwh4&#x27;</span>}`,wrap:!1}}),e=new ws({props:{title:"Preprocesmaiento",local:"preprocesmaiento",headingTag:"h2"}}),D=new R({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMEF1dG9Ub2tlbml6ZXIlMEElMEF0b2tlbml6ZXIlMjAlM0QlMjBBdXRvVG9rZW5pemVyLmZyb21fcHJldHJhaW5lZCglMjJnb29nbGUtYmVydCUyRmJlcnQtYmFzZS11bmNhc2VkJTIyKQ==",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;google-bert/bert-base-uncased&quot;</span>)`,wrap:!1}}),K=new R({props:{code:"ZW5kaW5nX25hbWVzJTIwJTNEJTIwJTVCJTIyZW5kaW5nMCUyMiUyQyUyMCUyMmVuZGluZzElMjIlMkMlMjAlMjJlbmRpbmcyJTIyJTJDJTIwJTIyZW5kaW5nMyUyMiU1RCUwQSUwQSUwQWRlZiUyMHByZXByb2Nlc3NfZnVuY3Rpb24oZXhhbXBsZXMpJTNBJTBBJTIwJTIwJTIwJTIwZmlyc3Rfc2VudGVuY2VzJTIwJTNEJTIwJTVCJTVCY29udGV4dCU1RCUyMColMjA0JTIwZm9yJTIwY29udGV4dCUyMGluJTIwZXhhbXBsZXMlNUIlMjJzZW50MSUyMiU1RCU1RCUwQSUyMCUyMCUyMCUyMHF1ZXN0aW9uX2hlYWRlcnMlMjAlM0QlMjBleGFtcGxlcyU1QiUyMnNlbnQyJTIyJTVEJTBBJTIwJTIwJTIwJTIwc2Vjb25kX3NlbnRlbmNlcyUyMCUzRCUyMCU1QiUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCU1QmYlMjIlN0JoZWFkZXIlN0QlMjAlN0JleGFtcGxlcyU1QmVuZCU1RCU1QmklNUQlN0QlMjIlMjBmb3IlMjBlbmQlMjBpbiUyMGVuZGluZ19uYW1lcyU1RCUyMGZvciUyMGklMkMlMjBoZWFkZXIlMjBpbiUyMGVudW1lcmF0ZShxdWVzdGlvbl9oZWFkZXJzKSUwQSUyMCUyMCUyMCUyMCU1RCUwQSUwQSUyMCUyMCUyMCUyMGZpcnN0X3NlbnRlbmNlcyUyMCUzRCUyMHN1bShmaXJzdF9zZW50ZW5jZXMlMkMlMjAlNUIlNUQpJTBBJTIwJTIwJTIwJTIwc2Vjb25kX3NlbnRlbmNlcyUyMCUzRCUyMHN1bShzZWNvbmRfc2VudGVuY2VzJTJDJTIwJTVCJTVEKSUwQSUwQSUyMCUyMCUyMCUyMHRva2VuaXplZF9leGFtcGxlcyUyMCUzRCUyMHRva2VuaXplcihmaXJzdF9zZW50ZW5jZXMlMkMlMjBzZWNvbmRfc2VudGVuY2VzJTJDJTIwdHJ1bmNhdGlvbiUzRFRydWUpJTBBJTIwJTIwJTIwJTIwcmV0dXJuJTIwJTdCayUzQSUyMCU1QnYlNUJpJTIwJTNBJTIwaSUyMCUyQiUyMDQlNUQlMjBmb3IlMjBpJTIwaW4lMjByYW5nZSgwJTJDJTIwbGVuKHYpJTJDJTIwNCklNUQlMjBmb3IlMjBrJTJDJTIwdiUyMGluJTIwdG9rZW5pemVkX2V4YW1wbGVzLml0ZW1zKCklN0Q=",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span>ending_names = [<span class="hljs-string">&quot;ending0&quot;</span>, <span class="hljs-string">&quot;ending1&quot;</span>, <span class="hljs-string">&quot;ending2&quot;</span>, <span class="hljs-string">&quot;ending3&quot;</span>]


<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>    first_sentences = [[context] * <span class="hljs-number">4</span> <span class="hljs-keyword">for</span> context <span class="hljs-keyword">in</span> examples[<span class="hljs-string">&quot;sent1&quot;</span>]]
<span class="hljs-meta">... </span>    question_headers = examples[<span class="hljs-string">&quot;sent2&quot;</span>]
<span class="hljs-meta">... </span>    second_sentences = [
<span class="hljs-meta">... </span>        [<span class="hljs-string">f&quot;<span class="hljs-subst">{header}</span> <span class="hljs-subst">{examples[end][i]}</span>&quot;</span> <span class="hljs-keyword">for</span> end <span class="hljs-keyword">in</span> ending_names] <span class="hljs-keyword">for</span> i, header <span class="hljs-keyword">in</span> <span class="hljs-built_in">enumerate</span>(question_headers)
<span class="hljs-meta">... </span>    ]

<span class="hljs-meta">... </span>    first_sentences = <span class="hljs-built_in">sum</span>(first_sentences, [])
<span class="hljs-meta">... </span>    second_sentences = <span class="hljs-built_in">sum</span>(second_sentences, [])

<span class="hljs-meta">... </span>    tokenized_examples = tokenizer(first_sentences, second_sentences, truncation=<span class="hljs-literal">True</span>)
<span class="hljs-meta">... </span>    <span class="hljs-keyword">return</span> {k: [v[i : i + <span class="hljs-number">4</span>] <span class="hljs-keyword">for</span> i <span class="hljs-keyword">in</span> <span class="hljs-built_in">range</span>(<span class="hljs-number">0</span>, <span class="hljs-built_in">len</span>(v), <span class="hljs-number">4</span>)] <span class="hljs-keyword">for</span> k, v <span class="hljs-keyword">in</span> tokenized_examples.items()}`,wrap:!1}}),ss=new R({props:{code:"dG9rZW5pemVkX3N3YWclMjAlM0QlMjBzd2FnLm1hcChwcmVwcm9jZXNzX2Z1bmN0aW9uJTJDJTIwYmF0Y2hlZCUzRFRydWUp",highlighted:'tokenized_swag = swag.<span class="hljs-built_in">map</span>(preprocess_function, batched=<span class="hljs-literal">True</span>)',wrap:!1}}),v=new Vs({props:{pytorch:!0,tensorflow:!0,jax:!1,$$slots:{tensorflow:[vs],pytorch:[Fs]},$$scope:{ctx:C}}}),es=new ws({props:{title:"Entrenamiento",local:"entrenamiento",headingTag:"h2"}}),S=new Vs({props:{pytorch:!0,tensorflow:!0,jax:!1,$$slots:{tensorflow:[Ps],pytorch:[qs]},$$scope:{ctx:C}}}),ts=new Ys({props:{source:"https://github.com/huggingface/transformers/blob/main/docs/source/es/tasks/multiple_choice.md"}}),{c(){a=T("meta"),c=o(),l=T("p"),r=o(),y(m.$$.fragment),b=o(),_=T("p"),_.textContent=I,E=o(),k=T("p"),k.innerHTML=G,W=o(),y(Z.$$.fragment),V=o(),A=T("p"),A.textContent=M,w=o(),y($.$$.fragment),H=o(),B=T("p"),B.textContent=Q,F=o(),y(X.$$.fragment),q=o(),z=T("p"),z.innerHTML=Y,N=o(),y(e.$$.fragment),j=o(),x=T("p"),x.textContent=bs,ps=o(),y(D.$$.fragment),Ms=o(),L=T("p"),L.textContent=gs,rs=o(),P=T("ol"),P.innerHTML=Cs,cs=o(),y(K.$$.fragment),os=o(),O=T("p"),O.innerHTML=Zs,is=o(),y(ss.$$.fragment),ms=o(),ls=T("p"),ls.innerHTML=Is,js=o(),as=T("p"),as.innerHTML=Gs,ys=o(),y(v.$$.fragment),ds=o(),y(es.$$.fragment),hs=o(),y(S.$$.fragment),us=o(),y(ts.$$.fragment),Us=o(),ns=T("p"),this.h()},l(s){const p=Es("svelte-u9bgzb",document.head);a=f(p,"META",{name:!0,content:!0}),p.forEach(t),c=i(s),l=f(s,"P",{}),ks(l).forEach(t),r=i(s),d(m.$$.fragment,s),b=i(s),_=f(s,"P",{"data-svelte-h":!0}),g(_)!=="svelte-50nup6"&&(_.textContent=I),E=i(s),k=f(s,"P",{"data-svelte-h":!0}),g(k)!=="svelte-1tgwhyx"&&(k.innerHTML=G),W=i(s),d(Z.$$.fragment,s),V=i(s),A=f(s,"P",{"data-svelte-h":!0}),g(A)!=="svelte-vnn33k"&&(A.textContent=M),w=i(s),d($.$$.fragment,s),H=i(s),B=f(s,"P",{"data-svelte-h":!0}),g(B)!=="svelte-x1ncwr"&&(B.textContent=Q),F=i(s),d(X.$$.fragment,s),q=i(s),z=f(s,"P",{"data-svelte-h":!0}),g(z)!=="svelte-1ri0vdd"&&(z.innerHTML=Y),N=i(s),d(e.$$.fragment,s),j=i(s),x=f(s,"P",{"data-svelte-h":!0}),g(x)!=="svelte-1iq2bgx"&&(x.textContent=bs),ps=i(s),d(D.$$.fragment,s),Ms=i(s),L=f(s,"P",{"data-svelte-h":!0}),g(L)!=="svelte-1jkglaf"&&(L.textContent=gs),rs=i(s),P=f(s,"OL",{"data-svelte-h":!0}),g(P)!=="svelte-12xaauq"&&(P.innerHTML=Cs),cs=i(s),d(K.$$.fragment,s),os=i(s),O=f(s,"P",{"data-svelte-h":!0}),g(O)!=="svelte-f9xmqh"&&(O.innerHTML=Zs),is=i(s),d(ss.$$.fragment,s),ms=i(s),ls=f(s,"P",{"data-svelte-h":!0}),g(ls)!=="svelte-1vi4idm"&&(ls.innerHTML=Is),js=i(s),as=f(s,"P",{"data-svelte-h":!0}),g(as)!=="svelte-1010f04"&&(as.innerHTML=Gs),ys=i(s),d(v.$$.fragment,s),ds=i(s),d(es.$$.fragment,s),hs=i(s),d(S.$$.fragment,s),us=i(s),d(ts.$$.fragment,s),Us=i(s),ns=f(s,"P",{}),ks(ns).forEach(t),this.h()},h(){As(a,"name","hf:doc:metadata"),As(a,"content",Os)},m(s,p){Qs(document.head,a),n(s,c,p),n(s,l,p),n(s,r,p),h(m,s,p),n(s,b,p),n(s,_,p),n(s,E,p),n(s,k,p),n(s,W,p),h(Z,s,p),n(s,V,p),n(s,A,p),n(s,w,p),h($,s,p),n(s,H,p),n(s,B,p),n(s,F,p),h(X,s,p),n(s,q,p),n(s,z,p),n(s,N,p),h(e,s,p),n(s,j,p),n(s,x,p),n(s,ps,p),h(D,s,p),n(s,Ms,p),n(s,L,p),n(s,rs,p),n(s,P,p),n(s,cs,p),h(K,s,p),n(s,os,p),n(s,O,p),n(s,is,p),h(ss,s,p),n(s,ms,p),n(s,ls,p),n(s,js,p),n(s,as,p),n(s,ys,p),h(v,s,p),n(s,ds,p),h(es,s,p),n(s,hs,p),h(S,s,p),n(s,us,p),h(ts,s,p),n(s,Us,p),n(s,ns,p),Js=!0},p(s,[p]){const $s={};p&2&&($s.$$scope={dirty:p,ctx:s}),v.$set($s);const _s={};p&2&&(_s.$$scope={dirty:p,ctx:s}),S.$set(_s)},i(s){Js||(u(m.$$.fragment,s),u(Z.$$.fragment,s),u($.$$.fragment,s),u(X.$$.fragment,s),u(e.$$.fragment,s),u(D.$$.fragment,s),u(K.$$.fragment,s),u(ss.$$.fragment,s),u(v.$$.fragment,s),u(es.$$.fragment,s),u(S.$$.fragment,s),u(ts.$$.fragment,s),Js=!0)},o(s){U(m.$$.fragment,s),U(Z.$$.fragment,s),U($.$$.fragment,s),U(X.$$.fragment,s),U(e.$$.fragment,s),U(D.$$.fragment,s),U(K.$$.fragment,s),U(ss.$$.fragment,s),U(v.$$.fragment,s),U(es.$$.fragment,s),U(S.$$.fragment,s),U(ts.$$.fragment,s),Js=!1},d(s){s&&(t(c),t(l),t(r),t(b),t(_),t(E),t(k),t(W),t(V),t(A),t(w),t(H),t(B),t(F),t(q),t(z),t(N),t(j),t(x),t(ps),t(Ms),t(L),t(rs),t(P),t(cs),t(os),t(O),t(is),t(ms),t(ls),t(js),t(as),t(ys),t(ds),t(hs),t(us),t(Us),t(ns)),t(a),J(m,s),J(Z,s),J($,s),J(X,s),J(e,s),J(D,s),J(K,s),J(ss,s),J(v,s),J(es,s),J(S,s),J(ts,s)}}}const Os='{"title":"Selección múltiple","local":"selección-múltiple","sections":[{"title":"Cargar el dataset SWAG","local":"cargar-el-dataset-swag","sections":[],"depth":2},{"title":"Preprocesmaiento","local":"preprocesmaiento","sections":[],"depth":2},{"title":"Entrenamiento","local":"entrenamiento","sections":[],"depth":2}],"depth":1}';function sl(C){return Ws(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class Ml extends Bs{constructor(a){super(),zs(this,a,sl,Ks,Rs,{})}}export{Ml as component};
