import{S as me,i as de,s as je,e as o,k as y,w as _,t as n,M as he,c,d as l,m as u,a as i,x as I,h as p,b,G as a,g as M,y as Z,q as E,o as G,B as A,v as ye,L as ie}from"../../chunks/vendor-hf-doc-builder.js";import{T as Me}from"../../chunks/Tip-hf-doc-builder.js";import{I as Ra}from"../../chunks/IconCopyLink-hf-doc-builder.js";import{C as es}from"../../chunks/CodeBlock-hf-doc-builder.js";import{F as ce,M as Xa}from"../../chunks/Markdown-hf-doc-builder.js";import"../../chunks/IconTensorflow-hf-doc-builder.js";function ue(W){let t,j;return t=new es({props:{code:"ZnJvbSUyMGRhdGFjbGFzc2VzJTIwaW1wb3J0JTIwZGF0YWNsYXNzJTBBZnJvbSUyMHRyYW5zZm9ybWVycy50b2tlbml6YXRpb25fdXRpbHNfYmFzZSUyMGltcG9ydCUyMFByZVRyYWluZWRUb2tlbml6ZXJCYXNlJTJDJTIwUGFkZGluZ1N0cmF0ZWd5JTBBZnJvbSUyMHR5cGluZyUyMGltcG9ydCUyME9wdGlvbmFsJTJDJTIwVW5pb24lMEFpbXBvcnQlMjB0b3JjaCUwQSUwQSUwQSU0MGRhdGFjbGFzcyUwQWNsYXNzJTIwRGF0YUNvbGxhdG9yRm9yTXVsdGlwbGVDaG9pY2UlM0ElMEElMjAlMjAlMjAlMjAlMjIlMjIlMjIlMEElMjAlMjAlMjAlMjBDb2xsYXRvciUyMGRlJTIwZGF0b3MlMjBxdWUlMjBsZSUyMGElQzMlQjFhZGlyJUMzJUExJTIwcmVsbGVubyUyMGRlJTIwZm9ybWElMjBhdXRvbSVDMyVBMXRpY2ElMjBhJTIwbGFzJTIwZW50cmFkYXMlMjByZWNpYmlkYXMlMjBwYXJhJTBBJTIwJTIwJTIwJTIwdW5hJTIwdGFyZWElMjBkZSUyMHNlbGVjY2klQzMlQjNuJTIwbSVDMyVCQWx0aXBsZS4lMEElMjAlMjAlMjAlMjAlMjIlMjIlMjIlMEElMEElMjAlMjAlMjAlMjB0b2tlbml6ZXIlM0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rJTJDJTIwdiUyMGluJTIwYmF0Y2guaXRlbXMoKSU3RCUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMGJhdGNoJTVCJTIybGFiZWxzJTIyJTVEJTIwJTNEJTIwdG9yY2gudGVuc29yKGxhYmVscyUyQyUyMGR0eXBlJTNEdG9yY2guaW50NjQpJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwcmV0dXJuJTIwYmF0Y2g=",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\xF1adir\xE1 relleno de forma autom\xE1tica a las entradas recibidas para
<span class="hljs-meta">... </span>    una tarea de selecci\xF3n m\xFAltiple.
<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`}}),{c(){_(t.$$.fragment)},l(e){I(t.$$.fragment,e)},m(e,h){Z(t,e,h),j=!0},p:ie,i(e){j||(E(t.$$.fragment,e),j=!0)},o(e){G(t.$$.fragment,e),j=!1},d(e){A(t,e)}}}function fe(W){let t,j;return t=new Xa({props:{$$slots:{default:[ue]},$$scope:{ctx:W}}}),{c(){_(t.$$.fragment)},l(e){I(t.$$.fragment,e)},m(e,h){Z(t,e,h),j=!0},p(e,h){const U={};h&2&&(U.$$scope={dirty:h,ctx:e}),t.$set(U)},i(e){j||(E(t.$$.fragment,e),j=!0)},o(e){G(t.$$.fragment,e),j=!1},d(e){A(t,e)}}}function Ue(W){let t,j;return t=new es({props:{code:"ZnJvbSUyMGRhdGFjbGFzc2VzJTIwaW1wb3J0JTIwZGF0YWNsYXNzJTBBZnJvbSUyMHRyYW5zZm9ybWVycy50b2tlbml6YXRpb25fdXRpbHNfYmFzZSUyMGltcG9ydCUyMFByZVRyYWluZWRUb2tlbml6ZXJCYXNlJTJDJTIwUGFkZGluZ1N0cmF0ZWd5JTBBZnJvbSUyMHR5cGluZyUyMGltcG9ydCUyME9wdGlvbmFsJTJDJTIwVW5pb24lMEFpbXBvcnQlMjB0ZW5zb3JmbG93JTIwYXMlMjB0ZiUwQSUwQSUwQSU0MGRhdGFjbGFzcyUwQWNsYXNzJTIwRGF0YUNvbGxhdG9yRm9yTXVsdGlwbGVDaG9pY2UlM0ElMEElMjAlMjAlMjAlMjAlMjIlMjIlMjIlMEElMjAlMjAlMjAlMjBEYXRhJTIwY29sbGF0b3IlMjB0aGF0JTIwd2lsbCUyMGR5bmFtaWNhbGx5JTIwcGFkJTIwdGhlJTIwaW5wdXRzJTIwZm9yJTIwbXVsdGlwbGUlMjBjaG9pY2UlMjByZWNlaXZlZC4lMEElMjAlMjAl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hhcGUodiUyQyUyMChiYXRjaF9zaXplJTJDJTIwbnVtX2Nob2ljZXMlMkMlMjAtMSkpJTIwZm9yJTIwayUyQyUyMHYlMjBpbiUyMGJhdGNoLml0ZW1zKCklN0QlMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjBiYXRjaCU1QiUyMmxhYmVscyUyMiU1RCUyMCUzRCUyMHRmLmNvbnZlcnRfdG9fdGVuc29yKGxhYmVscyUyQyUyMGR0eXBlJTNEdGYuaW50NjQpJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwcmV0dXJuJTIwYmF0Y2g=",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`}}),{c(){_(t.$$.fragment)},l(e){I(t.$$.fragment,e)},m(e,h){Z(t,e,h),j=!0},p:ie,i(e){j||(E(t.$$.fragment,e),j=!0)},o(e){G(t.$$.fragment,e),j=!1},d(e){A(t,e)}}}function we(W){let t,j;return t=new Xa({props:{$$slots:{default:[Ue]},$$scope:{ctx:W}}}),{c(){_(t.$$.fragment)},l(e){I(t.$$.fragment,e)},m(e,h){Z(t,e,h),j=!0},p(e,h){const U={};h&2&&(U.$$scope={dirty:h,ctx:e}),t.$set(U)},i(e){j||(E(t.$$.fragment,e),j=!0)},o(e){G(t.$$.fragment,e),j=!1},d(e){A(t,e)}}}function Je(W){let t,j,e,h,U,J,C,v;return{c(){t=o("p"),j=n("Para familiarizarte con el fine-tuning con "),e=o("code"),h=n("Trainer"),U=n(", \xA1mira el tutorial b\xE1sico "),J=o("a"),C=n("aqu\xED"),v=n("!"),this.h()},l(V){t=c(V,"P",{});var g=i(t);j=p(g,"Para familiarizarte con el fine-tuning con "),e=c(g,"CODE",{});var R=i(e);h=p(R,"Trainer"),R.forEach(l),U=p(g,", \xA1mira el tutorial b\xE1sico "),J=c(g,"A",{href:!0});var z=i(J);C=p(z,"aqu\xED"),z.forEach(l),v=p(g,"!"),g.forEach(l),this.h()},h(){b(J,"href","../training#finetune-with-trainer")},m(V,g){M(V,t,g),a(t,j),a(t,e),a(e,h),a(t,U),a(t,J),a(J,C),a(t,v)},d(V){V&&l(t)}}}function Te(W){let t,j,e,h,U,J,C,v,V,g,R,z,as,T,K,H,Q,os,Y,ds,S,O,ts,cs,P,N,k,ns,X,ps,rs,is,x,B;return C=new es({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>)`}}),V=new Me({props:{$$slots:{default:[Je]},$$scope:{ctx:W}}}),x=new es({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()`}}),{c(){t=o("p"),j=n("Carga el modelo BERT con "),e=o("code"),h=n("AutoModelForMultipleChoice"),U=n(":"),J=y(),_(C.$$.fragment),v=y(),_(V.$$.fragment),g=y(),R=o("p"),z=n("En este punto, solo quedan tres pasos:"),as=y(),T=o("ol"),K=o("li"),H=n("Definir tus hiperpar\xE1metros de entrenamiento en "),Q=o("code"),os=n("TrainingArguments"),Y=n("."),ds=y(),S=o("li"),O=n("Pasarle los argumentos del entrenamiento al "),ts=o("code"),cs=n("Trainer"),P=n(" jnto con el modelo, el dataset, el tokenizer y el collator de datos."),N=y(),k=o("li"),ns=n("Invocar el m\xE9todo "),X=o("code"),ps=n("train()"),rs=n(" para realizar el fine-tuning del modelo."),is=y(),_(x.$$.fragment)},l(m){t=c(m,"P",{});var w=i(t);j=p(w,"Carga el modelo BERT con "),e=c(w,"CODE",{});var q=i(e);h=p(q,"AutoModelForMultipleChoice"),q.forEach(l),U=p(w,":"),w.forEach(l),J=u(m),I(C.$$.fragment,m),v=u(m),I(V.$$.fragment,m),g=u(m),R=c(m,"P",{});var L=i(R);z=p(L,"En este punto, solo quedan tres pasos:"),L.forEach(l),as=u(m),T=c(m,"OL",{});var F=i(T);K=c(F,"LI",{});var Ms=i(K);H=p(Ms,"Definir tus hiperpar\xE1metros de entrenamiento en "),Q=c(Ms,"CODE",{});var js=i(Q);os=p(js,"TrainingArguments"),js.forEach(l),Y=p(Ms,"."),Ms.forEach(l),ds=u(F),S=c(F,"LI",{});var D=i(S);O=p(D,"Pasarle los argumentos del entrenamiento al "),ts=c(D,"CODE",{});var ss=i(ts);cs=p(ss,"Trainer"),ss.forEach(l),P=p(D," jnto con el modelo, el dataset, el tokenizer y el collator de datos."),D.forEach(l),N=u(F),k=c(F,"LI",{});var $=i(k);ns=p($,"Invocar el m\xE9todo "),X=c($,"CODE",{});var r=i(X);ps=p(r,"train()"),r.forEach(l),rs=p($," para realizar el fine-tuning del modelo."),$.forEach(l),F.forEach(l),is=u(m),I(x.$$.fragment,m)},m(m,w){M(m,t,w),a(t,j),a(t,e),a(e,h),a(t,U),M(m,J,w),Z(C,m,w),M(m,v,w),Z(V,m,w),M(m,g,w),M(m,R,w),a(R,z),M(m,as,w),M(m,T,w),a(T,K),a(K,H),a(K,Q),a(Q,os),a(K,Y),a(T,ds),a(T,S),a(S,O),a(S,ts),a(ts,cs),a(S,P),a(T,N),a(T,k),a(k,ns),a(k,X),a(X,ps),a(k,rs),M(m,is,w),Z(x,m,w),B=!0},p(m,w){const q={};w&2&&(q.$$scope={dirty:w,ctx:m}),V.$set(q)},i(m){B||(E(C.$$.fragment,m),E(V.$$.fragment,m),E(x.$$.fragment,m),B=!0)},o(m){G(C.$$.fragment,m),G(V.$$.fragment,m),G(x.$$.fragment,m),B=!1},d(m){m&&l(t),m&&l(J),A(C,m),m&&l(v),A(V,m),m&&l(g),m&&l(R),m&&l(as),m&&l(T),m&&l(is),A(x,m)}}}function be(W){let t,j;return t=new Xa({props:{$$slots:{default:[Te]},$$scope:{ctx:W}}}),{c(){_(t.$$.fragment)},l(e){I(t.$$.fragment,e)},m(e,h){Z(t,e,h),j=!0},p(e,h){const U={};h&2&&(U.$$scope={dirty:h,ctx:e}),t.$set(U)},i(e){j||(E(t.$$.fragment,e),j=!0)},o(e){G(t.$$.fragment,e),j=!1},d(e){A(t,e)}}}function Ce(W){let t,j,e,h,U;return{c(){t=o("p"),j=n("Para familiarizarte con el fine-tuning con Keras, \xA1mira el tutorial b\xE1sico "),e=o("a"),h=n("aqu\xED"),U=n("!"),this.h()},l(J){t=c(J,"P",{});var C=i(t);j=p(C,"Para familiarizarte con el fine-tuning con Keras, \xA1mira el tutorial b\xE1sico "),e=c(C,"A",{href:!0});var v=i(e);h=p(v,"aqu\xED"),v.forEach(l),U=p(C,"!"),C.forEach(l),this.h()},h(){b(e,"href","training#finetune-with-keras")},m(J,C){M(J,t,C),a(t,j),a(t,e),a(e,h),a(t,U)},d(J){J&&l(t)}}}function ge(W){let t,j,e,h,U,J,C,v,V,g,R,z,as,T,K,H,Q,os,Y,ds,S,O,ts,cs,P,N,k,ns,X,ps,rs,is,x,B,m,w,q,L,F,Ms,js,D,ss,$;return g=new es({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>)`}}),z=new Me({props:{$$slots:{default:[Ce]},$$scope:{ctx:W}}}),Q=new es({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)`}}),P=new es({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>)`}}),B=new es({props:{code:"bW9kZWwuY29tcGlsZShvcHRpbWl6ZXIlM0RvcHRpbWl6ZXIp",highlighted:'<span class="hljs-meta">&gt;&gt;&gt; </span>model.<span class="hljs-built_in">compile</span>(optimizer=optimizer)'}}),ss=new es({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>)'}}),{c(){t=o("p"),j=n("Para realizar el fine-tuning de un modelo en TensorFlow, primero convierte tus datasets al formato "),e=o("code"),h=n("tf.data.Dataset"),U=n(" con el m\xE9todo "),J=o("code"),C=n("prepare_tf_dataset()"),v=n("."),V=y(),_(g.$$.fragment),R=y(),_(z.$$.fragment),as=y(),T=o("p"),K=n("Prepara una funci\xF3n de optimizaci\xF3n, un programa para la tasa de aprendizaje y algunos hiperpar\xE1metros de entrenamiento:"),H=y(),_(Q.$$.fragment),os=y(),Y=o("p"),ds=n("Carga el modelo BERT con "),S=o("code"),O=n("TFAutoModelForMultipleChoice"),ts=n(":"),cs=y(),_(P.$$.fragment),N=y(),k=o("p"),ns=n("Configura el modelo para entrenarlo con "),X=o("a"),ps=o("code"),rs=n("compile"),is=n(":"),x=y(),_(B.$$.fragment),m=y(),w=o("p"),q=n("Invoca el m\xE9todo "),L=o("a"),F=o("code"),Ms=n("fit"),js=n(" para realizar el fine-tuning del modelo:"),D=y(),_(ss.$$.fragment),this.h()},l(r){t=c(r,"P",{});var f=i(t);j=p(f,"Para realizar el fine-tuning de un modelo en TensorFlow, primero convierte tus datasets al formato "),e=c(f,"CODE",{});var Js=i(e);h=p(Js,"tf.data.Dataset"),Js.forEach(l),U=p(f," con el m\xE9todo "),J=c(f,"CODE",{});var Ys=i(J);C=p(Ys,"prepare_tf_dataset()"),Ys.forEach(l),v=p(f,"."),f.forEach(l),V=u(r),I(g.$$.fragment,r),R=u(r),I(z.$$.fragment,r),as=u(r),T=c(r,"P",{});var gs=i(T);K=p(gs,"Prepara una funci\xF3n de optimizaci\xF3n, un programa para la tasa de aprendizaje y algunos hiperpar\xE1metros de entrenamiento:"),gs.forEach(l),H=u(r),I(Q.$$.fragment,r),os=u(r),Y=c(r,"P",{});var _s=i(Y);ds=p(_s,"Carga el modelo BERT con "),S=c(_s,"CODE",{});var Ns=i(S);O=p(Ns,"TFAutoModelForMultipleChoice"),Ns.forEach(l),ts=p(_s,":"),_s.forEach(l),cs=u(r),I(P.$$.fragment,r),N=u(r),k=c(r,"P",{});var ys=i(k);ns=p(ys,"Configura el modelo para entrenarlo con "),X=c(ys,"A",{href:!0,rel:!0});var Qs=i(X);ps=c(Qs,"CODE",{});var Ss=i(ps);rs=p(Ss,"compile"),Ss.forEach(l),Qs.forEach(l),is=p(ys,":"),ys.forEach(l),x=u(r),I(B.$$.fragment,r),m=u(r),w=c(r,"P",{});var us=i(w);q=p(us,"Invoca el m\xE9todo "),L=c(us,"A",{href:!0,rel:!0});var xs=i(L);F=c(xs,"CODE",{});var qs=i(F);Ms=p(qs,"fit"),qs.forEach(l),xs.forEach(l),js=p(us," para realizar el fine-tuning del modelo:"),us.forEach(l),D=u(r),I(ss.$$.fragment,r),this.h()},h(){b(X,"href","https://keras.io/api/models/model_training_apis/#compile-method"),b(X,"rel","nofollow"),b(L,"href","https://keras.io/api/models/model_training_apis/#fit-method"),b(L,"rel","nofollow")},m(r,f){M(r,t,f),a(t,j),a(t,e),a(e,h),a(t,U),a(t,J),a(J,C),a(t,v),M(r,V,f),Z(g,r,f),M(r,R,f),Z(z,r,f),M(r,as,f),M(r,T,f),a(T,K),M(r,H,f),Z(Q,r,f),M(r,os,f),M(r,Y,f),a(Y,ds),a(Y,S),a(S,O),a(Y,ts),M(r,cs,f),Z(P,r,f),M(r,N,f),M(r,k,f),a(k,ns),a(k,X),a(X,ps),a(ps,rs),a(k,is),M(r,x,f),Z(B,r,f),M(r,m,f),M(r,w,f),a(w,q),a(w,L),a(L,F),a(F,Ms),a(w,js),M(r,D,f),Z(ss,r,f),$=!0},p(r,f){const Js={};f&2&&(Js.$$scope={dirty:f,ctx:r}),z.$set(Js)},i(r){$||(E(g.$$.fragment,r),E(z.$$.fragment,r),E(Q.$$.fragment,r),E(P.$$.fragment,r),E(B.$$.fragment,r),E(ss.$$.fragment,r),$=!0)},o(r){G(g.$$.fragment,r),G(z.$$.fragment,r),G(Q.$$.fragment,r),G(P.$$.fragment,r),G(B.$$.fragment,r),G(ss.$$.fragment,r),$=!1},d(r){r&&l(t),r&&l(V),A(g,r),r&&l(R),A(z,r),r&&l(as),r&&l(T),r&&l(H),A(Q,r),r&&l(os),r&&l(Y),r&&l(cs),A(P,r),r&&l(N),r&&l(k),r&&l(x),A(B,r),r&&l(m),r&&l(w),r&&l(D),A(ss,r)}}}function _e(W){let t,j;return t=new Xa({props:{$$slots:{default:[ge]},$$scope:{ctx:W}}}),{c(){_(t.$$.fragment)},l(e){I(t.$$.fragment,e)},m(e,h){Z(t,e,h),j=!0},p(e,h){const U={};h&2&&(U.$$scope={dirty:h,ctx:e}),t.$set(U)},i(e){j||(E(t.$$.fragment,e),j=!0)},o(e){G(t.$$.fragment,e),j=!1},d(e){A(t,e)}}}function Ie(W){let t,j,e,h,U,J,C,v,V,g,R,z,as,T,K,H,Q,os,Y,ds,S,O,ts,cs,P,N,k,ns,X,ps,rs,is,x,B,m,w,q,L,F,Ms,js,D,ss,$,r,f,Js,Ys,gs,_s,Ns,ys,Qs,Ss,us,xs,qs,ua,Ts,Is,Os,vs,Wa,Ls,za,fa,Ds,Ba,Ua,Rs,wa,Hs,Fa,Ja,fs,bs,Ya,sa,Na,Qa,aa,Sa,xa,qa,Xs,Da,la,Ha,Pa,Ka,hs,Oa,ea,La,sl,ta,al,ll,na,el,tl,Ta,Ws,ba,ms,nl,pa,pl,rl,ra,ol,cl,oa,il,Ml,Ca,zs,ga,ls,ml,ca,dl,jl,ia,hl,yl,Ma,ul,fl,ma,Ul,wl,_a,Zs,Jl,da,Tl,bl,Ia,Es,Za,Cs,Gs,ja,Bs,Cl,ha,gl,Ea,As,Ga;return J=new Ra({}),X=new Ra({}),q=new es({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>)`}}),D=new es({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>}`}}),vs=new Ra({}),Rs=new es({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>t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9leGFtcGxlcyUyMCUzRCUyMHRva2VuaXplcihmaXJzdF9zZW50ZW5jZXMlMkMlMjBzZWNvbmRfc2VudGVuY2VzJTJDJTIwdHJ1bmNhdGlvbiUzRFRydWUpJTBBJTIwJTIwJTIwJTIwcmV0dXJuJTIwJTdCayUzQSUyMCU1QnYlNUJpJTIwJTNBJTIwaSUyMCUyQiUyMDQlNUQlMjBmb3IlMjBpJTIwaW4lMjByYW5nZSgwJTJDJTIwbGVuKHYpJTJDJTIwNCklNUQlMjBmb3IlMjBrJTJDJTIwdiUyMGluJTIwdG9rZW5pemVkX2V4YW1wbGVzLml0ZW1zKCklN0Q=",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()}`}}),zs=new es({props:{code:"dG9rZW5pemVkX3N3YWclMjAlM0QlMjBzd2FnLm1hcChwcmVwcm9jZXNzX2Z1bmN0aW9uJTJDJTIwYmF0Y2hlZCUzRFRydWUp",highlighted:'tokenized_swag = swag.<span class="hljs-built_in">map</span>(preprocess_function, batched=<span class="hljs-literal">True</span>)'}}),Es=new ce({props:{pytorch:!0,tensorflow:!0,jax:!1,$$slots:{tensorflow:[we],pytorch:[fe]},$$scope:{ctx:W}}}),Bs=new Ra({}),As=new ce({props:{pytorch:!0,tensorflow:!0,jax:!1,$$slots:{tensorflow:[_e],pytorch:[be]},$$scope:{ctx:W}}}),{c(){t=o("meta"),j=y(),e=o("h1"),h=o("a"),U=o("span"),_(J.$$.fragment),C=y(),v=o("span"),V=n("Selecci\xF3n m\xFAltiple"),g=y(),R=o("p"),z=n(`La tarea de selecci\xF3n m\xFAltiple es parecida a la de responder preguntas, con la excepci\xF3n 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.`),as=y(),T=o("p"),K=n("Esta gu\xEDa te mostrar\xE1 como hacerle fine-tuning a "),H=o("a"),Q=n("BERT"),os=n(" en la configuraci\xF3n "),Y=o("code"),ds=n("regular"),S=n(" del dataset "),O=o("a"),ts=n("SWAG"),cs=n(`, de forma
que seleccione la mejor respuesta a partir de varias opciones y alg\xFAn contexto.`),P=y(),N=o("h2"),k=o("a"),ns=o("span"),_(X.$$.fragment),ps=y(),rs=o("span"),is=n("Cargar el dataset SWAG"),x=y(),B=o("p"),m=n("Carga el dataset SWAG con la biblioteca \u{1F917} Datasets:"),w=y(),_(q.$$.fragment),L=y(),F=o("p"),Ms=n("Ahora, \xE9chale un vistazo a un ejemplo del dataset:"),js=y(),_(D.$$.fragment),ss=y(),$=o("p"),r=n("Los campos "),f=o("code"),Js=n("sent1"),Ys=n(" y "),gs=o("code"),_s=n("sent2"),Ns=n(" muestran c\xF3mo comienza una oraci\xF3n, y cada campo "),ys=o("code"),Qs=n("ending"),Ss=n(" indica c\xF3mo podr\xEDa terminar. Dado el comienzo de la oraci\xF3n, el modelo debe escoger el final de oraci\xF3n correcto indicado por el campo "),us=o("code"),xs=n("label"),qs=n("."),ua=y(),Ts=o("h2"),Is=o("a"),Os=o("span"),_(vs.$$.fragment),Wa=y(),Ls=o("span"),za=n("Preprocesmaiento"),fa=y(),Ds=o("p"),Ba=n("Carga el tokenizer de BERT para procesar el comienzo de cada oraci\xF3n y los cuatro finales posibles:"),Ua=y(),_(Rs.$$.fragment),wa=y(),Hs=o("p"),Fa=n("La funci\xF3n de preprocesmaiento debe hacer lo siguiente:"),Ja=y(),fs=o("ol"),bs=o("li"),Ya=n("Hacer cuatro copias del campo "),sa=o("code"),Na=n("sent1"),Qa=n(" de forma que se pueda combinar cada una con el campo "),aa=o("code"),Sa=n("sent2"),xa=n(" para recrear la forma en que empieza la oraci\xF3n."),qa=y(),Xs=o("li"),Da=n("Combinar "),la=o("code"),Ha=n("sent2"),Pa=n(" con cada uno de los cuatro finales de oraci\xF3n posibles."),Ka=y(),hs=o("li"),Oa=n("Aplanar las dos listas para que puedas tokenizarlas, y luego des-aplanarlas para que cada ejemplo tenga los campos "),ea=o("code"),La=n("input_ids"),sl=n(", "),ta=o("code"),al=n("attention_mask"),ll=n(" y "),na=o("code"),el=n("labels"),tl=n(" correspondientes."),Ta=y(),_(Ws.$$.fragment),ba=y(),ms=o("p"),nl=n("Usa la funci\xF3n "),pa=o("code"),pl=n("map"),rl=n(" de \u{1F917} Datasets para aplicarle la funci\xF3n de preprocesamiento al dataset entero. Puedes acelerar la funci\xF3n "),ra=o("code"),ol=n("map"),cl=n(" haciendo "),oa=o("code"),il=n("batched=True"),Ml=n(" para procesar varios elementos del dataset a la vez."),Ca=y(),_(zs.$$.fragment),ga=y(),ls=o("p"),ml=n("\u{1F917} Transformers no tiene un collator de datos para la tarea de selecci\xF3n m\xFAltiple, as\xED que tendr\xEDas que crear uno. Puedes adaptar el "),ca=o("code"),dl=n("DataCollatorWithPadding"),jl=n(` para crear un lote de ejemplos para selecci\xF3n m\xFAltiple. Este tambi\xE9n
le `),ia=o("em"),hl=n("a\xF1adir\xE1 relleno de manera din\xE1mica"),yl=n(" a tu texto y a las etiquetas para que tengan la longitud del elemento m\xE1s largo en su lote, de forma que tengan una longitud uniforme. Aunque es posible rellenar el texto en la funci\xF3n "),Ma=o("code"),ul=n("tokenizer"),fl=n(` haciendo
`),ma=o("code"),Ul=n("padding=True"),wl=n(", el rellenado din\xE1mico es m\xE1s eficiente."),_a=y(),Zs=o("p"),Jl=n("El "),da=o("code"),Tl=n("DataCollatorForMultipleChoice"),bl=n(" aplanar\xE1 todas las entradas del modelo, les aplicar\xE1 relleno y luego des-aplanar\xE1 los resultados:"),Ia=y(),_(Es.$$.fragment),Za=y(),Cs=o("h2"),Gs=o("a"),ja=o("span"),_(Bs.$$.fragment),Cl=y(),ha=o("span"),gl=n("Entrenamiento"),Ea=y(),_(As.$$.fragment),this.h()},l(s){const d=he('[data-svelte="svelte-1phssyn"]',document.head);t=c(d,"META",{name:!0,content:!0}),d.forEach(l),j=u(s),e=c(s,"H1",{class:!0});var Fs=i(e);h=c(Fs,"A",{id:!0,class:!0,href:!0});var ya=i(h);U=c(ya,"SPAN",{});var _l=i(U);I(J.$$.fragment,_l),_l.forEach(l),ya.forEach(l),C=u(Fs),v=c(Fs,"SPAN",{});var Il=i(v);V=p(Il,"Selecci\xF3n m\xFAltiple"),Il.forEach(l),Fs.forEach(l),g=u(s),R=c(s,"P",{});var Zl=i(R);z=p(Zl,`La tarea de selecci\xF3n m\xFAltiple es parecida a la de responder preguntas, con la excepci\xF3n 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.`),Zl.forEach(l),as=u(s),T=c(s,"P",{});var ks=i(T);K=p(ks,"Esta gu\xEDa te mostrar\xE1 como hacerle fine-tuning a "),H=c(ks,"A",{href:!0,rel:!0});var El=i(H);Q=p(El,"BERT"),El.forEach(l),os=p(ks," en la configuraci\xF3n "),Y=c(ks,"CODE",{});var Gl=i(Y);ds=p(Gl,"regular"),Gl.forEach(l),S=p(ks," del dataset "),O=c(ks,"A",{href:!0,rel:!0});var Al=i(O);ts=p(Al,"SWAG"),Al.forEach(l),cs=p(ks,`, de forma
que seleccione la mejor respuesta a partir de varias opciones y alg\xFAn contexto.`),ks.forEach(l),P=u(s),N=c(s,"H2",{class:!0});var Aa=i(N);k=c(Aa,"A",{id:!0,class:!0,href:!0});var kl=i(k);ns=c(kl,"SPAN",{});var $l=i(ns);I(X.$$.fragment,$l),$l.forEach(l),kl.forEach(l),ps=u(Aa),rs=c(Aa,"SPAN",{});var Vl=i(rs);is=p(Vl,"Cargar el dataset SWAG"),Vl.forEach(l),Aa.forEach(l),x=u(s),B=c(s,"P",{});var vl=i(B);m=p(vl,"Carga el dataset SWAG con la biblioteca \u{1F917} Datasets:"),vl.forEach(l),w=u(s),I(q.$$.fragment,s),L=u(s),F=c(s,"P",{});var Rl=i(F);Ms=p(Rl,"Ahora, \xE9chale un vistazo a un ejemplo del dataset:"),Rl.forEach(l),js=u(s),I(D.$$.fragment,s),ss=u(s),$=c(s,"P",{});var Us=i($);r=p(Us,"Los campos "),f=c(Us,"CODE",{});var Xl=i(f);Js=p(Xl,"sent1"),Xl.forEach(l),Ys=p(Us," y "),gs=c(Us,"CODE",{});var Wl=i(gs);_s=p(Wl,"sent2"),Wl.forEach(l),Ns=p(Us," muestran c\xF3mo comienza una oraci\xF3n, y cada campo "),ys=c(Us,"CODE",{});var zl=i(ys);Qs=p(zl,"ending"),zl.forEach(l),Ss=p(Us," indica c\xF3mo podr\xEDa terminar. Dado el comienzo de la oraci\xF3n, el modelo debe escoger el final de oraci\xF3n correcto indicado por el campo "),us=c(Us,"CODE",{});var Bl=i(us);xs=p(Bl,"label"),Bl.forEach(l),qs=p(Us,"."),Us.forEach(l),ua=u(s),Ts=c(s,"H2",{class:!0});var ka=i(Ts);Is=c(ka,"A",{id:!0,class:!0,href:!0});var Fl=i(Is);Os=c(Fl,"SPAN",{});var Yl=i(Os);I(vs.$$.fragment,Yl),Yl.forEach(l),Fl.forEach(l),Wa=u(ka),Ls=c(ka,"SPAN",{});var Nl=i(Ls);za=p(Nl,"Preprocesmaiento"),Nl.forEach(l),ka.forEach(l),fa=u(s),Ds=c(s,"P",{});var Ql=i(Ds);Ba=p(Ql,"Carga el tokenizer de BERT para procesar el comienzo de cada oraci\xF3n y los cuatro finales posibles:"),Ql.forEach(l),Ua=u(s),I(Rs.$$.fragment,s),wa=u(s),Hs=c(s,"P",{});var Sl=i(Hs);Fa=p(Sl,"La funci\xF3n de preprocesmaiento debe hacer lo siguiente:"),Sl.forEach(l),Ja=u(s),fs=c(s,"OL",{});var Ps=i(fs);bs=c(Ps,"LI",{});var Ks=i(bs);Ya=p(Ks,"Hacer cuatro copias del campo "),sa=c(Ks,"CODE",{});var xl=i(sa);Na=p(xl,"sent1"),xl.forEach(l),Qa=p(Ks," de forma que se pueda combinar cada una con el campo "),aa=c(Ks,"CODE",{});var ql=i(aa);Sa=p(ql,"sent2"),ql.forEach(l),xa=p(Ks," para recrear la forma en que empieza la oraci\xF3n."),Ks.forEach(l),qa=u(Ps),Xs=c(Ps,"LI",{});var $a=i(Xs);Da=p($a,"Combinar "),la=c($a,"CODE",{});var Dl=i(la);Ha=p(Dl,"sent2"),Dl.forEach(l),Pa=p($a," con cada uno de los cuatro finales de oraci\xF3n posibles."),$a.forEach(l),Ka=u(Ps),hs=c(Ps,"LI",{});var $s=i(hs);Oa=p($s,"Aplanar las dos listas para que puedas tokenizarlas, y luego des-aplanarlas para que cada ejemplo tenga los campos "),ea=c($s,"CODE",{});var Hl=i(ea);La=p(Hl,"input_ids"),Hl.forEach(l),sl=p($s,", "),ta=c($s,"CODE",{});var Pl=i(ta);al=p(Pl,"attention_mask"),Pl.forEach(l),ll=p($s," y "),na=c($s,"CODE",{});var Kl=i(na);el=p(Kl,"labels"),Kl.forEach(l),tl=p($s," correspondientes."),$s.forEach(l),Ps.forEach(l),Ta=u(s),I(Ws.$$.fragment,s),ba=u(s),ms=c(s,"P",{});var Vs=i(ms);nl=p(Vs,"Usa la funci\xF3n "),pa=c(Vs,"CODE",{});var Ol=i(pa);pl=p(Ol,"map"),Ol.forEach(l),rl=p(Vs," de \u{1F917} Datasets para aplicarle la funci\xF3n de preprocesamiento al dataset entero. Puedes acelerar la funci\xF3n "),ra=c(Vs,"CODE",{});var Ll=i(ra);ol=p(Ll,"map"),Ll.forEach(l),cl=p(Vs," haciendo "),oa=c(Vs,"CODE",{});var se=i(oa);il=p(se,"batched=True"),se.forEach(l),Ml=p(Vs," para procesar varios elementos del dataset a la vez."),Vs.forEach(l),Ca=u(s),I(zs.$$.fragment,s),ga=u(s),ls=c(s,"P",{});var ws=i(ls);ml=p(ws,"\u{1F917} Transformers no tiene un collator de datos para la tarea de selecci\xF3n m\xFAltiple, as\xED que tendr\xEDas que crear uno. Puedes adaptar el "),ca=c(ws,"CODE",{});var ae=i(ca);dl=p(ae,"DataCollatorWithPadding"),ae.forEach(l),jl=p(ws,` para crear un lote de ejemplos para selecci\xF3n m\xFAltiple. Este tambi\xE9n
le `),ia=c(ws,"EM",{});var le=i(ia);hl=p(le,"a\xF1adir\xE1 relleno de manera din\xE1mica"),le.forEach(l),yl=p(ws," a tu texto y a las etiquetas para que tengan la longitud del elemento m\xE1s largo en su lote, de forma que tengan una longitud uniforme. Aunque es posible rellenar el texto en la funci\xF3n "),Ma=c(ws,"CODE",{});var ee=i(Ma);ul=p(ee,"tokenizer"),ee.forEach(l),fl=p(ws,` haciendo
`),ma=c(ws,"CODE",{});var te=i(ma);Ul=p(te,"padding=True"),te.forEach(l),wl=p(ws,", el rellenado din\xE1mico es m\xE1s eficiente."),ws.forEach(l),_a=u(s),Zs=c(s,"P",{});var Va=i(Zs);Jl=p(Va,"El "),da=c(Va,"CODE",{});var ne=i(da);Tl=p(ne,"DataCollatorForMultipleChoice"),ne.forEach(l),bl=p(Va," aplanar\xE1 todas las entradas del modelo, les aplicar\xE1 relleno y luego des-aplanar\xE1 los resultados:"),Va.forEach(l),Ia=u(s),I(Es.$$.fragment,s),Za=u(s),Cs=c(s,"H2",{class:!0});var va=i(Cs);Gs=c(va,"A",{id:!0,class:!0,href:!0});var pe=i(Gs);ja=c(pe,"SPAN",{});var re=i(ja);I(Bs.$$.fragment,re),re.forEach(l),pe.forEach(l),Cl=u(va),ha=c(va,"SPAN",{});var oe=i(ha);gl=p(oe,"Entrenamiento"),oe.forEach(l),va.forEach(l),Ea=u(s),I(As.$$.fragment,s),this.h()},h(){b(t,"name","hf:doc:metadata"),b(t,"content",JSON.stringify(Ze)),b(h,"id","seleccin-mltiple"),b(h,"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(h,"href","#seleccin-mltiple"),b(e,"class","relative group"),b(H,"href","https://huggingface.co/bert-base-uncased"),b(H,"rel","nofollow"),b(O,"href","https://huggingface.co/datasets/swag"),b(O,"rel","nofollow"),b(k,"id","cargar-el-dataset-swag"),b(k,"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(k,"href","#cargar-el-dataset-swag"),b(N,"class","relative group"),b(Is,"id","preprocesmaiento"),b(Is,"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(Is,"href","#preprocesmaiento"),b(Ts,"class","relative group"),b(Gs,"id","entrenamiento"),b(Gs,"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(Gs,"href","#entrenamiento"),b(Cs,"class","relative group")},m(s,d){a(document.head,t),M(s,j,d),M(s,e,d),a(e,h),a(h,U),Z(J,U,null),a(e,C),a(e,v),a(v,V),M(s,g,d),M(s,R,d),a(R,z),M(s,as,d),M(s,T,d),a(T,K),a(T,H),a(H,Q),a(T,os),a(T,Y),a(Y,ds),a(T,S),a(T,O),a(O,ts),a(T,cs),M(s,P,d),M(s,N,d),a(N,k),a(k,ns),Z(X,ns,null),a(N,ps),a(N,rs),a(rs,is),M(s,x,d),M(s,B,d),a(B,m),M(s,w,d),Z(q,s,d),M(s,L,d),M(s,F,d),a(F,Ms),M(s,js,d),Z(D,s,d),M(s,ss,d),M(s,$,d),a($,r),a($,f),a(f,Js),a($,Ys),a($,gs),a(gs,_s),a($,Ns),a($,ys),a(ys,Qs),a($,Ss),a($,us),a(us,xs),a($,qs),M(s,ua,d),M(s,Ts,d),a(Ts,Is),a(Is,Os),Z(vs,Os,null),a(Ts,Wa),a(Ts,Ls),a(Ls,za),M(s,fa,d),M(s,Ds,d),a(Ds,Ba),M(s,Ua,d),Z(Rs,s,d),M(s,wa,d),M(s,Hs,d),a(Hs,Fa),M(s,Ja,d),M(s,fs,d),a(fs,bs),a(bs,Ya),a(bs,sa),a(sa,Na),a(bs,Qa),a(bs,aa),a(aa,Sa),a(bs,xa),a(fs,qa),a(fs,Xs),a(Xs,Da),a(Xs,la),a(la,Ha),a(Xs,Pa),a(fs,Ka),a(fs,hs),a(hs,Oa),a(hs,ea),a(ea,La),a(hs,sl),a(hs,ta),a(ta,al),a(hs,ll),a(hs,na),a(na,el),a(hs,tl),M(s,Ta,d),Z(Ws,s,d),M(s,ba,d),M(s,ms,d),a(ms,nl),a(ms,pa),a(pa,pl),a(ms,rl),a(ms,ra),a(ra,ol),a(ms,cl),a(ms,oa),a(oa,il),a(ms,Ml),M(s,Ca,d),Z(zs,s,d),M(s,ga,d),M(s,ls,d),a(ls,ml),a(ls,ca),a(ca,dl),a(ls,jl),a(ls,ia),a(ia,hl),a(ls,yl),a(ls,Ma),a(Ma,ul),a(ls,fl),a(ls,ma),a(ma,Ul),a(ls,wl),M(s,_a,d),M(s,Zs,d),a(Zs,Jl),a(Zs,da),a(da,Tl),a(Zs,bl),M(s,Ia,d),Z(Es,s,d),M(s,Za,d),M(s,Cs,d),a(Cs,Gs),a(Gs,ja),Z(Bs,ja,null),a(Cs,Cl),a(Cs,ha),a(ha,gl),M(s,Ea,d),Z(As,s,d),Ga=!0},p(s,[d]){const Fs={};d&2&&(Fs.$$scope={dirty:d,ctx:s}),Es.$set(Fs);const ya={};d&2&&(ya.$$scope={dirty:d,ctx:s}),As.$set(ya)},i(s){Ga||(E(J.$$.fragment,s),E(X.$$.fragment,s),E(q.$$.fragment,s),E(D.$$.fragment,s),E(vs.$$.fragment,s),E(Rs.$$.fragment,s),E(Ws.$$.fragment,s),E(zs.$$.fragment,s),E(Es.$$.fragment,s),E(Bs.$$.fragment,s),E(As.$$.fragment,s),Ga=!0)},o(s){G(J.$$.fragment,s),G(X.$$.fragment,s),G(q.$$.fragment,s),G(D.$$.fragment,s),G(vs.$$.fragment,s),G(Rs.$$.fragment,s),G(Ws.$$.fragment,s),G(zs.$$.fragment,s),G(Es.$$.fragment,s),G(Bs.$$.fragment,s),G(As.$$.fragment,s),Ga=!1},d(s){l(t),s&&l(j),s&&l(e),A(J),s&&l(g),s&&l(R),s&&l(as),s&&l(T),s&&l(P),s&&l(N),A(X),s&&l(x),s&&l(B),s&&l(w),A(q,s),s&&l(L),s&&l(F),s&&l(js),A(D,s),s&&l(ss),s&&l($),s&&l(ua),s&&l(Ts),A(vs),s&&l(fa),s&&l(Ds),s&&l(Ua),A(Rs,s),s&&l(wa),s&&l(Hs),s&&l(Ja),s&&l(fs),s&&l(Ta),A(Ws,s),s&&l(ba),s&&l(ms),s&&l(Ca),A(zs,s),s&&l(ga),s&&l(ls),s&&l(_a),s&&l(Zs),s&&l(Ia),A(Es,s),s&&l(Za),s&&l(Cs),A(Bs),s&&l(Ea),A(As,s)}}}const Ze={local:"seleccin-mltiple",sections:[{local:"cargar-el-dataset-swag",title:"Cargar el dataset SWAG"},{local:"preprocesmaiento",title:"Preprocesmaiento"},{local:"entrenamiento",title:"Entrenamiento"}],title:"Selecci\xF3n m\xFAltiple"};function Ee(W){return ye(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class Re extends me{constructor(t){super();de(this,t,Ee,Ie,je,{})}}export{Re as default,Ze as metadata};
