import{s as Ge,o as We,n as xe}from"../chunks/scheduler.36a0863c.js";import{S as ze,i as Xe,g as M,s as i,r as y,A as Ie,h,f as a,c as o,j as Ze,u as g,x as J,k as ke,y as Ve,a as t,v as j,d as U,t as b,w}from"../chunks/index.f891bdb2.js";import{T as Re}from"../chunks/Tip.a8272f7f.js";import{C as z}from"../chunks/CodeBlock.b05e74dc.js";import{F as Fe,M as ve}from"../chunks/Markdown.7b58822e.js";import{H as Ue,E as Be}from"../chunks/index.edcb1a86.js";function Ye(W){let l,d='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(){l=M("p"),l.innerHTML=d},l(p){l=h(p,"P",{"data-svelte-h":!0}),J(l)!=="svelte-1sco78m"&&(l.innerHTML=d)},m(p,c){t(p,l,c)},p:xe,d(p){p&&a(l)}}}function Qe(W){let l,d="Carga el modelo BERT con <code>AutoModelForMultipleChoice</code>:",p,c,f,$,k,C,F="En este punto, solo quedan tres pasos:",x,_,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>",T,v,R;return c=new z({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}}),$=new Re({props:{$$slots:{default:[Ye]},$$scope:{ctx:W}}}),v=new z({props:{code:"dHJhaW5pbmdfYXJncyUyMCUzRCUyMFRyYWluaW5nQXJndW1lbnRzKCUwQSUyMCUyMCUyMCUyMG91dHB1dF9kaXIlM0QlMjIuJTJGcmVzdWx0cyUyMiUyQyUwQSUyMCUyMCUyMCUyMGV2YWxfc3RyYXRlZ3klM0QlMjJlcG9jaCUyMiUyQyUwQSUyMCUyMCUyMCUyMGxlYXJuaW5nX3JhdGUlM0Q1ZS01JTJDJTBBJTIwJTIwJTIwJTIwcGVyX2RldmljZV90cmFpbl9iYXRjaF9zaXplJTNEMTYlMkMlMEElMjAlMjAlMjAlMjBwZXJfZGV2aWNlX2V2YWxfYmF0Y2hfc2l6ZSUzRDE2JTJDJTBBJTIwJTIwJTIwJTIwbnVtX3RyYWluX2Vwb2NocyUzRDMlMkMlMEElMjAlMjAlMjAlMjB3ZWlnaHRfZGVjYXklM0QwLjAxJTJDJTBBKSUwQSUwQXRyYWluZXIlMjAlM0QlMjBUcmFpbmVyKCUwQSUyMCUyMCUyMCUyMG1vZGVsJTNEbW9kZWwlMkMlMEElMjAlMjAlMjAlMjBhcmdzJTNEdHJhaW5pbmdfYXJncyUyQyUwQSUyMCUyMCUyMCUyMHRyYWluX2RhdGFzZXQlM0R0b2tlbml6ZWRfc3dhZyU1QiUyMnRyYWluJTIyJTVEJTJDJTBBJTIwJTIwJTIwJTIwZXZhbF9kYXRhc2V0JTNEdG9rZW5pemVkX3N3YWclNUIlMjJ2YWxpZGF0aW9uJTIyJTVEJTJDJTBBJTIwJTIwJTIwJTIwcHJvY2Vzc2luZ19jbGFzcyUzRHRva2VuaXplciUyQyUwQSUyMCUyMCUyMCUyMGRhdGFfY29sbGF0b3IlM0Rjb2xsYXRvciUyQyUwQSklMEElMEF0cmFpbmVyLnRyYWluKCk=",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span>training_args = TrainingArguments(
<span class="hljs-meta">... </span>    output_dir=<span class="hljs-string">&quot;./results&quot;</span>,
<span class="hljs-meta">... </span>    eval_strategy=<span class="hljs-string">&quot;epoch&quot;</span>,
<span class="hljs-meta">... </span>    learning_rate=<span class="hljs-number">5e-5</span>,
<span class="hljs-meta">... </span>    per_device_train_batch_size=<span class="hljs-number">16</span>,
<span class="hljs-meta">... </span>    per_device_eval_batch_size=<span class="hljs-number">16</span>,
<span class="hljs-meta">... </span>    num_train_epochs=<span class="hljs-number">3</span>,
<span class="hljs-meta">... </span>    weight_decay=<span class="hljs-number">0.01</span>,
<span class="hljs-meta">... </span>)

