import{s as Xs,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 Vs,y as xs,a as n,v as h,d as u,t as U,w as J}from"../chunks/index.f891bdb2.js";import{T as Rs}from"../chunks/Tip.a8272f7f.js";import{C as X}from"../chunks/CodeBlock.3ec784ea.js";import{F as As,M as fs}from"../chunks/Markdown.7b58822e.js";import{H as ws,E as Ys}from"../chunks/EditOnGithub.a58e27a9.js";function Fs(C){let a,c;return a=new X({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,M){h(a,l,M),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 Qs(C){let a,c;return a=new fs({props:{$$slots:{default:[Fs]},$$scope:{ctx:C}}}),{c(){y(a.$$.fragment)},l(l){d(a.$$.fragment,l)},m(l,M){h(a,l,M),c=!0},p(l,M){const m={};M&2&&(m.$$scope={dirty:M,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 vs(C){let a,c;return a=new X({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,M){h(a,l,M),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 Ns(C){let a,c;return a=new fs({props:{$$slots:{default:[vs]},$$scope:{ctx:C}}}),{c(){y(a.$$.fragment)},l(l){d(a.$$.fragment,l)},m(l,M){h(a,l,M),c=!0},p(l,M){const m={};M&2&&(m.$$scope={dirty:M,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,M){n(l,a,M)},p:Ts,d(l){l&&t(a)}}}function Hs(C){let a,c="Carga el modelo BERT con <code>AutoModelForMultipleChoice</code>:",l,M,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,A,V;return M=new X({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 Rs({props:{$$slots:{default:[Ss]},$$scope:{ctx:C}}}),A=new X({props:{code:"dHJhaW5pbmdfYXJncyUyMCUzRCUyMFRyYWluaW5nQXJndW1lbnRzKCUwQSUyMCUyMCUyMCUyMG91dHB1dF9kaXIlM0QlMjIuJTJGcmVzdWx0cyUyMiUyQyUwQSUyMCUyMCUyMCUyMGV2YWxfc3RyYXRlZ3klM0QlMjJlcG9jaCUyMiUyQyUwQSUyMCUyMCUyMCUyMGxlYXJuaW5nX3JhdGUlM0Q1ZS01JTJDJTBBJTIwJTIwJTIwJTIwcGVyX2RldmljZV90cmFpbl9iYXRjaF9zaXplJTNEMTYlMkMlMEElMjAlMjAlMjAlMjBwZXJfZGV2aWNlX2V2YWxfYmF0Y2hfc2l6ZSUzRDE2JTJDJTBBJTIwJTIwJTIwJTIwbnVtX3RyYWluX2Vwb2NocyUzRDMlMkMlMEElMjAlMjAlMjAlMjB3ZWlnaHRfZGVjYXklM0QwLjAxJTJDJTBBKSUwQSUwQXRyYWluZXIlMjAlM0QlMjBUcmFpbmVyKCUwQSUyMCUyMCUyMCUyMG1vZGVsJTNEbW9kZWwlMkMlMEElMjAlMjAlMjAlMjBhcmdzJTNEdHJhaW5pbmdfYXJncyUyQyUwQSUyMCUyMCUyMCUyMHRyYWluX2RhdGFzZXQlM0R0b2tlbml6ZWRfc3dhZyU1QiUyMnRyYWluJTIyJTVEJTJDJTBBJTIwJTIwJTIwJTIwZXZhbF9kYXRhc2V0JTNEdG9rZW5pemVkX3N3YWclNUIlMjJ2YWxpZGF0aW9uJTIyJTVEJTJDJTBBJTIwJTIwJTIwJTIwdG9rZW5pemVyJTNEdG9rZW5pemVyJTJDJTBBJTIwJTIwJTIwJTIwZGF0YV9jb2xsYXRvciUzRERhdGFDb2xsYXRvckZvck11bHRpcGxlQ2hvaWNlKHRva2VuaXplciUzRHRva2VuaXplciklMkMlMEEpJTBBJTBBdHJhaW5lci50cmFpbigp",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>    tokenizer=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(M.$$.fragment),m=o(),y(b.$$.fragment),_=o(),I=T("p"),I.textContent=E,k=o(),G=T("ol"),G.innerHTML=W,Z=o(),y(A.$$.fragment)},l(r){a=f(r,"P",{"data-svelte-h":!0}),g(a)!=="svelte-6bdz67"&&(a.innerHTML=c),l=i(r),d(M.$$.fragment,r),m=i(r),d(b.$$.fragment,r),_=i(r),I=f(r,"P",{"data-svelte-h":!0}),g(I)!=="svelte-bd5x35"&&(I.textContent=E),k=i(r),G=f(r,"OL",{"data-svelte-h":!0}),g(G)!=="svelte-k4ouyy"&&(G.innerHTML=W),Z=i(r),d(A.$$.fragment,r)},m(r,w){n(r,a,w),n(r,l,w),h(M,r,w),n(r,m,w),h(b,r,w),n(r,_,w),n(r,I,w),n(r,k,w),n(r,G,w),n(r,Z,w),h(A,r,w),V=!0},p(r,w){const $={};w&2&&($.$$scope={dirty:w,ctx:r}),b.$set($)},i(r){V||(u(M.$$.fragment,r),u(b.$$.fragment,r),u(A.$$.fragment,r),V=!0)},o(r){U(M.$$.fragment,r),U(b.$$.fragment,r),U(A.$$.fragment,r),V=!1},d(r){r&&(t(a),t(l),t(m),t(_),t(I),t(k),t(G),t(Z)),J(M,r),J(b,r),J(A,r)}}}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,M){h(a,l,M),c=!0},p(l,M){const m={};M&2&&(m.$$scope={dirty:M,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,M){n(l,a,M)},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,M,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,A="Carga el modelo BERT con <code>TFAutoModelForMultipleChoice</code>:",V,r,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,x,Q,R,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,v;return M=new X({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 Rs({props:{$$slots:{default:[Ds]},$$scope:{ctx:C}}}),G=new X({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}}),r=new X({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}}),x=new X({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 X({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(M.$$.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=A,V=o(),y(r.$$.fragment),w=o(),$=T("p"),$.innerHTML=H,B=o(),y(x.$$.fragment),Q=o(),R=T("p"),R.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(M.$$.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=A),V=i(e),d(r.$$.fragment,e),w=i(e),$=f(e,"P",{"data-svelte-h":!0}),g($)!=="svelte-jy7mgr"&&($.innerHTML=H),B=i(e),d(x.$$.fragment,e),Q=i(e),R=f(e,"P",{"data-svelte-h":!0}),g(R)!=="svelte-1dz4xz1"&&(R.innerHTML=q),z=i(e),d(Y.$$.fragment,e)},m(e,j){n(e,a,j),n(e,l,j),h(M,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,V,j),h(r,e,j),n(e,w,j),n(e,$,j),n(e,B,j),h(x,e,j),n(e,Q,j),n(e,R,j),n(e,z,j),h(Y,e,j),v=!0},p(e,j){const F={};j&2&&(F.$$scope={dirty:j,ctx:e}),b.$set(F)},i(e){v||(u(M.$$.fragment,e),u(b.$$.fragment,e),u(G.$$.fragment,e),u(r.$$.fragment,e),u(x.$$.fragment,e),u(Y.$$.fragment,e),v=!0)},o(e){U(M.$$.fragment,e),U(b.$$.fragment,e),U(G.$$.fragment,e),U(r.$$.fragment,e),U(x.$$.fragment,e),U(Y.$$.fragment,e),v=!1},d(e){e&&(t(a),t(l),t(m),t(_),t(I),t(k),t(W),t(Z),t(V),t(w),t($),t(B),t(Q),t(R),t(z)),J(M,e),J(b,e),J(G,e),J(r,e),J(x,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,M){h(a,l,M),c=!0},p(l,M){const m={};M&2&&(m.$$scope={dirty:M,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,M,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,A,V,r="Carga el dataset SWAG con la biblioteca 🤗 Datasets:",w,$,H,B,x="Ahora, échale un vistazo a un ejemplo del dataset:",Q,R,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>.",v,e,j,F,bs="Carga el tokenizer de BERT para procesar el comienzo de cada oración y los cuatro finales posibles:",ps,D,rs,L,gs="La función de preprocesmaiento debe hacer lo siguiente:",Ms,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,N,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 X({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}}),R=new X({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 X({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 X({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 X({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}}),N=new As({props:{pytorch:!0,tensorflow:!0,jax:!1,$$slots:{tensorflow:[Ns],pytorch:[Qs]},$$scope:{ctx:C}}}),es=new ws({props:{title:"Entrenamiento",local:"entrenamiento",headingTag:"h2"}}),S=new As({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"),M=o(),y(m.$$.fragment),b=o(),_=T("p"),_.textContent=I,E=o(),k=T("p"),k.innerHTML=G,W=o(),y(Z.$$.fragment),A=o(),V=T("p"),V.textContent=r,w=o(),y($.$$.fragment),H=o(),B=T("p"),B.textContent=x,Q=o(),y(R.$$.fragment),q=o(),z=T("p"),z.innerHTML=Y,v=o(),y(e.$$.fragment),j=o(),F=T("p"),F.textContent=bs,ps=o(),y(D.$$.fragment),rs=o(),L=T("p"),L.textContent=gs,Ms=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(N.$$.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),M=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),A=i(s),V=f(s,"P",{"data-svelte-h":!0}),g(V)!=="svelte-vnn33k"&&(V.textContent=r),w=i(s),d($.$$.fragment,s),H=i(s),B=f(s,"P",{"data-svelte-h":!0}),g(B)!=="svelte-x1ncwr"&&(B.textContent=x),Q=i(s),d(R.$$.fragment,s),q=i(s),z=f(s,"P",{"data-svelte-h":!0}),g(z)!=="svelte-1ri0vdd"&&(z.innerHTML=Y),v=i(s),d(e.$$.fragment,s),j=i(s),F=f(s,"P",{"data-svelte-h":!0}),g(F)!=="svelte-1iq2bgx"&&(F.textContent=bs),ps=i(s),d(D.$$.fragment,s),rs=i(s),L=f(s,"P",{"data-svelte-h":!0}),g(L)!=="svelte-1jkglaf"&&(L.textContent=gs),Ms=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(N.$$.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(){Vs(a,"name","hf:doc:metadata"),Vs(a,"content",Os)},m(s,p){xs(document.head,a),n(s,c,p),n(s,l,p),n(s,M,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,A,p),n(s,V,p),n(s,w,p),h($,s,p),n(s,H,p),n(s,B,p),n(s,Q,p),h(R,s,p),n(s,q,p),n(s,z,p),n(s,v,p),h(e,s,p),n(s,j,p),n(s,F,p),n(s,ps,p),h(D,s,p),n(s,rs,p),n(s,L,p),n(s,Ms,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(N,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}),N.$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(R.$$.fragment,s),u(e.$$.fragment,s),u(D.$$.fragment,s),u(K.$$.fragment,s),u(ss.$$.fragment,s),u(N.$$.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(R.$$.fragment,s),U(e.$$.fragment,s),U(D.$$.fragment,s),U(K.$$.fragment,s),U(ss.$$.fragment,s),U(N.$$.fragment,s),U(es.$$.fragment,s),U(S.$$.fragment,s),U(ts.$$.fragment,s),Js=!1},d(s){s&&(t(c),t(l),t(M),t(b),t(_),t(E),t(k),t(W),t(A),t(V),t(w),t(H),t(B),t(Q),t(q),t(z),t(v),t(j),t(F),t(ps),t(rs),t(L),t(Ms),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(R,s),J(e,s),J(D,s),J(K,s),J(ss,s),J(N,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 rl extends Bs{constructor(a){super(),zs(this,a,sl,Ks,Xs,{})}}export{rl as component};
