import{S as fn,i as hn,s as gn,e as p,k as f,w as k,t as l,M as yn,c as i,d as s,m as h,a as c,x as C,h as n,b as w,G as a,g as m,y as G,q as x,o as R,B as z,v as Mn,L as un}from"../../chunks/vendor-hf-doc-builder.js";import{T as Ca}from"../../chunks/Tip-hf-doc-builder.js";import{Y as et}from"../../chunks/Youtube-hf-doc-builder.js";import{I as Ea}from"../../chunks/IconCopyLink-hf-doc-builder.js";import{C as te}from"../../chunks/CodeBlock-hf-doc-builder.js";import{F as dl,M as Ga}from"../../chunks/Markdown-hf-doc-builder.js";import"../../chunks/IconTensorflow-hf-doc-builder.js";function jn(N){let t,j,r,g,E,M,$,v,b,T,Z,q,A,J,V,X,D,W,Q,y;return{c(){t=p("p"),j=l("Puedes realizar fine-tuning a otras arquitecturas para modelos de lenguaje como "),r=p("a"),g=l("GPT-Neo"),E=l(", "),M=p("a"),$=l("GPT-J"),v=l(" y "),b=p("a"),T=l("BERT"),Z=l(" siguiendo los mismos pasos presentados en esta gu\xEDa!"),q=f(),A=p("p"),J=l("Mira la "),V=p("a"),X=l("p\xE1gina de tarea"),D=l(" para generaci\xF3n de texto y la "),W=p("a"),Q=l("p\xE1gina de tarea"),y=l(" para modelos de lenguajes por enmascaramiento para obtener m\xE1s informaci\xF3n sobre los modelos, datasets, y m\xE9tricas asociadas."),this.h()},l(_){t=i(_,"P",{});var Y=c(t);j=n(Y,"Puedes realizar fine-tuning a otras arquitecturas para modelos de lenguaje como "),r=i(Y,"A",{href:!0,rel:!0});var I=c(r);g=n(I,"GPT-Neo"),I.forEach(s),E=n(Y,", "),M=i(Y,"A",{href:!0,rel:!0});var B=c(M);$=n(B,"GPT-J"),B.forEach(s),v=n(Y," y "),b=i(Y,"A",{href:!0,rel:!0});var L=c(b);T=n(L,"BERT"),L.forEach(s),Z=n(Y," siguiendo los mismos pasos presentados en esta gu\xEDa!"),Y.forEach(s),q=h(_),A=i(_,"P",{});var ee=c(A);J=n(ee,"Mira la "),V=i(ee,"A",{href:!0,rel:!0});var ae=c(V);X=n(ae,"p\xE1gina de tarea"),ae.forEach(s),D=n(ee," para generaci\xF3n de texto y la "),W=i(ee,"A",{href:!0,rel:!0});var ie=c(W);Q=n(ie,"p\xE1gina de tarea"),ie.forEach(s),y=n(ee," para modelos de lenguajes por enmascaramiento para obtener m\xE1s informaci\xF3n sobre los modelos, datasets, y m\xE9tricas asociadas."),ee.forEach(s),this.h()},h(){w(r,"href","https://huggingface.co/EleutherAI/gpt-neo-125M"),w(r,"rel","nofollow"),w(M,"href","https://huggingface.co/EleutherAI/gpt-j-6B"),w(M,"rel","nofollow"),w(b,"href","https://huggingface.co/bert-base-uncased"),w(b,"rel","nofollow"),w(V,"href","https://huggingface.co/tasks/text-generation"),w(V,"rel","nofollow"),w(W,"href","https://huggingface.co/tasks/fill-mask"),w(W,"rel","nofollow")},m(_,Y){m(_,t,Y),a(t,j),a(t,r),a(r,g),a(t,E),a(t,M),a(M,$),a(t,v),a(t,b),a(b,T),a(t,Z),m(_,q,Y),m(_,A,Y),a(A,J),a(A,V),a(V,X),a(A,D),a(A,W),a(W,Q),a(A,y)},d(_){_&&s(t),_&&s(q),_&&s(A)}}}function $n(N){let t,j,r,g,E,M,$,v,b,T,Z,q,A,J,V,X,D,W,Q;return $=new te({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMERhdGFDb2xsYXRvckZvckxhbmd1YWdlTW9kZWxpbmclMEElMEF0b2tlbml6ZXIucGFkX3Rva2VuJTIwJTNEJTIwdG9rZW5pemVyLmVvc190b2tlbiUwQWRhdGFfY29sbGF0b3IlMjAlM0QlMjBEYXRhQ29sbGF0b3JGb3JMYW5ndWFnZU1vZGVsaW5nKHRva2VuaXplciUzRHRva2VuaXplciUyQyUyMG1sbSUzREZhbHNlKQ==",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> DataCollatorForLanguageModeling

<span class="hljs-meta">&gt;&gt;&gt; </span>tokenizer.pad_token = tokenizer.eos_token
<span class="hljs-meta">&gt;&gt;&gt; </span>data_collator = DataCollatorForLanguageModeling(tokenizer=tokenizer, mlm=<span class="hljs-literal">False</span>)`}}),W=new te({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMERhdGFDb2xsYXRvckZvckxhbmd1YWdlTW9kZWxpbmclMEElMEF0b2tlbml6ZXIucGFkX3Rva2VuJTIwJTNEJTIwdG9rZW5pemVyLmVvc190b2tlbiUwQWRhdGFfY29sbGF0b3IlMjAlM0QlMjBEYXRhQ29sbGF0b3JGb3JMYW5ndWFnZU1vZGVsaW5nKHRva2VuaXplciUzRHRva2VuaXplciUyQyUyMG1sbV9wcm9iYWJpbGl0eSUzRDAuMTUp",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> DataCollatorForLanguageModeling

<span class="hljs-meta">&gt;&gt;&gt; </span>tokenizer.pad_token = tokenizer.eos_token
<span class="hljs-meta">&gt;&gt;&gt; </span>data_collator = DataCollatorForLanguageModeling(tokenizer=tokenizer, mlm_probability=<span class="hljs-number">0.15</span>)`}}),{c(){t=p("p"),j=l("Puedes usar el token de final de secuencia como el token de relleno y asignar "),r=p("code"),g=l("mlm=False"),E=l(". Esto usar\xE1 los inputs como etiquetas movidas un elemento hacia la derecha:"),M=f(),k($.$$.fragment),v=f(),b=p("p"),T=l("Para modelados de lenguaje por enmascaramiento usa el mismo "),Z=p("code"),q=l("DataCollatorForLanguageModeling"),A=l(" excepto que deber\xE1s especificar "),J=p("code"),V=l("mlm_probability"),X=l(" para enmascarar tokens aleatoriamente cada vez que iteras sobre los datos."),D=f(),k(W.$$.fragment)},l(y){t=i(y,"P",{});var _=c(t);j=n(_,"Puedes usar el token de final de secuencia como el token de relleno y asignar "),r=i(_,"CODE",{});var Y=c(r);g=n(Y,"mlm=False"),Y.forEach(s),E=n(_,". Esto usar\xE1 los inputs como etiquetas movidas un elemento hacia la derecha:"),_.forEach(s),M=h(y),C($.$$.fragment,y),v=h(y),b=i(y,"P",{});var I=c(b);T=n(I,"Para modelados de lenguaje por enmascaramiento usa el mismo "),Z=i(I,"CODE",{});var B=c(Z);q=n(B,"DataCollatorForLanguageModeling"),B.forEach(s),A=n(I," excepto que deber\xE1s especificar "),J=i(I,"CODE",{});var L=c(J);V=n(L,"mlm_probability"),L.forEach(s),X=n(I," para enmascarar tokens aleatoriamente cada vez que iteras sobre los datos."),I.forEach(s),D=h(y),C(W.$$.fragment,y)},m(y,_){m(y,t,_),a(t,j),a(t,r),a(r,g),a(t,E),m(y,M,_),G($,y,_),m(y,v,_),m(y,b,_),a(b,T),a(b,Z),a(Z,q),a(b,A),a(b,J),a(J,V),a(b,X),m(y,D,_),G(W,y,_),Q=!0},p:un,i(y){Q||(x($.$$.fragment,y),x(W.$$.fragment,y),Q=!0)},o(y){R($.$$.fragment,y),R(W.$$.fragment,y),Q=!1},d(y){y&&s(t),y&&s(M),z($,y),y&&s(v),y&&s(b),y&&s(D),z(W,y)}}}function bn(N){let t,j;return t=new Ga({props:{$$slots:{default:[$n]},$$scope:{ctx:N}}}),{c(){k(t.$$.fragment)},l(r){C(t.$$.fragment,r)},m(r,g){G(t,r,g),j=!0},p(r,g){const E={};g&2&&(E.$$scope={dirty:g,ctx:r}),t.$set(E)},i(r){j||(x(t.$$.fragment,r),j=!0)},o(r){R(t.$$.fragment,r),j=!1},d(r){z(t,r)}}}function _n(N){let t,j,r,g,E,M,$,v,b,T,Z,q,A,J,V,X,D,W,Q;return $=new te({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMERhdGFDb2xsYXRvckZvckxhbmd1YWdlTW9kZWxpbmclMEElMEFkYXRhX2NvbGxhdG9yJTIwJTNEJTIwRGF0YUNvbGxhdG9yRm9yTGFuZ3VhZ2VNb2RlbGluZyh0b2tlbml6ZXIlM0R0b2tlbml6ZXIlMkMlMjBtbG0lM0RGYWxzZSUyQyUyMHJldHVybl90ZW5zb3JzJTNEJTIydGYlMjIp",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> DataCollatorForLanguageModeling

<span class="hljs-meta">&gt;&gt;&gt; </span>data_collator = DataCollatorForLanguageModeling(tokenizer=tokenizer, mlm=<span class="hljs-literal">False</span>, return_tensors=<span class="hljs-string">&quot;tf&quot;</span>)`}}),W=new te({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMERhdGFDb2xsYXRvckZvckxhbmd1YWdlTW9kZWxpbmclMEElMEFkYXRhX2NvbGxhdG9yJTIwJTNEJTIwRGF0YUNvbGxhdG9yRm9yTGFuZ3VhZ2VNb2RlbGluZyh0b2tlbml6ZXIlM0R0b2tlbml6ZXIlMkMlMjBtbG0lM0RGYWxzZSUyQyUyMHJldHVybl90ZW5zb3JzJTNEJTIydGYlMjIp",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> DataCollatorForLanguageModeling

<span class="hljs-meta">&gt;&gt;&gt; </span>data_collator = DataCollatorForLanguageModeling(tokenizer=tokenizer, mlm=<span class="hljs-literal">False</span>, return_tensors=<span class="hljs-string">&quot;tf&quot;</span>)`}}),{c(){t=p("p"),j=l("Puedes usar el token de final de secuencia como el token de relleno y asignar "),r=p("code"),g=l("mlm=False"),E=l(". Esto usar\xE1 los inputs como etiquetas movidas un elemento hacia la derecha:"),M=f(),k($.$$.fragment),v=f(),b=p("p"),T=l("Para modelados de lenguajes por enmascaramiento usa el mismo "),Z=p("code"),q=l("DataCollatorForLanguageModeling"),A=l(" excepto que deber\xE1s especificar "),J=p("code"),V=l("mlm_probability"),X=l(" para enmascarar tokens aleatoriamente cada vez que iteras sobre los datos."),D=f(),k(W.$$.fragment)},l(y){t=i(y,"P",{});var _=c(t);j=n(_,"Puedes usar el token de final de secuencia como el token de relleno y asignar "),r=i(_,"CODE",{});var Y=c(r);g=n(Y,"mlm=False"),Y.forEach(s),E=n(_,". Esto usar\xE1 los inputs como etiquetas movidas un elemento hacia la derecha:"),_.forEach(s),M=h(y),C($.$$.fragment,y),v=h(y),b=i(y,"P",{});var I=c(b);T=n(I,"Para modelados de lenguajes por enmascaramiento usa el mismo "),Z=i(I,"CODE",{});var B=c(Z);q=n(B,"DataCollatorForLanguageModeling"),B.forEach(s),A=n(I," excepto que deber\xE1s especificar "),J=i(I,"CODE",{});var L=c(J);V=n(L,"mlm_probability"),L.forEach(s),X=n(I," para enmascarar tokens aleatoriamente cada vez que iteras sobre los datos."),I.forEach(s),D=h(y),C(W.$$.fragment,y)},m(y,_){m(y,t,_),a(t,j),a(t,r),a(r,g),a(t,E),m(y,M,_),G($,y,_),m(y,v,_),m(y,b,_),a(b,T),a(b,Z),a(Z,q),a(b,A),a(b,J),a(J,V),a(b,X),m(y,D,_),G(W,y,_),Q=!0},p:un,i(y){Q||(x($.$$.fragment,y),x(W.$$.fragment,y),Q=!0)},o(y){R($.$$.fragment,y),R(W.$$.fragment,y),Q=!1},d(y){y&&s(t),y&&s(M),z($,y),y&&s(v),y&&s(b),y&&s(D),z(W,y)}}}function wn(N){let t,j;return t=new Ga({props:{$$slots:{default:[_n]},$$scope:{ctx:N}}}),{c(){k(t.$$.fragment)},l(r){C(t.$$.fragment,r)},m(r,g){G(t,r,g),j=!0},p(r,g){const E={};g&2&&(E.$$scope={dirty:g,ctx:r}),t.$set(E)},i(r){j||(x(t.$$.fragment,r),j=!0)},o(r){R(t.$$.fragment,r),j=!1},d(r){z(t,r)}}}function En(N){let t,j,r,g,E,M,$,v;return{c(){t=p("p"),j=l("Si no est\xE1s familiarizado con el proceso de realizar fine-tuning sobre un modelo con "),r=p("code"),g=l("Trainer"),E=l(", considera el tutorial b\xE1sico "),M=p("a"),$=l("aqu\xED"),v=l("!"),this.h()},l(b){t=i(b,"P",{});var T=c(t);j=n(T,"Si no est\xE1s familiarizado con el proceso de realizar fine-tuning sobre un modelo con "),r=i(T,"CODE",{});var Z=c(r);g=n(Z,"Trainer"),Z.forEach(s),E=n(T,", considera el tutorial b\xE1sico "),M=i(T,"A",{href:!0});var q=c(M);$=n(q,"aqu\xED"),q.forEach(s),v=n(T,"!"),T.forEach(s),this.h()},h(){w(M,"href","../training#finetune-with-trainer")},m(b,T){m(b,t,T),a(t,j),a(t,r),a(r,g),a(t,E),a(t,M),a(M,$),a(t,v)},d(b){b&&s(t)}}}function Un(N){let t,j,r,g,E,M,$,v,b,T,Z,q,A,J,V,X,D,W,Q,y,_,Y,I,B,L,ee,ae,ie,P,de,se,ne,S,oe;return $=new te({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMEF1dG9Nb2RlbEZvckNhdXNhbExNJTJDJTIwVHJhaW5pbmdBcmd1bWVudHMlMkMlMjBUcmFpbmVyJTBBJTBBbW9kZWwlMjAlM0QlMjBBdXRvTW9kZWxGb3JDYXVzYWxMTS5mcm9tX3ByZXRyYWluZWQoJTIyZGlzdGlsZ3B0MiUyMik=",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoModelForCausalLM, TrainingArguments, Trainer

<span class="hljs-meta">&gt;&gt;&gt; </span>model = AutoModelForCausalLM.from_pretrained(<span class="hljs-string">&quot;distilgpt2&quot;</span>)`}}),b=new Ca({props:{$$slots:{default:[En]},$$scope:{ctx:N}}}),S=new te({props:{code:"dHJhaW5pbmdfYXJncyUyMCUzRCUyMFRyYWluaW5nQXJndW1lbnRzKCUwQSUyMCUyMCUyMCUyMG91dHB1dF9kaXIlM0QlMjIuJTJGcmVzdWx0cyUyMiUyQyUwQSUyMCUyMCUyMCUyMGV2YWx1YXRpb25fc3RyYXRlZ3klM0QlMjJlcG9jaCUyMiUyQyUwQSUyMCUyMCUyMCUyMGxlYXJuaW5nX3JhdGUlM0QyZS01JTJDJTBBJTIwJTIwJTIwJTIwd2VpZ2h0X2RlY2F5JTNEMC4wMSUyQyUwQSklMEElMEF0cmFpbmVyJTIwJTNEJTIwVHJhaW5lciglMEElMjAlMjAlMjAlMjBtb2RlbCUzRG1vZGVsJTJDJTBBJTIwJTIwJTIwJTIwYXJncyUzRHRyYWluaW5nX2FyZ3MlMkMlMEElMjAlMjAlMjAlMjB0cmFpbl9kYXRhc2V0JTNEbG1fZGF0YXNldCU1QiUyMnRyYWluJTIyJTVEJTJDJTBBJTIwJTIwJTIwJTIwZXZhbF9kYXRhc2V0JTNEbG1fZGF0YXNldCU1QiUyMnRlc3QlMjIlNUQlMkMlMEElMjAlMjAlMjAlMjBkYXRhX2NvbGxhdG9yJTNEZGF0YV9jb2xsYXRvciUyQyUwQSklMEElMEF0cmFpbmVyLnRyYWluKCk=",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">2e-5</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=lm_dataset[<span class="hljs-string">&quot;train&quot;</span>],
<span class="hljs-meta">... </span>    eval_dataset=lm_dataset[<span class="hljs-string">&quot;test&quot;</span>],
<span class="hljs-meta">... </span>    data_collator=data_collator,
<span class="hljs-meta">... </span>)

<span class="hljs-meta">&gt;&gt;&gt; </span>trainer.train()`}}),{c(){t=p("p"),j=l("Carga DistilGPT2 con "),r=p("code"),g=l("AutoModelForCausalLM"),E=l(":"),M=f(),k($.$$.fragment),v=f(),k(b.$$.fragment),T=f(),Z=p("p"),q=l("A este punto, solo faltan tres pasos:"),A=f(),J=p("ol"),V=p("li"),X=l("Definir tus hiperpar\xE1metros de entrenamiento en "),D=p("code"),W=l("TrainingArguments"),Q=l("."),y=f(),_=p("li"),Y=l("Pasarle los argumentos de entrenamiento a "),I=p("code"),B=l("Trainer"),L=l(" junto con el modelo, dataset, y el data collator."),ee=f(),ae=p("li"),ie=l("Realiza la llamada "),P=p("code"),de=l("train()"),se=l(" para realizar el fine-tuning sobre tu modelo."),ne=f(),k(S.$$.fragment)},l(d){t=i(d,"P",{});var F=c(t);j=n(F,"Carga DistilGPT2 con "),r=i(F,"CODE",{});var re=c(r);g=n(re,"AutoModelForCausalLM"),re.forEach(s),E=n(F,":"),F.forEach(s),M=h(d),C($.$$.fragment,d),v=h(d),C(b.$$.fragment,d),T=h(d),Z=i(d,"P",{});var le=c(Z);q=n(le,"A este punto, solo faltan tres pasos:"),le.forEach(s),A=h(d),J=i(d,"OL",{});var O=c(J);V=i(O,"LI",{});var K=c(V);X=n(K,"Definir tus hiperpar\xE1metros de entrenamiento en "),D=i(K,"CODE",{});var ce=c(D);W=n(ce,"TrainingArguments"),ce.forEach(s),Q=n(K,"."),K.forEach(s),y=h(O),_=i(O,"LI",{});var H=c(_);Y=n(H,"Pasarle los argumentos de entrenamiento a "),I=i(H,"CODE",{});var me=c(I);B=n(me,"Trainer"),me.forEach(s),L=n(H," junto con el modelo, dataset, y el data collator."),H.forEach(s),ee=h(O),ae=i(O,"LI",{});var pe=c(ae);ie=n(pe,"Realiza la llamada "),P=i(pe,"CODE",{});var fe=c(P);de=n(fe,"train()"),fe.forEach(s),se=n(pe," para realizar el fine-tuning sobre tu modelo."),pe.forEach(s),O.forEach(s),ne=h(d),C(S.$$.fragment,d)},m(d,F){m(d,t,F),a(t,j),a(t,r),a(r,g),a(t,E),m(d,M,F),G($,d,F),m(d,v,F),G(b,d,F),m(d,T,F),m(d,Z,F),a(Z,q),m(d,A,F),m(d,J,F),a(J,V),a(V,X),a(V,D),a(D,W),a(V,Q),a(J,y),a(J,_),a(_,Y),a(_,I),a(I,B),a(_,L),a(J,ee),a(J,ae),a(ae,ie),a(ae,P),a(P,de),a(ae,se),m(d,ne,F),G(S,d,F),oe=!0},p(d,F){const re={};F&2&&(re.$$scope={dirty:F,ctx:d}),b.$set(re)},i(d){oe||(x($.$$.fragment,d),x(b.$$.fragment,d),x(S.$$.fragment,d),oe=!0)},o(d){R($.$$.fragment,d),R(b.$$.fragment,d),R(S.$$.fragment,d),oe=!1},d(d){d&&s(t),d&&s(M),z($,d),d&&s(v),z(b,d),d&&s(T),d&&s(Z),d&&s(A),d&&s(J),d&&s(ne),z(S,d)}}}function Tn(N){let t,j;return t=new Ga({props:{$$slots:{default:[Un]},$$scope:{ctx:N}}}),{c(){k(t.$$.fragment)},l(r){C(t.$$.fragment,r)},m(r,g){G(t,r,g),j=!0},p(r,g){const E={};g&2&&(E.$$scope={dirty:g,ctx:r}),t.$set(E)},i(r){j||(x(t.$$.fragment,r),j=!0)},o(r){R(t.$$.fragment,r),j=!1},d(r){z(t,r)}}}function Jn(N){let t,j,r,g,E;return{c(){t=p("p"),j=l("Si no est\xE1s familiarizado con realizar fine-tuning de tus modelos con Keras, considera el tutorial b\xE1sico "),r=p("a"),g=l("aqu\xED"),E=l("!"),this.h()},l(M){t=i(M,"P",{});var $=c(t);j=n($,"Si no est\xE1s familiarizado con realizar fine-tuning de tus modelos con Keras, considera el tutorial b\xE1sico "),r=i($,"A",{href:!0});var v=c(r);g=n(v,"aqu\xED"),v.forEach(s),E=n($,"!"),$.forEach(s),this.h()},h(){w(r,"href","training#finetune-with-keras")},m(M,$){m(M,t,$),a(t,j),a(t,r),a(r,g),a(t,E)},d(M){M&&s(t)}}}function vn(N){let t,j,r,g,E,M,$,v,b,T,Z,q,A,J,V,X,D,W,Q,y,_,Y,I,B,L,ee,ae,ie,P,de,se,ne,S,oe,d,F,re,le,O,K,ce,H,me,pe,fe,ge,ue,ye;return J=new te({props:{code:"dGZfdHJhaW5fc2V0JTIwJTNEJTIwbG1fZGF0YXNldCU1QiUyMnRyYWluJTIyJTVELnRvX3RmX2RhdGFzZXQoJTBBJTIwJTIwJTIwJTIwY29sdW1ucyUzRCU1QiUyMmF0dGVudGlvbl9tYXNrJTIyJTJDJTIwJTIyaW5wdXRfaWRzJTIyJTJDJTIwJTIybGFiZWxzJTIyJTVEJTJDJTBBJTIwJTIwJTIwJTIwZHVtbXlfbGFiZWxzJTNEVHJ1ZSUyQyUwQSUyMCUyMCUyMCUyMHNodWZmbGUlM0RUcnVlJTJDJTBBJTIwJTIwJTIwJTIwYmF0Y2hfc2l6ZSUzRDE2JTJDJTBBJTIwJTIwJTIwJTIwY29sbGF0ZV9mbiUzRGRhdGFfY29sbGF0b3IlMkMlMEEpJTBBJTBBdGZfdGVzdF9zZXQlMjAlM0QlMjBsbV9kYXRhc2V0JTVCJTIydGVzdCUyMiU1RC50b190Zl9kYXRhc2V0KCUwQSUyMCUyMCUyMCUyMGNvbHVtbnMlM0QlNUIlMjJhdHRlbnRpb25fbWFzayUyMiUyQyUyMCUyMmlucHV0X2lkcyUyMiUyQyUyMCUyMmxhYmVscyUyMiU1RCUyQyUwQSUyMCUyMCUyMCUyMGR1bW15X2xhYmVscyUzRFRydWUlMkMlMEElMjAlMjAlMjAlMjBzaHVmZmxlJTNERmFsc2UlMkMlMEElMjAlMjAlMjAlMjBiYXRjaF9zaXplJTNEMTYlMkMlMEElMjAlMjAlMjAlMjBjb2xsYXRlX2ZuJTNEZGF0YV9jb2xsYXRvciUyQyUwQSk=",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span>tf_train_set = lm_dataset[<span class="hljs-string">&quot;train&quot;</span>].to_tf_dataset(
<span class="hljs-meta">... </span>    columns=[<span class="hljs-string">&quot;attention_mask&quot;</span>, <span class="hljs-string">&quot;input_ids&quot;</span>, <span class="hljs-string">&quot;labels&quot;</span>],
<span class="hljs-meta">... </span>    dummy_labels=<span class="hljs-literal">True</span>,
<span class="hljs-meta">... </span>    shuffle=<span class="hljs-literal">True</span>,
<span class="hljs-meta">... </span>    batch_size=<span class="hljs-number">16</span>,
<span class="hljs-meta">... </span>    collate_fn=data_collator,
<span class="hljs-meta">... </span>)

<span class="hljs-meta">&gt;&gt;&gt; </span>tf_test_set = lm_dataset[<span class="hljs-string">&quot;test&quot;</span>].to_tf_dataset(
<span class="hljs-meta">... </span>    columns=[<span class="hljs-string">&quot;attention_mask&quot;</span>, <span class="hljs-string">&quot;input_ids&quot;</span>, <span class="hljs-string">&quot;labels&quot;</span>],
<span class="hljs-meta">... </span>    dummy_labels=<span class="hljs-literal">True</span>,
<span class="hljs-meta">... </span>    shuffle=<span class="hljs-literal">False</span>,
<span class="hljs-meta">... </span>    batch_size=<span class="hljs-number">16</span>,
<span class="hljs-meta">... </span>    collate_fn=data_collator,
<span class="hljs-meta">... </span>)`}}),X=new Ca({props:{$$slots:{default:[Jn]},$$scope:{ctx:N}}}),_=new te({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMGNyZWF0ZV9vcHRpbWl6ZXIlMkMlMjBBZGFtV2VpZ2h0RGVjYXklMEElMEFvcHRpbWl6ZXIlMjAlM0QlMjBBZGFtV2VpZ2h0RGVjYXkobGVhcm5pbmdfcmF0ZSUzRDJlLTUlMkMlMjB3ZWlnaHRfZGVjYXlfcmF0ZSUzRDAuMDEp",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> create_optimizer, AdamWeightDecay

<span class="hljs-meta">&gt;&gt;&gt; </span>optimizer = AdamWeightDecay(learning_rate=<span class="hljs-number">2e-5</span>, weight_decay_rate=<span class="hljs-number">0.01</span>)`}}),P=new te({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMFRGQXV0b01vZGVsRm9yQ2F1c2FsTE0lMEElMEFtb2RlbCUyMCUzRCUyMFRGQXV0b01vZGVsRm9yQ2F1c2FsTE0uZnJvbV9wcmV0cmFpbmVkKCUyMmRpc3RpbGdwdDIlMjIp",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> TFAutoModelForCausalLM

<span class="hljs-meta">&gt;&gt;&gt; </span>model = TFAutoModelForCausalLM.from_pretrained(<span class="hljs-string">&quot;distilgpt2&quot;</span>)`}}),le=new te({props:{code:"aW1wb3J0JTIwdGVuc29yZmxvdyUyMGFzJTIwdGYlMEElMEFtb2RlbC5jb21waWxlKG9wdGltaXplciUzRG9wdGltaXplcik=",highlighted:`<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>model.<span class="hljs-built_in">compile</span>(optimizer=optimizer)`}}),ue=new te({props:{code:"bW9kZWwuZml0KHglM0R0Zl90cmFpbl9zZXQlMkMlMjB2YWxpZGF0aW9uX2RhdGElM0R0Zl90ZXN0X3NldCUyQyUyMGVwb2NocyUzRDMp",highlighted:'<span class="hljs-meta">&gt;&gt;&gt; </span>model.fit(x=tf_train_set, validation_data=tf_test_set, epochs=<span class="hljs-number">3</span>)'}}),{c(){t=p("p"),j=l("Para realizar el fine-tuning de un modelo en TensorFlow, comienza por convertir tus datasets al formato "),r=p("code"),g=l("tf.data.Dataset"),E=l(" con "),M=p("a"),$=p("code"),v=l("to_tf_dataset"),b=l(". Especifica los inputs y etiquetas en "),T=p("code"),Z=l("columns"),q=l(", ya sea para mezclar el dataset, tama\xF1o de lote, y el data collator:"),A=f(),k(J.$$.fragment),V=f(),k(X.$$.fragment),D=f(),W=p("p"),Q=l("Crea la funci\xF3n optimizadora, la tasa de aprendizaje, y algunos hiperpar\xE1metros de entrenamiento:"),y=f(),k(_.$$.fragment),Y=f(),I=p("p"),B=l("Carga DistilGPT2 con "),L=p("code"),ee=l("TFAutoModelForCausalLM"),ae=l(":"),ie=f(),k(P.$$.fragment),de=f(),se=p("p"),ne=l("Configura el modelo para entrenamiento con "),S=p("a"),oe=p("code"),d=l("compile"),F=l(":"),re=f(),k(le.$$.fragment),O=f(),K=p("p"),ce=l("Llama a "),H=p("a"),me=p("code"),pe=l("fit"),fe=l(" para realizar el fine-tuning del modelo:"),ge=f(),k(ue.$$.fragment),this.h()},l(o){t=i(o,"P",{});var U=c(t);j=n(U,"Para realizar el fine-tuning de un modelo en TensorFlow, comienza por convertir tus datasets al formato "),r=i(U,"CODE",{});var he=c(r);g=n(he,"tf.data.Dataset"),he.forEach(s),E=n(U," con "),M=i(U,"A",{href:!0,rel:!0});var we=c(M);$=i(we,"CODE",{});var ke=c($);v=n(ke,"to_tf_dataset"),ke.forEach(s),we.forEach(s),b=n(U,". Especifica los inputs y etiquetas en "),T=i(U,"CODE",{});var Te=c(T);Z=n(Te,"columns"),Te.forEach(s),q=n(U,", ya sea para mezclar el dataset, tama\xF1o de lote, y el data collator:"),U.forEach(s),A=h(o),C(J.$$.fragment,o),V=h(o),C(X.$$.fragment,o),D=h(o),W=i(o,"P",{});var Ie=c(W);Q=n(Ie,"Crea la funci\xF3n optimizadora, la tasa de aprendizaje, y algunos hiperpar\xE1metros de entrenamiento:"),Ie.forEach(s),y=h(o),C(_.$$.fragment,o),Y=h(o),I=i(o,"P",{});var Me=c(I);B=n(Me,"Carga DistilGPT2 con "),L=i(Me,"CODE",{});var Ee=c(L);ee=n(Ee,"TFAutoModelForCausalLM"),Ee.forEach(s),ae=n(Me,":"),Me.forEach(s),ie=h(o),C(P.$$.fragment,o),de=h(o),se=i(o,"P",{});var je=c(se);ne=n(je,"Configura el modelo para entrenamiento con "),S=i(je,"A",{href:!0,rel:!0});var Je=c(S);oe=i(Je,"CODE",{});var Fe=c(oe);d=n(Fe,"compile"),Fe.forEach(s),Je.forEach(s),F=n(je,":"),je.forEach(s),re=h(o),C(le.$$.fragment,o),O=h(o),K=i(o,"P",{});var $e=c(K);ce=n($e,"Llama a "),H=i($e,"A",{href:!0,rel:!0});var Ue=c(H);me=i(Ue,"CODE",{});var Ce=c(me);pe=n(Ce,"fit"),Ce.forEach(s),Ue.forEach(s),fe=n($e," para realizar el fine-tuning del modelo:"),$e.forEach(s),ge=h(o),C(ue.$$.fragment,o),this.h()},h(){w(M,"href","https://huggingface.co/docs/datasets/package_reference/main_classes.html#datasets.Dataset.to_tf_dataset"),w(M,"rel","nofollow"),w(S,"href","https://keras.io/api/models/model_training_apis/#compile-method"),w(S,"rel","nofollow"),w(H,"href","https://keras.io/api/models/model_training_apis/#fit-method"),w(H,"rel","nofollow")},m(o,U){m(o,t,U),a(t,j),a(t,r),a(r,g),a(t,E),a(t,M),a(M,$),a($,v),a(t,b),a(t,T),a(T,Z),a(t,q),m(o,A,U),G(J,o,U),m(o,V,U),G(X,o,U),m(o,D,U),m(o,W,U),a(W,Q),m(o,y,U),G(_,o,U),m(o,Y,U),m(o,I,U),a(I,B),a(I,L),a(L,ee),a(I,ae),m(o,ie,U),G(P,o,U),m(o,de,U),m(o,se,U),a(se,ne),a(se,S),a(S,oe),a(oe,d),a(se,F),m(o,re,U),G(le,o,U),m(o,O,U),m(o,K,U),a(K,ce),a(K,H),a(H,me),a(me,pe),a(K,fe),m(o,ge,U),G(ue,o,U),ye=!0},p(o,U){const he={};U&2&&(he.$$scope={dirty:U,ctx:o}),X.$set(he)},i(o){ye||(x(J.$$.fragment,o),x(X.$$.fragment,o),x(_.$$.fragment,o),x(P.$$.fragment,o),x(le.$$.fragment,o),x(ue.$$.fragment,o),ye=!0)},o(o){R(J.$$.fragment,o),R(X.$$.fragment,o),R(_.$$.fragment,o),R(P.$$.fragment,o),R(le.$$.fragment,o),R(ue.$$.fragment,o),ye=!1},d(o){o&&s(t),o&&s(A),z(J,o),o&&s(V),z(X,o),o&&s(D),o&&s(W),o&&s(y),z(_,o),o&&s(Y),o&&s(I),o&&s(ie),z(P,o),o&&s(de),o&&s(se),o&&s(re),z(le,o),o&&s(O),o&&s(K),o&&s(ge),z(ue,o)}}}function kn(N){let t,j;return t=new Ga({props:{$$slots:{default:[vn]},$$scope:{ctx:N}}}),{c(){k(t.$$.fragment)},l(r){C(t.$$.fragment,r)},m(r,g){G(t,r,g),j=!0},p(r,g){const E={};g&2&&(E.$$scope={dirty:g,ctx:r}),t.$set(E)},i(r){j||(x(t.$$.fragment,r),j=!0)},o(r){R(t.$$.fragment,r),j=!1},d(r){z(t,r)}}}function Cn(N){let t,j,r,g,E,M,$,v;return{c(){t=p("p"),j=l("Si no est\xE1s familiarizado con el proceso de realizar fine-tuning sobre un modelo con "),r=p("code"),g=l("Trainer"),E=l(", considera el tutorial b\xE1sico "),M=p("a"),$=l("aqu\xED"),v=l("!"),this.h()},l(b){t=i(b,"P",{});var T=c(t);j=n(T,"Si no est\xE1s familiarizado con el proceso de realizar fine-tuning sobre un modelo con "),r=i(T,"CODE",{});var Z=c(r);g=n(Z,"Trainer"),Z.forEach(s),E=n(T,", considera el tutorial b\xE1sico "),M=i(T,"A",{href:!0});var q=c(M);$=n(q,"aqu\xED"),q.forEach(s),v=n(T,"!"),T.forEach(s),this.h()},h(){w(M,"href","../training#finetune-with-trainer")},m(b,T){m(b,t,T),a(t,j),a(t,r),a(r,g),a(t,E),a(t,M),a(M,$),a(t,v)},d(b){b&&s(t)}}}function Gn(N){let t,j,r,g,E,M,$,v,b,T,Z,q,A,J,V,X,D,W,Q,y,_,Y,I,B,L,ee,ae,ie,P,de,se,ne,S,oe;return $=new te({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMEF1dG9Nb2RlbEZvck1hc2tlZExNJTBBJTBBbW9kZWwlMjAlM0QlMjBBdXRvTW9kZWxGb3JNYXNrZWRMTS5mcm9tX3ByZXRyYWluZWQoJTIyZGlzdGlscm9iZXJ0YS1iYXNlJTIyKQ==",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoModelForMaskedLM

<span class="hljs-meta">&gt;&gt;&gt; </span>model = AutoModelForMaskedLM.from_pretrained(<span class="hljs-string">&quot;distilroberta-base&quot;</span>)`}}),b=new Ca({props:{$$slots:{default:[Cn]},$$scope:{ctx:N}}}),S=new te({props:{code:"dHJhaW5pbmdfYXJncyUyMCUzRCUyMFRyYWluaW5nQXJndW1lbnRzKCUwQSUyMCUyMCUyMCUyMG91dHB1dF9kaXIlM0QlMjIuJTJGcmVzdWx0cyUyMiUyQyUwQSUyMCUyMCUyMCUyMGV2YWx1YXRpb25fc3RyYXRlZ3klM0QlMjJlcG9jaCUyMiUyQyUwQSUyMCUyMCUyMCUyMGxlYXJuaW5nX3JhdGUlM0QyZS01JTJDJTBBJTIwJTIwJTIwJTIwbnVtX3RyYWluX2Vwb2NocyUzRDMlMkMlMEElMjAlMjAlMjAlMjB3ZWlnaHRfZGVjYXklM0QwLjAxJTJDJTBBKSUwQSUwQXRyYWluZXIlMjAlM0QlMjBUcmFpbmVyKCUwQSUyMCUyMCUyMCUyMG1vZGVsJTNEbW9kZWwlMkMlMEElMjAlMjAlMjAlMjBhcmdzJTNEdHJhaW5pbmdfYXJncyUyQyUwQSUyMCUyMCUyMCUyMHRyYWluX2RhdGFzZXQlM0RsbV9kYXRhc2V0JTVCJTIydHJhaW4lMjIlNUQlMkMlMEElMjAlMjAlMjAlMjBldmFsX2RhdGFzZXQlM0RsbV9kYXRhc2V0JTVCJTIydGVzdCUyMiU1RCUyQyUwQSUyMCUyMCUyMCUyMGRhdGFfY29sbGF0b3IlM0RkYXRhX2NvbGxhdG9yJTJDJTBBKSUwQSUwQXRyYWluZXIudHJhaW4oKQ==",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">2e-5</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=lm_dataset[<span class="hljs-string">&quot;train&quot;</span>],
<span class="hljs-meta">... </span>    eval_dataset=lm_dataset[<span class="hljs-string">&quot;test&quot;</span>],
<span class="hljs-meta">... </span>    data_collator=data_collator,
<span class="hljs-meta">... </span>)

<span class="hljs-meta">&gt;&gt;&gt; </span>trainer.train()`}}),{c(){t=p("p"),j=l("Carga DistilRoBERTa con "),r=p("code"),g=l("AutoModelForMaskedlM"),E=l(":"),M=f(),k($.$$.fragment),v=f(),k(b.$$.fragment),T=f(),Z=p("p"),q=l("A este punto, solo faltan tres pasos:"),A=f(),J=p("ol"),V=p("li"),X=l("Definir tus hiperpar\xE1metros de entrenamiento en "),D=p("code"),W=l("TrainingArguments"),Q=l("."),y=f(),_=p("li"),Y=l("Pasarle los argumentos de entrenamiento a "),I=p("code"),B=l("Trainer"),L=l(" junto con el modelo, dataset, y el data collator."),ee=f(),ae=p("li"),ie=l("Realiza la llamada "),P=p("code"),de=l("train()"),se=l(" para realizar el fine-tuning de tu modelo."),ne=f(),k(S.$$.fragment)},l(d){t=i(d,"P",{});var F=c(t);j=n(F,"Carga DistilRoBERTa con "),r=i(F,"CODE",{});var re=c(r);g=n(re,"AutoModelForMaskedlM"),re.forEach(s),E=n(F,":"),F.forEach(s),M=h(d),C($.$$.fragment,d),v=h(d),C(b.$$.fragment,d),T=h(d),Z=i(d,"P",{});var le=c(Z);q=n(le,"A este punto, solo faltan tres pasos:"),le.forEach(s),A=h(d),J=i(d,"OL",{});var O=c(J);V=i(O,"LI",{});var K=c(V);X=n(K,"Definir tus hiperpar\xE1metros de entrenamiento en "),D=i(K,"CODE",{});var ce=c(D);W=n(ce,"TrainingArguments"),ce.forEach(s),Q=n(K,"."),K.forEach(s),y=h(O),_=i(O,"LI",{});var H=c(_);Y=n(H,"Pasarle los argumentos de entrenamiento a "),I=i(H,"CODE",{});var me=c(I);B=n(me,"Trainer"),me.forEach(s),L=n(H," junto con el modelo, dataset, y el data collator."),H.forEach(s),ee=h(O),ae=i(O,"LI",{});var pe=c(ae);ie=n(pe,"Realiza la llamada "),P=i(pe,"CODE",{});var fe=c(P);de=n(fe,"train()"),fe.forEach(s),se=n(pe," para realizar el fine-tuning de tu modelo."),pe.forEach(s),O.forEach(s),ne=h(d),C(S.$$.fragment,d)},m(d,F){m(d,t,F),a(t,j),a(t,r),a(r,g),a(t,E),m(d,M,F),G($,d,F),m(d,v,F),G(b,d,F),m(d,T,F),m(d,Z,F),a(Z,q),m(d,A,F),m(d,J,F),a(J,V),a(V,X),a(V,D),a(D,W),a(V,Q),a(J,y),a(J,_),a(_,Y),a(_,I),a(I,B),a(_,L),a(J,ee),a(J,ae),a(ae,ie),a(ae,P),a(P,de),a(ae,se),m(d,ne,F),G(S,d,F),oe=!0},p(d,F){const re={};F&2&&(re.$$scope={dirty:F,ctx:d}),b.$set(re)},i(d){oe||(x($.$$.fragment,d),x(b.$$.fragment,d),x(S.$$.fragment,d),oe=!0)},o(d){R($.$$.fragment,d),R(b.$$.fragment,d),R(S.$$.fragment,d),oe=!1},d(d){d&&s(t),d&&s(M),z($,d),d&&s(v),z(b,d),d&&s(T),d&&s(Z),d&&s(A),d&&s(J),d&&s(ne),z(S,d)}}}function xn(N){let t,j;return t=new Ga({props:{$$slots:{default:[Gn]},$$scope:{ctx:N}}}),{c(){k(t.$$.fragment)},l(r){C(t.$$.fragment,r)},m(r,g){G(t,r,g),j=!0},p(r,g){const E={};g&2&&(E.$$scope={dirty:g,ctx:r}),t.$set(E)},i(r){j||(x(t.$$.fragment,r),j=!0)},o(r){R(t.$$.fragment,r),j=!1},d(r){z(t,r)}}}function Rn(N){let t,j,r,g,E;return{c(){t=p("p"),j=l("Si no est\xE1s familiarizado con realizar fine-tuning de tus modelos con Keras, considera el tutorial b\xE1sico "),r=p("a"),g=l("aqu\xED"),E=l("!"),this.h()},l(M){t=i(M,"P",{});var $=c(t);j=n($,"Si no est\xE1s familiarizado con realizar fine-tuning de tus modelos con Keras, considera el tutorial b\xE1sico "),r=i($,"A",{href:!0});var v=c(r);g=n(v,"aqu\xED"),v.forEach(s),E=n($,"!"),$.forEach(s),this.h()},h(){w(r,"href","training#finetune-with-keras")},m(M,$){m(M,t,$),a(t,j),a(t,r),a(r,g),a(t,E)},d(M){M&&s(t)}}}function zn(N){let t,j,r,g,E,M,$,v,b,T,Z,q,A,J,V,X,D,W,Q,y,_,Y,I,B,L,ee,ae,ie,P,de,se,ne,S,oe,d,F,re,le,O,K,ce,H,me,pe,fe,ge,ue,ye;return J=new te({props:{code:"dGZfdHJhaW5fc2V0JTIwJTNEJTIwbG1fZGF0YXNldCU1QiUyMnRyYWluJTIyJTVELnRvX3RmX2RhdGFzZXQoJTBBJTIwJTIwJTIwJTIwY29sdW1ucyUzRCU1QiUyMmF0dGVudGlvbl9tYXNrJTIyJTJDJTIwJTIyaW5wdXRfaWRzJTIyJTJDJTIwJTIybGFiZWxzJTIyJTVEJTJDJTBBJTIwJTIwJTIwJTIwZHVtbXlfbGFiZWxzJTNEVHJ1ZSUyQyUwQSUyMCUyMCUyMCUyMHNodWZmbGUlM0RUcnVlJTJDJTBBJTIwJTIwJTIwJTIwYmF0Y2hfc2l6ZSUzRDE2JTJDJTBBJTIwJTIwJTIwJTIwY29sbGF0ZV9mbiUzRGRhdGFfY29sbGF0b3IlMkMlMEEpJTBBJTBBdGZfdGVzdF9zZXQlMjAlM0QlMjBsbV9kYXRhc2V0JTVCJTIydGVzdCUyMiU1RC50b190Zl9kYXRhc2V0KCUwQSUyMCUyMCUyMCUyMGNvbHVtbnMlM0QlNUIlMjJhdHRlbnRpb25fbWFzayUyMiUyQyUyMCUyMmlucHV0X2lkcyUyMiUyQyUyMCUyMmxhYmVscyUyMiU1RCUyQyUwQSUyMCUyMCUyMCUyMGR1bW15X2xhYmVscyUzRFRydWUlMkMlMEElMjAlMjAlMjAlMjBzaHVmZmxlJTNERmFsc2UlMkMlMEElMjAlMjAlMjAlMjBiYXRjaF9zaXplJTNEMTYlMkMlMEElMjAlMjAlMjAlMjBjb2xsYXRlX2ZuJTNEZGF0YV9jb2xsYXRvciUyQyUwQSk=",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span>tf_train_set = lm_dataset[<span class="hljs-string">&quot;train&quot;</span>].to_tf_dataset(
<span class="hljs-meta">... </span>    columns=[<span class="hljs-string">&quot;attention_mask&quot;</span>, <span class="hljs-string">&quot;input_ids&quot;</span>, <span class="hljs-string">&quot;labels&quot;</span>],
<span class="hljs-meta">... </span>    dummy_labels=<span class="hljs-literal">True</span>,
<span class="hljs-meta">... </span>    shuffle=<span class="hljs-literal">True</span>,
<span class="hljs-meta">... </span>    batch_size=<span class="hljs-number">16</span>,
<span class="hljs-meta">... </span>    collate_fn=data_collator,
<span class="hljs-meta">... </span>)

<span class="hljs-meta">&gt;&gt;&gt; </span>tf_test_set = lm_dataset[<span class="hljs-string">&quot;test&quot;</span>].to_tf_dataset(
<span class="hljs-meta">... </span>    columns=[<span class="hljs-string">&quot;attention_mask&quot;</span>, <span class="hljs-string">&quot;input_ids&quot;</span>, <span class="hljs-string">&quot;labels&quot;</span>],
<span class="hljs-meta">... </span>    dummy_labels=<span class="hljs-literal">True</span>,
<span class="hljs-meta">... </span>    shuffle=<span class="hljs-literal">False</span>,
<span class="hljs-meta">... </span>    batch_size=<span class="hljs-number">16</span>,
<span class="hljs-meta">... </span>    collate_fn=data_collator,
<span class="hljs-meta">... </span>)`}}),X=new Ca({props:{$$slots:{default:[Rn]},$$scope:{ctx:N}}}),_=new te({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMGNyZWF0ZV9vcHRpbWl6ZXIlMkMlMjBBZGFtV2VpZ2h0RGVjYXklMEElMEFvcHRpbWl6ZXIlMjAlM0QlMjBBZGFtV2VpZ2h0RGVjYXkobGVhcm5pbmdfcmF0ZSUzRDJlLTUlMkMlMjB3ZWlnaHRfZGVjYXlfcmF0ZSUzRDAuMDEp",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> create_optimizer, AdamWeightDecay

<span class="hljs-meta">&gt;&gt;&gt; </span>optimizer = AdamWeightDecay(learning_rate=<span class="hljs-number">2e-5</span>, weight_decay_rate=<span class="hljs-number">0.01</span>)`}}),P=new te({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMFRGQXV0b01vZGVsRm9yTWFza2VkTE0lMEElMEFtb2RlbCUyMCUzRCUyMFRGQXV0b01vZGVsRm9yQ2F1c2FsTE0uZnJvbV9wcmV0cmFpbmVkKCUyMmRpc3RpbHJvYmVydGEtYmFzZSUyMik=",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> TFAutoModelForMaskedLM

<span class="hljs-meta">&gt;&gt;&gt; </span>model = TFAutoModelForCausalLM.from_pretrained(<span class="hljs-string">&quot;distilroberta-base&quot;</span>)`}}),le=new te({props:{code:"aW1wb3J0JTIwdGVuc29yZmxvdyUyMGFzJTIwdGYlMEElMEFtb2RlbC5jb21waWxlKG9wdGltaXplciUzRG9wdGltaXplcik=",highlighted:`<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>model.<span class="hljs-built_in">compile</span>(optimizer=optimizer)`}}),ue=new te({props:{code:"bW9kZWwuZml0KHglM0R0Zl90cmFpbl9zZXQlMkMlMjB2YWxpZGF0aW9uX2RhdGElM0R0Zl90ZXN0X3NldCUyQyUyMGVwb2NocyUzRDMp",highlighted:'<span class="hljs-meta">&gt;&gt;&gt; </span>model.fit(x=tf_train_set, validation_data=tf_test_set, epochs=<span class="hljs-number">3</span>)'}}),{c(){t=p("p"),j=l("Para realizar el fine-tuning de un modelo en TensorFlow, comienza por convertir tus datasets al formato "),r=p("code"),g=l("tf.data.Dataset"),E=l(" con "),M=p("a"),$=p("code"),v=l("to_tf_dataset"),b=l(". Especifica los inputs y etiquetas en "),T=p("code"),Z=l("columns"),q=l(", ya sea para mezclar el dataset, tama\xF1o de lote, y el data collator:"),A=f(),k(J.$$.fragment),V=f(),k(X.$$.fragment),D=f(),W=p("p"),Q=l("Crea la funci\xF3n optimizadora, la tasa de aprendizaje, y algunos hiperpar\xE1metros de entrenamiento:"),y=f(),k(_.$$.fragment),Y=f(),I=p("p"),B=l("Carga DistilRoBERTa con "),L=p("code"),ee=l("TFAutoModelForMaskedLM"),ae=l(":"),ie=f(),k(P.$$.fragment),de=f(),se=p("p"),ne=l("Configura el modelo para entrenamiento con "),S=p("a"),oe=p("code"),d=l("compile"),F=l(":"),re=f(),k(le.$$.fragment),O=f(),K=p("p"),ce=l("Llama a "),H=p("a"),me=p("code"),pe=l("fit"),fe=l(" para realizar el fine-tuning del modelo:"),ge=f(),k(ue.$$.fragment),this.h()},l(o){t=i(o,"P",{});var U=c(t);j=n(U,"Para realizar el fine-tuning de un modelo en TensorFlow, comienza por convertir tus datasets al formato "),r=i(U,"CODE",{});var he=c(r);g=n(he,"tf.data.Dataset"),he.forEach(s),E=n(U," con "),M=i(U,"A",{href:!0,rel:!0});var we=c(M);$=i(we,"CODE",{});var ke=c($);v=n(ke,"to_tf_dataset"),ke.forEach(s),we.forEach(s),b=n(U,". Especifica los inputs y etiquetas en "),T=i(U,"CODE",{});var Te=c(T);Z=n(Te,"columns"),Te.forEach(s),q=n(U,", ya sea para mezclar el dataset, tama\xF1o de lote, y el data collator:"),U.forEach(s),A=h(o),C(J.$$.fragment,o),V=h(o),C(X.$$.fragment,o),D=h(o),W=i(o,"P",{});var Ie=c(W);Q=n(Ie,"Crea la funci\xF3n optimizadora, la tasa de aprendizaje, y algunos hiperpar\xE1metros de entrenamiento:"),Ie.forEach(s),y=h(o),C(_.$$.fragment,o),Y=h(o),I=i(o,"P",{});var Me=c(I);B=n(Me,"Carga DistilRoBERTa con "),L=i(Me,"CODE",{});var Ee=c(L);ee=n(Ee,"TFAutoModelForMaskedLM"),Ee.forEach(s),ae=n(Me,":"),Me.forEach(s),ie=h(o),C(P.$$.fragment,o),de=h(o),se=i(o,"P",{});var je=c(se);ne=n(je,"Configura el modelo para entrenamiento con "),S=i(je,"A",{href:!0,rel:!0});var Je=c(S);oe=i(Je,"CODE",{});var Fe=c(oe);d=n(Fe,"compile"),Fe.forEach(s),Je.forEach(s),F=n(je,":"),je.forEach(s),re=h(o),C(le.$$.fragment,o),O=h(o),K=i(o,"P",{});var $e=c(K);ce=n($e,"Llama a "),H=i($e,"A",{href:!0,rel:!0});var Ue=c(H);me=i(Ue,"CODE",{});var Ce=c(me);pe=n(Ce,"fit"),Ce.forEach(s),Ue.forEach(s),fe=n($e," para realizar el fine-tuning del modelo:"),$e.forEach(s),ge=h(o),C(ue.$$.fragment,o),this.h()},h(){w(M,"href","https://huggingface.co/docs/datasets/package_reference/main_classes.html#datasets.Dataset.to_tf_dataset"),w(M,"rel","nofollow"),w(S,"href","https://keras.io/api/models/model_training_apis/#compile-method"),w(S,"rel","nofollow"),w(H,"href","https://keras.io/api/models/model_training_apis/#fit-method"),w(H,"rel","nofollow")},m(o,U){m(o,t,U),a(t,j),a(t,r),a(r,g),a(t,E),a(t,M),a(M,$),a($,v),a(t,b),a(t,T),a(T,Z),a(t,q),m(o,A,U),G(J,o,U),m(o,V,U),G(X,o,U),m(o,D,U),m(o,W,U),a(W,Q),m(o,y,U),G(_,o,U),m(o,Y,U),m(o,I,U),a(I,B),a(I,L),a(L,ee),a(I,ae),m(o,ie,U),G(P,o,U),m(o,de,U),m(o,se,U),a(se,ne),a(se,S),a(S,oe),a(oe,d),a(se,F),m(o,re,U),G(le,o,U),m(o,O,U),m(o,K,U),a(K,ce),a(K,H),a(H,me),a(me,pe),a(K,fe),m(o,ge,U),G(ue,o,U),ye=!0},p(o,U){const he={};U&2&&(he.$$scope={dirty:U,ctx:o}),X.$set(he)},i(o){ye||(x(J.$$.fragment,o),x(X.$$.fragment,o),x(_.$$.fragment,o),x(P.$$.fragment,o),x(le.$$.fragment,o),x(ue.$$.fragment,o),ye=!0)},o(o){R(J.$$.fragment,o),R(X.$$.fragment,o),R(_.$$.fragment,o),R(P.$$.fragment,o),R(le.$$.fragment,o),R(ue.$$.fragment,o),ye=!1},d(o){o&&s(t),o&&s(A),z(J,o),o&&s(V),z(X,o),o&&s(D),o&&s(W),o&&s(y),z(_,o),o&&s(Y),o&&s(I),o&&s(ie),z(P,o),o&&s(de),o&&s(se),o&&s(re),z(le,o),o&&s(O),o&&s(K),o&&s(ge),z(ue,o)}}}function Zn(N){let t,j;return t=new Ga({props:{$$slots:{default:[zn]},$$scope:{ctx:N}}}),{c(){k(t.$$.fragment)},l(r){C(t.$$.fragment,r)},m(r,g){G(t,r,g),j=!0},p(r,g){const E={};g&2&&(E.$$scope={dirty:g,ctx:r}),t.$set(E)},i(r){j||(x(t.$$.fragment,r),j=!0)},o(r){R(t.$$.fragment,r),j=!1},d(r){z(t,r)}}}function In(N){let t,j,r,g,E,M,$,v;return{c(){t=p("p"),j=l(`Para un ejemplo m\xE1s profundo sobre c\xF3mo realizar el fine-tuning sobre un modelo de lenguaje causal, considera
`),r=p("a"),g=l("PyTorch notebook"),E=l(`
o `),M=p("a"),$=l("TensorFlow notebook"),v=l("."),this.h()},l(b){t=i(b,"P",{});var T=c(t);j=n(T,`Para un ejemplo m\xE1s profundo sobre c\xF3mo realizar el fine-tuning sobre un modelo de lenguaje causal, considera
`),r=i(T,"A",{href:!0,rel:!0});var Z=c(r);g=n(Z,"PyTorch notebook"),Z.forEach(s),E=n(T,`
o `),M=i(T,"A",{href:!0,rel:!0});var q=c(M);$=n(q,"TensorFlow notebook"),q.forEach(s),v=n(T,"."),T.forEach(s),this.h()},h(){w(r,"href","https://colab.research.google.com/github/huggingface/notebooks/blob/main/examples/language_modeling.ipynb"),w(r,"rel","nofollow"),w(M,"href","https://colab.research.google.com/github/huggingface/notebooks/blob/main/examples/language_modeling-tf.ipynb"),w(M,"rel","nofollow")},m(b,T){m(b,t,T),a(t,j),a(t,r),a(r,g),a(t,E),a(t,M),a(M,$),a(t,v)},d(b){b&&s(t)}}}function Fn(N){let t,j,r,g,E,M,$,v,b,T,Z,q,A,J,V,X,D,W,Q,y,_,Y,I,B,L,ee,ae,ie,P,de,se,ne,S,oe,d,F,re,le,O,K,ce,H,me,pe,fe,ge,ue,ye,o,U,he,we,ke,Te,Ie,Me,Ee,je,Je,Fe,$e,Ue,Ce,ve,at,xa,st,tt,Ra,lt,nt,za,ot,rt,ms,We,Ye,Za,la,pt,Ia,it,ds,na,us,De,ct,Fa,mt,dt,fs,oa,hs,ra,gs,Ua,ut,ys,pa,Ms,Ge,ft,Wa,ht,gt,ia,Va,yt,Mt,js,ca,$s,xe,jt,Xa,$t,bt,Aa,_t,wt,bs,Ta,Et,_s,ma,ws,be,Ut,da,qa,Tt,Jt,Ya,vt,kt,Da,Ct,Gt,Ba,xt,Rt,Es,ua,Us,Ja,zt,Ts,Be,Qa,Zt,It,fa,Ft,Na,Wt,Vt,Js,ha,vs,Qe,Xt,Pa,At,qt,ks,ga,Cs,_e,Yt,Sa,Dt,Bt,Ha,Qt,Nt,La,Pt,St,Oa,Ht,Lt,Gs,Ne,xs,Ve,Pe,Ka,ya,Ot,es,Kt,Rs,Se,el,Ma,al,sl,zs,Xe,He,as,ja,tl,ss,ll,Zs,Le,Is,Ae,Oe,ts,$a,nl,ls,ol,Fs,Ke,rl,ba,pl,il,Ws,qe,ea,ns,_a,cl,os,ml,Vs,aa,Xs,sa,As;return M=new Ea({}),J=new et({props:{id:"Vpjb1lu0MDk"}}),Q=new et({props:{id:"mqElG5QJWUg"}}),O=new Ca({props:{$$slots:{default:[jn]},$$scope:{ctx:N}}}),pe=new Ea({}),we=new te({props:{code:"ZnJvbSUyMGRhdGFzZXRzJTIwaW1wb3J0JTIwbG9hZF9kYXRhc2V0JTBBJTBBZWxpNSUyMCUzRCUyMGxvYWRfZGF0YXNldCglMjJlbGk1JTIyJTJDJTIwc3BsaXQlM0QlMjJ0cmFpbl9hc2tzJTVCJTNBNTAwMCU1RCUyMik=",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>eli5 = load_dataset(<span class="hljs-string">&quot;eli5&quot;</span>, split=<span class="hljs-string">&quot;train_asks[:5000]&quot;</span>)`}}),Ee=new te({props:{code:"ZWxpNSUyMCUzRCUyMGVsaTUudHJhaW5fdGVzdF9zcGxpdCh0ZXN0X3NpemUlM0QwLjIp",highlighted:'eli5 = eli5.train_test_split(test_size=<span class="hljs-number">0.2</span>)'}}),Ue=new te({props:{code:"ZWxpNSU1QiUyMnRyYWluJTIyJTVEJTVCMCU1RA==",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span>eli5[<span class="hljs-string">&quot;train&quot;</span>][<span class="hljs-number">0</span>]
{<span class="hljs-string">&#x27;answers&#x27;</span>: {<span class="hljs-string">&#x27;a_id&#x27;</span>: [<span class="hljs-string">&#x27;c3d1aib&#x27;</span>, <span class="hljs-string">&#x27;c3d4lya&#x27;</span>],
  <span class="hljs-string">&#x27;score&#x27;</span>: [<span class="hljs-number">6</span>, <span class="hljs-number">3</span>],
  <span class="hljs-string">&#x27;text&#x27;</span>: [<span class="hljs-string">&quot;The velocity needed to remain in orbit is equal to the square root of Newton&#x27;s constant times the mass of earth divided by the distance from the center of the earth. I don&#x27;t know the altitude of that specific mission, but they&#x27;re usually around 300 km. That means he&#x27;s going 7-8 km/s.\\n\\nIn space there are no other forces acting on either the shuttle or the guy, so they stay in the same position relative to each other. If he were to become unable to return to the ship, he would presumably run out of oxygen, or slowly fall into the atmosphere and burn up.&quot;</span>,
   <span class="hljs-string">&quot;Hope you don&#x27;t mind me asking another question, but why aren&#x27;t there any stars visible in this photo?&quot;</span>]},
 <span class="hljs-string">&#x27;answers_urls&#x27;</span>: {<span class="hljs-string">&#x27;url&#x27;</span>: []},
 <span class="hljs-string">&#x27;document&#x27;</span>: <span class="hljs-string">&#x27;&#x27;</span>,
 <span class="hljs-string">&#x27;q_id&#x27;</span>: <span class="hljs-string">&#x27;nyxfp&#x27;</span>,
 <span class="hljs-string">&#x27;selftext&#x27;</span>: <span class="hljs-string">&#x27;_URL_0_\\n\\nThis was on the front page earlier and I have a few questions about it. Is it possible to calculate how fast the astronaut would be orbiting the earth? Also how does he stay close to the shuttle so that he can return safely, i.e is he orbiting at the same speed and can therefore stay next to it? And finally if his propulsion system failed, would he eventually re-enter the atmosphere and presumably die?&#x27;</span>,
 <span class="hljs-string">&#x27;selftext_urls&#x27;</span>: {<span class="hljs-string">&#x27;url&#x27;</span>: [<span class="hljs-string">&#x27;http://apod.nasa.gov/apod/image/1201/freeflyer_nasa_3000.jpg&#x27;</span>]},
 <span class="hljs-string">&#x27;subreddit&#x27;</span>: <span class="hljs-string">&#x27;askscience&#x27;</span>,
 <span class="hljs-string">&#x27;title&#x27;</span>: <span class="hljs-string">&#x27;Few questions about this space walk photograph.&#x27;</span>,
 <span class="hljs-string">&#x27;title_urls&#x27;</span>: {<span class="hljs-string">&#x27;url&#x27;</span>: []}}`}}),la=new Ea({}),na=new et({props:{id:"ma1TrR7gE7I"}}),oa=new te({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMEF1dG9Ub2tlbml6ZXIlMEElMEF0b2tlbml6ZXIlMjAlM0QlMjBBdXRvVG9rZW5pemVyLmZyb21fcHJldHJhaW5lZCglMjJkaXN0aWxncHQyJTIyKQ==",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;distilgpt2&quot;</span>)`}}),ra=new et({props:{id:"8PmhEIXhBvI"}}),pa=new te({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMEF1dG9Ub2tlbml6ZXIlMEElMEF0b2tlbml6ZXIlMjAlM0QlMjBBdXRvVG9rZW5pemVyLmZyb21fcHJldHJhaW5lZCglMjJkaXN0aWxyb2JlcnRhLWJhc2UlMjIp",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;distilroberta-base&quot;</span>)`}}),ca=new te({props:{code:"ZWxpNSUyMCUzRCUyMGVsaTUuZmxhdHRlbigpJTBBZWxpNSU1QiUyMnRyYWluJTIyJTVEJTVCMCU1RA==",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span>eli5 = eli5.flatten()
<span class="hljs-meta">&gt;&gt;&gt; </span>eli5[<span class="hljs-string">&quot;train&quot;</span>][<span class="hljs-number">0</span>]
{<span class="hljs-string">&#x27;answers.a_id&#x27;</span>: [<span class="hljs-string">&#x27;c3d1aib&#x27;</span>, <span class="hljs-string">&#x27;c3d4lya&#x27;</span>],
 <span class="hljs-string">&#x27;answers.score&#x27;</span>: [<span class="hljs-number">6</span>, <span class="hljs-number">3</span>],
 <span class="hljs-string">&#x27;answers.text&#x27;</span>: [<span class="hljs-string">&quot;The velocity needed to remain in orbit is equal to the square root of Newton&#x27;s constant times the mass of earth divided by the distance from the center of the earth. I don&#x27;t know the altitude of that specific mission, but they&#x27;re usually around 300 km. That means he&#x27;s going 7-8 km/s.\\n\\nIn space there are no other forces acting on either the shuttle or the guy, so they stay in the same position relative to each other. If he were to become unable to return to the ship, he would presumably run out of oxygen, or slowly fall into the atmosphere and burn up.&quot;</span>,
  <span class="hljs-string">&quot;Hope you don&#x27;t mind me asking another question, but why aren&#x27;t there any stars visible in this photo?&quot;</span>],
 <span class="hljs-string">&#x27;answers_urls.url&#x27;</span>: [],
 <span class="hljs-string">&#x27;document&#x27;</span>: <span class="hljs-string">&#x27;&#x27;</span>,
 <span class="hljs-string">&#x27;q_id&#x27;</span>: <span class="hljs-string">&#x27;nyxfp&#x27;</span>,
 <span class="hljs-string">&#x27;selftext&#x27;</span>: <span class="hljs-string">&#x27;_URL_0_\\n\\nThis was on the front page earlier and I have a few questions about it. Is it possible to calculate how fast the astronaut would be orbiting the earth? Also how does he stay close to the shuttle so that he can return safely, i.e is he orbiting at the same speed and can therefore stay next to it? And finally if his propulsion system failed, would he eventually re-enter the atmosphere and presumably die?&#x27;</span>,
 <span class="hljs-string">&#x27;selftext_urls.url&#x27;</span>: [<span class="hljs-string">&#x27;http://apod.nasa.gov/apod/image/1201/freeflyer_nasa_3000.jpg&#x27;</span>],
 <span class="hljs-string">&#x27;subreddit&#x27;</span>: <span class="hljs-string">&#x27;askscience&#x27;</span>,
 <span class="hljs-string">&#x27;title&#x27;</span>: <span class="hljs-string">&#x27;Few questions about this space walk photograph.&#x27;</span>,
 <span class="hljs-string">&#x27;title_urls.url&#x27;</span>: []}`}}),ma=new te({props:{code:"ZGVmJTIwcHJlcHJvY2Vzc19mdW5jdGlvbihleGFtcGxlcyklM0ElMEElMjAlMjAlMjAlMjByZXR1cm4lMjB0b2tlbml6ZXIoJTVCJTIyJTIwJTIyLmpvaW4oeCklMjBmb3IlMjB4JTIwaW4lMjBleGFtcGxlcyU1QiUyMmFuc3dlcnMudGV4dCUyMiU1RCU1RCUyQyUyMHRydW5jYXRpb24lM0RUcnVlKQ==",highlighted:`<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>    <span class="hljs-keyword">return</span> tokenizer([<span class="hljs-string">&quot; &quot;</span>.join(x) <span class="hljs-keyword">for</span> x <span class="hljs-keyword">in</span> examples[<span class="hljs-string">&quot;answers.text&quot;</span>]], truncation=<span class="hljs-literal">True</span>)`}}),ua=new te({props:{code:"dG9rZW5pemVkX2VsaTUlMjAlM0QlMjBlbGk1Lm1hcCglMEElMjAlMjAlMjAlMjBwcmVwcm9jZXNzX2Z1bmN0aW9uJTJDJTBBJTIwJTIwJTIwJTIwYmF0Y2hlZCUzRFRydWUlMkMlMEElMjAlMjAlMjAlMjBudW1fcHJvYyUzRDQlMkMlMEElMjAlMjAlMjAlMjByZW1vdmVfY29sdW1ucyUzRGVsaTUlNUIlMjJ0cmFpbiUyMiU1RC5jb2x1bW5fbmFtZXMlMkMlMEEp",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span>tokenized_eli5 = eli5.<span class="hljs-built_in">map</span>(
<span class="hljs-meta">... </span>    preprocess_function,
<span class="hljs-meta">... </span>    batched=<span class="hljs-literal">True</span>,
<span class="hljs-meta">... </span>    num_proc=<span class="hljs-number">4</span>,
<span class="hljs-meta">... </span>    remove_columns=eli5[<span class="hljs-string">&quot;train&quot;</span>].column_names,
<span class="hljs-meta">... </span>)`}}),ha=new te({props:{code:"YmxvY2tfc2l6ZSUyMCUzRCUyMDEyOCUwQSUwQSUwQWRlZiUyMGdyb3VwX3RleHRzKGV4YW1wbGVzKSUzQSUwQSUyMCUyMCUyMCUyMGNvbmNhdGVuYXRlZF9leGFtcGxlcyUyMCUzRCUyMCU3QmslM0ElMjBzdW0oZXhhbXBsZXMlNUJrJTVEJTJDJTIwJTVCJTVEKSUyMGZvciUyMGslMjBpbiUyMGV4YW1wbGVzLmtleXMoKSU3RCUwQSUyMCUyMCUyMCUyMHRvdGFsX2xlbmd0aCUyMCUzRCUyMGxlbihjb25jYXRlbmF0ZWRfZXhhbXBsZXMlNUJsaXN0KGV4YW1wbGVzLmtleXMoKSklNUIwJTVEJTVEKSUwQSUyMCUyMCUyMCUyMHRvdGFsX2xlbmd0aCUyMCUzRCUyMCh0b3RhbF9sZW5ndGglMjAlMkYlMkYlMjBibG9ja19zaXplKSUyMColMjBibG9ja19zaXplJTBBJTIwJTIwJTIwJTIwcmVzdWx0JTIwJTNEJTIwJTdCJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwayUzQSUyMCU1QnQlNUJpJTIwJTNBJTIwaSUyMCUyQiUyMGJsb2NrX3NpemUlNUQlMjBmb3IlMjBpJTIwaW4lMjByYW5nZSgwJTJDJTIwdG90YWxfbGVuZ3RoJTJDJTIwYmxvY2tfc2l6ZSklNUQlMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjBmb3IlMjBrJTJDJTIwdCUyMGluJTIwY29uY2F0ZW5hdGVkX2V4YW1wbGVzLml0ZW1zKCklMEElMjAlMjAlMjAlMjAlN0QlMEElMjAlMjAlMjAlMjByZXN1bHQlNUIlMjJsYWJlbHMlMjIlNUQlMjAlM0QlMjByZXN1bHQlNUIlMjJpbnB1dF9pZHMlMjIlNUQuY29weSgpJTBBJTIwJTIwJTIwJTIwcmV0dXJuJTIwcmVzdWx0",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span>block_size = <span class="hljs-number">128</span>


<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">def</span> <span class="hljs-title function_">group_texts</span>(<span class="hljs-params">examples</span>):
<span class="hljs-meta">... </span>    concatenated_examples = {k: <span class="hljs-built_in">sum</span>(examples[k], []) <span class="hljs-keyword">for</span> k <span class="hljs-keyword">in</span> examples.keys()}
<span class="hljs-meta">... </span>    total_length = <span class="hljs-built_in">len</span>(concatenated_examples[<span class="hljs-built_in">list</span>(examples.keys())[<span class="hljs-number">0</span>]])
<span class="hljs-meta">... </span>    total_length = (total_length // block_size) * block_size
<span class="hljs-meta">... </span>    result = {
<span class="hljs-meta">... </span>        k: [t[i : i + block_size] <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>, total_length, block_size)]
<span class="hljs-meta">... </span>        <span class="hljs-keyword">for</span> k, t <span class="hljs-keyword">in</span> concatenated_examples.items()
<span class="hljs-meta">... </span>    }
<span class="hljs-meta">... </span>    result[<span class="hljs-string">&quot;labels&quot;</span>] = result[<span class="hljs-string">&quot;input_ids&quot;</span>].copy()
<span class="hljs-meta">... </span>    <span class="hljs-keyword">return</span> result`}}),ga=new te({props:{code:"bG1fZGF0YXNldCUyMCUzRCUyMHRva2VuaXplZF9lbGk1Lm1hcChncm91cF90ZXh0cyUyQyUyMGJhdGNoZWQlM0RUcnVlJTJDJTIwbnVtX3Byb2MlM0Q0KQ==",highlighted:'<span class="hljs-meta">&gt;&gt;&gt; </span>lm_dataset = tokenized_eli5.<span class="hljs-built_in">map</span>(group_texts, batched=<span class="hljs-literal">True</span>, num_proc=<span class="hljs-number">4</span>)'}}),Ne=new dl({props:{pytorch:!0,tensorflow:!0,jax:!1,$$slots:{tensorflow:[wn],pytorch:[bn]},$$scope:{ctx:N}}}),ya=new Ea({}),ja=new Ea({}),Le=new dl({props:{pytorch:!0,tensorflow:!0,jax:!1,$$slots:{tensorflow:[kn],pytorch:[Tn]},$$scope:{ctx:N}}}),$a=new Ea({}),_a=new Ea({}),aa=new dl({props:{pytorch:!0,tensorflow:!0,jax:!1,$$slots:{tensorflow:[Zn],pytorch:[xn]},$$scope:{ctx:N}}}),sa=new Ca({props:{$$slots:{default:[In]},$$scope:{ctx:N}}}),{c(){t=p("meta"),j=f(),r=p("h1"),g=p("a"),E=p("span"),k(M.$$.fragment),$=f(),v=p("span"),b=l("Modelado de lenguaje"),T=f(),Z=p("p"),q=l("El modelado de lenguaje predice palabras en un enunciado. Hay dos formas de modelado de lenguaje."),A=f(),k(J.$$.fragment),V=f(),X=p("p"),D=l("El modelado de lenguaje causal predice el siguiente token en una secuencia de tokens, y el modelo solo puede considerar los tokens a la izquierda."),W=f(),k(Q.$$.fragment),y=f(),_=p("p"),Y=l("El modelado de lenguaje por enmascaramiento predice un token enmascarado en una secuencia, y el modelo puede considerar los tokens bidireccionalmente."),I=f(),B=p("p"),L=l("Esta gu\xEDa te mostrar\xE1 c\xF3mo realizar fine-tuning "),ee=p("a"),ae=l("DistilGPT2"),ie=l(" para modelos de lenguaje causales y "),P=p("a"),de=l("DistilRoBERTa"),se=l(" para modelos de lenguaje por enmascaramiento en el "),ne=p("a"),S=l("r/askscience"),oe=l(" subdataset "),d=p("a"),F=l("ELI5"),re=l("."),le=f(),k(O.$$.fragment),K=f(),ce=p("h2"),H=p("a"),me=p("span"),k(pe.$$.fragment),fe=f(),ge=p("span"),ue=l("Carga el dataset ELI5"),ye=f(),o=p("p"),U=l("Carga solo los primeros 5000 registros desde la biblioteca \u{1F917} Datasets, dado que es bastante grande:"),he=f(),k(we.$$.fragment),ke=f(),Te=p("p"),Ie=l("Divide este dataset en subdatasets para el entrenamiento y el test:"),Me=f(),k(Ee.$$.fragment),je=f(),Je=p("p"),Fe=l("Luego observa un ejemplo:"),$e=f(),k(Ue.$$.fragment),Ce=f(),ve=p("p"),at=l("Observa que "),xa=p("code"),st=l("text"),tt=l(" es un subcampo anidado dentro del diccionario "),Ra=p("code"),lt=l("answers"),nt=l(". Cuando preproceses el dataset, deber\xE1s extraer el subcampo "),za=p("code"),ot=l("text"),rt=l(" en una columna aparte."),ms=f(),We=p("h2"),Ye=p("a"),Za=p("span"),k(la.$$.fragment),pt=f(),Ia=p("span"),it=l("Preprocesamiento"),ds=f(),k(na.$$.fragment),us=f(),De=p("p"),ct=l("Para modelados de lenguaje causales carga el tokenizador DistilGPT2 para procesar el subcampo "),Fa=p("code"),mt=l("text"),dt=l(":"),fs=f(),k(oa.$$.fragment),hs=f(),k(ra.$$.fragment),gs=f(),Ua=p("p"),ut=l("Para modelados de lenguaje por enmascaramiento carga el tokenizador DistilRoBERTa, en lugar de DistilGPT2:"),ys=f(),k(pa.$$.fragment),Ms=f(),Ge=p("p"),ft=l("Extrae el subcampo "),Wa=p("code"),ht=l("text"),gt=l(" desde su estructura anidado con el m\xE9todo "),ia=p("a"),Va=p("code"),yt=l("flatten"),Mt=l(":"),js=f(),k(ca.$$.fragment),$s=f(),xe=p("p"),jt=l("Cada subcampo es ahora una columna separada, como lo indica el prefijo "),Xa=p("code"),$t=l("answers"),bt=l(". Observa que "),Aa=p("code"),_t=l("answers.text"),wt=l(" es una lista. En lugar de tokenizar cada enunciado por separado, convierte la lista en un string para tokenizarlos conjuntamente."),bs=f(),Ta=p("p"),Et=l("As\xED es como puedes crear una funci\xF3n de preprocesamiento para convertir la lista en una cadena y truncar las secuencias para que no superen la longitud m\xE1xima de input de DistilGPT2:"),_s=f(),k(ma.$$.fragment),ws=f(),be=p("p"),Ut=l("Usa de \u{1F917} Datasets la funci\xF3n "),da=p("a"),qa=p("code"),Tt=l("map"),Jt=l(" para aplicar la funci\xF3n de preprocesamiento sobre el dataset en su totalidad. Puedes acelerar la funci\xF3n "),Ya=p("code"),vt=l("map"),kt=l(" configurando el argumento "),Da=p("code"),Ct=l("batched=True"),Gt=l(" para procesar m\xFAltiples elementos del dataset a la vez y aumentar la cantidad de procesos con "),Ba=p("code"),xt=l("num_proc"),Rt=l(". Elimina las columnas que no necesitas:"),Es=f(),k(ua.$$.fragment),Us=f(),Ja=p("p"),zt=l("Ahora necesitas una segunda funci\xF3n de preprocesamiento para capturar el texto truncado de cualquier ejemplo demasiado largo para evitar cualquier p\xE9rdida de informaci\xF3n. Esta funci\xF3n de preprocesamiento deber\xEDa:"),Ts=f(),Be=p("ul"),Qa=p("li"),Zt=l("Concatenar todo el texto."),It=f(),fa=p("li"),Ft=l("Dividir el texto concatenado en trozos m\xE1s peque\xF1os definidos por un "),Na=p("code"),Wt=l("block_size"),Vt=l("."),Js=f(),k(ha.$$.fragment),vs=f(),Qe=p("p"),Xt=l("Aplica la funci\xF3n "),Pa=p("code"),At=l("group_texts"),qt=l(" sobre todo el dataset:"),ks=f(),k(ga.$$.fragment),Cs=f(),_e=p("p"),Yt=l("Para modelados de lenguaje causales, usa "),Sa=p("code"),Dt=l("DataCollatorForLanguageModeling"),Bt=l(" para crear un lote de ejemplos. Esto tambi\xE9n "),Ha=p("em"),Qt=l("rellenar\xE1 din\xE1micamente"),Nt=l(" tu texto a la dimensi\xF3n del elemento m\xE1s largo del lote para que de esta manera tengan largo uniforme. Si bien es posible rellenar tu texto en la funci\xF3n "),La=p("code"),Pt=l("tokenizer"),St=l(" mediante el argumento "),Oa=p("code"),Ht=l("padding=True"),Lt=l(", el rellenado din\xE1mico es m\xE1s eficiente."),Gs=f(),k(Ne.$$.fragment),xs=f(),Ve=p("h2"),Pe=p("a"),Ka=p("span"),k(ya.$$.fragment),Ot=f(),es=p("span"),Kt=l("Modelado de lenguaje causal"),Rs=f(),Se=p("p"),el=l("El modelado de lenguaje causal es frecuentemente utilizado para generaci\xF3n de texto. Esta secci\xF3n te muestra c\xF3mo realizar fine-tuning a "),Ma=p("a"),al=l("DistilGPT2"),sl=l(" para generar nuevo texto."),zs=f(),Xe=p("h3"),He=p("a"),as=p("span"),k(ja.$$.fragment),tl=f(),ss=p("span"),ll=l("Entrenamiento"),Zs=f(),k(Le.$$.fragment),Is=f(),Ae=p("h2"),Oe=p("a"),ts=p("span"),k($a.$$.fragment),nl=f(),ls=p("span"),ol=l("Modelado de lenguaje por enmascaramiento"),Fs=f(),Ke=p("p"),rl=l("El modelado de lenguaje por enmascaramiento es tambi\xE9n conocido como una tarea de rellenar la m\xE1scara, pues predice un token enmascarado dada una secuencia. Los modelos de lenguaje por enmascaramiento requieren una buena comprensi\xF3n del contexto de una secuencia entera, en lugar de solo el contexto a la izquierda. Esta secci\xF3n te ense\xF1a como realizar el fine-tuning de "),ba=p("a"),pl=l("DistilRoBERTa"),il=l(" para predecir una palabra enmascarada."),Ws=f(),qe=p("h3"),ea=p("a"),ns=p("span"),k(_a.$$.fragment),cl=f(),os=p("span"),ml=l("Entrenamiento"),Vs=f(),k(aa.$$.fragment),Xs=f(),k(sa.$$.fragment),this.h()},l(e){const u=yn('[data-svelte="svelte-1phssyn"]',document.head);t=i(u,"META",{name:!0,content:!0}),u.forEach(s),j=h(e),r=i(e,"H1",{class:!0});var wa=c(r);g=i(wa,"A",{id:!0,class:!0,href:!0});var rs=c(g);E=i(rs,"SPAN",{});var ps=c(E);C(M.$$.fragment,ps),ps.forEach(s),rs.forEach(s),$=h(wa),v=i(wa,"SPAN",{});var is=c(v);b=n(is,"Modelado de lenguaje"),is.forEach(s),wa.forEach(s),T=h(e),Z=i(e,"P",{});var cs=c(Z);q=n(cs,"El modelado de lenguaje predice palabras en un enunciado. Hay dos formas de modelado de lenguaje."),cs.forEach(s),A=h(e),C(J.$$.fragment,e),V=h(e),X=i(e,"P",{});var ul=c(X);D=n(ul,"El modelado de lenguaje causal predice el siguiente token en una secuencia de tokens, y el modelo solo puede considerar los tokens a la izquierda."),ul.forEach(s),W=h(e),C(Q.$$.fragment,e),y=h(e),_=i(e,"P",{});var fl=c(_);Y=n(fl,"El modelado de lenguaje por enmascaramiento predice un token enmascarado en una secuencia, y el modelo puede considerar los tokens bidireccionalmente."),fl.forEach(s),I=h(e),B=i(e,"P",{});var Re=c(B);L=n(Re,"Esta gu\xEDa te mostrar\xE1 c\xF3mo realizar fine-tuning "),ee=i(Re,"A",{href:!0,rel:!0});var hl=c(ee);ae=n(hl,"DistilGPT2"),hl.forEach(s),ie=n(Re," para modelos de lenguaje causales y "),P=i(Re,"A",{href:!0,rel:!0});var gl=c(P);de=n(gl,"DistilRoBERTa"),gl.forEach(s),se=n(Re," para modelos de lenguaje por enmascaramiento en el "),ne=i(Re,"A",{href:!0,rel:!0});var yl=c(ne);S=n(yl,"r/askscience"),yl.forEach(s),oe=n(Re," subdataset "),d=i(Re,"A",{href:!0,rel:!0});var Ml=c(d);F=n(Ml,"ELI5"),Ml.forEach(s),re=n(Re,"."),Re.forEach(s),le=h(e),C(O.$$.fragment,e),K=h(e),ce=i(e,"H2",{class:!0});var qs=c(ce);H=i(qs,"A",{id:!0,class:!0,href:!0});var jl=c(H);me=i(jl,"SPAN",{});var $l=c(me);C(pe.$$.fragment,$l),$l.forEach(s),jl.forEach(s),fe=h(qs),ge=i(qs,"SPAN",{});var bl=c(ge);ue=n(bl,"Carga el dataset ELI5"),bl.forEach(s),qs.forEach(s),ye=h(e),o=i(e,"P",{});var _l=c(o);U=n(_l,"Carga solo los primeros 5000 registros desde la biblioteca \u{1F917} Datasets, dado que es bastante grande:"),_l.forEach(s),he=h(e),C(we.$$.fragment,e),ke=h(e),Te=i(e,"P",{});var wl=c(Te);Ie=n(wl,"Divide este dataset en subdatasets para el entrenamiento y el test:"),wl.forEach(s),Me=h(e),C(Ee.$$.fragment,e),je=h(e),Je=i(e,"P",{});var El=c(Je);Fe=n(El,"Luego observa un ejemplo:"),El.forEach(s),$e=h(e),C(Ue.$$.fragment,e),Ce=h(e),ve=i(e,"P",{});var ta=c(ve);at=n(ta,"Observa que "),xa=i(ta,"CODE",{});var Ul=c(xa);st=n(Ul,"text"),Ul.forEach(s),tt=n(ta," es un subcampo anidado dentro del diccionario "),Ra=i(ta,"CODE",{});var Tl=c(Ra);lt=n(Tl,"answers"),Tl.forEach(s),nt=n(ta,". Cuando preproceses el dataset, deber\xE1s extraer el subcampo "),za=i(ta,"CODE",{});var Jl=c(za);ot=n(Jl,"text"),Jl.forEach(s),rt=n(ta," en una columna aparte."),ta.forEach(s),ms=h(e),We=i(e,"H2",{class:!0});var Ys=c(We);Ye=i(Ys,"A",{id:!0,class:!0,href:!0});var vl=c(Ye);Za=i(vl,"SPAN",{});var kl=c(Za);C(la.$$.fragment,kl),kl.forEach(s),vl.forEach(s),pt=h(Ys),Ia=i(Ys,"SPAN",{});var Cl=c(Ia);it=n(Cl,"Preprocesamiento"),Cl.forEach(s),Ys.forEach(s),ds=h(e),C(na.$$.fragment,e),us=h(e),De=i(e,"P",{});var Ds=c(De);ct=n(Ds,"Para modelados de lenguaje causales carga el tokenizador DistilGPT2 para procesar el subcampo "),Fa=i(Ds,"CODE",{});var Gl=c(Fa);mt=n(Gl,"text"),Gl.forEach(s),dt=n(Ds,":"),Ds.forEach(s),fs=h(e),C(oa.$$.fragment,e),hs=h(e),C(ra.$$.fragment,e),gs=h(e),Ua=i(e,"P",{});var xl=c(Ua);ut=n(xl,"Para modelados de lenguaje por enmascaramiento carga el tokenizador DistilRoBERTa, en lugar de DistilGPT2:"),xl.forEach(s),ys=h(e),C(pa.$$.fragment,e),Ms=h(e),Ge=i(e,"P",{});var va=c(Ge);ft=n(va,"Extrae el subcampo "),Wa=i(va,"CODE",{});var Rl=c(Wa);ht=n(Rl,"text"),Rl.forEach(s),gt=n(va," desde su estructura anidado con el m\xE9todo "),ia=i(va,"A",{href:!0,rel:!0});var zl=c(ia);Va=i(zl,"CODE",{});var Zl=c(Va);yt=n(Zl,"flatten"),Zl.forEach(s),zl.forEach(s),Mt=n(va,":"),va.forEach(s),js=h(e),C(ca.$$.fragment,e),$s=h(e),xe=i(e,"P",{});var ka=c(xe);jt=n(ka,"Cada subcampo es ahora una columna separada, como lo indica el prefijo "),Xa=i(ka,"CODE",{});var Il=c(Xa);$t=n(Il,"answers"),Il.forEach(s),bt=n(ka,". Observa que "),Aa=i(ka,"CODE",{});var Fl=c(Aa);_t=n(Fl,"answers.text"),Fl.forEach(s),wt=n(ka," es una lista. En lugar de tokenizar cada enunciado por separado, convierte la lista en un string para tokenizarlos conjuntamente."),ka.forEach(s),bs=h(e),Ta=i(e,"P",{});var Wl=c(Ta);Et=n(Wl,"As\xED es como puedes crear una funci\xF3n de preprocesamiento para convertir la lista en una cadena y truncar las secuencias para que no superen la longitud m\xE1xima de input de DistilGPT2:"),Wl.forEach(s),_s=h(e),C(ma.$$.fragment,e),ws=h(e),be=i(e,"P",{});var ze=c(be);Ut=n(ze,"Usa de \u{1F917} Datasets la funci\xF3n "),da=i(ze,"A",{href:!0,rel:!0});var Vl=c(da);qa=i(Vl,"CODE",{});var Xl=c(qa);Tt=n(Xl,"map"),Xl.forEach(s),Vl.forEach(s),Jt=n(ze," para aplicar la funci\xF3n de preprocesamiento sobre el dataset en su totalidad. Puedes acelerar la funci\xF3n "),Ya=i(ze,"CODE",{});var Al=c(Ya);vt=n(Al,"map"),Al.forEach(s),kt=n(ze," configurando el argumento "),Da=i(ze,"CODE",{});var ql=c(Da);Ct=n(ql,"batched=True"),ql.forEach(s),Gt=n(ze," para procesar m\xFAltiples elementos del dataset a la vez y aumentar la cantidad de procesos con "),Ba=i(ze,"CODE",{});var Yl=c(Ba);xt=n(Yl,"num_proc"),Yl.forEach(s),Rt=n(ze,". Elimina las columnas que no necesitas:"),ze.forEach(s),Es=h(e),C(ua.$$.fragment,e),Us=h(e),Ja=i(e,"P",{});var Dl=c(Ja);zt=n(Dl,"Ahora necesitas una segunda funci\xF3n de preprocesamiento para capturar el texto truncado de cualquier ejemplo demasiado largo para evitar cualquier p\xE9rdida de informaci\xF3n. Esta funci\xF3n de preprocesamiento deber\xEDa:"),Dl.forEach(s),Ts=h(e),Be=i(e,"UL",{});var Bs=c(Be);Qa=i(Bs,"LI",{});var Bl=c(Qa);Zt=n(Bl,"Concatenar todo el texto."),Bl.forEach(s),It=h(Bs),fa=i(Bs,"LI",{});var Qs=c(fa);Ft=n(Qs,"Dividir el texto concatenado en trozos m\xE1s peque\xF1os definidos por un "),Na=i(Qs,"CODE",{});var Ql=c(Na);Wt=n(Ql,"block_size"),Ql.forEach(s),Vt=n(Qs,"."),Qs.forEach(s),Bs.forEach(s),Js=h(e),C(ha.$$.fragment,e),vs=h(e),Qe=i(e,"P",{});var Ns=c(Qe);Xt=n(Ns,"Aplica la funci\xF3n "),Pa=i(Ns,"CODE",{});var Nl=c(Pa);At=n(Nl,"group_texts"),Nl.forEach(s),qt=n(Ns," sobre todo el dataset:"),Ns.forEach(s),ks=h(e),C(ga.$$.fragment,e),Cs=h(e),_e=i(e,"P",{});var Ze=c(_e);Yt=n(Ze,"Para modelados de lenguaje causales, usa "),Sa=i(Ze,"CODE",{});var Pl=c(Sa);Dt=n(Pl,"DataCollatorForLanguageModeling"),Pl.forEach(s),Bt=n(Ze," para crear un lote de ejemplos. Esto tambi\xE9n "),Ha=i(Ze,"EM",{});var Sl=c(Ha);Qt=n(Sl,"rellenar\xE1 din\xE1micamente"),Sl.forEach(s),Nt=n(Ze," tu texto a la dimensi\xF3n del elemento m\xE1s largo del lote para que de esta manera tengan largo uniforme. Si bien es posible rellenar tu texto en la funci\xF3n "),La=i(Ze,"CODE",{});var Hl=c(La);Pt=n(Hl,"tokenizer"),Hl.forEach(s),St=n(Ze," mediante el argumento "),Oa=i(Ze,"CODE",{});var Ll=c(Oa);Ht=n(Ll,"padding=True"),Ll.forEach(s),Lt=n(Ze,", el rellenado din\xE1mico es m\xE1s eficiente."),Ze.forEach(s),Gs=h(e),C(Ne.$$.fragment,e),xs=h(e),Ve=i(e,"H2",{class:!0});var Ps=c(Ve);Pe=i(Ps,"A",{id:!0,class:!0,href:!0});var Ol=c(Pe);Ka=i(Ol,"SPAN",{});var Kl=c(Ka);C(ya.$$.fragment,Kl),Kl.forEach(s),Ol.forEach(s),Ot=h(Ps),es=i(Ps,"SPAN",{});var en=c(es);Kt=n(en,"Modelado de lenguaje causal"),en.forEach(s),Ps.forEach(s),Rs=h(e),Se=i(e,"P",{});var Ss=c(Se);el=n(Ss,"El modelado de lenguaje causal es frecuentemente utilizado para generaci\xF3n de texto. Esta secci\xF3n te muestra c\xF3mo realizar fine-tuning a "),Ma=i(Ss,"A",{href:!0,rel:!0});var an=c(Ma);al=n(an,"DistilGPT2"),an.forEach(s),sl=n(Ss," para generar nuevo texto."),Ss.forEach(s),zs=h(e),Xe=i(e,"H3",{class:!0});var Hs=c(Xe);He=i(Hs,"A",{id:!0,class:!0,href:!0});var sn=c(He);as=i(sn,"SPAN",{});var tn=c(as);C(ja.$$.fragment,tn),tn.forEach(s),sn.forEach(s),tl=h(Hs),ss=i(Hs,"SPAN",{});var ln=c(ss);ll=n(ln,"Entrenamiento"),ln.forEach(s),Hs.forEach(s),Zs=h(e),C(Le.$$.fragment,e),Is=h(e),Ae=i(e,"H2",{class:!0});var Ls=c(Ae);Oe=i(Ls,"A",{id:!0,class:!0,href:!0});var nn=c(Oe);ts=i(nn,"SPAN",{});var on=c(ts);C($a.$$.fragment,on),on.forEach(s),nn.forEach(s),nl=h(Ls),ls=i(Ls,"SPAN",{});var rn=c(ls);ol=n(rn,"Modelado de lenguaje por enmascaramiento"),rn.forEach(s),Ls.forEach(s),Fs=h(e),Ke=i(e,"P",{});var Os=c(Ke);rl=n(Os,"El modelado de lenguaje por enmascaramiento es tambi\xE9n conocido como una tarea de rellenar la m\xE1scara, pues predice un token enmascarado dada una secuencia. Los modelos de lenguaje por enmascaramiento requieren una buena comprensi\xF3n del contexto de una secuencia entera, en lugar de solo el contexto a la izquierda. Esta secci\xF3n te ense\xF1a como realizar el fine-tuning de "),ba=i(Os,"A",{href:!0,rel:!0});var pn=c(ba);pl=n(pn,"DistilRoBERTa"),pn.forEach(s),il=n(Os," para predecir una palabra enmascarada."),Os.forEach(s),Ws=h(e),qe=i(e,"H3",{class:!0});var Ks=c(qe);ea=i(Ks,"A",{id:!0,class:!0,href:!0});var cn=c(ea);ns=i(cn,"SPAN",{});var mn=c(ns);C(_a.$$.fragment,mn),mn.forEach(s),cn.forEach(s),cl=h(Ks),os=i(Ks,"SPAN",{});var dn=c(os);ml=n(dn,"Entrenamiento"),dn.forEach(s),Ks.forEach(s),Vs=h(e),C(aa.$$.fragment,e),Xs=h(e),C(sa.$$.fragment,e),this.h()},h(){w(t,"name","hf:doc:metadata"),w(t,"content",JSON.stringify(Wn)),w(g,"id","modelado-de-lenguaje"),w(g,"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"),w(g,"href","#modelado-de-lenguaje"),w(r,"class","relative group"),w(ee,"href","https://huggingface.co/distilgpt2"),w(ee,"rel","nofollow"),w(P,"href","https://huggingface.co/distilroberta-base"),w(P,"rel","nofollow"),w(ne,"href","https://www.reddit.com/r/askscience/"),w(ne,"rel","nofollow"),w(d,"href","https://huggingface.co/datasets/eli5"),w(d,"rel","nofollow"),w(H,"id","carga-el-dataset-eli5"),w(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"),w(H,"href","#carga-el-dataset-eli5"),w(ce,"class","relative group"),w(Ye,"id","preprocesamiento"),w(Ye,"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"),w(Ye,"href","#preprocesamiento"),w(We,"class","relative group"),w(ia,"href","https://huggingface.co/docs/datasets/process.html#flatten"),w(ia,"rel","nofollow"),w(da,"href","https://huggingface.co/docs/datasets/package_reference/main_classes.html#datasets.Dataset.map"),w(da,"rel","nofollow"),w(Pe,"id","modelado-de-lenguaje-causal"),w(Pe,"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"),w(Pe,"href","#modelado-de-lenguaje-causal"),w(Ve,"class","relative group"),w(Ma,"href","https://huggingface.co/distilgpt2"),w(Ma,"rel","nofollow"),w(He,"id","entrenamiento"),w(He,"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"),w(He,"href","#entrenamiento"),w(Xe,"class","relative group"),w(Oe,"id","modelado-de-lenguaje-por-enmascaramiento"),w(Oe,"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"),w(Oe,"href","#modelado-de-lenguaje-por-enmascaramiento"),w(Ae,"class","relative group"),w(ba,"href","https://huggingface.co/distilroberta-base"),w(ba,"rel","nofollow"),w(ea,"id","entrenamiento"),w(ea,"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"),w(ea,"href","#entrenamiento"),w(qe,"class","relative group")},m(e,u){a(document.head,t),m(e,j,u),m(e,r,u),a(r,g),a(g,E),G(M,E,null),a(r,$),a(r,v),a(v,b),m(e,T,u),m(e,Z,u),a(Z,q),m(e,A,u),G(J,e,u),m(e,V,u),m(e,X,u),a(X,D),m(e,W,u),G(Q,e,u),m(e,y,u),m(e,_,u),a(_,Y),m(e,I,u),m(e,B,u),a(B,L),a(B,ee),a(ee,ae),a(B,ie),a(B,P),a(P,de),a(B,se),a(B,ne),a(ne,S),a(B,oe),a(B,d),a(d,F),a(B,re),m(e,le,u),G(O,e,u),m(e,K,u),m(e,ce,u),a(ce,H),a(H,me),G(pe,me,null),a(ce,fe),a(ce,ge),a(ge,ue),m(e,ye,u),m(e,o,u),a(o,U),m(e,he,u),G(we,e,u),m(e,ke,u),m(e,Te,u),a(Te,Ie),m(e,Me,u),G(Ee,e,u),m(e,je,u),m(e,Je,u),a(Je,Fe),m(e,$e,u),G(Ue,e,u),m(e,Ce,u),m(e,ve,u),a(ve,at),a(ve,xa),a(xa,st),a(ve,tt),a(ve,Ra),a(Ra,lt),a(ve,nt),a(ve,za),a(za,ot),a(ve,rt),m(e,ms,u),m(e,We,u),a(We,Ye),a(Ye,Za),G(la,Za,null),a(We,pt),a(We,Ia),a(Ia,it),m(e,ds,u),G(na,e,u),m(e,us,u),m(e,De,u),a(De,ct),a(De,Fa),a(Fa,mt),a(De,dt),m(e,fs,u),G(oa,e,u),m(e,hs,u),G(ra,e,u),m(e,gs,u),m(e,Ua,u),a(Ua,ut),m(e,ys,u),G(pa,e,u),m(e,Ms,u),m(e,Ge,u),a(Ge,ft),a(Ge,Wa),a(Wa,ht),a(Ge,gt),a(Ge,ia),a(ia,Va),a(Va,yt),a(Ge,Mt),m(e,js,u),G(ca,e,u),m(e,$s,u),m(e,xe,u),a(xe,jt),a(xe,Xa),a(Xa,$t),a(xe,bt),a(xe,Aa),a(Aa,_t),a(xe,wt),m(e,bs,u),m(e,Ta,u),a(Ta,Et),m(e,_s,u),G(ma,e,u),m(e,ws,u),m(e,be,u),a(be,Ut),a(be,da),a(da,qa),a(qa,Tt),a(be,Jt),a(be,Ya),a(Ya,vt),a(be,kt),a(be,Da),a(Da,Ct),a(be,Gt),a(be,Ba),a(Ba,xt),a(be,Rt),m(e,Es,u),G(ua,e,u),m(e,Us,u),m(e,Ja,u),a(Ja,zt),m(e,Ts,u),m(e,Be,u),a(Be,Qa),a(Qa,Zt),a(Be,It),a(Be,fa),a(fa,Ft),a(fa,Na),a(Na,Wt),a(fa,Vt),m(e,Js,u),G(ha,e,u),m(e,vs,u),m(e,Qe,u),a(Qe,Xt),a(Qe,Pa),a(Pa,At),a(Qe,qt),m(e,ks,u),G(ga,e,u),m(e,Cs,u),m(e,_e,u),a(_e,Yt),a(_e,Sa),a(Sa,Dt),a(_e,Bt),a(_e,Ha),a(Ha,Qt),a(_e,Nt),a(_e,La),a(La,Pt),a(_e,St),a(_e,Oa),a(Oa,Ht),a(_e,Lt),m(e,Gs,u),G(Ne,e,u),m(e,xs,u),m(e,Ve,u),a(Ve,Pe),a(Pe,Ka),G(ya,Ka,null),a(Ve,Ot),a(Ve,es),a(es,Kt),m(e,Rs,u),m(e,Se,u),a(Se,el),a(Se,Ma),a(Ma,al),a(Se,sl),m(e,zs,u),m(e,Xe,u),a(Xe,He),a(He,as),G(ja,as,null),a(Xe,tl),a(Xe,ss),a(ss,ll),m(e,Zs,u),G(Le,e,u),m(e,Is,u),m(e,Ae,u),a(Ae,Oe),a(Oe,ts),G($a,ts,null),a(Ae,nl),a(Ae,ls),a(ls,ol),m(e,Fs,u),m(e,Ke,u),a(Ke,rl),a(Ke,ba),a(ba,pl),a(Ke,il),m(e,Ws,u),m(e,qe,u),a(qe,ea),a(ea,ns),G(_a,ns,null),a(qe,cl),a(qe,os),a(os,ml),m(e,Vs,u),G(aa,e,u),m(e,Xs,u),G(sa,e,u),As=!0},p(e,[u]){const wa={};u&2&&(wa.$$scope={dirty:u,ctx:e}),O.$set(wa);const rs={};u&2&&(rs.$$scope={dirty:u,ctx:e}),Ne.$set(rs);const ps={};u&2&&(ps.$$scope={dirty:u,ctx:e}),Le.$set(ps);const is={};u&2&&(is.$$scope={dirty:u,ctx:e}),aa.$set(is);const cs={};u&2&&(cs.$$scope={dirty:u,ctx:e}),sa.$set(cs)},i(e){As||(x(M.$$.fragment,e),x(J.$$.fragment,e),x(Q.$$.fragment,e),x(O.$$.fragment,e),x(pe.$$.fragment,e),x(we.$$.fragment,e),x(Ee.$$.fragment,e),x(Ue.$$.fragment,e),x(la.$$.fragment,e),x(na.$$.fragment,e),x(oa.$$.fragment,e),x(ra.$$.fragment,e),x(pa.$$.fragment,e),x(ca.$$.fragment,e),x(ma.$$.fragment,e),x(ua.$$.fragment,e),x(ha.$$.fragment,e),x(ga.$$.fragment,e),x(Ne.$$.fragment,e),x(ya.$$.fragment,e),x(ja.$$.fragment,e),x(Le.$$.fragment,e),x($a.$$.fragment,e),x(_a.$$.fragment,e),x(aa.$$.fragment,e),x(sa.$$.fragment,e),As=!0)},o(e){R(M.$$.fragment,e),R(J.$$.fragment,e),R(Q.$$.fragment,e),R(O.$$.fragment,e),R(pe.$$.fragment,e),R(we.$$.fragment,e),R(Ee.$$.fragment,e),R(Ue.$$.fragment,e),R(la.$$.fragment,e),R(na.$$.fragment,e),R(oa.$$.fragment,e),R(ra.$$.fragment,e),R(pa.$$.fragment,e),R(ca.$$.fragment,e),R(ma.$$.fragment,e),R(ua.$$.fragment,e),R(ha.$$.fragment,e),R(ga.$$.fragment,e),R(Ne.$$.fragment,e),R(ya.$$.fragment,e),R(ja.$$.fragment,e),R(Le.$$.fragment,e),R($a.$$.fragment,e),R(_a.$$.fragment,e),R(aa.$$.fragment,e),R(sa.$$.fragment,e),As=!1},d(e){s(t),e&&s(j),e&&s(r),z(M),e&&s(T),e&&s(Z),e&&s(A),z(J,e),e&&s(V),e&&s(X),e&&s(W),z(Q,e),e&&s(y),e&&s(_),e&&s(I),e&&s(B),e&&s(le),z(O,e),e&&s(K),e&&s(ce),z(pe),e&&s(ye),e&&s(o),e&&s(he),z(we,e),e&&s(ke),e&&s(Te),e&&s(Me),z(Ee,e),e&&s(je),e&&s(Je),e&&s($e),z(Ue,e),e&&s(Ce),e&&s(ve),e&&s(ms),e&&s(We),z(la),e&&s(ds),z(na,e),e&&s(us),e&&s(De),e&&s(fs),z(oa,e),e&&s(hs),z(ra,e),e&&s(gs),e&&s(Ua),e&&s(ys),z(pa,e),e&&s(Ms),e&&s(Ge),e&&s(js),z(ca,e),e&&s($s),e&&s(xe),e&&s(bs),e&&s(Ta),e&&s(_s),z(ma,e),e&&s(ws),e&&s(be),e&&s(Es),z(ua,e),e&&s(Us),e&&s(Ja),e&&s(Ts),e&&s(Be),e&&s(Js),z(ha,e),e&&s(vs),e&&s(Qe),e&&s(ks),z(ga,e),e&&s(Cs),e&&s(_e),e&&s(Gs),z(Ne,e),e&&s(xs),e&&s(Ve),z(ya),e&&s(Rs),e&&s(Se),e&&s(zs),e&&s(Xe),z(ja),e&&s(Zs),z(Le,e),e&&s(Is),e&&s(Ae),z($a),e&&s(Fs),e&&s(Ke),e&&s(Ws),e&&s(qe),z(_a),e&&s(Vs),z(aa,e),e&&s(Xs),z(sa,e)}}}const Wn={local:"modelado-de-lenguaje",sections:[{local:"carga-el-dataset-eli5",title:"Carga el dataset ELI5"},{local:"preprocesamiento",title:"Preprocesamiento"},{local:"modelado-de-lenguaje-causal",sections:[{local:"entrenamiento",title:"Entrenamiento"}],title:"Modelado de lenguaje causal"},{local:"modelado-de-lenguaje-por-enmascaramiento",sections:[{local:"entrenamiento",title:"Entrenamiento"}],title:"Modelado de lenguaje por enmascaramiento"}],title:"Modelado de lenguaje"};function Vn(N){return Mn(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class Nn extends fn{constructor(t){super();hn(this,t,Vn,Fn,gn,{})}}export{Nn as default,Wn as metadata};
