import{s as yl,o as hl,n as Qs}from"../chunks/scheduler.36a0863c.js";import{S as dl,i as ul,g as m,s as M,u,A as Ul,h as j,f as e,c as i,j as X,v as U,y as b,k as _,o as k,a as n,w,d as J,t as f,x as T}from"../chunks/index.d0f7a4c4.js";import{T as jl}from"../chunks/Tip.4c7d7eb1.js";import{I as Fs}from"../chunks/IconCopyLink.bc5fad79.js";import{C as v}from"../chunks/CodeBlock.4236768d.js";import{F as ml,M as Ss}from"../chunks/Markdown.2bf44d4a.js";function wl(I){let a,o;return a=new v({props:{code:"ZnJvbSUyMGRhdGFjbGFzc2VzJTIwaW1wb3J0JTIwZGF0YWNsYXNzJTBBZnJvbSUyMHRyYW5zZm9ybWVycy50b2tlbml6YXRpb25fdXRpbHNfYmFzZSUyMGltcG9ydCUyMFByZVRyYWluZWRUb2tlbml6ZXJCYXNlJTJDJTIwUGFkZGluZ1N0cmF0ZWd5JTBBZnJvbSUyMHR5cGluZyUyMGltcG9ydCUyME9wdGlvbmFsJTJDJTIwVW5pb24lMEFpbXBvcnQlMjB0b3JjaCUwQSUwQSUwQSU0MGRhdGFjbGFzcyUwQWNsYXNzJTIwRGF0YUNvbGxhdG9yRm9yTXVsdGlwbGVDaG9pY2UlM0ElMEElMjAlMjAlMjAlMjAlMjIlMjIlMjIlMEElMjAlMjAlMjAlMjBDb2xsYXRvciUyMGRlJTIwZGF0b3MlMjBxdWUlMjBsZSUyMGElQzMlQjFhZGlyJUMzJUExJTIwcmVsbGVubyUyMGRlJTIwZm9ybWElMjBhdXRvbSVDMyVBMXRpY2ElMjBhJTIwbGFzJTIwZW50cmFkYXMlMjByZWNpYmlkYXMlMjBwYXJhJTBBJTIwJTIwJTIwJTIwdW5hJTIwdGFyZWElMjBkZSUyMHNlbGVjY2klQzMlQjNuJTIwbSVDMyVCQWx0aXBsZS4lMEElMjAlMjAlMjAlMjAlMjIlMjIlMjIlMEElMEElMjAlMjAlMjAlMjB0b2tlbml6ZXIlM0ElMjBQcmVUcmFpbmVkV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IwYmF0Y2guaXRlbXMoKSU3RCUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMGJhdGNoJTVCJTIybGFiZWxzJTIyJTVEJTIwJTNEJTIwdG9yY2gudGVuc29yKGxhYmVscyUyQyUyMGR0eXBlJTNEdG9yY2guaW50NjQpJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwcmV0dXJuJTIwYmF0Y2g=",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(){u(a.$$.fragment)},l(l){U(a.$$.fragment,l)},m(l,c){w(a,l,c),o=!0},p:Qs,i(l){o||(J(a.$$.fragment,l),o=!0)},o(l){f(a.$$.fragment,l),o=!1},d(l){T(a,l)}}}function Jl(I){let a,o;return a=new Ss({props:{$$slots:{default:[wl]},$$scope:{ctx:I}}}),{c(){u(a.$$.fragment)},l(l){U(a.$$.fragment,l)},m(l,c){w(a,l,c),o=!0},p(l,c){const y={};c&2&&(y.$$scope={dirty:c,ctx:l}),a.$set(y)},i(l){o||(J(a.$$.fragment,l),o=!0)},o(l){f(a.$$.fragment,l),o=!1},d(l){T(a,l)}}}function fl(I){let a,o;return a=new v({props:{code:"ZnJvbSUyMGRhdGFjbGFzc2VzJTIwaW1wb3J0JTIwZGF0YWNsYXNzJTBBZnJvbSUyMHRyYW5zZm9ybWVycy50b2tlbml6YXRpb25fdXRpbHNfYmFzZSUyMGltcG9ydCUyMFByZVRyYWluZWRUb2tlbml6ZXJCYXNlJTJDJTIwUGFkZGluZ1N0cmF0ZWd5JTBBZnJvbSUyMHR5cGluZyUyMGltcG9ydCUyME9wdGlvbmFsJTJDJTIwVW5pb24lMEFpbXBvcnQlMjB0ZW5zb3JmbG93JTIwYXMlMjB0ZiUwQSUwQSUwQSU0MGRhdGFjbGFzcyUwQWNsYXNzJTIwRGF0YUNvbGxhdG9yRm9yTXVsdGlwbGVDaG9pY2UlM0ElMEElMjAlMjAlMjAlMjAlMjIlMjIlMjIlMEElMjAlMjAlMjAlMjBEYXRhJTIwY29sbGF0b3IlMjB0aGF0JTIwd2lsbCUyMGR5bmFtaWNhbGx5JTIwcGFkJTIwdGhlJTIwaW5wdXRzJTIwZm9yJTIwbXVsdGlwbGUlMjBjaG9pY2UlMjByZWNlaXZlZC4lMEElMjAlMjAlMjAlMjAlMjIlMjIlMjIlMEElMEElMjAlMjAlMj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nVtX2Nob2ljZXMlMkMlMjAtMSkpJTIwZm9yJTIwayUyQyUyMHYlMjBpbiUyMGJhdGNoLml0ZW1zKCklN0QlMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjBiYXRjaCU1QiUyMmxhYmVscyUyMiU1RCUyMCUzRCUyMHRmLmNvbnZlcnRfdG9fdGVuc29yKGxhYmVscyUyQyUyMGR0eXBlJTNEdGYuaW50NjQpJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwcmV0dXJuJTIwYmF0Y2g=",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(){u(a.$$.fragment)},l(l){U(a.$$.fragment,l)},m(l,c){w(a,l,c),o=!0},p:Qs,i(l){o||(J(a.$$.fragment,l),o=!0)},o(l){f(a.$$.fragment,l),o=!1},d(l){T(a,l)}}}function Tl(I){let a,o;return a=new Ss({props:{$$slots:{default:[fl]},$$scope:{ctx:I}}}),{c(){u(a.$$.fragment)},l(l){U(a.$$.fragment,l)},m(l,c){w(a,l,c),o=!0},p(l,c){const y={};c&2&&(y.$$scope={dirty:c,ctx:l}),a.$set(y)},i(l){o||(J(a.$$.fragment,l),o=!0)},o(l){f(a.$$.fragment,l),o=!1},d(l){T(a,l)}}}function bl(I){let a,o='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=m("p"),a.innerHTML=o},l(l){a=j(l,"P",{"data-svelte-h":!0}),b(a)!=="svelte-1sco78m"&&(a.innerHTML=o)},m(l,c){n(l,a,c)},p:Qs,d(l){l&&e(a)}}}function gl(I){let a,o="Carga el modelo BERT con <code>AutoModelForMultipleChoice</code>:",l,c,y,d,A,g,H="En este punto, solo quedan tres pasos:",$,G,x="<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,W,R;return c=new v({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMEF1dG9Nb2RlbEZvck11bHRpcGxlQ2hvaWNlJTJDJTIwVHJhaW5pbmdBcmd1bWVudHMlMkMlMjBUcmFpbmVyJTBBJTBBbW9kZWwlMjAlM0QlMjBBdXRvTW9kZWxGb3JNdWx0aXBsZUNob2ljZS5mcm9tX3ByZXRyYWluZWQoJTIyYmVydC1iYXNlLXVuY2FzZWQlMjIp",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;bert-base-uncased&quot;</span>)`,wrap:!1}}),d=new jl({props:{$$slots:{default:[bl]},$$scope:{ctx:I}}}),W=new v({props:{code:"dHJhaW5pbmdfYXJncyUyMCUzRCUyMFRyYWluaW5nQXJndW1lbnRzKCUwQSUyMCUyMCUyMCUyMG91dHB1dF9kaXIlM0QlMjIuJTJGcmVzdWx0cyUyMiUyQyUwQSUyMCUyMCUyMCUyMGV2YWx1YXRpb25fc3RyYXRlZ3klM0QlMjJlcG9jaCUyMiUyQyUwQSUyMCUyMCUyMCUyMGxlYXJuaW5nX3JhdGUlM0Q1ZS01JTJDJTBBJTIwJTIwJTIwJTIwcGVyX2RldmljZV90cmFpbl9iYXRjaF9zaXplJTNEMTYlMkMlMEElMjAlMjAlMjAlMjBwZXJfZGV2aWNlX2V2YWxfYmF0Y2hfc2l6ZSUzRDE2JTJDJTBBJTIwJTIwJTIwJTIwbnVtX3RyYWluX2Vwb2NocyUzRDMlMkMlMEElMjAlMjAlMjAlMjB3ZWlnaHRfZGVjYXklM0QwLjAxJTJDJTBBKSUwQSUwQXRyYWluZXIlMjAlM0QlMjBUcmFpbmVyKCUwQSUyMCUyMCUyMCUyMG1vZGVsJTNEbW9kZWwlMkMlMEElMjAlMjAlMjAlMjBhcmdzJTNEdHJhaW5pbmdfYXJncyUyQyUwQSUyMCUyMCUyMCUyMHRyYWluX2RhdGFzZXQlM0R0b2tlbml6ZWRfc3dhZyU1QiUyMnRyYWluJTIyJTVEJTJDJTBBJTIwJTIwJTIwJTIwZXZhbF9kYXRhc2V0JTNEdG9rZW5pemVkX3N3YWclNUIlMjJ2YWxpZGF0aW9uJTIyJTVEJTJDJTBBJTIwJTIwJTIwJTIwdG9rZW5pemVyJTNEdG9rZW5pemVyJTJDJTBBJTIwJTIwJTIwJTIwZGF0YV9jb2xsYXRvciUzRERhdGFDb2xsYXRvckZvck11bHRpcGxlQ2hvaWNlKHRva2VuaXplciUzRHRva2VuaXplciklMkMlMEEpJTBBJTBBdHJhaW5lci50cmFpbigp",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>    evaluation_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=m("p"),a.innerHTML=o,l=M(),u(c.$$.fragment),y=M(),u(d.$$.fragment),A=M(),g=m("p"),g.textContent=H,$=M(),G=m("ol"),G.innerHTML=x,Z=M(),u(W.$$.fragment)},l(r){a=j(r,"P",{"data-svelte-h":!0}),b(a)!=="svelte-6bdz67"&&(a.innerHTML=o),l=i(r),U(c.$$.fragment,r),y=i(r),U(d.$$.fragment,r),A=i(r),g=j(r,"P",{"data-svelte-h":!0}),b(g)!=="svelte-bd5x35"&&(g.textContent=H),$=i(r),G=j(r,"OL",{"data-svelte-h":!0}),b(G)!=="svelte-k4ouyy"&&(G.innerHTML=x),Z=i(r),U(W.$$.fragment,r)},m(r,C){n(r,a,C),n(r,l,C),w(c,r,C),n(r,y,C),w(d,r,C),n(r,A,C),n(r,g,C),n(r,$,C),n(r,G,C),n(r,Z,C),w(W,r,C),R=!0},p(r,C){const V={};C&2&&(V.$$scope={dirty:C,ctx:r}),d.$set(V)},i(r){R||(J(c.$$.fragment,r),J(d.$$.fragment,r),J(W.$$.fragment,r),R=!0)},o(r){f(c.$$.fragment,r),f(d.$$.fragment,r),f(W.$$.fragment,r),R=!1},d(r){r&&(e(a),e(l),e(y),e(A),e(g),e($),e(G),e(Z)),T(c,r),T(d,r),T(W,r)}}}function Cl(I){let a,o;return a=new Ss({props:{$$slots:{default:[gl]},$$scope:{ctx:I}}}),{c(){u(a.$$.fragment)},l(l){U(a.$$.fragment,l)},m(l,c){w(a,l,c),o=!0},p(l,c){const y={};c&2&&(y.$$scope={dirty:c,ctx:l}),a.$set(y)},i(l){o||(J(a.$$.fragment,l),o=!0)},o(l){f(a.$$.fragment,l),o=!1},d(l){T(a,l)}}}function Il(I){let a,o='Para familiarizarte con el fine-tuning con Keras, ¡mira el tutorial básico <a href="training#finetune-with-keras">aquí</a>!';return{c(){a=m("p"),a.innerHTML=o},l(l){a=j(l,"P",{"data-svelte-h":!0}),b(a)!=="svelte-66s4ry"&&(a.innerHTML=o)},m(l,c){n(l,a,c)},p:Qs,d(l){l&&e(a)}}}function Zl(I){let a,o="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,c,y,d,A,g,H="Prepara una función de optimización, un programa para la tasa de aprendizaje y algunos hiperparámetros de entrenamiento:",$,G,x,Z,W="Carga el modelo BERT con <code>TFAutoModelForMultipleChoice</code>:",R,r,C,V,z='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,E,Y,Q,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:',ls,N,F;return c=new v({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}}),d=new jl({props:{$$slots:{default:[Il]},$$scope:{ctx:I}}}),G=new v({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 v({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMFRGQXV0b01vZGVsRm9yTXVsdGlwbGVDaG9pY2UlMEElMEFtb2RlbCUyMCUzRCUyMFRGQXV0b01vZGVsRm9yTXVsdGlwbGVDaG9pY2UuZnJvbV9wcmV0cmFpbmVkKCUyMmJlcnQtYmFzZS11bmNhc2VkJTIyKQ==",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;bert-base-uncased&quot;</span>)`,wrap:!1}}),E=new v({props:{code:"bW9kZWwuY29tcGlsZShvcHRpbWl6ZXIlM0RvcHRpbWl6ZXIp",highlighted:'<span class="hljs-meta">&gt;&gt;&gt; </span>model.<span class="hljs-built_in">compile</span>(optimizer=optimizer)',wrap:!1}}),N=new v({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=m("p"),a.innerHTML=o,l=M(),u(c.$$.fragment),y=M(),u(d.$$.fragment),A=M(),g=m("p"),g.textContent=H,$=M(),u(G.$$.fragment),x=M(),Z=m("p"),Z.innerHTML=W,R=M(),u(r.$$.fragment),C=M(),V=m("p"),V.innerHTML=z,B=M(),u(E.$$.fragment),Y=M(),Q=m("p"),Q.innerHTML=q,ls=M(),u(N.$$.fragment)},l(t){a=j(t,"P",{"data-svelte-h":!0}),b(a)!=="svelte-1dn6k4v"&&(a.innerHTML=o),l=i(t),U(c.$$.fragment,t),y=i(t),U(d.$$.fragment,t),A=i(t),g=j(t,"P",{"data-svelte-h":!0}),b(g)!=="svelte-81yq28"&&(g.textContent=H),$=i(t),U(G.$$.fragment,t),x=i(t),Z=j(t,"P",{"data-svelte-h":!0}),b(Z)!=="svelte-1v9x5sp"&&(Z.innerHTML=W),R=i(t),U(r.$$.fragment,t),C=i(t),V=j(t,"P",{"data-svelte-h":!0}),b(V)!=="svelte-jy7mgr"&&(V.innerHTML=z),B=i(t),U(E.$$.fragment,t),Y=i(t),Q=j(t,"P",{"data-svelte-h":!0}),b(Q)!=="svelte-1dz4xz1"&&(Q.innerHTML=q),ls=i(t),U(N.$$.fragment,t)},m(t,h){n(t,a,h),n(t,l,h),w(c,t,h),n(t,y,h),w(d,t,h),n(t,A,h),n(t,g,h),n(t,$,h),w(G,t,h),n(t,x,h),n(t,Z,h),n(t,R,h),w(r,t,h),n(t,C,h),n(t,V,h),n(t,B,h),w(E,t,h),n(t,Y,h),n(t,Q,h),n(t,ls,h),w(N,t,h),F=!0},p(t,h){const S={};h&2&&(S.$$scope={dirty:h,ctx:t}),d.$set(S)},i(t){F||(J(c.$$.fragment,t),J(d.$$.fragment,t),J(G.$$.fragment,t),J(r.$$.fragment,t),J(E.$$.fragment,t),J(N.$$.fragment,t),F=!0)},o(t){f(c.$$.fragment,t),f(d.$$.fragment,t),f(G.$$.fragment,t),f(r.$$.fragment,t),f(E.$$.fragment,t),f(N.$$.fragment,t),F=!1},d(t){t&&(e(a),e(l),e(y),e(A),e(g),e($),e(x),e(Z),e(R),e(C),e(V),e(B),e(Y),e(Q),e(ls)),T(c,t),T(d,t),T(G,t),T(r,t),T(E,t),T(N,t)}}}function Gl(I){let a,o;return a=new Ss({props:{$$slots:{default:[Zl]},$$scope:{ctx:I}}}),{c(){u(a.$$.fragment)},l(l){U(a.$$.fragment,l)},m(l,c){w(a,l,c),o=!0},p(l,c){const y={};c&2&&(y.$$scope={dirty:c,ctx:l}),a.$set(y)},i(l){o||(J(a.$$.fragment,l),o=!0)},o(l){f(a.$$.fragment,l),o=!1},d(l){T(a,l)}}}function _l(I){let a,o,l,c,y,d,A,g,H,$,G="Selección múltiple",x,Z,W=`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.`,R,r,C=`Esta guía te mostrará como hacerle fine-tuning a <a href="https://huggingface.co/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.`,V,z,B,E,Y,Q,q,ls="Cargar el dataset SWAG",N,F,t="Carga el dataset SWAG con la biblioteca 🤗 Datasets:",h,S,bs,as,Ds="Ahora, échale un vistazo a un ejemplo del dataset:",gs,es,Cs,ts,Ps="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>.",Is,D,L,ws,ns,Hs,us,Ls="Preprocesmaiento",Zs,ps,Ks="Carga el tokenizer de BERT para procesar el comienzo de cada oración y los cuatro finales posibles:",Gs,rs,_s,cs,Os="La función de preprocesmaiento debe hacer lo siguiente:",ks,os,sl="<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>",$s,Ms,As,is,ll="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.",Vs,ms,Rs,js,al=`🤗 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.`,Xs,ys,el="El <code>DataCollatorForMultipleChoice</code> aplanará todas las entradas del modelo, les aplicará relleno y luego des-aplanará los resultados:",vs,K,Ws,P,O,Js,hs,qs,Us,tl="Entrenamiento",Bs,ss,Es,fs,xs;return g=new Fs({}),Y=new Fs({}),S=new v({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}}),es=new v({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}}),ns=new Fs({}),rs=new v({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMEF1dG9Ub2tlbml6ZXIlMEElMEF0b2tlbml6ZXIlMjAlM0QlMjBBdXRvVG9rZW5pemVyLmZyb21fcHJldHJhaW5lZCglMjJiZXJ0LWJhc2UtdW5jYXNlZCUyMik=",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;bert-base-uncased&quot;</span>)`,wrap:!1}}),Ms=new v({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}}),ms=new v({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}}),K=new ml({props:{pytorch:!0,tensorflow:!0,jax:!1,$$slots:{tensorflow:[Tl],pytorch:[Jl]},$$scope:{ctx:I}}}),hs=new Fs({}),ss=new ml({props:{pytorch:!0,tensorflow:!0,jax:!1,$$slots:{tensorflow:[Gl],pytorch:[Cl]},$$scope:{ctx:I}}}),{c(){a=m("meta"),o=M(),l=m("p"),c=M(),y=m("h1"),d=m("a"),A=m("span"),u(g.$$.fragment),H=M(),$=m("span"),$.textContent=G,x=M(),Z=m("p"),Z.textContent=W,R=M(),r=m("p"),r.innerHTML=C,V=M(),z=m("h2"),B=m("a"),E=m("span"),u(Y.$$.fragment),Q=M(),q=m("span"),q.textContent=ls,N=M(),F=m("p"),F.textContent=t,h=M(),u(S.$$.fragment),bs=M(),as=m("p"),as.textContent=Ds,gs=M(),u(es.$$.fragment),Cs=M(),ts=m("p"),ts.innerHTML=Ps,Is=M(),D=m("h2"),L=m("a"),ws=m("span"),u(ns.$$.fragment),Hs=M(),us=m("span"),us.textContent=Ls,Zs=M(),ps=m("p"),ps.textContent=Ks,Gs=M(),u(rs.$$.fragment),_s=M(),cs=m("p"),cs.textContent=Os,ks=M(),os=m("ol"),os.innerHTML=sl,$s=M(),u(Ms.$$.fragment),As=M(),is=m("p"),is.innerHTML=ll,Vs=M(),u(ms.$$.fragment),Rs=M(),js=m("p"),js.innerHTML=al,Xs=M(),ys=m("p"),ys.innerHTML=el,vs=M(),u(K.$$.fragment),Ws=M(),P=m("h2"),O=m("a"),Js=m("span"),u(hs.$$.fragment),qs=M(),Us=m("span"),Us.textContent=tl,Bs=M(),u(ss.$$.fragment),Es=M(),fs=m("p"),this.h()},l(s){const p=Ul("svelte-1phssyn",document.head);a=j(p,"META",{name:!0,content:!0}),p.forEach(e),o=i(s),l=j(s,"P",{}),X(l).forEach(e),c=i(s),y=j(s,"H1",{class:!0});var ds=X(y);d=j(ds,"A",{id:!0,class:!0,href:!0});var Ts=X(d);A=j(Ts,"SPAN",{});var nl=X(A);U(g.$$.fragment,nl),nl.forEach(e),Ts.forEach(e),H=i(ds),$=j(ds,"SPAN",{"data-svelte-h":!0}),b($)!=="svelte-1q8offf"&&($.textContent=G),ds.forEach(e),x=i(s),Z=j(s,"P",{"data-svelte-h":!0}),b(Z)!=="svelte-50nup6"&&(Z.textContent=W),R=i(s),r=j(s,"P",{"data-svelte-h":!0}),b(r)!=="svelte-1j0el6v"&&(r.innerHTML=C),V=i(s),z=j(s,"H2",{class:!0});var zs=X(z);B=j(zs,"A",{id:!0,class:!0,href:!0});var pl=X(B);E=j(pl,"SPAN",{});var rl=X(E);U(Y.$$.fragment,rl),rl.forEach(e),pl.forEach(e),Q=i(zs),q=j(zs,"SPAN",{"data-svelte-h":!0}),b(q)!=="svelte-taf57e"&&(q.textContent=ls),zs.forEach(e),N=i(s),F=j(s,"P",{"data-svelte-h":!0}),b(F)!=="svelte-vnn33k"&&(F.textContent=t),h=i(s),U(S.$$.fragment,s),bs=i(s),as=j(s,"P",{"data-svelte-h":!0}),b(as)!=="svelte-x1ncwr"&&(as.textContent=Ds),gs=i(s),U(es.$$.fragment,s),Cs=i(s),ts=j(s,"P",{"data-svelte-h":!0}),b(ts)!=="svelte-1ri0vdd"&&(ts.innerHTML=Ps),Is=i(s),D=j(s,"H2",{class:!0});var Ys=X(D);L=j(Ys,"A",{id:!0,class:!0,href:!0});var cl=X(L);ws=j(cl,"SPAN",{});var ol=X(ws);U(ns.$$.fragment,ol),ol.forEach(e),cl.forEach(e),Hs=i(Ys),us=j(Ys,"SPAN",{"data-svelte-h":!0}),b(us)!=="svelte-whh6ux"&&(us.textContent=Ls),Ys.forEach(e),Zs=i(s),ps=j(s,"P",{"data-svelte-h":!0}),b(ps)!=="svelte-1iq2bgx"&&(ps.textContent=Ks),Gs=i(s),U(rs.$$.fragment,s),_s=i(s),cs=j(s,"P",{"data-svelte-h":!0}),b(cs)!=="svelte-1jkglaf"&&(cs.textContent=Os),ks=i(s),os=j(s,"OL",{"data-svelte-h":!0}),b(os)!=="svelte-12xaauq"&&(os.innerHTML=sl),$s=i(s),U(Ms.$$.fragment,s),As=i(s),is=j(s,"P",{"data-svelte-h":!0}),b(is)!=="svelte-f9xmqh"&&(is.innerHTML=ll),Vs=i(s),U(ms.$$.fragment,s),Rs=i(s),js=j(s,"P",{"data-svelte-h":!0}),b(js)!=="svelte-1vi4idm"&&(js.innerHTML=al),Xs=i(s),ys=j(s,"P",{"data-svelte-h":!0}),b(ys)!=="svelte-1010f04"&&(ys.innerHTML=el),vs=i(s),U(K.$$.fragment,s),Ws=i(s),P=j(s,"H2",{class:!0});var Ns=X(P);O=j(Ns,"A",{id:!0,class:!0,href:!0});var Ml=X(O);Js=j(Ml,"SPAN",{});var il=X(Js);U(hs.$$.fragment,il),il.forEach(e),Ml.forEach(e),qs=i(Ns),Us=j(Ns,"SPAN",{"data-svelte-h":!0}),b(Us)!=="svelte-1b8djky"&&(Us.textContent=tl),Ns.forEach(e),Bs=i(s),U(ss.$$.fragment,s),Es=i(s),fs=j(s,"P",{}),X(fs).forEach(e),this.h()},h(){_(a,"name","hf:doc:metadata"),_(a,"content",JSON.stringify(kl)),_(d,"id","seleccin-mltiple"),_(d,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),_(d,"href","#seleccin-mltiple"),_(y,"class","relative group"),_(B,"id","cargar-el-dataset-swag"),_(B,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),_(B,"href","#cargar-el-dataset-swag"),_(z,"class","relative group"),_(L,"id","preprocesmaiento"),_(L,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),_(L,"href","#preprocesmaiento"),_(D,"class","relative group"),_(O,"id","entrenamiento"),_(O,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),_(O,"href","#entrenamiento"),_(P,"class","relative group")},m(s,p){k(document.head,a),n(s,o,p),n(s,l,p),n(s,c,p),n(s,y,p),k(y,d),k(d,A),w(g,A,null),k(y,H),k(y,$),n(s,x,p),n(s,Z,p),n(s,R,p),n(s,r,p),n(s,V,p),n(s,z,p),k(z,B),k(B,E),w(Y,E,null),k(z,Q),k(z,q),n(s,N,p),n(s,F,p),n(s,h,p),w(S,s,p),n(s,bs,p),n(s,as,p),n(s,gs,p),w(es,s,p),n(s,Cs,p),n(s,ts,p),n(s,Is,p),n(s,D,p),k(D,L),k(L,ws),w(ns,ws,null),k(D,Hs),k(D,us),n(s,Zs,p),n(s,ps,p),n(s,Gs,p),w(rs,s,p),n(s,_s,p),n(s,cs,p),n(s,ks,p),n(s,os,p),n(s,$s,p),w(Ms,s,p),n(s,As,p),n(s,is,p),n(s,Vs,p),w(ms,s,p),n(s,Rs,p),n(s,js,p),n(s,Xs,p),n(s,ys,p),n(s,vs,p),w(K,s,p),n(s,Ws,p),n(s,P,p),k(P,O),k(O,Js),w(hs,Js,null),k(P,qs),k(P,Us),n(s,Bs,p),w(ss,s,p),n(s,Es,p),n(s,fs,p),xs=!0},p(s,[p]){const ds={};p&2&&(ds.$$scope={dirty:p,ctx:s}),K.$set(ds);const Ts={};p&2&&(Ts.$$scope={dirty:p,ctx:s}),ss.$set(Ts)},i(s){xs||(J(g.$$.fragment,s),J(Y.$$.fragment,s),J(S.$$.fragment,s),J(es.$$.fragment,s),J(ns.$$.fragment,s),J(rs.$$.fragment,s),J(Ms.$$.fragment,s),J(ms.$$.fragment,s),J(K.$$.fragment,s),J(hs.$$.fragment,s),J(ss.$$.fragment,s),xs=!0)},o(s){f(g.$$.fragment,s),f(Y.$$.fragment,s),f(S.$$.fragment,s),f(es.$$.fragment,s),f(ns.$$.fragment,s),f(rs.$$.fragment,s),f(Ms.$$.fragment,s),f(ms.$$.fragment,s),f(K.$$.fragment,s),f(hs.$$.fragment,s),f(ss.$$.fragment,s),xs=!1},d(s){s&&(e(o),e(l),e(c),e(y),e(x),e(Z),e(R),e(r),e(V),e(z),e(N),e(F),e(h),e(bs),e(as),e(gs),e(Cs),e(ts),e(Is),e(D),e(Zs),e(ps),e(Gs),e(_s),e(cs),e(ks),e(os),e($s),e(As),e(is),e(Vs),e(Rs),e(js),e(Xs),e(ys),e(vs),e(Ws),e(P),e(Bs),e(Es),e(fs)),e(a),T(g),T(Y),T(S,s),T(es,s),T(ns),T(rs,s),T(Ms,s),T(ms,s),T(K,s),T(hs),T(ss,s)}}}const kl={local:"seleccin-mltiple",sections:[{local:"cargar-el-dataset-swag",title:"Cargar el dataset SWAG"},{local:"preprocesmaiento",title:"Preprocesmaiento"},{local:"entrenamiento",title:"Entrenamiento"}],title:"Selección múltiple"};function $l(I){return hl(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class Bl extends dl{constructor(a){super(),ul(this,a,$l,_l,yl,{})}}export{Bl as component};