<span class="hljs-meta">&gt;&gt;&gt; </span>trainer = Trainer(
<span class="hljs-meta">... </span>    model=model,
<span class="hljs-meta">... </span>    args=training_args,
<span class="hljs-meta">... </span>    train_dataset=tokenized_swag[<span class="hljs-string">&quot;train&quot;</span>],
<span class="hljs-meta">... </span>    eval_dataset=tokenized_swag[<span class="hljs-string">&quot;validation&quot;</span>],
<span class="hljs-meta">... </span>    processing_class=tokenizer,
<span class="hljs-meta">... </span>    data_collator=collator,
<span class="hljs-meta">... </span>)

<span class="hljs-meta">&gt;&gt;&gt; </span>trainer.train()`,wrap:!1}}),{c(){l=M("p"),l.innerHTML=d,p=i(),y(c.$$.fragment),f=i(),y($.$$.fragment),k=i(),C=M("p"),C.textContent=F,x=i(),_=M("ol"),_.innerHTML=X,T=i(),y(v.$$.fragment)},l(r){l=h(r,"P",{"data-svelte-h":!0}),J(l)!=="svelte-6bdz67"&&(l.innerHTML=d),p=o(r),g(c.$$.fragment,r),f=o(r),g($.$$.fragment,r),k=o(r),C=h(r,"P",{"data-svelte-h":!0}),J(C)!=="svelte-bd5x35"&&(C.textContent=F),x=o(r),_=h(r,"OL",{"data-svelte-h":!0}),J(_)!=="svelte-k4ouyy"&&(_.innerHTML=X),T=o(r),g(v.$$.fragment,r)},m(r,u){t(r,l,u),t(r,p,u),j(c,r,u),t(r,f,u),j($,r,u),t(r,k,u),t(r,C,u),t(r,x,u),t(r,_,u),t(r,T,u),j(v,r,u),R=!0},p(r,u){const Z={};u&2&&(Z.$$scope={dirty:u,ctx:r}),$.$set(Z)},i(r){R||(U(c.$$.fragment,r),U($.$$.fragment,r),U(v.$$.fragment,r),R=!0)},o(r){b(c.$$.fragment,r),b($.$$.fragment,r),b(v.$$.fragment,r),R=!1},d(r){r&&(a(l),a(p),a(f),a(k),a(C),a(x),a(_),a(T)),w(c,r),w($,r),w(v,r)}}}function Ne(W){let l,d;return l=new ve({props:{$$slots:{default:[Qe]},$$scope:{ctx:W}}}),{c(){y(l.$$.fragment)},l(p){g(l.$$.fragment,p)},m(p,c){j(l,p,c),d=!0},p(p,c){const f={};c&2&&(f.$$scope={dirty:c,ctx:p}),l.$set(f)},i(p){d||(U(l.$$.fragment,p),d=!0)},o(p){b(l.$$.fragment,p),d=!1},d(p){w(l,p)}}}function Ee(W){let l,d='Para familiarizarte con el fine-tuning con Keras, ¡mira el tutorial básico <a href="training#finetune-with-keras">aquí</a>!';return{c(){l=M("p"),l.innerHTML=d},l(p){l=h(p,"P",{"data-svelte-h":!0}),J(l)!=="svelte-66s4ry"&&(l.innerHTML=d)},m(p,c){t(p,l,c)},p:xe,d(p){p&&a(l)}}}function He(W){let l,d="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>.",p,c,f,$,k,C,F="Prepara una función de optimización, un programa para la tasa de aprendizaje y algunos hiperparámetros de entrenamiento:",x,_,X,T,v="Carga el modelo BERT con <code>TFAutoModelForMultipleChoice</code>:",R,r,u,Z,q='Configura el modelo para entrenarlo con <a href="https://keras.io/api/models/model_training_apis/#compile-method" rel="nofollow"><code>compile</code></a>:',I,B,N,G,A='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:',V,Y,E;return c=new z({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}}),$=new Re({props:{$$slots:{default:[Ee]},$$scope:{ctx:W}}}),_=new z({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 z({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}}),B=new z({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 z({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(){l=M("p"),l.innerHTML=d,p=i(),y(c.$$.fragment),f=i(),y($.$$.fragment),k=i(),C=M("p"),C.textContent=F,x=i(),y(_.$$.fragment),X=i(),T=M("p"),T.innerHTML=v,R=i(),y(r.$$.fragment),u=i(),Z=M("p"),Z.innerHTML=q,I=i(),y(B.$$.fragment),N=i(),G=M("p"),G.innerHTML=A,V=i(),y(Y.$$.fragment)},l(s){l=h(s,"P",{"data-svelte-h":!0}),J(l)!=="svelte-1dn6k4v"&&(l.innerHTML=d),p=o(s),g(c.$$.fragment,s),f=o(s),g($.$$.fragment,s),k=o(s),C=h(s,"P",{"data-svelte-h":!0}),J(C)!=="svelte-81yq28"&&(C.textContent=F),x=o(s),g(_.$$.fragment,s),X=o(s),T=h(s,"P",{"data-svelte-h":!0}),J(T)!=="svelte-1v9x5sp"&&(T.innerHTML=v),R=o(s),g(r.$$.fragment,s),u=o(s),Z=h(s,"P",{"data-svelte-h":!0}),J(Z)!=="svelte-jy7mgr"&&(Z.innerHTML=q),I=o(s),g(B.$$.fragment,s),N=o(s),G=h(s,"P",{"data-svelte-h":!0}),J(G)!=="svelte-1dz4xz1"&&(G.innerHTML=A),V=o(s),g(Y.$$.fragment,s)},m(s,m){t(s,l,m),t(s,p,m),j(c,s,m),t(s,f,m),j($,s,m),t(s,k,m),t(s,C,m),t(s,x,m),j(_,s,m),t(s,X,m),t(s,T,m),t(s,R,m),j(r,s,m),t(s,u,m),t(s,Z,m),t(s,I,m),j(B,s,m),t(s,N,m),t(s,G,m),t(s,V,m),j(Y,s,m),E=!0},p(s,m){const Q={};m&2&&(Q.$$scope={dirty:m,ctx:s}),$.$set(Q)},i(s){E||(U(c.$$.fragment,s),U($.$$.fragment,s),U(_.$$.fragment,s),U(r.$$.fragment,s),U(B.$$.fragment,s),U(Y.$$.fragment,s),E=!0)},o(s){b(c.$$.fragment,s),b($.$$.fragment,s),b(_.$$.fragment,s),b(r.$$.fragment,s),b(B.$$.fragment,s),b(Y.$$.fragment,s),E=!1},d(s){s&&(a(l),a(p),a(f),a(k),a(C),a(x),a(X),a(T),a(R),a(u),a(Z),a(I),a(N),a(G),a(V)),w(c,s),w($,s),w(_,s),w(r,s),w(B,s),w(Y,s)}}}function qe(W){let l,d;return l=new ve({props:{$$slots:{default:[He]},$$scope:{ctx:W}}}),{c(){y(l.$$.fragment)},l(p){g(l.$$.fragment,p)},m(p,c){j(l,p,c),d=!0},p(p,c){const f={};c&2&&(f.$$scope={dirty:c,ctx:p}),l.$set(f)},i(p){d||(U(l.$$.fragment,p),d=!0)},o(p){b(l.$$.fragment,p),d=!1},d(p){w(l,p)}}}function Ae(W){let l,d,p,c,f,$,k,C=`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.`,F,x,_=`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.`,X,T,v,R,r="Carga el dataset SWAG con la biblioteca 🤗 Datasets:",u,Z,q,I,B="Ahora, échale un vistazo a un ejemplo del dataset:",N,G,A,V,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>.",E,s,m,Q,be="Carga el tokenizer de BERT para procesar el comienzo de cada oración y los cuatro finales posibles:",pe,S,re,L,we="La función de preprocesmaiento debe hacer lo siguiente:",ie,D,$e="<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>",oe,P,ce,K,Je="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.",me,O,de,ee,Te=`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.`,ue,se,Ce="El <code>DataCollatorForMultipleChoice</code> aplanará todas las entradas del modelo, les aplicará relleno y luego des-aplanará los resultados.",Me,ae,he,te,fe,H,ye,le,ge,ne,je;return f=new Ue({props:{title:"Selección múltiple",local:"selección-múltiple",headingTag:"h1"}}),T=new Ue({props:{title:"Cargar el dataset SWAG",local:"cargar-el-dataset-swag",headingTag:"h2"}}),Z=new z({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}}),G=new z({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}}),s=new Ue({props:{title:"Preprocesmaiento",local:"preprocesmaiento",headingTag:"h2"}}),S=new z({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}}),P=new z({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}}),O=new z({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}}),ae=new z({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMERhdGFDb2xsYXRvckZvck11bHRpcGxlQ2hvaWNlJTBBY29sbGF0b3IlMjAlM0QlMjBEYXRhQ29sbGF0b3JGb3JNdWx0aXBsZUNob2ljZSh0b2tlbml6ZXIlM0R0b2tlbml6ZXIp",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> DataCollatorForMultipleChoice
<span class="hljs-meta">&gt;&gt;&gt; </span>collator = DataCollatorForMultipleChoice(tokenizer=tokenizer)`,wrap:!1}}),te=new Ue({props:{title:"Entrenamiento",local:"entrenamiento",headingTag:"h2"}}),H=new Fe({props:{pytorch:!0,tensorflow:!0,jax:!1,$$slots:{tensorflow:[qe],pytorch:[Ne]},$$scope:{ctx:W}}}),le=new Be({props:{source:"https://github.com/huggingface/transformers/blob/main/docs/source/es/tasks/multiple_choice.md"}}),{c(){l=M("meta"),d=i(),p=M("p"),c=i(),y(f.$$.fragment),$=i(),k=M("p"),k.textContent=C,F=i(),x=M("p"),x.innerHTML=_,X=i(),y(T.$$.fragment),v=i(),R=M("p"),R.textContent=r,u=i(),y(Z.$$.fragment),q=i(),I=M("p"),I.textContent=B,N=i(),y(G.$$.fragment),A=i(),V=M("p"),V.innerHTML=Y,E=i(),y(s.$$.fragment),m=i(),Q=M("p"),Q.textContent=be,pe=i(),y(S.$$.fragment),re=i(),L=M("p"),L.textContent=we,ie=i(),D=M("ol"),D.innerHTML=$e,oe=i(),y(P.$$.fragment),ce=i(),K=M("p"),K.innerHTML=Je,me=i(),y(O.$$.fragment),de=i(),ee=M("p"),ee.innerHTML=Te,ue=i(),se=M("p"),se.innerHTML=Ce,Me=i(),y(ae.$$.fragment),he=i(),y(te.$$.fragment),fe=i(),y(H.$$.fragment),ye=i(),y(le.$$.fragment),ge=i(),ne=M("p"),this.h()},l(e){const n=Ie("svelte-u9bgzb",document.head);l=h(n,"META",{name:!0,content:!0}),n.forEach(a),d=o(e),p=h(e,"P",{}),Ze(p).forEach(a),c=o(e),g(f.$$.fragment,e),$=o(e),k=h(e,"P",{"data-svelte-h":!0}),J(k)!=="svelte-50nup6"&&(k.textContent=C),F=o(e),x=h(e,"P",{"data-svelte-h":!0}),J(x)!=="svelte-1tgwhyx"&&(x.innerHTML=_),X=o(e),g(T.$$.fragment,e),v=o(e),R=h(e,"P",{"data-svelte-h":!0}),J(R)!=="svelte-vnn33k"&&(R.textContent=r),u=o(e),g(Z.$$.fragment,e),q=o(e),I=h(e,"P",{"data-svelte-h":!0}),J(I)!=="svelte-x1ncwr"&&(I.textContent=B),N=o(e),g(G.$$.fragment,e),A=o(e),V=h(e,"P",{"data-svelte-h":!0}),J(V)!=="svelte-1ri0vdd"&&(V.innerHTML=Y),E=o(e),g(s.$$.fragment,e),m=o(e),Q=h(e,"P",{"data-svelte-h":!0}),J(Q)!=="svelte-1iq2bgx"&&(Q.textContent=be),pe=o(e),g(S.$$.fragment,e),re=o(e),L=h(e,"P",{"data-svelte-h":!0}),J(L)!=="svelte-1jkglaf"&&(L.textContent=we),ie=o(e),D=h(e,"OL",{"data-svelte-h":!0}),J(D)!=="svelte-12xaauq"&&(D.innerHTML=$e),oe=o(e),g(P.$$.fragment,e),ce=o(e),K=h(e,"P",{"data-svelte-h":!0}),J(K)!=="svelte-f9xmqh"&&(K.innerHTML=Je),me=o(e),g(O.$$.fragment,e),de=o(e),ee=h(e,"P",{"data-svelte-h":!0}),J(ee)!=="svelte-n4gnur"&&(ee.innerHTML=Te),ue=o(e),se=h(e,"P",{"data-svelte-h":!0}),J(se)!=="svelte-x8ys0g"&&(se.innerHTML=Ce),Me=o(e),g(ae.$$.fragment,e),he=o(e),g(te.$$.fragment,e),fe=o(e),g(H.$$.fragment,e),ye=o(e),g(le.$$.fragment,e),ge=o(e),ne=h(e,"P",{}),Ze(ne).forEach(a),this.h()},h(){ke(l,"name","hf:doc:metadata"),ke(l,"content",Se)},m(e,n){Ve(document.head,l),t(e,d,n),t(e,p,n),t(e,c,n),j(f,e,n),t(e,$,n),t(e,k,n),t(e,F,n),t(e,x,n),t(e,X,n),j(T,e,n),t(e,v,n),t(e,R,n),t(e,u,n),j(Z,e,n),t(e,q,n),t(e,I,n),t(e,N,n),j(G,e,n),t(e,A,n),t(e,V,n),t(e,E,n),j(s,e,n),t(e,m,n),t(e,Q,n),t(e,pe,n),j(S,e,n),t(e,re,n),t(e,L,n),t(e,ie,n),t(e,D,n),t(e,oe,n),j(P,e,n),t(e,ce,n),t(e,K,n),t(e,me,n),j(O,e,n),t(e,de,n),t(e,ee,n),t(e,ue,n),t(e,se,n),t(e,Me,n),j(ae,e,n),t(e,he,n),j(te,e,n),t(e,fe,n),j(H,e,n),t(e,ye,n),j(le,e,n),t(e,ge,n),t(e,ne,n),je=!0},p(e,[n]){const _e={};n&2&&(_e.$$scope={dirty:n,ctx:e}),H.$set(_e)},i(e){je||(U(f.$$.fragment,e),U(T.$$.fragment,e),U(Z.$$.fragment,e),U(G.$$.fragment,e),U(s.$$.fragment,e),U(S.$$.fragment,e),U(P.$$.fragment,e),U(O.$$.fragment,e),U(ae.$$.fragment,e),U(te.$$.fragment,e),U(H.$$.fragment,e),U(le.$$.fragment,e),je=!0)},o(e){b(f.$$.fragment,e),b(T.$$.fragment,e),b(Z.$$.fragment,e),b(G.$$.fragment,e),b(s.$$.fragment,e),b(S.$$.fragment,e),b(P.$$.fragment,e),b(O.$$.fragment,e),b(ae.$$.fragment,e),b(te.$$.fragment,e),b(H.$$.fragment,e),b(le.$$.fragment,e),je=!1},d(e){e&&(a(d),a(p),a(c),a($),a(k),a(F),a(x),a(X),a(v),a(R),a(u),a(q),a(I),a(N),a(A),a(V),a(E),a(m),a(Q),a(pe),a(re),a(L),a(ie),a(D),a(oe),a(ce),a(K),a(me),a(de),a(ee),a(ue),a(se),a(Me),a(he),a(fe),a(ye),a(ge),a(ne)),a(l),w(f,e),w(T,e),w(Z,e),w(G,e),w(s,e),w(S,e),w(P,e),w(O,e),w(ae,e),w(te,e),w(H,e),w(le,e)}}}const Se='{"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 Le(W){return We(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class as extends ze{constructor(l){super(),Xe(this,l,Le,Ae,Ge,{})}}export{as as component};
